@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.
Files changed (165) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/box-control/utils.js +1 -1
  3. package/build/box-control/utils.js.map +1 -1
  4. package/build/composite/context.js +1 -1
  5. package/build/composite/context.js.map +1 -1
  6. package/build/composite/group-label.js +1 -1
  7. package/build/composite/group-label.js.map +1 -1
  8. package/build/composite/group.js +1 -1
  9. package/build/composite/group.js.map +1 -1
  10. package/build/composite/hover.js +1 -1
  11. package/build/composite/hover.js.map +1 -1
  12. package/build/composite/index.js +17 -26
  13. package/build/composite/index.js.map +1 -1
  14. package/build/composite/item.js +1 -1
  15. package/build/composite/item.js.map +1 -1
  16. package/build/composite/legacy/index.js +59 -8
  17. package/build/composite/legacy/index.js.map +1 -1
  18. package/build/composite/row.js +1 -1
  19. package/build/composite/row.js.map +1 -1
  20. package/build/composite/typeahead.js +1 -1
  21. package/build/composite/typeahead.js.map +1 -1
  22. package/build/composite/types.js.map +1 -1
  23. package/build/date-time/date/index.js +1 -1
  24. package/build/date-time/date/index.js.map +1 -1
  25. package/build/date-time/date/styles.js +35 -24
  26. package/build/date-time/date/styles.js.map +1 -1
  27. package/build/date-time/date/use-lilius/index.js +163 -0
  28. package/build/date-time/date/use-lilius/index.js.map +1 -0
  29. package/build/index.js +7 -0
  30. package/build/index.js.map +1 -1
  31. package/build/modal/index.js +11 -4
  32. package/build/modal/index.js.map +1 -1
  33. package/build/navigator/navigator-screen/component.js +5 -0
  34. package/build/navigator/navigator-screen/component.js.map +1 -1
  35. package/build/private-apis.js +0 -9
  36. package/build/private-apis.js.map +1 -1
  37. package/build/slot-fill/index.js +1 -0
  38. package/build/slot-fill/index.js.map +1 -1
  39. package/build/tabs/styles.js +3 -3
  40. package/build/tabs/styles.js.map +1 -1
  41. package/build/tabs/tablist.js +5 -4
  42. package/build/tabs/tablist.js.map +1 -1
  43. package/build/utils/element-rect.js +73 -105
  44. package/build/utils/element-rect.js.map +1 -1
  45. package/build-module/box-control/utils.js +1 -1
  46. package/build-module/box-control/utils.js.map +1 -1
  47. package/build-module/composite/context.js +1 -1
  48. package/build-module/composite/context.js.map +1 -1
  49. package/build-module/composite/group-label.js +1 -1
  50. package/build-module/composite/group-label.js.map +1 -1
  51. package/build-module/composite/group.js +1 -1
  52. package/build-module/composite/group.js.map +1 -1
  53. package/build-module/composite/hover.js +1 -1
  54. package/build-module/composite/hover.js.map +1 -1
  55. package/build-module/composite/index.js +17 -26
  56. package/build-module/composite/index.js.map +1 -1
  57. package/build-module/composite/item.js +1 -1
  58. package/build-module/composite/item.js.map +1 -1
  59. package/build-module/composite/legacy/index.js +56 -8
  60. package/build-module/composite/legacy/index.js.map +1 -1
  61. package/build-module/composite/row.js +1 -1
  62. package/build-module/composite/row.js.map +1 -1
  63. package/build-module/composite/typeahead.js +1 -1
  64. package/build-module/composite/typeahead.js.map +1 -1
  65. package/build-module/composite/types.js.map +1 -1
  66. package/build-module/date-time/date/index.js +1 -2
  67. package/build-module/date-time/date/index.js.map +1 -1
  68. package/build-module/date-time/date/styles.js +31 -24
  69. package/build-module/date-time/date/styles.js.map +1 -1
  70. package/build-module/date-time/date/use-lilius/index.js +158 -0
  71. package/build-module/date-time/date/use-lilius/index.js.map +1 -0
  72. package/build-module/index.js +1 -0
  73. package/build-module/index.js.map +1 -1
  74. package/build-module/modal/index.js +12 -4
  75. package/build-module/modal/index.js.map +1 -1
  76. package/build-module/navigator/navigator-screen/component.js +4 -0
  77. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  78. package/build-module/private-apis.js +0 -9
  79. package/build-module/private-apis.js.map +1 -1
  80. package/build-module/slot-fill/index.js +1 -0
  81. package/build-module/slot-fill/index.js.map +1 -1
  82. package/build-module/tabs/styles.js +3 -3
  83. package/build-module/tabs/styles.js.map +1 -1
  84. package/build-module/tabs/tablist.js +5 -4
  85. package/build-module/tabs/tablist.js.map +1 -1
  86. package/build-module/utils/element-rect.js +74 -105
  87. package/build-module/utils/element-rect.js.map +1 -1
  88. package/build-style/style-rtl.css +1 -4
  89. package/build-style/style.css +1 -4
  90. package/build-types/box-control/utils.d.ts +1 -1
  91. package/build-types/box-control/utils.d.ts.map +1 -1
  92. package/build-types/composite/context.d.ts.map +1 -1
  93. package/build-types/composite/index.d.ts +36 -24
  94. package/build-types/composite/index.d.ts.map +1 -1
  95. package/build-types/composite/legacy/index.d.ts +25 -2
  96. package/build-types/composite/legacy/index.d.ts.map +1 -1
  97. package/build-types/composite/legacy/stories/index.story.d.ts.map +1 -1
  98. package/build-types/composite/stories/index.story.d.ts +9 -9
  99. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  100. package/build-types/composite/types.d.ts +11 -10
  101. package/build-types/composite/types.d.ts.map +1 -1
  102. package/build-types/date-time/date/index.d.ts +0 -3
  103. package/build-types/date-time/date/index.d.ts.map +1 -1
  104. package/build-types/date-time/date/styles.d.ts.map +1 -1
  105. package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
  106. package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
  107. package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
  108. package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
  109. package/build-types/index.d.ts +1 -0
  110. package/build-types/index.d.ts.map +1 -1
  111. package/build-types/modal/index.d.ts.map +1 -1
  112. package/build-types/modal/stories/index.story.d.ts +3 -0
  113. package/build-types/modal/stories/index.story.d.ts.map +1 -1
  114. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  115. package/build-types/private-apis.d.ts.map +1 -1
  116. package/build-types/slot-fill/index.d.ts +3 -0
  117. package/build-types/slot-fill/index.d.ts.map +1 -1
  118. package/build-types/tabs/styles.d.ts.map +1 -1
  119. package/build-types/tabs/tablist.d.ts.map +1 -1
  120. package/build-types/utils/element-rect.d.ts +32 -74
  121. package/build-types/utils/element-rect.d.ts.map +1 -1
  122. package/package.json +19 -20
  123. package/src/box-control/utils.ts +1 -1
  124. package/src/composite/README.md +5 -24
  125. package/src/composite/{context.ts → context.tsx} +1 -2
  126. package/src/composite/group-label.tsx +1 -1
  127. package/src/composite/group.tsx +1 -1
  128. package/src/composite/hover.tsx +1 -1
  129. package/src/composite/index.tsx +17 -28
  130. package/src/composite/item.tsx +1 -1
  131. package/src/composite/legacy/index.tsx +72 -11
  132. package/src/composite/legacy/stories/index.story.tsx +2 -1
  133. package/src/composite/legacy/test/index.tsx +57 -1
  134. package/src/composite/row.tsx +1 -1
  135. package/src/composite/stories/index.story.tsx +185 -169
  136. package/src/composite/typeahead.tsx +1 -1
  137. package/src/composite/types.ts +13 -15
  138. package/src/date-time/date/index.tsx +1 -1
  139. package/src/date-time/date/styles.ts +31 -11
  140. package/src/date-time/date/test/use-lilius.ts +417 -0
  141. package/src/date-time/date/use-lilius/index.ts +394 -0
  142. package/src/index.ts +1 -0
  143. package/src/modal/index.tsx +16 -7
  144. package/src/modal/stories/index.story.tsx +8 -14
  145. package/src/modal/style.scss +0 -5
  146. package/src/navigator/navigator-screen/component.tsx +7 -0
  147. package/src/navigator/test/index.tsx +8 -0
  148. package/src/popover/style.scss +2 -1
  149. package/src/private-apis.ts +0 -9
  150. package/src/select-control/README.md +2 -2
  151. package/src/slot-fill/index.tsx +1 -0
  152. package/src/tabs/styles.ts +40 -11
  153. package/src/tabs/tablist.tsx +5 -4
  154. package/src/utils/element-rect.ts +93 -130
  155. package/tsconfig.tsbuildinfo +1 -1
  156. package/build/composite/store.js +0 -54
  157. package/build/composite/store.js.map +0 -1
  158. package/build-module/composite/store.js +0 -46
  159. package/build-module/composite/store.js.map +0 -1
  160. package/build-types/composite/store.d.ts +0 -25
  161. package/build-types/composite/store.d.ts.map +0 -1
  162. package/build-types/composite/stories/utils.d.ts +0 -29
  163. package/build-types/composite/stories/utils.d.ts.map +0 -1
  164. package/src/composite/store.ts +0 -46
  165. 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: reduce ) {\n\t\t&.is-animation-enabled::after {\n\t\t\ttransition-property: left, top, width, height;\n\t\t\ttransition-duration: 0.2s;\n\t\t\ttransition-timing-function: ease-out;\n\t\t}\n\t}\n\t&::after {\n\t\tcontent: '';\n\t\tposition: absolute;\n\t\tpointer-events: none;\n\n\t\t// Windows high contrast mode.\n\t\toutline: 2px solid transparent;\n\t\toutline-offset: -1px;\n\t}\n\t&:not( [aria-orientation='vertical'] )::after {\n\t\tbottom: 0;\n\t\tleft: var( --indicator-left );\n\t\twidth: var( --indicator-width );\n\t\theight: 0;\n\t\tborder-bottom: var( --wp-admin-border-width-focus ) solid\n\t\t\t${ COLORS.theme.accent };\n\t}\n\t&[aria-orientation='vertical']::after {\n\t\tz-index: -1;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\ttop: var( --indicator-top );\n\t\theight: var( --indicator-height );\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,6nBAkCrBT,MAAM,CAACU,KAAK,CAACC,MAAM,wJAQFX,MAAM,CAACU,KAAK,CAACE,IAAI,CAAE,GAAG,CAAE,UAAAP,OAAA,CAAAC,GAAA,CAAAC,QAAA,49JAE9C;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,49JAEF;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,49JAKxB","ignoreList":[]}
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-left': `${indicatorPosition.left}px`,
76
- '--indicator-top': `${indicatorPosition.top}px`,
77
- '--indicator-width': `${indicatorPosition.width}px`,
78
- '--indicator-height': `${indicatorPosition.height}px`,
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","left","top","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-left': `${ indicatorPosition.left }px`,\n\t\t\t\t'--indicator-top': `${ indicatorPosition.top }px`,\n\t\t\t\t'--indicator-width': `${ indicatorPosition.width }px`,\n\t\t\t\t'--indicator-height': `${ indicatorPosition.height }px`,\n\t\t\t\t...otherProps.style,\n\t\t\t} }\n\t\t\tclassName={ clsx(\n\t\t\t\tanimationEnabled ? 'is-animation-enabled' : '',\n\t\t\t\totherProps.className\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</Ariakit.TabList>\n\t);\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA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AAEa;EAAY,CAAC,GAAGZ,KAAK;EAE7B,MAAMa,MAAM,GAAGA,CAAA,KAAM;IACpB,IAAK,CAAEF,YAAY,EAAG;MACrB;IACD;;IAEA;IACA;IACA;IACA;IACA,IAAKV,UAAU,KAAKS,QAAQ,EAAG;MAC9BE,WAAW,CAAEX,UAAW,CAAC;IAC1B;EACD,CAAC;EAED,oBACCR,IAAA,CAACX,OAAO,CAACY,OAAO;IACfG,GAAG,EAAGA,GAAK;IACXG,KAAK,EAAGA,KAAO;IACfc,MAAM,eACLrB,IAAA,CAACL,cAAc;MACd2B,eAAe,EAAKC,KAAK,IAAM;QAC9B,IAAKA,KAAK,CAACC,aAAa,KAAK,SAAS,EAAG;UACxCX,mBAAmB,CAAE,KAAM,CAAC;QAC7B;MACD;IAAG,CACH,CACD;IACDO,MAAM,EAAGA,MAAQ;IAAA,GACZjB,UAAU;IACfsB,KAAK,EAAG;MACP,kBAAkB,EAAG,GAAGhB,iBAAiB,CAACiB,IAAM,IAAG;MACnD,iBAAiB,EAAG,GAAGjB,iBAAiB,CAACkB,GAAK,IAAG;MACjD,mBAAmB,EAAG,GAAGlB,iBAAiB,CAACmB,KAAO,IAAG;MACrD,oBAAoB,EAAG,GAAGnB,iBAAiB,CAACoB,MAAQ,IAAG;MACvD,GAAG1B,UAAU,CAACsB;IACf,CAAG;IACHK,SAAS,EAAGlC,IAAI,CACfgB,gBAAgB,GAAG,sBAAsB,GAAG,EAAE,EAC9CT,UAAU,CAAC2B,SACZ,CAAG;IAAA5B,QAAA,EAEDA;EAAQ,CACM,CAAC;AAEpB,CAAE,CAAC","ignoreList":[]}
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} }\n\t\t\tclassName={ clsx(\n\t\t\t\tanimationEnabled ? 'is-animation-enabled' : '',\n\t\t\t\totherProps.className\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</Ariakit.TabList>\n\t);\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,SAASC,aAAa,QAAQ,gBAAgB;;AAE9C;AACA;AACA;AACA,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;;AAEzD;AACA;AACA;;AAEA,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,cAAc,QAAQ,UAAU;AAEzC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,yBAAyB,QAAQ,uBAAuB;AACjE,SAASC,gBAAgB,QAAQ,oCAAoC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtE,OAAO,MAAMC,OAAO,GAAGT,UAAU,CAG9B,SAASS,OAAOA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAW,CAAC,EAAEC,GAAG,EAAG;EACvD,MAAMC,OAAO,GAAGX,cAAc,CAAC,CAAC;EA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EAAG;MACP,iBAAiB,EAAEhB,iBAAiB,CAACiB,GAAG;MACxC,mBAAmB,EAAEjB,iBAAiB,CAACkB,KAAK;MAC5C,kBAAkB,EAAElB,iBAAiB,CAACmB,IAAI;MAC1C,mBAAmB,EAAEnB,iBAAiB,CAACoB,KAAK;MAC5C,oBAAoB,EAAEpB,iBAAiB,CAACqB,MAAM;MAC9C,GAAG3B,UAAU,CAACsB;IACf,CAAG;IACHM,SAAS,EAAGnC,IAAI,CACfgB,gBAAgB,GAAG,sBAAsB,GAAG,EAAE,EAC9CT,UAAU,CAAC4B,SACZ,CAAG;IAAA7B,QAAA,EAEDA;EAAQ,CACM,CAAC;AAEpB,CAAE,CAAC","ignoreList":[]}
@@ -2,98 +2,13 @@
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
- import { useRef, useEffect, useState } from '@wordpress/element';
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. This is useful in contexts where `getBoundingClientRect` is not
114
- * suitable, such as when the element is transformed.
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
- * **Note:** the `left` and `right` values are adjusted due to a limitation
117
- * in the way the browser calculates the offset position of the element,
118
- * which can cause unwanted scrollbars to appear. This adjustment makes the
119
- * values potentially inaccurate within a range of 1 pixel.
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
- // The adjustments mentioned in the documentation above are necessary
124
- // because `offsetLeft` and `offsetTop` are rounded to the nearest pixel,
125
- // which can result in a position mismatch that causes unwanted overflow.
126
- // For context, see: https://github.com/WordPress/gutenberg/pull/61979
127
- left: Math.max(element.offsetLeft - 1, 0),
128
- top: Math.max(element.offsetTop - 1, 0),
129
- // This is a workaround to obtain these values with a sub-pixel precision,
130
- // since `offsetWidth` and `offsetHeight` are rounded to the nearest pixel.
131
- width: parseFloat(getComputedStyle(element).width),
132
- height: parseFloat(getComputedStyle(element).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
- useTrackElementRectUpdates(targetElement, element => setIndicatorPosition(getElementOffsetRect(element)));
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":["useRef","useEffect","useState","useEvent","useTrackElementRectUpdates","targetElement","onRect","fireOnElementInit","onRectEvent","observedElementRef","resizeObserverRef","current","ResizeObserver","entries","resizeObserver","observe","unobserve","NULL_ELEMENT_OFFSET_RECT","left","top","width","height","getElementOffsetRect","element","Math","max","offsetLeft","offsetTop","parseFloat","getComputedStyle","useTrackElementOffsetRect","indicatorPosition","setIndicatorPosition"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport { useEvent } from './hooks/use-event';\n\n/**\n * `useTrackElementRectUpdates` options.\n */\nexport type UseTrackElementRectUpdatesOptions = {\n\t/**\n\t * Whether to trigger the callback when an element's ResizeObserver is\n\t * first set up, including when the target element changes.\n\t *\n\t * @default true\n\t */\n\tfireOnElementInit?: boolean;\n};\n\n/**\n * Tracks an element's \"rect\" (size and position) and fires `onRect` for all\n * of its discrete values. The element can be changed dynamically and **it\n * must not be stored in a ref**. Instead, it should be stored in a React\n * state or equivalent.\n *\n * By default, `onRect` is called initially for the target element (including\n * when the target element changes), not only on size or position updates.\n * This allows consumers of the hook to always be in sync with all rect values\n * of the target element throughout its lifetime. This behavior can be\n * disabled by setting the `fireOnElementInit` option to `false`.\n *\n * Under the hood, it sets up a `ResizeObserver` that tracks the element. The\n * target element can be changed dynamically, and the observer will be\n * updated accordingly.\n *\n * @example\n *\n * ```tsx\n * const [ targetElement, setTargetElement ] = useState< HTMLElement | null >();\n *\n * useTrackElementRectUpdates( targetElement, ( element ) => {\n * console.log( 'Element resized:', element );\n * } );\n *\n * <div ref={ setTargetElement } />;\n * ```\n */\nexport function useTrackElementRectUpdates(\n\t/**\n\t * The target element to observe. It can be changed dynamically.\n\t */\n\ttargetElement: HTMLElement | undefined | null,\n\t/**\n\t * Callback to fire when the element is resized. It will also be\n\t * called when the observer is set up, unless `fireOnElementInit` is\n\t * set to `false`.\n\t */\n\tonRect: (\n\t\t/**\n\t\t * The element being tracked at the time of this update.\n\t\t */\n\t\telement: HTMLElement,\n\t\t/**\n\t\t * The list of\n\t\t * [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)\n\t\t * objects passed to the `ResizeObserver.observe` callback. This list\n\t\t * won't be available when the observer is set up, and only on updates.\n\t\t */\n\t\tresizeObserverEntries?: ResizeObserverEntry[]\n\t) => void,\n\t{ fireOnElementInit = true }: UseTrackElementRectUpdatesOptions = {}\n) {\n\tconst onRectEvent = useEvent( onRect );\n\n\tconst observedElementRef = useRef< HTMLElement | null >();\n\tconst resizeObserverRef = useRef< ResizeObserver >();\n\n\t// TODO: could this be a layout effect?\n\tuseEffect( () => {\n\t\tif ( targetElement === observedElementRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tobservedElementRef.current = targetElement;\n\n\t\t// Set up a ResizeObserver.\n\t\tif ( ! resizeObserverRef.current ) {\n\t\t\tresizeObserverRef.current = new ResizeObserver( ( entries ) => {\n\t\t\t\tif ( observedElementRef.current ) {\n\t\t\t\t\tonRectEvent( observedElementRef.current, entries );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\tconst { current: resizeObserver } = resizeObserverRef;\n\n\t\t// Observe new element.\n\t\tif ( targetElement ) {\n\t\t\tif ( fireOnElementInit ) {\n\t\t\t\t// TODO: investigate if this can be removed,\n\t\t\t\t// see: https://stackoverflow.com/a/60026394\n\t\t\t\tonRectEvent( targetElement );\n\t\t\t}\n\t\t\tresizeObserver.observe( targetElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\t// Unobserve previous element.\n\t\t\tif ( observedElementRef.current ) {\n\t\t\t\tresizeObserver.unobserve( observedElementRef.current );\n\t\t\t}\n\t\t};\n\t}, [ fireOnElementInit, onRectEvent, targetElement ] );\n}\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 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 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 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\tleft: 0,\n\ttop: 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. This is useful in contexts where `getBoundingClientRect` is not\n * suitable, such as when the element is transformed.\n *\n * **Note:** the `left` and `right` values are adjusted due to a limitation\n * in the way the browser calculates the offset position of the element,\n * which can cause unwanted scrollbars to appear. This adjustment makes the\n * values potentially inaccurate within a range of 1 pixel.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect {\n\treturn {\n\t\t// The adjustments mentioned in the documentation above are necessary\n\t\t// because `offsetLeft` and `offsetTop` are rounded to the nearest pixel,\n\t\t// which can result in a position mismatch that causes unwanted overflow.\n\t\t// For context, see: https://github.com/WordPress/gutenberg/pull/61979\n\t\tleft: Math.max( element.offsetLeft - 1, 0 ),\n\t\ttop: Math.max( element.offsetTop - 1, 0 ),\n\t\t// This is a workaround to obtain these values with a sub-pixel precision,\n\t\t// since `offsetWidth` and `offsetHeight` are rounded to the nearest pixel.\n\t\twidth: parseFloat( getComputedStyle( element ).width ),\n\t\theight: parseFloat( getComputedStyle( element ).height ),\n\t};\n}\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\n\tuseTrackElementRectUpdates( targetElement, ( element ) =>\n\t\tsetIndicatorPosition( getElementOffsetRect( element ) )\n\t);\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,mBAAmB;;AAE5C;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA;AACzC;AACD;AACA;AACCC,aAA6C;AAC7C;AACD;AACA;AACA;AACA;AACCC,MAYS,EACT;EAAEC,iBAAiB,GAAG;AAAwC,CAAC,GAAG,CAAC,CAAC,EACnE;EACD,MAAMC,WAAW,GAAGL,QAAQ,CAAEG,MAAO,CAAC;EAEtC,MAAMG,kBAAkB,GAAGT,MAAM,CAAuB,CAAC;EACzD,MAAMU,iBAAiB,GAAGV,MAAM,CAAmB,CAAC;;EAEpD;EACAC,SAAS,CAAE,MAAM;IAChB,IAAKI,aAAa,KAAKI,kBAAkB,CAACE,OAAO,EAAG;MACnD;IACD;IAEAF,kBAAkB,CAACE,OAAO,GAAGN,aAAa;;IAE1C;IACA,IAAK,CAAEK,iBAAiB,CAACC,OAAO,EAAG;MAClCD,iBAAiB,CAACC,OAAO,GAAG,IAAIC,cAAc,CAAIC,OAAO,IAAM;QAC9D,IAAKJ,kBAAkB,CAACE,OAAO,EAAG;UACjCH,WAAW,CAAEC,kBAAkB,CAACE,OAAO,EAAEE,OAAQ,CAAC;QACnD;MACD,CAAE,CAAC;IACJ;IACA,MAAM;MAAEF,OAAO,EAAEG;IAAe,CAAC,GAAGJ,iBAAiB;;IAErD;IACA,IAAKL,aAAa,EAAG;MACpB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EV,oBAAoB,CAAEC,OAAQ,CAAE,CACvD,CAAC;EAED,OAAOQ,iBAAiB;AACzB;;AAEA","ignoreList":[]}
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;A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ACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACxCC,aAA6C,EAC5C;EACD,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAChD3B,QAAQ,CAAuBG,wBAAyB,CAAC;EAC1D,MAAMyB,WAAW,GAAG7B,MAAM,CAAqC,CAAC;EAEhE,MAAM8B,OAAO,GAAG3B,QAAQ,CAAE,MAAM;IAC/B,IAAKuB,aAAa,EAAG;MACpB,MAAMK,iBAAiB,GAAGpB,oBAAoB,CAAEe,aAAc,CAAC;MAC/D,IAAKK,iBAAiB,EAAG;QACxBH,oBAAoB,CAAEG,iBAAkB,CAAC;QACzCC,aAAa,CAAEH,WAAW,CAACI,OAAQ,CAAC;QACpC,OAAO,IAAI;MACZ;IACD,CAAC,MAAM;MACND,aAAa,CAAEH,WAAW,CAACI,OAAQ,CAAC;IACrC;IACA,OAAO,KAAK;EACb,CAAE,CAAC;EAEH,MAAMC,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;
@@ -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;;;;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,eAAe,CAAE,OAAO,CAAc,UAuCtD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAE,aAAa,CAAC,EAAE,eAAe,sBAQlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,MAAM,GAAE,eAAoB,EAC5B,aAAa,CAAC,EAAE,eAAe,EAC/B,KAAK,GAAE,eAAe,CAAE,OAAO,CAAc,WAM7C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAE,MAAM,CAAC,EAAE,eAAe,uBAUxD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,8BAQtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,eAAe,CAAE,OAAO,CAAE,2EAiBhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,eAAe,EAC9B,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.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,eAAO,MAAM,gBAAgB,gDACuB,CAAC;AAErD,eAAO,MAAM,mBAAmB,6BAAuC,CAAC"}
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, useCompositeStore } from '@wordpress/components';
21
+ * import { Composite } from '@wordpress/components';
22
22
  *
