@wordpress/components 28.8.4 → 28.8.6

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 (93) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/build/composite/group-label.js +7 -1
  3. package/build/composite/group-label.js.map +1 -1
  4. package/build/composite/group.js +7 -1
  5. package/build/composite/group.js.map +1 -1
  6. package/build/composite/hover.js +8 -2
  7. package/build/composite/hover.js.map +1 -1
  8. package/build/composite/index.js +5 -1
  9. package/build/composite/index.js.map +1 -1
  10. package/build/composite/item.js +16 -1
  11. package/build/composite/item.js.map +1 -1
  12. package/build/composite/row.js +7 -1
  13. package/build/composite/row.js.map +1 -1
  14. package/build/composite/typeahead.js +8 -2
  15. package/build/composite/typeahead.js.map +1 -1
  16. package/build/date-time/date/index.js +4 -2
  17. package/build/date-time/date/index.js.map +1 -1
  18. package/build/drop-zone/index.js +1 -2
  19. package/build/drop-zone/index.js.map +1 -1
  20. package/build/palette-edit/index.js +24 -1
  21. package/build/palette-edit/index.js.map +1 -1
  22. package/build/toggle-group-control/toggle-group-control/as-radio-group.js +2 -1
  23. package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
  24. package/build/toggle-group-control/toggle-group-control-option-base/component.js +8 -10
  25. package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  26. package/build/toggle-group-control/types.js.map +1 -1
  27. package/build/tooltip/index.js +5 -1
  28. package/build/tooltip/index.js.map +1 -1
  29. package/build-module/composite/group-label.js +7 -1
  30. package/build-module/composite/group-label.js.map +1 -1
  31. package/build-module/composite/group.js +7 -1
  32. package/build-module/composite/group.js.map +1 -1
  33. package/build-module/composite/hover.js +8 -2
  34. package/build-module/composite/hover.js.map +1 -1
  35. package/build-module/composite/index.js +5 -1
  36. package/build-module/composite/index.js.map +1 -1
  37. package/build-module/composite/item.js +16 -1
  38. package/build-module/composite/item.js.map +1 -1
  39. package/build-module/composite/row.js +7 -1
  40. package/build-module/composite/row.js.map +1 -1
  41. package/build-module/composite/typeahead.js +8 -2
  42. package/build-module/composite/typeahead.js.map +1 -1
  43. package/build-module/date-time/date/index.js +4 -2
  44. package/build-module/date-time/date/index.js.map +1 -1
  45. package/build-module/drop-zone/index.js +1 -2
  46. package/build-module/drop-zone/index.js.map +1 -1
  47. package/build-module/palette-edit/index.js +23 -1
  48. package/build-module/palette-edit/index.js.map +1 -1
  49. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +2 -1
  50. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
  51. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +8 -10
  52. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  53. package/build-module/toggle-group-control/types.js.map +1 -1
  54. package/build-module/tooltip/index.js +5 -1
  55. package/build-module/tooltip/index.js.map +1 -1
  56. package/build-style/style-rtl.css +4 -4
  57. package/build-style/style.css +4 -4
  58. package/build-types/composite/group-label.d.ts.map +1 -1
  59. package/build-types/composite/index.d.ts.map +1 -1
  60. package/build-types/composite/item.d.ts.map +1 -1
  61. package/build-types/composite/test/index.d.ts +2 -0
  62. package/build-types/composite/test/index.d.ts.map +1 -0
  63. package/build-types/date-time/date/index.d.ts.map +1 -1
  64. package/build-types/drop-zone/index.d.ts.map +1 -1
  65. package/build-types/palette-edit/index.d.ts +3 -0
  66. package/build-types/palette-edit/index.d.ts.map +1 -1
  67. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
  68. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  69. package/build-types/toggle-group-control/types.d.ts +1 -0
  70. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  71. package/build-types/tooltip/index.d.ts.map +1 -1
  72. package/package.json +2 -2
  73. package/src/composite/group-label.tsx +7 -5
  74. package/src/composite/group.tsx +7 -7
  75. package/src/composite/hover.tsx +7 -7
  76. package/src/composite/index.tsx +6 -1
  77. package/src/composite/item.tsx +19 -1
  78. package/src/composite/row.tsx +7 -7
  79. package/src/composite/test/index.tsx +123 -0
  80. package/src/composite/typeahead.tsx +7 -7
  81. package/src/date-time/date/index.tsx +2 -0
  82. package/src/drop-zone/index.tsx +1 -2
  83. package/src/drop-zone/style.scss +1 -1
  84. package/src/palette-edit/index.tsx +30 -5
  85. package/src/palette-edit/test/index.tsx +50 -1
  86. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
  87. package/src/toggle-group-control/test/index.tsx +13 -0
  88. package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +3 -1
  89. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +11 -15
  90. package/src/toggle-group-control/types.ts +1 -0
  91. package/src/tooltip/index.tsx +8 -1
  92. package/src/tooltip/test/index.tsx +78 -0
  93. package/tsconfig.tsbuildinfo +1 -1
@@ -66,7 +66,6 @@ function ToggleGroupControlOptionBase(props, forwardedRef) {
66
66
  value,
67
67
  children,
68
68
  showTooltip = false,
69
- onFocus: onFocusProp,
70
69
  disabled,
71
70
  ...otherButtonProps
72
71
  } = buttonProps;
