woocommerce/experimental-tree-control-s...

1 line
25 KiB
JavaScript
Raw Permalink Normal View History

"use strict";(self.webpackChunk_woocommerce_storybook=self.webpackChunk_woocommerce_storybook||[]).push([[6755],{"../../node_modules/.pnpm/@automattic+interpolate-components@1.2.1_@types+react@17.0.71_react@17.0.2/node_modules/@automattic/interpolate-components/dist/esm/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>interpolate});var react=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");function identifyToken(item){return item.startsWith("{{/")?{type:"componentClose",value:item.replace(/\W/g,"")}:item.endsWith("/}}")?{type:"componentSelfClosing",value:item.replace(/\W/g,"")}:item.startsWith("{{")?{type:"componentOpen",value:item.replace(/\W/g,"")}:{type:"string",value:item}}function buildChildren(tokens,components){let openComponent,openIndex,children=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("string"!==token.type){if(void 0===components[token.value])throw new Error(`Invalid interpolation, missing component node: \`${token.value}\``);if("object"!=typeof components[token.value])throw new Error(`Invalid interpolation, component node must be a ReactElement or null: \`${token.value}\``);if("componentClose"===token.type)throw new Error(`Missing opening component token: \`${token.value}\``);if("componentOpen"===token.type){openComponent=components[token.value],openIndex=i;break}children.push(components[token.value])}else children.push(token.value)}if(openComponent){const closeIndex=function getCloseIndex(openIndex,tokens){const openToken=tokens[openIndex];let nestLevel=0;for(let i=openIndex+1;i<tokens.length;i++){const token=tokens[i];if(token.value===openToken.value){if("componentOpen"===token.type){nestLevel++;continue}if("componentClose"===token.type){if(0===nestLevel)return i;nestLevel--}}}throw new Error("Missing closing component token `"+openToken.value+"`")}(openIndex,tokens),grandChildren=buildChildren(tokens.slice(openIndex+1,closeIndex),components),clonedOpenComponent=(0,react.cloneElement)(openComponent,{},grandChildren);if(children.push(clonedOpenComponent),closeIndex<tokens.length-1){const siblings=buildChildren(tokens.slice(closeIndex+1),components);children=children.concat(siblings)}}return children=children.filter(Boolean),0===children.length?null:1===children.length?children[0]:(0,react.createElement)(react.Fragment,null,...children)}function interpolate(options){const{mixedString,components,throwErrors}=options;if(!components)return mixedString;if("object"!=typeof components){if(throwErrors)throw new Error(`Interpolation Error: unable to process \`${mixedString}\` because components is not an object`);return mixedString}const tokens=function tokenize(mixedString){return mixedString.split(/(\{\{\/?\s*\w+\s*\/?\}\})/g).map(identifyToken)}(mixedString);try{return buildChildren(tokens,components)}catch(error){if(throwErrors)throw new Error(`Interpolation Error: unable to process \`${mixedString}\` because of error \`${error.message}\``);return mixedString}}},"../../packages/js/components/src/experimental-tree-control/stories/tree-control.story.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{CustomItemLabel:()=>CustomItemLabel,CustomItemLabelOnSearch:()=>CustomItemLabelOnSearch,ExpandOnFilter:()=>ExpandOnFilter,HighlightFirstMatchingItem:()=>HighlightFirstMatchingItem,SelectionMultiple:()=>SelectionMultiple,SelectionSingle:()=>SelectionSingle,SimpleTree:()=>SimpleTree,default:()=>tree_control_story});var toConsumableArray=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js"),slicedToArray=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),react=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),esm=(__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-j