@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/toggle-group-control/toggle-group-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\n/**\n * Used to determine, via an internal heuristics, whether an `undefined` value\n * received for the `value` prop should be interpreted as the component being\n * used in uncontrolled mode, or as an \"empty\" value for controlled mode.\n *\n * @param valueProp The received `value`\n */\nexport function useComputeControlledOrUncontrolledValue(valueProp) {\n const isInitialRenderRef = useRef(true);\n const prevValueProp = usePrevious(valueProp);\n const prevIsControlledRef = useRef(false);\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n }\n }, []);\n\n // Assume the component is being used in controlled mode on the first re-render\n // that has a different `valueProp` from the previous render.\n const isControlled = prevIsControlledRef.current || !isInitialRenderRef.current && prevValueProp !== valueProp;\n useEffect(() => {\n prevIsControlledRef.current = isControlled;\n }, [isControlled]);\n if (isControlled) {\n // When in controlled mode, use `''` instead of `undefined`\n return {\n value: valueProp
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,WAAW,cAAc;AAa3B,SAAS,wCAAwC,WAAW;AACjE,QAAM,qBAAqB,OAAO,IAAI;AACtC,QAAM,gBAAgB,YAAY,SAAS;AAC3C,QAAM,sBAAsB,OAAO,KAAK;AACxC,YAAU,MAAM;AACd,QAAI,mBAAmB,SAAS;AAC9B,yBAAmB,UAAU;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,CAAC;AAIL,QAAM,eAAe,oBAAoB,WAAW,CAAC,mBAAmB,WAAW,kBAAkB;AACrG,YAAU,MAAM;AACd,wBAAoB,UAAU;AAAA,EAChC,GAAG,CAAC,YAAY,CAAC;AACjB,MAAI,cAAc;AAEhB,WAAO;AAAA,MACL,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\n/**\n * Used to determine, via an internal heuristics, whether an `undefined` value\n * received for the `value` prop should be interpreted as the component being\n * used in uncontrolled mode, or as an \"empty\" value for controlled mode.\n *\n * @param valueProp The received `value`\n */\nexport function useComputeControlledOrUncontrolledValue(valueProp) {\n const isInitialRenderRef = useRef(true);\n const prevValueProp = usePrevious(valueProp);\n const prevIsControlledRef = useRef(false);\n useEffect(() => {\n if (isInitialRenderRef.current) {\n isInitialRenderRef.current = false;\n }\n }, []);\n\n // Assume the component is being used in controlled mode on the first re-render\n // that has a different `valueProp` from the previous render.\n const isControlled = prevIsControlledRef.current || !isInitialRenderRef.current && prevValueProp !== valueProp;\n useEffect(() => {\n prevIsControlledRef.current = isControlled;\n }, [isControlled]);\n if (isControlled) {\n // When in controlled mode, use `''` instead of `undefined`\n return {\n value: valueProp ?? '',\n defaultValue: undefined\n };\n }\n\n // When in uncontrolled mode, the `value` should be intended as the initial value\n return {\n value: undefined,\n defaultValue: valueProp\n };\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,WAAW,cAAc;AAa3B,SAAS,wCAAwC,WAAW;AACjE,QAAM,qBAAqB,OAAO,IAAI;AACtC,QAAM,gBAAgB,YAAY,SAAS;AAC3C,QAAM,sBAAsB,OAAO,KAAK;AACxC,YAAU,MAAM;AACd,QAAI,mBAAmB,SAAS;AAC9B,yBAAmB,UAAU;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,CAAC;AAIL,QAAM,eAAe,oBAAoB,WAAW,CAAC,mBAAmB,WAAW,kBAAkB;AACrG,YAAU,MAAM;AACd,wBAAoB,UAAU;AAAA,EAChC,GAAG,CAAC,YAAY,CAAC;AACjB,MAAI,cAAc;AAEhB,WAAO;AAAA,MACL,OAAO,aAAa;AAAA,MACpB,cAAc;AAAA,IAChB;AAAA,EACF;AAGA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -64,13 +64,12 @@ function UnforwardedTreeGrid({
|
|
|
64
64
|
}
|
|
65
65
|
if (canExpandCollapse) {
|
|
66
66
|
if (keyCode === LEFT) {
|
|
67
|
-
var _activeRow$getAttribu;
|
|
68
67
|
if (activeRow.getAttribute("data-expanded") === "true" || activeRow.getAttribute("aria-expanded") === "true") {
|
|
69
68
|
onCollapseRow(activeRow);
|
|
70
69
|
event.preventDefault();
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
|
-
const level = Math.max(parseInt(
|
|
72
|
+
const level = Math.max(parseInt(activeRow?.getAttribute("aria-level") ?? "1", 10) - 1, 1);
|
|
74
73
|
const rows = Array.from(treeGridElement.querySelectorAll('[role="row"]'));
|
|
75
74
|
let parentRow = activeRow;
|
|
76
75
|
const currentRowIndex = rows.indexOf(activeRow);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tree-grid/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { forwardRef, useCallback } from '@wordpress/element';\nimport { UP, DOWN, LEFT, RIGHT, HOME, END } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexContainer from './roving-tab-index';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Return focusables in a row element, excluding those from other branches\n * nested within the row.\n *\n * @param rowElement The DOM element representing the row.\n *\n * @return The array of focusables in the row.\n */\nfunction getRowFocusables(rowElement) {\n const focusablesInRow = focus.focusable.find(rowElement, {\n sequential: true\n });\n return focusablesInRow.filter(focusable => {\n return focusable.closest('[role=\"row\"]') === rowElement;\n });\n}\n\n/**\n * Renders both a table and tbody element, used to create a tree hierarchy.\n *\n */\nfunction UnforwardedTreeGrid({\n children,\n onExpandRow = () => {},\n onCollapseRow = () => {},\n onFocusRow = () => {},\n applicationAriaLabel,\n ...props\n}, /** A ref to the underlying DOM table element. */\nref) {\n const onKeyDown = useCallback(event => {\n const {\n keyCode,\n metaKey,\n ctrlKey,\n altKey\n } = event;\n\n // The shift key is intentionally absent from the following list,\n // to enable shift + up/down to select items from the list.\n const hasModifierKeyPressed = metaKey || ctrlKey || altKey;\n if (hasModifierKeyPressed || ![UP, DOWN, LEFT, RIGHT, HOME, END].includes(keyCode)) {\n return;\n }\n\n // The event will be handled, stop propagation.\n event.stopPropagation();\n const {\n activeElement\n } = document;\n const {\n currentTarget: treeGridElement\n } = event;\n if (!activeElement || !treeGridElement.contains(activeElement)) {\n return;\n }\n\n // Calculate the columnIndex of the active element.\n const activeRow = activeElement.closest('[role=\"row\"]');\n if (!activeRow) {\n return;\n }\n const focusablesInRow = getRowFocusables(activeRow);\n const currentColumnIndex = focusablesInRow.indexOf(activeElement);\n const canExpandCollapse = 0 === currentColumnIndex;\n const cannotFocusNextColumn = canExpandCollapse && (activeRow.getAttribute('data-expanded') === 'false' || activeRow.getAttribute('aria-expanded') === 'false') && keyCode === RIGHT;\n if ([LEFT, RIGHT].includes(keyCode)) {\n // Calculate to the next element.\n let nextIndex;\n if (keyCode === LEFT) {\n nextIndex = Math.max(0, currentColumnIndex - 1);\n } else {\n nextIndex = Math.min(currentColumnIndex + 1, focusablesInRow.length - 1);\n }\n\n // Focus is at the left most column.\n if (canExpandCollapse) {\n if (keyCode === LEFT) {\n var _activeRow$getAttribu;\n // Left:\n // If a row is focused, and it is expanded, collapses the current row.\n if (activeRow.getAttribute('data-expanded') === 'true' || activeRow.getAttribute('aria-expanded') === 'true') {\n onCollapseRow(activeRow);\n event.preventDefault();\n return;\n }\n // If a row is focused, and it is collapsed, moves to the parent row (if there is one).\n const level = Math.max(parseInt((_activeRow$getAttribu = activeRow?.getAttribute('aria-level')) !== null && _activeRow$getAttribu !== void 0 ? _activeRow$getAttribu : '1', 10) - 1, 1);\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n let parentRow = activeRow;\n const currentRowIndex = rows.indexOf(activeRow);\n for (let i = currentRowIndex; i >= 0; i--) {\n const ariaLevel = rows[i].getAttribute('aria-level');\n if (ariaLevel !== null && parseInt(ariaLevel, 10) === level) {\n parentRow = rows[i];\n break;\n }\n }\n getRowFocusables(parentRow)?.[0]?.focus();\n }\n if (keyCode === RIGHT) {\n // Right:\n // If a row is focused, and it is collapsed, expands the current row.\n if (activeRow.getAttribute('data-expanded') === 'false' || activeRow.getAttribute('aria-expanded') === 'false') {\n onExpandRow(activeRow);\n event.preventDefault();\n return;\n }\n // If a row is focused, and it is expanded, focuses the next cell in the row.\n const focusableItems = getRowFocusables(activeRow);\n if (focusableItems.length > 0) {\n focusableItems[nextIndex]?.focus();\n }\n }\n // Prevent key use for anything else. For example, Voiceover\n // will start reading text on continued use of left/right arrow\n // keys.\n event.preventDefault();\n return;\n }\n\n // Focus the next element. If at most left column and row is collapsed, moving right is not allowed as this will expand. However, if row is collapsed, moving left is allowed.\n if (cannotFocusNextColumn) {\n return;\n }\n focusablesInRow[nextIndex].focus();\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n } else if ([UP, DOWN].includes(keyCode)) {\n // Calculate the rowIndex of the next row.\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n const currentRowIndex = rows.indexOf(activeRow);\n let nextRowIndex;\n if (keyCode === UP) {\n nextRowIndex = Math.max(0, currentRowIndex - 1);\n } else {\n nextRowIndex = Math.min(currentRowIndex + 1, rows.length - 1);\n }\n\n // Focus is either at the top or bottom edge of the grid. Do nothing.\n if (nextRowIndex === currentRowIndex) {\n // Prevent key use for anything else. For example, Voiceover\n // will start navigating horizontally when reaching the vertical\n // bounds of a table.\n event.preventDefault();\n return;\n }\n\n // Get the focusables in the next row.\n const focusablesInNextRow = getRowFocusables(rows[nextRowIndex]);\n\n // If for some reason there are no focusables in the next row, do nothing.\n if (!focusablesInNextRow || !focusablesInNextRow.length) {\n // Prevent key use for anything else. For example, Voiceover\n // will still focus text when using arrow keys, while this\n // component should limit navigation to focusables.\n event.preventDefault();\n return;\n }\n\n // Try to focus the element in the next row that's at a similar column to the activeElement.\n const nextIndex = Math.min(currentColumnIndex, focusablesInNextRow.length - 1);\n focusablesInNextRow[nextIndex].focus();\n\n // Let consumers know the row that was originally focused,\n // and the row that is now in focus.\n onFocusRow(event, activeRow, rows[nextRowIndex]);\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n } else if ([HOME, END].includes(keyCode)) {\n // Calculate the rowIndex of the next row.\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n const currentRowIndex = rows.indexOf(activeRow);\n let nextRowIndex;\n if (keyCode === HOME) {\n nextRowIndex = 0;\n } else {\n nextRowIndex = rows.length - 1;\n }\n\n // Focus is either at the top or bottom edge of the grid. Do nothing.\n if (nextRowIndex === currentRowIndex) {\n // Prevent key use for anything else. For example, Voiceover\n // will start navigating horizontally when reaching the vertical\n // bounds of a table.\n event.preventDefault();\n return;\n }\n\n // Get the focusables in the next row.\n const focusablesInNextRow = getRowFocusables(rows[nextRowIndex]);\n\n // If for some reason there are no focusables in the next row, do nothing.\n if (!focusablesInNextRow || !focusablesInNextRow.length) {\n // Prevent key use for anything else. For example, Voiceover\n // will still focus text when using arrow keys, while this\n // component should limit navigation to focusables.\n event.preventDefault();\n return;\n }\n\n // Try to focus the element in the next row that's at a similar column to the activeElement.\n const nextIndex = Math.min(currentColumnIndex, focusablesInNextRow.length - 1);\n focusablesInNextRow[nextIndex].focus();\n\n // Let consumers know the row that was originally focused,\n // and the row that is now in focus.\n onFocusRow(event, activeRow, rows[nextRowIndex]);\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n }\n }, [onExpandRow, onCollapseRow, onFocusRow]);\n\n /* Disable reason: A treegrid is implemented using a table element. */\n /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n return /*#__PURE__*/_jsx(RovingTabIndexContainer, {\n children: /*#__PURE__*/_jsx(\"div\", {\n role: \"application\",\n \"aria-label\": applicationAriaLabel,\n children: /*#__PURE__*/_jsx(\"table\", {\n ...props,\n role: \"treegrid\",\n onKeyDown: onKeyDown,\n ref: ref,\n children: /*#__PURE__*/_jsx(\"tbody\", {\n children: children\n })\n })\n })\n });\n /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\n/**\n * `TreeGrid` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * A tree grid is a hierarchical 2 dimensional UI component, for example it could be\n * used to implement a file system browser.\n *\n * A tree grid allows the user to navigate using arrow keys.\n * Up/down to navigate vertically across rows, and left/right to navigate horizontally\n * between focusables in a row.\n *\n * The `TreeGrid` renders both a `table` and `tbody` element, and is intended to be used\n * with `TreeGridRow` (`tr`) and `TreeGridCell` (`td`) to build out a grid.\n *\n * ```jsx\n * function TreeMenu() {\n * \treturn (\n * \t\t<TreeGrid>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 1 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 2 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 2 } positionInSet={ 1 } setSize={ 1 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t</TreeGrid>\n * \t);\n * }\n * ```\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGrid = forwardRef(UnforwardedTreeGrid);\nTreeGrid.displayName = 'TreeGrid';\nexport default TreeGrid;\nexport { default as TreeGridRow } from './row';\nexport { default as TreeGridCell } from './cell';\nexport { default as TreeGridItem } from './item';"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,YAAY,mBAAmB;AACxC,SAAS,IAAI,MAAM,MAAM,OAAO,MAAM,WAAW;AAKjD,OAAO,6BAA6B;AACpC,SAAS,OAAO,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { forwardRef, useCallback } from '@wordpress/element';\nimport { UP, DOWN, LEFT, RIGHT, HOME, END } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexContainer from './roving-tab-index';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Return focusables in a row element, excluding those from other branches\n * nested within the row.\n *\n * @param rowElement The DOM element representing the row.\n *\n * @return The array of focusables in the row.\n */\nfunction getRowFocusables(rowElement) {\n const focusablesInRow = focus.focusable.find(rowElement, {\n sequential: true\n });\n return focusablesInRow.filter(focusable => {\n return focusable.closest('[role=\"row\"]') === rowElement;\n });\n}\n\n/**\n * Renders both a table and tbody element, used to create a tree hierarchy.\n *\n */\nfunction UnforwardedTreeGrid({\n children,\n onExpandRow = () => {},\n onCollapseRow = () => {},\n onFocusRow = () => {},\n applicationAriaLabel,\n ...props\n}, /** A ref to the underlying DOM table element. */\nref) {\n const onKeyDown = useCallback(event => {\n const {\n keyCode,\n metaKey,\n ctrlKey,\n altKey\n } = event;\n\n // The shift key is intentionally absent from the following list,\n // to enable shift + up/down to select items from the list.\n const hasModifierKeyPressed = metaKey || ctrlKey || altKey;\n if (hasModifierKeyPressed || ![UP, DOWN, LEFT, RIGHT, HOME, END].includes(keyCode)) {\n return;\n }\n\n // The event will be handled, stop propagation.\n event.stopPropagation();\n const {\n activeElement\n } = document;\n const {\n currentTarget: treeGridElement\n } = event;\n if (!activeElement || !treeGridElement.contains(activeElement)) {\n return;\n }\n\n // Calculate the columnIndex of the active element.\n const activeRow = activeElement.closest('[role=\"row\"]');\n if (!activeRow) {\n return;\n }\n const focusablesInRow = getRowFocusables(activeRow);\n const currentColumnIndex = focusablesInRow.indexOf(activeElement);\n const canExpandCollapse = 0 === currentColumnIndex;\n const cannotFocusNextColumn = canExpandCollapse && (activeRow.getAttribute('data-expanded') === 'false' || activeRow.getAttribute('aria-expanded') === 'false') && keyCode === RIGHT;\n if ([LEFT, RIGHT].includes(keyCode)) {\n // Calculate to the next element.\n let nextIndex;\n if (keyCode === LEFT) {\n nextIndex = Math.max(0, currentColumnIndex - 1);\n } else {\n nextIndex = Math.min(currentColumnIndex + 1, focusablesInRow.length - 1);\n }\n\n // Focus is at the left most column.\n if (canExpandCollapse) {\n if (keyCode === LEFT) {\n // Left:\n // If a row is focused, and it is expanded, collapses the current row.\n if (activeRow.getAttribute('data-expanded') === 'true' || activeRow.getAttribute('aria-expanded') === 'true') {\n onCollapseRow(activeRow);\n event.preventDefault();\n return;\n }\n // If a row is focused, and it is collapsed, moves to the parent row (if there is one).\n const level = Math.max(parseInt(activeRow?.getAttribute('aria-level') ?? '1', 10) - 1, 1);\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n let parentRow = activeRow;\n const currentRowIndex = rows.indexOf(activeRow);\n for (let i = currentRowIndex; i >= 0; i--) {\n const ariaLevel = rows[i].getAttribute('aria-level');\n if (ariaLevel !== null && parseInt(ariaLevel, 10) === level) {\n parentRow = rows[i];\n break;\n }\n }\n getRowFocusables(parentRow)?.[0]?.focus();\n }\n if (keyCode === RIGHT) {\n // Right:\n // If a row is focused, and it is collapsed, expands the current row.\n if (activeRow.getAttribute('data-expanded') === 'false' || activeRow.getAttribute('aria-expanded') === 'false') {\n onExpandRow(activeRow);\n event.preventDefault();\n return;\n }\n // If a row is focused, and it is expanded, focuses the next cell in the row.\n const focusableItems = getRowFocusables(activeRow);\n if (focusableItems.length > 0) {\n focusableItems[nextIndex]?.focus();\n }\n }\n // Prevent key use for anything else. For example, Voiceover\n // will start reading text on continued use of left/right arrow\n // keys.\n event.preventDefault();\n return;\n }\n\n // Focus the next element. If at most left column and row is collapsed, moving right is not allowed as this will expand. However, if row is collapsed, moving left is allowed.\n if (cannotFocusNextColumn) {\n return;\n }\n focusablesInRow[nextIndex].focus();\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n } else if ([UP, DOWN].includes(keyCode)) {\n // Calculate the rowIndex of the next row.\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n const currentRowIndex = rows.indexOf(activeRow);\n let nextRowIndex;\n if (keyCode === UP) {\n nextRowIndex = Math.max(0, currentRowIndex - 1);\n } else {\n nextRowIndex = Math.min(currentRowIndex + 1, rows.length - 1);\n }\n\n // Focus is either at the top or bottom edge of the grid. Do nothing.\n if (nextRowIndex === currentRowIndex) {\n // Prevent key use for anything else. For example, Voiceover\n // will start navigating horizontally when reaching the vertical\n // bounds of a table.\n event.preventDefault();\n return;\n }\n\n // Get the focusables in the next row.\n const focusablesInNextRow = getRowFocusables(rows[nextRowIndex]);\n\n // If for some reason there are no focusables in the next row, do nothing.\n if (!focusablesInNextRow || !focusablesInNextRow.length) {\n // Prevent key use for anything else. For example, Voiceover\n // will still focus text when using arrow keys, while this\n // component should limit navigation to focusables.\n event.preventDefault();\n return;\n }\n\n // Try to focus the element in the next row that's at a similar column to the activeElement.\n const nextIndex = Math.min(currentColumnIndex, focusablesInNextRow.length - 1);\n focusablesInNextRow[nextIndex].focus();\n\n // Let consumers know the row that was originally focused,\n // and the row that is now in focus.\n onFocusRow(event, activeRow, rows[nextRowIndex]);\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n } else if ([HOME, END].includes(keyCode)) {\n // Calculate the rowIndex of the next row.\n const rows = Array.from(treeGridElement.querySelectorAll('[role=\"row\"]'));\n const currentRowIndex = rows.indexOf(activeRow);\n let nextRowIndex;\n if (keyCode === HOME) {\n nextRowIndex = 0;\n } else {\n nextRowIndex = rows.length - 1;\n }\n\n // Focus is either at the top or bottom edge of the grid. Do nothing.\n if (nextRowIndex === currentRowIndex) {\n // Prevent key use for anything else. For example, Voiceover\n // will start navigating horizontally when reaching the vertical\n // bounds of a table.\n event.preventDefault();\n return;\n }\n\n // Get the focusables in the next row.\n const focusablesInNextRow = getRowFocusables(rows[nextRowIndex]);\n\n // If for some reason there are no focusables in the next row, do nothing.\n if (!focusablesInNextRow || !focusablesInNextRow.length) {\n // Prevent key use for anything else. For example, Voiceover\n // will still focus text when using arrow keys, while this\n // component should limit navigation to focusables.\n event.preventDefault();\n return;\n }\n\n // Try to focus the element in the next row that's at a similar column to the activeElement.\n const nextIndex = Math.min(currentColumnIndex, focusablesInNextRow.length - 1);\n focusablesInNextRow[nextIndex].focus();\n\n // Let consumers know the row that was originally focused,\n // and the row that is now in focus.\n onFocusRow(event, activeRow, rows[nextRowIndex]);\n\n // Prevent key use for anything else. This ensures Voiceover\n // doesn't try to handle key navigation.\n event.preventDefault();\n }\n }, [onExpandRow, onCollapseRow, onFocusRow]);\n\n /* Disable reason: A treegrid is implemented using a table element. */\n /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n return /*#__PURE__*/_jsx(RovingTabIndexContainer, {\n children: /*#__PURE__*/_jsx(\"div\", {\n role: \"application\",\n \"aria-label\": applicationAriaLabel,\n children: /*#__PURE__*/_jsx(\"table\", {\n ...props,\n role: \"treegrid\",\n onKeyDown: onKeyDown,\n ref: ref,\n children: /*#__PURE__*/_jsx(\"tbody\", {\n children: children\n })\n })\n })\n });\n /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\n/**\n * `TreeGrid` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * A tree grid is a hierarchical 2 dimensional UI component, for example it could be\n * used to implement a file system browser.\n *\n * A tree grid allows the user to navigate using arrow keys.\n * Up/down to navigate vertically across rows, and left/right to navigate horizontally\n * between focusables in a row.\n *\n * The `TreeGrid` renders both a `table` and `tbody` element, and is intended to be used\n * with `TreeGridRow` (`tr`) and `TreeGridCell` (`td`) to build out a grid.\n *\n * ```jsx\n * function TreeMenu() {\n * \treturn (\n * \t\t<TreeGrid>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 1 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 2 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 2 } positionInSet={ 1 } setSize={ 1 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t</TreeGrid>\n * \t);\n * }\n * ```\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGrid = forwardRef(UnforwardedTreeGrid);\nTreeGrid.displayName = 'TreeGrid';\nexport default TreeGrid;\nexport { default as TreeGridRow } from './row';\nexport { default as TreeGridCell } from './cell';\nexport { default as TreeGridItem } from './item';"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,YAAY,mBAAmB;AACxC,SAAS,IAAI,MAAM,MAAM,OAAO,MAAM,WAAW;AAKjD,OAAO,6BAA6B;AACpC,SAAS,OAAO,YAAY;AAgT5B,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,gBAA+B;AAzSxC,SAAS,iBAAiB,YAAY;AACpC,QAAM,kBAAkB,MAAM,UAAU,KAAK,YAAY;AAAA,IACvD,YAAY;AAAA,EACd,CAAC;AACD,SAAO,gBAAgB,OAAO,eAAa;AACzC,WAAO,UAAU,QAAQ,cAAc,MAAM;AAAA,EAC/C,CAAC;AACH;AAMA,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB;AAAA,EACA,GAAG;AACL,GACA,KAAK;AACH,QAAM,YAAY,YAAY,WAAS;AACrC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA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 -48,7 +48,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
48
48
|
version: "6.2"
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
const nonNullValueProp = valueProp
|
|
51
|
+
const nonNullValueProp = valueProp ?? void 0;
|
|
52
52
|
const [units, reFirstCharacterOfUnits] = useMemo(() => {
|
|
53
53
|
const list = getUnitsWithCurrentUnit(nonNullValueProp, unitProp, unitsProp);
|
|
54
54
|
const [{
|
|
@@ -91,7 +91,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
91
91
|
const {
|
|
92
92
|
data
|
|
93
93
|
} = changeProps;
|
|
94
|
-
let nextValue = `${parsedQuantity
|
|
94
|
+
let nextValue = `${parsedQuantity ?? ""}${nextUnitValue}`;
|
|
95
95
|
if (isResetValueOnUnitChange && data?.default !== void 0) {
|
|
96
96
|
nextValue = `${data.default}${nextUnitValue}`;
|
|
97
97
|
}
|
|
@@ -123,9 +123,8 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
123
123
|
}) : null;
|
|
124
124
|
let step = props.step;
|
|
125
125
|
if (!step && units) {
|
|
126
|
-
var _activeUnit$step;
|
|
127
126
|
const activeUnit = units.find((option) => option.value === unit);
|
|
128
|
-
step =
|
|
127
|
+
step = activeUnit?.step ?? 1;
|
|
129
128
|
}
|
|
130
129
|
return /* @__PURE__ */ _jsx(ValueInput, {
|
|
131
130
|
...props,
|
|
@@ -142,7 +141,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
|
|
|
142
141
|
size,
|
|
143
142
|
suffix: inputSuffix,
|
|
144
143
|
type: isPressEnterToChange ? "text" : "number",
|
|
145
|
-
value: parsedQuantity
|
|
144
|
+
value: parsedQuantity ?? "",
|
|
146
145
|
step,
|
|
147
146
|
onFocus: onFocusProp,
|
|
148
147
|
__unstableStateReducer
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/unit-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport { CSS_UNITS, getParsedQuantityAndUnit, getUnitsWithCurrentUnit, getValidParsedQuantityAndUnit } from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport { escapeRegExp } from '../utils/strings';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedUnitControl(unitControlProps, forwardedRef) {\n const {\n __unstableStateReducer,\n autoComplete = 'off',\n // @ts-expect-error Ensure that children is omitted from restProps\n children,\n className,\n disabled = false,\n disableUnits = false,\n isPressEnterToChange = false,\n isResetValueOnUnitChange = false,\n isUnitSelectTabbable = true,\n label,\n onChange: onChangeProp,\n onUnitChange,\n size = 'default',\n unit: unitProp,\n units: unitsProp = CSS_UNITS,\n value: valueProp,\n onFocus: onFocusProp,\n __shouldNotWarnDeprecated36pxSize,\n ...props\n } = useDeprecated36pxDefaultSizeProp(unitControlProps);\n maybeWarnDeprecated36pxSize({\n componentName: 'UnitControl',\n __next40pxDefaultSize: props.__next40pxDefaultSize,\n size,\n __shouldNotWarnDeprecated36pxSize\n });\n if ('unit' in unitControlProps) {\n deprecated('UnitControl unit prop', {\n since: '5.6',\n hint: 'The unit should be provided within the `value` prop.',\n version: '6.2'\n });\n }\n\n // The `value` prop, in theory, should not be `null`, but the following line\n // ensures it fallback to `undefined` in case a consumer of `UnitControl`\n // still passes `null` as a `value`.\n const nonNullValueProp = valueProp
|
|
5
|
-
"mappings": ";AAIA,OAAO,UAAU;AAKjB,OAAO,gBAAgB;AACvB,SAAS,YAAY,SAAS,QAAQ,iBAAiB;AACvD,SAAS,UAAU;AAMnB,SAAS,kBAAkB;AAC3B,OAAO,uBAAuB;AAC9B,SAAS,WAAW,0BAA0B,yBAAyB,qCAAqC;AAC5G,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,wCAAwC;AACjD,SAAS,mCAAmC;AAC5C,SAAS,OAAO,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport { CSS_UNITS, getParsedQuantityAndUnit, getUnitsWithCurrentUnit, getValidParsedQuantityAndUnit } from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport { escapeRegExp } from '../utils/strings';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedUnitControl(unitControlProps, forwardedRef) {\n const {\n __unstableStateReducer,\n autoComplete = 'off',\n // @ts-expect-error Ensure that children is omitted from restProps\n children,\n className,\n disabled = false,\n disableUnits = false,\n isPressEnterToChange = false,\n isResetValueOnUnitChange = false,\n isUnitSelectTabbable = true,\n label,\n onChange: onChangeProp,\n onUnitChange,\n size = 'default',\n unit: unitProp,\n units: unitsProp = CSS_UNITS,\n value: valueProp,\n onFocus: onFocusProp,\n __shouldNotWarnDeprecated36pxSize,\n ...props\n } = useDeprecated36pxDefaultSizeProp(unitControlProps);\n maybeWarnDeprecated36pxSize({\n componentName: 'UnitControl',\n __next40pxDefaultSize: props.__next40pxDefaultSize,\n size,\n __shouldNotWarnDeprecated36pxSize\n });\n if ('unit' in unitControlProps) {\n deprecated('UnitControl unit prop', {\n since: '5.6',\n hint: 'The unit should be provided within the `value` prop.',\n version: '6.2'\n });\n }\n\n // The `value` prop, in theory, should not be `null`, but the following line\n // ensures it fallback to `undefined` in case a consumer of `UnitControl`\n // still passes `null` as a `value`.\n const nonNullValueProp = valueProp ?? undefined;\n const [units, reFirstCharacterOfUnits] = useMemo(() => {\n const list = getUnitsWithCurrentUnit(nonNullValueProp, unitProp, unitsProp);\n const [{\n value: firstUnitValue = ''\n } = {}, ...rest] = list;\n const firstCharacters = rest.reduce((carry, {\n value\n }) => {\n const first = escapeRegExp(value?.substring(0, 1) || '');\n return carry.includes(first) ? carry : `${carry}|${first}`;\n }, escapeRegExp(firstUnitValue.substring(0, 1)));\n return [list, new RegExp(`^(?:${firstCharacters})$`, 'i')];\n }, [nonNullValueProp, unitProp, unitsProp]);\n const [parsedQuantity, parsedUnit] = getParsedQuantityAndUnit(nonNullValueProp, unitProp, units);\n const [unit, setUnit] = useControlledState(units.length === 1 ? units[0].value : unitProp, {\n initial: parsedUnit,\n fallback: ''\n });\n useEffect(() => {\n if (parsedUnit !== undefined) {\n setUnit(parsedUnit);\n }\n }, [parsedUnit, setUnit]);\n const classes = clsx('components-unit-control',\n // This class is added for legacy purposes to maintain it on the outer\n // wrapper. See: https://github.com/WordPress/gutenberg/pull/45139\n 'components-unit-control-wrapper', className);\n const handleOnQuantityChange = (nextQuantityValue, changeProps) => {\n if (nextQuantityValue === '' || typeof nextQuantityValue === 'undefined' || nextQuantityValue === null) {\n onChangeProp?.('', changeProps);\n return;\n }\n\n /*\n * Customizing the onChange callback.\n * This allows as to broadcast a combined value+unit to onChange.\n */\n const onChangeValue = getValidParsedQuantityAndUnit(nextQuantityValue, units, parsedQuantity, unit).join('');\n onChangeProp?.(onChangeValue, changeProps);\n };\n const handleOnUnitChange = (nextUnitValue, changeProps) => {\n const {\n data\n } = changeProps;\n let nextValue = `${parsedQuantity ?? ''}${nextUnitValue}`;\n if (isResetValueOnUnitChange && data?.default !== undefined) {\n nextValue = `${data.default}${nextUnitValue}`;\n }\n onChangeProp?.(nextValue, changeProps);\n onUnitChange?.(nextUnitValue, changeProps);\n setUnit(nextUnitValue);\n };\n let handleOnKeyDown;\n if (!disableUnits && isUnitSelectTabbable && units.length) {\n handleOnKeyDown = event => {\n props.onKeyDown?.(event);\n // Unless the meta or ctrl key was pressed (to avoid interfering with\n // shortcuts, e.g. pastes), move focus to the unit select if a key\n // matches the first character of a unit.\n if (!event.metaKey && !event.ctrlKey && reFirstCharacterOfUnits.test(event.key)) {\n refInputSuffix.current?.focus();\n }\n };\n }\n const refInputSuffix = useRef(null);\n const inputSuffix = !disableUnits ? /*#__PURE__*/_jsx(UnitSelectControl, {\n ref: refInputSuffix,\n \"aria-label\": __('Select unit'),\n disabled: disabled,\n isUnitSelectTabbable: isUnitSelectTabbable,\n onChange: handleOnUnitChange,\n size: ['small', 'compact'].includes(size) || size === 'default' && !props.__next40pxDefaultSize ? 'small' : 'default',\n unit: unit,\n units: units,\n onFocus: onFocusProp,\n onBlur: unitControlProps.onBlur\n }) : null;\n let step = props.step;\n\n /*\n * If no step prop has been passed, lookup the active unit and\n * try to get step from `units`, or default to a value of `1`\n */\n if (!step && units) {\n const activeUnit = units.find(option => option.value === unit);\n step = activeUnit?.step ?? 1;\n }\n return /*#__PURE__*/_jsx(ValueInput, {\n ...props,\n __shouldNotWarnDeprecated36pxSize: true,\n autoComplete: autoComplete,\n className: classes,\n disabled: disabled,\n spinControls: \"none\",\n isPressEnterToChange: isPressEnterToChange,\n label: label,\n onKeyDown: handleOnKeyDown,\n onChange: handleOnQuantityChange,\n ref: forwardedRef,\n size: size,\n suffix: inputSuffix,\n type: isPressEnterToChange ? 'text' : 'number',\n value: parsedQuantity ?? '',\n step: step,\n onFocus: onFocusProp,\n __unstableStateReducer: __unstableStateReducer\n });\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl __next40pxDefaultSize onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef(UnforwardedUnitControl);\nUnitControl.displayName = 'UnitControl';\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;"],
|
|
5
|
+
"mappings": ";AAIA,OAAO,UAAU;AAKjB,OAAO,gBAAgB;AACvB,SAAS,YAAY,SAAS,QAAQ,iBAAiB;AACvD,SAAS,UAAU;AAMnB,SAAS,kBAAkB;AAC3B,OAAO,uBAAuB;AAC9B,SAAS,WAAW,0BAA0B,yBAAyB,qCAAqC;AAC5G,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,wCAAwC;AACjD,SAAS,mCAAmC;AAC5C,SAAS,OAAO,YAAY;AAwK5B,SAAS,kCAAkC,sBAAsB;AAvKjE,SAAS,uBAAuB,kBAAkB,cAAc;AAC9D,QAAM;AAAA,IACJ;AAAA,IACA,eAAe;AAAA;AAAA,IAEf;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,2BAA2B;AAAA,IAC3B,uBAAuB;AAAA,IACvB;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO,YAAY;AAAA,IACnB,OAAO;AAAA,IACP,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EACL,IAAI,iCAAiC,gBAAgB;AACrD,8BAA4B;AAAA,IAC1B,eAAe;AAAA,IACf,uBAAuB,MAAM;AAAA,IAC7B;AAAA,IACA;AAAA,EACF,CAAC;AACD,MAAI,UAAU,kBAAkB;AAC9B,eAAW,yBAAyB;AAAA,MAClC,O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;AAAA,IACnC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,UAAU;AAAA,IACV,KAAK;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,IACR,MAAM,uBAAuB,SAAS;AAAA,IACtC,OAAO,kBAAkB;AAAA,IACzB;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAiBO,IAAM,cAAc,WAAW,sBAAsB;AAC5D,YAAY,cAAc;AAE1B,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -206,7 +206,7 @@ var ALL_CSS_UNITS = Object.values(allUnits);
|
|
|
206
206
|
var CSS_UNITS = [allUnits.px, allUnits["%"], allUnits.em, allUnits.rem, allUnits.vw, allUnits.vh];
|
|
207
207
|
var DEFAULT_UNIT = allUnits.px;
|
|
208
208
|
function getParsedQuantityAndUnit(rawValue, fallbackUnit, allowedUnits) {
|
|
209
|
-
const initialValue = fallbackUnit ? `${rawValue
|
|
209
|
+
const initialValue = fallbackUnit ? `${rawValue ?? ""}${fallbackUnit}` : rawValue;
|
|
210
210
|
return parseQuantityAndUnitFromRawValue(initialValue, allowedUnits);
|
|
211
211
|
}
|
|
212
212
|
function hasUnits(units) {
|
|
@@ -233,7 +233,7 @@ function parseQuantityAndUnitFromRawValue(rawValue, allowedUnits = ALL_CSS_UNITS
|
|
|
233
233
|
}
|
|
234
234
|
function getValidParsedQuantityAndUnit(rawValue, allowedUnits, fallbackQuantity, fallbackUnit) {
|
|
235
235
|
const [parsedQuantity, parsedUnit] = parseQuantityAndUnitFromRawValue(rawValue, allowedUnits);
|
|
236
|
-
const quantityToReturn = parsedQuantity
|
|
236
|
+
const quantityToReturn = parsedQuantity ?? fallbackQuantity;
|
|
237
237
|
let unitToReturn = parsedUnit || fallbackUnit;
|
|
238
238
|
if (!unitToReturn && hasUnits(allowedUnits)) {
|
|
239
239
|
unitToReturn = allowedUnits[0].value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/unit-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nconst isWeb = Platform.OS === 'web';\nconst allUnits = {\n px: {\n value: 'px',\n label: isWeb ? 'px' : __('Pixels (px)'),\n a11yLabel: __('Pixels (px)'),\n step: 1\n },\n '%': {\n value: '%',\n label: isWeb ? '%' : __('Percentage (%)'),\n a11yLabel: __('Percent (%)'),\n step: 0.1\n },\n em: {\n value: 'em',\n label: isWeb ? 'em' : __('Relative to parent font size (em)'),\n a11yLabel: _x('ems', 'Relative to parent font size (em)'),\n step: 0.01\n },\n rem: {\n value: 'rem',\n label: isWeb ? 'rem' : __('Relative to root font size (rem)'),\n a11yLabel: _x('rems', 'Relative to root font size (rem)'),\n step: 0.01\n },\n vw: {\n value: 'vw',\n label: isWeb ? 'vw' : __('Viewport width (vw)'),\n a11yLabel: __('Viewport width (vw)'),\n step: 0.1\n },\n vh: {\n value: 'vh',\n label: isWeb ? 'vh' : __('Viewport height (vh)'),\n a11yLabel: __('Viewport height (vh)'),\n step: 0.1\n },\n vmin: {\n value: 'vmin',\n label: isWeb ? 'vmin' : __('Viewport smallest dimension (vmin)'),\n a11yLabel: __('Viewport smallest dimension (vmin)'),\n step: 0.1\n },\n vmax: {\n value: 'vmax',\n label: isWeb ? 'vmax' : __('Viewport largest dimension (vmax)'),\n a11yLabel: __('Viewport largest dimension (vmax)'),\n step: 0.1\n },\n ch: {\n value: 'ch',\n label: isWeb ? 'ch' : __('Width of the zero (0) character (ch)'),\n a11yLabel: __('Width of the zero (0) character (ch)'),\n step: 0.01\n },\n ex: {\n value: 'ex',\n label: isWeb ? 'ex' : __('x-height of the font (ex)'),\n a11yLabel: __('x-height of the font (ex)'),\n step: 0.01\n },\n cm: {\n value: 'cm',\n label: isWeb ? 'cm' : __('Centimeters (cm)'),\n a11yLabel: __('Centimeters (cm)'),\n step: 0.001\n },\n mm: {\n value: 'mm',\n label: isWeb ? 'mm' : __('Millimeters (mm)'),\n a11yLabel: __('Millimeters (mm)'),\n step: 0.1\n },\n in: {\n value: 'in',\n label: isWeb ? 'in' : __('Inches (in)'),\n a11yLabel: __('Inches (in)'),\n step: 0.001\n },\n pc: {\n value: 'pc',\n label: isWeb ? 'pc' : __('Picas (pc)'),\n a11yLabel: __('Picas (pc)'),\n step: 1\n },\n pt: {\n value: 'pt',\n label: isWeb ? 'pt' : __('Points (pt)'),\n a11yLabel: __('Points (pt)'),\n step: 1\n },\n svw: {\n value: 'svw',\n label: isWeb ? 'svw' : __('Small viewport width (svw)'),\n a11yLabel: __('Small viewport width (svw)'),\n step: 0.1\n },\n svh: {\n value: 'svh',\n label: isWeb ? 'svh' : __('Small viewport height (svh)'),\n a11yLabel: __('Small viewport height (svh)'),\n step: 0.1\n },\n svi: {\n value: 'svi',\n label: isWeb ? 'svi' : __('Viewport smallest size in the inline direction (svi)'),\n a11yLabel: __('Small viewport width or height (svi)'),\n step: 0.1\n },\n svb: {\n value: 'svb',\n label: isWeb ? 'svb' : __('Viewport smallest size in the block direction (svb)'),\n a11yLabel: __('Small viewport width or height (svb)'),\n step: 0.1\n },\n svmin: {\n value: 'svmin',\n label: isWeb ? 'svmin' : __('Small viewport smallest dimension (svmin)'),\n a11yLabel: __('Small viewport smallest dimension (svmin)'),\n step: 0.1\n },\n lvw: {\n value: 'lvw',\n label: isWeb ? 'lvw' : __('Large viewport width (lvw)'),\n a11yLabel: __('Large viewport width (lvw)'),\n step: 0.1\n },\n lvh: {\n value: 'lvh',\n label: isWeb ? 'lvh' : __('Large viewport height (lvh)'),\n a11yLabel: __('Large viewport height (lvh)'),\n step: 0.1\n },\n lvi: {\n value: 'lvi',\n label: isWeb ? 'lvi' : __('Large viewport width or height (lvi)'),\n a11yLabel: __('Large viewport width or height (lvi)'),\n step: 0.1\n },\n lvb: {\n value: 'lvb',\n label: isWeb ? 'lvb' : __('Large viewport width or height (lvb)'),\n a11yLabel: __('Large viewport width or height (lvb)'),\n step: 0.1\n },\n lvmin: {\n value: 'lvmin',\n label: isWeb ? 'lvmin' : __('Large viewport smallest dimension (lvmin)'),\n a11yLabel: __('Large viewport smallest dimension (lvmin)'),\n step: 0.1\n },\n dvw: {\n value: 'dvw',\n label: isWeb ? 'dvw' : __('Dynamic viewport width (dvw)'),\n a11yLabel: __('Dynamic viewport width (dvw)'),\n step: 0.1\n },\n dvh: {\n value: 'dvh',\n label: isWeb ? 'dvh' : __('Dynamic viewport height (dvh)'),\n a11yLabel: __('Dynamic viewport height (dvh)'),\n step: 0.1\n },\n dvi: {\n value: 'dvi',\n label: isWeb ? 'dvi' : __('Dynamic viewport width or height (dvi)'),\n a11yLabel: __('Dynamic viewport width or height (dvi)'),\n step: 0.1\n },\n dvb: {\n value: 'dvb',\n label: isWeb ? 'dvb' : __('Dynamic viewport width or height (dvb)'),\n a11yLabel: __('Dynamic viewport width or height (dvb)'),\n step: 0.1\n },\n dvmin: {\n value: 'dvmin',\n label: isWeb ? 'dvmin' : __('Dynamic viewport smallest dimension (dvmin)'),\n a11yLabel: __('Dynamic viewport smallest dimension (dvmin)'),\n step: 0.1\n },\n dvmax: {\n value: 'dvmax',\n label: isWeb ? 'dvmax' : __('Dynamic viewport largest dimension (dvmax)'),\n a11yLabel: __('Dynamic viewport largest dimension (dvmax)'),\n step: 0.1\n },\n svmax: {\n value: 'svmax',\n label: isWeb ? 'svmax' : __('Small viewport largest dimension (svmax)'),\n a11yLabel: __('Small viewport largest dimension (svmax)'),\n step: 0.1\n },\n lvmax: {\n value: 'lvmax',\n label: isWeb ? 'lvmax' : __('Large viewport largest dimension (lvmax)'),\n a11yLabel: __('Large viewport largest dimension (lvmax)'),\n step: 0.1\n }\n};\n\n/**\n * An array of all available CSS length units.\n */\nexport const ALL_CSS_UNITS = Object.values(allUnits);\n\n/**\n * Units of measurements. `a11yLabel` is used by screenreaders.\n */\nexport const CSS_UNITS = [allUnits.px, allUnits['%'], allUnits.em, allUnits.rem, allUnits.vw, allUnits.vh];\nexport const DEFAULT_UNIT = allUnits.px;\n\n/**\n * Handles legacy value + unit handling.\n * This component use to manage both incoming value and units separately.\n *\n * Moving forward, ideally the value should be a string that contains both\n * the value and unit, example: '10px'\n *\n * @param rawValue The raw value as a string (may or may not contain the unit)\n * @param fallbackUnit The unit used as a fallback, if not unit is detected in the `value`\n * @param allowedUnits Units to derive from.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parse\n * from the raw value could not be matched against the list of allowed units.\n */\nexport function getParsedQuantityAndUnit(rawValue, fallbackUnit, allowedUnits) {\n const initialValue = fallbackUnit ? `${rawValue !== null && rawValue !== void 0 ? rawValue : ''}${fallbackUnit}` : rawValue;\n return parseQuantityAndUnitFromRawValue(initialValue, allowedUnits);\n}\n\n/**\n * Checks if units are defined.\n *\n * @param units List of units.\n * @return Whether the list actually contains any units.\n */\nexport function hasUnits(units) {\n // Although the `isArray` check shouldn't be necessary (given the signature of\n // this typed function), it's better to stay on the side of caution, since\n // this function may be called from un-typed environments.\n return Array.isArray(units) && !!units.length;\n}\n\n/**\n * Parses a quantity and unit from a raw string value, given a list of allowed\n * units and otherwise falling back to the default unit.\n *\n * @param rawValue The raw value as a string (may or may not contain the unit)\n * @param allowedUnits Units to derive from.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parsed\n * from the raw value could not be matched against the list of allowed units.\n */\nexport function parseQuantityAndUnitFromRawValue(rawValue, allowedUnits = ALL_CSS_UNITS) {\n let trimmedValue;\n let quantityToReturn;\n if (typeof rawValue !== 'undefined' || rawValue === null) {\n trimmedValue = `${rawValue}`.trim();\n const parsedQuantity = parseFloat(trimmedValue);\n quantityToReturn = !isFinite(parsedQuantity) ? undefined : parsedQuantity;\n }\n const unitMatch = trimmedValue?.match(/[\\d.\\-\\+]*\\s*(.*)/);\n const matchedUnit = unitMatch?.[1]?.toLowerCase();\n let unitToReturn;\n if (hasUnits(allowedUnits)) {\n const match = allowedUnits.find(item => item.value === matchedUnit);\n unitToReturn = match?.value;\n } else {\n unitToReturn = DEFAULT_UNIT.value;\n }\n return [quantityToReturn, unitToReturn];\n}\n\n/**\n * Parses quantity and unit from a raw value. Validates parsed value, using fallback\n * value if invalid.\n *\n * @param rawValue The next value.\n * @param allowedUnits Units to derive from.\n * @param fallbackQuantity The fallback quantity, used in case it's not possible to parse a valid quantity from the raw value.\n * @param fallbackUnit The fallback unit, used in case it's not possible to parse a valid unit from the raw value.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly, and the `fallbackQuantity` was also `undefined`. The\n * unit can be `undefined` only if the unit parsed from the raw value could not be matched against\n * the list of allowed units, the `fallbackQuantity` is also `undefined` and the list of\n * `allowedUnits` is passed empty.\n */\nexport function getValidParsedQuantityAndUnit(rawValue, allowedUnits, fallbackQuantity, fallbackUnit) {\n const [parsedQuantity, parsedUnit] = parseQuantityAndUnitFromRawValue(rawValue, allowedUnits);\n\n // The parsed value from `parseQuantityAndUnitFromRawValue` should now be\n // either a real number or undefined. If undefined, use the fallback value.\n const quantityToReturn = parsedQuantity !== null && parsedQuantity !== void 0 ? parsedQuantity : fallbackQuantity;\n\n // If no unit is parsed from the raw value, or if the fallback unit is not\n // defined, use the first value from the list of allowed units as fallback.\n let unitToReturn = parsedUnit || fallbackUnit;\n if (!unitToReturn && hasUnits(allowedUnits)) {\n unitToReturn = allowedUnits[0].value;\n }\n return [quantityToReturn, unitToReturn];\n}\n\n/**\n * Takes a unit value and finds the matching accessibility label for the\n * unit abbreviation.\n *\n * @param unit Unit value (example: `px`)\n * @return a11y label for the unit abbreviation\n */\nexport function getAccessibleLabelForUnit(unit) {\n const match = ALL_CSS_UNITS.find(item => item.value === unit);\n return match?.a11yLabel ? match?.a11yLabel : match?.value;\n}\n\n/**\n * Filters available units based on values defined a list of allowed unit values.\n *\n * @param allowedUnitValues Collection of allowed unit value strings.\n * @param availableUnits Collection of available unit objects.\n * @return Filtered units.\n */\nexport function filterUnitsWithSettings(allowedUnitValues = [], availableUnits) {\n // Although the `isArray` check shouldn't be necessary (given the signature of\n // this typed function), it's better to stay on the side of caution, since\n // this function may be called from un-typed environments.\n return Array.isArray(availableUnits) ? availableUnits.filter(unit => allowedUnitValues.includes(unit.value)) : [];\n}\n\n/**\n * Custom hook to retrieve and consolidate units setting from add_theme_support().\n * TODO: ideally this hook shouldn't be needed\n * https://github.com/WordPress/gutenberg/pull/31822#discussion_r633280823\n *\n * @param args An object containing units, settingPath & defaultUnits.\n * @param args.units Collection of all potentially available units.\n * @param args.availableUnits Collection of unit value strings for filtering available units.\n * @param args.defaultValues Collection of default values for defined units. Example: `{ px: 350, em: 15 }`.\n *\n * @return Filtered list of units, with their default values updated following the `defaultValues`\n * argument's property.\n */\nexport const useCustomUnits = ({\n units = ALL_CSS_UNITS,\n availableUnits = [],\n defaultValues\n}) => {\n const customUnitsToReturn = filterUnitsWithSettings(availableUnits, units);\n if (!defaultValues) {\n return customUnitsToReturn;\n }\n return customUnitsToReturn.map(unit => {\n const [defaultValue] = defaultValues[unit.value] ? parseQuantityAndUnitFromRawValue(defaultValues[unit.value]) : [];\n return {\n ...unit,\n default: defaultValue\n };\n });\n};\n\n/**\n * Get available units with the unit for the currently selected value\n * prepended if it is not available in the list of units.\n *\n * This is useful to ensure that the current value's unit is always\n * accurately displayed in the UI, even if the intention is to hide\n * the availability of that unit.\n *\n * @param rawValue Selected value to parse.\n * @param legacyUnit Legacy unit value, if rawValue needs it appended.\n * @param units List of available units.\n *\n * @return A collection of units containing the unit for the current value.\n */\nexport function getUnitsWithCurrentUnit(rawValue, legacyUnit, units = ALL_CSS_UNITS) {\n const unitsToReturn = Array.isArray(units) ? [...units] : [];\n const [, currentUnit] = getParsedQuantityAndUnit(rawValue, legacyUnit, ALL_CSS_UNITS);\n if (currentUnit && !unitsToReturn.some(unit => unit.value === currentUnit)) {\n if (allUnits[currentUnit]) {\n unitsToReturn.unshift(allUnits[currentUnit]);\n }\n }\n return unitsToReturn;\n}"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,IAAI,UAAU;AACvB,SAAS,gBAAgB;AAMzB,IAAM,QAAQ,SAAS,OAAO;AAC9B,IAAM,WAAW;AAAA,EACf,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,aAAa;AAAA,IACtC,WAAW,GAAG,aAAa;AAAA,IAC3B,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO,QAAQ,MAAM,GAAG,gBAAgB;AAAA,IACxC,WAAW,GAAG,aAAa;AAAA,IAC3B,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,mCAAmC;AAAA,IAC5D,WAAW,GAAG,OAAO,mCAAmC;AAAA,IACxD,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO,QAAQ,QAAQ,GAAG,kCAAkC;AAAA,IAC5D,WAAW,GAAG,QAAQ,kCAAkC;AAAA,IACxD,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,qBAAqB;AAAA,IAC9C,WAAW,GAAG,qBAAqB;AAAA,IACnC,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,sBAAsB;AAAA,IAC/C,WAAW,GAAG,sBAAsB;AAAA,IACpC,MAAM;AAAA,EACR;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO,QAAQ,SAAS,GAAG,oCAAoC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MAAM;AAAA,EACR;AACF;AAKO,IAAM,gBAAgB,OAAO,OAAO,QAAQ;AAK5C,IAAM,YAAY,CAAC,SAAS,IAAI,SAAS,GAAG,GAAG,SAAS,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,EAAE;AAClG,IAAM,eAAe,SAAS;AAgB9B,SAAS,yBAAyB,UAAU,cAAc,cAAc;AAC7E,QAAM,eAAe,eAAe,GAAG,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nconst isWeb = Platform.OS === 'web';\nconst allUnits = {\n px: {\n value: 'px',\n label: isWeb ? 'px' : __('Pixels (px)'),\n a11yLabel: __('Pixels (px)'),\n step: 1\n },\n '%': {\n value: '%',\n label: isWeb ? '%' : __('Percentage (%)'),\n a11yLabel: __('Percent (%)'),\n step: 0.1\n },\n em: {\n value: 'em',\n label: isWeb ? 'em' : __('Relative to parent font size (em)'),\n a11yLabel: _x('ems', 'Relative to parent font size (em)'),\n step: 0.01\n },\n rem: {\n value: 'rem',\n label: isWeb ? 'rem' : __('Relative to root font size (rem)'),\n a11yLabel: _x('rems', 'Relative to root font size (rem)'),\n step: 0.01\n },\n vw: {\n value: 'vw',\n label: isWeb ? 'vw' : __('Viewport width (vw)'),\n a11yLabel: __('Viewport width (vw)'),\n step: 0.1\n },\n vh: {\n value: 'vh',\n label: isWeb ? 'vh' : __('Viewport height (vh)'),\n a11yLabel: __('Viewport height (vh)'),\n step: 0.1\n },\n vmin: {\n value: 'vmin',\n label: isWeb ? 'vmin' : __('Viewport smallest dimension (vmin)'),\n a11yLabel: __('Viewport smallest dimension (vmin)'),\n step: 0.1\n },\n vmax: {\n value: 'vmax',\n label: isWeb ? 'vmax' : __('Viewport largest dimension (vmax)'),\n a11yLabel: __('Viewport largest dimension (vmax)'),\n step: 0.1\n },\n ch: {\n value: 'ch',\n label: isWeb ? 'ch' : __('Width of the zero (0) character (ch)'),\n a11yLabel: __('Width of the zero (0) character (ch)'),\n step: 0.01\n },\n ex: {\n value: 'ex',\n label: isWeb ? 'ex' : __('x-height of the font (ex)'),\n a11yLabel: __('x-height of the font (ex)'),\n step: 0.01\n },\n cm: {\n value: 'cm',\n label: isWeb ? 'cm' : __('Centimeters (cm)'),\n a11yLabel: __('Centimeters (cm)'),\n step: 0.001\n },\n mm: {\n value: 'mm',\n label: isWeb ? 'mm' : __('Millimeters (mm)'),\n a11yLabel: __('Millimeters (mm)'),\n step: 0.1\n },\n in: {\n value: 'in',\n label: isWeb ? 'in' : __('Inches (in)'),\n a11yLabel: __('Inches (in)'),\n step: 0.001\n },\n pc: {\n value: 'pc',\n label: isWeb ? 'pc' : __('Picas (pc)'),\n a11yLabel: __('Picas (pc)'),\n step: 1\n },\n pt: {\n value: 'pt',\n label: isWeb ? 'pt' : __('Points (pt)'),\n a11yLabel: __('Points (pt)'),\n step: 1\n },\n svw: {\n value: 'svw',\n label: isWeb ? 'svw' : __('Small viewport width (svw)'),\n a11yLabel: __('Small viewport width (svw)'),\n step: 0.1\n },\n svh: {\n value: 'svh',\n label: isWeb ? 'svh' : __('Small viewport height (svh)'),\n a11yLabel: __('Small viewport height (svh)'),\n step: 0.1\n },\n svi: {\n value: 'svi',\n label: isWeb ? 'svi' : __('Viewport smallest size in the inline direction (svi)'),\n a11yLabel: __('Small viewport width or height (svi)'),\n step: 0.1\n },\n svb: {\n value: 'svb',\n label: isWeb ? 'svb' : __('Viewport smallest size in the block direction (svb)'),\n a11yLabel: __('Small viewport width or height (svb)'),\n step: 0.1\n },\n svmin: {\n value: 'svmin',\n label: isWeb ? 'svmin' : __('Small viewport smallest dimension (svmin)'),\n a11yLabel: __('Small viewport smallest dimension (svmin)'),\n step: 0.1\n },\n lvw: {\n value: 'lvw',\n label: isWeb ? 'lvw' : __('Large viewport width (lvw)'),\n a11yLabel: __('Large viewport width (lvw)'),\n step: 0.1\n },\n lvh: {\n value: 'lvh',\n label: isWeb ? 'lvh' : __('Large viewport height (lvh)'),\n a11yLabel: __('Large viewport height (lvh)'),\n step: 0.1\n },\n lvi: {\n value: 'lvi',\n label: isWeb ? 'lvi' : __('Large viewport width or height (lvi)'),\n a11yLabel: __('Large viewport width or height (lvi)'),\n step: 0.1\n },\n lvb: {\n value: 'lvb',\n label: isWeb ? 'lvb' : __('Large viewport width or height (lvb)'),\n a11yLabel: __('Large viewport width or height (lvb)'),\n step: 0.1\n },\n lvmin: {\n value: 'lvmin',\n label: isWeb ? 'lvmin' : __('Large viewport smallest dimension (lvmin)'),\n a11yLabel: __('Large viewport smallest dimension (lvmin)'),\n step: 0.1\n },\n dvw: {\n value: 'dvw',\n label: isWeb ? 'dvw' : __('Dynamic viewport width (dvw)'),\n a11yLabel: __('Dynamic viewport width (dvw)'),\n step: 0.1\n },\n dvh: {\n value: 'dvh',\n label: isWeb ? 'dvh' : __('Dynamic viewport height (dvh)'),\n a11yLabel: __('Dynamic viewport height (dvh)'),\n step: 0.1\n },\n dvi: {\n value: 'dvi',\n label: isWeb ? 'dvi' : __('Dynamic viewport width or height (dvi)'),\n a11yLabel: __('Dynamic viewport width or height (dvi)'),\n step: 0.1\n },\n dvb: {\n value: 'dvb',\n label: isWeb ? 'dvb' : __('Dynamic viewport width or height (dvb)'),\n a11yLabel: __('Dynamic viewport width or height (dvb)'),\n step: 0.1\n },\n dvmin: {\n value: 'dvmin',\n label: isWeb ? 'dvmin' : __('Dynamic viewport smallest dimension (dvmin)'),\n a11yLabel: __('Dynamic viewport smallest dimension (dvmin)'),\n step: 0.1\n },\n dvmax: {\n value: 'dvmax',\n label: isWeb ? 'dvmax' : __('Dynamic viewport largest dimension (dvmax)'),\n a11yLabel: __('Dynamic viewport largest dimension (dvmax)'),\n step: 0.1\n },\n svmax: {\n value: 'svmax',\n label: isWeb ? 'svmax' : __('Small viewport largest dimension (svmax)'),\n a11yLabel: __('Small viewport largest dimension (svmax)'),\n step: 0.1\n },\n lvmax: {\n value: 'lvmax',\n label: isWeb ? 'lvmax' : __('Large viewport largest dimension (lvmax)'),\n a11yLabel: __('Large viewport largest dimension (lvmax)'),\n step: 0.1\n }\n};\n\n/**\n * An array of all available CSS length units.\n */\nexport const ALL_CSS_UNITS = Object.values(allUnits);\n\n/**\n * Units of measurements. `a11yLabel` is used by screenreaders.\n */\nexport const CSS_UNITS = [allUnits.px, allUnits['%'], allUnits.em, allUnits.rem, allUnits.vw, allUnits.vh];\nexport const DEFAULT_UNIT = allUnits.px;\n\n/**\n * Handles legacy value + unit handling.\n * This component use to manage both incoming value and units separately.\n *\n * Moving forward, ideally the value should be a string that contains both\n * the value and unit, example: '10px'\n *\n * @param rawValue The raw value as a string (may or may not contain the unit)\n * @param fallbackUnit The unit used as a fallback, if not unit is detected in the `value`\n * @param allowedUnits Units to derive from.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parse\n * from the raw value could not be matched against the list of allowed units.\n */\nexport function getParsedQuantityAndUnit(rawValue, fallbackUnit, allowedUnits) {\n const initialValue = fallbackUnit ? `${rawValue ?? ''}${fallbackUnit}` : rawValue;\n return parseQuantityAndUnitFromRawValue(initialValue, allowedUnits);\n}\n\n/**\n * Checks if units are defined.\n *\n * @param units List of units.\n * @return Whether the list actually contains any units.\n */\nexport function hasUnits(units) {\n // Although the `isArray` check shouldn't be necessary (given the signature of\n // this typed function), it's better to stay on the side of caution, since\n // this function may be called from un-typed environments.\n return Array.isArray(units) && !!units.length;\n}\n\n/**\n * Parses a quantity and unit from a raw string value, given a list of allowed\n * units and otherwise falling back to the default unit.\n *\n * @param rawValue The raw value as a string (may or may not contain the unit)\n * @param allowedUnits Units to derive from.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parsed\n * from the raw value could not be matched against the list of allowed units.\n */\nexport function parseQuantityAndUnitFromRawValue(rawValue, allowedUnits = ALL_CSS_UNITS) {\n let trimmedValue;\n let quantityToReturn;\n if (typeof rawValue !== 'undefined' || rawValue === null) {\n trimmedValue = `${rawValue}`.trim();\n const parsedQuantity = parseFloat(trimmedValue);\n quantityToReturn = !isFinite(parsedQuantity) ? undefined : parsedQuantity;\n }\n const unitMatch = trimmedValue?.match(/[\\d.\\-\\+]*\\s*(.*)/);\n const matchedUnit = unitMatch?.[1]?.toLowerCase();\n let unitToReturn;\n if (hasUnits(allowedUnits)) {\n const match = allowedUnits.find(item => item.value === matchedUnit);\n unitToReturn = match?.value;\n } else {\n unitToReturn = DEFAULT_UNIT.value;\n }\n return [quantityToReturn, unitToReturn];\n}\n\n/**\n * Parses quantity and unit from a raw value. Validates parsed value, using fallback\n * value if invalid.\n *\n * @param rawValue The next value.\n * @param allowedUnits Units to derive from.\n * @param fallbackQuantity The fallback quantity, used in case it's not possible to parse a valid quantity from the raw value.\n * @param fallbackUnit The fallback unit, used in case it's not possible to parse a valid unit from the raw value.\n * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value\n * could not be parsed to a number correctly, and the `fallbackQuantity` was also `undefined`. The\n * unit can be `undefined` only if the unit parsed from the raw value could not be matched against\n * the list of allowed units, the `fallbackQuantity` is also `undefined` and the list of\n * `allowedUnits` is passed empty.\n */\nexport function getValidParsedQuantityAndUnit(rawValue, allowedUnits, fallbackQuantity, fallbackUnit) {\n const [parsedQuantity, parsedUnit] = parseQuantityAndUnitFromRawValue(rawValue, allowedUnits);\n\n // The parsed value from `parseQuantityAndUnitFromRawValue` should now be\n // either a real number or undefined. If undefined, use the fallback value.\n const quantityToReturn = parsedQuantity ?? fallbackQuantity;\n\n // If no unit is parsed from the raw value, or if the fallback unit is not\n // defined, use the first value from the list of allowed units as fallback.\n let unitToReturn = parsedUnit || fallbackUnit;\n if (!unitToReturn && hasUnits(allowedUnits)) {\n unitToReturn = allowedUnits[0].value;\n }\n return [quantityToReturn, unitToReturn];\n}\n\n/**\n * Takes a unit value and finds the matching accessibility label for the\n * unit abbreviation.\n *\n * @param unit Unit value (example: `px`)\n * @return a11y label for the unit abbreviation\n */\nexport function getAccessibleLabelForUnit(unit) {\n const match = ALL_CSS_UNITS.find(item => item.value === unit);\n return match?.a11yLabel ? match?.a11yLabel : match?.value;\n}\n\n/**\n * Filters available units based on values defined a list of allowed unit values.\n *\n * @param allowedUnitValues Collection of allowed unit value strings.\n * @param availableUnits Collection of available unit objects.\n * @return Filtered units.\n */\nexport function filterUnitsWithSettings(allowedUnitValues = [], availableUnits) {\n // Although the `isArray` check shouldn't be necessary (given the signature of\n // this typed function), it's better to stay on the side of caution, since\n // this function may be called from un-typed environments.\n return Array.isArray(availableUnits) ? availableUnits.filter(unit => allowedUnitValues.includes(unit.value)) : [];\n}\n\n/**\n * Custom hook to retrieve and consolidate units setting from add_theme_support().\n * TODO: ideally this hook shouldn't be needed\n * https://github.com/WordPress/gutenberg/pull/31822#discussion_r633280823\n *\n * @param args An object containing units, settingPath & defaultUnits.\n * @param args.units Collection of all potentially available units.\n * @param args.availableUnits Collection of unit value strings for filtering available units.\n * @param args.defaultValues Collection of default values for defined units. Example: `{ px: 350, em: 15 }`.\n *\n * @return Filtered list of units, with their default values updated following the `defaultValues`\n * argument's property.\n */\nexport const useCustomUnits = ({\n units = ALL_CSS_UNITS,\n availableUnits = [],\n defaultValues\n}) => {\n const customUnitsToReturn = filterUnitsWithSettings(availableUnits, units);\n if (!defaultValues) {\n return customUnitsToReturn;\n }\n return customUnitsToReturn.map(unit => {\n const [defaultValue] = defaultValues[unit.value] ? parseQuantityAndUnitFromRawValue(defaultValues[unit.value]) : [];\n return {\n ...unit,\n default: defaultValue\n };\n });\n};\n\n/**\n * Get available units with the unit for the currently selected value\n * prepended if it is not available in the list of units.\n *\n * This is useful to ensure that the current value's unit is always\n * accurately displayed in the UI, even if the intention is to hide\n * the availability of that unit.\n *\n * @param rawValue Selected value to parse.\n * @param legacyUnit Legacy unit value, if rawValue needs it appended.\n * @param units List of available units.\n *\n * @return A collection of units containing the unit for the current value.\n */\nexport function getUnitsWithCurrentUnit(rawValue, legacyUnit, units = ALL_CSS_UNITS) {\n const unitsToReturn = Array.isArray(units) ? [...units] : [];\n const [, currentUnit] = getParsedQuantityAndUnit(rawValue, legacyUnit, ALL_CSS_UNITS);\n if (currentUnit && !unitsToReturn.some(unit => unit.value === currentUnit)) {\n if (allUnits[currentUnit]) {\n unitsToReturn.unshift(allUnits[currentUnit]);\n }\n }\n return unitsToReturn;\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,UAAU;AACvB,SAAS,gBAAgB;AAMzB,IAAM,QAAQ,SAAS,OAAO;AAC9B,IAAM,WAAW;AAAA,EACf,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,aAAa;AAAA,IACtC,WAAW,GAAG,aAAa;AAAA,IAC3B,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO,QAAQ,MAAM,GAAG,gBAAgB;AAAA,IACxC,WAAW,GAAG,aAAa;AAAA,IAC3B,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,mCAAmC;AAAA,IAC5D,WAAW,GAAG,OAAO,mCAAmC;AAAA,IACxD,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO,QAAQ,QAAQ,GAAG,kCAAkC;AAAA,IAC5D,WAAW,GAAG,QAAQ,kCAAkC;AAAA,IACxD,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,qBAAqB;AAAA,IAC9C,WAAW,GAAG,qBAAqB;AAAA,IACnC,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,OAAO,QAAQ,OAAO,GAAG,sBAAsB;AAAA,IAC/C,WAAW,GAAG,sBAAsB;AAAA,IACpC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
11
|
height: 0
|
|
12
12
|
};
|
|
13
13
|
function getElementOffsetRect(element) {
|
|
14
|
-
var _offsetParent$getBoun, _offsetParent$scrollL, _offsetParent$scrollT;
|
|
15
14
|
const rect = element.getBoundingClientRect();
|
|
16
15
|
if (rect.width === 0 || rect.height === 0) {
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
18
|
const offsetParent = element.offsetParent;
|
|
20
|
-
const offsetParentRect =
|
|
21
|
-
const offsetParentScrollX =
|
|
22
|
-
const offsetParentScrollY =
|
|
19
|
+
const offsetParentRect = offsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;
|
|
20
|
+
const offsetParentScrollX = offsetParent?.scrollLeft ?? 0;
|
|
21
|
+
const offsetParentScrollY = offsetParent?.scrollTop ?? 0;
|
|
23
22
|
const computedWidth = parseFloat(getComputedStyle(element).width);
|
|
24
23
|
const computedHeight = parseFloat(getComputedStyle(element).height);
|
|
25
24
|
const scaleX = computedWidth / rect.width;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/element-rect.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n element: undefined,\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n width: 0,\n height: 0\n};\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(element) {\n
|
|
5
|
-
"mappings": ";AAIA,SAAS,iBAAiB,QAAQ,gBAAgB;AAClD,SAAS,UAAU,yBAAyB;AASrC,IAAM,2BAA2B;AAAA,EACtC,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AACV;AAeO,SAAS,qBAAqB,SAAS;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n element: undefined,\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n width: 0,\n height: 0\n};\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(element) {\n // Position and dimension values computed with `getBoundingClientRect` have\n // subpixel precision, but are affected by distortions since they represent\n // the \"real\" measures, or in other words, the actual final values as rendered\n // by the browser.\n const rect = element.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) {\n return;\n }\n const offsetParent = element.offsetParent;\n const offsetParentRect = offsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;\n const offsetParentScrollX = offsetParent?.scrollLeft ?? 0;\n const offsetParentScrollY = offsetParent?.scrollTop ?? 0;\n\n // Computed widths and heights have subpixel precision, and are not affected\n // by distortions.\n const computedWidth = parseFloat(getComputedStyle(element).width);\n const computedHeight = parseFloat(getComputedStyle(element).height);\n\n // We can obtain the current scale factor for the element by comparing \"computed\"\n // dimensions with the \"real\" ones.\n const scaleX = computedWidth / rect.width;\n const scaleY = computedHeight / rect.height;\n return {\n element,\n // To obtain the adjusted values for the position:\n // 1. Compute the element's position relative to the offset parent.\n // 2. Correct for the scale factor.\n // 3. Adjust for the scroll position of the offset parent.\n top: (rect.top - offsetParentRect?.top) * scaleY + offsetParentScrollY,\n right: (offsetParentRect?.right - rect.right) * scaleX - offsetParentScrollX,\n bottom: (offsetParentRect?.bottom - rect.bottom) * scaleY - offsetParentScrollY,\n left: (rect.left - offsetParentRect?.left) * scaleX + offsetParentScrollX,\n // Computed dimensions don't need any adjustments.\n width: computedWidth,\n height: computedHeight\n };\n}\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * When no element is provided (`null` or `undefined`), the hook will return\n * a \"null\" rect, in which all values are `0` and `element` is `undefined`.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(targetElement, deps = []) {\n const [indicatorPosition, setIndicatorPosition] = useState(NULL_ELEMENT_OFFSET_RECT);\n const intervalRef = useRef();\n const measure = useEvent(() => {\n // Check that the targetElement is still attached to the DOM, in case\n // it was removed since the last `measure` call.\n if (targetElement && targetElement.isConnected) {\n const elementOffsetRect = getElementOffsetRect(targetElement);\n if (elementOffsetRect) {\n setIndicatorPosition(elementOffsetRect);\n clearInterval(intervalRef.current);\n return true;\n }\n } else {\n clearInterval(intervalRef.current);\n }\n return false;\n });\n const setElement = useResizeObserver(() => {\n if (!measure()) {\n requestAnimationFrame(() => {\n if (!measure()) {\n intervalRef.current = setInterval(measure, POLL_RATE);\n }\n });\n }\n });\n useLayoutEffect(() => {\n setElement(targetElement);\n if (!targetElement) {\n setIndicatorPosition(NULL_ELEMENT_OFFSET_RECT);\n }\n }, [setElement, targetElement]);\n\n // Escape hatch to force a remeasurement when something else changes rather\n // than the target elements' ref or size (for example, the target element\n // can change its position within the tablist).\n useLayoutEffect(() => {\n measure();\n // `measure` is a stable function, so it's safe to omit it from the deps array.\n // deps can't be statically analyzed by ESLint\n }, deps);\n return indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,iBAAiB,QAAQ,gBAAgB;AAClD,SAAS,UAAU,yBAAyB;AASrC,IAAM,2BAA2B;AAAA,EACtC,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AACV;AAeO,SAAS,qBAAqB,SAAS;AAK5C,QAAM,OAAO,QAAQ,sBAAsB;AAC3C,MAAI,KAAK,UAAU,KAAK,KAAK,WAAW,GAAG;AACzC;AAAA,EACF;AACA,QAAM,eAAe,QAAQ;AAC7B,QAAM,mBAAmB,cAAc,sBAAsB,KAAK;AAClE,QAAM,sBAAsB,cAAc,cAAc;AACxD,QAAM,sBAAsB,cAAc,aAAa;AAIvD,QAAM,gBAAgB,WAAW,iBAAiB,OAAO,EAAE,KAAK;AAChE,QAAM,iBAAiB,WAAW,iBAAiB,OAAO,EAAE,MAAM;AAIlE,QAAM,SAAS,gBAAgB,KAAK;AACpC,QAAM,SAAS,iBAAiB,KAAK;AACrC,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,KAAK,MAAM,kBAAkB,OAAO,SAAS;AAAA,IACnD,QAAQ,kBAAkB,QAAQ,KAAK,SAAS,SAAS;AAAA,IACzD,SAAS,kBAAkB,SAAS,KAAK,UAAU,SAAS;AAAA,IAC5D,OAAO,KAAK,OAAO,kBAAkB,QAAQ,SAAS;AAAA;AAAA,IAEtD,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AACF;AACA,IAAM,YAAY;AAcX,SAAS,0BAA0B,eAAe,OAAO,CAAC,GAAG;AAClE,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,wBAAwB;AACnF,QAAM,cAAc,OAAO;AAC3B,QAAM,UAAU,SAAS,MAAM;AAG7B,QAAI,iBAAiB,cAAc,aAAa;AAC9C,YAAM,oBAAoB,qBAAqB,aAAa;AAC5D,UAAI,mBAAmB;AACrB,6BAAqB,iBAAiB;AACtC,sBAAc,YAAY,OAAO;AACjC,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,oBAAc,YAAY,OAAO;AAAA,IACnC;AACA,WAAO;AAAA,EACT,CAAC;AACD,QAAM,aAAa,kBAAkB,MAAM;AACzC,QAAI,CAAC,QAAQ,GAAG;AACd,4BAAsB,MAAM;AAC1B,YAAI,CAAC,QAAQ,GAAG;AACd,sBAAY,UAAU,YAAY,SAAS,SAAS;AAAA,QACtD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,kBAAgB,MAAM;AACpB,eAAW,aAAa;AACxB,QAAI,CAAC,eAAe;AAClB,2BAAqB,wBAAwB;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,YAAY,aAAa,CAAC;AAK9B,kBAAgB,MAAM;AACpB,YAAQ;AAAA,EAGV,GAAG,IAAI;AACP,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// packages/components/src/utils/font.js
|
|
2
2
|
import FONT from "./font-values.mjs";
|
|
3
3
|
function font(value) {
|
|
4
|
-
|
|
5
|
-
return (_FONT$value = FONT[value]) !== null && _FONT$value !== void 0 ? _FONT$value : "";
|
|
4
|
+
return FONT[value] ?? "";
|
|
6
5
|
}
|
|
7
6
|
export {
|
|
8
7
|
font
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/font.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport FONT from './font-values';\n\n/**\n *\n * @param {keyof FONT} value Path of value from `FONT`\n * @return {string} Font rule value\n */\nexport function font(value) {\n
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAOV,SAAS,KAAK,OAAO;AAC1B,
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport FONT from './font-values';\n\n/**\n *\n * @param {keyof FONT} value Path of value from `FONT`\n * @return {string} Font rule value\n */\nexport function font(value) {\n return FONT[value] ?? '';\n}"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAOV,SAAS,KAAK,OAAO;AAC1B,SAAO,KAAK,KAAK,KAAK;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,8 +6,7 @@ var normalizeTextString = (value) => {
|
|
|
6
6
|
return removeAccents(value).normalize("NFKC").toLocaleLowerCase().replace(ALL_UNICODE_DASH_CHARACTERS, "-");
|
|
7
7
|
};
|
|
8
8
|
function kebabCase(str) {
|
|
9
|
-
|
|
10
|
-
let input = (_str$toString = str?.toString?.()) !== null && _str$toString !== void 0 ? _str$toString : "";
|
|
9
|
+
let input = str?.toString?.() ?? "";
|
|
11
10
|
input = input.replace(/['\u2019]/, "");
|
|
12
11
|
return paramCase(input, {
|
|
13
12
|
splitRegexp: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/strings.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\nimport { paramCase } from 'change-case';\n\n/**\n * All unicode characters that we consider \"dash-like\":\n * - `\\u007e`: ~ (tilde)\n * - `\\u00ad`: \u00AD (soft hyphen)\n * - `\\u2053`: \u2053 (swung dash)\n * - `\\u207b`: \u207B (superscript minus)\n * - `\\u208b`: \u208B (subscript minus)\n * - `\\u2212`: \u2212 (minus sign)\n * - `\\\\p{Pd}`: any other Unicode dash character\n */\nconst ALL_UNICODE_DASH_CHARACTERS = new RegExp(/[\\u007e\\u00ad\\u2053\\u207b\\u208b\\u2212\\p{Pd}]/gu);\nexport const normalizeTextString = value => {\n return removeAccents(value).normalize('NFKC').toLocaleLowerCase().replace(ALL_UNICODE_DASH_CHARACTERS, '-');\n};\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param str String to convert.\n * @return Kebab-cased string\n */\nexport function kebabCase(str) {\n
|
|
5
|
-
"mappings": ";AAGA,OAAO,mBAAmB;AAC1B,SAAS,iBAAiB;AAY1B,IAAM,8BAA8B,IAAI,OAAO,gDAAgD;AACxF,IAAM,sBAAsB,WAAS;AAC1C,SAAO,cAAc,KAAK,EAAE,UAAU,MAAM,EAAE,kBAAkB,EAAE,QAAQ,6BAA6B,GAAG;AAC5G;AAaO,SAAS,UAAU,KAAK;AAC7B,MAAI
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\nimport { paramCase } from 'change-case';\n\n/**\n * All unicode characters that we consider \"dash-like\":\n * - `\\u007e`: ~ (tilde)\n * - `\\u00ad`: \u00AD (soft hyphen)\n * - `\\u2053`: \u2053 (swung dash)\n * - `\\u207b`: \u207B (superscript minus)\n * - `\\u208b`: \u208B (subscript minus)\n * - `\\u2212`: \u2212 (minus sign)\n * - `\\\\p{Pd}`: any other Unicode dash character\n */\nconst ALL_UNICODE_DASH_CHARACTERS = new RegExp(/[\\u007e\\u00ad\\u2053\\u207b\\u208b\\u2212\\p{Pd}]/gu);\nexport const normalizeTextString = value => {\n return removeAccents(value).normalize('NFKC').toLocaleLowerCase().replace(ALL_UNICODE_DASH_CHARACTERS, '-');\n};\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param str String to convert.\n * @return Kebab-cased string\n */\nexport function kebabCase(str) {\n let input = str?.toString?.() ?? '';\n\n // See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n input = input.replace(/['\\u2019]/, '');\n return paramCase(input, {\n splitRegexp: [/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g,\n // fooBar => foo-bar, 3Bar => 3-bar\n /(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g,\n // 3bar => 3-bar\n /([A-Za-z])([0-9])/g,\n // Foo3 => foo-3, foo3 => foo-3\n /([A-Z])([A-Z][a-z])/g // FOOBar => foo-bar\n ]\n });\n}\n\n/**\n * Escapes the RegExp special characters.\n *\n * @param string Input string.\n *\n * @return Regex-escaped string.\n */\nexport function escapeRegExp(string) {\n return string.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n}"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,mBAAmB;AAC1B,SAAS,iBAAiB;AAY1B,IAAM,8BAA8B,IAAI,OAAO,gDAAgD;AACxF,IAAM,sBAAsB,WAAS;AAC1C,SAAO,cAAc,KAAK,EAAE,UAAU,MAAM,EAAE,kBAAkB,EAAE,QAAQ,6BAA6B,GAAG;AAC5G;AAaO,SAAS,UAAU,KAAK;AAC7B,MAAI,QAAQ,KAAK,WAAW,KAAK;AAGjC,UAAQ,MAAM,QAAQ,aAAa,EAAE;AACrC,SAAO,UAAU,OAAO;AAAA,IACtB,aAAa;AAAA,MAAC;AAAA;AAAA,MAEd;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AASO,SAAS,aAAa,QAAQ;AACnC,SAAO,OAAO,QAAQ,uBAAuB,MAAM;AACrD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ function useDeprecated36pxDefaultSizeProp(props) {
|
|
|
7
7
|
} = props;
|
|
8
8
|
return {
|
|
9
9
|
...otherProps,
|
|
10
|
-
__next40pxDefaultSize: __next40pxDefaultSize
|
|
10
|
+
__next40pxDefaultSize: __next40pxDefaultSize ?? __next36pxDefaultSize
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/use-deprecated-props.ts"],
|
|
4
|
-
"sourcesContent": ["export function useDeprecated36pxDefaultSizeProp(props) {\n const {\n __next36pxDefaultSize,\n __next40pxDefaultSize,\n ...otherProps\n } = props;\n return {\n ...otherProps,\n __next40pxDefaultSize: __next40pxDefaultSize
|
|
5
|
-
"mappings": ";AAAO,SAAS,iCAAiC,OAAO;AACtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,SAAO;AAAA,IACL,GAAG;AAAA,IACH,uBAAuB,
|
|
4
|
+
"sourcesContent": ["export function useDeprecated36pxDefaultSizeProp(props) {\n const {\n __next36pxDefaultSize,\n __next40pxDefaultSize,\n ...otherProps\n } = props;\n return {\n ...otherProps,\n __next40pxDefaultSize: __next40pxDefaultSize ?? __next36pxDefaultSize\n };\n}"],
|
|
5
|
+
"mappings": ";AAAO,SAAS,iCAAiC,OAAO;AACtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,SAAO;AAAA,IACL,GAAG;AAAA,IACH,uBAAuB,yBAAyB;AAAA,EAClD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,8 +7,7 @@ function isValueEmpty(value) {
|
|
|
7
7
|
return !isValueDefined(value) || isEmptyString;
|
|
8
8
|
}
|
|
9
9
|
function getDefinedValue(values = [], fallbackValue) {
|
|
10
|
-
|
|
11
|
-
return (_values$find = values.find(isValueDefined)) !== null && _values$find !== void 0 ? _values$find : fallbackValue;
|
|
10
|
+
return values.find(isValueDefined) ?? fallbackValue;
|
|
12
11
|
}
|
|
13
12
|
var stringToNumber = (value) => {
|
|
14
13
|
return parseFloat(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/values.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Determines if a value is null or undefined.\n *\n * @template T\n *\n * @param {T} value The value to check.\n * @return {value is Exclude<T, null | undefined>} Whether value is not null or undefined.\n */\nexport function isValueDefined(value) {\n return value !== undefined && value !== null;\n}\n\n/**\n * Determines if a value is empty, null, or undefined.\n *\n * @param {string | number | null | undefined} value The value to check.\n * @return {value is (\"\" | null | undefined)} Whether value is empty.\n */\nexport function isValueEmpty(value) {\n const isEmptyString = value === '';\n return !isValueDefined(value) || isEmptyString;\n}\n\n/**\n * Get the first defined/non-null value from an array.\n *\n * @template T\n *\n * @param {Array<T | null | undefined>} values Values to derive from.\n * @param {T} fallbackValue Fallback value if there are no defined values.\n * @return {T} A defined value or the fallback value.\n */\nexport function getDefinedValue(values = [], fallbackValue) {\n
|
|
5
|
-
"mappings": ";AAQO,SAAS,eAAe,OAAO;AACpC,SAAO,UAAU,UAAa,UAAU;AAC1C;AAQO,SAAS,aAAa,OAAO;AAClC,QAAM,gBAAgB,UAAU;AAChC,SAAO,CAAC,eAAe,KAAK,KAAK;AACnC;AAWO,SAAS,gBAAgB,SAAS,CAAC,GAAG,eAAe;AAC1D,
|
|
4
|
+
"sourcesContent": ["/**\n * Determines if a value is null or undefined.\n *\n * @template T\n *\n * @param {T} value The value to check.\n * @return {value is Exclude<T, null | undefined>} Whether value is not null or undefined.\n */\nexport function isValueDefined(value) {\n return value !== undefined && value !== null;\n}\n\n/**\n * Determines if a value is empty, null, or undefined.\n *\n * @param {string | number | null | undefined} value The value to check.\n * @return {value is (\"\" | null | undefined)} Whether value is empty.\n */\nexport function isValueEmpty(value) {\n const isEmptyString = value === '';\n return !isValueDefined(value) || isEmptyString;\n}\n\n/**\n * Get the first defined/non-null value from an array.\n *\n * @template T\n *\n * @param {Array<T | null | undefined>} values Values to derive from.\n * @param {T} fallbackValue Fallback value if there are no defined values.\n * @return {T} A defined value or the fallback value.\n */\nexport function getDefinedValue(values = [], fallbackValue) {\n return values.find(isValueDefined) ?? fallbackValue;\n}\n\n/**\n * Converts a string to a number.\n *\n * @param {string} value\n * @return {number} String as a number.\n */\nexport const stringToNumber = value => {\n return parseFloat(value);\n};\n\n/**\n * Regardless of the input being a string or a number, returns a number.\n *\n * Returns `undefined` in case the string is `undefined` or not a valid numeric value.\n *\n * @param {string | number} value\n * @return {number} The parsed number.\n */\nexport const ensureNumber = value => {\n return typeof value === 'string' ? stringToNumber(value) : value;\n};"],
|
|
5
|
+
"mappings": ";AAQO,SAAS,eAAe,OAAO;AACpC,SAAO,UAAU,UAAa,UAAU;AAC1C;AAQO,SAAS,aAAa,OAAO;AAClC,QAAM,gBAAgB,UAAU;AAChC,SAAO,CAAC,eAAe,KAAK,KAAK;AACnC;AAWO,SAAS,gBAAgB,SAAS,CAAC,GAAG,eAAe;AAC1D,SAAO,OAAO,KAAK,cAAc,KAAK;AACxC;AAQO,IAAM,iBAAiB,WAAS;AACrC,SAAO,WAAW,KAAK;AACzB;AAUO,IAAM,eAAe,WAAS;AACnC,SAAO,OAAO,UAAU,WAAW,eAAe,KAAK,IAAI;AAC7D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ var UnforwardedValidatedComboboxControl = ({
|
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
const input = validityTargetRef.current?.querySelector('input[role="combobox"]');
|
|
17
17
|
if (input) {
|
|
18
|
-
input.required = required
|
|
18
|
+
input.required = required ?? false;
|
|
19
19
|
}
|
|
20
20
|
}, [required]);
|
|
21
21
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/combobox-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ComboboxControl from '../../combobox-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedComboboxControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n const input = validityTargetRef.current?.querySelector('input[role=\"combobox\"]');\n if (input) {\n input.required = required
|
|
5
|
-
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc;AAK9C,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,UAAM,QAAQ,kBAAkB,SAAS,cAAc,wBAAwB;AAC/E,QAAI,OAAO;AACT,YAAM,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ComboboxControl from '../../combobox-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedComboboxControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n const input = validityTargetRef.current?.querySelector('input[role=\"combobox\"]');\n if (input) {\n input.required = required ?? false;\n }\n }, [required]);\n return (\n /*#__PURE__*/\n // TODO: Bug - Missing value error is not cleared immediately on change, waits for blur.\n _jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n ref: mergedRefs,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current?.querySelector('input[role=\"combobox\"]'),\n children: /*#__PURE__*/_jsx(ComboboxControl, {\n __next40pxDefaultSize: true,\n ...restProps\n })\n })\n );\n};\nexport const ValidatedComboboxControl = forwardRef(UnforwardedValidatedComboboxControl);\nValidatedComboboxControl.displayName = 'ValidatedComboboxControl';"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,cAAc;AAK9C,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,UAAM,QAAQ,kBAAkB,SAAS,cAAc,wBAAwB;AAC/E,QAAI,OAAO;AACT,YAAM,WAAW,YAAY;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb;AAAA;AAAA,IAGE,qBAAK,kBAAkB;AAAA,MACrB;AAAA,MACA;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA,mBAAmB,MAAM,kBAAkB,SAAS,cAAc,wBAAwB;AAAA,MAC1F,UAAuB,qBAAK,iBAAiB;AAAA,QAC3C,uBAAuB;AAAA,QACvB,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC;AAAA;AAEL;AACO,IAAM,2BAA2B,WAAW,mCAAmC;AACtF,yBAAyB,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ var UnforwardedValidatedToggleControl = ({
|
|
|
14
14
|
const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
if (validityTargetRef.current) {
|
|
17
|
-
validityTargetRef.current.required = required
|
|
17
|
+
validityTargetRef.current.required = required ?? false;
|
|
18
18
|
}
|
|
19
19
|
}, [required]);
|
|
20
20
|
return /* @__PURE__ */ _jsx(ControlWithError, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/toggle-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\n\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n if (validityTargetRef.current) {\n validityTargetRef.current.required = required
|
|
5
|
-
"mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAG1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\n\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n if (validityTargetRef.current) {\n validityTargetRef.current.required = required ?? false;\n }\n }, [required]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleControl, {\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedToggleControl = forwardRef(UnforwardedValidatedToggleControl);\nValidatedToggleControl.displayName = 'ValidatedToggleControl';"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAG1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,YAAY;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;AAClF,uBAAuB,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|