@wordpress/components 32.0.2-next.v.0 → 32.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/build/alignment-matrix-control/cell.cjs +6 -121
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/icon.cjs +2 -3
- package/build/alignment-matrix-control/icon.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +6 -121
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/angle-picker-control/angle-circle.cjs +6 -85
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/autocomplete/autocompleter-ui.cjs +1 -2
- package/build/autocomplete/autocompleter-ui.cjs.map +2 -2
- package/build/box-control/input-control.cjs +8 -12
- package/build/box-control/input-control.cjs.map +2 -2
- package/build/button/index.cjs +6 -12
- package/build/button/index.cjs.map +2 -2
- package/build/calendar/date-calendar/index.cjs +2 -2
- package/build/calendar/date-calendar/index.cjs.map +2 -2
- package/build/calendar/date-range-calendar/index.cjs +4 -6
- package/build/calendar/date-range-calendar/index.cjs.map +2 -2
- package/build/card/card/hook.cjs +1 -2
- package/build/card/card/hook.cjs.map +2 -2
- package/build/color-palette/utils.cjs +2 -2
- package/build/color-palette/utils.cjs.map +2 -2
- package/build/combobox-control/index.cjs +1 -2
- package/build/combobox-control/index.cjs.map +2 -2
- package/build/composite/group-label.cjs +1 -2
- package/build/composite/group-label.cjs.map +2 -2
- package/build/composite/group.cjs +1 -2
- package/build/composite/group.cjs.map +2 -2
- package/build/composite/hover.cjs +1 -2
- package/build/composite/hover.cjs.map +2 -2
- package/build/composite/index.cjs +1 -1
- package/build/composite/index.cjs.map +2 -2
- package/build/composite/item.cjs +1 -2
- package/build/composite/item.cjs.map +2 -2
- package/build/composite/legacy/index.cjs +1 -2
- package/build/composite/legacy/index.cjs.map +2 -2
- package/build/composite/row.cjs +1 -2
- package/build/composite/row.cjs.map +2 -2
- package/build/composite/typeahead.cjs +1 -2
- package/build/composite/typeahead.cjs.map +2 -2
- package/build/confirm-dialog/component.cjs +2 -2
- package/build/confirm-dialog/component.cjs.map +2 -2
- package/build/context/context-system-provider.cjs +1 -1
- package/build/context/context-system-provider.cjs.map +2 -2
- package/build/custom-gradient-picker/index.cjs +1 -2
- package/build/custom-gradient-picker/index.cjs.map +2 -2
- package/build/custom-gradient-picker/utils.cjs +1 -1
- package/build/custom-gradient-picker/utils.cjs.map +2 -2
- package/build/custom-select-control/index.cjs +2 -3
- package/build/custom-select-control/index.cjs.map +2 -2
- package/build/custom-select-control-v2/custom-select.cjs +1 -1
- package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
- package/build/custom-select-control-v2/item.cjs +2 -3
- package/build/custom-select-control-v2/item.cjs.map +2 -2
- package/build/date-time/date/index.cjs +1 -1
- package/build/date-time/date/index.cjs.map +2 -2
- package/build/date-time/time/index.cjs +2 -2
- package/build/date-time/time/index.cjs.map +2 -2
- package/build/date-time/utils.cjs +1 -2
- package/build/date-time/utils.cjs.map +2 -2
- package/build/divider/styles.cjs +2 -2
- package/build/divider/styles.cjs.map +2 -2
- package/build/dropdown-menu/index.cjs +2 -3
- package/build/dropdown-menu/index.cjs.map +2 -2
- package/build/duotone-picker/duotone-picker.cjs +1 -1
- package/build/duotone-picker/duotone-picker.cjs.map +2 -2
- package/build/flex/flex/hook.cjs +1 -1
- package/build/flex/flex/hook.cjs.map +2 -2
- package/build/focal-point-picker/index.cjs +1 -2
- package/build/focal-point-picker/index.cjs.map +2 -2
- package/build/font-size-picker/font-size-picker-select.cjs +1 -2
- package/build/font-size-picker/font-size-picker-select.cjs.map +2 -2
- package/build/font-size-picker/index.cjs +2 -2
- package/build/font-size-picker/index.cjs.map +2 -2
- package/build/guide/index.cjs +2 -3
- package/build/guide/index.cjs.map +2 -2
- package/build/higher-order/navigate-regions/index.cjs +1 -2
- package/build/higher-order/navigate-regions/index.cjs.map +2 -2
- package/build/input-control/input-field.cjs +1 -1
- package/build/input-control/input-field.cjs.map +2 -2
- package/build/input-control/reducer/reducer.cjs +2 -4
- package/build/input-control/reducer/reducer.cjs.map +2 -2
- package/build/keyboard-shortcuts/index.cjs +1 -1
- package/build/keyboard-shortcuts/index.cjs.map +2 -2
- package/build/menu/index.cjs +1 -1
- package/build/menu/index.cjs.map +2 -2
- package/build/menu/item.cjs +1 -1
- package/build/menu/item.cjs.map +2 -2
- package/build/menu/popover.cjs +2 -2
- package/build/menu/popover.cjs.map +2 -2
- package/build/modal/index.cjs +2 -4
- package/build/modal/index.cjs.map +2 -2
- package/build/navigator/navigator/component.cjs +8 -13
- package/build/navigator/navigator/component.cjs.map +2 -2
- package/build/navigator/navigator-screen/component.cjs +1 -1
- package/build/navigator/navigator-screen/component.cjs.map +2 -2
- package/build/number-control/index.cjs +2 -3
- package/build/number-control/index.cjs.map +2 -2
- package/build/palette-edit/index.cjs +3 -4
- package/build/palette-edit/index.cjs.map +2 -2
- package/build/popover/index.cjs +1 -2
- package/build/popover/index.cjs.map +2 -2
- package/build/popover/overlay-middlewares.cjs +1 -2
- package/build/popover/overlay-middlewares.cjs.map +2 -2
- package/build/popover/utils.cjs +3 -8
- package/build/popover/utils.cjs.map +2 -2
- package/build/private-apis.cjs +1 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/radio-group/index.cjs +1 -1
- package/build/radio-group/index.cjs.map +2 -2
- package/build/range-control/index.cjs +4 -4
- package/build/range-control/index.cjs.map +2 -2
- package/build/range-control/utils.cjs +1 -1
- package/build/range-control/utils.cjs.map +2 -2
- package/build/search-control/index.cjs +3 -3
- package/build/search-control/index.cjs.map +2 -2
- package/build/slot-fill/fill.cjs +1 -2
- package/build/slot-fill/fill.cjs.map +2 -2
- package/build/slot-fill/slot.cjs +1 -2
- package/build/slot-fill/slot.cjs.map +2 -2
- package/build/tabs/tab.cjs +1 -2
- package/build/tabs/tab.cjs.map +2 -2
- package/build/tabs/tablist.cjs +7 -11
- package/build/tabs/tablist.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/utils.cjs +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.cjs.map +2 -2
- package/build/tree-grid/index.cjs +1 -2
- package/build/tree-grid/index.cjs.map +2 -2
- package/build/unit-control/index.cjs +4 -5
- package/build/unit-control/index.cjs.map +2 -2
- package/build/unit-control/utils.cjs +2 -2
- package/build/unit-control/utils.cjs.map +2 -2
- package/build/utils/element-rect.cjs +3 -4
- package/build/utils/element-rect.cjs.map +2 -2
- package/build/utils/font.cjs +1 -2
- package/build/utils/font.cjs.map +2 -2
- package/build/utils/strings.cjs +1 -2
- package/build/utils/strings.cjs.map +2 -2
- package/build/utils/use-deprecated-props.cjs +1 -1
- package/build/utils/use-deprecated-props.cjs.map +2 -2
- package/build/utils/values.cjs +1 -2
- package/build/utils/values.cjs.map +2 -2
- package/build/validated-form-controls/components/combobox-control.cjs +1 -1
- package/build/validated-form-controls/components/combobox-control.cjs.map +2 -2
- package/build/validated-form-controls/components/toggle-control.cjs +1 -1
- package/build/validated-form-controls/components/toggle-control.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +3 -6
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +6 -121
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/icon.mjs +2 -3
- package/build-module/alignment-matrix-control/icon.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +6 -121
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs +6 -85
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/autocomplete/autocompleter-ui.mjs +1 -2
- package/build-module/autocomplete/autocompleter-ui.mjs.map +2 -2
- package/build-module/box-control/input-control.mjs +8 -12
- package/build-module/box-control/input-control.mjs.map +2 -2
- package/build-module/button/index.mjs +6 -12
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/calendar/date-calendar/index.mjs +2 -2
- package/build-module/calendar/date-calendar/index.mjs.map +2 -2
- package/build-module/calendar/date-range-calendar/index.mjs +4 -6
- package/build-module/calendar/date-range-calendar/index.mjs.map +2 -2
- package/build-module/card/card/hook.mjs +1 -2
- package/build-module/card/card/hook.mjs.map +2 -2
- package/build-module/color-palette/utils.mjs +2 -2
- package/build-module/color-palette/utils.mjs.map +2 -2
- package/build-module/combobox-control/index.mjs +1 -2
- package/build-module/combobox-control/index.mjs.map +2 -2
- package/build-module/composite/group-label.mjs +1 -2
- package/build-module/composite/group-label.mjs.map +2 -2
- package/build-module/composite/group.mjs +1 -2
- package/build-module/composite/group.mjs.map +2 -2
- package/build-module/composite/hover.mjs +1 -2
- package/build-module/composite/hover.mjs.map +2 -2
- package/build-module/composite/index.mjs +1 -1
- package/build-module/composite/index.mjs.map +2 -2
- package/build-module/composite/item.mjs +1 -2
- package/build-module/composite/item.mjs.map +2 -2
- package/build-module/composite/legacy/index.mjs +1 -2
- package/build-module/composite/legacy/index.mjs.map +2 -2
- package/build-module/composite/row.mjs +1 -2
- package/build-module/composite/row.mjs.map +2 -2
- package/build-module/composite/typeahead.mjs +1 -2
- package/build-module/composite/typeahead.mjs.map +2 -2
- package/build-module/confirm-dialog/component.mjs +2 -2
- package/build-module/confirm-dialog/component.mjs.map +2 -2
- package/build-module/context/context-system-provider.mjs +1 -1
- package/build-module/context/context-system-provider.mjs.map +2 -2
- package/build-module/custom-gradient-picker/index.mjs +1 -2
- package/build-module/custom-gradient-picker/index.mjs.map +2 -2
- package/build-module/custom-gradient-picker/utils.mjs +1 -1
- package/build-module/custom-gradient-picker/utils.mjs.map +2 -2
- package/build-module/custom-select-control/index.mjs +2 -3
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs +1 -1
- package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
- package/build-module/custom-select-control-v2/item.mjs +2 -3
- package/build-module/custom-select-control-v2/item.mjs.map +2 -2
- package/build-module/date-time/date/index.mjs +1 -1
- package/build-module/date-time/date/index.mjs.map +2 -2
- package/build-module/date-time/time/index.mjs +2 -2
- package/build-module/date-time/time/index.mjs.map +2 -2
- package/build-module/date-time/utils.mjs +1 -2
- package/build-module/date-time/utils.mjs.map +2 -2
- package/build-module/divider/styles.mjs +2 -2
- package/build-module/divider/styles.mjs.map +2 -2
- package/build-module/dropdown-menu/index.mjs +2 -3
- package/build-module/dropdown-menu/index.mjs.map +2 -2
- package/build-module/duotone-picker/duotone-picker.mjs +1 -1
- package/build-module/duotone-picker/duotone-picker.mjs.map +2 -2
- package/build-module/flex/flex/hook.mjs +1 -1
- package/build-module/flex/flex/hook.mjs.map +2 -2
- package/build-module/focal-point-picker/index.mjs +1 -2
- package/build-module/focal-point-picker/index.mjs.map +2 -2
- package/build-module/font-size-picker/font-size-picker-select.mjs +1 -2
- package/build-module/font-size-picker/font-size-picker-select.mjs.map +2 -2
- package/build-module/font-size-picker/index.mjs +2 -2
- package/build-module/font-size-picker/index.mjs.map +2 -2
- package/build-module/guide/index.mjs +2 -3
- package/build-module/guide/index.mjs.map +2 -2
- package/build-module/higher-order/navigate-regions/index.mjs +1 -2
- package/build-module/higher-order/navigate-regions/index.mjs.map +2 -2
- package/build-module/input-control/input-field.mjs +1 -1
- package/build-module/input-control/input-field.mjs.map +2 -2
- package/build-module/input-control/reducer/reducer.mjs +2 -4
- package/build-module/input-control/reducer/reducer.mjs.map +2 -2
- package/build-module/keyboard-shortcuts/index.mjs +1 -1
- package/build-module/keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/menu/index.mjs +1 -1
- package/build-module/menu/index.mjs.map +2 -2
- package/build-module/menu/item.mjs +1 -1
- package/build-module/menu/item.mjs.map +2 -2
- package/build-module/menu/popover.mjs +2 -2
- package/build-module/menu/popover.mjs.map +2 -2
- package/build-module/modal/index.mjs +2 -4
- package/build-module/modal/index.mjs.map +2 -2
- package/build-module/navigator/navigator/component.mjs +8 -13
- package/build-module/navigator/navigator/component.mjs.map +2 -2
- package/build-module/navigator/navigator-screen/component.mjs +1 -1
- package/build-module/navigator/navigator-screen/component.mjs.map +2 -2
- package/build-module/number-control/index.mjs +2 -3
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs +3 -4
- package/build-module/palette-edit/index.mjs.map +2 -2
- package/build-module/popover/index.mjs +1 -2
- package/build-module/popover/index.mjs.map +2 -2
- package/build-module/popover/overlay-middlewares.mjs +1 -2
- package/build-module/popover/overlay-middlewares.mjs.map +2 -2
- package/build-module/popover/utils.mjs +3 -8
- package/build-module/popover/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +2 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/radio-group/index.mjs +1 -1
- package/build-module/radio-group/index.mjs.map +2 -2
- package/build-module/range-control/index.mjs +4 -4
- package/build-module/range-control/index.mjs.map +2 -2
- package/build-module/range-control/utils.mjs +1 -1
- package/build-module/range-control/utils.mjs.map +2 -2
- package/build-module/search-control/index.mjs +3 -3
- package/build-module/search-control/index.mjs.map +2 -2
- package/build-module/slot-fill/fill.mjs +1 -2
- package/build-module/slot-fill/fill.mjs.map +2 -2
- package/build-module/slot-fill/slot.mjs +1 -2
- package/build-module/slot-fill/slot.mjs.map +2 -2
- package/build-module/tabs/tab.mjs +1 -2
- package/build-module/tabs/tab.mjs.map +2 -2
- package/build-module/tabs/tablist.mjs +7 -11
- package/build-module/tabs/tablist.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/utils.mjs +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.mjs.map +2 -2
- package/build-module/tree-grid/index.mjs +1 -2
- package/build-module/tree-grid/index.mjs.map +2 -2
- package/build-module/unit-control/index.mjs +4 -5
- package/build-module/unit-control/index.mjs.map +2 -2
- package/build-module/unit-control/utils.mjs +2 -2
- package/build-module/unit-control/utils.mjs.map +2 -2
- package/build-module/utils/element-rect.mjs +3 -4
- package/build-module/utils/element-rect.mjs.map +2 -2
- package/build-module/utils/font.mjs +1 -2
- package/build-module/utils/font.mjs.map +2 -2
- package/build-module/utils/strings.mjs +1 -2
- package/build-module/utils/strings.mjs.map +2 -2
- package/build-module/utils/use-deprecated-props.mjs +1 -1
- package/build-module/utils/use-deprecated-props.mjs.map +2 -2
- package/build-module/utils/values.mjs +1 -2
- package/build-module/utils/values.mjs.map +2 -2
- package/build-module/validated-form-controls/components/combobox-control.mjs +1 -1
- package/build-module/validated-form-controls/components/combobox-control.mjs.map +2 -2
- package/build-module/validated-form-controls/components/toggle-control.mjs +1 -1
- package/build-module/validated-form-controls/components/toggle-control.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +3 -6
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-types/private-apis.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/private-apis.ts +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/popover/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\nimport { useFloating, flip as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n var _refs$floating$curren;\n const {\n firstElementChild\n } = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside') {\n // Check if this blur event is actually relevant to this popover\n const blurTarget = event?.target;\n const referenceElement = refs.reference.current;\n const floatingElement = refs.floating.current;\n\n // Check if blur is from this popover's reference element or its floating content\n const isBlurFromThisPopover = referenceElement && 'contains' in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);\n // Ignore blur events that don't originate from this popover when there's no\n // relatedTarget (next focus target) and focus moves to document.body.\n // This prevents incorrectly closing the popover when clicking on elements\n // that don't accept focus (like clicking outside to empty space).\n const ownerDocument = floatingElement?.ownerDocument;\n if (!isBlurFromThisPopover && !('relatedTarget' in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {\n return;\n }\n // Call onFocusOutside if defined or call onClose.\n if (onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n } else if (onClose) {\n // onClose should be called for other event types if it exists.\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n displayName: 'Popover.__unstableSlotNameProvider'\n })\n});\nexport default Popover;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAiB;AACjB,uBAA+I;AAC/I,2BAAuB;AAKvB,qBAA6H;AAC7H,qBAAuG;AACvG,mBAAsB;AACtB,w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MAAe,GAAG,0BAAsB,uBAAK;AAAA,IAC/K,SAAS;AAAA,IACT,MAAM,WAAW;AACf,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\nimport { useFloating, flip as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n const {\n firstElementChild\n } = refs.floating.current ?? {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside') {\n // Check if this blur event is actually relevant to this popover\n const blurTarget = event?.target;\n const referenceElement = refs.reference.current;\n const floatingElement = refs.floating.current;\n\n // Check if blur is from this popover's reference element or its floating content\n const isBlurFromThisPopover = referenceElement && 'contains' in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);\n // Ignore blur events that don't originate from this popover when there's no\n // relatedTarget (next focus target) and focus moves to document.body.\n // This prevents incorrectly closing the popover when clicking on elements\n // that don't accept focus (like clicking outside to empty space).\n const ownerDocument = floatingElement?.ownerDocument;\n if (!isBlurFromThisPopover && !('relatedTarget' in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {\n return;\n }\n // Call onFocusOutside if defined or call onClose.\n if (onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n } else if (onClose) {\n // onClose should be called for other event types if it exists.\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n displayName: 'Popover.__unstableSlotNameProvider'\n })\n});\nexport default Popover;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAiB;AACjB,uBAA+I;AAC/I,2BAAuB;AAKvB,qBAA6H;AAC7H,qBAAuG;AACvG,mBAAsB;AACtB,wBAAuB;AACvB,wBAA0B;AAC1B,kBAAmB;AAKnB,oBAAmB;AACnB,yBAAuB;AACvB,uBAAoC;AACpC,mBAAkH;AAClH,qBAAiD;AACjD,iCAAmC;AACnC,4BAA8B;AAO9B,yBAAkE;AAC3D,IAAM,YAAY;AAOzB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB,MAAmB,uCAAAA,MAAM,uBAAK;AAAA,EAClD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU,CAAc,uCAAAC,KAAK,wBAAM;AAAA,IACjC,WAAW;AAAA,IACX,GAAG;AAAA,EACL,CAAC,GAAgB,uCAAAA,KAAK,wBAAM;AAAA,IAC1B,WAAW;AAAA,IACX,GAAG;AAAA,IACH,cAAc;AAAA,EAChB,CAAC,CAAC;AACJ,CAAC;AACD,IAAM,sBAAkB,8BAAc,MAAS;AAC/C,gBAAgB,cAAc;AAC9B,IAAM,6BAA6B;AACnC,IAAM,8BAA8B,MAAM;AACxC,MAAI,YAAY,SAAS,KAAK,cAAc,MAAM,0BAA0B;AAC5E,MAAI,CAAC,WAAW;AACd,gBAAY,SAAS,cAAc,KAAK;AACxC,cAAU,YAAY;AACtB,aAAS,KAAK,OAAO,SAAS;AAAA,EAChC;AACA,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,4BAA4B,CAAC;AAAA,EACnC;AACA,MAAI,WAAW;AACb,WAAO;AAAA,EACT;AACA,SAAoB,uCAAAD,MAAM,mBAAAU,UAAW;AAAA,IACnC,UAAU,CAAc,uCAAAT,KAAK,QAAQ;AAAA,MACnC,KAAK;AAAA,IACP,CAAC,GAAG,OAAO;AAAA,EACb,CAAC;AACH;AAGO,IAAM,kBAAc,2BAAW,CAAC;AAAA,EACrC,OAAO;AACT,GAAG,QAAQ;AACT,SAAoB,uCAAAA,KAAK,uBAAM;AAAA,IAC7B,kBAAkB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AACH,CAAC;AAyBM,IAAM,UAAU,OAAO,WAAO,+BAAe,oBAAoB,SAAS,GAAG;AAAA;AAAA;AAAA;AAAA,EAIlF,MAAM,OAAO,OAAO,aAAa;AAAA,IAC/B,aAAa;AAAA,EACf,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,4BAA4B,OAAO,OAAO,gBAAgB,UAAU;AAAA,IAClE,aAAa;AAAA,EACf,CAAC;AACH,CAAC;AACD,IAAO,kBAAQ;",
|
|
6
6
|
"names": ["_jsxs", "_jsx", "deprecated", "offsetMiddleware", "flipMiddleware", "shiftMiddleware", "useDialog", "clsx", "ScrollLock", "Button", "_Fragment"]
|
|
7
7
|
}
|
|
@@ -37,10 +37,9 @@ function overlayMiddlewares() {
|
|
|
37
37
|
rects,
|
|
38
38
|
elements
|
|
39
39
|
}) {
|
|
40
|
-
var _elements$floating;
|
|
41
40
|
const {
|
|
42
41
|
firstElementChild
|
|
43
|
-
} =
|
|
42
|
+
} = elements.floating ?? {};
|
|
44
43
|
if (!(firstElementChild instanceof HTMLElement)) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/popover/overlay-middlewares.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport { size } from '@floating-ui/react-dom';\nexport function overlayMiddlewares() {\n return [{\n name: 'overlay',\n fn({\n rects\n }) {\n return rects.reference;\n }\n }, size({\n apply({\n rects,\n elements\n }) {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAqB;AACd,SAAS,qBAAqB;AACnC,SAAO,CAAC;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,MACD;AAAA,IACF,GAAG;AACD,aAAO,MAAM;AAAA,IACf;AAAA,EACF,OAAG,uBAAK;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF,GAAG;AACD,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport { size } from '@floating-ui/react-dom';\nexport function overlayMiddlewares() {\n return [{\n name: 'overlay',\n fn({\n rects\n }) {\n return rects.reference;\n }\n }, size({\n apply({\n rects,\n elements\n }) {\n const {\n firstElementChild\n } = elements.floating ?? {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n width: `${rects.reference.width}px`,\n height: `${rects.reference.height}px`\n });\n }\n })];\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAqB;AACd,SAAS,qBAAqB;AACnC,SAAO,CAAC;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,MACD;AAAA,IACF,GAAG;AACD,aAAO,MAAM;AAAA,IACf;AAAA,EACF,OAAG,uBAAK;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF,GAAG;AACD,YAAM;AAAA,QACJ;AAAA,MACF,IAAI,SAAS,YAAY,CAAC;AAG1B,UAAI,EAAE,6BAA6B,cAAc;AAC/C;AAAA,MACF;AAGA,aAAO,OAAO,kBAAkB,OAAO;AAAA,QACrC,OAAO,GAAG,MAAM,UAAU,KAAK;AAAA,QAC/B,QAAQ,GAAG,MAAM,UAAU,MAAM;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC,CAAC;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/popover/utils.cjs
CHANGED
|
@@ -80,10 +80,7 @@ var POSITION_TO_PLACEMENT = {
|
|
|
80
80
|
"middle center right": "bottom",
|
|
81
81
|
"middle center top": "bottom"
|
|
82
82
|
};
|
|
83
|
-
var positionToPlacement = (position) =>
|
|
84
|
-
var _POSITION_TO_PLACEMEN;
|
|
85
|
-
return (_POSITION_TO_PLACEMEN = POSITION_TO_PLACEMENT[position]) !== null && _POSITION_TO_PLACEMEN !== void 0 ? _POSITION_TO_PLACEMEN : "bottom";
|
|
86
|
-
};
|
|
83
|
+
var positionToPlacement = (position) => POSITION_TO_PLACEMENT[position] ?? "bottom";
|
|
87
84
|
var PLACEMENT_TO_ANIMATION_ORIGIN = {
|
|
88
85
|
top: {
|
|
89
86
|
originX: 0.5,
|
|
@@ -189,7 +186,6 @@ var getReferenceElement = ({
|
|
|
189
186
|
getAnchorRect,
|
|
190
187
|
fallbackReferenceElement
|
|
191
188
|
}) => {
|
|
192
|
-
var _referenceElement;
|
|
193
189
|
let referenceElement = null;
|
|
194
190
|
if (anchor) {
|
|
195
191
|
referenceElement = anchor;
|
|
@@ -214,15 +210,14 @@ var getReferenceElement = ({
|
|
|
214
210
|
} else if (getAnchorRect) {
|
|
215
211
|
referenceElement = {
|
|
216
212
|
getBoundingClientRect() {
|
|
217
|
-
var _rect$x, _rect$y, _rect$width, _rect$height;
|
|
218
213
|
const rect = getAnchorRect(fallbackReferenceElement);
|
|
219
|
-
return new window.DOMRect(
|
|
214
|
+
return new window.DOMRect(rect.x ?? rect.left, rect.y ?? rect.top, rect.width ?? rect.right - rect.left, rect.height ?? rect.bottom - rect.top);
|
|
220
215
|
}
|
|
221
216
|
};
|
|
222
217
|
} else if (fallbackReferenceElement) {
|
|
223
218
|
referenceElement = fallbackReferenceElement.parentElement;
|
|
224
219
|
}
|
|
225
|
-
return
|
|
220
|
+
return referenceElement ?? null;
|
|
226
221
|
};
|
|
227
222
|
var computePopoverPosition = (c) => c === null || Number.isNaN(c) ? void 0 : Math.round(c);
|
|
228
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/popover/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { cubicBezier } from 'framer-motion';\n/**\n * Internal dependencies\n */\nimport { DROPDOWN_MOTION } from '../utils';\nconst POSITION_TO_PLACEMENT = {\n bottom: 'bottom',\n top: 'top',\n 'middle left': 'left',\n 'middle right': 'right',\n 'bottom left': 'bottom-end',\n 'bottom center': 'bottom',\n 'bottom right': 'bottom-start',\n 'top left': 'top-end',\n 'top center': 'top',\n 'top right': 'top-start',\n 'middle left left': 'left',\n 'middle left right': 'left',\n 'middle left bottom': 'left-end',\n 'middle left top': 'left-start',\n 'middle right left': 'right',\n 'middle right right': 'right',\n 'middle right bottom': 'right-end',\n 'middle right top': 'right-start',\n 'bottom left left': 'bottom-end',\n 'bottom left right': 'bottom-end',\n 'bottom left bottom': 'bottom-end',\n 'bottom left top': 'bottom-end',\n 'bottom center left': 'bottom',\n 'bottom center right': 'bottom',\n 'bottom center bottom': 'bottom',\n 'bottom center top': 'bottom',\n 'bottom right left': 'bottom-start',\n 'bottom right right': 'bottom-start',\n 'bottom right bottom': 'bottom-start',\n 'bottom right top': 'bottom-start',\n 'top left left': 'top-end',\n 'top left right': 'top-end',\n 'top left bottom': 'top-end',\n 'top left top': 'top-end',\n 'top center left': 'top',\n 'top center right': 'top',\n 'top center bottom': 'top',\n 'top center top': 'top',\n 'top right left': 'top-start',\n 'top right right': 'top-start',\n 'top right bottom': 'top-start',\n 'top right top': 'top-start',\n // `middle`/`middle center [corner?]` positions are associated to a fallback\n // `bottom` placement because there aren't any corresponding placement values.\n middle: 'bottom',\n 'middle center': 'bottom',\n 'middle center bottom': 'bottom',\n 'middle center left': 'bottom',\n 'middle center right': 'bottom',\n 'middle center top': 'bottom'\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = position =>
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,2BAA4B;AAI5B,mBAAgC;AAChC,IAAM,wBAAwB;AAAA,EAC5B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA;AAAA;AAAA,EAGjB,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,qBAAqB;AACvB;AASO,IAAM,sBAAsB,cAAY
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { cubicBezier } from 'framer-motion';\n/**\n * Internal dependencies\n */\nimport { DROPDOWN_MOTION } from '../utils';\nconst POSITION_TO_PLACEMENT = {\n bottom: 'bottom',\n top: 'top',\n 'middle left': 'left',\n 'middle right': 'right',\n 'bottom left': 'bottom-end',\n 'bottom center': 'bottom',\n 'bottom right': 'bottom-start',\n 'top left': 'top-end',\n 'top center': 'top',\n 'top right': 'top-start',\n 'middle left left': 'left',\n 'middle left right': 'left',\n 'middle left bottom': 'left-end',\n 'middle left top': 'left-start',\n 'middle right left': 'right',\n 'middle right right': 'right',\n 'middle right bottom': 'right-end',\n 'middle right top': 'right-start',\n 'bottom left left': 'bottom-end',\n 'bottom left right': 'bottom-end',\n 'bottom left bottom': 'bottom-end',\n 'bottom left top': 'bottom-end',\n 'bottom center left': 'bottom',\n 'bottom center right': 'bottom',\n 'bottom center bottom': 'bottom',\n 'bottom center top': 'bottom',\n 'bottom right left': 'bottom-start',\n 'bottom right right': 'bottom-start',\n 'bottom right bottom': 'bottom-start',\n 'bottom right top': 'bottom-start',\n 'top left left': 'top-end',\n 'top left right': 'top-end',\n 'top left bottom': 'top-end',\n 'top left top': 'top-end',\n 'top center left': 'top',\n 'top center right': 'top',\n 'top center bottom': 'top',\n 'top center top': 'top',\n 'top right left': 'top-start',\n 'top right right': 'top-start',\n 'top right bottom': 'top-start',\n 'top right top': 'top-start',\n // `middle`/`middle center [corner?]` positions are associated to a fallback\n // `bottom` placement because there aren't any corresponding placement values.\n middle: 'bottom',\n 'middle center': 'bottom',\n 'middle center bottom': 'bottom',\n 'middle center left': 'bottom',\n 'middle center right': 'bottom',\n 'middle center top': 'bottom'\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = position => POSITION_TO_PLACEMENT[position] ?? 'bottom';\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN = {\n top: {\n originX: 0.5,\n originY: 1\n },\n // open from bottom, center\n 'top-start': {\n originX: 0,\n originY: 1\n },\n // open from bottom, left\n 'top-end': {\n originX: 1,\n originY: 1\n },\n // open from bottom, right\n right: {\n originX: 0,\n originY: 0.5\n },\n // open from middle, left\n 'right-start': {\n originX: 0,\n originY: 0\n },\n // open from top, left\n 'right-end': {\n originX: 0,\n originY: 1\n },\n // open from bottom, left\n bottom: {\n originX: 0.5,\n originY: 0\n },\n // open from top, center\n 'bottom-start': {\n originX: 0,\n originY: 0\n },\n // open from top, left\n 'bottom-end': {\n originX: 1,\n originY: 0\n },\n // open from top, right\n left: {\n originX: 1,\n originY: 0.5\n },\n // open from middle, right\n 'left-start': {\n originX: 1,\n originY: 0\n },\n // open from top, right\n 'left-end': {\n originX: 1,\n originY: 1\n },\n // open from bottom, right\n overlay: {\n originX: 0.5,\n originY: 0.5\n } // open from center, center\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = placement => {\n const translateProp = placement.startsWith('top') || placement.startsWith('bottom') ? 'translateY' : 'translateX';\n const translateDirection = placement.startsWith('top') || placement.startsWith('left') ? 1 : -1;\n return {\n style: PLACEMENT_TO_ANIMATION_ORIGIN[placement],\n initial: {\n opacity: 0,\n [translateProp]: `${DROPDOWN_MOTION.SLIDE_DISTANCE * translateDirection}px`\n },\n animate: {\n opacity: 1,\n [translateProp]: 0\n },\n transition: {\n opacity: {\n duration: DROPDOWN_MOTION.FADE_DURATION / 1000,\n ease: DROPDOWN_MOTION.FADE_EASING.function\n },\n [translateProp]: {\n duration: DROPDOWN_MOTION.SLIDE_DURATION / 1000,\n ease: cubicBezier(...DROPDOWN_MOTION.SLIDE_EASING.args)\n }\n }\n };\n};\nfunction isTopBottom(anchorRef) {\n return !!anchorRef?.top;\n}\nfunction isRef(anchorRef) {\n return !!anchorRef?.current;\n}\nexport const getReferenceElement = ({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n}) => {\n let referenceElement = null;\n if (anchor) {\n referenceElement = anchor;\n } else if (isTopBottom(anchorRef)) {\n // Create a virtual element for the ref. The expectation is that\n // if anchorRef.top is defined, then anchorRef.bottom is defined too.\n // Seems to be used by the block toolbar, when multiple blocks are selected\n // (top and bottom blocks are used to calculate the resulting rect).\n referenceElement = {\n getBoundingClientRect() {\n const topRect = anchorRef.top.getBoundingClientRect();\n const bottomRect = anchorRef.bottom.getBoundingClientRect();\n return new window.DOMRect(topRect.x, topRect.y, topRect.width, bottomRect.bottom - topRect.top);\n }\n };\n } else if (isRef(anchorRef)) {\n // Standard React ref.\n referenceElement = anchorRef.current;\n } else if (anchorRef) {\n // If `anchorRef` holds directly the element's value (no `current` key)\n // This is a weird scenario and should be deprecated.\n referenceElement = anchorRef;\n } else if (anchorRect) {\n // Create a virtual element for the ref.\n referenceElement = {\n getBoundingClientRect() {\n return anchorRect;\n }\n };\n } else if (getAnchorRect) {\n // Create a virtual element for the ref.\n referenceElement = {\n getBoundingClientRect() {\n const rect = getAnchorRect(fallbackReferenceElement);\n return new window.DOMRect(rect.x ?? rect.left, rect.y ?? rect.top, rect.width ?? rect.right - rect.left, rect.height ?? rect.bottom - rect.top);\n }\n };\n } else if (fallbackReferenceElement) {\n // If no explicit ref is passed via props, fall back to\n // anchoring to the popover's parent node.\n referenceElement = fallbackReferenceElement.parentElement;\n }\n\n // Convert any `undefined` value to `null`.\n return referenceElement ?? null;\n};\n\n/**\n * Computes the final coordinate that needs to be applied to the floating\n * element when applying transform inline styles, defaulting to `undefined`\n * if the provided value is `null` or `NaN`.\n *\n * @param c input coordinate (usually as returned from floating-ui)\n * @return The coordinate's value to be used for inline styles. An `undefined`\n * return value means \"no style set\" for this coordinate.\n */\nexport const computePopoverPosition = c => c === null || Number.isNaN(c) ? undefined : Math.round(c);"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,2BAA4B;AAI5B,mBAAgC;AAChC,IAAM,wBAAwB;AAAA,EAC5B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,qB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,uBAAmB,UAAU;AAAA,EAC/B,WAAW,WAAW;AAGpB,uBAAmB;AAAA,EACrB,WAAW,YAAY;AAErB,uBAAmB;AAAA,MACjB,wBAAwB;AACtB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,WAAW,eAAe;AAExB,uBAAmB;AAAA,MACjB,wBAAwB;AACtB,cAAM,OAAO,cAAc,wBAAwB;AACnD,eAAO,IAAI,OAAO,QAAQ,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,KAAK,KAAK,KAAK,SAAS,KAAK,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,SAAS,KAAK,GAAG;AAAA,MAChJ;AAAA,IACF;AAAA,EACF,WAAW,0BAA0B;AAGnC,uBAAmB,yBAAyB;AAAA,EAC9C;AAGA,SAAO,oBAAoB;AAC7B;AAWO,IAAM,yBAAyB,OAAK,MAAM,QAAQ,OAAO,MAAM,CAAC,IAAI,SAAY,KAAK,MAAM,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/private-apis.cjs
CHANGED
|
@@ -63,6 +63,7 @@ var privateApis = {};
|
|
|
63
63
|
Picker: import_picker.Picker,
|
|
64
64
|
ValidatedInputControl: import_validated_form_controls.ValidatedInputControl,
|
|
65
65
|
ValidatedCheckboxControl: import_validated_form_controls.ValidatedCheckboxControl,
|
|
66
|
+
ValidatedComboboxControl: import_validated_form_controls.ValidatedComboboxControl,
|
|
66
67
|
ValidatedNumberControl: import_validated_form_controls.ValidatedNumberControl,
|
|
67
68
|
ValidatedSelectControl: import_validated_form_controls.ValidatedSelectControl,
|
|
68
69
|
ValidatedRadioControl: import_validated_form_controls.ValidatedRadioControl,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport { Picker } from './color-picker/picker';\nexport const privateApis = {};\nlock(privateApis, {\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n Picker,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsF;AACtF,kBAAqB;AACrB,qCAAkC;AAClC,mBAAkB;AAClB,kBAAqB;AACrB,qBAA+C;AAC/C,oCAAoC;AACpC,yBAAqB;AACrB,mBAAkB;AAClB,sBAAwD;AACxD,
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport { Picker } from './color-picker/picker';\nexport const privateApis = {};\nlock(privateApis, {\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n Picker,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedComboboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsF;AACtF,kBAAqB;AACrB,qCAAkC;AAClC,mBAAkB;AAClB,kBAAqB;AACrB,qBAA+C;AAC/C,oCAAoC;AACpC,yBAAqB;AACrB,mBAAkB;AAClB,sBAAwD;AACxD,qCAAsQ;AACtQ,8BAAwC;AACxC,oBAAuB;AAChB,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAK,aAAa;AAAA,EAChB,6DAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": ["__experimentalPopoverLegacyPositionToPlacement", "Theme", "Badge"]
|
|
7
7
|
}
|
|
@@ -54,7 +54,7 @@ function UnforwardedRadioGroup({
|
|
|
54
54
|
value: checked,
|
|
55
55
|
defaultValue: defaultChecked,
|
|
56
56
|
setValue: (newValue) => {
|
|
57
|
-
onChange?.(newValue
|
|
57
|
+
onChange?.(newValue ?? void 0);
|
|
58
58
|
},
|
|
59
59
|
rtl: (0, import_i18n.isRTL)()
|
|
60
60
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/radio-group/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo, forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ButtonGroup from '../button-group';\nimport { RadioGroupContext } from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedRadioGroup({\n label,\n checked,\n defaultChecked,\n disabled,\n onChange,\n children,\n ...props\n}, ref) {\n const radioStore = Ariakit.useRadioStore({\n value: checked,\n defaultValue: defaultChecked,\n setValue: newValue => {\n onChange?.(newValue
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAGA,cAAyB;AAKzB,wBAAuB;AACvB,qBAAoC;AACpC,kBAAsB;AAKtB,0BAAwB;AACxB,qBAAkC;AAClC,yBAA4B;AAC5B,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,aAAqB,sBAAc;AAAA,IACvC,OAAO;AAAA,IACP,cAAc;AAAA,IACd,UAAU,cAAY;AACpB,iBAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo, forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ButtonGroup from '../button-group';\nimport { RadioGroupContext } from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedRadioGroup({\n label,\n checked,\n defaultChecked,\n disabled,\n onChange,\n children,\n ...props\n}, ref) {\n const radioStore = Ariakit.useRadioStore({\n value: checked,\n defaultValue: defaultChecked,\n setValue: newValue => {\n onChange?.(newValue ?? undefined);\n },\n rtl: isRTL()\n });\n const contextValue = useMemo(() => ({\n store: radioStore,\n disabled\n }), [radioStore, disabled]);\n deprecated('wp.components.__experimentalRadioGroup', {\n alternative: 'wp.components.RadioControl or wp.components.__experimentalToggleGroupControl',\n since: '6.8'\n });\n return /*#__PURE__*/_jsx(RadioGroupContext.Provider, {\n value: contextValue,\n children: /*#__PURE__*/_jsx(Ariakit.RadioGroup, {\n store: radioStore,\n render: /*#__PURE__*/_jsx(ButtonGroup, {\n __shouldNotWarnDeprecated: true,\n children: children\n }),\n \"aria-label\": label,\n ref: ref,\n ...props\n })\n });\n}\n\n/**\n * @deprecated Use `RadioControl` or `ToggleGroupControl` instead.\n */\nexport const RadioGroup = forwardRef(UnforwardedRadioGroup);\nRadioGroup.displayName = 'RadioGroup';\nexport default RadioGroup;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAAA;AAAA,EAAA;AAAA;AAAA;AAGA,cAAyB;AAKzB,wBAAuB;AACvB,qBAAoC;AACpC,kBAAsB;AAKtB,0BAAwB;AACxB,qBAAkC;AAClC,yBAA4B;AAC5B,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,aAAqB,sBAAc;AAAA,IACvC,OAAO;AAAA,IACP,cAAc;AAAA,IACd,UAAU,cAAY;AACpB,iBAAW,YAAY,MAAS;AAAA,IAClC;AAAA,IACA,SAAK,mBAAM;AAAA,EACb,CAAC;AACD,QAAM,mBAAe,wBAAQ,OAAO;AAAA,IAClC,OAAO;AAAA,IACP;AAAA,EACF,IAAI,CAAC,YAAY,QAAQ,CAAC;AAC1B,wBAAAC,SAAW,0CAA0C;AAAA,IACnD,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AACD,SAAoB,uCAAAC,KAAK,iCAAkB,UAAU;AAAA,IACnD,OAAO;AAAA,IACP,UAAuB,uCAAAA,KAAa,oBAAY;AAAA,MAC9C,OAAO;AAAA,MACP,QAAqB,uCAAAA,KAAK,oBAAAC,SAAa;AAAA,QACrC,2BAA2B;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,MACD,cAAc;AAAA,MACd;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AAKO,IAAMH,kBAAa,2BAAW,qBAAqB;AAC1DA,YAAW,cAAc;AACzB,IAAO,sBAAQA;",
|
|
6
6
|
"names": ["RadioGroup", "deprecated", "_jsx", "ButtonGroup"]
|
|
7
7
|
}
|
|
@@ -105,7 +105,7 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
105
105
|
const [value, setValue] = (0, import_utils2.useControlledRangeValue)({
|
|
106
106
|
min,
|
|
107
107
|
max,
|
|
108
|
-
value: valueProp
|
|
108
|
+
value: valueProp ?? null,
|
|
109
109
|
initial: initialPosition
|
|
110
110
|
});
|
|
111
111
|
const isResetPendent = (0, import_element.useRef)(false);
|
|
@@ -156,9 +156,9 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
158
|
const handleOnReset = () => {
|
|
159
|
-
const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue
|
|
159
|
+
const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;
|
|
160
160
|
setValue(resetValue);
|
|
161
|
-
onChange(resetValue
|
|
161
|
+
onChange(resetValue ?? void 0);
|
|
162
162
|
};
|
|
163
163
|
const handleShowTooltip = () => setShowTooltip(true);
|
|
164
164
|
const handleHideTooltip = () => setShowTooltip(false);
|
|
@@ -214,7 +214,7 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
214
214
|
onMouseLeave,
|
|
215
215
|
ref: (0, import_compose.useMergeRefs)([inputRef, forwardedRef]),
|
|
216
216
|
step,
|
|
217
|
-
value: inputSliderValue
|
|
217
|
+
value: inputSliderValue ?? void 0
|
|
218
218
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_rail.default, {
|
|
219
219
|
"aria-hidden": true,
|
|
220
220
|
disabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp !== null && valueProp !== void 0 ? valueProp : null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef();\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue !== null && resetFallbackValue !== void 0 ? resetFallbackValue : null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue !== null && resetValue !== void 0 ? resetValue : undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue !== null && inputSliderValue !== void 0 ? inputSliderValue : undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAA0B;AAC1B,qBAA6C;AAC7C,qBAA4C;AAK5C,0BAAwB;AACxB,oBAAmB;AACnB,kBAAiB;AACjB,mBAAuB;AACvB,IAAAA,gBAAoD;AACpD,kBAAsB;AACtB,yBAAuB;AACvB,kBAAsB;AACtB,qBAA0B;AAC1B,kCAAgI;AAChI,mBAAsB;AACtB,kCAA4C;AAC5C,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA,IACJ,yBAAyB;AAAA;AAAA,IAEzB;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,OAAO,YAAY,oBAAO,MAAM;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,IACf,cAAc;AAAA,IACd;AAAA,IACA,uBAAuB,OAAK;AAAA,IAC5B;AAAA,IACA,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,CAAC,OAAO,QAAQ,QAAI,uCAAwB;AAAA,IAChD;AAAA,IACA;AAAA,IACA,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef();\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAA0B;AAC1B,qBAA6C;AAC7C,qBAA4C;AAK5C,0BAAwB;AACxB,o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U;AAAA,QACV;AAAA,QACA,MAAM,wBAAwB,qBAAqB;AAAA,QACnD,sBAAsB,4BAAwB,oBAAM,EAAE,QAAI,oBAAM,EAAE;AAAA,QAClE;AAAA,QAGA,OAAO;AAAA,QACP,mCAAmC;AAAA,MACrC,CAAC,GAAG,cAA2B,uCAAAA,KAAK,gDAAoB;AAAA,QACtD,UAAuB,uCAAAA,KAAK,cAAAO,SAAQ;AAAA,UAClC,WAAW;AAAA,UAGX,wBAAwB,CAAC;AAAA,UAKzB,UAAU,YAAY,UAAU,kBAAkB;AAAA,YAChD;AAAA,YACA;AAAA,UACF,CAAC;AAAA,UACD,SAAS;AAAA,UACT,MAAM;AAAA,UACN,SAAS;AAAA,UACT,cAAU,gBAAG,OAAO;AAAA,QACtB,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH;AA0BO,IAAM,mBAAe,2BAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,wBAAQ;",
|
|
6
6
|
"names": ["import_utils", "clsx", "_jsx", "BaseControl", "_jsxs", "Icon", "InputRange", "RangeRail", "SimpleTooltip", "Button"]
|
|
7
7
|
}
|
|
@@ -41,7 +41,7 @@ function useControlledRangeValue(settings) {
|
|
|
41
41
|
initial
|
|
42
42
|
} = settings;
|
|
43
43
|
const [state, setInternalState] = (0, import_hooks.useControlledState)(floatClamp(valueProp, min, max), {
|
|
44
|
-
initial: floatClamp(initial
|
|
44
|
+
initial: floatClamp(initial ?? null, min, max),
|
|
45
45
|
fallback: null
|
|
46
46
|
});
|
|
47
47
|
const setState = (0, import_element.useCallback)((nextValue) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp(value, min, max) {\n if (typeof value !== 'number') {\n return null;\n }\n return parseFloat(`${clamp(value, min, max)}`);\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(settings) {\n const {\n min,\n max,\n value: valueProp,\n initial\n } = settings;\n const [state, setInternalState] = useControlledState(floatClamp(valueProp, min, max), {\n initial: floatClamp(initial
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAK5B,mBAAmC;AACnC,kBAAsB;AAUf,SAAS,WAAW,OAAO,KAAK,KAAK;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,WAAW,OAAG,mBAAM,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/C;AAQO,SAAS,wBAAwB,UAAU;AAChD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,OAAO,gBAAgB,QAAI,iCAAmB,WAAW,WAAW,KAAK,GAAG,GAAG;AAAA,IACpF,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp(value, min, max) {\n if (typeof value !== 'number') {\n return null;\n }\n return parseFloat(`${clamp(value, min, max)}`);\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(settings) {\n const {\n min,\n max,\n value: valueProp,\n initial\n } = settings;\n const [state, setInternalState] = useControlledState(floatClamp(valueProp, min, max), {\n initial: floatClamp(initial ?? null, min, max),\n fallback: null\n });\n const setState = useCallback(nextValue => {\n if (nextValue === null) {\n setInternalState(null);\n } else {\n setInternalState(floatClamp(nextValue, min, max));\n }\n }, [min, max, setInternalState]);\n\n // `state` can't be an empty string because we specified a fallback value of\n // `null` in `useControlledState`\n return [state, setState];\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAK5B,mBAAmC;AACnC,kBAAsB;AAUf,SAAS,WAAW,OAAO,KAAK,KAAK;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,WAAW,OAAG,mBAAM,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/C;AAQO,SAAS,wBAAwB,UAAU;AAChD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,OAAO,gBAAgB,QAAI,iCAAmB,WAAW,WAAW,KAAK,GAAG,GAAG;AAAA,IACpF,SAAS,WAAW,WAAW,MAAM,KAAK,GAAG;AAAA,IAC7C,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,eAAW,4BAAY,eAAa;AACxC,QAAI,cAAc,MAAM;AACtB,uBAAiB,IAAI;AAAA,IACvB,OAAO;AACL,uBAAiB,WAAW,WAAW,KAAK,GAAG,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,KAAK,KAAK,gBAAgB,CAAC;AAI/B,SAAO,CAAC,OAAO,QAAQ;AACzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -69,7 +69,7 @@ function SuffixItem({
|
|
|
69
69
|
size: "small",
|
|
70
70
|
icon: import_icons.closeSmall,
|
|
71
71
|
label: onClose ? (0, import_i18n.__)("Close search") : (0, import_i18n.__)("Reset search"),
|
|
72
|
-
onClick: onClose
|
|
72
|
+
onClick: onClose ?? onReset
|
|
73
73
|
})
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -101,10 +101,10 @@ function UnforwardedSearchControl({
|
|
|
101
101
|
type: "search",
|
|
102
102
|
size,
|
|
103
103
|
className: (0, import_clsx.default)("components-search-control", className),
|
|
104
|
-
onChange: (nextValue) => onChange(nextValue
|
|
104
|
+
onChange: (nextValue) => onChange(nextValue ?? ""),
|
|
105
105
|
autoComplete: "off",
|
|
106
106
|
placeholder,
|
|
107
|
-
value: value
|
|
107
|
+
value: value ?? "",
|
|
108
108
|
prefix: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input_prefix_wrapper.InputControlPrefixWrapper, {
|
|
109
109
|
variant: "icon",
|
|
110
110
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledIcon, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/search-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport { StyledInputControl, StyledIcon } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n value,\n onChange,\n onClose\n}) {\n if (!onClose && !value) {\n return null;\n }\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,qBAA4C;AAC5C,kBAAmB;AACnB,mBAAmC;AACnC,qBAAmC;AACnC,wBAAuB;AAKvB,oBAAmB;AACnB,kCAA0C;AAC1C,kCAA0C;AAC1C,oBAA+C;AAC/C,yBAA4B;AAC5B,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,MAAI,CAAC,WAAW,CAAC,OAAO;AACtB,WAAO;AAAA,EACT;AACA,MAAI,SAAS;AACX,0BAAAA,SAAW,iDAAiD;AAAA,MAC1D,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,QAAM,UAAU,MAAM;AACpB,aAAS,EAAE;AACX,cAAU,SAAS,MAAM;AAAA,EAC3B;AACA,SAAoB,uCAAAC,KAAK,uDAA2B;AAAA,IAClD,SAAS;AAAA,IACT,UAAuB,uCAAAA,KAAK,cAAAC,SAAQ;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,cAAU,gBAAG,cAAc,QAAI,gBAAG,cAAc;AAAA,MACvD,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport { StyledInputControl, StyledIcon } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n value,\n onChange,\n onClose\n}) {\n if (!onClose && !value) {\n return null;\n }\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose ?? onReset\n })\n });\n}\nfunction UnforwardedSearchControl({\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n className,\n onChange,\n value,\n label = __('Search'),\n placeholder = __('Search'),\n hideLabelFromVision = true,\n onClose,\n size = 'default',\n ...restProps\n}, forwardedRef) {\n // @ts-expect-error The `disabled` prop is not yet supported in the SearchControl component.\n // Work with the design team (@WordPress/gutenberg-design) if you need this feature.\n const {\n disabled,\n ...filteredRestProps\n } = restProps;\n const searchRef = useRef(null);\n const instanceId = useInstanceId(SearchControl, 'components-search-control');\n return /*#__PURE__*/_jsx(StyledInputControl, {\n __next40pxDefaultSize: true,\n id: instanceId,\n hideLabelFromVision: hideLabelFromVision,\n label: label,\n ref: useMergeRefs([searchRef, forwardedRef]),\n type: \"search\",\n size: size,\n className: clsx('components-search-control', className),\n onChange: nextValue => onChange(nextValue ?? ''),\n autoComplete: \"off\",\n placeholder: placeholder,\n value: value ?? '',\n prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {\n variant: \"icon\",\n children: /*#__PURE__*/_jsx(StyledIcon, {\n icon: search,\n fill: \"currentColor\"\n })\n }),\n suffix: /*#__PURE__*/_jsx(SuffixItem, {\n searchRef: searchRef,\n value: value,\n onChange: onChange,\n onClose: onClose\n }),\n ...filteredRestProps\n });\n}\n\n/**\n * SearchControl components let users display a search control.\n *\n * ```jsx\n * import { SearchControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function MySearchControl( { className, setState } ) {\n * const [ searchInput, setSearchInput ] = useState( '' );\n *\n * return (\n * <SearchControl\n * value={ searchInput }\n * onChange={ setSearchInput }\n * />\n * );\n * }\n * ```\n */\nexport const SearchControl = forwardRef(UnforwardedSearchControl);\nSearchControl.displayName = 'SearchControl';\nexport default SearchControl;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,qBAA4C;AAC5C,kBAAmB;AACnB,mBAAmC;AACnC,qBAAmC;AACnC,wBAAuB;AAKvB,oBAAmB;AACnB,kCAA0C;AAC1C,kCAA0C;AAC1C,oBAA+C;AAC/C,yBAA4B;AAC5B,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,MAAI,CAAC,WAAW,CAAC,OAAO;AACtB,WAAO;AAAA,EACT;AACA,MAAI,SAAS;AACX,0BAAAA,SAAW,iDAAiD;AAAA,MAC1D,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,QAAM,UAAU,MAAM;AACpB,aAAS,EAAE;AACX,cAAU,SAAS,MAAM;AAAA,EAC3B;AACA,SAAoB,uCAAAC,KAAK,uDAA2B;AAAA,IAClD,SAAS;AAAA,IACT,UAAuB,uCAAAA,KAAK,cAAAC,SAAQ;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,cAAU,gBAAG,cAAc,QAAI,gBAAG,cAAc;AAAA,MACvD,SAAS,WAAW;AAAA,IACtB,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,yBAAyB;AAAA,EAChC,yBAAyB;AAAA;AAAA,EAEzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAQ,gBAAG,QAAQ;AAAA,EACnB,kBAAc,gBAAG,QAAQ;AAAA,EACzB,sBAAsB;AAAA,EACtB;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAG,cAAc;AAGf,QAAM;AAAA,IACJ;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,gBAAY,uBAAO,IAAI;AAC7B,QAAM,iBAAa,8BAAc,eAAe,2BAA2B;AAC3E,SAAoB,uCAAAD,KAAK,kCAAoB;AAAA,IAC3C,uBAAuB;AAAA,IACvB,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAK,6BAAa,CAAC,WAAW,YAAY,CAAC;AAAA,IAC3C,MAAM;AAAA,IACN;AAAA,IACA,eAAW,YAAAE,SAAK,6BAA6B,SAAS;AAAA,IACtD,UAAU,eAAa,SAAS,aAAa,EAAE;AAAA,IAC/C,cAAc;AAAA,IACd;AAAA,IACA,OAAO,SAAS;AAAA,IAChB,QAAqB,uCAAAF,KAAK,uDAA2B;AAAA,MACnD,SAAS;AAAA,MACT,UAAuB,uCAAAA,KAAK,0BAAY;AAAA,QACtC,MAAM;AAAA,QACN,MAAM;AAAA,MACR,CAAC;AAAA,IACH,CAAC;AAAA,IACD,QAAqB,uCAAAA,KAAK,YAAY;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;AAqBO,IAAM,oBAAgB,2BAAW,wBAAwB;AAChE,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
|
|
6
6
|
"names": ["deprecated", "_jsx", "Button", "clsx"]
|
|
7
7
|
}
|
package/build/slot-fill/fill.cjs
CHANGED
|
@@ -42,7 +42,6 @@ function Fill({
|
|
|
42
42
|
name,
|
|
43
43
|
children
|
|
44
44
|
}) {
|
|
45
|
-
var _slot$fillProps;
|
|
46
45
|
const registry = (0, import_element.useContext)(import_context.default);
|
|
47
46
|
const instanceRef = (0, import_element.useRef)({});
|
|
48
47
|
const childrenRef = (0, import_element.useRef)(children);
|
|
@@ -74,7 +73,7 @@ function Fill({
|
|
|
74
73
|
if (!portalEl) {
|
|
75
74
|
return null;
|
|
76
75
|
}
|
|
77
|
-
const wrappedChildren = typeof children === "function" ? children(
|
|
76
|
+
const wrappedChildren = typeof children === "function" ? children(slot.fillProps ?? {}) : children;
|
|
78
77
|
return (0, import_element.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_style_provider.default, {
|
|
79
78
|
document: portalEl.ownerDocument,
|
|
80
79
|
children: wrappedChildren
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/slot-fill/fill.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport StyleProvider from '../style-provider';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function Fill({\n name,\n children\n}) {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAAkE;AAKlE,qBAA4B;AAC5B,4BAA0B;AAC1B,yBAA4B;AACb,SAAR,KAAsB;AAAA,EAC3B;AAAA,EACA;AACF,GAAG;AACD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useObservableValue } from '@wordpress/compose';\nimport { useContext, useLayoutEffect, useRef, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport StyleProvider from '../style-provider';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default function Fill({\n name,\n children\n}) {\n const registry = useContext(SlotFillContext);\n const instanceRef = useRef({});\n const childrenRef = useRef(children);\n useLayoutEffect(() => {\n childrenRef.current = children;\n }, [children]);\n useLayoutEffect(() => {\n const instance = instanceRef.current;\n registry.registerFill(name, {\n instance,\n children: childrenRef.current\n });\n return () => registry.unregisterFill(name, instance);\n }, [registry, name]);\n useLayoutEffect(() => {\n registry.updateFill(name, {\n instance: instanceRef.current,\n children: childrenRef.current\n });\n });\n const slot = useObservableValue(registry.slots, name);\n if (!slot) {\n return null;\n }\n if (slot.type === 'children') {\n return null;\n }\n const portalEl = slot.ref.current;\n if (!portalEl) {\n return null;\n }\n const wrappedChildren = typeof children === 'function' ? children(slot.fillProps ?? {}) : children;\n\n // When using a `Fill`, the `children` will be rendered in the document of the\n // `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n // to make sure we're referencing the right document/iframe (instead of the\n // context of the `Fill`'s parent).\n return createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: portalEl.ownerDocument,\n children: wrappedChildren\n }), portalEl);\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAAkE;AAKlE,qBAA4B;AAC5B,4BAA0B;AAC1B,yBAA4B;AACb,SAAR,KAAsB;AAAA,EAC3B;AAAA,EACA;AACF,GAAG;AACD,QAAM,eAAW,2BAAW,eAAAA,OAAe;AAC3C,QAAM,kBAAc,uBAAO,CAAC,CAAC;AAC7B,QAAM,kBAAc,uBAAO,QAAQ;AACnC,sCAAgB,MAAM;AACpB,gBAAY,UAAU;AAAA,EACxB,GAAG,CAAC,QAAQ,CAAC;AACb,sCAAgB,MAAM;AACpB,UAAM,WAAW,YAAY;AAC7B,aAAS,aAAa,MAAM;AAAA,MAC1B;AAAA,MACA,UAAU,YAAY;AAAA,IACxB,CAAC;AACD,WAAO,MAAM,SAAS,eAAe,MAAM,QAAQ;AAAA,EACrD,GAAG,CAAC,UAAU,IAAI,CAAC;AACnB,sCAAgB,MAAM;AACpB,aAAS,WAAW,MAAM;AAAA,MACxB,UAAU,YAAY;AAAA,MACtB,UAAU,YAAY;AAAA,IACxB,CAAC;AAAA,EACH,CAAC;AACD,QAAM,WAAO,mCAAmB,SAAS,OAAO,IAAI;AACpD,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,MAAI,KAAK,SAAS,YAAY;AAC5B,WAAO;AAAA,EACT;AACA,QAAM,WAAW,KAAK,IAAI;AAC1B,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,kBAAkB,OAAO,aAAa,aAAa,SAAS,KAAK,aAAa,CAAC,CAAC,IAAI;AAM1F,aAAO,6BAA0B,uCAAAC,KAAK,sBAAAC,SAAe;AAAA,IACnD,UAAU,SAAS;AAAA,IACnB,UAAU;AAAA,EACZ,CAAC,GAAG,QAAQ;AACd;",
|
|
6
6
|
"names": ["SlotFillContext", "_jsx", "StyleProvider"]
|
|
7
7
|
}
|
package/build/slot-fill/slot.cjs
CHANGED
|
@@ -55,7 +55,6 @@ function addKeysToChildren(children) {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
function Slot(props) {
|
|
58
|
-
var _useObservableValue;
|
|
59
58
|
const {
|
|
60
59
|
name,
|
|
61
60
|
children,
|
|
@@ -71,7 +70,7 @@ function Slot(props) {
|
|
|
71
70
|
});
|
|
72
71
|
return () => registry.unregisterSlot(name, instance);
|
|
73
72
|
}, [registry, name]);
|
|
74
|
-
let fills = (
|
|
73
|
+
let fills = (0, import_compose.useObservableValue)(registry.fills, name) ?? [];
|
|
75
74
|
const currentSlot = (0, import_compose.useObservableValue)(registry.slots, name);
|
|
76
75
|
if (!currentSlot || currentSlot.instance !== instanceRef.current) {
|
|
77
76
|
fills = [];
|