1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
"use strict";(self.webpackChunk_woocommerce_storybook=self.webpackChunk_woocommerce_storybook||[]).push([[7754],{"../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],excluded.indexOf(key)>=0||(target[key]=source[key]);return target}(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],excluded.indexOf(key)>=0||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}__webpack_require__.d(__webpack_exports__,{A:()=>_objectWithoutProperties})},"../../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/dropdown/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>Dropdown});var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js"),_wordpress_element__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),classnames__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js"),classnames__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__),_popover__WEBPACK_IMPORTED_MODULE_2__=__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/popover/index.js");function Dropdown(props){var _popoverProps$anchorR;const{renderContent,renderToggle,position="bottom right",className,contentClassName,expandOnMobile,headerTitle,focusOnMount,popoverProps,onClose,onToggle}=props,containerRef=(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useRef)(),[isOpen,setIsOpen]=function useObservableState(initialState,onStateChange){const[state,setState]=(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(initialState);return[state,value=>{setState(value),onStateChange&&onStateChange(value)}]}(!1,onToggle);function close(){onClose&&onClose(),setIsOpen(!1)}(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)((()=>()=>{onToggle&&onToggle(!1)}),[]);const args={isOpen,onToggle:function toggle(){setIsOpen(!isOpen)},onClose:close};return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div",{className:classnames__WEBPACK_IMPORTED_MODULE_0___default()("components-dropdown",className),ref:containerRef,tabIndex:"-1"},renderToggle(args),isOpen&&(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_popover__WEBPACK_IMPORTED_MODULE_2__.A,(0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_3__.A)({position,onClose:close,onFocusOutside:function closeIfFocusOutside(){const{ownerDocument}=containerRef.current,dialog=ownerDocument.activeElement.closest('[role="dialog"]');containerRef.current.contains(ownerDocument.activeElement)||dialog&&!dialog.contains(containerRef.current)||close()},expandOnMobile,headerTitle,focusOnMount},popoverProps,{anchorRef:null!==(_popoverProps$anchorR=null==popoverProps?void 0:popoverProps.anchorRef)&&void 0!==_popoverProps$anchorR?_popoverProps$anchorR:containerRef.current,className:classnames__WEBPACK_IMPORTED_MODULE_0___default()("components-dropdown__content",popoverProps?popoverProps.className:void 0,contentClassName)}),renderContent(args)))}},"../../node_modules/.pnpm/@wordpress+html-entities@3.6.1/node_modules/@wordpress/html-entities/build-module/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{let _decodeTextArea;function decodeEntities(html){if("string"!=typeof html||-1===html.indexOf("&"))return html;void 0===_decodeTextArea&&(_decodeTextArea=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),_decodeTextArea.innerHTML=html;const decoded=_decodeTextArea.textContent;return _decodeTextArea.innerHTML="",decoded}__webpack_require__.d(__webpack_exports__,{S:()=>decodeEntities})},"../../packages/js/components/src/dropdown-button/index.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js"),_babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),_wordpress_components__WEBPACK_IMPORTED_MODULE_4__=(__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")),_wordpress_element__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__("../../node_modules/.pnpm/@wordpress+html-entities@3.6.1/node_modules/@wordpress/html-entities/build-module/index.js"),prop_types__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__("../../node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js"),prop_types__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_7__),classnames__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js"),classnames__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__),_excluded=["labels","isOpen"],DropdownButton=function DropdownButton(props){var labels=props.labels,isOpen=props.isOpen,otherProps=(0,_babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_2__.A)(props,_excluded),buttonClasses=classnames__WEBPACK_IMPORTED_MODULE_1___default()("woocommerce-dropdown-button",{"is-open":isOpen,"is-multi-line":labels.length>1});return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.A,(0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_5__.A)({className:buttonClasses,"aria-expanded":isOpen},otherProps),(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)("div",{className:"woocommerce-dropdown-button__labels"},labels.map((function(label,i){return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)("span",{key:i},(0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_6__.S)(label))}))))};DropdownButton.propTypes={labels:prop_types__WEBPACK_IMPORTED_MODULE_7___default().array.isRequired,isOpen:prop_types__WEBPACK_IMPORTED_MODULE_7___default().bool};const __WEBPACK_DEFAULT_EXPORT__=DropdownButton},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-iteration.js":(module,__unused_webpack_exports,__webpack_require__)=>{var bind=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/function-bind-context.js"),uncurryThis=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/function-uncurry-this.js"),IndexedObject=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/indexed-object.js"),toObject=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/to-object.js"),lengthOfArrayLike=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/length-of-array-like.js"),arraySpeciesCreate=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-species-create.js"),push=uncurryThis([].push),createMethod=function(TYPE){var IS_MAP=1===TYPE,IS_FILTER=2===TYPE,IS_SOME=3===TYPE,IS_EVERY=4===TYPE,IS_FIND_INDEX=6===TYPE,IS_FILTER_REJECT=7===TYPE,NO_HOLES=5===TYPE||IS_FIND_INDEX;return function($this,callbackfn,that,specificCreate){for(var value,result,O=toObject($this),self=IndexedObject(O),length=lengthOfArrayLike(self),boundFunction=bind(callbackfn,that),index=0,create=specificCreate||arraySpeciesCreate,target=IS_MAP?create($this,length):IS_FILTER||IS_FILTER_REJECT?create($this,0):void 0;length>index;index++)if((NO_HOLES||index in self)&&(result=boundFunction(value=self[index],index,O),TYPE))if(IS_MAP)target[index]=result;else if(result)switch(TYPE){case 3:return!0;case 5:return value;case 6:return index;case 2:push(target,value)}else switch(TYPE){case 4:return!1;case 7:push(target,value)}return IS_FIND_INDEX?-1:IS_SOME||IS_EVERY?IS_EVERY:target}};module.exports={forEach:createMethod(0),map:createMethod(1),filter:createMethod(2),some:createMethod(3),every:createMethod(4),find:createMethod(5),findIndex:createMethod(6),filterReject:createMethod(7)}},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-method-has-species-support.js":(module,__unused_webpack_exports,__webpack_require__)=>{var fails=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/fails.js"),wellKnownSymbol=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/well-known-symbol.js"),V8_VERSION=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/engine-v8-version.js"),SPECIES=wellKnownSymbol("species");module.exports=function(METHOD_NAME){return V8_VERSION>=51||!fails((function(){var array=[];return(array.constructor={})[SPECIES]=function(){return{foo:1}},1!==array[METHOD_NAME](Boolean).foo}))}},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-species-constructor.js":(module,__unused_webpack_exports,__webpack_require__)=>{var isArray=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/is-array.js"),isConstructor=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/is-constructor.js"),isObject=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/is-object.js"),SPECIES=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/well-known-symbol.js")("species"),$Array=Array;module.exports=function(originalArray){var C;return isArray(originalArray)&&(C=originalArray.constructor,(isConstructor(C)&&(C===$Array||isArray(C.prototype))||isObject(C)&&null===(C=C[SPECIES]))&&(C=void 0)),void 0===C?$Array:C}},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-species-create.js":(module,__unused_webpack_exports,__webpack_require__)=>{var arraySpeciesConstructor=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-species-constructor.js");module.exports=function(originalArray,length){return new(arraySpeciesConstructor(originalArray))(0===length?0:length)}},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/is-array.js":(module,__unused_webpack_exports,__webpack_require__)=>{var classof=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/classof-raw.js");module.exports=Array.isArray||function isArray(argument){return"Array"===classof(argument)}},"../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.map.js":(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{var $=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/export.js"),$map=__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-iteration.js").map;$({target:"Array",proto:!0,forced:!__webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/internals/array-method-has-species-support.js")("map")},{map:function map(callbackfn){return $map(this,callbackfn,arguments.length>1?arguments[1]:void 0)}})},"../../packages/js/components/src/dropdown-button/stories/index.story.js":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Basic:()=>Basic,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),_wordpress_components__WEBPACK_IMPORTED_MODULE_1__=__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/dropdown/index.js"),_woocommerce_components__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("../../packages/js/components/src/dropdown-button/index.js"),Basic=function Basic(){return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.A,{renderToggle:function renderToggle(_ref){var isOpen=_ref.isOpen,onToggle=_ref.onToggle;return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_woocommerce_components__WEBPACK_IMPORTED_MODULE_2__.A,{onClick:onToggle,isOpen,labels:["All products Sold"]})},renderContent:function renderContent(){return(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p",null,"Dropdown content here")}})};const __WEBPACK_DEFAULT_EXPORT__={title:"WooCommerce Admin/components/DropdownButton",component:_woocommerce_components__WEBPACK_IMPORTED_MODULE_2__.A};Basic.parameters={...Basic.parameters,docs:{...Basic.parameters?.docs,source:{originalSource:"() => <Dropdown renderToggle={({\n isOpen,\n onToggle\n}) => <DropdownButton onClick={onToggle} isOpen={isOpen} labels={['All products Sold']} />} renderContent={() => <p>Dropdown content here</p>} />",...Basic.parameters?.docs?.source}}}}}]); |