@@ -101,7 +100,6 @@ function ToggleGroupControlOptionBase(props, forwardedRef) {
101
100
  children: isDeselectable ? /*#__PURE__*/_jsx("button", {
102
101
  ...commonProps,
103
102
  disabled: disabled,
104
- onFocus: onFocusProp,
105
103
  "aria-pressed": isPressed,
106
104
  type: "button",
107
105
  onClick: buttonOnClick,
@@ -110,16 +108,16 @@ function ToggleGroupControlOptionBase(props, forwardedRef) {
110
108
  })
111
109
  }) : /*#__PURE__*/_jsx(Ariakit.Radio, {
112
110
  disabled: disabled,
113
- render: /*#__PURE__*/_jsx("button", {
114
- type: "button",
115
- ...commonProps,
116
- onFocus: event => {
117
- onFocusProp?.(event);
118
- if (event.defaultPrevented) {
119
- return;
120
- }
111
+ onFocusVisible: () => {
112
+ // Conditions ensure that the first visible focus to a radio group
113
+ // without a selected option will not automatically select the option.
114
+ if (toggleGroupControlContext.value !== null || toggleGroupControlContext.activeItemIsNotFirstItem?.()) {
121
115
  toggleGroupControlContext.setValue(value);
122
116
  }
117
+ },
118
+ render: /*#__PURE__*/_jsx("button", {
119
+ type: "button",
120
+ ...commonProps
123
121
  }),
124
122
  value: value,
125
123
  children: /*#__PURE__*/_jsx(ButtonContentView, {
@@ -1 +1 @@
1
- {"version":3,"names":["Ariakit","motion","useReducedMotion","useInstanceId","useMemo","contextConnect","useContextSystem","useToggleGroupControlContext","styles","useCx","Tooltip","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ButtonContentView","LabelView","REDUCED_MOTION_TRANSITION_CONFIG","duration","LAYOUT_ID","WithToolTip","showTooltip","text","children","placement","ToggleGroupControlOptionBase","props","forwardedRef","shouldReduceMotion","toggleGroupControlContext","id","baseId","buttonProps","isBlock","isDeselectable","size","className","isIcon","value","onFocus","onFocusProp","disabled","otherButtonProps","isPressed","cx","labelViewClasses","labelBlock","itemClasses","buttonView","backdropClasses","backdropView","buttonOnClick","setValue","undefined","commonProps","ref","type","onClick","Radio","render","event","defaultPrevented","div","layout","layoutRoot","transition","role","layoutId","ConnectedToggleGroupControlOptionBase"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport * as Ariakit from '@ariakit/react';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion, useInstanceId } from '@wordpress/compose';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport type {\n\tToggleGroupControlOptionBaseProps,\n\tWithToolTipProps,\n} from '../types';\nimport { useToggleGroupControlContext } from '../context';\nimport * as styles from './styles';\nimport { useCx } from '../../utils/hooks';\nimport Tooltip from '../../tooltip';\n\nconst { ButtonContentView, LabelView } = styles;\n\nconst REDUCED_MOTION_TRANSITION_CONFIG = {\n\tduration: 0,\n};\n\nconst LAYOUT_ID = 'toggle-group-backdrop-shared-layout-id';\n\nconst WithToolTip = ( { showTooltip, text, children }: WithToolTipProps ) => {\n\tif ( showTooltip && text ) {\n\t\treturn (\n\t\t\t<Tooltip text={ text } placement=\"top\">\n\t\t\t\t{ children }\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction ToggleGroupControlOptionBase(\n\tprops: Omit<\n\t\tWordPressComponentProps<\n\t\t\tToggleGroupControlOptionBaseProps,\n\t\t\t'button',\n\t\t\tfalse\n\t\t>,\n\t\t// the element's id is generated internally\n\t\t| 'id'\n\t\t// due to how the component works, only the `disabled` prop should be used\n\t\t| 'aria-disabled'\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst shouldReduceMotion = useReducedMotion();\n\tconst toggleGroupControlContext = useToggleGroupControlContext();\n\n\tconst id = useInstanceId(\n\t\tToggleGroupControlOptionBase,\n\t\ttoggleGroupControlContext.baseId || 'toggle-group-control-option-base'\n\t);\n\n\tconst buttonProps = useContextSystem(\n\t\t{ ...props, id },\n\t\t'ToggleGroupControlOptionBase'\n\t);\n\n\tconst {\n\t\tisBlock = false,\n\t\tisDeselectable = false,\n\t\tsize = 'default',\n\t} = toggleGroupControlContext;\n\n\tconst {\n\t\tclassName,\n\t\tisIcon = false,\n\t\tvalue,\n\t\tchildren,\n\t\tshowTooltip = false,\n\t\tonFocus: onFocusProp,\n\t\tdisabled,\n\t\t...otherButtonProps\n\t} = buttonProps;\n\n\tconst isPressed = toggleGroupControlContext.value === value;\n\tconst cx = useCx();\n\tconst labelViewClasses = useMemo(\n\t\t() => cx( isBlock && styles.labelBlock ),\n\t\t[ cx, isBlock ]\n\t);\n\tconst itemClasses = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.buttonView( {\n\t\t\t\t\tisDeselectable,\n\t\t\t\t\tisIcon,\n\t\t\t\t\tisPressed,\n\t\t\t\t\tsize,\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ cx, isDeselectable, isIcon, isPressed, size, className ]\n\t);\n\tconst backdropClasses = useMemo( () => cx( styles.backdropView ), [ cx ] );\n\n\tconst buttonOnClick = () => {\n\t\tif ( isDeselectable && isPressed ) {\n\t\t\ttoggleGroupControlContext.setValue( undefined );\n\t\t} else {\n\t\t\ttoggleGroupControlContext.setValue( value );\n\t\t}\n\t};\n\n\tconst commonProps = {\n\t\t...otherButtonProps,\n\t\tclassName: itemClasses,\n\t\t'data-value': value,\n\t\tref: forwardedRef,\n\t};\n\n\treturn (\n\t\t<LabelView className={ labelViewClasses }>\n\t\t\t<WithToolTip\n\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\ttext={ otherButtonProps[ 'aria-label' ] }\n\t\t\t>\n\t\t\t\t{ isDeselectable ? (\n\t\t\t\t\t<button\n\t\t\t\t\t\t{ ...commonProps }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tonFocus={ onFocusProp }\n\t\t\t\t\t\taria-pressed={ isPressed }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ buttonOnClick }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ButtonContentView>{ children }</ButtonContentView>\n\t\t\t\t\t</button>\n\t\t\t\t) : (\n\t\t\t\t\t<Ariakit.Radio\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t{ ...commonProps }\n\t\t\t\t\t\t\t\tonFocus={ ( event ) => {\n\t\t\t\t\t\t\t\t\tonFocusProp?.( event );\n\t\t\t\t\t\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\ttoggleGroupControlContext.setValue( value );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ButtonContentView>{ children }</ButtonContentView>\n\t\t\t\t\t</Ariakit.Radio>\n\t\t\t\t) }\n\t\t\t</WithToolTip>\n\t\t\t{ /* Animated backdrop using framer motion's shared layout animation */ }\n\t\t\t{ isPressed ? (\n\t\t\t\t<motion.div layout layoutRoot>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName={ backdropClasses }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tshouldReduceMotion\n\t\t\t\t\t\t\t\t? REDUCED_MOTION_TRANSITION_CONFIG\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\tlayoutId={ LAYOUT_ID }\n\t\t\t\t\t/>\n\t\t\t\t</motion.div>\n\t\t\t) : null }\n\t\t</LabelView>\n\t);\n}\n\n/**\n * `ToggleGroupControlOptionBase` is a form component and is meant to be used as an internal,\n * generic component for any children of `ToggleGroupControl`.\n *\n * @example\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOptionBase as ToggleGroupControlOptionBase,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl label=\"my label\" value=\"vertical\" isBlock>\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * ```\n */\nconst ConnectedToggleGroupControlOptionBase = contextConnect(\n\tToggleGroupControlOptionBase,\n\t'ToggleGroupControlOptionBase'\n);\n\nexport default ConnectedToggleGroupControlOptionBase;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,SAASC,MAAM,QAAQ,eAAe;;AAEtC;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC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,GACV,IAAI;EAAA,CACE,CAAC;AAEd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMiD,qCAAqC,GAAGjE,cAAc,CAC3DsB,4BAA4B,EAC5B,8BACD,CAAC;AAED,eAAe2C,qCAAqC","ignoreList":[]}
1
+ {"version":3,"names":["Ariakit","motion","useReducedMotion","useInstanceId","useMemo","contextConnect","useContextSystem","useToggleGroupControlContext","styles","useCx","Tooltip","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ButtonContentView","LabelView","REDUCED_MOTION_TRANSITION_CONFIG","duration","LAYOUT_ID","WithToolTip","showTooltip","text","children","placement","ToggleGroupControlOptionBase","props","forwardedRef","shouldReduceMotion","toggleGroupControlContext","id","baseId","buttonProps","isBlock","isDeselectable","size","className","isIcon","value","disabled","otherButtonProps","isPressed","cx","labelViewClasses","labelBlock","itemClasses","buttonView","backdropClasses","backdropView","buttonOnClick","setValue","undefined","commonProps","ref","type","onClick","Radio","onFocusVisible","activeItemIsNotFirstItem","render","div","layout","layoutRoot","transition","role","layoutId","ConnectedToggleGroupControlOptionBase"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-base/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport * as Ariakit from '@ariakit/react';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion, useInstanceId } from '@wordpress/compose';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport type {\n\tToggleGroupControlOptionBaseProps,\n\tWithToolTipProps,\n} from '../types';\nimport { useToggleGroupControlContext } from '../context';\nimport * as styles from './styles';\nimport { useCx } from '../../utils/hooks';\nimport Tooltip from '../../tooltip';\n\nconst { ButtonContentView, LabelView } = styles;\n\nconst REDUCED_MOTION_TRANSITION_CONFIG = {\n\tduration: 0,\n};\n\nconst LAYOUT_ID = 'toggle-group-backdrop-shared-layout-id';\n\nconst WithToolTip = ( { showTooltip, text, children }: WithToolTipProps ) => {\n\tif ( showTooltip && text ) {\n\t\treturn (\n\t\t\t<Tooltip text={ text } placement=\"top\">\n\t\t\t\t{ children }\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction ToggleGroupControlOptionBase(\n\tprops: Omit<\n\t\tWordPressComponentProps<\n\t\t\tToggleGroupControlOptionBaseProps,\n\t\t\t'button',\n\t\t\tfalse\n\t\t>,\n\t\t// the element's id is generated internally\n\t\t| 'id'\n\t\t// due to how the component works, only the `disabled` prop should be used\n\t\t| 'aria-disabled'\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst shouldReduceMotion = useReducedMotion();\n\tconst toggleGroupControlContext = useToggleGroupControlContext();\n\n\tconst id = useInstanceId(\n\t\tToggleGroupControlOptionBase,\n\t\ttoggleGroupControlContext.baseId || 'toggle-group-control-option-base'\n\t);\n\n\tconst buttonProps = useContextSystem(\n\t\t{ ...props, id },\n\t\t'ToggleGroupControlOptionBase'\n\t);\n\n\tconst {\n\t\tisBlock = false,\n\t\tisDeselectable = false,\n\t\tsize = 'default',\n\t} = toggleGroupControlContext;\n\n\tconst {\n\t\tclassName,\n\t\tisIcon = false,\n\t\tvalue,\n\t\tchildren,\n\t\tshowTooltip = false,\n\t\tdisabled,\n\t\t...otherButtonProps\n\t} = buttonProps;\n\n\tconst isPressed = toggleGroupControlContext.value === value;\n\tconst cx = useCx();\n\tconst labelViewClasses = useMemo(\n\t\t() => cx( isBlock && styles.labelBlock ),\n\t\t[ cx, isBlock ]\n\t);\n\tconst itemClasses = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.buttonView( {\n\t\t\t\t\tisDeselectable,\n\t\t\t\t\tisIcon,\n\t\t\t\t\tisPressed,\n\t\t\t\t\tsize,\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ cx, isDeselectable, isIcon, isPressed, size, className ]\n\t);\n\tconst backdropClasses = useMemo( () => cx( styles.backdropView ), [ cx ] );\n\n\tconst buttonOnClick = () => {\n\t\tif ( isDeselectable && isPressed ) {\n\t\t\ttoggleGroupControlContext.setValue( undefined );\n\t\t} else {\n\t\t\ttoggleGroupControlContext.setValue( value );\n\t\t}\n\t};\n\n\tconst commonProps = {\n\t\t...otherButtonProps,\n\t\tclassName: itemClasses,\n\t\t'data-value': value,\n\t\tref: forwardedRef,\n\t};\n\n\treturn (\n\t\t<LabelView className={ labelViewClasses }>\n\t\t\t<WithToolTip\n\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\ttext={ otherButtonProps[ 'aria-label' ] }\n\t\t\t>\n\t\t\t\t{ isDeselectable ? (\n\t\t\t\t\t<button\n\t\t\t\t\t\t{ ...commonProps }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\taria-pressed={ isPressed }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ buttonOnClick }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ButtonContentView>{ children }</ButtonContentView>\n\t\t\t\t\t</button>\n\t\t\t\t) : (\n\t\t\t\t\t<Ariakit.Radio\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tonFocusVisible={ () => {\n\t\t\t\t\t\t\t// Conditions ensure that the first visible focus to a radio group\n\t\t\t\t\t\t\t// without a selected option will not automatically select the option.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttoggleGroupControlContext.value !== null ||\n\t\t\t\t\t\t\t\ttoggleGroupControlContext.activeItemIsNotFirstItem?.()\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\ttoggleGroupControlContext.setValue( value );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trender={ <button type=\"button\" { ...commonProps } /> }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ButtonContentView>{ children }</ButtonContentView>\n\t\t\t\t\t</Ariakit.Radio>\n\t\t\t\t) }\n\t\t\t</WithToolTip>\n\t\t\t{ /* Animated backdrop using framer motion's shared layout animation */ }\n\t\t\t{ isPressed ? (\n\t\t\t\t<motion.div layout layoutRoot>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName={ backdropClasses }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tshouldReduceMotion\n\t\t\t\t\t\t\t\t? REDUCED_MOTION_TRANSITION_CONFIG\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\tlayoutId={ LAYOUT_ID }\n\t\t\t\t\t/>\n\t\t\t\t</motion.div>\n\t\t\t) : null }\n\t\t</LabelView>\n\t);\n}\n\n/**\n * `ToggleGroupControlOptionBase` is a form component and is meant to be used as an internal,\n * generic component for any children of `ToggleGroupControl`.\n *\n * @example\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOptionBase as ToggleGroupControlOptionBase,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl label=\"my label\" value=\"vertical\" isBlock>\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * ```\n */\nconst ConnectedToggleGroupControlOptionBase = contextConnect(\n\tToggleGroupControlOptionBase,\n\t'ToggleGroupControlOptionBase'\n);\n\nexport default ConnectedToggleGroupControlOptionBase;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,SAASC,MAAM,QAAQ,eAAe;;AAEtC;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,oB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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM+C,qCAAqC,GAAG/D,cAAc,CAC3DsB,4BAA4B,EAC5B,8BACD,CAAC;AAED,eAAeyC,qCAAqC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/toggle-group-control/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { BaseControlProps } from '../base-control/types';\nimport type { TooltipProps } from '../tooltip/types';\n\nexport type ToggleGroupControlOptionBaseProps = {\n\tchildren: ReactNode;\n\t/**\n\t * Style the option as an icon option.\n\t *\n\t * @default false\n\t */\n\tisIcon?: boolean;\n\tvalue: string | number;\n\t/**\n\t * Whether to display a Tooltip for the control option. If set to `true`, the tooltip will\n\t * show the aria-label or the label prop text.\n\t *\n\t * @default false\n\t */\n\tshowTooltip?: boolean;\n};\n\nexport type ToggleGroupControlOptionIconProps = Pick<\n\tToggleGroupControlOptionBaseProps,\n\t'value'\n> & {\n\t/**\n\t * Icon displayed as the content of the option. Usually one of the icons from\n\t * the `@wordpress/icons` package, or a custom React `<svg>` icon.\n\t */\n\ticon: JSX.Element;\n\t/**\n\t * The text to accessibly label the icon option. Will also be shown in a tooltip.\n\t */\n\tlabel: string;\n};\n\nexport type ToggleGroupControlOptionProps = Pick<\n\tToggleGroupControlOptionBaseProps,\n\t'value' | 'showTooltip'\n> & {\n\t/**\n\t * Label for the option. If needed, the `aria-label` prop can be used in addition\n\t * to specify a different label for assistive technologies.\n\t */\n\tlabel: string;\n};\n\nexport type WithToolTipProps = {\n\t/**\n\t * React children\n\t */\n\tchildren: TooltipProps[ 'children' ];\n\t/**\n\t * Label for the Tooltip component.\n\t */\n\ttext?: string;\n\t/**\n\t * Whether to wrap the control option in a Tooltip component.\n\t *\n\t * @default false\n\t */\n\tshowTooltip?: boolean;\n};\n\nexport type ToggleGroupControlProps = Pick<\n\tBaseControlProps,\n\t'help' | '__nextHasNoMarginBottom'\n> & {\n\t/**\n\t * Label for the control.\n\t */\n\tlabel: string;\n\t/**\n\t * If true, the label will only be visible to screen readers.\n\t *\n\t * @default false\n\t */\n\thideLabelFromVision?: boolean;\n\t/**\n\t * Determines if segments should be rendered with equal widths.\n\t *\n\t * @default false\n\t */\n\tisAdaptiveWidth?: boolean;\n\t/**\n\t * Renders `ToggleGroupControl` as a (CSS) block element, spanning the entire width of\n\t * the available space. This is the recommended style when the options are text-based and not icons.\n\t *\n\t * @default false\n\t */\n\tisBlock?: boolean;\n\t/**\n\t * Whether an option can be deselected by clicking it again.\n\t *\n\t * @default false\n\t */\n\tisDeselectable?: boolean;\n\t/**\n\t * Callback when a segment is selected.\n\t */\n\tonChange?: ( value: string | number | undefined ) => void;\n\t/**\n\t * The selected value.\n\t */\n\tvalue?: string | number;\n\t/**\n\t * The options to render in the `ToggleGroupControl`, using either the `ToggleGroupControlOption` or\n\t * `ToggleGroupControlOptionIcon` components.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * The size variant of the control.\n\t *\n\t * @default 'default'\n\t */\n\tsize?: 'default' | '__unstable-large';\n\t/**\n\t * Start opting into the larger default height that will become the default size in a future version.\n\t *\n\t * @default false\n\t */\n\t__next40pxDefaultSize?: boolean;\n};\n\nexport type ToggleGroupControlContextProps = {\n\tisDeselectable?: boolean;\n\tbaseId: string;\n\tisBlock: ToggleGroupControlProps[ 'isBlock' ];\n\tsize: ToggleGroupControlProps[ 'size' ];\n\tvalue: ToggleGroupControlProps[ 'value' ];\n\tsetValue: ( newValue: string | number | undefined ) => void;\n};\n\nexport type ToggleGroupControlMainControlProps = Pick<\n\tToggleGroupControlProps,\n\t'children' | 'isAdaptiveWidth' | 'label' | 'size' | 'onChange' | 'value'\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/toggle-group-control/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { BaseControlProps } from '../base-control/types';\nimport type { TooltipProps } from '../tooltip/types';\n\nexport type ToggleGroupControlOptionBaseProps = {\n\tchildren: ReactNode;\n\t/**\n\t * Style the option as an icon option.\n\t *\n\t * @default false\n\t */\n\tisIcon?: boolean;\n\tvalue: string | number;\n\t/**\n\t * Whether to display a Tooltip for the control option. If set to `true`, the tooltip will\n\t * show the aria-label or the label prop text.\n\t *\n\t * @default false\n\t */\n\tshowTooltip?: boolean;\n};\n\nexport type ToggleGroupControlOptionIconProps = Pick<\n\tToggleGroupControlOptionBaseProps,\n\t'value'\n> & {\n\t/**\n\t * Icon displayed as the content of the option. Usually one of the icons from\n\t * the `@wordpress/icons` package, or a custom React `<svg>` icon.\n\t */\n\ticon: JSX.Element;\n\t/**\n\t * The text to accessibly label the icon option. Will also be shown in a tooltip.\n\t */\n\tlabel: string;\n};\n\nexport type ToggleGroupControlOptionProps = Pick<\n\tToggleGroupControlOptionBaseProps,\n\t'value' | 'showTooltip'\n> & {\n\t/**\n\t * Label for the option. If needed, the `aria-label` prop can be used in addition\n\t * to specify a different label for assistive technologies.\n\t */\n\tlabel: string;\n};\n\nexport type WithToolTipProps = {\n\t/**\n\t * React children\n\t */\n\tchildren: TooltipProps[ 'children' ];\n\t/**\n\t * Label for the Tooltip component.\n\t */\n\ttext?: string;\n\t/**\n\t * Whether to wrap the control option in a Tooltip component.\n\t *\n\t * @default false\n\t */\n\tshowTooltip?: boolean;\n};\n\nexport type ToggleGroupControlProps = Pick<\n\tBaseControlProps,\n\t'help' | '__nextHasNoMarginBottom'\n> & {\n\t/**\n\t * Label for the control.\n\t */\n\tlabel: string;\n\t/**\n\t * If true, the label will only be visible to screen readers.\n\t *\n\t * @default false\n\t */\n\thideLabelFromVision?: boolean;\n\t/**\n\t * Determines if segments should be rendered with equal widths.\n\t *\n\t * @default false\n\t */\n\tisAdaptiveWidth?: boolean;\n\t/**\n\t * Renders `ToggleGroupControl` as a (CSS) block element, spanning the entire width of\n\t * the available space. This is the recommended style when the options are text-based and not icons.\n\t *\n\t * @default false\n\t */\n\tisBlock?: boolean;\n\t/**\n\t * Whether an option can be deselected by clicking it again.\n\t *\n\t * @default false\n\t */\n\tisDeselectable?: boolean;\n\t/**\n\t * Callback when a segment is selected.\n\t */\n\tonChange?: ( value: string | number | undefined ) => void;\n\t/**\n\t * The selected value.\n\t */\n\tvalue?: string | number;\n\t/**\n\t * The options to render in the `ToggleGroupControl`, using either the `ToggleGroupControlOption` or\n\t * `ToggleGroupControlOptionIcon` components.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * The size variant of the control.\n\t *\n\t * @default 'default'\n\t */\n\tsize?: 'default' | '__unstable-large';\n\t/**\n\t * Start opting into the larger default height that will become the default size in a future version.\n\t *\n\t * @default false\n\t */\n\t__next40pxDefaultSize?: boolean;\n};\n\nexport type ToggleGroupControlContextProps = {\n\tactiveItemIsNotFirstItem?: () => boolean;\n\tisDeselectable?: boolean;\n\tbaseId: string;\n\tisBlock: ToggleGroupControlProps[ 'isBlock' ];\n\tsize: ToggleGroupControlProps[ 'size' ];\n\tvalue: ToggleGroupControlProps[ 'value' ];\n\tsetValue: ( newValue: string | number | undefined ) => void;\n};\n\nexport type ToggleGroupControlMainControlProps = Pick<\n\tToggleGroupControlProps,\n\t'children' | 'isAdaptiveWidth' | 'label' | 'size' | 'onChange' | 'value'\n>;\n"],"mappings":"","ignoreList":[]}
@@ -87,9 +87,13 @@ function UnforwardedTooltip(props, ref) {
87
87
  // TODO: this is a temporary workaround to minimize the effects of the
88
88
  // Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to
89
89
  // the tooltip anchor anymore since 0.4.0, so we need to add it manually.
90
+ // The `aria-describedby` attribute is added only if the anchor doesn't have
91
+ // one already, and if the tooltip text is not the same as the anchor's
92
+ // `aria-label`
90
93
  // See: https://github.com/WordPress/gutenberg/pull/64066
94
+ // See: https://github.com/WordPress/gutenberg/pull/65989
91
95
  function addDescribedById(element) {
92
- return describedById && mounted ? cloneElement(element, {
96
+ return describedById && mounted && element.props['aria-describedby'] === undefined && element.props['aria-label'] !== text ? cloneElement(element, {
93
97
  'aria-describedby': describedById
94
98
  }) : element;
95
99
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Ariakit","useStoreState","clsx","useInstanceId","Children","useContext","createContext","forwardRef","cloneElement","deprecated","Shortcut","positionToPlacement","jsx","_jsx","jsxs","_jsxs","TooltipInternalContext","isNestedInTooltip","TOOLTIP_DELAY","CONTEXT_VALUE","UnforwardedTooltip","props","ref","children","className","delay","hideOnClick","placement","position","shortcut","text","restProps","baseId","Tooltip","describedById","undefined","isOnlyChild","count","process","env","NODE_ENV","console","error","computedPlacement","since","alternative","tooltipStore","useTooltipStore","showTimeout","mounted","Role","render","addDescribedById","element","Provider","value","TooltipAnchor","onClick","hide","store","unmountOnHide","gutter","id","overflowPadding"],"sources":["@wordpress/components/src/tooltip/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport { useStoreState } from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tChildren,\n\tuseContext,\n\tcreateContext,\n\tforwardRef,\n\tcloneElement,\n} from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tTooltipProps,\n\tTooltipInternalContext as TooltipInternalContextType,\n} from './types';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\n\nconst TooltipInternalContext = createContext< TooltipInternalContextType >( {\n\tisNestedInTooltip: false,\n} );\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst CONTEXT_VALUE = {\n\tisNestedInTooltip: true,\n};\n\nfunction UnforwardedTooltip(\n\tprops: TooltipProps,\n\tref: React.ForwardedRef< any >\n) {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tdelay = TOOLTIP_DELAY,\n\t\thideOnClick = true,\n\t\tplacement,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\n\t\t...restProps\n\t} = props;\n\n\tconst { isNestedInTooltip } = useContext( TooltipInternalContext );\n\n\tconst baseId = useInstanceId( Tooltip, 'tooltip' );\n\tconst describedById = text || shortcut ? baseId : undefined;\n\n\tconst isOnlyChild = Children.count( children ) === 1;\n\t// console error if more than one child element is added\n\tif ( ! isOnlyChild ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'wp-components.Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\t}\n\n\t// Compute tooltip's placement:\n\t// - give priority to `placement` prop, if defined\n\t// - otherwise, compute it from the legacy `position` prop (if defined)\n\t// - finally, fallback to the default placement: 'bottom'\n\tlet computedPlacement;\n\tif ( placement !== undefined ) {\n\t\tcomputedPlacement = placement;\n\t} else if ( position !== undefined ) {\n\t\tcomputedPlacement = positionToPlacement( position );\n\t\tdeprecated( '`position` prop in wp.components.tooltip', {\n\t\t\tsince: '6.4',\n\t\t\talternative: '`placement` prop',\n\t\t} );\n\t}\n\tcomputedPlacement = computedPlacement || 'bottom';\n\n\tconst tooltipStore = Ariakit.useTooltipStore( {\n\t\tplacement: computedPlacement,\n\t\tshowTimeout: delay,\n\t} );\n\tconst mounted = useStoreState( tooltipStore, 'mounted' );\n\n\tif ( isNestedInTooltip ) {\n\t\treturn isOnlyChild ? (\n\t\t\t<Ariakit.Role { ...restProps } render={ children } />\n\t\t) : (\n\t\t\tchildren\n\t\t);\n\t}\n\n\t// TODO: this is a temporary workaround to minimize the effects of the\n\t// Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to\n\t// the tooltip anchor anymore since 0.4.0, so we need to add it manually.\n\t// See: https://github.com/WordPress/gutenberg/pull/64066\n\tfunction addDescribedById( element: React.ReactElement ) {\n\t\treturn describedById && mounted\n\t\t\t? cloneElement( element, { 'aria-describedby': describedById } )\n\t\t\t: element;\n\t}\n\n\treturn (\n\t\t<TooltipInternalContext.Provider value={ CONTEXT_VALUE }>\n\t\t\t<Ariakit.TooltipAnchor\n\t\t\t\tonClick={ hideOnClick ? tooltipStore.hide : undefined }\n\t\t\t\tstore={ tooltipStore }\n\t\t\t\trender={\n\t\t\t\t\tisOnlyChild ? addDescribedById( children ) : undefined\n\t\t\t\t}\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t{ isOnlyChild ? undefined : children }\n\t\t\t</Ariakit.TooltipAnchor>\n\t\t\t{ isOnlyChild && ( text || shortcut ) && (\n\t\t\t\t<Ariakit.Tooltip\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tclassName={ clsx( 'components-tooltip', className ) }\n\t\t\t\t\tunmountOnHide\n\t\t\t\t\tgutter={ 4 }\n\t\t\t\t\tid={ describedById }\n\t\t\t\t\toverflowPadding={ 0.5 }\n\t\t\t\t\tstore={ tooltipStore }\n\t\t\t\t>\n\t\t\t\t\t{ text }\n\t\t\t\t\t{ shortcut && (\n\t\t\t\t\t\t<Shortcut\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\ttext ? 'components-tooltip__shortcut' : ''\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Ariakit.Tooltip>\n\t\t\t) }\n\t\t</TooltipInternalContext.Provider>\n\t);\n}\nexport const Tooltip = forwardRef( UnforwardedTooltip );\n\nexport default Tooltip;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,OAAOC,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SACCC,Q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AAW,KAAMN,IAAI,IAAID,QAAQ,CAAE,iBACpCd,KAAA,CAACf,OAAO,CAACiC,OAAO;MAAA,GACVF,SAAS;MACdP,SAAS,EAAGtB,IAAI,CAAE,oBAAoB,EAAEsB,SAAU,CAAG;MACrDoC,aAAa;MACbC,MAAM,EAAG,CAAG;MACZC,EAAE,EAAG5B,aAAe;MACpB6B,eAAe,EAAG,GAAK;MACvBJ,KAAK,EAAGb,YAAc;MAAAvB,QAAA,GAEpBO,IAAI,EACJD,QAAQ,iBACThB,IAAA,CAACH,QAAQ;QACRc,SAAS,EACRM,IAAI,GAAG,8BAA8B,GAAG,EACxC;QACDD,QAAQ,EAAGA;MAAU,CACrB,CACD;IAAA,CACe,CACjB;EAAA,CAC+B,CAAC;AAEpC;AACA,OAAO,MAAMI,OAAO,GAAG1B,UAAU,CAAEa,kBAAmB,CAAC;AAEvD,eAAea,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["Ariakit","useStoreState","clsx","useInstanceId","Children","useContext","createContext","forwardRef","cloneElement","deprecated","Shortcut","positionToPlacement","jsx","_jsx","jsxs","_jsxs","TooltipInternalContext","isNestedInTooltip","TOOLTIP_DELAY","CONTEXT_VALUE","UnforwardedTooltip","props","ref","children","className","delay","hideOnClick","placement","position","shortcut","text","restProps","baseId","Tooltip","describedById","undefined","isOnlyChild","count","process","env","NODE_ENV","console","error","computedPlacement","since","alternative","tooltipStore","useTooltipStore","showTimeout","mounted","Role","render","addDescribedById","element","Provider","value","TooltipAnchor","onClick","hide","store","unmountOnHide","gutter","id","overflowPadding"],"sources":["@wordpress/components/src/tooltip/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport { useStoreState } from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tChildren,\n\tuseContext,\n\tcreateContext,\n\tforwardRef,\n\tcloneElement,\n} from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tTooltipProps,\n\tTooltipInternalContext as TooltipInternalContextType,\n} from './types';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\n\nconst TooltipInternalContext = createContext< TooltipInternalContextType >( {\n\tisNestedInTooltip: false,\n} );\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst CONTEXT_VALUE = {\n\tisNestedInTooltip: true,\n};\n\nfunction UnforwardedTooltip(\n\tprops: TooltipProps,\n\tref: React.ForwardedRef< any >\n) {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tdelay = TOOLTIP_DELAY,\n\t\thideOnClick = true,\n\t\tplacement,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\n\t\t...restProps\n\t} = props;\n\n\tconst { isNestedInTooltip } = useContext( TooltipInternalContext );\n\n\tconst baseId = useInstanceId( Tooltip, 'tooltip' );\n\tconst describedById = text || shortcut ? baseId : undefined;\n\n\tconst isOnlyChild = Children.count( children ) === 1;\n\t// console error if more than one child element is added\n\tif ( ! isOnlyChild ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'wp-components.Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\t}\n\n\t// Compute tooltip's placement:\n\t// - give priority to `placement` prop, if defined\n\t// - otherwise, compute it from the legacy `position` prop (if defined)\n\t// - finally, fallback to the default placement: 'bottom'\n\tlet computedPlacement;\n\tif ( placement !== undefined ) {\n\t\tcomputedPlacement = placement;\n\t} else if ( position !== undefined ) {\n\t\tcomputedPlacement = positionToPlacement( position );\n\t\tdeprecated( '`position` prop in wp.components.tooltip', {\n\t\t\tsince: '6.4',\n\t\t\talternative: '`placement` prop',\n\t\t} );\n\t}\n\tcomputedPlacement = computedPlacement || 'bottom';\n\n\tconst tooltipStore = Ariakit.useTooltipStore( {\n\t\tplacement: computedPlacement,\n\t\tshowTimeout: delay,\n\t} );\n\tconst mounted = useStoreState( tooltipStore, 'mounted' );\n\n\tif ( isNestedInTooltip ) {\n\t\treturn isOnlyChild ? (\n\t\t\t<Ariakit.Role { ...restProps } render={ children } />\n\t\t) : (\n\t\t\tchildren\n\t\t);\n\t}\n\n\t// TODO: this is a temporary workaround to minimize the effects of the\n\t// Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to\n\t// the tooltip anchor anymore since 0.4.0, so we need to add it manually.\n\t// The `aria-describedby` attribute is added only if the anchor doesn't have\n\t// one already, and if the tooltip text is not the same as the anchor's\n\t// `aria-label`\n\t// See: https://github.com/WordPress/gutenberg/pull/64066\n\t// See: https://github.com/WordPress/gutenberg/pull/65989\n\tfunction addDescribedById( element: React.ReactElement ) {\n\t\treturn describedById &&\n\t\t\tmounted &&\n\t\t\telement.props[ 'aria-describedby' ] === undefined &&\n\t\t\telement.props[ 'aria-label' ] !== text\n\t\t\t? cloneElement( element, { 'aria-describedby': describedById } )\n\t\t\t: element;\n\t}\n\n\treturn (\n\t\t<TooltipInternalContext.Provider value={ CONTEXT_VALUE }>\n\t\t\t<Ariakit.TooltipAnchor\n\t\t\t\tonClick={ hideOnClick ? tooltipStore.hide : undefined }\n\t\t\t\tstore={ tooltipStore }\n\t\t\t\trender={\n\t\t\t\t\tisOnlyChild ? addDescribedById( children ) : undefined\n\t\t\t\t}\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t{ isOnlyChild ? undefined : children }\n\t\t\t</Ariakit.TooltipAnchor>\n\t\t\t{ isOnlyChild && ( text || shortcut ) && (\n\t\t\t\t<Ariakit.Tooltip\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tclassName={ clsx( 'components-tooltip', className ) }\n\t\t\t\t\tunmountOnHide\n\t\t\t\t\tgutter={ 4 }\n\t\t\t\t\tid={ describedById }\n\t\t\t\t\toverflowPadding={ 0.5 }\n\t\t\t\t\tstore={ tooltipStore }\n\t\t\t\t>\n\t\t\t\t\t{ text }\n\t\t\t\t\t{ shortcut && (\n\t\t\t\t\t\t<Shortcut\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\ttext ? 'components-tooltip__shortcut' : ''\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Ariakit.Tooltip>\n\t\t\t) }\n\t\t</TooltipInternalContext.Provider>\n\t);\n}\nexport const Tooltip = forwardRef( UnforwardedTooltip );\n\nexport default Tooltip;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,OAAOC,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SACCC,QAAQ,EACRC,UAAU,EACVC,aAAa,EACbC,UAAU,EACVC,YAAY,QACN,oBAAoB;AAC3B,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;;AAKA,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,mBAAmB,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEvD,MAAMC,sBAAsB,GAAGV,aAAa,CAAgC;EAC3EW,iBAAiB,EAAE;AACpB,CAAE,CAAC;;AAEH;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG,GAAG;AAEhC,MAAMC,aAAa,GAAG;EACrBF,iBAAiB,EAAE;AACpB,CAAC;AAED,SAASG,kBAAkBA,CAC1BC,KAAmB,EACnBC,GAA8B,EAC7B;EACD,MAAM;IACLC,QAAQ;IACRC,SAAS;IACTC,KAAK,GAAGP,aAAa;IACrBQ,WAAW,GAAG,IAAI;IAClBC,SAAS;IACTC,QAAQ;IACRC,QAAQ;IACRC,IAAI;IAEJ,GAAGC;EACJ,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;AAEvD,eAAea,OAAO","ignoreList":[]}
@@ -1132,22 +1132,22 @@ body.is-dragging-components-draggable {
1132
1132
  opacity: 0;
1133
1133
  transform: scale(0.9);
1134
1134
  }
1135
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1135
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content {
1136
1136
  opacity: 1;
1137
1137
  transition: opacity 0.2s ease-in-out;
1138
1138
  }
1139
1139
  @media (prefers-reduced-motion) {
1140
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1140
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content {
1141
1141
  transition: none;
1142
1142
  }
1143
1143
  }
1144
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1144
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content-inner {
1145
1145
  opacity: 1;
1146
1146
  transform: scale(1);
1147
1147
  transition: opacity 0.1s ease-in-out 0.1s, transform 0.1s ease-in-out 0.1s;
1148
1148
  }
1149
1149
  @media (prefers-reduced-motion) {
1150
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1150
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content-inner {
1151
1151
  transition: none;
1152
1152
  }
1153
1153
  }
@@ -1137,22 +1137,22 @@ body.is-dragging-components-draggable {
1137
1137
  opacity: 0;
1138
1138
  transform: scale(0.9);
1139
1139
  }
1140
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1140
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content {
1141
1141
  opacity: 1;
1142
1142
  transition: opacity 0.2s ease-in-out;
1143
1143
  }
1144
1144
  @media (prefers-reduced-motion) {
1145
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content {
1145
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content {
1146
1146
  transition: none;
1147
1147
  }
1148
1148
  }
1149
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1149
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content-inner {
1150
1150
  opacity: 1;
1151
1151
  transform: scale(1);
1152
1152
  transition: opacity 0.1s ease-in-out 0.1s, transform 0.1s ease-in-out 0.1s;
1153
1153
  }
1154
1154
  @media (prefers-reduced-motion) {
1155
- .components-drop-zone.is-active:not(.has-dragged-out) .components-drop-zone__content-inner {
1155
+ .components-drop-zone.is-active.is-dragging-over-element .components-drop-zone__content-inner {
1156
1156
  transition: none;
1157
1157
  }
1158
1158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"group-label.d.ts","sourceRoot":"","sources":["../../src/composite/group-label.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,mBAAmB,mRAY7B,CAAC"}
1
+ {"version":3,"file":"group-label.d.ts","sourceRoot":"","sources":["../../src/composite/group-label.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,mBAAmB,mRAc7B,CAAC"}
@@ -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;AAqB1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2DpB;;;;;;;;;;;;;;;OAeG;;;;IAIH;;;;;;;;;;;;;;;;;OAiBG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;IAEH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;;;IAEH;;;;;;;;;;;;;;;;;;OAkBG;;;;IAIH;;;;;;;;;;;;;;OAcG;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgEpB;;;;;;;;;;;;;;;OAeG;;;;IAIH;;;;;;;;;;;;;;;;;OAiBG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;IAEH;;;;;;;;;;;;;;;;;;;;;;OAsBG;;;;IAEH;;;;;;;;;;;;;;;;;;OAkBG;;;;IAIH;;;;;;;;;;;;;;OAcG;;;;IAIH;;;;;;;;;;;;;OAaG;;;;CAKJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/composite/item.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,aAAa,sRAYvB,CAAC"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/composite/item.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,aAAa,sRA8BvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composite/test/index.tsx"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-time/date/index.tsx"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAahD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAE,EAC3B,WAAW,EACX,QAAQ,EACR,MAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,EAAE,YAAgB,GAC7B,EAAE,eAAe,+BAkMjB;AAmGD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-time/date/index.tsx"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAahD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAE,EAC3B,WAAW,EACX,QAAQ,EACR,MAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,EAAE,YAAgB,GAC7B,EAAE,eAAe,+BAoMjB;AAmGD,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drop-zone/index.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAE,EAClC,SAAS,EACT,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,GAAG,SAAS,EACZ,EAAE,uBAAuB,CAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAE,+BA0FxD;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drop-zone/index.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAE,EAClC,SAAS,EACT,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,GAAG,SAAS,EACZ,EAAE,uBAAuB,CAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAE,+BAyFxD;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,4 +1,7 @@
1
1
  import type { PaletteEditProps, PaletteElement } from './types';
2
+ export declare function deduplicateElementSlugs<T extends PaletteElement>(elements: T[]): (T & {
3
+ slug: string;
4
+ })[];
2
5
  /**
3
6
  * Returns a name and slug for a palette item. The name takes the format "Color + id".
4
7
  * To ensure there are no duplicate ids, this function checks all slugs.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette-edit/index.tsx"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAOX,gBAAgB,EAChB,cAAc,EACd,MAAM,SAAS,CAAC;AAejB;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,cAAc,EAAE,EAC1B,UAAU,EAAE,MAAM;;;EAwBlB;AA6ND;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAE,EAC5B,SAAS,EACT,MAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,wBAA4B,EAC5B,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,UAAe,EACf,YAAY,GACZ,EAAE,gBAAgB,+BA8OlB;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/palette-edit/index.tsx"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAMX,gBAAgB,EAChB,cAAc,EACd,MAAM,SAAS,CAAC;AAkBjB,wBAAgB,uBAAuB,CAAE,CAAC,SAAS,cAAc,EAChE,QAAQ,EAAE,CAAC,EAAE;;KAgBb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,cAAc,EAAE,EAC1B,UAAU,EAAE,MAAM;;;EAwBlB;AAiOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAE,EAC5B,SAAS,EACT,MAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,wBAA4B,EAC5B,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,UAAe,EACf,YAAY,GACZ,EAAE,gBAAgB,+BA8OlB;AAED,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"as-radio-group.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control/as-radio-group.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACX,kCAAkC,EAElC,MAAM,UAAU,CAAC;AA8ElB,eAAO,MAAM,8BAA8B,uUAE1C,CAAC"}
1
+ {"version":3,"file":"as-radio-group.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control/as-radio-group.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACX,kCAAkC,EAElC,MAAM,UAAU,CAAC;AAgFlB,eAAO,MAAM,8BAA8B,uUAE1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/component.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EACX,iCAAiC,EAEjC,MAAM,UAAU,CAAC;AAmKlB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,qCAAqC,2RAG1C,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/component.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EACX,iCAAiC,EAEjC,MAAM,UAAU,CAAC;AA+JlB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,qCAAqC,2RAG1C,CAAC;AAEF,eAAe,qCAAqC,CAAC"}
@@ -115,6 +115,7 @@ export type ToggleGroupControlProps = Pick<BaseControlProps, 'help' | '__nextHas
115
115
  __next40pxDefaultSize?: boolean;
116
116
  };
117
117
  export type ToggleGroupControlContextProps = {
118
+ activeItemIsNotFirstItem?: () => boolean;
118
119
  isDeselectable?: boolean;
119
120
  baseId: string;
120
121
  isBlock: ToggleGroupControlProps['isBlock'];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/toggle-group-control/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,IAAI,CACnD,iCAAiC,EACjC,OAAO,CACP,GAAG;IACH;;;OAGG;IACH,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC/C,iCAAiC,EACjC,OAAO,GAAG,aAAa,CACvB,GAAG;IACH;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAE,UAAU,CAAE,CAAC;IACrC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC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AAM,OAAO,8FAAmC,CAAC;AAExD,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tooltip/index.tsx"],"names":[],"mappings":"AAoBA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EAEZ,MAAM,SAAS,CAAC;AAQjB;;GAEG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AA0HjC,eAAO,MAAM,OAAO,8FAAmC,CAAC;AAExD,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "28.8.4",
3
+ "version": "28.8.6",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -84,5 +84,5 @@
84
84
  "publishConfig": {
85
85
  "access": "public"
86
86
  },
87
- "gitHead": "07c75154341d1e5a1b8aaa1c226029b6666a52a9"
87
+ "gitHead": "b7af02f8431034ee19cdc33dd105d21705823eed"
88
88
  }
@@ -20,11 +20,13 @@ export const CompositeGroupLabel = forwardRef<
20
20
  WordPressComponentProps< CompositeGroupLabelProps, 'div', false >
21
21
  >( function CompositeGroupLabel( props, ref ) {
22
22
  const context = useCompositeContext();
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
23
29
  return (
24
- <Ariakit.CompositeGroupLabel
25
- store={ context.store as Ariakit.CompositeStore }
26
- { ...props }
27
- ref={ ref }
28
- />
30
+ <Ariakit.CompositeGroupLabel store={ store } { ...props } ref={ ref } />
29
31
  );
30
32
  } );
@@ -20,11 +20,11 @@ export const CompositeGroup = forwardRef<
20
20
  WordPressComponentProps< CompositeGroupProps, 'div', false >
21
21
  >( function CompositeGroup( props, ref ) {
22
22
  const context = useCompositeContext();
23
- return (
24
- <Ariakit.CompositeGroup
25
- store={ context.store as Ariakit.CompositeStore }
26
- { ...props }
27
- ref={ ref }
28
- />
29
- );
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
29
+ return <Ariakit.CompositeGroup store={ store } { ...props } ref={ ref } />;
30
30
  } );
@@ -20,11 +20,11 @@ export const CompositeHover = forwardRef<
20
20
  WordPressComponentProps< CompositeHoverProps, 'div', false >
21
21
  >( function CompositeHover( props, ref ) {
22
22
  const context = useCompositeContext();
23
- return (
24
- <Ariakit.CompositeHover
25
- store={ context.store as Ariakit.CompositeStore }
26
- { ...props }
27
- ref={ ref }
28
- />
29
- );
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
29
+ return <Ariakit.CompositeGroup store={ store } { ...props } ref={ ref } />;
30
30
  } );
@@ -73,7 +73,10 @@ export const Composite = Object.assign(
73
73
  },
74
74
  ref
75
75
  ) {
76
- const store = Ariakit.useCompositeStore( {
76
+ // @ts-expect-error The store prop is undocumented and only used by the
77
+ // legacy compat layer.
78
+ const storeProp = props.store as Ariakit.CompositeStore;
79
+ const internalStore = Ariakit.useCompositeStore( {
77
80
  activeId,
78
81
  defaultActiveId,
79
82
  setActiveId,
@@ -85,6 +88,8 @@ export const Composite = Object.assign(
85
88
  rtl,
86
89
  } );
87
90
 
91
+ const store = storeProp ?? internalStore;
92
+
88
93
  const contextValue = useMemo(
89
94
  () => ( {
90
95
  store,
@@ -20,9 +20,27 @@ export const CompositeItem = forwardRef<
20
20
  WordPressComponentProps< CompositeItemProps, 'button', false >
21
21
  >( function CompositeItem( props, ref ) {
22
22
  const context = useCompositeContext();
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
29
+ // If the active item is not connected, Composite may end up in a state
30
+ // where none of the items are tabbable. In this case, we force all items to
31
+ // be tabbable, so that as soon as an item received focus, it becomes active
32
+ // and Composite goes back to working as expected.
33
+ const tabbable = Ariakit.useStoreState( store, ( state ) => {
34
+ return (
35
+ state?.activeId !== null &&
36
+ ! store?.item( state?.activeId )?.element?.isConnected
37
+ );
38
+ } );
39
+
23
40
  return (
24
41
  <Ariakit.CompositeItem
25
- store={ context.store as Ariakit.CompositeStore }
42
+ store={ store }
43
+ tabbable={ tabbable }
26
44
  { ...props }
27
45
  ref={ ref }
28
46
  />
@@ -20,11 +20,11 @@ export const CompositeRow = forwardRef<
20
20
  WordPressComponentProps< CompositeRowProps, 'div', false >
21
21
  >( function CompositeRow( props, ref ) {
22
22
  const context = useCompositeContext();
23
- return (
24
- <Ariakit.CompositeRow
25
- store={ context.store as Ariakit.CompositeStore }
26
- { ...props }
27
- ref={ ref }
28
- />
29
- );
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
29
+ return <Ariakit.CompositeRow store={ store } { ...props } ref={ ref } />;
30
30
  } );
@@ -0,0 +1,123 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { queryByAttribute, render, screen } from '@testing-library/react';
5
+ import { click, press, waitFor } from '@ariakit/test';
6
+ import type { ComponentProps } from 'react';
7
+
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+ import { useState } from '@wordpress/element';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { Composite } from '..';
17
+
18
+ // This is necessary because of how Ariakit calculates page up and
19
+ // page down. Without this, nothing has a height, and so paging up
20
+ // and down doesn't behave as expected in tests.
21
+
22
+ let clientHeightSpy: jest.SpiedGetter<
23
+ typeof HTMLElement.prototype.clientHeight
24
+ >;
25
+
26
+ beforeAll( () => {
27
+ clientHeightSpy = jest
28
+ .spyOn( HTMLElement.prototype, 'clientHeight', 'get' )
29
+ .mockImplementation( function getClientHeight( this: HTMLElement ) {
30
+ if ( this.tagName === 'BODY' ) {
31
+ return window.outerHeight;
32
+ }
33
+ return 50;
34
+ } );
35
+ } );
36
+
37
+ afterAll( () => {
38
+ clientHeightSpy?.mockRestore();
39
+ } );
40
+
41
+ async function renderAndValidate( ...args: Parameters< typeof render > ) {
42
+ const view = render( ...args );
43
+ await waitFor( () => {
44
+ const activeButton = queryByAttribute(
45
+ 'data-active-item',
46
+ view.baseElement,
47
+ 'true'
48
+ );
49
+ expect( activeButton ).not.toBeNull();
50
+ } );
51
+ return view;
52
+ }
53
+
54
+ function RemoveItemTest( props: ComponentProps< typeof Composite > ) {
55
+ const [ showThirdItem, setShowThirdItem ] = useState( true );
56
+ return (
57
+ <>
58
+ <button>Focus trap before composite</button>
59
+ <Composite { ...props }>
60
+ <Composite.Item>Item 1</Composite.Item>
61
+ <Composite.Item>Item 2</Composite.Item>
62
+ { showThirdItem && <Composite.Item>Item 3</Composite.Item> }
63
+ </Composite>
64
+ <button onClick={ () => setShowThirdItem( ( value ) => ! value ) }>
65
+ Toggle third item
66
+ </button>
67
+ </>
68
+ );
69
+ }
70
+
71
+ describe( 'Composite', () => {
72
+ it( 'should remain focusable even when there are no elements in the DOM associated with the currently active ID', async () => {
73
+ await renderAndValidate( <RemoveItemTest /> );
74
+
75
+ const toggleButton = screen.getByRole( 'button', {
76
+ name: 'Toggle third item',
77
+ } );
78
+
79
+ await press.Tab();
80
+ await press.Tab();
81
+
82
+ expect(
83
+ screen.getByRole( 'button', { name: 'Item 1' } )
84
+ ).toHaveFocus();
85
+
86
+ await press.ArrowRight();
87
+ await press.ArrowRight();
88
+
89
+ expect(
90
+ screen.getByRole( 'button', { name: 'Item 3' } )
91
+ ).toHaveFocus();
92
+
93
+ await click( toggleButton );
94
+
95
+ expect(
96
+ screen.queryByRole( 'button', { name: 'Item 3' } )
97
+ ).not.toBeInTheDocument();
98
+
99
+ await press.ShiftTab();
100
+
101
+ expect(
102
+ screen.getByRole( 'button', { name: 'Item 2' } )
103
+ ).toHaveFocus();
104
+
105
+ await click( toggleButton );
106
+
107
+ expect(
108
+ screen.getByRole( 'button', { name: 'Item 3' } )
109
+ ).toBeVisible();
110
+
111
+ await press.ShiftTab();
112
+
113
+ expect(
114
+ screen.getByRole( 'button', { name: 'Item 2' } )
115
+ ).toHaveFocus();
116
+
117
+ await press.ArrowRight();
118
+
119
+ expect(
120
+ screen.getByRole( 'button', { name: 'Item 3' } )
121
+ ).toHaveFocus();
122
+ } );
123
+ } );
@@ -20,11 +20,11 @@ export const CompositeTypeahead = forwardRef<
20
20
  WordPressComponentProps< CompositeTypeaheadProps, 'div', false >
21
21
  >( function CompositeTypeahead( props, ref ) {
22
22
  const context = useCompositeContext();
23
- return (
24
- <Ariakit.CompositeTypeahead
25
- store={ context.store as Ariakit.CompositeStore }
26
- { ...props }
27
- ref={ ref }
28
- />
29
- );
23
+
24
+ // @ts-expect-error The store prop is undocumented and only used by the
25
+ // legacy compat layer. The `store` prop is documented, but its type is
26
+ // obfuscated to discourage its use outside of the component's internals.
27
+ const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;
28
+
29
+ return <Ariakit.CompositeRow store={ store } { ...props } ref={ ref } />;
30
30
  } );