@namroodinc/liquid-editorial 0.3.1 → 0.3.3
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/README.md +1568 -139
- package/UPGRADING.md +131 -0
- package/dist/chunks/{Board-BUJ5CinL.cjs → Board-BaQ04nWg.cjs} +2 -2
- package/dist/chunks/Board-BaQ04nWg.cjs.map +1 -0
- package/dist/chunks/{Board-Cyrda2qG.js → Board-CUhF8pTX.js} +2 -2
- package/dist/chunks/Board-CUhF8pTX.js.map +1 -0
- package/dist/chunks/ColourField-Bd4twbaG.js +499 -0
- package/dist/chunks/ColourField-Bd4twbaG.js.map +1 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs +2 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs.map +1 -0
- package/dist/chunks/FormEditor-DRmPFe2E.js.map +1 -1
- package/dist/chunks/FormEditor-PVkvKep1.cjs.map +1 -1
- package/dist/chunks/{Icon-CW6qJcDy.cjs → Icon-BBoWP_Y6.cjs} +2 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +1 -0
- package/dist/chunks/{Icon-ByUB0L1a.js → Icon-XNismJDm.js} +21 -20
- package/dist/chunks/Icon-XNismJDm.js.map +1 -0
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +1 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +1 -1
- package/dist/chunks/binding-Bshy43sG.js.map +1 -1
- package/dist/chunks/binding-tMjrUzkU.cjs.map +1 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +2 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +1 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js +48 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +1 -0
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +1 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +1 -1
- package/dist/chunks/group-CzbacuAY.js.map +1 -1
- package/dist/chunks/group-pKDQtq-9.cjs.map +1 -1
- package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs.map +1 -1
- package/dist/chunks/mergeRefs-DGM402mE.js.map +1 -1
- package/dist/chunks/observeElementWidth-BCJM2FAw.cjs.map +1 -1
- package/dist/chunks/observeElementWidth-BlQOlW2t.js.map +1 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.d.cts.map +1 -1
- package/dist/components/AppShell/index.d.ts.map +1 -1
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.d.cts.map +1 -1
- package/dist/components/Board/index.d.ts.map +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Board/keyboard.d.cts.map +1 -1
- package/dist/components/Board/keyboard.d.ts.map +1 -1
- package/dist/components/Board/moves.d.cts.map +1 -1
- package/dist/components/Board/moves.d.ts.map +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/ColourField/colour.d.cts +12 -0
- package/dist/components/ColourField/colour.d.cts.map +1 -0
- package/dist/components/ColourField/colour.d.ts +12 -0
- package/dist/components/ColourField/colour.d.ts.map +1 -0
- package/dist/components/ColourField/focus.d.cts +3 -0
- package/dist/components/ColourField/focus.d.cts.map +1 -0
- package/dist/components/ColourField/focus.d.ts +3 -0
- package/dist/components/ColourField/focus.d.ts.map +1 -0
- package/dist/components/ColourField/index.cjs +1 -0
- package/dist/components/ColourField/index.d.cts +15 -0
- package/dist/components/ColourField/index.d.cts.map +1 -0
- package/dist/components/ColourField/index.d.ts +15 -0
- package/dist/components/ColourField/index.d.ts.map +1 -0
- package/dist/components/ColourField/index.js +1 -0
- package/dist/components/ColourField/panel.d.cts +21 -0
- package/dist/components/ColourField/panel.d.cts.map +1 -0
- package/dist/components/ColourField/panel.d.ts +21 -0
- package/dist/components/ColourField/panel.d.ts.map +1 -0
- package/dist/components/ColourField/square.d.cts +9 -0
- package/dist/components/ColourField/square.d.cts.map +1 -0
- package/dist/components/ColourField/square.d.ts +9 -0
- package/dist/components/ColourField/square.d.ts.map +1 -0
- package/dist/components/ColourField/style.css +266 -0
- package/dist/components/ColourField/value.d.cts +13 -0
- package/dist/components/ColourField/value.d.cts.map +1 -0
- package/dist/components/ColourField/value.d.ts +13 -0
- package/dist/components/ColourField/value.d.ts.map +1 -0
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.cjs.map +1 -1
- package/dist/components/DatePicker/index.d.cts +6 -2
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +6 -2
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +45 -42
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +69 -73
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +69 -56
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/Field/binding.d.cts.map +1 -1
- package/dist/components/Field/binding.d.ts.map +1 -1
- package/dist/components/Field/group.d.cts.map +1 -1
- package/dist/components/Field/group.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.cjs +1 -1
- package/dist/components/FieldAffix/index.cjs.map +1 -1
- package/dist/components/FieldAffix/index.d.cts +3 -1
- package/dist/components/FieldAffix/index.d.cts.map +1 -1
- package/dist/components/FieldAffix/index.d.ts +3 -1
- package/dist/components/FieldAffix/index.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.js +20 -16
- package/dist/components/FieldAffix/index.js.map +1 -1
- package/dist/components/FieldAffix/style.css +1 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/Icon/icons.d.cts +1 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +1 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.d.cts.map +1 -1
- package/dist/components/ImageCropper/index.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +40 -48
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/Pagination/index.cjs.map +1 -1
- package/dist/components/Pagination/index.d.cts.map +1 -1
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/components/Pagination/index.js.map +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +52 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts.map +1 -1
- package/dist/components/SideNav/index.d.ts.map +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/Slider/index.cjs.map +1 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.d.cts.map +1 -1
- package/dist/components/TagsInput/index.d.ts.map +1 -1
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/Time/index.cjs.map +1 -1
- package/dist/components/Time/index.d.cts.map +1 -1
- package/dist/components/Time/index.d.ts.map +1 -1
- package/dist/components/Time/index.js.map +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/internal/dialogFocus.d.cts +17 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -0
- package/dist/internal/dialogFocus.d.ts +17 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -0
- package/dist/internal/dialogStack.d.cts.map +1 -1
- package/dist/internal/dialogStack.d.ts.map +1 -1
- package/dist/internal/lockBodyScroll.d.cts.map +1 -1
- package/dist/internal/lockBodyScroll.d.ts.map +1 -1
- package/dist/internal/mergeRefs.d.cts.map +1 -1
- package/dist/internal/mergeRefs.d.ts.map +1 -1
- package/dist/internal/observeElementWidth.d.cts.map +1 -1
- package/dist/internal/observeElementWidth.d.ts.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +3 -2
- package/dist/chunks/Board-BUJ5CinL.cjs.map +0 -1
- package/dist/chunks/Board-Cyrda2qG.js.map +0 -1
- package/dist/chunks/Icon-ByUB0L1a.js.map +0 -1
- package/dist/chunks/Icon-CW6qJcDy.cjs.map +0 -1
- package/dist/components/Board/keyboard.test.d.cts +0 -2
- package/dist/components/Board/keyboard.test.d.cts.map +0 -1
- package/dist/components/Board/keyboard.test.d.ts +0 -2
- package/dist/components/Board/keyboard.test.d.ts.map +0 -1
- package/dist/components/Board/moves.test.d.cts +0 -2
- package/dist/components/Board/moves.test.d.cts.map +0 -1
- package/dist/components/Board/moves.test.d.ts +0 -2
- package/dist/components/Board/moves.test.d.ts.map +0 -1
- package/dist/test/dragEvent.d.cts +0 -3
- package/dist/test/dragEvent.d.cts.map +0 -1
- package/dist/test/dragEvent.d.ts +0 -3
- package/dist/test/dragEvent.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useGroupBinding","cx","parts","NumberField","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","inputRef","useRef","commit","useCallback","next","onValueChange","nudge","min","direction","step","max","outOfRange","className","size","hasSteppers","Button","decreaseLabel","isDisabled","disabled","FieldAffix","prefix","suffix","node","ref","isInvalid","raw","event","increaseLabel","NumberRangeField","binding","crossed","attributes","minLabel","maxLabel"],"sources":["../../../src/components/NumberField/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useRef,\n useState,\n type InputHTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport { useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"prefix\"\n> {\n size?: FieldSize;\n value?: number | \"\";\n defaultValue?: number | \"\";\n onValueChange?: (value: number | \"\") => void;\n min?: number;\n max?: number;\n step?: number | \"any\";\n /** Rendered inside the field, before the number — \"£\", \"$\", a glyph. */\n prefix?: ReactNode;\n /** Rendered inside the field, after the number — \"kg\", \"%\", \"px\". */\n suffix?: ReactNode;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Hide the − / + steppers and keep typing only. */\n hasSteppers?: boolean;\n /** Stepper names. Include the field's label when a form has several number fields. */\n decreaseLabel?: string;\n increaseLabel?: string;\n}\n\n/**\n * A quantity, bounded by `min` and `max`. Steppers move by `step` and stop at\n * the bounds; typing is never blocked, an out-of-range value reads invalid.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n size = \"md\",\n value,\n defaultValue = \"\",\n onValueChange,\n min,\n max,\n step = 1,\n prefix,\n suffix,\n\n isDisabled = false,\n isInvalid = false,\n hasSteppers = true,\n decreaseLabel = \"Decrease\",\n increaseLabel = \"Increase\",\n className,\n disabled,\n \"aria-invalid\": ariaInvalid,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<number | \"\">(defaultValue);\n const current = value ?? internal;\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = useCallback(\n (next: number | \"\") => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n },\n [onValueChange, value],\n );\n\n const nudge = (direction: 1 | -1) => {\n const base = current === \"\" ? (min ?? 0) : current;\n let next = base + direction * (step === \"any\" ? 1 : step);\n if (min !== undefined) next = Math.max(min, next);\n if (max !== undefined) next = Math.min(max, next);\n next = Number(next.toFixed(10));\n commit(next);\n inputRef.current?.focus();\n };\n\n const outOfRange =\n current !== \"\" &&\n ((min !== undefined && current < min) || (max !== undefined && current > max));\n\n return (\n <div\n className={cx(\"ds-number\", className)}\n data-size={size}\n >\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"minus\"\n className=\"ds-number__step\"\n aria-label={decreaseLabel}\n isDisabled={\n isDisabled || disabled || (min !== undefined && current !== \"\" && current <= min)\n }\n onClick={() => nudge(-1)}\n />\n )}\n <FieldAffix\n className=\"ds-number__body\"\n lead={prefix}\n trail={suffix}\n >\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"number\"\n inputMode=\"decimal\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={isDisabled || disabled}\n aria-invalid={isInvalid || outOfRange || ariaInvalid || undefined}\n data-size={size}\n className=\"ds-field-skin ds-number__input\"\n onChange={(event) => {\n const raw = event.target.value;\n commit(raw === \"\" ? \"\" : Number(raw));\n }}\n {...rest}\n />\n </FieldAffix>\n\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"plus\"\n className=\"ds-number__step\"\n aria-label={increaseLabel}\n isDisabled={\n isDisabled || disabled || (max !== undefined && current !== \"\" && current >= max)\n }\n onClick={() => nudge(1)}\n />\n )}\n </div>\n );\n});\n\nexport interface NumberRangeValue {\n min: number | \"\";\n max: number | \"\";\n}\n\nexport interface NumberRangeFieldProps extends FieldBinding {\n className?: string;\n value?: NumberRangeValue;\n defaultValue?: NumberRangeValue;\n onValueChange?: (value: NumberRangeValue) => void;\n size?: FieldSize;\n /** Hard bounds both ends are clamped to. */\n min?: number;\n max?: number;\n step?: number;\n /** Rendered inside both fields, before the number. */\n prefix?: ReactNode;\n suffix?: ReactNode;\n isDisabled?: boolean;\n minLabel?: string;\n maxLabel?: string;\n}\n\n/**\n * A lower and an upper bound, typed. The pair reads invalid when the minimum\n * passes the maximum — neither field is rewritten behind the user.\n */\nexport function NumberRangeField({\n value,\n defaultValue = { min: \"\", max: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n step = 1,\n prefix,\n suffix,\n isDisabled = false,\n minLabel = \"Minimum\",\n maxLabel = \"Maximum\",\n className,\n ...binding\n}: NumberRangeFieldProps) {\n const [internal, setInternal] = useState<NumberRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: NumberRangeValue) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const crossed = current.min !== \"\" && current.max !== \"\" && current.min > current.max;\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-number-range\", className)}\n >\n <NumberField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={minLabel}\n size={size}\n value={current.min}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, min: next })}\n />\n <span\n className=\"ds-number-range__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <NumberField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={maxLabel}\n size={size}\n value={current.max}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, max: next })}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAeA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AA8BA,IAAaC,IAAcC,EAA+C,SACxE,EACE,UAAO,MACP,UACA,kBAAe,IACf,kBACA,QACA,QACA,UAAO,GACP,WACA,WAEA,gBAAa,IACb,eAAY,IACZ,iBAAc,IACd,mBAAgB,YAChB,mBAAgB,YAChB,cACA,aACA,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAsBC,CAAY,GAC5DC,IAAUC,KAASL,GACnBM,IAAWC,EAAgC,IAAI,GAE/CC,IAASC,GACZ,MAAsB;EAErB,AADIJ,MAAU,KAAA,KAAWJ,EAAYS,CAAI,GACzCC,IAAgBD,CAAI;CACtB,GACA,CAACC,GAAeN,CAAK,CACvB,GAEMO,KAAS,MAAsB;EAEnC,IAAIF,KADSN,MAAY,KAAMS,KAAO,IAAKT,KACzBU,KAAaC,MAAS,QAAQ,IAAIA;EAKpD,AAJIF,MAAQ,KAAA,MAAW,IAAO,KAAK,IAAIA,GAAKH,CAAI,IAC5CM,MAAQ,KAAA,MAAW,IAAO,KAAK,IAAIA,GAAKN,CAAI,IAChD,IAAO,OAAOA,EAAK,QAAQ,EAAE,CAAC,GAC9BF,EAAOE,CAAI,GACXJ,EAAS,SAAS,MAAM;CAC1B,GAEMW,IACJb,MAAY,OACVS,MAAQ,KAAA,KAAaT,IAAUS,KAASG,MAAQ,KAAA,KAAaZ,IAAUY;CAE3E,OACE,kBAAC,OAAD;EACE,WAAWtB,EAAG,aAAawB,CAAS;EACpC,aAAWC;EAFb,UAAA;GAIGC,KACC,kBAACC,GAAD;IACQ;IACN,YAA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MA,EAAQ,KAC5E,EAAE,kBAAeX,EAAgB0C,CAAO;CAE9C,OACE,kBAAC,OAAD;EACE,GAAIE;EACJ,WAAW3C,EAAG,mBAAmBwB,CAAS;EAF5C,UAAA;GAIE,kBAACtB,GAAD;IACE,gBAAcuC,EAAQ;IACtB,cAAYG;IACN;IACN,OAAOlC,EAAQ;IACV;IACA;IACC;IACE;IACA;IACI;IACZ,WAAWgC;IACX,gBAAgB,MAAS5B,EAAO;KAAE,GAAGJ;KAAS,KAAKM;IAAK,CAAC;GAC1D,CAAA;GACD,kBAAC,QAAD;IACE,WAAU;IACV,eAAY;IACb,UAAA;GAEK,CAAA;GACN,kBAACd,GAAD;IACE,gBAAcuC,EAAQ;IACtB,cAAYI;IACN;IACN,OAAOnC,EAAQ;IACV;IACA;IACC;IACE;IACA;IACI;IACZ,WAAWgC;IACX,gBAAgB,MAAS5B,EAAO;KAAE,GAAGJ;KAAS,KAAKM;IAAK,CAAC;GAC1D,CAAA;EACE;;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useGroupBinding","cx","parts","NumberField","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","inputRef","useRef","commit","useCallback","next","onValueChange","nudge","min","direction","step","max","outOfRange","className","size","hasSteppers","Button","decreaseLabel","isDisabled","disabled","FieldAffix","prefix","suffix","node","ref","isInvalid","raw","event","increaseLabel","NumberRangeField","binding","crossed","attributes","minLabel","maxLabel"],"sources":["../../../src/components/NumberField/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useRef,\n useState,\n type InputHTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport { useGroupBinding } from \"../Field/binding\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"prefix\"\n> {\n size?: FieldSize;\n value?: number | \"\";\n defaultValue?: number | \"\";\n onValueChange?: (value: number | \"\") => void;\n min?: number;\n max?: number;\n step?: number | \"any\";\n /** Rendered inside the field, before the number — \"£\", \"$\", a glyph. */\n prefix?: ReactNode;\n /** Rendered inside the field, after the number — \"kg\", \"%\", \"px\". */\n suffix?: ReactNode;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Hide the − / + steppers and keep typing only. */\n hasSteppers?: boolean;\n /** Stepper names. Include the field's label when a form has several number fields. */\n decreaseLabel?: string;\n increaseLabel?: string;\n}\n\n/**\n * A quantity, bounded by `min` and `max`. Steppers move by `step` and stop at\n * the bounds; typing is never blocked, an out-of-range value reads invalid.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n size = \"md\",\n value,\n defaultValue = \"\",\n onValueChange,\n min,\n max,\n step = 1,\n prefix,\n suffix,\n\n isDisabled = false,\n isInvalid = false,\n hasSteppers = true,\n decreaseLabel = \"Decrease\",\n increaseLabel = \"Increase\",\n className,\n disabled,\n \"aria-invalid\": ariaInvalid,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<number | \"\">(defaultValue);\n const current = value ?? internal;\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = useCallback(\n (next: number | \"\") => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n },\n [onValueChange, value],\n );\n\n const nudge = (direction: 1 | -1) => {\n const base = current === \"\" ? (min ?? 0) : current;\n let next = base + direction * (step === \"any\" ? 1 : step);\n if (min !== undefined) {\n next = Math.max(min, next);\n }\n if (max !== undefined) {\n next = Math.min(max, next);\n }\n next = Number(next.toFixed(10));\n commit(next);\n inputRef.current?.focus();\n };\n\n const outOfRange =\n current !== \"\" &&\n ((min !== undefined && current < min) || (max !== undefined && current > max));\n\n return (\n <div\n className={cx(\"ds-number\", className)}\n data-size={size}\n >\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"minus\"\n className=\"ds-number__step\"\n aria-label={decreaseLabel}\n isDisabled={\n isDisabled || disabled || (min !== undefined && current !== \"\" && current <= min)\n }\n onClick={() => nudge(-1)}\n />\n )}\n <FieldAffix\n className=\"ds-number__body\"\n lead={prefix}\n trail={suffix}\n >\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"number\"\n inputMode=\"decimal\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={isDisabled || disabled}\n aria-invalid={isInvalid || outOfRange || ariaInvalid || undefined}\n data-size={size}\n className=\"ds-field-skin ds-number__input\"\n onChange={(event) => {\n const raw = event.target.value;\n commit(raw === \"\" ? \"\" : Number(raw));\n }}\n {...rest}\n />\n </FieldAffix>\n\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"plus\"\n className=\"ds-number__step\"\n aria-label={increaseLabel}\n isDisabled={\n isDisabled || disabled || (max !== undefined && current !== \"\" && current >= max)\n }\n onClick={() => nudge(1)}\n />\n )}\n </div>\n );\n});\n\nexport interface NumberRangeValue {\n min: number | \"\";\n max: number | \"\";\n}\n\nexport interface NumberRangeFieldProps extends FieldBinding {\n className?: string;\n value?: NumberRangeValue;\n defaultValue?: NumberRangeValue;\n onValueChange?: (value: NumberRangeValue) => void;\n size?: FieldSize;\n /** Hard bounds both ends are clamped to. */\n min?: number;\n max?: number;\n step?: number;\n /** Rendered inside both fields, before the number. */\n prefix?: ReactNode;\n suffix?: ReactNode;\n isDisabled?: boolean;\n minLabel?: string;\n maxLabel?: string;\n}\n\n/**\n * A lower and an upper bound, typed. The pair reads invalid when the minimum\n * passes the maximum — neither field is rewritten behind the user.\n */\nexport function NumberRangeField({\n value,\n defaultValue = { min: \"\", max: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n step = 1,\n prefix,\n suffix,\n isDisabled = false,\n minLabel = \"Minimum\",\n maxLabel = \"Maximum\",\n className,\n ...binding\n}: NumberRangeFieldProps) {\n const [internal, setInternal] = useState<NumberRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: NumberRangeValue) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const crossed = current.min !== \"\" && current.max !== \"\" && current.min > current.max;\n const { attributes } = useGroupBinding(binding);\n\n return (\n <div\n {...attributes}\n className={cx(\"ds-number-range\", className)}\n >\n <NumberField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={minLabel}\n size={size}\n value={current.min}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, min: next })}\n />\n <span\n className=\"ds-number-range__dash\"\n aria-hidden=\"true\"\n >\n –\n </span>\n <NumberField\n aria-invalid={binding[\"aria-invalid\"]}\n aria-label={maxLabel}\n size={size}\n value={current.max}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, max: next })}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAeA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AA8BA,IAAaC,IAAcC,EAA+C,SACxE,EACE,UAAO,MACP,UACA,kBAAe,IACf,kBACA,QACA,QACA,UAAO,GACP,WACA,WAEA,gBAAa,IACb,eAAY,IACZ,iBAAc,IACd,mBAAgB,YAChB,mBAAgB,YAChB,cACA,aACA,gBAAgBC,GAChB,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAsBC,CAAY,GAC5DC,IAAUC,KAASL,GACnBM,IAAWC,EAAgC,IAAI,GAE/CC,IAASC,GACZ,MAAsB;EA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CAAA;EACE;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useId","Button","Select","require_components_Button_index","require_components_Select_index","react","react_jsx_runtime","Pagination","rest","labelId","pageCount","totalResults","pageSize","currentPage","page","disabled","isDisabled","atStart","atEnd","start","end","go","next","nextPage","onChange","size","className","showLabels","pageSizeOptions","value","nextSize","nextPageCount"],"sources":["../../../src/components/Pagination/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Select } from \"../Select\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport \"./style.css\";\n\nexport type PaginationSize = \"sm\" | \"md\";\n\nexport interface PaginationState {\n /** One-based page number. */\n page: number;\n /** Positive integer results per page. */\n pageSize: number;\n}\n\nexport interface PaginationProps\n extends Omit<HTMLAttributes<HTMLElement>, \"children\" | \"onChange\">, PaginationState {\n /** Total number of matching results, before pagination. */\n totalResults: number;\n /** Emitted once per user change, with both values ready to apply together. */\n onChange: (next: PaginationState) => void;\n /** Nonempty list of positive integers containing the current pageSize. */\n pageSizeOptions?: number[];\n size?: PaginationSize;\n isDisabled?: boolean;\n showLabels?: boolean;\n menuPlacement?: PopoverPlacement;\n}\n\n/** Controlled navigation for a result set. Data loading and slicing belong to the application. */\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(function Pagination(\n {\n totalResults,\n page,\n pageSize,\n onChange,\n pageSizeOptions = [10, 25, 50, 100],\n size = \"md\",\n isDisabled = false,\n showLabels = true,\n menuPlacement = \"bottom\",\n className,\n ...rest\n },\n ref,\n) {\n const labelId = useId();\n const pageCount = Math.max(1, Math.ceil(totalResults / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const disabled = isDisabled || totalResults === 0;\n const atStart = disabled || currentPage === 1;\n const atEnd = disabled || currentPage === pageCount;\n const start = (currentPage - 1) * pageSize + 1;\n const end = Math.min(currentPage * pageSize, totalResults);\n\n const go = (nextPage: number) => {\n const next = Math.min(Math.max(1, nextPage), pageCount);\n if (next !== currentPage) onChange({ page: next, pageSize });\n };\n\n return (\n <nav\n ref={ref}\n aria-label=\"Pagination\"\n data-size={size}\n className={[\"ds-pagination\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <div className=\"ds-pagination__actions\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart=\"chevron-left\"\n isIconOnly={!showLabels}\n aria-label=\"Previous page\"\n isDisabled={atStart}\n onClick={() => go(currentPage - 1)}\n >\n Previous\n </Button>\n </div>\n\n <div className=\"ds-pagination__centre\">\n <div className=\"ds-pagination__per-page\">\n <span id={labelId}>Per page</span>\n <div className=\"ds-pagination__select\">\n <Select\n aria-labelledby={labelId}\n value={String(pageSize)}\n options={pageSizeOptions.map((value) => ({\n value: String(value),\n label: String(value),\n }))}\n size={size}\n menuPlacement={menuPlacement}\n isDisabled={disabled || totalResults <= Math.min(...pageSizeOptions)}\n onValueChange={(value) => {\n const nextSize = Number(value);\n if (nextSize === pageSize) return;\n const nextPage = Math.floor(((currentPage - 1) * pageSize) / nextSize) + 1;\n const nextPageCount = Math.max(1, Math.ceil(totalResults / nextSize));\n onChange({\n page: Math.min(nextPage, nextPageCount),\n pageSize: nextSize,\n });\n }}\n />\n </div>\n </div>\n <span\n className=\"ds-pagination__range\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {totalResults === 0\n ? \"No results\"\n : `${start.toLocaleString(\"en-US\")}–${end.toLocaleString(\"en-US\")} of ${totalResults.toLocaleString(\"en-US\")}`}\n </span>\n </div>\n\n <div className=\"ds-pagination__actions ds-pagination__actions--next\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart={showLabels ? undefined : \"chevron-right\"}\n iconEnd={showLabels ? \"chevron-right\" : undefined}\n isIconOnly={!showLabels}\n aria-label=\"Next page\"\n isDisabled={atEnd}\n onClick={() => go(currentPage + 1)}\n >\n Next\n </Button>\n </div>\n </nav>\n );\n});\n"],"mappings":"A,iMA8BA,IAAaQ,GAAA,EAAaR,EAAAA,WAAAA,CAAyC,SACjE,CACE,eACA,OACA,WACA,WACA,kBAAkB,CAAC,GAAI,GAAI,GAAI,GAAG,EAClC,OAAO,KACP,aAAa,GACb,aAAa,GACb,gBAAgB,SAChB,YACA,GAAGS,GAEL,EACA,CACA,IAAMC,GAAA,EAAUT,EAAAA,MAAAA,CAAM,EAChBU,EAAY,KAAK,IAAI,EAAG,KAAK,KAAKC,EAAeC,CAAQ,CAAC,EAC1DC,EAAc,KAAK,IAAI,KAAK,IAAI,EAAGC,CAAI,EAAGJ,CAAS,EACnDK,EAAWC,GAAcL,IAAiB,EAC1CM,EAAUF,GAAYF,IAAgB,EACtCK,EAAQH,GAAYF,IAAgBH,EACpCS,GAASN,EAAc,GAAKD,EAAW,EACvCQ,EAAM,KAAK,IAAIP,EAAcD,EAAUD,CAAY,EAEnDU,EAAM,GAAqB,CAC/B,IAAMC,EAAO,KAAK,IAAI,KAAK,IAAI,EAAGC,CAAQ,EAAGb,CAAS,EAClDY,IAAST,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useId","Button","Select","require_components_Button_index","require_components_Select_index","react","react_jsx_runtime","Pagination","rest","labelId","pageCount","totalResults","pageSize","currentPage","page","disabled","isDisabled","atStart","atEnd","start","end","go","next","nextPage","onChange","size","className","showLabels","pageSizeOptions","value","nextSize","nextPageCount"],"sources":["../../../src/components/Pagination/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Select } from \"../Select\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport \"./style.css\";\n\nexport type PaginationSize = \"sm\" | \"md\";\n\nexport interface PaginationState {\n /** One-based page number. */\n page: number;\n /** Positive integer results per page. */\n pageSize: number;\n}\n\nexport interface PaginationProps\n extends Omit<HTMLAttributes<HTMLElement>, \"children\" | \"onChange\">, PaginationState {\n /** Total number of matching results, before pagination. */\n totalResults: number;\n /** Emitted once per user change, with both values ready to apply together. */\n onChange: (next: PaginationState) => void;\n /** Nonempty list of positive integers containing the current pageSize. */\n pageSizeOptions?: number[];\n size?: PaginationSize;\n isDisabled?: boolean;\n showLabels?: boolean;\n menuPlacement?: PopoverPlacement;\n}\n\n/** Controlled navigation for a result set. Data loading and slicing belong to the application. */\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(function Pagination(\n {\n totalResults,\n page,\n pageSize,\n onChange,\n pageSizeOptions = [10, 25, 50, 100],\n size = \"md\",\n isDisabled = false,\n showLabels = true,\n menuPlacement = \"bottom\",\n className,\n ...rest\n },\n ref,\n) {\n const labelId = useId();\n const pageCount = Math.max(1, Math.ceil(totalResults / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const disabled = isDisabled || totalResults === 0;\n const atStart = disabled || currentPage === 1;\n const atEnd = disabled || currentPage === pageCount;\n const start = (currentPage - 1) * pageSize + 1;\n const end = Math.min(currentPage * pageSize, totalResults);\n\n const go = (nextPage: number) => {\n const next = Math.min(Math.max(1, nextPage), pageCount);\n if (next !== currentPage) {\n onChange({ page: next, pageSize });\n }\n };\n\n return (\n <nav\n ref={ref}\n aria-label=\"Pagination\"\n data-size={size}\n className={[\"ds-pagination\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <div className=\"ds-pagination__actions\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart=\"chevron-left\"\n isIconOnly={!showLabels}\n aria-label=\"Previous page\"\n isDisabled={atStart}\n onClick={() => go(currentPage - 1)}\n >\n Previous\n </Button>\n </div>\n\n <div className=\"ds-pagination__centre\">\n <div className=\"ds-pagination__per-page\">\n <span id={labelId}>Per page</span>\n <div className=\"ds-pagination__select\">\n <Select\n aria-labelledby={labelId}\n value={String(pageSize)}\n options={pageSizeOptions.map((value) => ({\n value: String(value),\n label: String(value),\n }))}\n size={size}\n menuPlacement={menuPlacement}\n isDisabled={disabled || totalResults <= Math.min(...pageSizeOptions)}\n onValueChange={(value) => {\n const nextSize = Number(value);\n if (nextSize === pageSize) {\n return;\n }\n const nextPage = Math.floor(((currentPage - 1) * pageSize) / nextSize) + 1;\n const nextPageCount = Math.max(1, Math.ceil(totalResults / nextSize));\n onChange({\n page: Math.min(nextPage, nextPageCount),\n pageSize: nextSize,\n });\n }}\n />\n </div>\n </div>\n <span\n className=\"ds-pagination__range\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {totalResults === 0\n ? \"No results\"\n : `${start.toLocaleString(\"en-US\")}–${end.toLocaleString(\"en-US\")} of ${totalResults.toLocaleString(\"en-US\")}`}\n </span>\n </div>\n\n <div className=\"ds-pagination__actions ds-pagination__actions--next\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart={showLabels ? undefined : \"chevron-right\"}\n iconEnd={showLabels ? \"chevron-right\" : undefined}\n isIconOnly={!showLabels}\n aria-label=\"Next page\"\n isDisabled={atEnd}\n onClick={() => go(currentPage + 1)}\n >\n Next\n </Button>\n </div>\n </nav>\n );\n});\n"],"mappings":"A,iMA8BA,IAAaQ,GAAA,EAAaR,EAAAA,WAAAA,CAAyC,SACjE,CACE,eACA,OACA,WACA,WACA,kBAAkB,CAAC,GAAI,GAAI,GAAI,GAAG,EAClC,OAAO,KACP,aAAa,GACb,aAAa,GACb,gBAAgB,SAChB,YACA,GAAGS,GAEL,EACA,CACA,IAAMC,GAAA,EAAUT,EAAAA,MAAAA,CAAM,EAChBU,EAAY,KAAK,IAAI,EAAG,KAAK,KAAKC,EAAeC,CAAQ,CAAC,EAC1DC,EAAc,KAAK,IAAI,KAAK,IAAI,EAAGC,CAAI,EAAGJ,CAAS,EACnDK,EAAWC,GAAcL,IAAiB,EAC1CM,EAAUF,GAAYF,IAAgB,EACtCK,EAAQH,GAAYF,IAAgBH,EACpCS,GAASN,EAAc,GAAKD,EAAW,EACvCQ,EAAM,KAAK,IAAIP,EAAcD,EAAUD,CAAY,EAEnDU,EAAM,GAAqB,CAC/B,IAAMC,EAAO,KAAK,IAAI,KAAK,IAAI,EAA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KAAM,KAAK,IAAID,EAAUQ,CAAa,EACtC,SAAUD,CACZ,CAAC,CACH,CACD,CAAA,CACE,CAAA,CACF,CACL,CAAA,GAAA,EAAAxB,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,uBACV,YAAU,SACV,cAAY,OAEX,SAAAK,IAAiB,EACd,aACA,GAAGQ,EAAM,eAAe,OAAO,EAAE,GAAGC,EAAI,eAAe,OAAO,EAAE,MAAMT,EAAa,eAAe,OAAO,GACzG,CAAA,CACH,C,IAEL,EAAAL,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,sDACb,UAAA,EAAAA,EAAA,IAAA,CAACL,EAAAA,OAAD,CACE,QAAQ,UACF,OACN,UAAW0B,EAAa,IAAA,GAAY,gBACpC,QAASA,EAAa,gBAAkB,IAAA,GACxC,WAAY,CAACA,EACb,aAAW,YACX,WAAYT,EACZ,YAAeG,EAAGR,EAAc,CAAC,EAClC,SAAA,MAEO,CAAA,CACL,CAAA,CACF,C,EAET,CAAC,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,eAAe;IACnF,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,EAAE,C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":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,eAAe;IACnF,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,kGAAkG;AAClG,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,eAAe;IACnF,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,kGAAkG;AAClG,eAAO,MAAM,UAAU,yGA8GrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Pagination","forwardRef","rest","labelId","useId","pageCount","totalResults","pageSize","currentPage","page","disabled","isDisabled","atStart","atEnd","start","end","go","next","nextPage","onChange","size","className","Button","showLabels","Select","pageSizeOptions","value","nextSize","nextPageCount"],"sources":["../../../src/components/Pagination/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Select } from \"../Select\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport \"./style.css\";\n\nexport type PaginationSize = \"sm\" | \"md\";\n\nexport interface PaginationState {\n /** One-based page number. */\n page: number;\n /** Positive integer results per page. */\n pageSize: number;\n}\n\nexport interface PaginationProps\n extends Omit<HTMLAttributes<HTMLElement>, \"children\" | \"onChange\">, PaginationState {\n /** Total number of matching results, before pagination. */\n totalResults: number;\n /** Emitted once per user change, with both values ready to apply together. */\n onChange: (next: PaginationState) => void;\n /** Nonempty list of positive integers containing the current pageSize. */\n pageSizeOptions?: number[];\n size?: PaginationSize;\n isDisabled?: boolean;\n showLabels?: boolean;\n menuPlacement?: PopoverPlacement;\n}\n\n/** Controlled navigation for a result set. Data loading and slicing belong to the application. */\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(function Pagination(\n {\n totalResults,\n page,\n pageSize,\n onChange,\n pageSizeOptions = [10, 25, 50, 100],\n size = \"md\",\n isDisabled = false,\n showLabels = true,\n menuPlacement = \"bottom\",\n className,\n ...rest\n },\n ref,\n) {\n const labelId = useId();\n const pageCount = Math.max(1, Math.ceil(totalResults / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const disabled = isDisabled || totalResults === 0;\n const atStart = disabled || currentPage === 1;\n const atEnd = disabled || currentPage === pageCount;\n const start = (currentPage - 1) * pageSize + 1;\n const end = Math.min(currentPage * pageSize, totalResults);\n\n const go = (nextPage: number) => {\n const next = Math.min(Math.max(1, nextPage), pageCount);\n if (next !== currentPage) onChange({ page: next, pageSize });\n };\n\n return (\n <nav\n ref={ref}\n aria-label=\"Pagination\"\n data-size={size}\n className={[\"ds-pagination\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <div className=\"ds-pagination__actions\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart=\"chevron-left\"\n isIconOnly={!showLabels}\n aria-label=\"Previous page\"\n isDisabled={atStart}\n onClick={() => go(currentPage - 1)}\n >\n Previous\n </Button>\n </div>\n\n <div className=\"ds-pagination__centre\">\n <div className=\"ds-pagination__per-page\">\n <span id={labelId}>Per page</span>\n <div className=\"ds-pagination__select\">\n <Select\n aria-labelledby={labelId}\n value={String(pageSize)}\n options={pageSizeOptions.map((value) => ({\n value: String(value),\n label: String(value),\n }))}\n size={size}\n menuPlacement={menuPlacement}\n isDisabled={disabled || totalResults <= Math.min(...pageSizeOptions)}\n onValueChange={(value) => {\n const nextSize = Number(value);\n if (nextSize === pageSize) return;\n const nextPage = Math.floor(((currentPage - 1) * pageSize) / nextSize) + 1;\n const nextPageCount = Math.max(1, Math.ceil(totalResults / nextSize));\n onChange({\n page: Math.min(nextPage, nextPageCount),\n pageSize: nextSize,\n });\n }}\n />\n </div>\n </div>\n <span\n className=\"ds-pagination__range\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {totalResults === 0\n ? \"No results\"\n : `${start.toLocaleString(\"en-US\")}–${end.toLocaleString(\"en-US\")} of ${totalResults.toLocaleString(\"en-US\")}`}\n </span>\n </div>\n\n <div className=\"ds-pagination__actions ds-pagination__actions--next\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart={showLabels ? undefined : \"chevron-right\"}\n iconEnd={showLabels ? \"chevron-right\" : undefined}\n isIconOnly={!showLabels}\n aria-label=\"Next page\"\n isDisabled={atEnd}\n onClick={() => go(currentPage + 1)}\n >\n Next\n </Button>\n </div>\n </nav>\n );\n});\n"],"mappings":";;;;;AA8BA,IAAaA,IAAaC,EAAyC,SACjE,EACE,iBACA,SACA,aACA,aACA,qBAAkB;CAAC;CAAI;CAAI;CAAI;AAAG,GAClC,UAAO,MACP,gBAAa,IACb,gBAAa,IACb,mBAAgB,UAChB,cACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAUC,EAAM,GAChBC,IAAY,KAAK,IAAI,GAAG,KAAK,KAAKC,IAAeC,CAAQ,CAAC,GAC1DC,IAAc,KAAK,IAAI,KAAK,IAAI,GAAGC,CAAI,GAAGJ,CAAS,GACnDK,IAAWC,KAAcL,MAAiB,GAC1CM,IAAUF,KAAYF,MAAgB,GACtCK,IAAQH,KAAYF,MAAgBH,GACpCS,KAASN,IAAc,KAAKD,IAAW,GACvCQ,IAAM,KAAK,IAAIP,IAAcD,GAAUD,CAAY,GAEnDU,KAAM,MAAqB;EAC/B,IAAMC,IAAO,KAAK,IAAI,KAAK,IAAI,GAAGC,CAAQ,GAAGb,CAAS;EACtD,AAAIY,MAAST,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Pagination","forwardRef","rest","labelId","useId","pageCount","totalResults","pageSize","currentPage","page","disabled","isDisabled","atStart","atEnd","start","end","go","next","nextPage","onChange","size","className","Button","showLabels","Select","pageSizeOptions","value","nextSize","nextPageCount"],"sources":["../../../src/components/Pagination/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes } from \"react\";\nimport { Button } from \"../Button\";\nimport { Select } from \"../Select\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport \"./style.css\";\n\nexport type PaginationSize = \"sm\" | \"md\";\n\nexport interface PaginationState {\n /** One-based page number. */\n page: number;\n /** Positive integer results per page. */\n pageSize: number;\n}\n\nexport interface PaginationProps\n extends Omit<HTMLAttributes<HTMLElement>, \"children\" | \"onChange\">, PaginationState {\n /** Total number of matching results, before pagination. */\n totalResults: number;\n /** Emitted once per user change, with both values ready to apply together. */\n onChange: (next: PaginationState) => void;\n /** Nonempty list of positive integers containing the current pageSize. */\n pageSizeOptions?: number[];\n size?: PaginationSize;\n isDisabled?: boolean;\n showLabels?: boolean;\n menuPlacement?: PopoverPlacement;\n}\n\n/** Controlled navigation for a result set. Data loading and slicing belong to the application. */\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(function Pagination(\n {\n totalResults,\n page,\n pageSize,\n onChange,\n pageSizeOptions = [10, 25, 50, 100],\n size = \"md\",\n isDisabled = false,\n showLabels = true,\n menuPlacement = \"bottom\",\n className,\n ...rest\n },\n ref,\n) {\n const labelId = useId();\n const pageCount = Math.max(1, Math.ceil(totalResults / pageSize));\n const currentPage = Math.min(Math.max(1, page), pageCount);\n const disabled = isDisabled || totalResults === 0;\n const atStart = disabled || currentPage === 1;\n const atEnd = disabled || currentPage === pageCount;\n const start = (currentPage - 1) * pageSize + 1;\n const end = Math.min(currentPage * pageSize, totalResults);\n\n const go = (nextPage: number) => {\n const next = Math.min(Math.max(1, nextPage), pageCount);\n if (next !== currentPage) {\n onChange({ page: next, pageSize });\n }\n };\n\n return (\n <nav\n ref={ref}\n aria-label=\"Pagination\"\n data-size={size}\n className={[\"ds-pagination\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <div className=\"ds-pagination__actions\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart=\"chevron-left\"\n isIconOnly={!showLabels}\n aria-label=\"Previous page\"\n isDisabled={atStart}\n onClick={() => go(currentPage - 1)}\n >\n Previous\n </Button>\n </div>\n\n <div className=\"ds-pagination__centre\">\n <div className=\"ds-pagination__per-page\">\n <span id={labelId}>Per page</span>\n <div className=\"ds-pagination__select\">\n <Select\n aria-labelledby={labelId}\n value={String(pageSize)}\n options={pageSizeOptions.map((value) => ({\n value: String(value),\n label: String(value),\n }))}\n size={size}\n menuPlacement={menuPlacement}\n isDisabled={disabled || totalResults <= Math.min(...pageSizeOptions)}\n onValueChange={(value) => {\n const nextSize = Number(value);\n if (nextSize === pageSize) {\n return;\n }\n const nextPage = Math.floor(((currentPage - 1) * pageSize) / nextSize) + 1;\n const nextPageCount = Math.max(1, Math.ceil(totalResults / nextSize));\n onChange({\n page: Math.min(nextPage, nextPageCount),\n pageSize: nextSize,\n });\n }}\n />\n </div>\n </div>\n <span\n className=\"ds-pagination__range\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {totalResults === 0\n ? \"No results\"\n : `${start.toLocaleString(\"en-US\")}–${end.toLocaleString(\"en-US\")} of ${totalResults.toLocaleString(\"en-US\")}`}\n </span>\n </div>\n\n <div className=\"ds-pagination__actions ds-pagination__actions--next\">\n <Button\n variant=\"neutral\"\n size={size}\n iconStart={showLabels ? undefined : \"chevron-right\"}\n iconEnd={showLabels ? \"chevron-right\" : undefined}\n isIconOnly={!showLabels}\n aria-label=\"Next page\"\n isDisabled={atEnd}\n onClick={() => go(currentPage + 1)}\n >\n Next\n </Button>\n </div>\n </nav>\n );\n});\n"],"mappings":";;;;;AA8BA,IAAaA,IAAaC,EAAyC,SACjE,EACE,iBACA,SACA,aACA,aACA,qBAAkB;CAAC;CAAI;CAAI;CAAI;AAAG,GAClC,UAAO,MACP,gBAAa,IACb,gBAAa,IACb,mBAAgB,UAChB,cACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAUC,EAAM,GAChBC,IAAY,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AW,OAAOD,CAAK;QAC7B,IAAIC,MAAapB,GACf;QAEF,IAAMW,IAAW,KAAK,OAAQV,IAAc,KAAKD,IAAYoB,CAAQ,IAAI,GACnEC,IAAgB,KAAK,IAAI,GAAG,KAAK,KAAKtB,IAAeqB,CAAQ,CAAC;QACpE,EAAS;SACP,MAAM,KAAK,IAAIT,GAAUU,CAAa;SACtC,UAAUD;QACZ,CAAC;OACH;MACD,CAAA;KACE,CAAA,CACF;IACL,CAAA,GAAA,kBAAC,QAAD;KACE,WAAU;KACV,aAAU;KACV,eAAY;KAEX,UAAArB,MAAiB,IACd,eACA,GAAGQ,EAAM,eAAe,OAAO,EAAE,GAAGC,EAAI,eAAe,OAAO,EAAE,MAAMT,EAAa,eAAe,OAAO;IACzG,CAAA,CACH;;GAEL,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAACgB,GAAD;KACE,SAAQ;KACF;KACN,WAAWC,IAAa,KAAA,IAAY;KACpC,SAASA,IAAa,kBAAkB,KAAA;KACxC,YAAY,CAACA;KACb,cAAW;KACX,YAAYV;KACZ,eAAeG,EAAGR,IAAc,CAAC;KAClC,UAAA;IAEO,CAAA;GACL,CAAA;EACF;;AAET,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),t=require("../../chunks/dialogFocus-B9iqKl3I.cjs");let n=require("react"),r=require("react-dom"),i=require("react/jsx-runtime");function a(...e){return e.filter(Boolean).join(` `)}var o=8;function s({anchorRef:s,anchorId:c,isOpen:l,align:u=`start`,placement:d=`bottom`,matchAnchorWidth:f=!1,offset:p=4,className:m,children:h,role:g,id:_,panelRef:v,...y}){let b=(0,n.useRef)(null),x=(0,n.useId)(),S=_??x,C=(0,n.useCallback)(()=>{let e=s.current??(c?document.getElementById(c):null),t=b.current;if(!e||!t)return;let n=e.getBoundingClientRect();f&&(t.style.width=`${n.width}px`);let r=t.getBoundingClientRect(),i=r.height+Math.max(0,t.scrollHeight-t.clientHeight),a={width:r.width,height:i},l=document.documentElement.clientWidth,m=document.documentElement.clientHeight,h=Math.max(0,m-16),g=Math.max(0,Math.min(h,m-n.bottom-p-o)),_=Math.max(0,Math.min(h,n.top-p-o)),v=d===`top`?_>=a.height||_>g:g<a.height&&_>g,y=v?_:g,x=Math.min(a.height,y),S=v?n.top-p-x:n.bottom+p,C=Math.max(o,Math.min(S,m-o-x)),w=u===`end`?n.right-a.width:n.left,T=Math.max(o,Math.min(w,l-a.width-o));t.style.left=`${Math.round(T)}px`,t.style.top=`${Math.round(C)}px`,t.style.setProperty(`--popover-max-block-size`,`${Math.round(y)}px`),t.style.visibility=`visible`},[u,c,s,f,p,d]);if((0,n.useEffect)(()=>{if(!l)return;let e=b.current,n=s.current??(c?document.getElementById(c):null),r=e&&n?t.t(e,n):void 0;C();let i=()=>C(),a=({target:t})=>{t instanceof Node&&e?.contains(t)||C()},o=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);n&&o?.observe(n);let u=()=>{if(e&&o){o.observe(e);for(let t of e.children)o.observe(t)}};u();let d=new MutationObserver(u);return e&&d.observe(e,{childList:!0}),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,a,!0),()=>{window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,a,!0),o?.disconnect(),d.disconnect(),r?.()}},[c,s,l,C]),!l||typeof document>`u`)return null;let w=(0,i.jsx)(`div`,{ref:e.t(b,v),id:S,role:g,className:a(`ds-popover`,m),...y,children:h});return(0,r.createPortal)(w,document.body)}exports.Popover=s;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useRef","useId","useCallback","createPortal","react","react_dom","react_jsx_runtime","cx","parts","VIEWPORT_MARGIN","Popover","rest","floatingRef","generatedId","panelId","id","place","reference","anchorRef","anchorId","floating","anchor","matchAnchorWidth","panel","viewportWidth","viewportHeight","roomBelow","offset","roomAbove","placeAbove","placement","availableHeight","top","preferredLeft","align","left","isOpen","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useRef","useId","useCallback","registerPopup","mergeRefs","createPortal","require_mergeRefs","require_dialogFocus","react","react_dom","react_jsx_runtime","cx","parts","VIEWPORT_MARGIN","Popover","rest","floatingRef","generatedId","panelId","id","place","reference","anchorRef","anchorId","floating","anchor","matchAnchorWidth","box","naturalHeight","panel","viewportWidth","viewportHeight","viewportRoom","roomBelow","offset","roomAbove","placeAbove","placement","availableHeight","visibleHeight","preferredTop","top","preferredLeft","align","left","isOpen","unregister","update","scroll","target","observer","observeContent","child","mutations","panelRef","className"],"sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["import { useCallback, useEffect, useId, useRef, type ReactNode, type RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { registerPopup } from \"../../internal/dialogFocus\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst VIEWPORT_MARGIN = 8;\n\nexport type PopoverAlign = \"start\" | \"end\";\nexport type PopoverPlacement = \"top\" | \"bottom\";\n\nexport interface PopoverProps {\n /** The control the panel hangs off. */\n anchorRef: RefObject<HTMLElement | null>;\n /** Optional DOM id fallback for composed controls whose refs are consumed by a field wrapper. */\n anchorId?: string;\n isOpen: boolean;\n /** Which edge of the anchor the panel lines up with. Flips when it must. */\n align?: PopoverAlign;\n /** Preferred side of the anchor. Flips when the other side has more room. */\n placement?: PopoverPlacement;\n /** Match the anchor's width — for listboxes that read as one field. */\n matchAnchorWidth?: boolean;\n /** Gap between anchor and panel. */\n offset?: number;\n className?: string;\n children: ReactNode;\n role?: string;\n id?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n panelRef?: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * A panel anchored to a control. It is positioned against the viewport, so it\n * flips above the anchor when the space below runs out and slides inward\n * rather than being cut off at any edge.\n */\nexport function Popover({\n anchorRef,\n anchorId,\n isOpen,\n align = \"start\",\n placement = \"bottom\",\n matchAnchorWidth = false,\n offset = 4,\n className,\n children,\n role,\n id,\n panelRef,\n ...rest\n}: PopoverProps) {\n const floatingRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const panelId = id ?? generatedId;\n\n const place = useCallback(() => {\n const reference = anchorRef.current ?? (anchorId ? document.getElementById(anchorId) : null);\n const floating = floatingRef.current;\n if (!reference || !floating) {\n return;\n }\n\n const anchor = reference.getBoundingClientRect();\n if (matchAnchorWidth) {\n floating.style.width = `${anchor.width}px`;\n }\n // Natural height is the capped box plus whatever it scrolls. Lifting the cap\n // to measure would clamp the panel's scroll position back to the top.\n const box = floating.getBoundingClientRect();\n const naturalHeight = box.height + Math.max(0, floating.scrollHeight - floating.clientHeight);\n const panel = { width: box.width, height: naturalHeight };\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n const viewportRoom = Math.max(0, viewportHeight - VIEWPORT_MARGIN * 2);\n const roomBelow = Math.max(\n 0,\n Math.min(viewportRoom, viewportHeight - anchor.bottom - offset - VIEWPORT_MARGIN),\n );\n const roomAbove = Math.max(0, Math.min(viewportRoom, anchor.top - offset - VIEWPORT_MARGIN));\n const placeAbove =\n placement === \"top\"\n ? roomAbove >= panel.height || roomAbove > roomBelow\n : roomBelow < panel.height && roomAbove > roomBelow;\n const availableHeight = placeAbove ? roomAbove : roomBelow;\n const visibleHeight = Math.min(panel.height, availableHeight);\n const preferredTop = placeAbove ? anchor.top - offset - visibleHeight : anchor.bottom + offset;\n const top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(preferredTop, viewportHeight - VIEWPORT_MARGIN - visibleHeight),\n );\n const preferredLeft = align === \"end\" ? anchor.right - panel.width : anchor.left;\n const left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(preferredLeft, viewportWidth - panel.width - VIEWPORT_MARGIN),\n );\n\n floating.style.left = `${Math.round(left)}px`;\n floating.style.top = `${Math.round(top)}px`;\n floating.style.setProperty(\"--popover-max-block-size\", `${Math.round(availableHeight)}px`);\n floating.style.visibility = \"visible\";\n }, [align, anchorId, anchorRef, matchAnchorWidth, offset, placement]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const floating = floatingRef.current;\n const reference = anchorRef.current ?? (anchorId ? document.getElementById(anchorId) : null);\n // A dialog around the anchor leaves Tab in this portalled panel to the panel.\n const unregister = floating && reference ? registerPopup(floating, reference) : undefined;\n place();\n const update = () => place();\n // The panel's own scrolling never moves its anchor.\n const scroll = ({ target }: Event) => {\n if (target instanceof Node && floating?.contains(target)) {\n return;\n }\n place();\n };\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(update);\n if (reference) {\n observer?.observe(reference);\n }\n // Children can grow while the outer panel stays capped and scrollable. Size\n // changes arrive through the observer; new children only need observing.\n const observeContent = () => {\n if (!floating || !observer) {\n return;\n }\n observer.observe(floating);\n for (const child of floating.children) {\n observer.observe(child);\n }\n };\n observeContent();\n const mutations = new MutationObserver(observeContent);\n if (floating) {\n mutations.observe(floating, { childList: true });\n }\n window.addEventListener(\"resize\", update);\n window.addEventListener(\"scroll\", scroll, true);\n return () => {\n window.removeEventListener(\"resize\", update);\n window.removeEventListener(\"scroll\", scroll, true);\n observer?.disconnect();\n mutations.disconnect();\n unregister?.();\n };\n }, [anchorId, anchorRef, isOpen, place]);\n\n if (!isOpen || typeof document === \"undefined\") {\n return null;\n }\n\n const panel = (\n <div\n ref={mergeRefs(floatingRef, panelRef)}\n id={panelId}\n role={role}\n className={cx(\"ds-popover\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n\n return createPortal(panel, document.body);\n}\n"],"mappings":"A,0PAMA,SAASW,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,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K,CAAC,EAEjD,OAAO,iBAAiB,SAAUuB,CAAM,EACxC,OAAO,iBAAiB,SAAUC,EAAQ,EAAI,MACjC,CACX,OAAO,oBAAoB,SAAUD,CAAM,EAC3C,OAAO,oBAAoB,SAAUC,EAAQ,EAAI,EACjDE,GAAU,WAAW,EACrBG,EAAU,WAAW,EACrBP,IAAa,CACf,CACF,EAAG,CAACvB,EAAUD,EAAWuB,EAAQzB,CAAK,CAAC,EAEnC,CAACyB,GAAU,OAAO,SAAa,IACjC,OAAO,KAGT,IAAMhB,GACJ,EAAAnB,EAAA,IAAA,CAAC,MAAD,CACE,IAAKN,EAAAA,EAAUY,EAAasC,CAAQ,EACpC,GAAIpC,EACE,OACN,UAAWP,EAAG,aAAc4C,CAAS,EACrC,GAAIxC,EAEH,UACE,CAAA,EAGP,OAAA,EAAOV,EAAAA,aAAAA,CAAawB,EAAO,SAAS,IAAI,CAC1C,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI9F,OAAO,aAAa,CAAC;AAQrB,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAe,EACf,SAAoB,EACpB,gBAAwB,EACxB,MAAU,EACV,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,YAAY,sCAqHd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI9F,OAAO,aAAa,CAAC;AAQrB,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAe,EACf,SAAoB,EACpB,gBAAwB,EACxB,MAAU,EACV,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,YAAY,sCAqHd"}
|
|
@@ -1,53 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "../../chunks/mergeRefs-DGM402mE.js";
|
|
2
|
+
import { t } from "../../chunks/dialogFocus-BFoyeTpA.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useId as i, useRef as a } from "react";
|
|
4
|
+
import { createPortal as o } from "react-dom";
|
|
5
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
4
6
|
//#region src/components/Popover/index.tsx
|
|
5
|
-
function
|
|
7
|
+
function c(...e) {
|
|
6
8
|
return e.filter(Boolean).join(" ");
|
|
7
9
|
}
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
let e =
|
|
10
|
+
var l = 8;
|
|
11
|
+
function u({ anchorRef: u, anchorId: d, isOpen: f, align: p = "start", placement: m = "bottom", matchAnchorWidth: h = !1, offset: g = 4, className: _, children: v, role: y, id: b, panelRef: x, ...S }) {
|
|
12
|
+
let C = a(null), w = i(), T = b ?? w, E = n(() => {
|
|
13
|
+
let e = u.current ?? (d ? document.getElementById(d) : null), t = C.current;
|
|
12
14
|
if (!e || !t) return;
|
|
13
15
|
let n = e.getBoundingClientRect();
|
|
14
|
-
|
|
15
|
-
let r = t.getBoundingClientRect(), i =
|
|
16
|
-
|
|
16
|
+
h && (t.style.width = `${n.width}px`);
|
|
17
|
+
let r = t.getBoundingClientRect(), i = r.height + Math.max(0, t.scrollHeight - t.clientHeight), a = {
|
|
18
|
+
width: r.width,
|
|
19
|
+
height: i
|
|
20
|
+
}, o = document.documentElement.clientWidth, s = document.documentElement.clientHeight, c = Math.max(0, s - 16), f = Math.max(0, Math.min(c, s - n.bottom - g - l)), _ = Math.max(0, Math.min(c, n.top - g - l)), v = m === "top" ? _ >= a.height || _ > f : f < a.height && _ > f, y = v ? _ : f, b = Math.min(a.height, y), x = v ? n.top - g - b : n.bottom + g, S = Math.max(l, Math.min(x, s - l - b)), w = p === "end" ? n.right - a.width : n.left, T = Math.max(l, Math.min(w, o - a.width - l));
|
|
21
|
+
t.style.left = `${Math.round(T)}px`, t.style.top = `${Math.round(S)}px`, t.style.setProperty("--popover-max-block-size", `${Math.round(y)}px`), t.style.visibility = "visible";
|
|
17
22
|
}, [
|
|
18
|
-
d,
|
|
19
|
-
l,
|
|
20
|
-
c,
|
|
21
23
|
p,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
d,
|
|
25
|
+
u,
|
|
26
|
+
h,
|
|
27
|
+
g,
|
|
28
|
+
m
|
|
24
29
|
]);
|
|
25
|
-
if (
|
|
26
|
-
if (!
|
|
27
|
-
let e = document.
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (r(() => {
|
|
31
|
+
if (!f) return;
|
|
32
|
+
let e = C.current, n = u.current ?? (d ? document.getElementById(d) : null), r = e && n ? t(e, n) : void 0;
|
|
33
|
+
E();
|
|
34
|
+
let i = () => E(), a = ({ target: t }) => {
|
|
35
|
+
t instanceof Node && e?.contains(t) || E();
|
|
36
|
+
}, o = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(i);
|
|
37
|
+
n && o?.observe(n);
|
|
38
|
+
let s = () => {
|
|
39
|
+
if (e && o) {
|
|
40
|
+
o.observe(e);
|
|
41
|
+
for (let t of e.children) o.observe(t);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
s();
|
|
45
|
+
let c = new MutationObserver(s);
|
|
46
|
+
return e && c.observe(e, { childList: !0 }), window.addEventListener("resize", i), window.addEventListener("scroll", a, !0), () => {
|
|
47
|
+
window.removeEventListener("resize", i), window.removeEventListener("scroll", a, !0), o?.disconnect(), c.disconnect(), r?.();
|
|
32
48
|
};
|
|
33
49
|
}, [
|
|
34
|
-
|
|
50
|
+
d,
|
|
35
51
|
u,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
id:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
children: g
|
|
52
|
+
f,
|
|
53
|
+
E
|
|
54
|
+
]), !f || typeof document > "u") return null;
|
|
55
|
+
let D = /* @__PURE__ */ s("div", {
|
|
56
|
+
ref: e(C, x),
|
|
57
|
+
id: T,
|
|
58
|
+
role: y,
|
|
59
|
+
className: c("ds-popover", _),
|
|
60
|
+
...S,
|
|
61
|
+
children: v
|
|
47
62
|
});
|
|
48
|
-
return
|
|
63
|
+
return o(D, document.body);
|
|
49
64
|
}
|
|
50
65
|
//#endregion
|
|
51
|
-
export {
|
|
66
|
+
export { u as Popover };
|
|
52
67
|
|
|
53
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","VIEWPORT_MARGIN","Popover","rest","floatingRef","useRef","generatedId","useId","panelId","id","place","useCallback","reference","anchorRef","anchorId","floating","anchor","matchAnchorWidth","panel","viewportWidth","viewportHeight","roomBelow","offset","roomAbove","placeAbove","placement","availableHeight","top","preferredLeft","align","left","useEffect","isOpen","
|
|
1
|
+
{"version":3,"file":"index.js","names":["mergeRefs","cx","parts","VIEWPORT_MARGIN","Popover","rest","floatingRef","useRef","generatedId","useId","panelId","id","place","useCallback","reference","anchorRef","anchorId","floating","anchor","matchAnchorWidth","box","naturalHeight","panel","viewportWidth","viewportHeight","viewportRoom","roomBelow","offset","roomAbove","placeAbove","placement","availableHeight","visibleHeight","preferredTop","top","preferredLeft","align","left","useEffect","isOpen","unregister","registerPopup","update","scroll","target","observer","observeContent","child","mutations","panelRef","className","createPortal"],"sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["import { useCallback, useEffect, useId, useRef, type ReactNode, type RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { registerPopup } from \"../../internal/dialogFocus\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst VIEWPORT_MARGIN = 8;\n\nexport type PopoverAlign = \"start\" | \"end\";\nexport type PopoverPlacement = \"top\" | \"bottom\";\n\nexport interface PopoverProps {\n /** The control the panel hangs off. */\n anchorRef: RefObject<HTMLElement | null>;\n /** Optional DOM id fallback for composed controls whose refs are consumed by a field wrapper. */\n anchorId?: string;\n isOpen: boolean;\n /** Which edge of the anchor the panel lines up with. Flips when it must. */\n align?: PopoverAlign;\n /** Preferred side of the anchor. Flips when the other side has more room. */\n placement?: PopoverPlacement;\n /** Match the anchor's width — for listboxes that read as one field. */\n matchAnchorWidth?: boolean;\n /** Gap between anchor and panel. */\n offset?: number;\n className?: string;\n children: ReactNode;\n role?: string;\n id?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n panelRef?: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * A panel anchored to a control. It is positioned against the viewport, so it\n * flips above the anchor when the space below runs out and slides inward\n * rather than being cut off at any edge.\n */\nexport function Popover({\n anchorRef,\n anchorId,\n isOpen,\n align = \"start\",\n placement = \"bottom\",\n matchAnchorWidth = false,\n offset = 4,\n className,\n children,\n role,\n id,\n panelRef,\n ...rest\n}: PopoverProps) {\n const floatingRef = useRef<HTMLDivElement | null>(null);\n const generatedId = useId();\n const panelId = id ?? generatedId;\n\n const place = useCallback(() => {\n const reference = anchorRef.current ?? (anchorId ? document.getElementById(anchorId) : null);\n const floating = floatingRef.current;\n if (!reference || !floating) {\n return;\n }\n\n const anchor = reference.getBoundingClientRect();\n if (matchAnchorWidth) {\n floating.style.width = `${anchor.width}px`;\n }\n // Natural height is the capped box plus whatever it scrolls. Lifting the cap\n // to measure would clamp the panel's scroll position back to the top.\n const box = floating.getBoundingClientRect();\n const naturalHeight = box.height + Math.max(0, floating.scrollHeight - floating.clientHeight);\n const panel = { width: box.width, height: naturalHeight };\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n const viewportRoom = Math.max(0, viewportHeight - VIEWPORT_MARGIN * 2);\n const roomBelow = Math.max(\n 0,\n Math.min(viewportRoom, viewportHeight - anchor.bottom - offset - VIEWPORT_MARGIN),\n );\n const roomAbove = Math.max(0, Math.min(viewportRoom, anchor.top - offset - VIEWPORT_MARGIN));\n const placeAbove =\n placement === \"top\"\n ? roomAbove >= panel.height || roomAbove > roomBelow\n : roomBelow < panel.height && roomAbove > roomBelow;\n const availableHeight = placeAbove ? roomAbove : roomBelow;\n const visibleHeight = Math.min(panel.height, availableHeight);\n const preferredTop = placeAbove ? anchor.top - offset - visibleHeight : anchor.bottom + offset;\n const top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(preferredTop, viewportHeight - VIEWPORT_MARGIN - visibleHeight),\n );\n const preferredLeft = align === \"end\" ? anchor.right - panel.width : anchor.left;\n const left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(preferredLeft, viewportWidth - panel.width - VIEWPORT_MARGIN),\n );\n\n floating.style.left = `${Math.round(left)}px`;\n floating.style.top = `${Math.round(top)}px`;\n floating.style.setProperty(\"--popover-max-block-size\", `${Math.round(availableHeight)}px`);\n floating.style.visibility = \"visible\";\n }, [align, anchorId, anchorRef, matchAnchorWidth, offset, placement]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const floating = floatingRef.current;\n const reference = anchorRef.current ?? (anchorId ? document.getElementById(anchorId) : null);\n // A dialog around the anchor leaves Tab in this portalled panel to the panel.\n const unregister = floating && reference ? registerPopup(floating, reference) : undefined;\n place();\n const update = () => place();\n // The panel's own scrolling never moves its anchor.\n const scroll = ({ target }: Event) => {\n if (target instanceof Node && floating?.contains(target)) {\n return;\n }\n place();\n };\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(update);\n if (reference) {\n observer?.observe(reference);\n }\n // Children can grow while the outer panel stays capped and scrollable. Size\n // changes arrive through the observer; new children only need observing.\n const observeContent = () => {\n if (!floating || !observer) {\n return;\n }\n observer.observe(floating);\n for (const child of floating.children) {\n observer.observe(child);\n }\n };\n observeContent();\n const mutations = new MutationObserver(observeContent);\n if (floating) {\n mutations.observe(floating, { childList: true });\n }\n window.addEventListener(\"resize\", update);\n window.addEventListener(\"scroll\", scroll, true);\n return () => {\n window.removeEventListener(\"resize\", update);\n window.removeEventListener(\"scroll\", scroll, true);\n observer?.disconnect();\n mutations.disconnect();\n unregister?.();\n };\n }, [anchorId, anchorRef, isOpen, place]);\n\n if (!isOpen || typeof document === \"undefined\") {\n return null;\n }\n\n const panel = (\n <div\n ref={mergeRefs(floatingRef, panelRef)}\n id={panelId}\n role={role}\n className={cx(\"ds-popover\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n\n return createPortal(panel, document.body);\n}\n"],"mappings":";;;;;;AAMA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAEA,IAAMC,IAAkB;AAiCxB,SAAgBC,EAAQ,EACtB,cACA,aACA,WACA,WAAQ,SACR,eAAY,UACZ,sBAAmB,IACnB,YAAS,GACT,cACA,aACA,SACA,OACA,aACA,GAAGC,KACY;CACf,IAAMC,IAAcC,EAA8B,IAAI,GAChDC,IAAcC,EAAM,GACpBC,IAAUC,KAAMH,GAEhBI,IAAQC,QAAkB;EAC9B,IAAMC,IAAYC,EAAU,YAAYC,IAAW,SAAS,eAAeA,CAAQ,IAAI,OACjFC,IAAWX,EAAY;EAC7B,IAAI,CAACQ,KAAa,CAACG,GACjB;EAGF,IAAMC,IAASJ,EAAU,sBAAsB;EAC/C,AAAIK,MACF,EAAS,MAAM,QAAQ,GAAGD,EAAO,MAAM;EAIzC,IAAME,IAAMH,EAAS,sBAAsB,GACrCI,IAAgBD,EAAI,SAAS,KAAK,IAAI,GAAGH,EAAS,eAAeA,EAAS,YAAY,GACtFK,IAAQ;GAAE,OAAOF,EAAI;GAAO,QAAQC;EAAc,GAClDE,IAAgB,SAAS,gBAAgB,aACzCC,IAAiB,SAAS,gBAAgB,cAC1CC,IAAe,KAAK,IAAI,GAAGD,IAAiB,EAAmB,GAC/DE,IAAY,KAAK,IACrB,GACA,KAAK,IAAID,GAAcD,IAAiBN,EAAO,SAASS,IAASxB,CAAe,CAClF,GACMyB,IAAY,KAAK,IAAI,GAAG,KAAK,IAAIH,GAAcP,EAAO,MAAMS,IAASxB,CAAe,CAAC,GACrF0B,IACJC,MAAc,QACVF,KAAaN,EAAM,UAAUM,IAAYF,IACzCA,IAAYJ,EAAM,UAAUM,IAAYF,GACxCK,IAAkBF,IAAaD,IAAYF,GAC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I3B;EACA,EAAe;EACf,IAAMC,IAAY,IAAI,iBAAiBF,CAAc;EAMrD,OALI7B,KACF+B,EAAU,QAAQ/B,GAAU,EAAE,WAAW,GAAK,CAAC,GAEjD,OAAO,iBAAiB,UAAUyB,CAAM,GACxC,OAAO,iBAAiB,UAAUC,GAAQ,EAAI,SACjC;GAKX,AAJA,OAAO,oBAAoB,UAAUD,CAAM,GAC3C,OAAO,oBAAoB,UAAUC,GAAQ,EAAI,GACjDE,GAAU,WAAW,GACrBG,EAAU,WAAW,GACrBR,IAAa;EACf;CACF,GAAG;EAACxB;EAAUD;EAAWwB;EAAQ3B;CAAK,CAAC,GAEnC,CAAC2B,KAAU,OAAO,WAAa,KACjC,OAAO;CAGT,IAAMjB,IACJ,kBAAC,OAAD;EACE,KAAKtB,EAAUM,GAAa2C,CAAQ;EACpC,IAAIvC;EACE;EACN,WAAWT,EAAG,cAAciD,CAAS;EACrC,GAAI7C;EAEH;CACE,CAAA;CAGP,OAAO8C,EAAa7B,GAAO,SAAS,IAAI;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.cts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,aAAa,EAAE,gBAAoE,CAAC;AAEjG,wBAAgB,kBAAkB,gLAKjC;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,CAE9E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"document.d.cts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,aAAa,EAAE,gBAAoE,CAAC;AAEjG,wBAAgB,kBAAkB,gLAKjC;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,CAE9E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAsChE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,aAAa,EAAE,gBAAoE,CAAC;AAEjG,wBAAgB,kBAAkB,gLAKjC;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,CAE9E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextEditor/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,aAAa,EAAE,gBAAoE,CAAC;AAEjG,wBAAgB,kBAAkB,gLAKjC;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,gBAAg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AAE,gBAAgB,CAAC;IACzB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACjD,CACJ,CAAC;AAwSJ;;;GAGG;AACH,eAAO,MAAM,cAAc,gHA8L1B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs");;/* empty css */const n=require("../FieldAffix/index.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=(0,r.forwardRef)(function({size:a=`md`,isDisabled:o=!1,onClear:s,className:c,placeholder:l=`Search`,value:u,disabled:d,onKeyDown:f,...p},m){let h=(0,r.useRef)(null),g=u!==void 0&&String(u).length>0;return(0,i.jsx)(n.FieldAffix,{className:c,lead:(0,i.jsx)(e.t,{name:`search`,size:16}),isTrailInteractive:!0,trail:g&&s?(0,i.jsx)(t.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`x`,"aria-label":`Clear search`,isDisabled:o||d,onClick:()=>{s(),h.current?.focus()}}):void 0,children:(0,i.jsx)(`input`,{ref:e=>{h.current=e,typeof m==`function`?m(e):m&&(m.current=e)},type:`search`,value:u,placeholder:l,disabled:o||d,"data-size":a,className:`ds-field-skin ds-search__input`,onKeyDown:e=>{e.key===`Escape`&&s&&s(),f?.(e)},...p})})});exports.SearchField=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useRef","FieldAffix","Icon","Button","require_Icon","require_components_Button_index","require_components_FieldAffix_index","react","react_jsx_runtime","SearchField","rest","inner","hasValue","value","onClear","isDisabled","disabled","node","ref","size","event","onKeyDown"],"sources":["../../../src/components/SearchField/index.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport interface SearchFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\"\n> {\n size?: FieldSize;\n isDisabled?: boolean;\n /** Fired by the clear button and by Escape. */\n onClear?: () => void;\n}\n\n/** A filter over a collection. Carries the glyph, and clears without a Save. */\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(function SearchField(\n {\n size = \"md\",\n isDisabled = false,\n onClear,\n className,\n placeholder = \"Search\",\n value,\n disabled,\n onKeyDown,\n ...rest\n },\n ref,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const hasValue = value !== undefined ? String(value).length > 0 : false;\n\n return (\n <FieldAffix\n className={className}\n lead={\n <Icon\n name=\"search\"\n size={16}\n />\n }\n isTrailInteractive\n trail={\n hasValue && onClear ? (\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Clear search\"\n isDisabled={isDisabled || disabled}\n onClick={() => {\n onClear();\n inner.current?.focus();\n }}\n />\n ) : undefined\n }\n >\n <input\n ref={(node) => {\n inner.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"search\"\n value={value}\n placeholder={placeholder}\n disabled={isDisabled || disabled}\n data-size={size}\n className=\"ds-field-skin ds-search__input\"\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && onClear) onClear();\n onKeyDown?.(event);\n }}\n {...rest}\n />\n </FieldAffix>\n );\n});\n"],"mappings":"A,kSAmBA,IAAaU,GAAA,EAAcV,EAAAA,WAAAA,CAA+C,SACxE,CACE,OAAO,KACP,aAAa,GACb,UACA,YACA,cAAc,SACd,QACA,WACA,YACA,GAAGW,GAEL,EACA,CACA,IAAMC,GAAA,EAAQX,EAAAA,OAAAA,CAAgC,IAAI,EAC5CY,EAAWC,IAAU,IAAA,IAAY,OAAOA,CAAK,CAAC,CAAC,OAAS,EAE9D,OACE,EAAAL,EAAA,IAAA,CAACP,EAAAA,WAAD,CACa,YACX,MACE,EAAAO,EAAA,IAAA,CAACN,EAAAA,EAAD,CACE,KAAK,SACL,KAAM,EACP,CAAA,EAEH,mBAAA,GACA,MACEU,GAAYE,GACV,EAAAN,EAAA,IAAA,CAACL,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,IACV,aAAW,eACX,WAAYY,GAAcC,EAC1B,YAAe,CACbF,EAAQ,EACRH,EAAM,SAAS,MAAM,CACvB,CACD,CAAA,EACC,IAAA,GAGN,UAAA,EAAAH,EAAA,IAAA,CAAC,QAAD,CACE,IAAM,GAAS,CACb,EAAM,QAAUS,EACZ,OAAOC,GAAQ,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useRef","FieldAffix","Icon","Button","require_Icon","require_components_Button_index","require_components_FieldAffix_index","react","react_jsx_runtime","SearchField","rest","inner","hasValue","value","onClear","isDisabled","disabled","node","ref","size","event","onKeyDown"],"sources":["../../../src/components/SearchField/index.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport interface SearchFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\"\n> {\n size?: FieldSize;\n isDisabled?: boolean;\n /** Fired by the clear button and by Escape. */\n onClear?: () => void;\n}\n\n/** A filter over a collection. Carries the glyph, and clears without a Save. */\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(function SearchField(\n {\n size = \"md\",\n isDisabled = false,\n onClear,\n className,\n placeholder = \"Search\",\n value,\n disabled,\n onKeyDown,\n ...rest\n },\n ref,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const hasValue = value !== undefined ? String(value).length > 0 : false;\n\n return (\n <FieldAffix\n className={className}\n lead={\n <Icon\n name=\"search\"\n size={16}\n />\n }\n isTrailInteractive\n trail={\n hasValue && onClear ? (\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Clear search\"\n isDisabled={isDisabled || disabled}\n onClick={() => {\n onClear();\n inner.current?.focus();\n }}\n />\n ) : undefined\n }\n >\n <input\n ref={(node) => {\n inner.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"search\"\n value={value}\n placeholder={placeholder}\n disabled={isDisabled || disabled}\n data-size={size}\n className=\"ds-field-skin ds-search__input\"\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && onClear) {\n onClear();\n }\n onKeyDown?.(event);\n }}\n {...rest}\n />\n </FieldAffix>\n );\n});\n"],"mappings":"A,kSAmBA,IAAaU,GAAA,EAAcV,EAAAA,WAAAA,CAA+C,SACxE,CACE,OAAO,KACP,aAAa,GACb,UACA,YACA,cAAc,SACd,QACA,WACA,YACA,GAAGW,GAEL,EACA,CACA,IAAMC,GAAA,EAAQX,EAAAA,OAAAA,CAAgC,IAAI,EAC5CY,EAAWC,IAAU,IAAA,IAAY,OAAOA,CAAK,CAAC,CAAC,OAAS,EAE9D,OACE,EAAAL,EAAA,IAAA,CAACP,EAAAA,WAAD,CACa,YACX,MACE,EAAAO,EAAA,IAAA,CAACN,EAAAA,EAAD,CACE,KAAK,SACL,KAAM,EACP,CAAA,EAEH,mBAAA,GACA,MACEU,GAAYE,GACV,EAAAN,EAAA,IAAA,CAACL,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,IACV,aAAW,eACX,WAAYY,GAAcC,EAC1B,YAAe,CACbF,EAAQ,EACRH,EAAM,SAAS,MAAM,CACvB,CACD,CAAA,EACC,IAAA,GAGN,UAAA,EAAAH,EAAA,IAAA,CAAC,QAAD,CACE,IAAM,GAAS,CACb,EAAM,QAAUS,EACZ,OAAOC,GAAQ,WACjBA,EAAID,CAAI,EACCC,IACT,EAAI,QAAUD,EAElB,EACA,KAAK,SACE,QACM,cACb,SAAUF,GAAcC,EACxB,YAAWG,EACX,UAAU,iCACV,UAAY,GAAU,CAChBC,EAAM,MAAQ,UAAYN,GAC5BA,EAAQ,EAEVO,IAAYD,CAAK,CACnB,EACA,GAAIV,CACL,CAAA,CACS,CAAA,CAEhB,CAAC,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/SearchField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,MAAM,CAChB;IACC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gFAAgF;AAChF,eAAO,MAAM,WAAW,+
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/SearchField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,MAAM,CAChB;IACC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gFAAgF;AAChF,eAAO,MAAM,WAAW,+GAqEtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SearchField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,MAAM,CAChB;IACC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gFAAgF;AAChF,eAAO,MAAM,WAAW,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SearchField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,MAAM,CAChB;IACC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gFAAgF;AAChF,eAAO,MAAM,WAAW,+GAqEtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","SearchField","forwardRef","rest","inner","useRef","hasValue","value","FieldAffix","onClear","Button","isDisabled","disabled","node","ref","size","event","onKeyDown"],"sources":["../../../src/components/SearchField/index.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport interface SearchFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\"\n> {\n size?: FieldSize;\n isDisabled?: boolean;\n /** Fired by the clear button and by Escape. */\n onClear?: () => void;\n}\n\n/** A filter over a collection. Carries the glyph, and clears without a Save. */\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(function SearchField(\n {\n size = \"md\",\n isDisabled = false,\n onClear,\n className,\n placeholder = \"Search\",\n value,\n disabled,\n onKeyDown,\n ...rest\n },\n ref,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const hasValue = value !== undefined ? String(value).length > 0 : false;\n\n return (\n <FieldAffix\n className={className}\n lead={\n <Icon\n name=\"search\"\n size={16}\n />\n }\n isTrailInteractive\n trail={\n hasValue && onClear ? (\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Clear search\"\n isDisabled={isDisabled || disabled}\n onClick={() => {\n onClear();\n inner.current?.focus();\n }}\n />\n ) : undefined\n }\n >\n <input\n ref={(node) => {\n inner.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"search\"\n value={value}\n placeholder={placeholder}\n disabled={isDisabled || disabled}\n data-size={size}\n className=\"ds-field-skin ds-search__input\"\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && onClear) onClear();\n onKeyDown?.(event);\n }}\n {...rest}\n />\n </FieldAffix>\n );\n});\n"],"mappings":";;;;;;;AAmBA,IAAaC,IAAcC,EAA+C,SACxE,EACE,UAAO,MACP,gBAAa,IACb,YACA,cACA,iBAAc,UACd,UACA,aACA,cACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,EAAgC,IAAI,GAC5CC,IAAWC,MAAU,KAAA,KAAY,OAAOA,CAAK,CAAC,CAAC,SAAS;CAE9D,OACE,kBAACC,GAAD;EACa;EACX,MACE,kBAACR,GAAD;GACE,MAAK;GACL,MAAM;EACP,CAAA;EAEH,oBAAA;EACA,OACEM,KAAYG,IACV,kBAACC,GAAD;GACE,SAAQ;GACR,MAAK;GACL,YAAA;GACA,WAAU;GACV,cAAW;GACX,YAAYC,KAAcC;GAC1B,eAAe;IAEb,AADAH,EAAQ,GACRL,EAAM,SAAS,MAAM;GACvB;EACD,CAAA,IACC,KAAA;EAGN,UAAA,kBAAC,SAAD;GACE,MAAM,MAAS;IAEb,AADA,EAAM,UAAUS,GACZ,OAAOC,KAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","SearchField","forwardRef","rest","inner","useRef","hasValue","value","FieldAffix","onClear","Button","isDisabled","disabled","node","ref","size","event","onKeyDown"],"sources":["../../../src/components/SearchField/index.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport interface SearchFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"size\" | \"type\"\n> {\n size?: FieldSize;\n isDisabled?: boolean;\n /** Fired by the clear button and by Escape. */\n onClear?: () => void;\n}\n\n/** A filter over a collection. Carries the glyph, and clears without a Save. */\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(function SearchField(\n {\n size = \"md\",\n isDisabled = false,\n onClear,\n className,\n placeholder = \"Search\",\n value,\n disabled,\n onKeyDown,\n ...rest\n },\n ref,\n) {\n const inner = useRef<HTMLInputElement | null>(null);\n const hasValue = value !== undefined ? String(value).length > 0 : false;\n\n return (\n <FieldAffix\n className={className}\n lead={\n <Icon\n name=\"search\"\n size={16}\n />\n }\n isTrailInteractive\n trail={\n hasValue && onClear ? (\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Clear search\"\n isDisabled={isDisabled || disabled}\n onClick={() => {\n onClear();\n inner.current?.focus();\n }}\n />\n ) : undefined\n }\n >\n <input\n ref={(node) => {\n inner.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"search\"\n value={value}\n placeholder={placeholder}\n disabled={isDisabled || disabled}\n data-size={size}\n className=\"ds-field-skin ds-search__input\"\n onKeyDown={(event) => {\n if (event.key === \"Escape\" && onClear) {\n onClear();\n }\n onKeyDown?.(event);\n }}\n {...rest}\n />\n </FieldAffix>\n );\n});\n"],"mappings":";;;;;;;AAmBA,IAAaC,IAAcC,EAA+C,SACxE,EACE,UAAO,MACP,gBAAa,IACb,YACA,cACA,iBAAc,UACd,UACA,aACA,cACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,EAAgC,IAAI,GAC5CC,IAAWC,MAAU,KAAA,KAAY,OAAOA,CAAK,CAAC,CAAC,SAAS;CAE9D,OACE,kBAACC,GAAD;EACa;EACX,MACE,kBAACR,GAAD;GACE,MAAK;GACL,MAAM;EACP,CAAA;EAEH,oBAAA;EACA,OACEM,KAAYG,IACV,kBAACC,GAAD;GACE,SAAQ;GACR,MAAK;GACL,YAAA;GACA,WAAU;GACV,cAAW;GACX,YAAYC,KAAcC;GAC1B,eAAe;IAEb,AADAH,EAAQ,GACRL,EAAM,SAAS,MAAM;GACvB;EACD,CAAA,IACC,KAAA;EAGN,UAAA,kBAAC,SAAD;GACE,MAAM,MAAS;IAEb,AADA,EAAM,UAAUS,GACZ,OAAOC,KAAQ,aACjBA,EAAID,CAAI,IACCC,MACT,EAAI,UAAUD;GAElB;GACA,MAAK;GACE;GACM;GACb,UAAUF,KAAcC;GACxB,aAAWG;GACX,WAAU;GACV,YAAY,MAAU;IAIpB,AAHIC,EAAM,QAAQ,YAAYP,KAC5BA,EAAQ,GAEVQ,IAAYD,CAAK;GACnB;GACA,GAAIb;EACL,CAAA;CACS,CAAA;AAEhB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs");;/* empty css */const n=require("../Popover/index.cjs");let r=require("react"),i=require("react/jsx-runtime");function a(...e){return e.filter(Boolean).join(` `)}var o=(0,r.forwardRef)(function({options:o,value:s,defaultValue:c,onValueChange:l,placeholder:u=`Select an option`,size:d=`md`,isDisabled:f=!1,isInvalid:p=!1,"aria-invalid":m,required:h,menuPlacement:g=`bottom`,className:_,disabled:v,onClick:y,onKeyDown:b,...x},S){let[C,w]=(0,r.useState)(c??``),T=s??C,[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(0),A=(0,r.useRef)(null),j=(0,r.useRef)(null),M=(0,r.useRef)(null),N=(0,r.useId)(),P=f||v,F=E&&!P,I=o.find(e=>e.value===T),L=o.filter(e=>!e.isDisabled),R=(0,r.useCallback)(e=>{s===void 0&&w(e),l?.(e),D(!1)},[l,s]);(0,r.useEffect)(()=>{if(!F)return;let e=o.findIndex(e=>e.value===T&&!e.isDisabled);k(e<0?o.indexOf(L[0]):e);let t=e=>{let t=e.target;!A.current?.contains(t)&&!M.current?.contains(t)&&D(!1)};return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[F]),(0,r.useEffect)(()=>{F&&(M.current?.querySelectorAll(`[role='option']`)[O])?.scrollIntoView({block:`nearest`})},[O,F]);let z=e=>{let t=o.map((e,t)=>({option:e,index:t})).filter(e=>!e.option.isDisabled);if(t.length===0)return;let n=t[(t.findIndex(e=>e.index===O)+e+t.length)%t.length];k(n.index)},B=e=>{switch(e.key){case`Escape`:e.preventDefault(),D(!1),j.current?.focus();break;case`Tab`:D(!1);break;case`ArrowDown`:case`ArrowUp`:e.preventDefault(),z(e.key===`ArrowDown`?1:-1);break;case`Home`:case`End`:{e.preventDefault();let t=e.key===`Home`?L[0]:L[L.length-1];t&&k(o.indexOf(t));break}case`Enter`:case` `:{e.preventDefault();let t=o[O];t&&!t.isDisabled&&R(t.value);break}}},V=e=>{P||(F?B(e):[`ArrowDown`,`ArrowUp`,`Enter`,` `].includes(e.key)&&(e.preventDefault(),D(!0)))};return(0,i.jsxs)(`div`,{className:`ds-select-root`,ref:A,children:[(0,i.jsxs)(t.Button,{ref:e=>{j.current=e,typeof S==`function`?S(e):S&&(S.current=e)},size:d,role:`combobox`,"aria-required":h||void 0,"aria-haspopup":`listbox`,"aria-expanded":F,"aria-controls":F?N:void 0,"aria-activedescendant":F&&o[O]&&!o[O].isDisabled?`${N}-option-${O}`:void 0,"aria-invalid":p||m||void 0,isDisabled:P,"data-placeholder":I?void 0:``,className:a(`ds-field-skin`,`ds-select`,_),onClick:e=>{y?.(e),e.defaultPrevented||D(e=>!e)},onKeyDown:e=>{b?.(e),e.defaultPrevented||V(e)},...x,children:[(0,i.jsx)(`span`,{className:`ds-select__value`,children:I?I.label:u}),(0,i.jsx)(e.t,{name:`chevron-down`,size:16,className:`ds-select__chevron`})]}),(0,i.jsx)(n.Popover,{anchorRef:j,isOpen:F,placement:g,matchAnchorWidth:!0,panelRef:M,id:N,role:`listbox`,"aria-label":x[`aria-labelledby`]?void 0:x[`aria-label`]??u,"aria-labelledby":x[`aria-labelledby`],className:`ds-surface-raised ds-select__menu`,children:(0,i.jsx)(`div`,{onKeyDown:V,onPointerDown:e=>e.preventDefault(),children:o.map((n,r)=>(0,i.jsxs)(t.Button,{variant:r===O?`active`:`simple`,size:`sm`,isDisabled:n.isDisabled,tabIndex:-1,id:`${N}-option-${r}`,role:`option`,"aria-selected":n.value===T,"aria-disabled":n.isDisabled||void 0,"data-active":r===O||void 0,className:`ds-select__option`,onMouseEnter:()=>!n.isDisabled&&k(r),onClick:()=>{n.isDisabled||(R(n.value),j.current?.focus())},children:[(0,i.jsxs)(`span`,{className:`ds-select__option-body`,children:[(0,i.jsx)(`span`,{className:`ds-select__option-label`,children:n.label}),n.description&&(0,i.jsx)(`span`,{className:`ds-select__option-description`,children:n.description})]}),n.value===T&&(0,i.jsx)(e.t,{name:`check`,size:16})]},n.value))})})]})});exports.Select=o;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|