@wordpress/boot 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-module/components/app/index.mjs +29 -53
- package/build-module/components/app/index.mjs.map +1 -7
- package/build-module/components/app/router.mjs +238 -214
- package/build-module/components/app/router.mjs.map +1 -7
- package/build-module/components/app/use-route-title.mjs +35 -42
- package/build-module/components/app/use-route-title.mjs.map +1 -7
- package/build-module/components/canvas/back-button.mjs +21 -20
- package/build-module/components/canvas/back-button.mjs.map +1 -7
- package/build-module/components/canvas/index.mjs +103 -129
- package/build-module/components/canvas/index.mjs.map +1 -7
- package/build-module/components/canvas/site-preview.mjs +36 -43
- package/build-module/components/canvas/site-preview.mjs.map +1 -7
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
- package/build-module/components/canvas/viewport.mjs +25 -13
- package/build-module/components/canvas/viewport.mjs.map +1 -7
- package/build-module/components/canvas-renderer/index.mjs +40 -32
- package/build-module/components/canvas-renderer/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +160 -108
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
- package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
- package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/index.mjs +55 -90
- package/build-module/components/navigation/index.mjs.map +1 -7
- package/build-module/components/navigation/items.mjs +51 -53
- package/build-module/components/navigation/items.mjs.map +1 -7
- package/build-module/components/navigation/navigation-item/index.mjs +120 -114
- package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
- package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
- package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
- package/build-module/components/navigation/path-matching.mjs +74 -73
- package/build-module/components/navigation/path-matching.mjs.map +1 -7
- package/build-module/components/navigation/router-link-item.mjs +13 -11
- package/build-module/components/navigation/router-link-item.mjs.map +1 -7
- package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
- package/build-module/components/plugin-area/index.mjs +20 -24
- package/build-module/components/plugin-area/index.mjs.map +1 -7
- package/build-module/components/root/index.mjs +227 -242
- package/build-module/components/root/index.mjs.map +1 -7
- package/build-module/components/root/single-page.mjs +174 -148
- package/build-module/components/root/single-page.mjs.map +1 -7
- package/build-module/components/root/use-sync-body-background.mjs +28 -22
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +170 -214
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/save-panel/index.mjs +110 -106
- package/build-module/components/save-panel/index.mjs.map +1 -7
- package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +126 -104
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/index.mjs +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +34 -31
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +9 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +48 -55
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +21 -16
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/types.mjs +0 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/store/types.d.ts +1 -1
- package/package.json +30 -31
- package/src/components/canvas/index.tsx +2 -2
- package/src/components/error-boundary/index.tsx +50 -4
- package/src/store/types.ts +1 -1
- package/CHANGELOG.md +0 -81
- package/build-module/index.mjs.map +0 -7
- package/build-module/store/types.mjs.map +0 -7
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/navigation/drilldown-item/index.tsx", "../../../../../style-runtime/src/index.ts", "../../../../src/components/navigation/navigation-item/style.module.scss"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport {\n\tFlexBlock,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\nimport { chevronRightSmall, chevronLeftSmall } from '@wordpress/icons';\nimport { wrapIcon } from '../items';\nimport type { IconType } from '../../../store/types';\nimport styles from '../navigation-item/style.module.scss';\n\ninterface DrilldownItemProps {\n\t/**\n\t * Optional CSS class name.\n\t */\n\tclassName?: string;\n\t/**\n\t * Identifier of the navigation item.\n\t */\n\tid: string;\n\t/**\n\t * Icon to display with the navigation item.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Whether to show placeholder icons for alignment.\n\t */\n\tshouldShowPlaceholder?: boolean;\n\t/**\n\t * Content to display inside the navigation item.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Function to handle sidebar navigation when the item is clicked.\n\t */\n\tonNavigate: ( {\n\t\tid,\n\t\tdirection,\n\t}: {\n\t\tid?: string;\n\t\tdirection: 'forward' | 'backward';\n\t} ) => void;\n}\n\nexport default function DrilldownItem( {\n\tclassName,\n\tid,\n\ticon,\n\tshouldShowPlaceholder = true,\n\tchildren,\n\tonNavigate,\n}: DrilldownItemProps ) {\n\tconst handleClick = ( e: React.MouseEvent ) => {\n\t\te.preventDefault();\n\t\tonNavigate( { id, direction: 'forward' } );\n\t};\n\n\treturn (\n\t\t<Item\n\t\t\tclassName={ clsx( styles.item, className ) }\n\t\t\tonClick={ handleClick }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\tstyle={ { flexGrow: '1' } }\n\t\t\t>\n\t\t\t\t{ wrapIcon( icon, shouldShowPlaceholder ) }\n\t\t\t\t<FlexBlock>{ children }</FlexBlock>\n\t\t\t\t<WCIcon\n\t\t\t\t\ticon={ isRTL() ? chevronLeftSmall : chevronRightSmall }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</Item>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"74796ab776\", \".d5331ded354c389a__item.d5331ded354c389a__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}.d5331ded354c389a__item.d5331ded354c389a__item:focus,.d5331ded354c389a__item.d5331ded354c389a__item:hover,.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}.d5331ded354c389a__item.d5331ded354c389a__item svg:last-child{padding:4px}.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=page],.d5331ded354c389a__item.d5331ded354c389a__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}.d5331ded354c389a__item.d5331ded354c389a__item:focus-visible{transform:translateZ(0)}.d5331ded354c389a__item._44ce5374f19a05f7__is-compact{min-height:24px}\");\n}\nexport default {\"item\":\"d5331ded354c389a__item\",\"is-compact\":\"_44ce5374f19a05f7__is-compact\"};\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AAEjB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,QAAQ;AAAA,OACF;AACP,SAAS,aAAa;AACtB,SAAS,mBAAmB,wBAAwB;AACpD,SAAS,gBAAgB;;;ACAzB,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;AAC3E,MAAK,CAAE,eAAe,MAAO;AAC5B;AAAA,EACD;AAEA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;AAEhE,MAAK,CAAE,gBAAiB;AACvB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAK,gBAAgB,cAAe;AAAA,EAC5D;AAEA,MAAK,eAAe,IAAK,IAAK,GAAI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GAAwB;AACvB,QAAM,cAAc,CAAE,MAAyB;AAC9C,MAAE,eAAe;AACjB,eAAY,EAAE,IAAI,WAAW,UAAU,CAAE;AAAA,EAC1C;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,qBAAO,MAAM,SAAU;AAAA,MACzC,SAAU;AAAA,MAEV;AAAA,QAAC;AAAA;AAAA,UACA,SAAQ;AAAA,UACR,SAAU;AAAA,UACV,OAAQ,EAAE,UAAU,IAAI;AAAA,UAEtB;AAAA,qBAAU,MAAM,qBAAsB;AAAA,YACxC,oBAAC,aAAY,UAAU;AAAA,YACvB;AAAA,cAAC;AAAA;AAAA,gBACA,MAAO,MAAM,IAAI,mBAAmB;AAAA;AAAA,YACrC;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Item","styles","HStack","WCIcon"],"sources":["../../../../../style-runtime/src/index.ts","../../../../src/components/navigation/navigation-item/style.module.scss","../../../../src/components/navigation/drilldown-item/index.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"1f139f6281\", \"._42242b9e34dc6a19__item._42242b9e34dc6a19__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus,._42242b9e34dc6a19__item._42242b9e34dc6a19__item:hover,._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._42242b9e34dc6a19__item._42242b9e34dc6a19__item svg:last-child{padding:4px}._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=page],._42242b9e34dc6a19__item._42242b9e34dc6a19__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus-visible{transform:translateZ(0)}._42242b9e34dc6a19__item._5feca241f78b1f09__is-compact{min-height:24px}\");\n}\nexport default {\"item\":\"_42242b9e34dc6a19__item\",\"is-compact\":\"_5feca241f78b1f09__is-compact\"};\n","import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport {\n\tFlexBlock,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\nimport { chevronRightSmall, chevronLeftSmall } from '@wordpress/icons';\nimport { wrapIcon } from '../items';\nimport type { IconType } from '../../../store/types';\nimport styles from '../navigation-item/style.module.scss';\n\ninterface DrilldownItemProps {\n\t/**\n\t * Optional CSS class name.\n\t */\n\tclassName?: string;\n\t/**\n\t * Identifier of the navigation item.\n\t */\n\tid: string;\n\t/**\n\t * Icon to display with the navigation item.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Whether to show placeholder icons for alignment.\n\t */\n\tshouldShowPlaceholder?: boolean;\n\t/**\n\t * Content to display inside the navigation item.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Function to handle sidebar navigation when the item is clicked.\n\t */\n\tonNavigate: ( {\n\t\tid,\n\t\tdirection,\n\t}: {\n\t\tid?: string;\n\t\tdirection: 'forward' | 'backward';\n\t} ) => void;\n}\n\nexport default function DrilldownItem( {\n\tclassName,\n\tid,\n\ticon,\n\tshouldShowPlaceholder = true,\n\tchildren,\n\tonNavigate,\n}: DrilldownItemProps ) {\n\tconst handleClick = ( e: React.MouseEvent ) => {\n\t\te.preventDefault();\n\t\tonNavigate( { id, direction: 'forward' } );\n\t};\n\n\treturn (\n\t\t<Item\n\t\t\tclassName={ clsx( styles.item, className ) }\n\t\t\tonClick={ handleClick }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\tstyle={ { flexGrow: '1' } }\n\t\t\t>\n\t\t\t\t{ wrapIcon( icon, shouldShowPlaceholder ) }\n\t\t\t\t<FlexBlock>{ children }</FlexBlock>\n\t\t\t\t<WCIcon\n\t\t\t\t\ticon={ isRTL() ? chevronLeftSmall : chevronRightSmall }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</Item>\n\t);\n}\n"],"mappings":";;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA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uBAAe;CAAC,QAAO;CAA0B,cAAa;AAA+B;;AC2C7F,SAAwB,cAAe,EACtC,WACA,IACA,MACA,wBAAwB,MACxB,UACA,cACuB;CACvB,MAAM,eAAgB,MAAyB;EAC9C,EAAE,eAAe;EACjB,WAAY;GAAE;GAAI,WAAW;EAAU,CAAE;CAC1C;CAEA,OACC,oBAACA,oBAAD;EACC,WAAY,KAAMC,qBAAO,MAAM,SAAU;EACzC,SAAU;EAEV,UAAA,qBAACC,sBAAD;GACC,SAAQ;GACR,SAAU;GACV,OAAQ,EAAE,UAAU,IAAI;GAHzB,UAAA;IAKG,SAAU,MAAM,qBAAsB;IACxC,oBAAC,WAAD,EAAa,SAAqB,CAAA;IAClC,oBAACC,MAAD,EACC,MAAO,MAAM,IAAI,mBAAmB,kBACpC,CAAA;GACM;;CACH,CAAA;AAER"}
|
|
@@ -1,195 +1,178 @@
|
|
|
1
|
-
// packages/boot/src/components/navigation/dropdown-item/index.tsx
|
|
2
1
|
import clsx from "clsx";
|
|
3
|
-
import {
|
|
4
|
-
FlexBlock,
|
|
5
|
-
__experimentalItem as Item,
|
|
6
|
-
__experimentalHStack as HStack,
|
|
7
|
-
Icon as WCIcon,
|
|
8
|
-
__unstableMotion as motion,
|
|
9
|
-
__unstableAnimatePresence as AnimatePresence
|
|
10
|
-
} from "@wordpress/components";
|
|
2
|
+
import { FlexBlock, Icon, __experimentalHStack, __experimentalItem, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
|
|
11
3
|
import { chevronDownSmall } from "@wordpress/icons";
|
|
12
4
|
import { useReducedMotion } from "@wordpress/compose";
|
|
13
5
|
import { useSelect } from "@wordpress/data";
|
|
14
6
|
import { STORE_NAME } from "../../../store/index.mjs";
|
|
15
7
|
import NavigationItem from "../navigation-item/index.mjs";
|
|
16
8
|
import { wrapIcon } from "../items.mjs";
|
|
17
|
-
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
10
|
// packages/style-runtime/src/index.ts
|
|
19
|
-
|
|
11
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
12
|
+
/**
|
|
13
|
+
* Returns the shared style runtime registry.
|
|
14
|
+
*
|
|
15
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
16
|
+
* package can coordinate through the same document and style maps.
|
|
17
|
+
*
|
|
18
|
+
* @return The shared runtime registry.
|
|
19
|
+
*/
|
|
20
20
|
function getRuntime() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (typeof document !== "undefined") {
|
|
31
|
-
registerDocument(document);
|
|
32
|
-
}
|
|
33
|
-
return globalScope.__wpStyleRuntime;
|
|
21
|
+
const globalScope = globalThis;
|
|
22
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
23
|
+
globalScope.__wpStyleRuntime = {
|
|
24
|
+
documents: /* @__PURE__ */ new Map(),
|
|
25
|
+
styles: /* @__PURE__ */ new Map(),
|
|
26
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
27
|
+
};
|
|
28
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
29
|
+
return globalScope.__wpStyleRuntime;
|
|
34
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
33
|
+
*
|
|
34
|
+
* @param targetDocument Document to inspect.
|
|
35
|
+
* @param hash Stable hash for the transformed CSS.
|
|
36
|
+
*
|
|
37
|
+
* @return Whether the style hash already exists in the document.
|
|
38
|
+
*/
|
|
35
39
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
40
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
41
|
-
)) {
|
|
42
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
40
|
+
if (!targetDocument.head) return false;
|
|
41
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
42
|
+
return false;
|
|
47
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Injects a registered style into a document, unless that document already
|
|
46
|
+
* contains a style tag for the same hash.
|
|
47
|
+
*
|
|
48
|
+
* @param targetDocument Document to inject the style into.
|
|
49
|
+
* @param hash Stable hash for the transformed CSS.
|
|
50
|
+
* @param css CSS text to inject.
|
|
51
|
+
*/
|
|
48
52
|
function injectStyle(targetDocument, hash, css) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
67
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
68
|
-
targetDocument.head.appendChild(style);
|
|
69
|
-
injectedStyles.add(hash);
|
|
53
|
+
if (!targetDocument.head) return;
|
|
54
|
+
const runtime = getRuntime();
|
|
55
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
56
|
+
if (!injectedStyles) {
|
|
57
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
58
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
59
|
+
}
|
|
60
|
+
if (injectedStyles.has(hash)) return;
|
|
61
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
62
|
+
injectedStyles.add(hash);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const style = targetDocument.createElement("style");
|
|
66
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
67
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
68
|
+
targetDocument.head.appendChild(style);
|
|
69
|
+
injectedStyles.add(hash);
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Registers a document as a style injection target.
|
|
73
|
+
*
|
|
74
|
+
* Existing registered styles are replayed into the document immediately.
|
|
75
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
76
|
+
* same document without one cleanup removing it while another registration is
|
|
77
|
+
* still active.
|
|
78
|
+
*
|
|
79
|
+
* @param targetDocument Document to receive registered styles.
|
|
80
|
+
* @return Cleanup function that unregisters this document registration.
|
|
81
|
+
*/
|
|
71
82
|
function registerDocument(targetDocument) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
if (count <= 1) {
|
|
86
|
-
runtime.documents.delete(targetDocument);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
90
|
-
};
|
|
83
|
+
const runtime = getRuntime();
|
|
84
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
85
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
86
|
+
return () => {
|
|
87
|
+
const count = runtime.documents.get(targetDocument);
|
|
88
|
+
if (count === void 0) return;
|
|
89
|
+
if (count <= 1) {
|
|
90
|
+
runtime.documents.delete(targetDocument);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
94
|
+
};
|
|
91
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Registers a style and injects it into all registered documents.
|
|
98
|
+
*
|
|
99
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
100
|
+
* the same hash will not add duplicate style tags to a document.
|
|
101
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
102
|
+
* replayed into documents that are registered later.
|
|
103
|
+
*
|
|
104
|
+
* @param hash Stable hash for the transformed CSS.
|
|
105
|
+
* @param css CSS text to inject.
|
|
106
|
+
*/
|
|
92
107
|
function registerStyle(hash, css) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
injectStyle(targetDocument, hash, css);
|
|
97
|
-
}
|
|
108
|
+
const runtime = getRuntime();
|
|
109
|
+
runtime.styles.set(hash, css);
|
|
110
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
98
111
|
}
|
|
99
|
-
|
|
100
112
|
// packages/boot/src/components/navigation/navigation-item/style.module.scss
|
|
101
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("1f139f6281", "._42242b9e34dc6a19__item._42242b9e34dc6a19__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus,._42242b9e34dc6a19__item._42242b9e34dc6a19__item:hover,._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._42242b9e34dc6a19__item._42242b9e34dc6a19__item svg:last-child{padding:4px}._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=page],._42242b9e34dc6a19__item._42242b9e34dc6a19__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus-visible{transform:translateZ(0)}._42242b9e34dc6a19__item._5feca241f78b1f09__is-compact{min-height:24px}");
|
|
114
|
+
var style_module_default$1 = {
|
|
115
|
+
"item": "_42242b9e34dc6a19__item",
|
|
116
|
+
"is-compact": "_5feca241f78b1f09__is-compact"
|
|
117
|
+
};
|
|
106
118
|
// packages/boot/src/components/navigation/dropdown-item/style.module.scss
|
|
107
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("afe932ce31", "._51fbf12353b41bfd__dropdown{display:block}.d62b19ea84deb921__dropdown-children{display:flex;flex-direction:column;margin-block-end:2px;margin-block-start:-2px;margin-inline-start:30px;overflow:hidden;padding:2px}._32fed855b8f13ebb__chevron._3ab794a15eff17b0__is-up{transform:rotate(180deg)}");
|
|
120
|
+
var style_module_default = {
|
|
121
|
+
"dropdown": "_51fbf12353b41bfd__dropdown",
|
|
122
|
+
"dropdown-children": "d62b19ea84deb921__dropdown-children",
|
|
123
|
+
"chevron": "_32fed855b8f13ebb__chevron",
|
|
124
|
+
"is-up": "_3ab794a15eff17b0__is-up"
|
|
125
|
+
};
|
|
112
126
|
// packages/boot/src/components/navigation/dropdown-item/index.tsx
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isExpanded && /* @__PURE__ */ jsx(
|
|
167
|
-
motion.div,
|
|
168
|
-
{
|
|
169
|
-
initial: { height: 0 },
|
|
170
|
-
animate: { height: "auto" },
|
|
171
|
-
exit: { height: 0 },
|
|
172
|
-
transition: {
|
|
173
|
-
type: "tween",
|
|
174
|
-
duration: disableMotion ? 0 : ANIMATION_DURATION,
|
|
175
|
-
ease: "easeOut"
|
|
176
|
-
},
|
|
177
|
-
className: style_module_default2["dropdown-children"],
|
|
178
|
-
children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
179
|
-
NavigationItem,
|
|
180
|
-
{
|
|
181
|
-
className: style_module_default["is-compact"],
|
|
182
|
-
to: item.to,
|
|
183
|
-
shouldShowPlaceholder: false,
|
|
184
|
-
children: item.label
|
|
185
|
-
},
|
|
186
|
-
index
|
|
187
|
-
))
|
|
188
|
-
}
|
|
189
|
-
) })
|
|
190
|
-
] });
|
|
127
|
+
const ANIMATION_DURATION = .2;
|
|
128
|
+
function DropdownItem({ className, id, icon, children, isExpanded, onToggle }) {
|
|
129
|
+
const items = useSelect((select) => select(STORE_NAME).getMenuItems(), []).filter((item) => item.parent === id);
|
|
130
|
+
const disableMotion = useReducedMotion();
|
|
131
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
132
|
+
className: style_module_default.dropdown,
|
|
133
|
+
children: [/* @__PURE__ */ jsx(__experimentalItem, {
|
|
134
|
+
className: clsx(style_module_default$1.item, className),
|
|
135
|
+
onClick: (e) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
onToggle();
|
|
139
|
+
},
|
|
140
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
141
|
+
children: /* @__PURE__ */ jsxs(__experimentalHStack, {
|
|
142
|
+
justify: "flex-start",
|
|
143
|
+
spacing: 2,
|
|
144
|
+
style: { flexGrow: "1" },
|
|
145
|
+
children: [
|
|
146
|
+
wrapIcon(icon, false),
|
|
147
|
+
/* @__PURE__ */ jsx(FlexBlock, { children }),
|
|
148
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
149
|
+
icon: chevronDownSmall,
|
|
150
|
+
className: clsx(style_module_default.chevron, { [style_module_default["is-up"]]: isExpanded })
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
})
|
|
154
|
+
}), /* @__PURE__ */ jsx(__unstableAnimatePresence, {
|
|
155
|
+
initial: false,
|
|
156
|
+
children: isExpanded && /* @__PURE__ */ jsx(__unstableMotion.div, {
|
|
157
|
+
initial: { height: 0 },
|
|
158
|
+
animate: { height: "auto" },
|
|
159
|
+
exit: { height: 0 },
|
|
160
|
+
transition: {
|
|
161
|
+
type: "tween",
|
|
162
|
+
duration: disableMotion ? 0 : ANIMATION_DURATION,
|
|
163
|
+
ease: "easeOut"
|
|
164
|
+
},
|
|
165
|
+
className: style_module_default["dropdown-children"],
|
|
166
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx(NavigationItem, {
|
|
167
|
+
className: style_module_default$1["is-compact"],
|
|
168
|
+
to: item.to,
|
|
169
|
+
shouldShowPlaceholder: false,
|
|
170
|
+
children: item.label
|
|
171
|
+
}, index))
|
|
172
|
+
})
|
|
173
|
+
})]
|
|
174
|
+
});
|
|
191
175
|
}
|
|
192
|
-
export {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
//# sourceMappingURL=index.mjs.map
|
|
176
|
+
export { DropdownItem as default };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/navigation/dropdown-item/index.tsx", "../../../../../style-runtime/src/index.ts", "../../../../src/components/navigation/navigation-item/style.module.scss", "../../../../src/components/navigation/dropdown-item/style.module.scss"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport {\n\tFlexBlock,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { chevronDownSmall } from '@wordpress/icons';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { STORE_NAME } from '../../../store';\nimport NavigationItem from '../navigation-item';\nimport { wrapIcon } from '../items';\nimport type { IconType, MenuItem } from '../../../store/types';\nimport navigationItemStyles from '../navigation-item/style.module.scss';\nimport styles from './style.module.scss';\n\nconst ANIMATION_DURATION = 0.2;\n\ninterface DropdownItemProps {\n\t/**\n\t * Optional CSS class name.\n\t */\n\tclassName?: string;\n\t/**\n\t * Identifier of the parent menu item.\n\t */\n\tid: string;\n\t/**\n\t * Icon to display with the dropdown item.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Whether to show placeholder icons for alignment.\n\t */\n\tshouldShowPlaceholder?: boolean;\n\t/**\n\t * Content to display inside the dropdown item.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Whether this dropdown is currently expanded.\n\t */\n\tisExpanded: boolean;\n\t/**\n\t * Function to toggle this dropdown's expanded state.\n\t */\n\tonToggle: () => void;\n}\n\nexport default function DropdownItem( {\n\tclassName,\n\tid,\n\ticon,\n\tchildren,\n\tisExpanded,\n\tonToggle,\n}: DropdownItemProps ) {\n\tconst menuItems: MenuItem[] = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error Store types are not available when selecting by store name.\n\t\t\tselect( STORE_NAME ).getMenuItems(),\n\t\t[]\n\t);\n\tconst items = menuItems.filter( ( item ) => item.parent === id );\n\tconst disableMotion = useReducedMotion();\n\treturn (\n\t\t<div className={ styles.dropdown }>\n\t\t\t<Item\n\t\t\t\tclassName={ clsx( navigationItemStyles.item, className ) }\n\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tonToggle();\n\t\t\t\t} }\n\t\t\t\tonMouseDown={ ( e ) => e.preventDefault() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tstyle={ { flexGrow: '1' } }\n\t\t\t\t>\n\t\t\t\t\t{ wrapIcon( icon, false ) }\n\t\t\t\t\t<FlexBlock>{ children }</FlexBlock>\n\t\t\t\t\t<WCIcon\n\t\t\t\t\t\ticon={ chevronDownSmall }\n\t\t\t\t\t\tclassName={ clsx( styles.chevron, {\n\t\t\t\t\t\t\t[ styles[ 'is-up' ] ]: isExpanded,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</Item>\n\t\t\t<AnimatePresence initial={ false }>\n\t\t\t\t{ isExpanded && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tinitial={ { height: 0 } }\n\t\t\t\t\t\tanimate={ { height: 'auto' } }\n\t\t\t\t\t\texit={ { height: 0 } }\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion ? 0 : ANIMATION_DURATION,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tclassName={ styles[ 'dropdown-children' ] }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tnavigationItemStyles[ 'is-compact' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tto={ item.to }\n\t\t\t\t\t\t\t\tshouldShowPlaceholder={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t</NavigationItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"74796ab776\", \".d5331ded354c389a__item.d5331ded354c389a__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}.d5331ded354c389a__item.d5331ded354c389a__item:focus,.d5331ded354c389a__item.d5331ded354c389a__item:hover,.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}.d5331ded354c389a__item.d5331ded354c389a__item svg:last-child{padding:4px}.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=page],.d5331ded354c389a__item.d5331ded354c389a__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}.d5331ded354c389a__item.d5331ded354c389a__item:focus-visible{transform:translateZ(0)}.d5331ded354c389a__item._44ce5374f19a05f7__is-compact{min-height:24px}\");\n}\nexport default {\"item\":\"d5331ded354c389a__item\",\"is-compact\":\"_44ce5374f19a05f7__is-compact\"};\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"1a6b086e6c\", \"._093b894bfb82e8de__dropdown{display:block}._5954dba25ac6e16f__dropdown-children{display:flex;flex-direction:column;margin-block-end:2px;margin-block-start:-2px;margin-inline-start:30px;overflow:hidden;padding:2px}._9a14116ec9dae0e2__chevron.a9ebdaa3f36d6986__is-up{transform:rotate(180deg)}\");\n}\nexport default {\"dropdown\":\"_093b894bfb82e8de__dropdown\",\"dropdown-children\":\"_5954dba25ac6e16f__dropdown-children\",\"chevron\":\"_9a14116ec9dae0e2__chevron\",\"is-up\":\"a9ebdaa3f36d6986__is-up\"};\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AAEjB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,OACvB;AACP,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,OAAO,oBAAoB;AAC3B,SAAS,gBAAgB;;;ACLzB,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM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"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styles","Item","navigationItemStyles","HStack","WCIcon","AnimatePresence","motion"],"sources":["../../../../../style-runtime/src/index.ts","../../../../src/components/navigation/navigation-item/style.module.scss","../../../../src/components/navigation/dropdown-item/style.module.scss","../../../../src/components/navigation/dropdown-item/index.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"1f139f6281\", \"._42242b9e34dc6a19__item._42242b9e34dc6a19__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus,._42242b9e34dc6a19__item._42242b9e34dc6a19__item:hover,._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._42242b9e34dc6a19__item._42242b9e34dc6a19__item svg:last-child{padding:4px}._42242b9e34dc6a19__item._42242b9e34dc6a19__item[aria-current=page],._42242b9e34dc6a19__item._42242b9e34dc6a19__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}._42242b9e34dc6a19__item._42242b9e34dc6a19__item:focus-visible{transform:translateZ(0)}._42242b9e34dc6a19__item._5feca241f78b1f09__is-compact{min-height:24px}\");\n}\nexport default {\"item\":\"_42242b9e34dc6a19__item\",\"is-compact\":\"_5feca241f78b1f09__is-compact\"};\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"afe932ce31\", \"._51fbf12353b41bfd__dropdown{display:block}.d62b19ea84deb921__dropdown-children{display:flex;flex-direction:column;margin-block-end:2px;margin-block-start:-2px;margin-inline-start:30px;overflow:hidden;padding:2px}._32fed855b8f13ebb__chevron._3ab794a15eff17b0__is-up{transform:rotate(180deg)}\");\n}\nexport default {\"dropdown\":\"_51fbf12353b41bfd__dropdown\",\"dropdown-children\":\"d62b19ea84deb921__dropdown-children\",\"chevron\":\"_32fed855b8f13ebb__chevron\",\"is-up\":\"_3ab794a15eff17b0__is-up\"};\n","import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport {\n\tFlexBlock,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { chevronDownSmall } from '@wordpress/icons';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { STORE_NAME } from '../../../store';\nimport NavigationItem from '../navigation-item';\nimport { wrapIcon } from '../items';\nimport type { IconType, MenuItem } from '../../../store/types';\nimport navigationItemStyles from '../navigation-item/style.module.scss';\nimport styles from './style.module.scss';\n\nconst ANIMATION_DURATION = 0.2;\n\ninterface DropdownItemProps {\n\t/**\n\t * Optional CSS class name.\n\t */\n\tclassName?: string;\n\t/**\n\t * Identifier of the parent menu item.\n\t */\n\tid: string;\n\t/**\n\t * Icon to display with the dropdown item.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Whether to show placeholder icons for alignment.\n\t */\n\tshouldShowPlaceholder?: boolean;\n\t/**\n\t * Content to display inside the dropdown item.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Whether this dropdown is currently expanded.\n\t */\n\tisExpanded: boolean;\n\t/**\n\t * Function to toggle this dropdown's expanded state.\n\t */\n\tonToggle: () => void;\n}\n\nexport default function DropdownItem( {\n\tclassName,\n\tid,\n\ticon,\n\tchildren,\n\tisExpanded,\n\tonToggle,\n}: DropdownItemProps ) {\n\tconst menuItems: MenuItem[] = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error Store types are not available when selecting by store name.\n\t\t\tselect( STORE_NAME ).getMenuItems(),\n\t\t[]\n\t);\n\tconst items = menuItems.filter( ( item ) => item.parent === id );\n\tconst disableMotion = useReducedMotion();\n\treturn (\n\t\t<div className={ styles.dropdown }>\n\t\t\t<Item\n\t\t\t\tclassName={ clsx( navigationItemStyles.item, className ) }\n\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\tonToggle();\n\t\t\t\t} }\n\t\t\t\tonMouseDown={ ( e ) => e.preventDefault() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tstyle={ { flexGrow: '1' } }\n\t\t\t\t>\n\t\t\t\t\t{ wrapIcon( icon, false ) }\n\t\t\t\t\t<FlexBlock>{ children }</FlexBlock>\n\t\t\t\t\t<WCIcon\n\t\t\t\t\t\ticon={ chevronDownSmall }\n\t\t\t\t\t\tclassName={ clsx( styles.chevron, {\n\t\t\t\t\t\t\t[ styles[ 'is-up' ] ]: isExpanded,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</Item>\n\t\t\t<AnimatePresence initial={ false }>\n\t\t\t\t{ isExpanded && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tinitial={ { height: 0 } }\n\t\t\t\t\t\tanimate={ { height: 'auto' } }\n\t\t\t\t\t\texit={ { height: 0 } }\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion ? 0 : ANIMATION_DURATION,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tclassName={ styles[ 'dropdown-children' ] }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<NavigationItem\n\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tnavigationItemStyles[ 'is-compact' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tto={ item.to }\n\t\t\t\t\t\t\t\tshouldShowPlaceholder={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t</NavigationItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;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