23
- * const store = useCompositeStore();
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<import("./types").CompositeStoreProps & {
31
- store?: Ariakit.CompositeStore;
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" | "store" | keyof import("./types").CompositeStoreProps> & import("react").RefAttributes<HTMLDivElement>> & {
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, useCompositeStore } from '@wordpress/components';
62
+ * import { Composite } from '@wordpress/components';
45
63
  *
46
- * const store = useCompositeStore();
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, useCompositeStore } from '@wordpress/components';
83
+ * import { Composite } from '@wordpress/components';
67
84
  *
68
- * const store = useCompositeStore();
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, useCompositeStore } from '@wordpress/components';
102
+ * import { Composite } from '@wordpress/components';
87
103
  *
88
- * const store = useCompositeStore();
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, useCompositeStore } from '@wordpress/components';
121
+ * import { Composite } from '@wordpress/components';
107
122
  *
108
- * const store = useCompositeStore();
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, useCompositeStore } from '@wordpress/components';
147
+ * import { Composite } from '@wordpress/components';
134
148
  *
135
- * const store = useCompositeStore();
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, useCompositeStore } from '@wordpress/components';
169
+ * import { Composite } from '@wordpress/components';
157
170
  *
158
- * const store = useCompositeStore();
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;AAoB1C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS;;;;;;;;;IAgEpB;;;;;;;;;;;;;;;;OAgBG;;;;IAIH;;;;;;;;;;;;;;;;;;OAkBG;;;;IAIH;;;;;;;;;;;;;;OAcG;;;;IAEH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;;;;IAEH;;;;;;;;;;;;;;;;;;;OAmBG;;;;IAIH;;;;;;;;;;;;;;;OAeG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;CAKJ,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
- import { useCompositeStore } from '../store';
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