@wordpress/components 28.7.0 → 28.8.1-next.1f6eadc42.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/CHANGELOG.md +32 -0
- package/build/box-control/utils.js +1 -1
- package/build/box-control/utils.js.map +1 -1
- package/build/composite/context.js +1 -1
- package/build/composite/context.js.map +1 -1
- package/build/composite/group-label.js +1 -1
- package/build/composite/group-label.js.map +1 -1
- package/build/composite/group.js +1 -1
- package/build/composite/group.js.map +1 -1
- package/build/composite/hover.js +1 -1
- package/build/composite/hover.js.map +1 -1
- package/build/composite/index.js +17 -26
- package/build/composite/index.js.map +1 -1
- package/build/composite/item.js +1 -1
- package/build/composite/item.js.map +1 -1
- package/build/composite/legacy/index.js +59 -8
- package/build/composite/legacy/index.js.map +1 -1
- package/build/composite/row.js +1 -1
- package/build/composite/row.js.map +1 -1
- package/build/composite/typeahead.js +1 -1
- package/build/composite/typeahead.js.map +1 -1
- package/build/composite/types.js.map +1 -1
- package/build/date-time/date/index.js +1 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/date-time/date/styles.js +35 -24
- package/build/date-time/date/styles.js.map +1 -1
- package/build/date-time/date/use-lilius/index.js +163 -0
- package/build/date-time/date/use-lilius/index.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/modal/index.js +11 -4
- package/build/modal/index.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +5 -0
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/private-apis.js +0 -9
- package/build/private-apis.js.map +1 -1
- package/build/slot-fill/index.js +1 -0
- package/build/slot-fill/index.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tablist.js +5 -4
- package/build/tabs/tablist.js.map +1 -1
- package/build/utils/element-rect.js +73 -105
- package/build/utils/element-rect.js.map +1 -1
- package/build-module/box-control/utils.js +1 -1
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/composite/context.js +1 -1
- package/build-module/composite/context.js.map +1 -1
- package/build-module/composite/group-label.js +1 -1
- package/build-module/composite/group-label.js.map +1 -1
- package/build-module/composite/group.js +1 -1
- package/build-module/composite/group.js.map +1 -1
- package/build-module/composite/hover.js +1 -1
- package/build-module/composite/hover.js.map +1 -1
- package/build-module/composite/index.js +17 -26
- package/build-module/composite/index.js.map +1 -1
- package/build-module/composite/item.js +1 -1
- package/build-module/composite/item.js.map +1 -1
- package/build-module/composite/legacy/index.js +56 -8
- package/build-module/composite/legacy/index.js.map +1 -1
- package/build-module/composite/row.js +1 -1
- package/build-module/composite/row.js.map +1 -1
- package/build-module/composite/typeahead.js +1 -1
- package/build-module/composite/typeahead.js.map +1 -1
- package/build-module/composite/types.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -2
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +31 -24
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/date-time/date/use-lilius/index.js +158 -0
- package/build-module/date-time/date/use-lilius/index.js.map +1 -0
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/modal/index.js +12 -4
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +4 -0
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/private-apis.js +0 -9
- package/build-module/private-apis.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -0
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tablist.js +5 -4
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/utils/element-rect.js +74 -105
- package/build-module/utils/element-rect.js.map +1 -1
- package/build-style/style-rtl.css +1 -4
- package/build-style/style.css +1 -4
- package/build-types/box-control/utils.d.ts +1 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/composite/context.d.ts.map +1 -1
- package/build-types/composite/index.d.ts +36 -24
- package/build-types/composite/index.d.ts.map +1 -1
- package/build-types/composite/legacy/index.d.ts +25 -2
- package/build-types/composite/legacy/index.d.ts.map +1 -1
- package/build-types/composite/legacy/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts +9 -9
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/types.d.ts +11 -10
- package/build-types/composite/types.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts +0 -3
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
- package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
- package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts +3 -0
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +3 -0
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/utils/element-rect.d.ts +32 -74
- package/build-types/utils/element-rect.d.ts.map +1 -1
- package/package.json +19 -20
- package/src/box-control/utils.ts +1 -1
- package/src/composite/README.md +5 -24
- package/src/composite/{context.ts → context.tsx} +1 -2
- package/src/composite/group-label.tsx +1 -1
- package/src/composite/group.tsx +1 -1
- package/src/composite/hover.tsx +1 -1
- package/src/composite/index.tsx +17 -28
- package/src/composite/item.tsx +1 -1
- package/src/composite/legacy/index.tsx +72 -11
- package/src/composite/legacy/stories/index.story.tsx +2 -1
- package/src/composite/legacy/test/index.tsx +57 -1
- package/src/composite/row.tsx +1 -1
- package/src/composite/stories/index.story.tsx +185 -169
- package/src/composite/typeahead.tsx +1 -1
- package/src/composite/types.ts +13 -15
- package/src/date-time/date/index.tsx +1 -1
- package/src/date-time/date/styles.ts +31 -11
- package/src/date-time/date/test/use-lilius.ts +417 -0
- package/src/date-time/date/use-lilius/index.ts +394 -0
- package/src/index.ts +1 -0
- package/src/modal/index.tsx +16 -7
- package/src/modal/stories/index.story.tsx +8 -14
- package/src/modal/style.scss +0 -5
- package/src/navigator/navigator-screen/component.tsx +7 -0
- package/src/navigator/test/index.tsx +8 -0
- package/src/popover/style.scss +2 -1
- package/src/private-apis.ts +0 -9
- package/src/select-control/README.md +2 -2
- package/src/slot-fill/index.tsx +1 -0
- package/src/tabs/styles.ts +40 -11
- package/src/tabs/tablist.tsx +5 -4
- package/src/utils/element-rect.ts +93 -130
- package/tsconfig.tsbuildinfo +1 -1
- package/build/composite/store.js +0 -54
- package/build/composite/store.js.map +0 -1
- package/build-module/composite/store.js +0 -46
- package/build-module/composite/store.js.map +0 -1
- package/build-types/composite/store.d.ts +0 -25
- package/build-types/composite/store.d.ts.map +0 -1
- package/build-types/composite/stories/utils.d.ts +0 -29
- package/build-types/composite/stories/utils.d.ts.map +0 -1
- package/src/composite/store.ts +0 -46
- package/src/composite/stories/utils.tsx +0 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Ariakit","COLORS","CONFIG","space","TabListWrapper","_styled","process","env","NODE_ENV","target","label","theme","accent","gray","Tab","foreground","ui","textDisabled","radiusSmall","TabPanel"],"sources":["@wordpress/components/src/tabs/styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * Internal dependencies\n */\nimport { COLORS, CONFIG } from '../utils';\nimport { space } from '../utils/space';\n\nexport const TabListWrapper = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tflex-direction: row;\n\ttext-align: center;\n\n\t&[aria-orientation='vertical'] {\n\t\tflex-direction: column;\n\t\ttext-align: start;\n\t}\n\n\t@media not ( prefers-reduced-motion
|
|
1
|
+
{"version":3,"names":["Ariakit","COLORS","CONFIG","space","TabListWrapper","_styled","process","env","NODE_ENV","target","label","theme","accent","gray","Tab","foreground","ui","textDisabled","radiusSmall","TabPanel"],"sources":["@wordpress/components/src/tabs/styles.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * Internal dependencies\n */\nimport { COLORS, CONFIG } from '../utils';\nimport { space } from '../utils/space';\n\nexport const TabListWrapper = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tflex-direction: row;\n\ttext-align: center;\n\n\t&[aria-orientation='vertical'] {\n\t\tflex-direction: column;\n\t\ttext-align: start;\n\t}\n\n\t@media not ( prefers-reduced-motion ) {\n\t\t&.is-animation-enabled::after {\n\t\t\ttransition-property: transform;\n\t\t\ttransition-duration: 0.2s;\n\t\t\ttransition-timing-function: ease-out;\n\t\t}\n\t}\n\t--direction-factor: 1;\n\t--direction-origin-x: left;\n\t--indicator-start: var( --indicator-left );\n\t&:dir( rtl ) {\n\t\t--direction-factor: -1;\n\t\t--direction-origin-x: right;\n\t\t--indicator-start: var( --indicator-right );\n\t}\n\t&::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tpointer-events: none;\n\t\ttransform-origin: var( --direction-origin-x ) top;\n\n\t\t// Windows high contrast mode.\n\t\toutline: 2px solid transparent;\n\t\toutline-offset: -1px;\n\t}\n\n\t/* Using a large value to avoid antialiasing rounding issues\n\t\t\twhen scaling in the transform, see: https://stackoverflow.com/a/52159123 */\n\t--antialiasing-factor: 100;\n\t&:not( [aria-orientation='vertical'] ) {\n\t\t&::after {\n\t\t\tbottom: 0;\n\t\t\theight: 0;\n\t\t\twidth: calc( var( --antialiasing-factor ) * 1px );\n\t\t\ttransform: translateX(\n\t\t\t\t\tcalc(\n\t\t\t\t\t\tvar( --indicator-start ) * var( --direction-factor ) *\n\t\t\t\t\t\t\t1px\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\tscaleX(\n\t\t\t\t\tcalc(\n\t\t\t\t\t\tvar( --indicator-width ) / var( --antialiasing-factor )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\tborder-bottom: var( --wp-admin-border-width-focus ) solid\n\t\t\t\t${ COLORS.theme.accent };\n\t\t}\n\t}\n\t&[aria-orientation='vertical']::after {\n\t\tz-index: -1;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\twidth: calc( var( --antialiasing-factor ) * 1px );\n\t\ttransform: translateY( calc( var( --indicator-top ) * 1px ) )\n\t\t\tscaleY(\n\t\t\t\tcalc( var( --indicator-height ) / var( --antialiasing-factor ) )\n\t\t\t);\n\t\tbackground-color: ${ COLORS.theme.gray[ 100 ] };\n\t}\n`;\n\nexport const Tab = styled( Ariakit.Tab )`\n\t& {\n\t\tdisplay: inline-flex;\n\t\talign-items: center;\n\t\tposition: relative;\n\t\tborder-radius: 0;\n\t\tmin-height: ${ space(\n\t\t\t12\n\t\t) }; // Avoid fixed height to allow for long strings that go in multiple lines.\n\t\theight: auto;\n\t\tbackground: transparent;\n\t\tborder: none;\n\t\tbox-shadow: none;\n\t\tcursor: pointer;\n\t\tline-height: 1.2; // Some languages characters e.g. Japanese may have a native higher line-height.\n\t\tpadding: ${ space( 4 ) };\n\t\tmargin-left: 0;\n\t\tfont-weight: 500;\n\t\ttext-align: inherit;\n\t\thyphens: auto;\n\t\tcolor: ${ COLORS.theme.foreground };\n\n\t\t&[aria-disabled='true'] {\n\t\t\tcursor: default;\n\t\t\tcolor: ${ COLORS.ui.textDisabled };\n\t\t}\n\n\t\t&:not( [aria-disabled='true'] ):hover {\n\t\t\tcolor: ${ COLORS.theme.accent };\n\t\t}\n\n\t\t&:focus:not( :disabled ) {\n\t\t\tposition: relative;\n\t\t\tbox-shadow: none;\n\t\t\toutline: none;\n\t\t}\n\n\t\t// Focus.\n\t\t&::before {\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\ttop: ${ space( 3 ) };\n\t\t\tright: ${ space( 3 ) };\n\t\t\tbottom: ${ space( 3 ) };\n\t\t\tleft: ${ space( 3 ) };\n\t\t\tpointer-events: none;\n\n\t\t\t// Draw the indicator.\n\t\t\t// Outline works for Windows high contrast mode as well.\n\t\t\toutline: var( --wp-admin-border-width-focus ) solid\n\t\t\t\t${ COLORS.theme.accent };\n\t\t\tborder-radius: ${ CONFIG.radiusSmall };\n\n\t\t\t// Animation\n\t\t\topacity: 0;\n\n\t\t\t@media not ( prefers-reduced-motion ) {\n\t\t\t\ttransition: opacity 0.1s linear;\n\t\t\t}\n\t\t}\n\n\t\t&:focus-visible::before {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\n\t[aria-orientation='vertical'] & {\n\t\tmin-height: ${ space(\n\t\t\t10\n\t\t) }; // Avoid fixed height to allow for long strings that go in multiple lines.\n\t}\n`;\n\nexport const TabPanel = styled( Ariakit.TabPanel )`\n\t&:focus {\n\t\tbox-shadow: none;\n\t\toutline: none;\n\t}\n\n\t&:focus-visible {\n\t\tbox-shadow: 0 0 0 var( --wp-admin-border-width-focus )\n\t\t\t${ COLORS.theme.accent };\n\t\t// Windows high contrast mode.\n\t\toutline: 2px solid transparent;\n\t\toutline-offset: 0;\n\t}\n`;\n"],"mappings":";AAAA;AACA;AACA;;AAEA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;;AAEzC;AACA;AACA;AACA,SAASC,MAAM,EAAEC,MAAM,QAAQ,UAAU;AACzC,SAASC,KAAK,QAAQ,gBAAgB;AAEtC,OAAO,MAAMC,cAAc,gBAAAC,OAAA,QAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,0nCA0DpBT,MAAM,CAACU,KAAK,CAACC,MAAM,4SAaHX,MAAM,CAACU,KAAK,CAACE,IAAI,CAAE,GAAG,CAAE,UAAAP,OAAA,CAAAC,GAAA,CAAAC,QAAA,wpMAE9C;AAED,OAAO,MAAMM,GAAG,gBAAGT,OAAA,CAAQL,OAAO,CAACc,GAAG,EAAAR,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,CAAC,CAAC,2FAMvBP,KAAK,CACnB,EACD,CAAC,6GAOWA,KAAK,CAAE,CAAE,CAAC,2EAKZF,MAAM,CAACU,KAAK,CAACI,UAAU,oDAItBd,MAAM,CAACe,EAAE,CAACC,YAAY,oDAItBhB,MAAM,CAACU,KAAK,CAACC,MAAM,4HAarBT,KAAK,CAAE,CAAE,CAAC,aACRA,KAAK,CAAE,CAAE,CAAC,cACTA,KAAK,CAAE,CAAE,CAAC,YACZA,KAAK,CAAE,CAAE,CAAC,8EAMfF,MAAM,CAACU,KAAK,CAACC,MAAM,qBACLV,MAAM,CAACgB,WAAW,uKAgBtBf,KAAK,CACnB,EACD,CAAC,UAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,wpMAEF;AAED,OAAO,MAAMW,QAAQ,gBAAGd,OAAA,CAAQL,OAAO,CAACmB,QAAQ,EAAAb,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,CAAC,CAAC,iHAQ5CT,MAAM,CAACU,KAAK,CAACC,MAAM,yDAAAN,OAAA,CAAAC,GAAA,CAAAC,QAAA,wpMAKxB","ignoreList":[]}
|
|
@@ -72,10 +72,11 @@ export const TabList = forwardRef(function TabList({
|
|
|
72
72
|
onBlur: onBlur,
|
|
73
73
|
...otherProps,
|
|
74
74
|
style: {
|
|
75
|
-
'--indicator-
|
|
76
|
-
'--indicator-
|
|
77
|
-
'--indicator-
|
|
78
|
-
'--indicator-
|
|
75
|
+
'--indicator-top': indicatorPosition.top,
|
|
76
|
+
'--indicator-right': indicatorPosition.right,
|
|
77
|
+
'--indicator-left': indicatorPosition.left,
|
|
78
|
+
'--indicator-width': indicatorPosition.width,
|
|
79
|
+
'--indicator-height': indicatorPosition.height,
|
|
79
80
|
...otherProps.style
|
|
80
81
|
},
|
|
81
82
|
className: clsx(animationEnabled ? 'is-animation-enabled' : '', otherProps.className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Ariakit","useStoreState","warning","forwardRef","useState","useTabsContext","TabListWrapper","clsx","useTrackElementOffsetRect","useOnValueUpdate","jsx","_jsx","TabList","children","otherProps","ref","context","tabStoreState","store","selectedId","indicatorPosition","item","element","animationEnabled","setAnimationEnabled","previousValue","globalThis","SCRIPT_DEBUG","activeId","selectOnMove","setActiveId","onBlur","render","onTransitionEnd","event","pseudoElement","style","
|
|
1
|
+
{"version":3,"names":["Ariakit","useStoreState","warning","forwardRef","useState","useTabsContext","TabListWrapper","clsx","useTrackElementOffsetRect","useOnValueUpdate","jsx","_jsx","TabList","children","otherProps","ref","context","tabStoreState","store","selectedId","indicatorPosition","item","element","animationEnabled","setAnimationEnabled","previousValue","globalThis","SCRIPT_DEBUG","activeId","selectOnMove","setActiveId","onBlur","render","onTransitionEnd","event","pseudoElement","style","top","right","left","width","height","className"],"sources":["@wordpress/components/src/tabs/tablist.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport { useStoreState } from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { TabListProps } from './types';\nimport { useTabsContext } from './context';\nimport { TabListWrapper } from './styles';\nimport type { WordPressComponentProps } from '../context';\nimport clsx from 'clsx';\nimport { useTrackElementOffsetRect } from '../utils/element-rect';\nimport { useOnValueUpdate } from '../utils/hooks/use-on-value-update';\n\nexport const TabList = forwardRef<\n\tHTMLDivElement,\n\tWordPressComponentProps< TabListProps, 'div', false >\n>( function TabList( { children, ...otherProps }, ref ) {\n\tconst context = useTabsContext();\n\n\tconst tabStoreState = useStoreState( context?.store );\n\tconst selectedId = tabStoreState?.selectedId;\n\tconst indicatorPosition = useTrackElementOffsetRect(\n\t\tcontext?.store.item( selectedId )?.element\n\t);\n\n\tconst [ animationEnabled, setAnimationEnabled ] = useState( false );\n\tuseOnValueUpdate(\n\t\tselectedId,\n\t\t( { previousValue } ) => previousValue && setAnimationEnabled( true )\n\t);\n\n\tif ( ! context || ! tabStoreState ) {\n\t\twarning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\n\tconst { store } = context;\n\tconst { activeId, selectOnMove } = tabStoreState;\n\tconst { setActiveId } = store;\n\n\tconst onBlur = () => {\n\t\tif ( ! selectOnMove ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// When automatic tab selection is on, make sure that the active tab is up\n\t\t// to date with the selected tab when leaving the tablist. This makes sure\n\t\t// that the selected tab will receive keyboard focus when tabbing back into\n\t\t// the tablist.\n\t\tif ( selectedId !== activeId ) {\n\t\t\tsetActiveId( selectedId );\n\t\t}\n\t};\n\n\treturn (\n\t\t<Ariakit.TabList\n\t\t\tref={ ref }\n\t\t\tstore={ store }\n\t\t\trender={\n\t\t\t\t<TabListWrapper\n\t\t\t\t\tonTransitionEnd={ ( event ) => {\n\t\t\t\t\t\tif ( event.pseudoElement === '::after' ) {\n\t\t\t\t\t\t\tsetAnimationEnabled( false );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tonBlur={ onBlur }\n\t\t\t{ ...otherProps }\n\t\t\tstyle={ {\n\t\t\t\t'--indicator-top': indicatorPosition.top,\n\t\t\t\t'--indicator-right': indicatorPosition.right,\n\t\t\t\t'--indicator-left': indicatorPosition.left,\n\t\t\t\t'--indicator-width': indicatorPosition.width,\n\t\t\t\t'--indicator-height': indicatorPosition.height,\n\t\t\t\t...otherProps.style,\n\t\t\t}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|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { useLayoutEffect, useRef, useState } from '@wordpress/element';
|
|
6
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import { useEvent } from './hooks/use-event';
|
|
10
11
|
|
|
11
|
-
/**
|
|
12
|
-
* `useTrackElementRectUpdates` options.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Tracks an element's "rect" (size and position) and fires `onRect` for all
|
|
17
|
-
* of its discrete values. The element can be changed dynamically and **it
|
|
18
|
-
* must not be stored in a ref**. Instead, it should be stored in a React
|
|
19
|
-
* state or equivalent.
|
|
20
|
-
*
|
|
21
|
-
* By default, `onRect` is called initially for the target element (including
|
|
22
|
-
* when the target element changes), not only on size or position updates.
|
|
23
|
-
* This allows consumers of the hook to always be in sync with all rect values
|
|
24
|
-
* of the target element throughout its lifetime. This behavior can be
|
|
25
|
-
* disabled by setting the `fireOnElementInit` option to `false`.
|
|
26
|
-
*
|
|
27
|
-
* Under the hood, it sets up a `ResizeObserver` that tracks the element. The
|
|
28
|
-
* target element can be changed dynamically, and the observer will be
|
|
29
|
-
* updated accordingly.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
*
|
|
33
|
-
* ```tsx
|
|
34
|
-
* const [ targetElement, setTargetElement ] = useState< HTMLElement | null >();
|
|
35
|
-
*
|
|
36
|
-
* useTrackElementRectUpdates( targetElement, ( element ) => {
|
|
37
|
-
* console.log( 'Element resized:', element );
|
|
38
|
-
* } );
|
|
39
|
-
*
|
|
40
|
-
* <div ref={ setTargetElement } />;
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export function useTrackElementRectUpdates(
|
|
44
|
-
/**
|
|
45
|
-
* The target element to observe. It can be changed dynamically.
|
|
46
|
-
*/
|
|
47
|
-
targetElement,
|
|
48
|
-
/**
|
|
49
|
-
* Callback to fire when the element is resized. It will also be
|
|
50
|
-
* called when the observer is set up, unless `fireOnElementInit` is
|
|
51
|
-
* set to `false`.
|
|
52
|
-
*/
|
|
53
|
-
onRect, {
|
|
54
|
-
fireOnElementInit = true
|
|
55
|
-
} = {}) {
|
|
56
|
-
const onRectEvent = useEvent(onRect);
|
|
57
|
-
const observedElementRef = useRef();
|
|
58
|
-
const resizeObserverRef = useRef();
|
|
59
|
-
|
|
60
|
-
// TODO: could this be a layout effect?
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (targetElement === observedElementRef.current) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
observedElementRef.current = targetElement;
|
|
66
|
-
|
|
67
|
-
// Set up a ResizeObserver.
|
|
68
|
-
if (!resizeObserverRef.current) {
|
|
69
|
-
resizeObserverRef.current = new ResizeObserver(entries => {
|
|
70
|
-
if (observedElementRef.current) {
|
|
71
|
-
onRectEvent(observedElementRef.current, entries);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
current: resizeObserver
|
|
77
|
-
} = resizeObserverRef;
|
|
78
|
-
|
|
79
|
-
// Observe new element.
|
|
80
|
-
if (targetElement) {
|
|
81
|
-
if (fireOnElementInit) {
|
|
82
|
-
// TODO: investigate if this can be removed,
|
|
83
|
-
// see: https://stackoverflow.com/a/60026394
|
|
84
|
-
onRectEvent(targetElement);
|
|
85
|
-
}
|
|
86
|
-
resizeObserver.observe(targetElement);
|
|
87
|
-
}
|
|
88
|
-
return () => {
|
|
89
|
-
// Unobserve previous element.
|
|
90
|
-
if (observedElementRef.current) {
|
|
91
|
-
resizeObserver.unobserve(observedElementRef.current);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}, [fireOnElementInit, onRectEvent, targetElement]);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
12
|
/**
|
|
98
13
|
* The position and dimensions of an element, relative to its offset parent.
|
|
99
14
|
*/
|
|
@@ -102,44 +17,98 @@ onRect, {
|
|
|
102
17
|
* An `ElementOffsetRect` object with all values set to zero.
|
|
103
18
|
*/
|
|
104
19
|
export const NULL_ELEMENT_OFFSET_RECT = {
|
|
105
|
-
left: 0,
|
|
106
20
|
top: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
left: 0,
|
|
107
24
|
width: 0,
|
|
108
25
|
height: 0
|
|
109
26
|
};
|
|
110
27
|
|
|
111
28
|
/**
|
|
112
29
|
* Returns the position and dimensions of an element, relative to its offset
|
|
113
|
-
* parent
|
|
114
|
-
*
|
|
30
|
+
* parent, with subpixel precision. Values reflect the real measures before any
|
|
31
|
+
* potential scaling distortions along the X and Y axes.
|
|
115
32
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
33
|
+
* Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`
|
|
34
|
+
* entries are not suitable, such as when the element is transformed, and when
|
|
35
|
+
* `element.offset<Top|Left|Width|Height>` methods are not precise enough.
|
|
36
|
+
*
|
|
37
|
+
* **Note:** in some contexts, like when the scale is 0, this method will fail
|
|
38
|
+
* because it's impossible to calculate a scaling ratio. When that happens, it
|
|
39
|
+
* will return `undefined`.
|
|
120
40
|
*/
|
|
121
41
|
export function getElementOffsetRect(element) {
|
|
42
|
+
var _element$offsetParent;
|
|
43
|
+
// Position and dimension values computed with `getBoundingClientRect` have
|
|
44
|
+
// subpixel precision, but are affected by distortions since they represent
|
|
45
|
+
// the "real" measures, or in other words, the actual final values as rendered
|
|
46
|
+
// by the browser.
|
|
47
|
+
const rect = element.getBoundingClientRect();
|
|
48
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const offsetParentRect = (_element$offsetParent = element.offsetParent?.getBoundingClientRect()) !== null && _element$offsetParent !== void 0 ? _element$offsetParent : NULL_ELEMENT_OFFSET_RECT;
|
|
52
|
+
|
|
53
|
+
// Computed widths and heights have subpixel precision, and are not affected
|
|
54
|
+
// by distortions.
|
|
55
|
+
const computedWidth = parseFloat(getComputedStyle(element).width);
|
|
56
|
+
const computedHeight = parseFloat(getComputedStyle(element).height);
|
|
57
|
+
|
|
58
|
+
// We can obtain the current scale factor for the element by comparing "computed"
|
|
59
|
+
// dimensions with the "real" ones.
|
|
60
|
+
const scaleX = computedWidth / rect.width;
|
|
61
|
+
const scaleY = computedHeight / rect.height;
|
|
122
62
|
return {
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
width:
|
|
132
|
-
height:
|
|
63
|
+
// To obtain the adjusted values for the position:
|
|
64
|
+
// 1. Compute the element's position relative to the offset parent.
|
|
65
|
+
// 2. Correct for the scale factor.
|
|
66
|
+
top: (rect.top - offsetParentRect?.top) * scaleY,
|
|
67
|
+
right: (offsetParentRect?.right - rect.right) * scaleX,
|
|
68
|
+
bottom: (offsetParentRect?.bottom - rect.bottom) * scaleY,
|
|
69
|
+
left: (rect.left - offsetParentRect?.left) * scaleX,
|
|
70
|
+
// Computed dimensions don't need any adjustments.
|
|
71
|
+
width: computedWidth,
|
|
72
|
+
height: computedHeight
|
|
133
73
|
};
|
|
134
74
|
}
|
|
75
|
+
const POLL_RATE = 100;
|
|
135
76
|
|
|
136
77
|
/**
|
|
137
78
|
* Tracks the position and dimensions of an element, relative to its offset
|
|
138
79
|
* parent. The element can be changed dynamically.
|
|
80
|
+
*
|
|
81
|
+
* **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s
|
|
82
|
+
* documentation for more details). When that happens, this hook will attempt
|
|
83
|
+
* to measure again after a frame, and if that fails, it will poll every 100
|
|
84
|
+
* milliseconds until it succeeds.
|
|
139
85
|
*/
|
|
140
86
|
export function useTrackElementOffsetRect(targetElement) {
|
|
141
87
|
const [indicatorPosition, setIndicatorPosition] = useState(NULL_ELEMENT_OFFSET_RECT);
|
|
142
|
-
|
|
88
|
+
const intervalRef = useRef();
|
|
89
|
+
const measure = useEvent(() => {
|
|
90
|
+
if (targetElement) {
|
|
91
|
+
const elementOffsetRect = getElementOffsetRect(targetElement);
|
|
92
|
+
if (elementOffsetRect) {
|
|
93
|
+
setIndicatorPosition(elementOffsetRect);
|
|
94
|
+
clearInterval(intervalRef.current);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
clearInterval(intervalRef.current);
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
const setElement = useResizeObserver(() => {
|
|
103
|
+
if (!measure()) {
|
|
104
|
+
requestAnimationFrame(() => {
|
|
105
|
+
if (!measure()) {
|
|
106
|
+
intervalRef.current = setInterval(measure, POLL_RATE);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
useLayoutEffect(() => setElement(targetElement), [setElement, targetElement]);
|
|
143
112
|
return indicatorPosition;
|
|
144
113
|
}
|
|
145
114
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useRef","useState","useResizeObserver","useEvent","NULL_ELEMENT_OFFSET_RECT","top","right","bottom","left","width","height","getElementOffsetRect","element","_element$offsetParent","rect","getBoundingClientRect","offsetParentRect","offsetParent","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","indicatorPosition","setIndicatorPosition","intervalRef","measure","elementOffsetRect","clearInterval","current","setElement","requestAnimationFrame","setInterval"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport { useEvent } from './hooks/use-event';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParentRect =\n\t\telement.offsetParent?.getBoundingClientRect() ??\n\t\tNULL_ELEMENT_OFFSET_RECT;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\ttop: ( rect.top - offsetParentRect?.top ) * scaleY,\n\t\tright: ( offsetParentRect?.right - rect.right ) * scaleX,\n\t\tbottom: ( offsetParentRect?.bottom - rect.bottom ) * scaleY,\n\t\tleft: ( rect.left - offsetParentRect?.left ) * scaleX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\tif ( targetElement ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect(\n\t\t() => setElement( targetElement ),\n\t\t[ setElement, targetElement ]\n\t);\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACtE,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,mBAAmB;;AAE5C;AACA;AACA;;AAgCA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG;EACvCC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACT,CAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CACnCC,OAAoB,EACY;EAAA,IAAAC,qBAAA;EAChC;EACA;EACA;EACA;EACA,MAAMC,IAAI,GAAGF,OAAO,CAACG,qBAAqB,CAAC,CAAC;EAC5C,IAAKD,IAAI,CAACL,KAAK,KAAK,CAAC,IAAIK,IAAI,CAACJ,MAAM,KAAK,CAAC,EAAG;IAC5C;EACD;EACA,MAAMM,gBAAgB,IAAAH,qBAAA,GACrBD,OAAO,CAACK,YAAY,EAAEF,qBAAqB,CAAC,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAC7CT,wBAAwB;;EAEzB;EACA;EACA,MAAMc,aAAa,GAAGC,UAAU,CAAEC,gBAAgB,CAAER,OAAQ,CAAC,CAACH,KAAM,CAAC;EACrE,MAAMY,cAAc,GAAGF,UAAU,CAAEC,gBAAgB,CAAER,OAAQ,CAAC,CAACF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UAAU,GAAGhC,iBAAiB,CAAE,MAAM;IAC3C,IAAK,CAAE4B,OAAO,CAAC,CAAC,EAAG;MAClBK,qBAAqB,CAAE,MAAM;QAC5B,IAAK,CAAEL,OAAO,CAAC,CAAC,EAAG;UAClBD,WAAW,CAACI,OAAO,GAAGG,WAAW,CAAEN,OAAO,EAAEN,SAAU,CAAC;QACxD;MACD,CAAE,CAAC;IACJ;EACD,CAAE,CAAC;EAEHzB,eAAe,CACd,MAAMmC,UAAU,CAAER,aAAc,CAAC,EACjC,CAAEQ,UAAU,EAAER,aAAa,CAC5B,CAAC;EAED,OAAOC,iBAAiB;AACzB;;AAEA","ignoreList":[]}
|
|
@@ -1988,10 +1988,6 @@ body.is-dragging-components-draggable {
|
|
|
1988
1988
|
line-height: 1;
|
|
1989
1989
|
margin: 0;
|
|
1990
1990
|
}
|
|
1991
|
-
.components-modal__header .components-button {
|
|
1992
|
-
position: relative;
|
|
1993
|
-
right: 8px;
|
|
1994
|
-
}
|
|
1995
1991
|
.components-modal__content.has-scrolled-content:not(.hide-header) .components-modal__header {
|
|
1996
1992
|
border-bottom-color: #ddd;
|
|
1997
1993
|
}
|
|
@@ -2513,6 +2509,7 @@ body.rtl .components-panel__body-toggle.components-button .dashicons-arrow-right
|
|
|
2513
2509
|
}
|
|
2514
2510
|
.is-alternate .components-popover__content {
|
|
2515
2511
|
box-shadow: 0 0 0 1px #1e1e1e;
|
|
2512
|
+
border-radius: 2px;
|
|
2516
2513
|
}
|
|
2517
2514
|
.is-unstyled .components-popover__content {
|
|
2518
2515
|
background: none;
|
package/build-style/style.css
CHANGED
|
@@ -1993,10 +1993,6 @@ body.is-dragging-components-draggable {
|
|
|
1993
1993
|
line-height: 1;
|
|
1994
1994
|
margin: 0;
|
|
1995
1995
|
}
|
|
1996
|
-
.components-modal__header .components-button {
|
|
1997
|
-
position: relative;
|
|
1998
|
-
left: 8px;
|
|
1999
|
-
}
|
|
2000
1996
|
.components-modal__content.has-scrolled-content:not(.hide-header) .components-modal__header {
|
|
2001
1997
|
border-bottom-color: #ddd;
|
|
2002
1998
|
}
|
|
@@ -2520,6 +2516,7 @@ body.rtl .components-panel__body-toggle.components-button .dashicons-arrow-right
|
|
|
2520
2516
|
}
|
|
2521
2517
|
.is-alternate .components-popover__content {
|
|
2522
2518
|
box-shadow: 0 0 0 1px #1e1e1e;
|
|
2519
|
+
border-radius: 2px;
|
|
2523
2520
|
}
|
|
2524
2521
|
.is-unstyled .components-popover__content {
|
|
2525
2522
|
background: none;
|
|
@@ -51,7 +51,7 @@ export declare function isValuesMixed(values?: BoxControlValue, selectedUnits?:
|
|
|
51
51
|
*
|
|
52
52
|
* @return Whether values are mixed.
|
|
53
53
|
*/
|
|
54
|
-
export declare function isValuesDefined(values?: BoxControlValue): boolean;
|
|
54
|
+
export declare function isValuesDefined(values?: BoxControlValue): boolean | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* Get initial selected side, factoring in whether the sides are linked,
|
|
57
57
|
* and whether the vertical / horizontal directions are grouped via splitOnAxis.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/box-control/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,EAAE,gBA6BnC,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;CASlB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC;AAEF,eAAO,MAAM,SAAS,6CAAgD,CAAC;AAmBvE;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,MAAM,GAAE,eAAoB,EAC5B,aAAa,CAAC,EAAE,eAAe,EAC/B,cAAc,GAAE,eAAe,CAAE,OAAO,CAAc,UAuCtD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAE,aAAa,CAAC,EAAE,eAAe,sBAQlE;AAED;;;;;;;;GA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C9B,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,eAAe,CAAE,OAAO,CAAE,GAChC,eAAe,CAoBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/composite/context.
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/composite/context.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,eAAO,MAAM,gBAAgB,gDAA+C,CAAC;AAE7E,eAAO,MAAM,mBAAmB,6BAAuC,CAAC"}
|
|
@@ -18,33 +18,50 @@ import * as Ariakit from '@ariakit/react';
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```jsx
|
|
21
|
-
* import { Composite
|
|
21
|
+
* import { Composite } from '@wordpress/components';
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* <Composite store={store}>
|
|
23
|
+
* <Composite>
|
|
25
24
|
* <Composite.Item>Item 1</Composite.Item>
|
|
26
25
|
* <Composite.Item>Item 2</Composite.Item>
|
|
27
26
|
* </Composite>
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
|
-
export declare const Composite: import("react").ForwardRefExoticComponent<
|
|
31
|
-
|
|
29
|
+
export declare const Composite: import("react").ForwardRefExoticComponent<{
|
|
30
|
+
activeId?: Ariakit.CompositeStoreProps["activeId"];
|
|
31
|
+
defaultActiveId?: Ariakit.CompositeStoreProps["defaultActiveId"];
|
|
32
|
+
setActiveId?: Ariakit.CompositeStoreProps["setActiveId"];
|
|
33
|
+
focusLoop?: Ariakit.CompositeStoreProps["focusLoop"];
|
|
34
|
+
focusWrap?: Ariakit.CompositeStoreProps["focusWrap"];
|
|
35
|
+
focusShift?: Ariakit.CompositeStoreProps["focusShift"];
|
|
36
|
+
virtualFocus?: Ariakit.CompositeStoreProps["virtualFocus"];
|
|
37
|
+
orientation?: Ariakit.CompositeStoreProps["orientation"];
|
|
38
|
+
rtl?: Ariakit.CompositeStoreProps["rtl"];
|
|
39
|
+
} & {
|
|
32
40
|
render?: Ariakit.CompositeProps["render"];
|
|
33
41
|
focusable?: Ariakit.CompositeProps["focusable"];
|
|
34
42
|
disabled?: Ariakit.CompositeProps["disabled"];
|
|
35
43
|
accessibleWhenDisabled?: Ariakit.CompositeProps["accessibleWhenDisabled"];
|
|
36
44
|
onFocusVisible?: Ariakit.CompositeProps["onFocusVisible"];
|
|
37
45
|
children?: Ariakit.CompositeProps["children"];
|
|
38
|
-
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "disabled" | "focusable" | "children" | "as" | "render" | "accessibleWhenDisabled" | "onFocusVisible" |
|
|
46
|
+
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "disabled" | "focusable" | "children" | "as" | "render" | "accessibleWhenDisabled" | "onFocusVisible" | keyof {
|
|
47
|
+
activeId?: Ariakit.CompositeStoreProps["activeId"];
|
|
48
|
+
defaultActiveId?: Ariakit.CompositeStoreProps["defaultActiveId"];
|
|
49
|
+
setActiveId?: Ariakit.CompositeStoreProps["setActiveId"];
|
|
50
|
+
focusLoop?: Ariakit.CompositeStoreProps["focusLoop"];
|
|
51
|
+
focusWrap?: Ariakit.CompositeStoreProps["focusWrap"];
|
|
52
|
+
focusShift?: Ariakit.CompositeStoreProps["focusShift"];
|
|
53
|
+
virtualFocus?: Ariakit.CompositeStoreProps["virtualFocus"];
|
|
54
|
+
orientation?: Ariakit.CompositeStoreProps["orientation"];
|
|
55
|
+
rtl?: Ariakit.CompositeStoreProps["rtl"];
|
|
56
|
+
}> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
39
57
|
/**
|
|
40
58
|
* Renders a group element for composite items.
|
|
41
59
|
*
|
|
42
60
|
* @example
|
|
43
61
|
* ```jsx
|
|
44
|
-
* import { Composite
|
|
62
|
+
* import { Composite } from '@wordpress/components';
|
|
45
63
|
*
|
|
46
|
-
*
|
|
47
|
-
* <Composite store={store}>
|
|
64
|
+
* <Composite>
|
|
48
65
|
* <Composite.Group>
|
|
49
66
|
* <Composite.GroupLabel>Label</Composite.GroupLabel>
|
|
50
67
|
* <Composite.Item>Item 1</Composite.Item>
|
|
@@ -63,10 +80,9 @@ export declare const Composite: import("react").ForwardRefExoticComponent<import
|
|
|
63
80
|
*
|
|
64
81
|
* @example
|
|
65
82
|
* ```jsx
|
|
66
|
-
* import { Composite
|
|
83
|
+
* import { Composite } from '@wordpress/components';
|
|
67
84
|
*
|
|
68
|
-
*
|
|
69
|
-
* <Composite store={store}>
|
|
85
|
+
* <Composite>
|
|
70
86
|
* <Composite.Group>
|
|
71
87
|
* <Composite.GroupLabel>Label</Composite.GroupLabel>
|
|
72
88
|
* <Composite.Item>Item 1</Composite.Item>
|
|
@@ -83,10 +99,9 @@ export declare const Composite: import("react").ForwardRefExoticComponent<import
|
|
|
83
99
|
*
|
|
84
100
|
* @example
|
|
85
101
|
* ```jsx
|
|
86
|
-
* import { Composite
|
|
102
|
+
* import { Composite } from '@wordpress/components';
|
|
87
103
|
*
|
|
88
|
-
*
|
|
89
|
-
* <Composite store={store}>
|
|
104
|
+
* <Composite>
|
|
90
105
|
* <Composite.Item>Item 1</Composite.Item>
|
|
91
106
|
* <Composite.Item>Item 2</Composite.Item>
|
|
92
107
|
* <Composite.Item>Item 3</Composite.Item>
|
|
@@ -103,10 +118,9 @@ export declare const Composite: import("react").ForwardRefExoticComponent<import
|
|
|
103
118
|
*
|
|
104
119
|
* @example
|
|
105
120
|
* ```jsx
|
|
106
|
-
* import { Composite
|
|
121
|
+
* import { Composite } from '@wordpress/components';
|
|
107
122
|
*
|
|
108
|
-
*
|
|
109
|
-
* <Composite store={store}>
|
|
123
|
+
* <Composite>
|
|
110
124
|
* <Composite.Row>
|
|
111
125
|
* <Composite.Item>Item 1.1</Composite.Item>
|
|
112
126
|
* <Composite.Item>Item 1.2</Composite.Item>
|
|
@@ -130,10 +144,9 @@ export declare const Composite: import("react").ForwardRefExoticComponent<import
|
|
|
130
144
|
*
|
|
131
145
|
* @example
|
|
132
146
|
* ```jsx
|
|
133
|
-
* import { Composite
|
|
147
|
+
* import { Composite } from '@wordpress/components';
|
|
134
148
|
*
|
|
135
|
-
*
|
|
136
|
-
* <Composite store={store}>
|
|
149
|
+
* <Composite>
|
|
137
150
|
* <Composite.Hover render={ <Composite.Item /> }>
|
|
138
151
|
* Item 1
|
|
139
152
|
* </Composite.Hover>
|
|
@@ -153,10 +166,9 @@ export declare const Composite: import("react").ForwardRefExoticComponent<import
|
|
|
153
166
|
*
|
|
154
167
|
* @example
|
|
155
168
|
* ```jsx
|
|
156
|
-
* import { Composite
|
|
169
|
+
* import { Composite } from '@wordpress/components';
|
|
157
170
|
*
|
|
158
|
-
*
|
|
159
|
-
* <Composite store={store} render={ <CompositeTypeahead /> }>
|
|
171
|
+
* <Composite render={ <CompositeTypeahead /> }>
|
|
160
172
|
* <Composite.Item>Item 1</Composite.Item>
|
|
161
173
|
* <Composite.Item>Item 2</Composite.Item>
|
|
162
174
|
* </Composite>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composite/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composite/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAqB1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2DpB;;;;;;;;;;;;;;;OAeG;;;;IAIH;;;;;;;;;;;;;;;;;OAiBG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;IAEH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;;;IAEH;;;;;;;;;;;;;;;;;;OAkBG;;;;IAIH;;;;;;;;;;;;;;OAcG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;CAKJ,CAAC"}
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @see https://ariakit.org/components/composite
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
import * as Ariakit from '@ariakit/react';
|
|
16
19
|
type Orientation = 'horizontal' | 'vertical';
|
|
17
20
|
export interface LegacyStateOptions {
|
|
18
21
|
/**
|
|
@@ -64,7 +67,7 @@ export interface LegacyStateOptions {
|
|
|
64
67
|
unstable_virtual?: boolean;
|
|
65
68
|
}
|
|
66
69
|
type Component = React.FunctionComponent<any>;
|
|
67
|
-
type CompositeStore = ReturnType<typeof useCompositeStore>;
|
|
70
|
+
type CompositeStore = ReturnType<typeof Ariakit.useCompositeStore>;
|
|
68
71
|
type CompositeStoreState = {
|
|
69
72
|
store: CompositeStore;
|
|
70
73
|
};
|
|
@@ -77,9 +80,29 @@ export type CompositeStateProps = {
|
|
|
77
80
|
type ComponentProps<C extends Component> = React.ComponentPropsWithRef<C>;
|
|
78
81
|
export type CompositeProps<C extends Component> = ComponentProps<C> & CompositeStateProps;
|
|
79
82
|
type CompositeComponent<C extends Component> = (props: CompositeProps<C>) => React.ReactElement;
|
|
83
|
+
/**
|
|
84
|
+
* _Note: please use the `Composite` component instead._
|
|
85
|
+
*
|
|
86
|
+
* @deprecated
|
|
87
|
+
*/
|
|
80
88
|
export declare const Composite: CompositeComponent<Component>;
|
|
89
|
+
/**
|
|
90
|
+
* _Note: please use the `Composite.Row` or `Composite.Group` components instead._
|
|
91
|
+
*
|
|
92
|
+
* @deprecated
|
|
93
|
+
*/
|
|
81
94
|
export declare const CompositeGroup: CompositeComponent<Component>;
|
|
95
|
+
/**
|
|
96
|
+
* _Note: please use the `Composite.Item` component instead._
|
|
97
|
+
*
|
|
98
|
+
* @deprecated
|
|
99
|
+
*/
|
|
82
100
|
export declare const CompositeItem: CompositeComponent<Component>;
|
|
101
|
+
/**
|
|
102
|
+
* _Note: please use the `Composite` component instead._
|
|
103
|
+
*
|
|
104
|
+
* @deprecated
|
|
105
|
+
*/
|
|
83
106
|
export declare function useCompositeState(legacyStateOptions?: LegacyStateOptions): CompositeState;
|
|
84
107
|
export {};
|
|
85
108
|
//# sourceMappingURL=index.d.ts.map
|