@wordpress/components 32.0.2-next.v.0 → 32.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/build/alignment-matrix-control/cell.cjs +6 -121
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/icon.cjs +2 -3
- package/build/alignment-matrix-control/icon.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +6 -121
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/angle-picker-control/angle-circle.cjs +6 -85
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/autocomplete/autocompleter-ui.cjs +1 -2
- package/build/autocomplete/autocompleter-ui.cjs.map +2 -2
- package/build/box-control/input-control.cjs +8 -12
- package/build/box-control/input-control.cjs.map +2 -2
- package/build/button/index.cjs +6 -12
- package/build/button/index.cjs.map +2 -2
- package/build/calendar/date-calendar/index.cjs +2 -2
- package/build/calendar/date-calendar/index.cjs.map +2 -2
- package/build/calendar/date-range-calendar/index.cjs +4 -6
- package/build/calendar/date-range-calendar/index.cjs.map +2 -2
- package/build/card/card/hook.cjs +1 -2
- package/build/card/card/hook.cjs.map +2 -2
- package/build/color-palette/utils.cjs +2 -2
- package/build/color-palette/utils.cjs.map +2 -2
- package/build/combobox-control/index.cjs +1 -2
- package/build/combobox-control/index.cjs.map +2 -2
- package/build/composite/group-label.cjs +1 -2
- package/build/composite/group-label.cjs.map +2 -2
- package/build/composite/group.cjs +1 -2
- package/build/composite/group.cjs.map +2 -2
- package/build/composite/hover.cjs +1 -2
- package/build/composite/hover.cjs.map +2 -2
- package/build/composite/index.cjs +1 -1
- package/build/composite/index.cjs.map +2 -2
- package/build/composite/item.cjs +1 -2
- package/build/composite/item.cjs.map +2 -2
- package/build/composite/legacy/index.cjs +1 -2
- package/build/composite/legacy/index.cjs.map +2 -2
- package/build/composite/row.cjs +1 -2
- package/build/composite/row.cjs.map +2 -2
- package/build/composite/typeahead.cjs +1 -2
- package/build/composite/typeahead.cjs.map +2 -2
- package/build/confirm-dialog/component.cjs +2 -2
- package/build/confirm-dialog/component.cjs.map +2 -2
- package/build/context/context-system-provider.cjs +1 -1
- package/build/context/context-system-provider.cjs.map +2 -2
- package/build/custom-gradient-picker/index.cjs +1 -2
- package/build/custom-gradient-picker/index.cjs.map +2 -2
- package/build/custom-gradient-picker/utils.cjs +1 -1
- package/build/custom-gradient-picker/utils.cjs.map +2 -2
- package/build/custom-select-control/index.cjs +2 -3
- package/build/custom-select-control/index.cjs.map +2 -2
- package/build/custom-select-control-v2/custom-select.cjs +1 -1
- package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
- package/build/custom-select-control-v2/item.cjs +2 -3
- package/build/custom-select-control-v2/item.cjs.map +2 -2
- package/build/date-time/date/index.cjs +1 -1
- package/build/date-time/date/index.cjs.map +2 -2
- package/build/date-time/time/index.cjs +2 -2
- package/build/date-time/time/index.cjs.map +2 -2
- package/build/date-time/utils.cjs +1 -2
- package/build/date-time/utils.cjs.map +2 -2
- package/build/divider/styles.cjs +2 -2
- package/build/divider/styles.cjs.map +2 -2
- package/build/dropdown-menu/index.cjs +2 -3
- package/build/dropdown-menu/index.cjs.map +2 -2
- package/build/duotone-picker/duotone-picker.cjs +1 -1
- package/build/duotone-picker/duotone-picker.cjs.map +2 -2
- package/build/flex/flex/hook.cjs +1 -1
- package/build/flex/flex/hook.cjs.map +2 -2
- package/build/focal-point-picker/index.cjs +1 -2
- package/build/focal-point-picker/index.cjs.map +2 -2
- package/build/font-size-picker/font-size-picker-select.cjs +1 -2
- package/build/font-size-picker/font-size-picker-select.cjs.map +2 -2
- package/build/font-size-picker/index.cjs +2 -2
- package/build/font-size-picker/index.cjs.map +2 -2
- package/build/guide/index.cjs +2 -3
- package/build/guide/index.cjs.map +2 -2
- package/build/higher-order/navigate-regions/index.cjs +1 -2
- package/build/higher-order/navigate-regions/index.cjs.map +2 -2
- package/build/input-control/input-field.cjs +1 -1
- package/build/input-control/input-field.cjs.map +2 -2
- package/build/input-control/reducer/reducer.cjs +2 -4
- package/build/input-control/reducer/reducer.cjs.map +2 -2
- package/build/keyboard-shortcuts/index.cjs +1 -1
- package/build/keyboard-shortcuts/index.cjs.map +2 -2
- package/build/menu/index.cjs +1 -1
- package/build/menu/index.cjs.map +2 -2
- package/build/menu/item.cjs +1 -1
- package/build/menu/item.cjs.map +2 -2
- package/build/menu/popover.cjs +2 -2
- package/build/menu/popover.cjs.map +2 -2
- package/build/modal/index.cjs +2 -4
- package/build/modal/index.cjs.map +2 -2
- package/build/navigator/navigator/component.cjs +8 -13
- package/build/navigator/navigator/component.cjs.map +2 -2
- package/build/navigator/navigator-screen/component.cjs +1 -1
- package/build/navigator/navigator-screen/component.cjs.map +2 -2
- package/build/number-control/index.cjs +2 -3
- package/build/number-control/index.cjs.map +2 -2
- package/build/palette-edit/index.cjs +3 -4
- package/build/palette-edit/index.cjs.map +2 -2
- package/build/popover/index.cjs +1 -2
- package/build/popover/index.cjs.map +2 -2
- package/build/popover/overlay-middlewares.cjs +1 -2
- package/build/popover/overlay-middlewares.cjs.map +2 -2
- package/build/popover/utils.cjs +3 -8
- package/build/popover/utils.cjs.map +2 -2
- package/build/private-apis.cjs +1 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/radio-group/index.cjs +1 -1
- package/build/radio-group/index.cjs.map +2 -2
- package/build/range-control/index.cjs +4 -4
- package/build/range-control/index.cjs.map +2 -2
- package/build/range-control/utils.cjs +1 -1
- package/build/range-control/utils.cjs.map +2 -2
- package/build/search-control/index.cjs +3 -3
- package/build/search-control/index.cjs.map +2 -2
- package/build/slot-fill/fill.cjs +1 -2
- package/build/slot-fill/fill.cjs.map +2 -2
- package/build/slot-fill/slot.cjs +1 -2
- package/build/slot-fill/slot.cjs.map +2 -2
- package/build/tabs/tab.cjs +1 -2
- package/build/tabs/tab.cjs.map +2 -2
- package/build/tabs/tablist.cjs +7 -11
- package/build/tabs/tablist.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/utils.cjs +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.cjs.map +2 -2
- package/build/tree-grid/index.cjs +1 -2
- package/build/tree-grid/index.cjs.map +2 -2
- package/build/unit-control/index.cjs +4 -5
- package/build/unit-control/index.cjs.map +2 -2
- package/build/unit-control/utils.cjs +2 -2
- package/build/unit-control/utils.cjs.map +2 -2
- package/build/utils/element-rect.cjs +3 -4
- package/build/utils/element-rect.cjs.map +2 -2
- package/build/utils/font.cjs +1 -2
- package/build/utils/font.cjs.map +2 -2
- package/build/utils/strings.cjs +1 -2
- package/build/utils/strings.cjs.map +2 -2
- package/build/utils/use-deprecated-props.cjs +1 -1
- package/build/utils/use-deprecated-props.cjs.map +2 -2
- package/build/utils/values.cjs +1 -2
- package/build/utils/values.cjs.map +2 -2
- package/build/validated-form-controls/components/combobox-control.cjs +1 -1
- package/build/validated-form-controls/components/combobox-control.cjs.map +2 -2
- package/build/validated-form-controls/components/toggle-control.cjs +1 -1
- package/build/validated-form-controls/components/toggle-control.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +3 -6
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +6 -121
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/icon.mjs +2 -3
- package/build-module/alignment-matrix-control/icon.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +6 -121
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs +6 -85
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/autocomplete/autocompleter-ui.mjs +1 -2
- package/build-module/autocomplete/autocompleter-ui.mjs.map +2 -2
- package/build-module/box-control/input-control.mjs +8 -12
- package/build-module/box-control/input-control.mjs.map +2 -2
- package/build-module/button/index.mjs +6 -12
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/calendar/date-calendar/index.mjs +2 -2
- package/build-module/calendar/date-calendar/index.mjs.map +2 -2
- package/build-module/calendar/date-range-calendar/index.mjs +4 -6
- package/build-module/calendar/date-range-calendar/index.mjs.map +2 -2
- package/build-module/card/card/hook.mjs +1 -2
- package/build-module/card/card/hook.mjs.map +2 -2
- package/build-module/color-palette/utils.mjs +2 -2
- package/build-module/color-palette/utils.mjs.map +2 -2
- package/build-module/combobox-control/index.mjs +1 -2
- package/build-module/combobox-control/index.mjs.map +2 -2
- package/build-module/composite/group-label.mjs +1 -2
- package/build-module/composite/group-label.mjs.map +2 -2
- package/build-module/composite/group.mjs +1 -2
- package/build-module/composite/group.mjs.map +2 -2
- package/build-module/composite/hover.mjs +1 -2
- package/build-module/composite/hover.mjs.map +2 -2
- package/build-module/composite/index.mjs +1 -1
- package/build-module/composite/index.mjs.map +2 -2
- package/build-module/composite/item.mjs +1 -2
- package/build-module/composite/item.mjs.map +2 -2
- package/build-module/composite/legacy/index.mjs +1 -2
- package/build-module/composite/legacy/index.mjs.map +2 -2
- package/build-module/composite/row.mjs +1 -2
- package/build-module/composite/row.mjs.map +2 -2
- package/build-module/composite/typeahead.mjs +1 -2
- package/build-module/composite/typeahead.mjs.map +2 -2
- package/build-module/confirm-dialog/component.mjs +2 -2
- package/build-module/confirm-dialog/component.mjs.map +2 -2
- package/build-module/context/context-system-provider.mjs +1 -1
- package/build-module/context/context-system-provider.mjs.map +2 -2
- package/build-module/custom-gradient-picker/index.mjs +1 -2
- package/build-module/custom-gradient-picker/index.mjs.map +2 -2
- package/build-module/custom-gradient-picker/utils.mjs +1 -1
- package/build-module/custom-gradient-picker/utils.mjs.map +2 -2
- package/build-module/custom-select-control/index.mjs +2 -3
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs +1 -1
- package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
- package/build-module/custom-select-control-v2/item.mjs +2 -3
- package/build-module/custom-select-control-v2/item.mjs.map +2 -2
- package/build-module/date-time/date/index.mjs +1 -1
- package/build-module/date-time/date/index.mjs.map +2 -2
- package/build-module/date-time/time/index.mjs +2 -2
- package/build-module/date-time/time/index.mjs.map +2 -2
- package/build-module/date-time/utils.mjs +1 -2
- package/build-module/date-time/utils.mjs.map +2 -2
- package/build-module/divider/styles.mjs +2 -2
- package/build-module/divider/styles.mjs.map +2 -2
- package/build-module/dropdown-menu/index.mjs +2 -3
- package/build-module/dropdown-menu/index.mjs.map +2 -2
- package/build-module/duotone-picker/duotone-picker.mjs +1 -1
- package/build-module/duotone-picker/duotone-picker.mjs.map +2 -2
- package/build-module/flex/flex/hook.mjs +1 -1
- package/build-module/flex/flex/hook.mjs.map +2 -2
- package/build-module/focal-point-picker/index.mjs +1 -2
- package/build-module/focal-point-picker/index.mjs.map +2 -2
- package/build-module/font-size-picker/font-size-picker-select.mjs +1 -2
- package/build-module/font-size-picker/font-size-picker-select.mjs.map +2 -2
- package/build-module/font-size-picker/index.mjs +2 -2
- package/build-module/font-size-picker/index.mjs.map +2 -2
- package/build-module/guide/index.mjs +2 -3
- package/build-module/guide/index.mjs.map +2 -2
- package/build-module/higher-order/navigate-regions/index.mjs +1 -2
- package/build-module/higher-order/navigate-regions/index.mjs.map +2 -2
- package/build-module/input-control/input-field.mjs +1 -1
- package/build-module/input-control/input-field.mjs.map +2 -2
- package/build-module/input-control/reducer/reducer.mjs +2 -4
- package/build-module/input-control/reducer/reducer.mjs.map +2 -2
- package/build-module/keyboard-shortcuts/index.mjs +1 -1
- package/build-module/keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/menu/index.mjs +1 -1
- package/build-module/menu/index.mjs.map +2 -2
- package/build-module/menu/item.mjs +1 -1
- package/build-module/menu/item.mjs.map +2 -2
- package/build-module/menu/popover.mjs +2 -2
- package/build-module/menu/popover.mjs.map +2 -2
- package/build-module/modal/index.mjs +2 -4
- package/build-module/modal/index.mjs.map +2 -2
- package/build-module/navigator/navigator/component.mjs +8 -13
- package/build-module/navigator/navigator/component.mjs.map +2 -2
- package/build-module/navigator/navigator-screen/component.mjs +1 -1
- package/build-module/navigator/navigator-screen/component.mjs.map +2 -2
- package/build-module/number-control/index.mjs +2 -3
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs +3 -4
- package/build-module/palette-edit/index.mjs.map +2 -2
- package/build-module/popover/index.mjs +1 -2
- package/build-module/popover/index.mjs.map +2 -2
- package/build-module/popover/overlay-middlewares.mjs +1 -2
- package/build-module/popover/overlay-middlewares.mjs.map +2 -2
- package/build-module/popover/utils.mjs +3 -8
- package/build-module/popover/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/radio-group/index.mjs +1 -1
- package/build-module/radio-group/index.mjs.map +2 -2
- package/build-module/range-control/index.mjs +4 -4
- package/build-module/range-control/index.mjs.map +2 -2
- package/build-module/range-control/utils.mjs +1 -1
- package/build-module/range-control/utils.mjs.map +2 -2
- package/build-module/search-control/index.mjs +3 -3
- package/build-module/search-control/index.mjs.map +2 -2
- package/build-module/slot-fill/fill.mjs +1 -2
- package/build-module/slot-fill/fill.mjs.map +2 -2
- package/build-module/slot-fill/slot.mjs +1 -2
- package/build-module/slot-fill/slot.mjs.map +2 -2
- package/build-module/tabs/tab.mjs +1 -2
- package/build-module/tabs/tab.mjs.map +2 -2
- package/build-module/tabs/tablist.mjs +7 -11
- package/build-module/tabs/tablist.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/utils.mjs +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.mjs.map +2 -2
- package/build-module/tree-grid/index.mjs +1 -2
- package/build-module/tree-grid/index.mjs.map +2 -2
- package/build-module/unit-control/index.mjs +4 -5
- package/build-module/unit-control/index.mjs.map +2 -2
- package/build-module/unit-control/utils.mjs +2 -2
- package/build-module/unit-control/utils.mjs.map +2 -2
- package/build-module/utils/element-rect.mjs +3 -4
- package/build-module/utils/element-rect.mjs.map +2 -2
- package/build-module/utils/font.mjs +1 -2
- package/build-module/utils/font.mjs.map +2 -2
- package/build-module/utils/strings.mjs +1 -2
- package/build-module/utils/strings.mjs.map +2 -2
- package/build-module/utils/use-deprecated-props.mjs +1 -1
- package/build-module/utils/use-deprecated-props.mjs.map +2 -2
- package/build-module/utils/values.mjs +1 -2
- package/build-module/utils/values.mjs.map +2 -2
- package/build-module/validated-form-controls/components/combobox-control.mjs +1 -1
- package/build-module/validated-form-controls/components/combobox-control.mjs.map +2 -2
- package/build-module/validated-form-controls/components/toggle-control.mjs +1 -1
- package/build-module/validated-form-controls/components/toggle-control.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +3 -6
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-types/private-apis.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/private-apis.ts +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/popover/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { cubicBezier } from 'framer-motion';\n/**\n * Internal dependencies\n */\nimport { DROPDOWN_MOTION } from '../utils';\nconst POSITION_TO_PLACEMENT = {\n bottom: 'bottom',\n top: 'top',\n 'middle left': 'left',\n 'middle right': 'right',\n 'bottom left': 'bottom-end',\n 'bottom center': 'bottom',\n 'bottom right': 'bottom-start',\n 'top left': 'top-end',\n 'top center': 'top',\n 'top right': 'top-start',\n 'middle left left': 'left',\n 'middle left right': 'left',\n 'middle left bottom': 'left-end',\n 'middle left top': 'left-start',\n 'middle right left': 'right',\n 'middle right right': 'right',\n 'middle right bottom': 'right-end',\n 'middle right top': 'right-start',\n 'bottom left left': 'bottom-end',\n 'bottom left right': 'bottom-end',\n 'bottom left bottom': 'bottom-end',\n 'bottom left top': 'bottom-end',\n 'bottom center left': 'bottom',\n 'bottom center right': 'bottom',\n 'bottom center bottom': 'bottom',\n 'bottom center top': 'bottom',\n 'bottom right left': 'bottom-start',\n 'bottom right right': 'bottom-start',\n 'bottom right bottom': 'bottom-start',\n 'bottom right top': 'bottom-start',\n 'top left left': 'top-end',\n 'top left right': 'top-end',\n 'top left bottom': 'top-end',\n 'top left top': 'top-end',\n 'top center left': 'top',\n 'top center right': 'top',\n 'top center bottom': 'top',\n 'top center top': 'top',\n 'top right left': 'top-start',\n 'top right right': 'top-start',\n 'top right bottom': 'top-start',\n 'top right top': 'top-start',\n // `middle`/`middle center [corner?]` positions are associated to a fallback\n // `bottom` placement because there aren't any corresponding placement values.\n middle: 'bottom',\n 'middle center': 'bottom',\n 'middle center bottom': 'bottom',\n 'middle center left': 'bottom',\n 'middle center right': 'bottom',\n 'middle center top': 'bottom'\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = position =>
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAI5B,SAAS,uBAAuB;AAChC,IAAM,wBAAwB;AAAA,EAC5B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA;AAAA;AAAA,EAGjB,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,qBAAqB;AACvB;AASO,IAAM,sBAAsB,cAAY
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { cubicBezier } from 'framer-motion';\n/**\n * Internal dependencies\n */\nimport { DROPDOWN_MOTION } from '../utils';\nconst POSITION_TO_PLACEMENT = {\n bottom: 'bottom',\n top: 'top',\n 'middle left': 'left',\n 'middle right': 'right',\n 'bottom left': 'bottom-end',\n 'bottom center': 'bottom',\n 'bottom right': 'bottom-start',\n 'top left': 'top-end',\n 'top center': 'top',\n 'top right': 'top-start',\n 'middle left left': 'left',\n 'middle left right': 'left',\n 'middle left bottom': 'left-end',\n 'middle left top': 'left-start',\n 'middle right left': 'right',\n 'middle right right': 'right',\n 'middle right bottom': 'right-end',\n 'middle right top': 'right-start',\n 'bottom left left': 'bottom-end',\n 'bottom left right': 'bottom-end',\n 'bottom left bottom': 'bottom-end',\n 'bottom left top': 'bottom-end',\n 'bottom center left': 'bottom',\n 'bottom center right': 'bottom',\n 'bottom center bottom': 'bottom',\n 'bottom center top': 'bottom',\n 'bottom right left': 'bottom-start',\n 'bottom right right': 'bottom-start',\n 'bottom right bottom': 'bottom-start',\n 'bottom right top': 'bottom-start',\n 'top left left': 'top-end',\n 'top left right': 'top-end',\n 'top left bottom': 'top-end',\n 'top left top': 'top-end',\n 'top center left': 'top',\n 'top center right': 'top',\n 'top center bottom': 'top',\n 'top center top': 'top',\n 'top right left': 'top-start',\n 'top right right': 'top-start',\n 'top right bottom': 'top-start',\n 'top right top': 'top-start',\n // `middle`/`middle center [corner?]` positions are associated to a fallback\n // `bottom` placement because there aren't any corresponding placement values.\n middle: 'bottom',\n 'middle center': 'bottom',\n 'middle center bottom': 'bottom',\n 'middle center left': 'bottom',\n 'middle center right': 'bottom',\n 'middle center top': 'bottom'\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = position => POSITION_TO_PLACEMENT[position] ?? 'bottom';\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN = {\n top: {\n originX: 0.5,\n originY: 1\n },\n // open from bottom, center\n 'top-start': {\n originX: 0,\n originY: 1\n },\n // open from bottom, left\n 'top-end': {\n originX: 1,\n originY: 1\n },\n // open from bottom, right\n right: {\n originX: 0,\n originY: 0.5\n },\n // open from middle, left\n 'right-start': {\n originX: 0,\n originY: 0\n },\n // open from top, left\n 'right-end': {\n originX: 0,\n originY: 1\n },\n // open from bottom, left\n bottom: {\n originX: 0.5,\n originY: 0\n },\n // open from top, center\n 'bottom-start': {\n originX: 0,\n originY: 0\n },\n // open from top, left\n 'bottom-end': {\n originX: 1,\n originY: 0\n },\n // open from top, right\n left: {\n originX: 1,\n originY: 0.5\n },\n // open from middle, right\n 'left-start': {\n originX: 1,\n originY: 0\n },\n // open from top, right\n 'left-end': {\n originX: 1,\n originY: 1\n },\n // open from bottom, right\n overlay: {\n originX: 0.5,\n originY: 0.5\n } // open from center, center\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = placement => {\n const translateProp = placement.startsWith('top') || placement.startsWith('bottom') ? 'translateY' : 'translateX';\n const translateDirection = placement.startsWith('top') || placement.startsWith('left') ? 1 : -1;\n return {\n style: PLACEMENT_TO_ANIMATION_ORIGIN[placement],\n initial: {\n opacity: 0,\n [translateProp]: `${DROPDOWN_MOTION.SLIDE_DISTANCE * translateDirection}px`\n },\n animate: {\n opacity: 1,\n [translateProp]: 0\n },\n transition: {\n opacity: {\n duration: DROPDOWN_MOTION.FADE_DURATION / 1000,\n ease: DROPDOWN_MOTION.FADE_EASING.function\n },\n [translateProp]: {\n duration: DROPDOWN_MOTION.SLIDE_DURATION / 1000,\n ease: cubicBezier(...DROPDOWN_MOTION.SLIDE_EASING.args)\n }\n }\n };\n};\nfunction isTopBottom(anchorRef) {\n return !!anchorRef?.top;\n}\nfunction isRef(anchorRef) {\n return !!anchorRef?.current;\n}\nexport const getReferenceElement = ({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n}) => {\n let referenceElement = null;\n if (anchor) {\n referenceElement = anchor;\n } else if (isTopBottom(anchorRef)) {\n // Create a virtual element for the ref. The expectation is that\n // if anchorRef.top is defined, then anchorRef.bottom is defined too.\n // Seems to be used by the block toolbar, when multiple blocks are selected\n // (top and bottom blocks are used to calculate the resulting rect).\n referenceElement = {\n getBoundingClientRect() {\n const topRect = anchorRef.top.getBoundingClientRect();\n const bottomRect = anchorRef.bottom.getBoundingClientRect();\n return new window.DOMRect(topRect.x, topRect.y, topRect.width, bottomRect.bottom - topRect.top);\n }\n };\n } else if (isRef(anchorRef)) {\n // Standard React ref.\n referenceElement = anchorRef.current;\n } else if (anchorRef) {\n // If `anchorRef` holds directly the element's value (no `current` key)\n // This is a weird scenario and should be deprecated.\n referenceElement = anchorRef;\n } else if (anchorRect) {\n // Create a virtual element for the ref.\n referenceElement = {\n getBoundingClientRect() {\n return anchorRect;\n }\n };\n } else if (getAnchorRect) {\n // Create a virtual element for the ref.\n referenceElement = {\n getBoundingClientRect() {\n const rect = getAnchorRect(fallbackReferenceElement);\n return new window.DOMRect(rect.x ?? rect.left, rect.y ?? rect.top, rect.width ?? rect.right - rect.left, rect.height ?? rect.bottom - rect.top);\n }\n };\n } else if (fallbackReferenceElement) {\n // If no explicit ref is passed via props, fall back to\n // anchoring to the popover's parent node.\n referenceElement = fallbackReferenceElement.parentElement;\n }\n\n // Convert any `undefined` value to `null`.\n return referenceElement ?? null;\n};\n\n/**\n * Computes the final coordinate that needs to be applied to the floating\n * element when applying transform inline styles, defaulting to `undefined`\n * if the provided value is `null` or `NaN`.\n *\n * @param c input coordinate (usually as returned from floating-ui)\n * @return The coordinate's value to be used for inline styles. An `undefined`\n * return value means \"no style set\" for this coordinate.\n */\nexport const computePopoverPosition = c => c === null || Number.isNaN(c) ? undefined : Math.round(c);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAI5B,SAAS,uBAAuB;AAChC,IAAM,wBAAwB;AAAA,EAC5B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,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AAmB;AACvB,MAAI,QAAQ;AACV,uBAAmB;AAAA,EACrB,WAAW,YAAY,SAAS,GAAG;AAKjC,uBAAmB;AAAA,MACjB,wBAAwB;AACtB,cAAM,UAAU,UAAU,IAAI,sBAAsB;AACpD,cAAM,aAAa,UAAU,OAAO,sBAAsB;AAC1D,eAAO,IAAI,OAAO,QAAQ,QAAQ,GAAG,QAAQ,GAAG,QAAQ,OAAO,WAAW,SAAS,QAAQ,GAAG;AAAA,MAChG;AAAA,IACF;AAAA,EACF,WAAW,MAAM,SAAS,GAAG;AAE3B,uBAAmB,UAAU;AAAA,EAC/B,WAAW,WAAW;AAGpB,uBAAmB;AAAA,EACrB,WAAW,YAAY;AAErB,uBAAmB;AAAA,MACjB,wBAAwB;AACtB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,WAAW,eAAe;AAExB,uBAAmB;AAAA,MACjB,wBAAwB;AACtB,cAAM,OAAO,cAAc,wBAAwB;AACnD,eAAO,IAAI,OAAO,QAAQ,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,KAAK,KAAK,KAAK,SAAS,KAAK,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,SAAS,KAAK,GAAG;AAAA,MAChJ;AAAA,IACF;AAAA,EACF,WAAW,0BAA0B;AAGnC,uBAAmB,yBAAyB;AAAA,EAC9C;AAGA,SAAO,oBAAoB;AAC7B;AAWO,IAAM,yBAAyB,OAAK,MAAM,QAAQ,OAAO,MAAM,CAAC,IAAI,SAAY,KAAK,MAAM,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@ import { withIgnoreIMEEvents } from "./utils/with-ignore-ime-events.mjs";
|
|
|
9
9
|
import { lock } from "./lock-unlock.mjs";
|
|
10
10
|
import Badge from "./badge/index.mjs";
|
|
11
11
|
import { DateCalendar, DateRangeCalendar, TZDate } from "./calendar/index.mjs";
|
|
12
|
-
import { ValidatedCheckboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from "./validated-form-controls/index.mjs";
|
|
12
|
+
import { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from "./validated-form-controls/index.mjs";
|
|
13
13
|
import { ValidatedFormTokenField } from "./validated-form-controls/components/form-token-field.mjs";
|
|
14
14
|
import { Picker } from "./color-picker/picker.mjs";
|
|
15
15
|
var privateApis = {};
|
|
@@ -29,6 +29,7 @@ lock(privateApis, {
|
|
|
29
29
|
Picker,
|
|
30
30
|
ValidatedInputControl,
|
|
31
31
|
ValidatedCheckboxControl,
|
|
32
|
+
ValidatedComboboxControl,
|
|
32
33
|
ValidatedNumberControl,
|
|
33
34
|
ValidatedSelectControl,
|
|
34
35
|
ValidatedRadioControl,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport { Picker } from './color-picker/picker';\nexport const privateApis = {};\nlock(privateApis, {\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n Picker,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,uBAAuB,sDAAsD;AACtF,SAAS,YAAY;AACrB,SAAS,yBAAyB;AAClC,OAAO,WAAW;AAClB,SAAS,YAAY;AACrB,SAAS,WAAW,2BAA2B;AAC/C,SAAS,2BAA2B;AACpC,SAAS,YAAY;AACrB,OAAO,WAAW;AAClB,SAAS,cAAc,mBAAmB,cAAc;AACxD,SAAS,0BAA0B,uBAAuB,wBAAwB,wBAAwB,uBAAuB,sBAAsB,0BAA0B,wBAAwB,mCAAmC;
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport { Picker } from './color-picker/picker';\nexport const privateApis = {};\nlock(privateApis, {\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n Picker,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedComboboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,uBAAuB,sDAAsD;AACtF,SAAS,YAAY;AACrB,SAAS,yBAAyB;AAClC,OAAO,WAAW;AAClB,SAAS,YAAY;AACrB,SAAS,WAAW,2BAA2B;AAC/C,SAAS,2BAA2B;AACpC,SAAS,YAAY;AACrB,OAAO,WAAW;AAClB,SAAS,cAAc,mBAAmB,cAAc;AACxD,SAAS,0BAA0B,0BAA0B,uBAAuB,wBAAwB,wBAAwB,uBAAuB,sBAAsB,0BAA0B,wBAAwB,mCAAmC;AACtQ,SAAS,+BAA+B;AACxC,SAAS,cAAc;AAChB,IAAM,cAAc,CAAC;AAC5B,KAAK,aAAa;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/radio-group/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo, forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ButtonGroup from '../button-group';\nimport { RadioGroupContext } from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedRadioGroup({\n label,\n checked,\n defaultChecked,\n disabled,\n onChange,\n children,\n ...props\n}, ref) {\n const radioStore = Ariakit.useRadioStore({\n value: checked,\n defaultValue: defaultChecked,\n setValue: newValue => {\n onChange?.(newValue
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AAKzB,OAAO,gBAAgB;AACvB,SAAS,SAAS,kBAAkB;AACpC,SAAS,aAAa;AAKtB,OAAO,iBAAiB;AACxB,SAAS,yBAAyB;AAClC,SAAS,OAAO,YAAY;AAC5B,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,aAAqB,sBAAc;AAAA,IACvC,OAAO;AAAA,IACP,cAAc;AAAA,IACd,UAAU,cAAY;AACpB,iBAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo, forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ButtonGroup from '../button-group';\nimport { RadioGroupContext } from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedRadioGroup({\n label,\n checked,\n defaultChecked,\n disabled,\n onChange,\n children,\n ...props\n}, ref) {\n const radioStore = Ariakit.useRadioStore({\n value: checked,\n defaultValue: defaultChecked,\n setValue: newValue => {\n onChange?.(newValue ?? undefined);\n },\n rtl: isRTL()\n });\n const contextValue = useMemo(() => ({\n store: radioStore,\n disabled\n }), [radioStore, disabled]);\n deprecated('wp.components.__experimentalRadioGroup', {\n alternative: 'wp.components.RadioControl or wp.components.__experimentalToggleGroupControl',\n since: '6.8'\n });\n return /*#__PURE__*/_jsx(RadioGroupContext.Provider, {\n value: contextValue,\n children: /*#__PURE__*/_jsx(Ariakit.RadioGroup, {\n store: radioStore,\n render: /*#__PURE__*/_jsx(ButtonGroup, {\n __shouldNotWarnDeprecated: true,\n children: children\n }),\n \"aria-label\": label,\n ref: ref,\n ...props\n })\n });\n}\n\n/**\n * @deprecated Use `RadioControl` or `ToggleGroupControl` instead.\n */\nexport const RadioGroup = forwardRef(UnforwardedRadioGroup);\nRadioGroup.displayName = 'RadioGroup';\nexport default RadioGroup;"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AAKzB,OAAO,gBAAgB;AACvB,SAAS,SAAS,kBAAkB;AACpC,SAAS,aAAa;AAKtB,OAAO,iBAAiB;AACxB,SAAS,yBAAyB;AAClC,SAAS,OAAO,YAAY;AAC5B,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,aAAqB,sBAAc;AAAA,IACvC,OAAO;AAAA,IACP,cAAc;AAAA,IACd,UAAU,cAAY;AACpB,iBAAW,YAAY,MAAS;AAAA,IAClC;AAAA,IACA,KAAK,MAAM;AAAA,EACb,CAAC;AACD,QAAM,eAAe,QAAQ,OAAO;AAAA,IAClC,OAAO;AAAA,IACP;AAAA,EACF,IAAI,CAAC,YAAY,QAAQ,CAAC;AAC1B,aAAW,0CAA0C;AAAA,IACnD,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AACD,SAAoB,qBAAK,kBAAkB,UAAU;AAAA,IACnD,OAAO;AAAA,IACP,UAAuB,qBAAa,oBAAY;AAAA,MAC9C,OAAO;AAAA,MACP,QAAqB,qBAAK,aAAa;AAAA,QACrC,2BAA2B;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,MACD,cAAc;AAAA,MACd;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AAKO,IAAMA,cAAa,WAAW,qBAAqB;AAC1DA,YAAW,cAAc;AACzB,IAAO,sBAAQA;",
|
|
6
6
|
"names": ["RadioGroup"]
|
|
7
7
|
}
|
|
@@ -70,7 +70,7 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
70
70
|
const [value, setValue] = useControlledRangeValue({
|
|
71
71
|
min,
|
|
72
72
|
max,
|
|
73
|
-
value: valueProp
|
|
73
|
+
value: valueProp ?? null,
|
|
74
74
|
initial: initialPosition
|
|
75
75
|
});
|
|
76
76
|
const isResetPendent = useRef(false);
|
|
@@ -121,9 +121,9 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
const handleOnReset = () => {
|
|
124
|
-
const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue
|
|
124
|
+
const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;
|
|
125
125
|
setValue(resetValue);
|
|
126
|
-
onChange(resetValue
|
|
126
|
+
onChange(resetValue ?? void 0);
|
|
127
127
|
};
|
|
128
128
|
const handleShowTooltip = () => setShowTooltip(true);
|
|
129
129
|
const handleHideTooltip = () => setShowTooltip(false);
|
|
@@ -179,7 +179,7 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
179
179
|
onMouseLeave,
|
|
180
180
|
ref: useMergeRefs([inputRef, forwardedRef]),
|
|
181
181
|
step,
|
|
182
|
-
value: inputSliderValue
|
|
182
|
+
value: inputSliderValue ?? void 0
|
|
183
183
|
}), /* @__PURE__ */ _jsx(RangeRail, {
|
|
184
184
|
"aria-hidden": true,
|
|
185
185
|
disabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp !== null && valueProp !== void 0 ? valueProp : null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef();\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue !== null && resetFallbackValue !== void 0 ? resetFallbackValue : null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue !== null && resetValue !== void 0 ? resetValue : undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue !== null && inputSliderValue !== void 0 ? inputSliderValue : undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO,eAAe;AAChI,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA,IACJ,yBAAyB;AAAA;AAAA,IAEzB;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,OAAO,YAAY,OAAO,MAAM;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,IACf,cAAc;AAAA,IACd;AAAA,IACA,uBAAuB,OAAK;AAAA,IAC5B;AAAA,IACA,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,CAAC,OAAO,QAAQ,IAAI,wBAAwB;AAAA,IAChD;AAAA,IACA;AAAA,IACA,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef();\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO,eAAe;AAChI,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA,IACJ,yBAAyB;AAA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ings;
|
|
18
18
|
const [state, setInternalState] = useControlledState(floatClamp(valueProp, min, max), {
|
|
19
|
-
initial: floatClamp(initial
|
|
19
|
+
initial: floatClamp(initial ?? null, min, max),
|
|
20
20
|
fallback: null
|
|
21
21
|
});
|
|
22
22
|
const setState = useCallback((nextValue) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp(value, min, max) {\n if (typeof value !== 'number') {\n return null;\n }\n return parseFloat(`${clamp(value, min, max)}`);\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(settings) {\n const {\n min,\n max,\n value: valueProp,\n initial\n } = settings;\n const [state, setInternalState] = useControlledState(floatClamp(valueProp, min, max), {\n initial: floatClamp(initial
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAK5B,SAAS,0BAA0B;AACnC,SAAS,aAAa;AAUf,SAAS,WAAW,OAAO,KAAK,KAAK;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,WAAW,GAAG,MAAM,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/C;AAQO,SAAS,wBAAwB,UAAU;AAChD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,OAAO,gBAAgB,IAAI,mBAAmB,WAAW,WAAW,KAAK,GAAG,GAAG;AAAA,IACpF,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp(value, min, max) {\n if (typeof value !== 'number') {\n return null;\n }\n return parseFloat(`${clamp(value, min, max)}`);\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(settings) {\n const {\n min,\n max,\n value: valueProp,\n initial\n } = settings;\n const [state, setInternalState] = useControlledState(floatClamp(valueProp, min, max), {\n initial: floatClamp(initial ?? null, min, max),\n fallback: null\n });\n const setState = useCallback(nextValue => {\n if (nextValue === null) {\n setInternalState(null);\n } else {\n setInternalState(floatClamp(nextValue, min, max));\n }\n }, [min, max, setInternalState]);\n\n // `state` can't be an empty string because we specified a fallback value of\n // `null` in `useControlledState`\n return [state, setState];\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAK5B,SAAS,0BAA0B;AACnC,SAAS,aAAa;AAUf,SAAS,WAAW,OAAO,KAAK,KAAK;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,WAAW,GAAG,MAAM,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/C;AAQO,SAAS,wBAAwB,UAAU;AAChD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,OAAO,gBAAgB,IAAI,mBAAmB,WAAW,WAAW,KAAK,GAAG,GAAG;AAAA,IACpF,SAAS,WAAW,WAAW,MAAM,KAAK,GAAG;AAAA,IAC7C,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,WAAW,YAAY,eAAa;AACxC,QAAI,cAAc,MAAM;AACtB,uBAAiB,IAAI;AAAA,IACvB,OAAO;AACL,uBAAiB,WAAW,WAAW,KAAK,GAAG,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,KAAK,KAAK,gBAAgB,CAAC;AAI/B,SAAO,CAAC,OAAO,QAAQ;AACzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,7 @@ function SuffixItem({
|
|
|
34
34
|
size: "small",
|
|
35
35
|
icon: closeSmall,
|
|
36
36
|
label: onClose ? __("Close search") : __("Reset search"),
|
|
37
|
-
onClick: onClose
|
|
37
|
+
onClick: onClose ?? onReset
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -66,10 +66,10 @@ function UnforwardedSearchControl({
|
|
|
66
66
|
type: "search",
|
|
67
67
|
size,
|
|
68
68
|
className: clsx("components-search-control", className),
|
|
69
|
-
onChange: (nextValue) => onChange(nextValue
|
|
69
|
+
onChange: (nextValue) => onChange(nextValue ?? ""),
|
|
70
70
|
autoComplete: "off",
|
|
71
71
|
placeholder,
|
|
72
|
-
value: value
|
|
72
|
+
value: value ?? "",
|
|
73
73
|
prefix: /* @__PURE__ */ _jsx(InputControlPrefixWrapper, {
|
|
74
74
|
variant: "icon",
|
|
75
75
|
children: /* @__PURE__ */ _jsx(StyledIcon, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/search-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport { StyledInputControl, StyledIcon } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n value,\n onChange,\n onClose\n}) {\n if (!onClose && !value) {\n return null;\n }\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AACnC,SAAS,YAAY,cAAc;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,oBAAoB,kBAAkB;AAC/C,SAAS,OAAO,YAAY;AAC5B,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,MAAI,CAAC,WAAW,CAAC,OAAO;AACtB,WAAO;AAAA,EACT;AACA,MAAI,SAAS;AACX,eAAW,iDAAiD;AAAA,MAC1D,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,QAAM,UAAU,MAAM;AACpB,aAAS,EAAE;AACX,cAAU,SAAS,MAAM;AAAA,EAC3B;AACA,SAAoB,qBAAK,2BAA2B;AAAA,IAClD,SAAS;AAAA,IACT,UAAuB,qBAAK,QAAQ;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,UAAU,GAAG,cAAc,IAAI,GAAG,cAAc;AAAA,MACvD,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport { StyledInputControl, StyledIcon } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n value,\n onChange,\n onClose\n}) {\n if (!onClose && !value) {\n return null;\n }\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose ?? onReset\n })\n });\n}\nfunction UnforwardedSearchControl({\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n className,\n onChange,\n value,\n label = __('Search'),\n placeholder = __('Search'),\n hideLabelFromVision = true,\n onClose,\n size = 'default',\n ...restProps\n}, forwardedRef) {\n // @ts-expect-error The `disabled` prop is not yet supported in the SearchControl component.\n // Work with the design team (@WordPress/gutenberg-design) if you need this feature.\n const {\n disabled,\n ...filteredRestProps\n } = restProps;\n const searchRef = useRef(null);\n const instanceId = useInstanceId(SearchControl, 'components-search-control');\n return /*#__PURE__*/_jsx(StyledInputControl, {\n __next40pxDefaultSize: true,\n id: instanceId,\n hideLabelFromVision: hideLabelFromVision,\n label: label,\n ref: useMergeRefs([searchRef, forwardedRef]),\n type: \"search\",\n size: size,\n className: clsx('components-search-control', className),\n onChange: nextValue => onChange(nextValue ?? ''),\n autoComplete: \"off\",\n placeholder: placeholder,\n value: value ?? '',\n prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {\n variant: \"icon\",\n children: /*#__PURE__*/_jsx(StyledIcon, {\n icon: search,\n fill: \"currentColor\"\n })\n }),\n suffix: /*#__PURE__*/_jsx(SuffixItem, {\n searchRef: searchRef,\n value: value,\n onChange: onChange,\n onClose: onClose\n }),\n ...filteredRestProps\n });\n}\n\n/**\n * SearchControl components let users display a search control.\n *\n * ```jsx\n * import { SearchControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function MySearchControl( { className, setState } ) {\n * const [ searchInput, setSearchInput ] = useState( '' );\n *\n * return (\n * <SearchControl\n * value={ searchInput }\n * onChange={ setSearchInput }\n * />\n * );\n * }\n * ```\n */\nexport const SearchControl = forwardRef(UnforwardedSearchControl);\nSearchControl.displayName = 'SearchControl';\nexport default SearchControl;"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AACnC,SAAS,YAAY,cAAc;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,oBAAoB,kBAAkB;AAC/C,SAAS,OAAO,YAAY;AAC5B,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,MAAI,CAAC,WAAW,CAAC,OAAO;AACtB,WAAO;AAAA,EACT;AACA,MAAI,SAAS;AACX,eAAW,iDAAiD;AAAA,MAC1D,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,QAAM,UAAU,MAAM;AACpB,aAAS,EAAE;AACX,cAAU,SAAS,MAAM;AAAA,EAC3B;AACA,SAAoB,qBAAK,2BAA2B;AAAA,IAClD,SAAS;AAAA,IACT,UAAuB,qBAAK,QAAQ;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,O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) {
|
|
11
|
-
var _slot$fillProps;
|
|
12
11
|
const registry = useContext(SlotFillContext);
|
|
13
12
|
const instanceRef = useRef({});
|
|
14
13
|
const childrenRef = useRef(children);
|
|
@@ -40,7 +39,7 @@ function Fill({
|
|
|
40
39
|
if (!portalEl) {
|
|
41
40
|
return null;
|
|
42
41
|
}
|
|
43
|
-
const wrappedChildren = typeof children === "function" ? children(
|
|
42
|
+
const wrappedChildren = typeof children === "function" ? children(slot.fillProps ?? {}) : children;
|
|
44
43
|
return createPortal(/* @__PURE__ */ _jsx(StyleProvider, {
|
|
45
44
|
document: portalEl.ownerDocument,
|
|
46
45
|
children: wrappedChildren
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/slot-fill/fill.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport StyleProvider from '../style-provider';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function Fill({\n name,\n children\n}) {\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB,QAAQ,oBAAoB;AAKlE,OAAO,qBAAqB;AAC5B,OAAO,mBAAmB;AAC1B,SAAS,OAAO,YAAY;AACb,SAAR,KAAsB;AAAA,EAC3B;AAAA,EACA;AACF,GAAG;AACD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport StyleProvider from '../style-provider';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function Fill({\n name,\n children\n}) {\n const registry = useContext(SlotFillContext);\n const instanceRef = useRef({});\n const childrenRef = useRef(children);\n useLayoutEffect(() => {\n childrenRef.current = children;\n }, [children]);\n useLayoutEffect(() => {\n const instance = instanceRef.current;\n registry.registerFill(name, {\n instance,\n children: childrenRef.current\n });\n return () => registry.unregisterFill(name, instance);\n }, [registry, name]);\n useLayoutEffect(() => {\n registry.updateFill(name, {\n instance: instanceRef.current,\n children: childrenRef.current\n });\n });\n const slot = useObservableValue(registry.slots, name);\n if (!slot) {\n return null;\n }\n if (slot.type === 'children') {\n return null;\n }\n const portalEl = slot.ref.current;\n if (!portalEl) {\n return null;\n }\n const wrappedChildren = typeof children === 'function' ? children(slot.fillProps ?? {}) : children;\n\n // When using a `Fill`, the `children` will be rendered in the document of the\n // `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n // to make sure we're referencing the right document/iframe (instead of the\n // context of the `Fill`'s parent).\n return createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: portalEl.ownerDocument,\n children: wrappedChildren\n }), portalEl);\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB,QAAQ,oBAAoB;AAKlE,OAAO,qBAAqB;AAC5B,OAAO,mBAAmB;AAC1B,SAAS,OAAO,YAAY;AACb,SAAR,KAAsB;AAAA,EAC3B;AAAA,EACA;AACF,GAAG;AACD,QAAM,WAAW,WAAW,eAAe;AAC3C,QAAM,cAAc,OAAO,CAAC,CAAC;AAC7B,QAAM,cAAc,OAAO,QAAQ;AACnC,kBAAgB,MAAM;AACpB,gBAAY,UAAU;AAAA,EACxB,GAAG,CAAC,QAAQ,CAAC;AACb,kBAAgB,MAAM;AACpB,UAAM,WAAW,YAAY;AAC7B,aAAS,aAAa,MAAM;AAAA,MAC1B;AAAA,MACA,UAAU,YAAY;AAAA,IACxB,CAAC;AACD,WAAO,MAAM,SAAS,eAAe,MAAM,QAAQ;AAAA,EACrD,GAAG,CAAC,UAAU,IAAI,CAAC;AACnB,kBAAgB,MAAM;AACpB,aAAS,WAAW,MAAM;AAAA,MACxB,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,IACxB,CAAC;AAAA,EACH,CAAC;AACD,QAAM,OAAO,mBAAmB,SAAS,OAAO,IAAI;AACpD,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,MAAI,KAAK,SAAS,YAAY;AAC5B,WAAO;AAAA,EACT;AACA,QAAM,WAAW,KAAK,IAAI;AAC1B,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,kBAAkB,OAAO,aAAa,aAAa,SAAS,KAAK,aAAa,CAAC,CAAC,IAAI;AAM1F,SAAO,aAA0B,qBAAK,eAAe;AAAA,IACnD,UAAU,SAAS;AAAA,IACnB,UAAU;AAAA,EACZ,CAAC,GAAG,QAAQ;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,7 +21,6 @@ function addKeysToChildren(children) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
function Slot(props) {
|
|
24
|
-
var _useObservableValue;
|
|
25
24
|
const {
|
|
26
25
|
name,
|
|
27
26
|
children,
|
|
@@ -37,7 +36,7 @@ function Slot(props) {
|
|
|
37
36
|
});
|
|
38
37
|
return () => registry.unregisterSlot(name, instance);
|
|
39
38
|
}, [registry, name]);
|
|
40
|
-
let fills =
|
|
39
|
+
let fills = useObservableValue(registry.fills, name) ?? [];
|
|
41
40
|
const currentSlot = useObservableValue(registry.slots, name);
|
|
42
41
|
if (!currentSlot || currentSlot.instance !== instanceRef.current) {
|
|
43
42
|
fills = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/slot-fill/slot.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, Children, cloneElement, isEmptyElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Whether the argument is a function.\n *\n * @param maybeFunc The argument to check.\n * @return True if the argument is a function, false otherwise.\n */\nfunction isFunction(maybeFunc) {\n return typeof maybeFunc === 'function';\n}\nfunction addKeysToChildren(children) {\n return Children.map(children, (child, childIndex) => {\n if (!child || typeof child === 'string') {\n return child;\n }\n let childKey = childIndex;\n if (typeof child === 'object' && 'key' in child && child?.key) {\n childKey = child.key;\n }\n return cloneElement(child, {\n key: childKey\n });\n });\n}\nfunction Slot(props) {\n
|
|
5
|
-
"mappings": ";AAOA,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB,QAAQ,UAAU,cAAc,sBAAsB;AAK5F,OAAO,qBAAqB;AAC5B,SAAS,YAAY,WAAW,OAAO,YAAY;AAOnD,SAAS,WAAW,WAAW;AAC7B,SAAO,OAAO,cAAc;AAC9B;AACA,SAAS,kBAAkB,UAAU;AACnC,SAAO,SAAS,IAAI,UAAU,CAAC,OAAO,eAAe;AACnD,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,aAAO;AAAA,IACT;AACA,QAAI,WAAW;AACf,QAAI,OAAO,UAAU,YAAY,SAAS,SAAS,OAAO,KAAK;AAC7D,iBAAW,MAAM;AAAA,IACnB;AACA,WAAO,aAAa,OAAO;AAAA,MACzB,KAAK;AAAA,IACP,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,KAAK,OAAO;AACnB,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, Children, cloneElement, isEmptyElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Whether the argument is a function.\n *\n * @param maybeFunc The argument to check.\n * @return True if the argument is a function, false otherwise.\n */\nfunction isFunction(maybeFunc) {\n return typeof maybeFunc === 'function';\n}\nfunction addKeysToChildren(children) {\n return Children.map(children, (child, childIndex) => {\n if (!child || typeof child === 'string') {\n return child;\n }\n let childKey = childIndex;\n if (typeof child === 'object' && 'key' in child && child?.key) {\n childKey = child.key;\n }\n return cloneElement(child, {\n key: childKey\n });\n });\n}\nfunction Slot(props) {\n const {\n name,\n children,\n fillProps = {}\n } = props;\n const registry = useContext(SlotFillContext);\n const instanceRef = useRef({});\n useLayoutEffect(() => {\n const instance = instanceRef.current;\n registry.registerSlot(name, {\n type: 'children',\n instance\n });\n return () => registry.unregisterSlot(name, instance);\n }, [registry, name]);\n let fills = useObservableValue(registry.fills, name) ?? [];\n const currentSlot = useObservableValue(registry.slots, name);\n\n // Fills should only be rendered in the currently registered instance of the slot.\n if (!currentSlot || currentSlot.instance !== instanceRef.current) {\n fills = [];\n }\n const renderedFills = fills.map(fill => {\n const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;\n return addKeysToChildren(fillChildren);\n }).filter(\n // In some cases fills are rendered only when some conditions apply.\n // This ensures that we only use non-empty fills when rendering, i.e.,\n // it allows us to render wrappers only when the fills are actually present.\n element => !isEmptyElement(element));\n return /*#__PURE__*/_jsx(_Fragment, {\n children: isFunction(children) ? children(renderedFills) : renderedFills\n });\n}\nexport default Slot;"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB,QAAQ,UAAU,cAAc,sBAAsB;AAK5F,OAAO,qBAAqB;AAC5B,SAAS,YAAY,WAAW,OAAO,YAAY;AAOnD,SAAS,WAAW,WAAW;AAC7B,SAAO,OAAO,cAAc;AAC9B;AACA,SAAS,kBAAkB,UAAU;AACnC,SAAO,SAAS,IAAI,UAAU,CAAC,OAAO,eAAe;AACnD,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,aAAO;AAAA,IACT;AACA,QAAI,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;
|
|
16
15
|
const {
|
|
17
16
|
store,
|
|
18
17
|
instanceId
|
|
19
|
-
} =
|
|
18
|
+
} = useTabsContext() ?? {};
|
|
20
19
|
if (!store) {
|
|
21
20
|
globalThis.SCRIPT_DEBUG === true ? warning("`Tabs.Tab` must be wrapped in a `Tabs` component.") : void 0;
|
|
22
21
|
return null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tabs/tab.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\n\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport warning from '@wordpress/warning';\nimport { useTabsContext } from './context';\nimport { Tab as StyledTab, TabChildren as StyledTabChildren, TabChevron as StyledTabChevron } from './styles';\nimport { chevronRight } from '@wordpress/icons';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const Tab = forwardRef(function Tab({\n children,\n tabId,\n disabled,\n render,\n ...otherProps\n}, ref) {\n
|
|
5
|
-
"mappings": ";AAIA,SAAS,kBAAkB;AAM3B,OAAO,aAAa;AACpB,SAAS,sBAAsB;AAC/B,SAAS,OAAO,WAAW,eAAe,mBAAmB,cAAc,wBAAwB;AACnG,SAAS,oBAAoB;AAC7B,SAAS,OAAO,MAAM,QAAQ,aAAa;AACpC,IAAM,MAAM,WAAW,SAASA,KAAI;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\n\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport warning from '@wordpress/warning';\nimport { useTabsContext } from './context';\nimport { Tab as StyledTab, TabChildren as StyledTabChildren, TabChevron as StyledTabChevron } from './styles';\nimport { chevronRight } from '@wordpress/icons';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const Tab = forwardRef(function Tab({\n children,\n tabId,\n disabled,\n render,\n ...otherProps\n}, ref) {\n const {\n store,\n instanceId\n } = useTabsContext() ?? {};\n if (!store) {\n globalThis.SCRIPT_DEBUG === true ? warning('`Tabs.Tab` must be wrapped in a `Tabs` component.') : void 0;\n return null;\n }\n const instancedTabId = `${instanceId}-${tabId}`;\n return /*#__PURE__*/_jsxs(StyledTab, {\n ref: ref,\n store: store,\n id: instancedTabId,\n disabled: disabled,\n render: render,\n ...otherProps,\n children: [/*#__PURE__*/_jsx(StyledTabChildren, {\n children: children\n }), /*#__PURE__*/_jsx(StyledTabChevron, {\n icon: chevronRight\n })]\n });\n});"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,kBAAkB;AAM3B,OAAO,aAAa;AACpB,SAAS,sBAAsB;AAC/B,SAAS,OAAO,WAAW,eAAe,mBAAmB,cAAc,wBAAwB;AACnG,SAAS,oBAAoB;AAC7B,SAAS,OAAO,MAAM,QAAQ,aAAa;AACpC,IAAM,MAAM,WAAW,SAASA,KAAI;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI,eAAe,KAAK,CAAC;AACzB,MAAI,CAAC,OAAO;AACV,eAAW,iBAAiB,OAAO,QAAQ,mDAAmD,IAAI;AAClG,WAAO;AAAA,EACT;AACA,QAAM,iBAAiB,GAAG,UAAU,IAAI,KAAK;AAC7C,SAAoB,sBAAM,WAAW;AAAA,IACnC;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,UAAU,CAAc,qBAAK,mBAAmB;AAAA,MAC9C;AAAA,IACF,CAAC,GAAgB,qBAAK,kBAAkB;AAAA,MACtC,MAAM;AAAA,IACR,CAAC,CAAC;AAAA,EACJ,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": ["Tab"]
|
|
7
7
|
}
|
|
@@ -47,10 +47,9 @@ var TabList = forwardRef(function TabList2({
|
|
|
47
47
|
children,
|
|
48
48
|
...otherProps
|
|
49
49
|
}, ref) {
|
|
50
|
-
var _useTabsContext;
|
|
51
50
|
const {
|
|
52
51
|
store
|
|
53
|
-
} =
|
|
52
|
+
} = useTabsContext() ?? {};
|
|
54
53
|
const selectedId = Ariakit.useStoreState(store, "selectedId");
|
|
55
54
|
const activeId = Ariakit.useStoreState(store, "activeId");
|
|
56
55
|
const selectOnMove = Ariakit.useStoreState(store, "selectOnMove");
|
|
@@ -87,15 +86,12 @@ var TabList = forwardRef(function TabList2({
|
|
|
87
86
|
return /* @__PURE__ */ _jsx(StyledTabList, {
|
|
88
87
|
ref: refs,
|
|
89
88
|
store,
|
|
90
|
-
render: (props) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
tabIndex: (_props$tabIndex = props.tabIndex) !== null && _props$tabIndex !== void 0 ? _props$tabIndex : -1
|
|
97
|
-
});
|
|
98
|
-
},
|
|
89
|
+
render: (props) => /* @__PURE__ */ _jsx("div", {
|
|
90
|
+
...props,
|
|
91
|
+
// Fallback to -1 to prevent browsers from making the tablist
|
|
92
|
+
// tabbable when it is a scrolling container.
|
|
93
|
+
tabIndex: props.tabIndex ?? -1
|
|
94
|
+
}),
|
|
99
95
|
onBlur,
|
|
100
96
|
"data-select-on-move": selectOnMove ? "true" : "false",
|
|
101
97
|
...otherProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tabs/tablist.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef, useLayoutEffect, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\n\nimport { useTabsContext } from './context';\nimport { StyledTabList } from './styles';\nimport { useTrackElementOffsetRect } from '../utils/element-rect';\nimport { useTrackOverflow } from './use-track-overflow';\nimport { useAnimatedOffsetRect } from '../utils/hooks/use-animated-offset-rect';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst DEFAULT_SCROLL_MARGIN = 24;\n\n/**\n * Scrolls a given parent element so that a given rect is visible.\n *\n * The scroll is updated initially and whenever the rect changes.\n */\nfunction useScrollRectIntoView(parent, rect, {\n margin = DEFAULT_SCROLL_MARGIN\n} = {}) {\n useLayoutEffect(() => {\n if (!parent || !rect) {\n return;\n }\n const {\n scrollLeft: parentScroll\n } = parent;\n const parentWidth = parent.getBoundingClientRect().width;\n const {\n left: childLeft,\n width: childWidth\n } = rect;\n const parentRightEdge = parentScroll + parentWidth;\n const childRightEdge = childLeft + childWidth;\n const rightOverflow = childRightEdge + margin - parentRightEdge;\n const leftOverflow = parentScroll - (childLeft - margin);\n let scrollLeft = null;\n if (leftOverflow > 0) {\n scrollLeft = parentScroll - leftOverflow;\n } else if (rightOverflow > 0) {\n scrollLeft = parentScroll + rightOverflow;\n }\n if (scrollLeft !== null) {\n /**\n * The optional chaining is used here to avoid unit test failures.\n * It can be removed when JSDOM supports `Element` scroll methods.\n * See: https://github.com/WordPress/gutenberg/pull/66498#issuecomment-2441146096\n */\n parent.scroll?.({\n left: scrollLeft\n });\n }\n }, [margin, parent, rect]);\n}\nexport const TabList = forwardRef(function TabList({\n children,\n ...otherProps\n}, ref) {\n
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,OAAO,aAAa;AACpB,SAAS,YAAY,iBAAiB,gBAAgB;AACtD,SAAS,oBAAoB;AAM7B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,OAAO,YAAY;AAC5B,IAAM,wBAAwB;AAO9B,SAAS,sBAAsB,QAAQ,MAAM;AAAA,EAC3C,SAAS;AACX,IAAI,CAAC,GAAG;AACN,kBAAgB,MAAM;AACpB,QAAI,CAAC,UAAU,CAAC,MAAM;AACpB;AAAA,IACF;AACA,UAAM;AAAA,MACJ,YAAY;AAAA,IACd,IAAI;AACJ,UAAM,cAAc,OAAO,sBAAsB,EAAE;AACnD,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,IACT,IAAI;AACJ,UAAM,kBAAkB,eAAe;AACvC,UAAM,iBAAiB,YAAY;AACnC,UAAM,gBAAgB,iBAAiB,SAAS;AAChD,UAAM,eAAe,gBAAgB,YAAY;AACjD,QAAI,aAAa;AACjB,QAAI,eAAe,GAAG;AACpB,mBAAa,eAAe;AAAA,IAC9B,WAAW,gBAAgB,GAAG;AAC5B,mBAAa,eAAe;AAAA,IAC9B;AACA,QAAI,eAAe,MAAM;AAMvB,aAAO,SAAS;AAAA,QACd,MAAM;AAAA,MACR,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,IAAI,CAAC;AAC3B;AACO,IAAM,UAAU,WAAW,SAASA,SAAQ;AAAA,EACjD;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef, useLayoutEffect, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\n\nimport { useTabsContext } from './context';\nimport { StyledTabList } from './styles';\nimport { useTrackElementOffsetRect } from '../utils/element-rect';\nimport { useTrackOverflow } from './use-track-overflow';\nimport { useAnimatedOffsetRect } from '../utils/hooks/use-animated-offset-rect';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst DEFAULT_SCROLL_MARGIN = 24;\n\n/**\n * Scrolls a given parent element so that a given rect is visible.\n *\n * The scroll is updated initially and whenever the rect changes.\n */\nfunction useScrollRectIntoView(parent, rect, {\n margin = DEFAULT_SCROLL_MARGIN\n} = {}) {\n useLayoutEffect(() => {\n if (!parent || !rect) {\n return;\n }\n const {\n scrollLeft: parentScroll\n } = parent;\n const parentWidth = parent.getBoundingClientRect().width;\n const {\n left: childLeft,\n width: childWidth\n } = rect;\n const parentRightEdge = parentScroll + parentWidth;\n const childRightEdge = childLeft + childWidth;\n const rightOverflow = childRightEdge + margin - parentRightEdge;\n const leftOverflow = parentScroll - (childLeft - margin);\n let scrollLeft = null;\n if (leftOverflow > 0) {\n scrollLeft = parentScroll - leftOverflow;\n } else if (rightOverflow > 0) {\n scrollLeft = parentScroll + rightOverflow;\n }\n if (scrollLeft !== null) {\n /**\n * The optional chaining is used here to avoid unit test failures.\n * It can be removed when JSDOM supports `Element` scroll methods.\n * See: https://github.com/WordPress/gutenberg/pull/66498#issuecomment-2441146096\n */\n parent.scroll?.({\n left: scrollLeft\n });\n }\n }, [margin, parent, rect]);\n}\nexport const TabList = forwardRef(function TabList({\n children,\n ...otherProps\n}, ref) {\n const {\n store\n } = useTabsContext() ?? {};\n const selectedId = Ariakit.useStoreState(store, 'selectedId');\n const activeId = Ariakit.useStoreState(store, 'activeId');\n const selectOnMove = Ariakit.useStoreState(store, 'selectOnMove');\n const items = Ariakit.useStoreState(store, 'items');\n const [parent, setParent] = useState();\n const refs = useMergeRefs([ref, setParent]);\n const selectedItem = store?.item(selectedId);\n const renderedItems = Ariakit.useStoreState(store, 'renderedItems');\n const selectedItemIndex = renderedItems && selectedItem ? renderedItems.indexOf(selectedItem) : -1;\n // Use selectedItemIndex as a dependency to force recalculation when the\n // selected item index changes (elements are swapped / added / removed).\n const selectedRect = useTrackElementOffsetRect(selectedItem?.element, [selectedItemIndex]);\n\n // Track overflow to show scroll hints.\n const overflow = useTrackOverflow(parent, {\n first: items?.at(0)?.element,\n last: items?.at(-1)?.element\n });\n\n // Size, position, and animate the indicator.\n useAnimatedOffsetRect(parent, selectedRect, {\n prefix: 'selected',\n dataAttribute: 'indicator-animated',\n transitionEndFilter: event => event.pseudoElement === '::before',\n roundRect: true\n });\n\n // Make sure selected tab is scrolled into view.\n useScrollRectIntoView(parent, selectedRect);\n const onBlur = () => {\n if (!selectOnMove) {\n return;\n }\n\n // When automatic tab selection is on, make sure that the active tab is up\n // to date with the selected tab when leaving the tablist. This makes sure\n // that the selected tab will receive keyboard focus when tabbing back into\n // the tablist.\n if (selectedId !== activeId) {\n store?.setActiveId(selectedId);\n }\n };\n if (!store) {\n globalThis.SCRIPT_DEBUG === true ? warning('`Tabs.TabList` must be wrapped in a `Tabs` component.') : void 0;\n return null;\n }\n return /*#__PURE__*/_jsx(StyledTabList, {\n ref: refs,\n store: store,\n render: props => /*#__PURE__*/_jsx(\"div\", {\n ...props,\n // Fallback to -1 to prevent browsers from making the tablist\n // tabbable when it is a scrolling container.\n tabIndex: props.tabIndex ?? -1\n }),\n onBlur: onBlur,\n \"data-select-on-move\": selectOnMove ? 'true' : 'false',\n ...otherProps,\n className: clsx(overflow.first && 'is-overflowing-first', overflow.last && 'is-overflowing-last', otherProps.className),\n children: children\n });\n});"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,OAAO,aAAa;AACpB,SAAS,YAAY,iBAAiB,gBAAgB;AACtD,SAAS,oBAAoB;AAM7B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,OAAO,YAAY;AAC5B,IAAM,wBAAwB;AAO9B,SAAS,sBAAsB,QAAQ,MAAM;AAAA,EAC3C,SAAS;AACX,IAAI,CAAC,GAAG;AACN,kBAAgB,MAAM;AACpB,QAAI,CAAC,UAAU,CAAC,MAAM;AACpB;AAAA,IACF;AACA,UAAM;AAAA,MACJ,YAA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AC;AAGD,wBAAsB,QAAQ,cAAc;AAAA,IAC1C,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,qBAAqB,WAAS,MAAM,kBAAkB;AAAA,IACtD,WAAW;AAAA,EACb,CAAC;AAGD,wBAAsB,QAAQ,YAAY;AAC1C,QAAM,SAAS,MAAM;AACnB,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AAMA,QAAI,eAAe,UAAU;AAC3B,aAAO,YAAY,UAAU;AAAA,IAC/B;AAAA,EACF;AACA,MAAI,CAAC,OAAO;AACV,eAAW,iBAAiB,OAAO,QAAQ,uDAAuD,IAAI;AACtG,WAAO;AAAA,EACT;AACA,SAAoB,qBAAK,eAAe;AAAA,IACtC,KAAK;AAAA,IACL;AAAA,IACA,QAAQ,WAAsB,qBAAK,OAAO;AAAA,MACxC,GAAG;AAAA;AAAA;AAAA,MAGH,UAAU,MAAM,YAAY;AAAA,IAC9B,CAAC;AAAA,IACD;AAAA,IACA,uBAAuB,eAAe,SAAS;AAAA,IAC/C,GAAG;AAAA,IACH,WAAW,KAAK,SAAS,SAAS,wBAAwB,SAAS,QAAQ,uBAAuB,WAAW,SAAS;AAAA,IACtH;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": ["TabList"]
|
|
7
7
|
}
|
|
@@ -25,7 +25,7 @@ function UnforwardedToggleGroupControlAsRadioGroup({
|
|
|
25
25
|
defaultValue
|
|
26
26
|
} = useComputeControlledOrUncontrolledValue(valueProp);
|
|
27
27
|
const wrappedOnChangeProp = onChangeProp ? (v) => {
|
|
28
|
-
onChangeProp(v
|
|
28
|
+
onChangeProp(v ?? void 0);
|
|
29
29
|
} : void 0;
|
|
30
30
|
const radio = Ariakit.useRadioStore({
|
|
31
31
|
defaultValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/toggle-group-control/toggle-group-control/as-radio-group.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useEffect, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { View } from '../../view';\nimport ToggleGroupControlContext from '../context';\nimport { useComputeControlledOrUncontrolledValue } from './utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedToggleGroupControlAsRadioGroup({\n children,\n isAdaptiveWidth,\n label,\n onChange: onChangeProp,\n size,\n value: valueProp,\n id: idProp,\n setSelectedElement,\n ...otherProps\n}, forwardedRef) {\n const generatedId = useInstanceId(ToggleGroupControlAsRadioGroup, 'toggle-group-control-as-radio-group');\n const baseId = idProp || generatedId;\n\n // Use a heuristic to understand if the component is being used in controlled\n // or uncontrolled mode, and consequently:\n // - when controlled, convert `undefined` values to `''` (ie. \"no value\")\n // - use the `value` prop as the `defaultValue` when uncontrolled\n const {\n value,\n defaultValue\n } = useComputeControlledOrUncontrolledValue(valueProp);\n\n // `useRadioStore`'s `setValue` prop can be called with `null`, while\n // the component's `onChange` prop only expects `undefined`\n const wrappedOnChangeProp = onChangeProp ? v => {\n onChangeProp(v
|
|
5
|
-
"mappings": ";AAIA,YAAY,aAAa;AAKzB,SAAS,qBAAqB;AAC9B,SAAS,YAAY,WAAW,eAAe;AAC/C,SAAS,aAAa;AAKtB,SAAS,YAAY;AACrB,OAAO,+BAA+B;AACtC,SAAS,+CAA+C;AACxD,SAAS,OAAO,YAAY;AAC5B,SAAS,0CAA0C;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,OAAO;AAAA,EACP,IAAI;AAAA,EACJ;AAAA,EACA,GAAG;AACL,GAAG,cAAc;AACf,QAAM,cAAc,cAAc,gCAAgC,qCAAqC;AACvG,QAAM,SAAS,UAAU;AAMzB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI,wCAAwC,SAAS;AAIrD,QAAM,sBAAsB,eAAe,OAAK;AAC9C,iBAAa,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useEffect, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { View } from '../../view';\nimport ToggleGroupControlContext from '../context';\nimport { useComputeControlledOrUncontrolledValue } from './utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedToggleGroupControlAsRadioGroup({\n children,\n isAdaptiveWidth,\n label,\n onChange: onChangeProp,\n size,\n value: valueProp,\n id: idProp,\n setSelectedElement,\n ...otherProps\n}, forwardedRef) {\n const generatedId = useInstanceId(ToggleGroupControlAsRadioGroup, 'toggle-group-control-as-radio-group');\n const baseId = idProp || generatedId;\n\n // Use a heuristic to understand if the component is being used in controlled\n // or uncontrolled mode, and consequently:\n // - when controlled, convert `undefined` values to `''` (ie. \"no value\")\n // - use the `value` prop as the `defaultValue` when uncontrolled\n const {\n value,\n defaultValue\n } = useComputeControlledOrUncontrolledValue(valueProp);\n\n // `useRadioStore`'s `setValue` prop can be called with `null`, while\n // the component's `onChange` prop only expects `undefined`\n const wrappedOnChangeProp = onChangeProp ? v => {\n onChangeProp(v ?? undefined);\n } : undefined;\n const radio = Ariakit.useRadioStore({\n defaultValue,\n value,\n setValue: wrappedOnChangeProp,\n rtl: isRTL()\n });\n const selectedValue = Ariakit.useStoreState(radio, 'value');\n const setValue = radio.setValue;\n\n // Ensures that the active id is also reset after the value is \"reset\" by the consumer.\n useEffect(() => {\n if (selectedValue === '') {\n radio.setActiveId(undefined);\n }\n }, [radio, selectedValue]);\n const groupContextValue = useMemo(() => ({\n activeItemIsNotFirstItem: () => radio.getState().activeId !== radio.first(),\n baseId,\n isBlock: !isAdaptiveWidth,\n size,\n // @ts-expect-error - This is wrong and we should fix it.\n value: selectedValue,\n // @ts-expect-error - This is wrong and we should fix it.\n setValue,\n setSelectedElement\n }), [baseId, isAdaptiveWidth, radio, selectedValue, setSelectedElement, setValue, size]);\n return /*#__PURE__*/_jsx(ToggleGroupControlContext.Provider, {\n value: groupContextValue,\n children: /*#__PURE__*/_jsx(Ariakit.RadioGroup, {\n store: radio,\n \"aria-label\": label,\n render: /*#__PURE__*/_jsx(View, {}),\n ...otherProps,\n id: baseId,\n ref: forwardedRef,\n children: children\n })\n });\n}\nexport const ToggleGroupControlAsRadioGroup = forwardRef(UnforwardedToggleGroupControlAsRadioGroup);\nToggleGroupControlAsRadioGroup.displayName = 'ToggleGroupControlAsRadioGroup';"],
|
|
5
|
+
"mappings": ";AAIA,YAAY,aAAa;AAKzB,SAAS,qBAAqB;AAC9B,SAAS,YAAY,WAAW,eAAe;AAC/C,SAAS,aAAa;AAKtB,SAAS,YAAY;AACrB,OAAO,+BAA+B;AACtC,SAAS,+CAA+C;AACxD,SAAS,OAAO,YAAY;AAC5B,SAAS,0CAA0C;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,OAAO;AAAA,EACP,IAAI;AAAA,EACJ;AAAA,EACA,GAAG;AACL,GAAG,cAAc;AACf,QAAM,cAAc,cAAc,gCAAgC,qCAAqC;AACvG,QAAM,SAAS,UAAU;AAMzB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI,wCAAwC,SAAS;AAIrD,QAAM,sBAAsB,eAAe,OAAK;AAC9C,iBAAa,KAAK,MAAS;AAAA,EAC7B,IAAI;AACJ,QAAM,QAAgB,sBAAc;AAAA,IAClC;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,KAAK,MAAM;AAAA,EACb,CAAC;AACD,QAAM,gBAAwB,sBAAc,OAAO,OAAO;AAC1D,QAAM,WAAW,MAAM;AAGvB,YAAU,MAAM;AAC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