1 line
46 KiB
JavaScript
1 line
46 KiB
JavaScript
"use strict";(self.webpackChunk_woocommerce_storybook=self.webpackChunk_woocommerce_storybook||[]).push([[7452],{"../../packages/js/components/src/experimental-tree-control/linked-tree-utils.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{TN:()=>toggleNode,VW:()=>countNumberOfNodes,YD:()=>createLinkedTree,g_:()=>getNodeDataByIndex,p_:()=>getVisibleNodeIndex});var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/defineProperty.js");__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.some.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.exec.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.constructor.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.map.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.slice.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.date.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.name.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.from.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.description.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.is-array.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.keys.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.filter.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptor.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptors.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-properties.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-property.js");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){(0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function _createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function _unsupportedIterableToArray(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function F(){};return{s:F,n:function n(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();return normalCompletion=step.done,step},e:function e(_e2){didErr=!0,err=_e2},f:function f(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}var shouldItemBeExpanded=function shouldItemBeExpanded(item,createValue){var _item$children;return!(!createValue||null===(_item$children=item.children)||void 0===_item$children||!_item$children.length)&&item.children.some((function(child){return!!new RegExp(createValue||"","ig").test(child.data.label)||shouldItemBeExpanded(child,createValue)}))};function findChildren(items){var memo=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},parent=arguments.length>2?arguments[2]:void 0,createValue=arguments.length>3?arguments[3]:void 0,children=[],others=[];return items.forEach((function(item){item.parent===parent?children.push(item):others.push(item),memo[item.value]={parent:void 0,data:item,children:[]}})),children.map((function(child){var linkedTree=memo[child.value];return linkedTree.parent=child.parent?memo[child.parent]:void 0,linkedTree.children=findChildren(others,memo,child.value,createValue),linkedTree.data.isExpanded=0===linkedTree.children.length||shouldItemBeExpanded(linkedTree,createValue),linkedTree}))}function createLinkedTree(items,value){return function populateIndexes(linkedTree){var count=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function populate(tree){var _step,_iterator=_createForOfIteratorHelper(tree);try{for(_iterator.s();!(_step=_iterator.n()).done;){var node=_step.value;node.index=count,count++,node.children&&(count=populate(node.children))}}catch(err){_iterator.e(err)}finally{_iterator.f()}return count}(linkedTree),linkedTree}(findChildren(items.map((function(i){return _objectSpread(_objectSpread({},i),{},{isExpanded:!1})})),{},void 0,value))}function toggleNode(tree,number,value){return tree.map((function(node){return _objectSpread(_objectSpread({},node),{},{children:node.children?toggleNode(node.children,number,value):node.children,data:_objectSpread(_objectSpread({},node.data),{},{isExpanded:node.index===number?value:node.data.isExpanded})},node.parent?{parent:_objectSpread(_objectSpread({},node.parent),{},{data:_objectSpread(_objectSpread({},node.parent.data),{},{isExpanded:node.parent.index===number?value:node.parent.data.isExpanded})})}:{})}))}function getVisibleNodeIndex(tree,highlightedIndex,direction){if("down"===direction){var _step2,_iterator2=_createForOfIteratorHelper(tree);try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var node=_step2.value;if(!node.parent||node.parent.data.isExpanded){if(void 0!==node.index&&node.index>=highlightedIndex)return node.index;var visibleNodeIndex=getVisibleNodeIndex(node.children,highlightedIndex,direction);if(void 0!==visibleNodeIndex)return visibleNodeIndex}}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}}else for(var i=tree.length-1;i>=0;i--){var _node=tree[i];if(!_node.parent||_node.parent.data.isExpanded){var _visibleNodeIndex=getVisibleNodeIndex(_node.children,highlightedIndex,direction);if(void 0!==_visibleNodeIndex)return _visibleNodeIndex;if(void 0!==_node.index&&_node.index<=highlightedIndex)return _node.index}}}function countNumberOfNodes(linkedTree){var _step3,count=0,_iterator3=_createForOfIteratorHelper(linkedTree);try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var node=_step3.value;count++,node.children&&(count+=countNumberOfNodes(node.children))}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}return count}function getNodeDataByIndex(linkedTree,index){var _step4,_iterator4=_createForOfIteratorHelper(linkedTree);try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var node=_step4.value;if(node.index===index)return node.data;if(node.children){var child=getNodeDataByIndex(node.children,index);if(child)return child}}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}}},"../../packages/js/components/src/experimental-tree-control/tree.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{P:()=>Tree});__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.keys.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.filter.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptor.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptors.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-properties.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-property.js");var esm_extends=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js"),defineProperty=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/defineProperty.js"),react=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),build_module_button=(__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.map.js"),__webpack_require__("../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/button/index.js")),icon=__webpack_require__("../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/icon/index.js"),build_module=__webpack_require__("../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js"),classnames=__webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js"),classnames_default=__webpack_require__.n(classnames),plus=__webpack_require__("../../node_modules/.pnpm/@wordpress+icons@8.2.3/node_modules/@wordpress/icons/build-module/library/plus.js"),use_merge_refs=__webpack_require__("../../node_modules/.pnpm/@wordpress+compose@5.4.1_react@17.0.2/node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js"),objectWithoutProperties=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),_excluded=["items","level","role","multiple","selected","getItemLabel","shouldItemBeExpanded","shouldItemBeHighlighted","onSelect","onRemove","shouldNotRecursivelySelect","createValue","onTreeBlur","onCreateNew","shouldShowCreateButton","onFirstItemLoop","onEscape","highlightedIndex","onExpand"];function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){(0,defineProperty.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var checkbox_control=__webpack_require__("../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/checkbox-control/index.js"),chevron_up=__webpack_require__("../../node_modules/.pnpm/@wordpress+icons@8.2.3/node_modules/@wordpress/icons/build-module/library/chevron-up.js"),chevron_down=__webpack_require__("../../node_modules/.pnpm/@wordpress+icons@8.2.3/node_modules/@wordpress/icons/build-module/library/chevron-down.js"),html_entities_build_module=__webpack_require__("../../node_modules/.pnpm/@wordpress+html-entities@3.6.1/node_modules/@wordpress/html-entities/build-module/index.js"),use_instance_id=__webpack_require__("../../node_modules/.pnpm/@wordpress+compose@5.4.1_react@17.0.2/node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js"),slicedToArray=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/slicedToArray.js");__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.slice.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.date.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.to-string.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.name.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.from.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.exec.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.description.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.iterator.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.is-array.js");function _createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function _unsupportedIterableToArray(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function F(){};return{s:F,n:function n(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();return normalCompletion=step.done,step},e:function e(_e2){didErr=!0,err=_e2},f:function f(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function getAllHeadings(currentHeading){var rootTree=currentHeading.closest(".experimental-woocommerce-tree--level-1");return null==rootTree?void 0:rootTree.querySelectorAll(".experimental-woocommerce-tree-item > .experimental-woocommerce-tree-item__heading")}var step={ArrowDown:1,ArrowUp:-1};function useKeyboard(_ref){var item=_ref.item,isExpanded=_ref.isExpanded,onExpand=_ref.onExpand,onCollapse=_ref.onCollapse,onToggleExpand=_ref.onToggleExpand,onLastItemLoop=_ref.onLastItemLoop,onFirstItemLoop=_ref.onFirstItemLoop;return{onKeyDown:function onKeyDown(event){if("ArrowRight"===event.code&&(event.preventDefault(),item.children.length>0)){if(isExpanded){var element=function getFirstChild(currentHeading){var parentTreeItem=null==currentHeading?void 0:currentHeading.closest(".experimental-woocommerce-tree-item"),firstSubTreeItem=null==parentTreeItem?void 0:parentTreeItem.querySelector(".experimental-woocommerce-tree > .experimental-woocommerce-tree-item"),label=null==firstSubTreeItem?void 0:firstSubTreeItem.querySelector(".experimental-woocommerce-tree-item__heading > .experimental-woocommerce-tree-item__label");return null!=label?label:null}(event.currentTarget);return null==element?void 0:element.focus()}onExpand()}if("ArrowLeft"===event.code){if(event.preventDefault(),!isExpanded&&item.parent){var _element=function getFirstAncestor(currentHeading){var parentTree=null==currentHeading?void 0:currentHeading.closest(".experimental-woocommerce-tree"),grandParentTreeItem=null==parentTree?void 0:parentTree.closest(".experimental-woocommerce-tree-item"),label=null==grandParentTreeItem?void 0:grandParentTreeItem.querySelector(".experimental-woocommerce-tree-item__heading > .experimental-woocommerce-tree-item__label");return null!=label?label:null}(event.currentTarget);return null==_element?void 0:_element.focus()}item.children.length>0&&onCollapse()}if("Enter"===event.code&&(event.preventDefault(),item.children.length>0&&onToggleExpand()),"ArrowDown"===event.code||"ArrowUp"===event.code){event.preventDefault();var _element2=function getNextFocusableElement(currentHeading,code){var _step$code,headingsNodeList=getAllHeadings(currentHeading);if(!headingsNodeList)return null;var _step,currentHeadingIndex=0,_iterator=_createForOfIteratorHelper(headingsNodeList.values());try{for(_iterator.s();!(_step=_iterator.n()).done&&_step.value!==currentHeading;)currentHeadingIndex++}catch(err){_iterator.e(err)}finally{_iterator.f()}if(currentHeadingIndex<0||currentHeadingIndex>=headingsNodeList.length)return null;var heading=headingsNodeList.item(currentHeadingIndex+(null!==(_step$code=step[code])&&void 0!==_step$code?_step$code:0));return null==heading?void 0:heading.querySelector(".experimental-woocommerce-tree-item__label")}(event.currentTarget,event.code);null==_element2||_element2.focus(),"ArrowDown"===event.code&&!_element2&&onLastItemLoop&&onLastItemLoop(event),"ArrowUp"===event.code&&!_element2&&onFirstItemLoop&&onFirstItemLoop(event)}if("Home"===event.code){event.preventDefault();var _element3=function getFirstFocusableElement(currentHeading){var headingsNodeList=getAllHeadings(currentHeading);return headingsNodeList?headingsNodeList.item(0).querySelector(".experimental-woocommerce-tree-item__label"):null}(event.currentTarget);null==_element3||_element3.focus()}if("End"===event.code){event.preventDefault();var _element4=function getLastFocusableElement(currentHeading){var headingsNodeList=getAllHeadings(currentHeading);return headingsNodeList?headingsNodeList.item(headingsNodeList.length-1).querySelector(".experimental-woocommerce-tree-item__label"):null}(event.currentTarget);null==_element4||_element4.focus()}}}}var toConsumableArray=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js");__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.reduce.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.some.js"),__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.concat.js");function use_selection_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function use_selection_objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?use_selection_ownKeys(Object(t),!0).forEach((function(r){(0,defineProperty.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):use_selection_ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function use_selection_createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function use_selection_unsupportedIterableToArray(o,minLen){if(!o)return;if("string"==typeof o)return use_selection_arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return use_selection_arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function F(){};return{s:F,n:function n(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();return normalCompletion=step.done,step},e:function e(_e2){didErr=!0,err=_e2},f:function f(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}function use_selection_arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}var selectedItemsMap={},indeterminateMemo={};function getDeepChildren(item){if(item.children.length){var children=item.children.map((function(_ref){return _ref.data}));return item.children.forEach((function(child){children.push.apply(children,(0,toConsumableArray.A)(getDeepChildren(child)))})),children}return[]}function isIndeterminate(selectedItems,children){var memo=arguments.length>2&&void 0!==arguments[2]?arguments[2]:indeterminateMemo;if(null!=children&&children.length){var _step,_iterator=use_selection_createForOfIteratorHelper(children);try{for(_iterator.s();!(_step=_iterator.n()).done;){var child=_step.value;if(child.data.value in indeterminateMemo)return!0;if(!(child.data.value in selectedItems)||isIndeterminate(selectedItems,child.children,memo))return indeterminateMemo[child.data.value]=!0,!0}}catch(err){_iterator.e(err)}finally{_iterator.f()}}return!1}function useSelection(_ref2){var item=_ref2.item,multiple=_ref2.multiple,shouldNotRecursivelySelect=_ref2.shouldNotRecursivelySelect,selected=_ref2.selected,level=_ref2.level,index=_ref2.index,onSelect=_ref2.onSelect,onRemove=_ref2.onRemove,selectedItems=(0,react.useMemo)((function(){return 1===level&&0===index&&(selectedItemsMap=function mapSelectedItems(){var selected=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(Array.isArray(selected)?selected:[selected]).reduce((function(map,selectedItem,index){return use_selection_objectSpread(use_selection_objectSpread({},map),{},(0,defineProperty.A)({},selectedItem.value,index))}),{})}(selected),indeterminateMemo={}),selectedItemsMap}),[selected,level,index]),checkedStatus=(0,react.useMemo)((function(){return item.data.value in selectedItems?multiple&&!shouldNotRecursivelySelect&&isIndeterminate(selectedItems,item.children)?"indeterminate":"checked":"unchecked"}),[selectedItems,item,multiple]);return{multiple,selected,checkedStatus,onSelectChild:function onSelectChild(checked){var _value,value=item.data;multiple&&(value=[item.data],item.children.length&&!shouldNotRecursivelySelect&&(_value=value).push.apply(_value,(0,toConsumableArray.A)(getDeepChildren(item)))),checked?"function"==typeof onSelect&&onSelect(value):"function"==typeof onRemove&&onRemove(value)},onSelectChildren:function onSelectChildren(value){"function"==typeof onSelect&&(multiple&&!shouldNotRecursivelySelect&&(value=[item.data].concat((0,toConsumableArray.A)(value))),onSelect(value))},onRemoveChildren:function onRemoveChildren(value){var _item$children;if("function"==typeof onRemove){if(multiple&&null!==(_item$children=item.children)&&void 0!==_item$children&&_item$children.length&&!shouldNotRecursivelySelect){var hasSelectedSibbling=function hasSelectedSibblingChildren(children,values,selectedItems){return children.some((function(child){return!!(child.data.value in selectedItems)&&!values.some((function(childValue){return childValue.value===child.data.value}))}))}(item.children,value,selectedItems);hasSelectedSibbling||(value=[item.data].concat((0,toConsumableArray.A)(value)))}onRemove(value)}}}}var use_tree_item_excluded=["item","level","multiple","shouldNotRecursivelySelect","selected","index","getLabel","shouldItemBeExpanded","shouldItemBeHighlighted","onSelect","onRemove","isExpanded","onCreateNew","shouldShowCreateButton","onLastItemLoop","onFirstItemLoop","onTreeBlur","onEscape","highlightedIndex","isHighlighted","onExpand"];function use_tree_item_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function use_tree_item_objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?use_tree_item_ownKeys(Object(t),!0).forEach((function(r){(0,defineProperty.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):use_tree_item_ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function useTreeItem(_ref){var item=_ref.item,level=_ref.level,multiple=_ref.multiple,shouldNotRecursivelySelect=_ref.shouldNotRecursivelySelect,selected=_ref.selected,index=_ref.index,getLabel=_ref.getLabel,shouldItemBeExpanded=_ref.shouldItemBeExpanded,shouldItemBeHighlighted=_ref.shouldItemBeHighlighted,onSelect=_ref.onSelect,onRemove=_ref.onRemove,onLastItemLoop=(_ref.isExpanded,_ref.onCreateNew,_ref.shouldShowCreateButton,_ref.onLastItemLoop),onFirstItemLoop=_ref.onFirstItemLoop,props=(_ref.onTreeBlur,_ref.onEscape,_ref.highlightedIndex,_ref.isHighlighted,_ref.onExpand,(0,objectWithoutProperties.A)(_ref,use_tree_item_excluded)),nextLevel=level+1,expander=function useExpander(_ref){var shouldItemBeExpanded=_ref.shouldItemBeExpanded,item=_ref.item,_useState=(0,react.useState)(!1),_useState2=(0,slicedToArray.A)(_useState,2),isExpanded=_useState2[0],setExpanded=_useState2[1];return(0,react.useEffect)((function(){var _item$children;null!==(_item$children=item.children)&&void 0!==_item$children&&_item$children.length&&"function"==typeof shouldItemBeExpanded&&!isExpanded&&setExpanded(shouldItemBeExpanded(item))}),[item,shouldItemBeExpanded]),{isExpanded,onExpand:function onExpand(){setExpanded(!0)},onCollapse:function onCollapse(){setExpanded(!1)},onToggleExpand:function onToggleExpand(){setExpanded((function(prev){return!prev}))}}}({item,shouldItemBeExpanded}),selection=useSelection({item,multiple,selected,level,index,onSelect,onRemove,shouldNotRecursivelySelect}),highlighter=function useHighlighter(_ref){var item=_ref.item,multiple=_ref.multiple,checkedStatus=_ref.checkedStatus,shouldItemBeHighlighted=_ref.shouldItemBeHighlighted;return{isHighlighted:(0,react.useMemo)((function(){return"function"!=typeof shouldItemBeHighlighted||!multiple&&0!==item.children.length?multiple?void 0:"checked"===checkedStatus:shouldItemBeHighlighted(item)}),[item,multiple,checkedStatus,shouldItemBeHighlighted])}}({item,checkedStatus:selection.checkedStatus,multiple,shouldItemBeHighlighted}),subTreeId="experimental-woocommerce-tree__group-".concat((0,use_instance_id.A)(useTreeItem)),onKeyDown=useKeyboard(use_tree_item_objectSpread(use_tree_item_objectSpread({},expander),{},{onLastItemLoop,onFirstItemLoop,item})).onKeyDown;return{item,level:nextLevel,expander,selection,highlighter,getLabel,treeItemProps:use_tree_item_objectSpread(use_tree_item_objectSpread({},props),{},{id:"woocommerce-experimental-tree-control__menu-item-"+item.index,role:"option"}),headingProps:{role:"treeitem","aria-selected":"unchecked"!==selection.checkedStatus,"aria-expanded":item.children.length?item.data.isExpanded:void 0,"aria-owns":item.children.length&&item.data.isExpanded?subTreeId:void 0,style:{"--level":level},onKeyDown},treeProps:{id:subTreeId,items:item.children,level:nextLevel,multiple:selection.multiple,selected:selection.selected,role:"group","aria-label":item.data.label,getItemLabel:getLabel,shouldItemBeExpanded,shouldItemBeHighlighted,shouldNotRecursivelySelect,onSelect:selection.onSelectChildren,onRemove:selection.onRemoveChildren}}}function tree_item_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function tree_item_objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?tree_item_ownKeys(Object(t),!0).forEach((function(r){(0,defineProperty.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):tree_item_ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var TreeItem=(0,react.forwardRef)((function ForwardedTreeItem(props,ref){var _item$children,_useTreeItem=useTreeItem(tree_item_objectSpread(tree_item_objectSpread({},props),{},{ref})),item=_useTreeItem.item,treeItemProps=_useTreeItem.treeItemProps,headingProps=_useTreeItem.headingProps,treeProps=_useTreeItem.treeProps,selection=_useTreeItem.selection,getLabel=_useTreeItem.getLabel;function handleKeyDown(event){if("Escape"===event.key&&props.onEscape)event.preventDefault(),props.onEscape();else if("ArrowLeft"===event.key){var _props$onExpand;if(void 0!==item.index)null===(_props$onExpand=props.onExpand)||void 0===_props$onExpand||_props$onExpand.call(props,item.index,!1)}else if("ArrowRight"===event.key){var _props$onExpand2;if(void 0!==item.index)null===(_props$onExpand2=props.onExpand)||void 0===_props$onExpand2||_props$onExpand2.call(props,item.index,!0)}}return(0,react.createElement)("li",(0,esm_extends.A)({},treeItemProps,{className:classnames_default()(treeItemProps.className,"experimental-woocommerce-tree-item",{"experimental-woocommerce-tree-item--highlighted":props.isHighlighted})}),(0,react.createElement)("div",(0,esm_extends.A)({},headingProps,{className:"experimental-woocommerce-tree-item__heading"}),(0,react.createElement)("label",{className:"experimental-woocommerce-tree-item__label"},selection.multiple?(0,react.createElement)(checkbox_control.A,{indeterminate:"indeterminate"===selection.checkedStatus,checked:"checked"===selection.checkedStatus,onChange:selection.onSelectChild,onKeyDown:handleKeyDown,__nextHasNoMarginBottom:!0}):(0,react.createElement)("input",{type:"checkbox",className:"experimental-woocommerce-tree-item__checkbox",checked:"checked"===selection.checkedStatus,onChange:function onChange(event){return selection.onSelectChild(event.target.checked)},onKeyDown:handleKeyDown}),"function"==typeof getLabel?getLabel(item):(0,react.createElement)("span",null,(0,html_entities_build_module.S)(item.data.label))),Boolean(null===(_item$children=item.children)||void 0===_item$children?void 0:_item$children.length)&&(0,react.createElement)("div",{className:"experimental-woocommerce-tree-item__expander"},(0,react.createElement)(build_module_button.A,{icon:item.data.isExpanded?chevron_up.A:chevron_down.A,onClick:function onClick(){var _props$onExpand3;void 0!==item.index&&(null===(_props$onExpand3=props.onExpand)||void 0===_props$onExpand3||_props$onExpand3.call(props,item.index,!item.data.isExpanded))},onKeyDown:handleKeyDown,className:"experimental-woocommerce-tree-item__expander","aria-label":item.data.isExpanded?(0,build_module.__)("Collapse","woocommerce"):(0,build_module.__)("Expand","woocommerce")}))),Boolean(item.children.length)&&item.data.isExpanded&&(0,react.createElement)(Tree,(0,esm_extends.A)({},treeProps,{highlightedIndex:props.highlightedIndex,onExpand:props.onExpand,onEscape:props.onEscape})))}));try{TreeItem.displayName="TreeItem",TreeItem.__docgenInfo={description:"",displayName:"TreeItem",props:{onSelect:{defaultValue:null,description:"When `multiple` is true and a child item is selected, all its\nancestors and its descendants are also selected. If it's false\nonly the clicked item is selected.\n@param value The selection",name:"onSelect",required:!1,type:{name:"((value: Item | Item[]) => void)"}},index:{defaultValue:null,description:"",name:"index",required:!0,type:{name:"number"}},level:{defaultValue:null,description:"",name:"level",required:!0,type:{name:"number"}},selected:{defaultValue:null,description:"It contains one item if `multiple` value is false or\na list of items if it is true.",name:"selected",required:!1,type:{name:"Item | Item[]"}},onExpand:{defaultValue:null,description:"",name:"onExpand",required:!1,type:{name:"((index: number, value: boolean) => void)"}},highlightedIndex:{defaultValue:null,description:"",name:"highlightedIndex",required:!1,type:{name:"number"}},multiple:{defaultValue:null,description:"Whether the tree items are single or multiple selected.",name:"multiple",required:!1,type:{name:"boolean"}},shouldNotRecursivelySelect:{defaultValue:null,description:"In `multiple` mode, when this flag is also set, selecting children does\nnot select their parents and selecting parents does not select their children.",name:"shouldNotRecursivelySelect",required:!1,type:{name:"boolean"}},createValue:{defaultValue:null,description:"The value to be used for comparison to determine if 'create new' button should be shown.",name:"createValue",required:!1,type:{name:"string"}},onCreateNew:{defaultValue:null,description:"Called when the 'create new' button is clicked.",name:"onCreateNew",required:!1,type:{name:"(() => void)"}},shouldShowCreateButton:{defaultValue:null,description:"If passed, shows create button if return from callback is true",name:"shouldShowCreateButton",required:!1,type:{name:"((value?: string) => boolean)"}},isExpanded:{defaultValue:null,description:"",name:"isExpanded",required:!1,type:{name:"boolean"}},onRemove:{defaultValue:null,description:"When `multiple` is true and a child item is unselected, all its\nancestors (if no sibblings are selected) and its descendants\nare also unselected. If it's false only the clicked item is\nunselected.\n@param value The unselection",name:"onRemove",required:!1,type:{name:"((value: Item | Item[]) => void)"}},shouldItemBeHighlighted:{defaultValue:null,description:"It provides a way to determine whether the current rendering\nitem is highlighted or not from outside the tree.\n@example <Tree\n\tshouldItemBeHighlighted={ isFirstChild }\n/>\n@param item The current linked tree item, useful to\ntraverse the entire linked tree from this item.\n@see {@link LinkedTree }",name:"shouldItemBeHighlighted",required:!1,type:{name:"((item: LinkedTree) => boolean)"}},onTreeBlur:{defaultValue:null,description:"Called when the create button is clicked to help closing any related popover.",name:"onTreeBlur",required:!1,type:{name:"(() => void)"}},onFirstItemLoop:{defaultValue:null,description:"",name:"onFirstItemLoop",required:!1,type:{name:"((event: KeyboardEvent<HTMLDivElement>) => void)"}},onEscape:{defaultValue:null,description:"Called when the escape key is pressed.",name:"onEscape",required:!1,type:{name:"(() => void)"}},shouldItemBeExpanded:{defaultValue:null,description:"",name:"shouldItemBeExpanded",required:!1,type:{name:"((item: LinkedTree) => boolean)"}},item:{defaultValue:null,description:"",name:"item",required:!0,type:{name:"LinkedTree"}},isFocused:{defaultValue:null,description:"",name:"isFocused",required:!1,type:{name:"boolean"}},isHighlighted:{defaultValue:null,description:"",name:"isHighlighted",required:!1,type:{name:"boolean"}},getLabel:{defaultValue:null,description:"",name:"getLabel",required:!1,type:{name:"((item: LinkedTree) => Element)"}},onLastItemLoop:{defaultValue:null,description:"",name:"onLastItemLoop",required:!1,type:{name:"((event: KeyboardEvent<HTMLDivElement>) => void)"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["../../packages/js/components/src/experimental-tree-control/tree-item.tsx#TreeItem"]={docgenInfo:TreeItem.__docgenInfo,name:"TreeItem",path:"../../packages/js/components/src/experimental-tree-control/tree-item.tsx#TreeItem"})}catch(__react_docgen_typescript_loader_error){}var linked_tree_utils=__webpack_require__("../../packages/js/components/src/experimental-tree-control/linked-tree-utils.ts");function tree_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function tree_objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?tree_ownKeys(Object(t),!0).forEach((function(r){(0,defineProperty.A)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):tree_ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var Tree=(0,react.forwardRef)((function ForwardedTree(props,forwardedRef){var rootListRef=(0,react.useRef)(null),ref=(0,use_merge_refs.A)([rootListRef,forwardedRef]),_useTree=function useTree(_ref){var items=_ref.items,_ref$level=_ref.level,level=void 0===_ref$level?1:_ref$level,_ref$role=_ref.role,role=void 0===_ref$role?"listbox":_ref$role,multiple=_ref.multiple,selected=_ref.selected,getItemLabel=_ref.getItemLabel,shouldItemBeExpanded=_ref.shouldItemBeExpanded,shouldItemBeHighlighted=_ref.shouldItemBeHighlighted,onSelect=_ref.onSelect,onRemove=_ref.onRemove,shouldNotRecursivelySelect=_ref.shouldNotRecursivelySelect;return _ref.createValue,_ref.onTreeBlur,_ref.onCreateNew,_ref.shouldShowCreateButton,_ref.onFirstItemLoop,_ref.onEscape,_ref.highlightedIndex,_ref.onExpand,{level,items,treeProps:_objectSpread(_objectSpread({},(0,objectWithoutProperties.A)(_ref,_excluded)),{},{role}),treeItemProps:{level,multiple,selected,getLabel:getItemLabel,shouldItemBeExpanded,shouldItemBeHighlighted,shouldNotRecursivelySelect,onSelect,onRemove}}}(tree_objectSpread(tree_objectSpread({},props),{},{ref})),level=_useTree.level,items=_useTree.items,treeProps=_useTree.treeProps,treeItemProps=_useTree.treeItemProps,numberOfItems=(0,linked_tree_utils.VW)(items),isCreateButtonVisible=props.shouldShowCreateButton&&props.shouldShowCreateButton(props.createValue);return(0,react.createElement)(react.Fragment,null,items.length||isCreateButtonVisible?(0,react.createElement)("ol",(0,esm_extends.A)({},treeProps,{className:classnames_default()(treeProps.className,"experimental-woocommerce-tree","experimental-woocommerce-tree--level-".concat(level))}),items.map((function(child,index){return(0,react.createElement)(TreeItem,(0,esm_extends.A)({},treeItemProps,{isHighlighted:props.highlightedIndex===child.index,onExpand:props.onExpand,highlightedIndex:props.highlightedIndex,isExpanded:child.data.isExpanded,key:child.data.value,item:child,index,onLastItemLoop:function onLastItemLoop(){var _rootListRef$current;null===(_rootListRef$current=rootListRef.current)||void 0===_rootListRef$current||null===(_rootListRef$current=_rootListRef$current.closest('ol[role="listbox"]'))||void 0===_rootListRef$current||null===(_rootListRef$current=_rootListRef$current.parentElement)||void 0===_rootListRef$current||null===(_rootListRef$current=_rootListRef$current.querySelector(".experimental-woocommerce-tree__button"))||void 0===_rootListRef$current||_rootListRef$current.focus()},onFirstItemLoop:props.onFirstItemLoop,onEscape:props.onEscape}))}))):null,isCreateButtonVisible&&(0,react.createElement)(build_module_button.A,{id:"woocommerce-experimental-tree-control__menu-item-"+numberOfItems,className:classnames_default()("experimental-woocommerce-tree__button",{"experimental-woocommerce-tree__button--highlighted":props.highlightedIndex===numberOfItems}),onClick:function onClick(){props.onCreateNew&&props.onCreateNew(),props.onTreeBlur&&props.onTreeBlur()},onKeyDown:function onKeyDown(event){if("ArrowUp"===event.key||"ArrowDown"===event.key){if(event.preventDefault(),"ArrowUp"===event.key){var _allHeadings,allHeadings=event.nativeEvent.srcElement.previousSibling.querySelectorAll(".experimental-woocommerce-tree-item > .experimental-woocommerce-tree-item__heading");null===(_allHeadings=allHeadings[allHeadings.length-1])||void 0===_allHeadings||null===(_allHeadings=_allHeadings.querySelector(".experimental-woocommerce-tree-item__label"))||void 0===_allHeadings||_allHeadings.focus()}}else"Escape"===event.key&&props.onEscape&&(event.preventDefault(),props.onEscape())}},(0,react.createElement)(icon.A,{icon:plus.A,size:20}),props.createValue?(0,build_module.nv)((0,build_module.__)('Create "%s"',"woocommerce"),props.createValue):(0,build_module.__)("Create new","woocommerce")))}));try{Tree.displayName="Tree",Tree.__docgenInfo={description:"",displayName:"Tree",props:{onSelect:{defaultValue:null,description:"When `multiple` is true and a child item is selected, all its\nancestors and its descendants are also selected. If it's false\nonly the clicked item is selected.\n@param value The selection",name:"onSelect",required:!1,type:{name:"((value: Item | Item[]) => void)"}},items:{defaultValue:null,description:"",name:"items",required:!0,type:{name:"LinkedTree[]"}},level:{defaultValue:null,description:"",name:"level",required:!1,type:{name:"number"}},selected:{defaultValue:null,description:"It contains one item if `multiple` value is false or\na list of items if it is true.",name:"selected",required:!1,type:{name:"Item | Item[]"}},onExpand:{defaultValue:null,description:"",name:"onExpand",required:!1,type:{name:"((index: number, value: boolean) => void)"}},highlightedIndex:{defaultValue:null,description:"",name:"highlightedIndex",required:!1,type:{name:"number"}},multiple:{defaultValue:null,description:"Whether the tree items are single or multiple selected.",name:"multiple",required:!1,type:{name:"boolean"}},shouldNotRecursivelySelect:{defaultValue:null,description:"In `multiple` mode, when this flag is also set, selecting children does\nnot select their parents and selecting parents does not select their children.",name:"shouldNotRecursivelySelect",required:!1,type:{name:"boolean"}},createValue:{defaultValue:null,description:"The value to be used for comparison to determine if 'create new' button should be shown.",name:"createValue",required:!1,type:{name:"string"}},onCreateNew:{defaultValue:null,description:"Called when the 'create new' button is clicked.",name:"onCreateNew",required:!1,type:{name:"(() => void)"}},shouldShowCreateButton:{defaultValue:null,description:"If passed, shows create button if return from callback is true",name:"shouldShowCreateButton",required:!1,type:{name:"((value?: string) => boolean)"}},isExpanded:{defaultValue:null,description:"",name:"isExpanded",required:!1,type:{name:"boolean"}},onRemove:{defaultValue:null,description:"When `multiple` is true and a child item is unselected, all its\nancestors (if no sibblings are selected) and its descendants\nare also unselected. If it's false only the clicked item is\nunselected.\n@param value The unselection",name:"onRemove",required:!1,type:{name:"((value: Item | Item[]) => void)"}},shouldItemBeHighlighted:{defaultValue:null,description:"It provides a way to determine whether the current rendering\nitem is highlighted or not from outside the tree.\n@example <Tree\n\tshouldItemBeHighlighted={ isFirstChild }\n/>\n@param item The current linked tree item, useful to\ntraverse the entire linked tree from this item.\n@see {@link LinkedTree }",name:"shouldItemBeHighlighted",required:!1,type:{name:"((item: LinkedTree) => boolean)"}},onTreeBlur:{defaultValue:null,description:"Called when the create button is clicked to help closing any related popover.",name:"onTreeBlur",required:!1,type:{name:"(() => void)"}},onFirstItemLoop:{defaultValue:null,description:"",name:"onFirstItemLoop",required:!1,type:{name:"((event: KeyboardEvent<HTMLDivElement>) => void)"}},onEscape:{defaultValue:null,description:"Called when the escape key is pressed.",name:"onEscape",required:!1,type:{name:"(() => void)"}},getItemLabel:{defaultValue:null,description:"It gives a way to render a different Element as the\ntree item label.\n@example <Tree\n\tgetItemLabel={ ( item ) => <span>${ item.data.label }</span> }\n/>\n@param item The current rendering tree item\n@see {@link LinkedTree }",name:"getItemLabel",required:!1,type:{name:"((item: LinkedTree) => Element)"}},shouldItemBeExpanded:{defaultValue:null,description:"Return if the tree item passed in should be expanded.\n@example <Tree\n\tshouldItemBeExpanded={\n\t\t( item ) => checkExpanded( item, filter )\n\t}\n/>\n@param item The tree item to determine if should be expanded.\n@see {@link LinkedTree }",name:"shouldItemBeExpanded",required:!1,type:{name:"((item: LinkedTree) => boolean)"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["../../packages/js/components/src/experimental-tree-control/tree.tsx#Tree"]={docgenInfo:Tree.__docgenInfo,name:"Tree",path:"../../packages/js/components/src/experimental-tree-control/tree.tsx#Tree"})}catch(__react_docgen_typescript_loader_error){}}}]); |