@plexui/ui 0.54.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ColorWell.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorWell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAA;AAC9F,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,WAAW,EAAyB,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA6BjG;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,EAAE,EACF,KAAK,EAAE,SAAS,EAChB,YAAY,GAAG,IAAI,EACnB,QAAQ,EACR,KAAK,GAAG,QAAQ,EAChB,kBAAkB,GAAG,IAAI,EACzB,IAAI,GAAG,IAAI,EACX,QAAQ,GAAG,KAAK,EAChB,IAAI,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,SAAS,EACT,GAAG,WAAW,E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ReactNode } from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useBreakpoint } from \"../../hooks/useBreakpoints\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Button, NavigationButton } from \"../Button\"\nimport { Dialog } from \"../Dialog\"\nimport { Eyedropper, X } from \"../Icon\"\nimport { Popover } from \"../Popover\"\nimport { Toolbar } from \"../Toolbar\"\nimport { ColorPicker, type ColorPickerProps } from \"./ColorPicker\"\nimport { alphaPercent, cssColor, eyeDropper, formatColor, hexDigits, parseColor } from \"./shared\"\n\nexport type ColorWellProps = Omit<ColorPickerProps, \"value\" | \"defaultValue\" | \"onChange\" | \"aria-label\" | \"className\" | \"id\"> & {\n /** The `id` of the well. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`; `null` shows the rainbow well with no color. Use with `onChange`. */\n value?: string | null\n /** The color when it is initially rendered. Use when you do not need to control the color. @default null */\n defaultValue?: string | null\n /** Called with the color the picker chose. */\n onChange?: (value: string) => void\n /** The title of the picker. @default \"Colors\" */\n title?: string\n /** Shows the eyedropper in the picker where the browser can pick a color from the screen (EyeDropper API). @default true */\n supportsEyedropper?: boolean\n /** The kit's Picker Button sizes: `sm` 28px, `lg` 36px. @default \"sm\" */\n size?: \"sm\" | \"lg\"\n /** When `true`, prevents the user from opening the picker. */\n disabled?: boolean\n /** The name of the well. Submits its color with the owning form. */\n name?: string\n /** Accessible name of the well. @default \"Color\" */\n \"aria-label\"?: string\n /** The `id` of the visible label of the well. */\n \"aria-labelledby\"?: string\n /** CSS classes applied to the well */\n className?: string\n}\n\n/**\n * A color well, as `UIColorWell`: the kit's Picker Button (5739:34128), a rainbow ring around the chosen color. It\n * opens the color picker, in a Popover from the well, and on a phone in a sheet, as the system picker.\n */\nexport function ColorWell({\n id,\n value: valueProp,\n defaultValue = null,\n onChange,\n title = \"Colors\",\n supportsEyedropper = true,\n size = \"sm\",\n disabled = false,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n ...pickerProps\n}: ColorWellProps) {\n const wide = useBreakpoint(\"md\")\n const valueId = `${useId()}-value`\n const [open, setOpen] = useState(false)\n const [internalValue, setInternalValue] = useState<string | null>(defaultValue)\n const value = valueProp === undefined ? internalValue : valueProp\n const color = parseColor(value)\n const options = useLatestValue({ controlled: valueProp !== undefined, onChange })\n // The EyeDropper API exists only in a browser, so the button appears after hydration.\n const [canPick, setCanPick] = useState(false)\n useEffect(() => setCanPick(eyeDropper() !== null), [])\n const picking = useRef(false)\n\n const choose = (next: string) => {\n if (!options.current.controlled) setInternalValue(next)\n options.current.onChange?.(next)\n }\n\n const pick = async () => {\n const EyeDropper = eyeDropper()\n if (!EyeDropper || picking.current) return\n picking.current = true\n try {\n const picked = parseColor((await new EyeDropper().open()).sRGBHex)\n if (picked) choose(formatColor({ ...picked, a: color?.a ?? 1 }))\n } catch {\n // Escape, or a click the browser did not hand to the page, cancels the pick.\n } finally {\n picking.current = false\n }\n }\n\n const well = (\n <button\n id={id}\n type=\"button\"\n className={clsx(s.Well, className)}\n data-size={size}\n data-selected={color ? \"\" : undefined}\n disabled={disabled}\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? \"Color\"}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={color ? valueId : undefined}\n style={color ? { \"--color-well-color\": cssColor(color) } as CSSProperties : undefined}\n >\n {color && <span className={s.WellColor} />}\n {/* The color, read as the well's description. */}\n {color && <span id={valueId} hidden>{`#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`}</span>}\n </button>\n )\n\n const picker = (\n <ColorPicker {...pickerProps} value={formatColor(color ?? { r: 0, g: 0, b: 0, a: 1 })} onChange={choose} aria-label={title} />\n )\n const eyedropperButton = (glass: boolean): ReactNode => supportsEyedropper && canPick && (\n <Button\n color=\"secondary\"\n variant={glass ? \"soft\" : \"ghost\"}\n mobileMaterial={glass ? \"glass\" : undefined}\n size={glass ? \"lg\" : \"sm\"}\n uniform\n pill\n aria-label=\"Eyedropper\"\n onClick={() => void pick()}\n >\n <Eyedropper />\n </Button>\n )\n\n return (\n <>\n {name !== undefined && <input type=\"hidden\" name={name} value={value ?? \"\"} disabled={disabled} />}\n {wide ? (\n <Popover open={open} onOpenChange={setOpen}>\n <Popover.Trigger>{well}</Popover.Trigger>\n <Popover.Content className={s.Popover} width=\"auto\" side=\"bottom\" align=\"center\">\n <div className={s.PopoverHeader}>\n <div className={s.PopoverLeading}>{eyedropperButton(false)}</div>\n <span className={s.PopoverTitle}>{title}</span>\n <div className={s.PopoverTrailing}>\n <Button color=\"secondary\" variant=\"ghost\" size=\"sm\" uniform pill aria-label=\"Close\" onClick={() => setOpen(false)}>\n <X />\n </Button>\n </div>\n </div>\n {picker}\n </Popover.Content>\n </Popover>\n ) : (\n <Dialog open={open} onOpenChange={setOpen}>\n <Dialog.Trigger>{well}</Dialog.Trigger>\n <Dialog.Content mobileVariant=\"sheet\" surface=\"grouped\" showClose={false} className={s.Sheet}>\n {/* iOS 27.2 sets Close first and the eyedropper last (UIColorPickerViewController on an iPhone 17); the\n iOS 26 kit had them the other way round. */}\n <Toolbar background=\"solid\">\n <Toolbar.Leading>\n <Dialog.Close>\n <NavigationButton action=\"close\" />\n </Dialog.Close>\n </Toolbar.Leading>\n <Toolbar.Title>{title}</Toolbar.Title>\n <Toolbar.Trailing>{eyedropperButton(true)}</Toolbar.Trailing>\n </Toolbar>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n </Dialog.Header>\n <Dialog.Body className={s.SheetBody}>{picker}</Dialog.Body>\n </Dialog.Content>\n </Dialog>\n )}\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"ColorWell.js","sourceRoot":"","sources":["../../../../src/components/ColorPicker/ColorWell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAA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AAK,CAAC,YAC/G,KAAC,CAAC,KAAG,GACE,GACL,IACF,EACL,MAAM,IACS,IACV,CACX,CAAC,CAAC,CAAC,CACF,MAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,aACvC,KAAC,MAAM,CAAC,OAAO,cAAE,IAAI,GAAkB,EACvC,MAAC,MAAM,CAAC,OAAO,IAAC,aAAa,EAAC,OAAO,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,aAG1F,MAAC,OAAO,IAAC,UAAU,EAAC,OAAO,aACzB,KAAC,OAAO,CAAC,OAAO,cACd,KAAC,MAAM,CAAC,KAAK,cACX,KAAC,gBAAgB,IAAC,MAAM,EAAC,OAAO,GAAG,GACtB,GACC,EAClB,KAAC,OAAO,CAAC,KAAK,cAAE,KAAK,GAAiB,EACtC,KAAC,OAAO,CAAC,QAAQ,cAAE,gBAAgB,CAAC,IAAI,CAAC,GAAoB,IACrD,EACV,KAAC,MAAM,CAAC,MAAM,cACZ,KAAC,MAAM,CAAC,KAAK,cAAE,KAAK,GAAgB,GACtB,EAChB,KAAC,MAAM,CAAC,IAAI,IAAC,SAAS,EAAE,CAAC,CAAC,SAAS,YAAG,MAAM,GAAe,IAC5C,IACV,CACV,IACA,CACJ,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from \"react\"\nimport s from \"@plexui/styles/components/ColorPicker/ColorPicker.module.css\"\nimport { useBreakpoint } from \"../../hooks/useBreakpoints\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Button, NavigationButton } from \"../Button\"\nimport { Dialog } from \"../Dialog\"\nimport { Eyedropper, X } from \"../Icon\"\nimport { Popover } from \"../Popover\"\nimport { Toolbar } from \"../Toolbar\"\nimport { ColorPicker, type ColorPickerProps } from \"./ColorPicker\"\nimport { alphaPercent, cssColor, eyeDropper, formatColor, hexDigits, parseColor } from \"./shared\"\n\nexport type ColorWellProps = Omit<ColorPickerProps, \"value\" | \"defaultValue\" | \"onChange\" | \"aria-label\" | \"className\" | \"id\"> & {\n /** The `id` of the well. */\n id?: string\n /** The controlled color, `#rrggbb` or `#rrggbbaa`; `null` shows the rainbow well with no color. Use with `onChange`. */\n value?: string | null\n /** The color when it is initially rendered. Use when you do not need to control the color. @default null */\n defaultValue?: string | null\n /** Called with the color the picker chose. */\n onChange?: (value: string) => void\n /** The title of the picker. @default \"Colors\" */\n title?: string\n /** Shows the eyedropper in the picker where the browser can pick a color from the screen (EyeDropper API). @default true */\n supportsEyedropper?: boolean\n /** The kit's Picker Button sizes, `sm` 28px and `lg` 36px, and `xs` 24px for the start of a 32px field. @default \"sm\" */\n size?: \"xs\" | \"sm\" | \"lg\"\n /** When `true`, prevents the user from opening the picker. */\n disabled?: boolean\n /** The name of the well. Submits its color with the owning form. */\n name?: string\n /** Accessible name of the well. @default \"Color\" */\n \"aria-label\"?: string\n /** The `id` of the visible label of the well. */\n \"aria-labelledby\"?: string\n /** CSS classes applied to the well */\n className?: string\n}\n\n/**\n * A color well, as `UIColorWell`: the kit's Picker Button (5739:34128), a rainbow ring around the chosen color. It\n * opens the color picker, in a Popover from the well, and on a phone in a sheet, as the system picker.\n */\nexport function ColorWell({\n id,\n value: valueProp,\n defaultValue = null,\n onChange,\n title = \"Colors\",\n supportsEyedropper = true,\n size = \"sm\",\n disabled = false,\n name,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n ...pickerProps\n}: ColorWellProps) {\n const wide = useBreakpoint(\"md\")\n const valueId = `${useId()}-value`\n const [open, setOpen] = useState(false)\n const [internalValue, setInternalValue] = useState<string | null>(defaultValue)\n const value = valueProp === undefined ? internalValue : valueProp\n const color = parseColor(value)\n const options = useLatestValue({ controlled: valueProp !== undefined, onChange })\n // The EyeDropper API exists only in a browser, so the button appears after hydration.\n const [canPick, setCanPick] = useState(false)\n useEffect(() => setCanPick(eyeDropper() !== null), [])\n const picking = useRef(false)\n\n const choose = (next: string) => {\n if (!options.current.controlled) setInternalValue(next)\n options.current.onChange?.(next)\n }\n\n const pick = async () => {\n const EyeDropper = eyeDropper()\n if (!EyeDropper || picking.current) return\n picking.current = true\n try {\n const picked = parseColor((await new EyeDropper().open()).sRGBHex)\n if (picked) choose(formatColor({ ...picked, a: color?.a ?? 1 }))\n } catch {\n // Escape, or a click the browser did not hand to the page, cancels the pick.\n } finally {\n picking.current = false\n }\n }\n\n const well = (\n <button\n id={id}\n type=\"button\"\n className={clsx(s.Well, className)}\n data-size={size}\n data-selected={color ? \"\" : undefined}\n disabled={disabled}\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? \"Color\"}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={color ? valueId : undefined}\n style={color ? { \"--color-well-color\": cssColor(color) } as CSSProperties : undefined}\n >\n {color && <span className={s.WellColor} />}\n {/* The color, read as the well's description. */}\n {color && <span id={valueId} hidden>{`#${hexDigits(color)}${color.a < 1 ? `, ${alphaPercent(color.a)}% opacity` : \"\"}`}</span>}\n </button>\n )\n\n const picker = (\n <ColorPicker {...pickerProps} value={formatColor(color ?? { r: 0, g: 0, b: 0, a: 1 })} onChange={choose} aria-label={title} />\n )\n const eyedropperButton = (glass: boolean): ReactNode => supportsEyedropper && canPick && (\n <Button\n color=\"secondary\"\n variant={glass ? \"soft\" : \"ghost\"}\n mobileMaterial={glass ? \"glass\" : undefined}\n size={glass ? \"lg\" : \"sm\"}\n uniform\n pill\n aria-label=\"Eyedropper\"\n onClick={() => void pick()}\n >\n <Eyedropper />\n </Button>\n )\n\n return (\n <>\n {name !== undefined && <input type=\"hidden\" name={name} value={value ?? \"\"} disabled={disabled} />}\n {wide ? (\n <Popover open={open} onOpenChange={setOpen}>\n <Popover.Trigger>{well}</Popover.Trigger>\n <Popover.Content className={s.Popover} width=\"auto\" side=\"bottom\" align=\"center\">\n <div className={s.PopoverHeader}>\n <div className={s.PopoverLeading}>{eyedropperButton(false)}</div>\n <span className={s.PopoverTitle}>{title}</span>\n <div className={s.PopoverTrailing}>\n <Button color=\"secondary\" variant=\"ghost\" size=\"sm\" uniform pill aria-label=\"Close\" onClick={() => setOpen(false)}>\n <X />\n </Button>\n </div>\n </div>\n {picker}\n </Popover.Content>\n </Popover>\n ) : (\n <Dialog open={open} onOpenChange={setOpen}>\n <Dialog.Trigger>{well}</Dialog.Trigger>\n <Dialog.Content mobileVariant=\"sheet\" surface=\"grouped\" showClose={false} className={s.Sheet}>\n {/* iOS 27.2 sets Close first and the eyedropper last (UIColorPickerViewController on an iPhone 17); the\n iOS 26 kit had them the other way round. */}\n <Toolbar background=\"solid\">\n <Toolbar.Leading>\n <Dialog.Close>\n <NavigationButton action=\"close\" />\n </Dialog.Close>\n </Toolbar.Leading>\n <Toolbar.Title>{title}</Toolbar.Title>\n <Toolbar.Trailing>{eyedropperButton(true)}</Toolbar.Trailing>\n </Toolbar>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n </Dialog.Header>\n <Dialog.Body className={s.SheetBody}>{picker}</Dialog.Body>\n </Dialog.Content>\n </Dialog>\n )}\n </>\n )\n}\n"]}
@@ -18,11 +18,33 @@ const DECIDE = 4;
18
18
  const HOLD = 200;
19
19
  const DRAG_TRANSFORM = "--dialog-panel-drag-transform";
20
20
  const EXITING = "[data-exiting], [data-exiting-active]";
21
+ // A sheet at its full height says so: a sheet under it then steps back, as one presented from a sheet does on iOS.
22
+ // A shorter sheet leaves the one under it in place, as a medium detent does.
23
+ const FULL = "data-sheet-full";
24
+ const watchFullHeight = (panel, view) => {
25
+ if (!view.ResizeObserver)
26
+ return () => { };
27
+ const update = () => {
28
+ const max = Number.parseFloat(view.getComputedStyle(panel).maxHeight);
29
+ const full = Number.isFinite(max) && panel.offsetHeight >= max - 1;
30
+ if (full !== panel.hasAttribute(FULL))
31
+ panel.toggleAttribute(FULL, full);
32
+ };
33
+ const observer = new view.ResizeObserver(update);
34
+ // Its height with the border, as `offsetHeight` reads it
35
+ observer.observe(panel, { box: "border-box" });
36
+ update();
37
+ return () => {
38
+ observer.disconnect();
39
+ panel.removeAttribute(FULL);
40
+ };
41
+ };
21
42
  /** `close` returns false when the owner keeps the dialog open: the sheet then returns at once. */
22
43
  export const attachSheetDrag = (panel, close) => {
23
44
  const view = panel.ownerDocument.defaultView;
24
45
  if (!view)
25
46
  return () => { };
47
+ const unwatchFull = watchFullHeight(panel, view);
26
48
  let startY = null;
27
49
  // A touch in the content that may become a pull, until its first move says which way it goes
28
50
  let pending = null;
@@ -195,6 +217,7 @@ export const attachSheetDrag = (panel, close) => {
195
217
  panel.addEventListener("touchend", onEnd);
196
218
  panel.addEventListener("touchcancel", onCancel);
197
219
  return () => {
220
+ unwatchFull();
198
221
  stateObserver?.disconnect();
199
222
  panel.removeEventListener("touchstart", onStart);
200
223
  panel.removeEventListener("touchmove", onMove);
@@ -1 +1 @@
1
- {"version":3,"file":"sheetDrag.js","sourceRoot":"","sources":["../../../../src/components/Dialog/sheetDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,sGAAsG;AACtG,mGAAmG;AACnG,+GAA+G;AAC/G,4GAA4G;AAC5G,0GAA0G;AAC1G,sFAAsF;AACtF,MAAM,IAAI,GAAG,EAAE,CAAA;AACf,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,MAAM,GAAG,GAAG,CAAA;AAClB,MAAM,WAAW,GAAG,qDAAqD,CAAA;AACzE,MAAM,QAAQ,GAAG,4FAA4F,CAAA;AAC7G,6GAA6G;AAC7G,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,yFAAyF;AACzF,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,cAAc,GAAG,+BAA+B,CAAA;AACtD,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C,SAAS,CAAA;IACd,aAAa,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE;QACtC,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI;KAC3E,CAAC,CAAA;IAEF,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,KAAK,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IAC/D,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACzC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;IAE/C,OAAO,GAAG,EAAE;QACV,aAAa,EAAE,UAAU,EAAE,CAAA;QAC3B,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAChD,KAAK,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAC9C,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAC5C,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QAClD,MAAM,GAAG,IAAI,CAAA;QACb,OAAO,GAAG,IAAI,CAAA;QACd,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { isPhoneLayout } from \"../../lib/phoneLayout\"\n\n// A bottom sheet follows the finger. A drag from its top 44px moves it 1:1, never up. Past 30% of its\n// height, or at 0.5px/ms, it closes; otherwise it returns. Buttons in that strip keep their press.\n// As on iOS, a pull down that starts anywhere else moves the sheet too once the content under the finger is at\n// its top: the first move decides, down and mostly vertical with every scroller under the finger at its top\n// takes the sheet; up, sideways, a move another handler took, a field, a control that pans by itself or a\n// finger that rested first (a hold: Sortable, a context menu) stays with the content.\nconst GRIP = 44\nconst CLOSE_SHARE = 0.3\nconst CLOSE_SPEED = 0.5\nconst REST = 100\nconst SETTLE = 400\nconst INTERACTIVE = \"a, button, input, select, textarea, [role='button']\"\nconst EDITABLE = \"input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='slider']\"\n// The move that settles which way the finger goes, under the browser's own slop so it can still be cancelled\nconst DECIDE = 4\n// A finger that rests this long holds (a Sortable row, a context menu) rather than pulls\nconst HOLD = 200\nconst DRAG_TRANSFORM = \"--dialog-panel-drag-transform\"\nconst EXITING = \"[data-exiting], [data-exiting-active]\"\n\n/** `close` returns false when the owner keeps the dialog open: the sheet then returns at once. */\nexport const attachSheetDrag = (panel: HTMLElement, close: (event: TouchEvent) => boolean | void) => {\n const view = panel.ownerDocument.defaultView\n if (!view) return () => {}\n let startY: number | null = null\n // A touch in the content that may become a pull, until its first move says which way it goes\n let pending: { x: number; y: number; time: number; target: Element } | null = null\n // The pull began in the content: its release must not press what lies under the finger\n let fromContent = false\n let lastY = 0\n let lastTime = 0\n let speed = 0\n let settleTimer: number | undefined\n\n const stopSettling = () => {\n if (settleTimer !== undefined) view.clearTimeout(settleTimer)\n settleTimer = undefined\n panel.removeEventListener(\"transitionend\", onSettled)\n }\n const clearInline = () => {\n panel.style.transition = \"\"\n panel.style.transform = \"\"\n }\n const clear = () => {\n stopSettling()\n clearInline()\n panel.style.removeProperty(DRAG_TRANSFORM)\n }\n const onSettled = (event: TransitionEvent) => {\n if (event.target === panel && event.propertyName === \"transform\") clear()\n }\n const returnToRest = () => {\n stopSettling()\n if (view.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) {\n clear()\n return\n }\n panel.style.transition = \"transform var(--motion-enter) var(--cubic-enter)\"\n panel.style.transform = \"\"\n panel.style.removeProperty(DRAG_TRANSFORM)\n const durationText = view.getComputedStyle(panel).transitionDuration\n const duration = Number.parseFloat(durationText) * (durationText.endsWith(\"ms\") ? 1 : 1000)\n if (duration === 0) {\n clear()\n return\n }\n panel.addEventListener(\"transitionend\", onSettled)\n // A theme can lengthen the token or remove the transition altogether.\n // This cleanup must not cut a valid longer transition at the veto timeout.\n settleTimer = view.setTimeout(clear, Math.max(SETTLE, Number.isFinite(duration) ? duration : 0))\n }\n\n const begin = (clientY: number, time: number) => {\n stopSettling()\n startY = clientY\n lastY = clientY\n lastTime = time\n speed = 0\n }\n\n // Every element from the target up to the panel: one that can scroll up, or pans by itself, keeps the move.\n const contentTakes = (target: Element) => {\n for (let element: Element | null = target; element; element = element.parentElement) {\n if (element.scrollTop > 0) return true\n const touchAction = view.getComputedStyle(element).touchAction\n if (touchAction && touchAction !== \"auto\" && touchAction !== \"manipulation\" && !touchAction.includes(\"pan-y\")) return true\n if (element === panel) break\n }\n return false\n }\n\n const onStart = (event: TouchEvent) => {\n pending = null\n fromContent = false\n const phone = isPhoneLayout(panel)\n if (event.touches.length !== 1 || !phone || panel.closest(EXITING)) return\n const { clientX, clientY } = event.touches[0]\n const target = event.target instanceof view.Element ? event.target : null\n if (clientY - panel.getBoundingClientRect().top <= GRIP) {\n if (target?.closest(INTERACTIVE)) return\n begin(clientY, event.timeStamp)\n return\n }\n if (!target || target.closest(EDITABLE)) return\n pending = { x: clientX, y: clientY, time: event.timeStamp, target }\n }\n\n // The first move of a touch in the content: a pull down from the top takes the sheet from here on.\n const decide = (event: TouchEvent, touch: Touch) => {\n const start = pending!\n const dx = touch.clientX - start.x\n const dy = touch.clientY - start.y\n if (Math.max(Math.abs(dx), Math.abs(dy)) < DECIDE) return\n pending = null\n if (event.defaultPrevented || !event.cancelable || event.timeStamp - start.time > HOLD) return\n if (dy <= 0 || Math.abs(dx) > dy || contentTakes(start.target)) return\n fromContent = true\n begin(start.y, start.time)\n }\n\n const onMove = (event: TouchEvent) => {\n const touch = event.touches[0]\n if (startY === null && pending && touch) decide(event, touch)\n if (startY === null || !touch) return\n event.preventDefault()\n const { clientY } = touch\n speed = (clientY - lastY) / Math.max(1, event.timeStamp - lastTime)\n lastY = clientY\n lastTime = event.timeStamp\n panel.style.transition = \"none\"\n panel.style.transform = `translateY(${Math.max(0, clientY - startY)}px)`\n }\n\n const onEnd = (event: TouchEvent) => {\n pending = null\n if (startY === null) return\n const travelled = lastY - startY\n // A pull from the content ends where it lifted, not in a press of the row under it. A finger that barely\n // moved keeps its tap.\n if (fromContent && travelled > DECIDE && event.cancelable) event.preventDefault()\n fromContent = false\n // A finger that rested before lifting is no flick.\n const flick = speed > CLOSE_SPEED && event.timeStamp - lastTime < REST\n startY = null\n if (travelled <= 0) {\n clear()\n return\n }\n if (travelled > panel.getBoundingClientRect().height * CLOSE_SHARE || flick) {\n // The normal/exit-start CSS states retain this exact release position.\n // No inline transform or transition may mask the active CSS exit.\n panel.style.setProperty(DRAG_TRANSFORM, `translateY(${travelled}px)`)\n clearInline()\n // An owner can veto close. Register before close, which can detach us.\n settleTimer = view.setTimeout(() => {\n settleTimer = undefined\n if (panel.isConnected && !panel.closest(EXITING)) returnToRest()\n }, SETTLE)\n if (close(event) === false) returnToRest()\n return\n }\n returnToRest()\n }\n\n const onCancel = () => {\n startY = null\n pending = null\n fromContent = false\n clear()\n }\n\n // A retained panel can reopen before its exit completes. Its new entrance\n // must return to rest, not finish at the old gesture's release offset.\n const dialog = panel.closest(\"[data-plex-dialog]\")\n const stateObserver = dialog ? new view.MutationObserver((records) => {\n if (panel.style.getPropertyValue(DRAG_TRANSFORM) &&\n dialog.getAttribute(\"data-state\") === \"open\" &&\n records.some((record) => record.oldValue === \"closed\")) clear()\n }) : undefined\n stateObserver?.observe(dialog ?? panel, {\n attributes: true, attributeFilter: [\"data-state\"], attributeOldValue: true,\n })\n\n panel.addEventListener(\"touchstart\", onStart, { passive: true })\n panel.addEventListener(\"touchmove\", onMove, { passive: false })\n panel.addEventListener(\"touchend\", onEnd)\n panel.addEventListener(\"touchcancel\", onCancel)\n\n return () => {\n stateObserver?.disconnect()\n panel.removeEventListener(\"touchstart\", onStart)\n panel.removeEventListener(\"touchmove\", onMove)\n panel.removeEventListener(\"touchend\", onEnd)\n panel.removeEventListener(\"touchcancel\", onCancel)\n startY = null\n pending = null\n clear()\n }\n}\n"]}
1
+ {"version":3,"file":"sheetDrag.js","sourceRoot":"","sources":["../../../../src/components/Dialog/sheetDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,sGAAsG;AACtG,mGAAmG;AACnG,+GAA+G;AAC/G,4GAA4G;AAC5G,0GAA0G;AAC1G,sFAAsF;AACtF,MAAM,IAAI,GAAG,EAAE,CAAA;AACf,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,MAAM,GAAG,GAAG,CAAA;AAClB,MAAM,WAAW,GAAG,qDAAqD,CAAA;AACzE,MAAM,QAAQ,GAAG,4FAA4F,CAAA;AAC7G,6GAA6G;AAC7G,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,yFAAyF;AACzF,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,cAAc,GAAG,+BAA+B,CAAA;AACtD,MAAM,OAAO,GAAG,uCAAuC,CAAA;AACvD,mHAAmH;AACnH,6EAA6E;AAC7E,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAE9B,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,IAAgC,EAAE,EAAE;IAC/E,IAAI,CAAC,IAAI,CAAC,cAAc;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAA;QACrE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,YAAY,IAAI,GAAG,GAAG,CAAC,CAAA;QAClE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,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAC5C,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QAClD,MAAM,GAAG,IAAI,CAAA;QACb,OAAO,GAAG,IAAI,CAAA;QACd,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { isPhoneLayout } from \"../../lib/phoneLayout\"\n\n// A bottom sheet follows the finger. A drag from its top 44px moves it 1:1, never up. Past 30% of its\n// height, or at 0.5px/ms, it closes; otherwise it returns. Buttons in that strip keep their press.\n// As on iOS, a pull down that starts anywhere else moves the sheet too once the content under the finger is at\n// its top: the first move decides, down and mostly vertical with every scroller under the finger at its top\n// takes the sheet; up, sideways, a move another handler took, a field, a control that pans by itself or a\n// finger that rested first (a hold: Sortable, a context menu) stays with the content.\nconst GRIP = 44\nconst CLOSE_SHARE = 0.3\nconst CLOSE_SPEED = 0.5\nconst REST = 100\nconst SETTLE = 400\nconst INTERACTIVE = \"a, button, input, select, textarea, [role='button']\"\nconst EDITABLE = \"input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='slider']\"\n// The move that settles which way the finger goes, under the browser's own slop so it can still be cancelled\nconst DECIDE = 4\n// A finger that rests this long holds (a Sortable row, a context menu) rather than pulls\nconst HOLD = 200\nconst DRAG_TRANSFORM = \"--dialog-panel-drag-transform\"\nconst EXITING = \"[data-exiting], [data-exiting-active]\"\n// A sheet at its full height says so: a sheet under it then steps back, as one presented from a sheet does on iOS.\n// A shorter sheet leaves the one under it in place, as a medium detent does.\nconst FULL = \"data-sheet-full\"\n\nconst watchFullHeight = (panel: HTMLElement, view: Window & typeof globalThis) => {\n if (!view.ResizeObserver) return () => {}\n const update = () => {\n const max = Number.parseFloat(view.getComputedStyle(panel).maxHeight)\n const full = Number.isFinite(max) && panel.offsetHeight >= max - 1\n if (full !== panel.hasAttribute(FULL)) panel.toggleAttribute(FULL, full)\n }\n const observer = new view.ResizeObserver(update)\n // Its height with the border, as `offsetHeight` reads it\n observer.observe(panel, { box: \"border-box\" })\n update()\n return () => {\n observer.disconnect()\n panel.removeAttribute(FULL)\n }\n}\n\n/** `close` returns false when the owner keeps the dialog open: the sheet then returns at once. */\nexport const attachSheetDrag = (panel: HTMLElement, close: (event: TouchEvent) => boolean | void) => {\n const view = panel.ownerDocument.defaultView\n if (!view) return () => {}\n const unwatchFull = watchFullHeight(panel, view)\n let startY: number | null = null\n // A touch in the content that may become a pull, until its first move says which way it goes\n let pending: { x: number; y: number; time: number; target: Element } | null = null\n // The pull began in the content: its release must not press what lies under the finger\n let fromContent = false\n let lastY = 0\n let lastTime = 0\n let speed = 0\n let settleTimer: number | undefined\n\n const stopSettling = () => {\n if (settleTimer !== undefined) view.clearTimeout(settleTimer)\n settleTimer = undefined\n panel.removeEventListener(\"transitionend\", onSettled)\n }\n const clearInline = () => {\n panel.style.transition = \"\"\n panel.style.transform = \"\"\n }\n const clear = () => {\n stopSettling()\n clearInline()\n panel.style.removeProperty(DRAG_TRANSFORM)\n }\n const onSettled = (event: TransitionEvent) => {\n if (event.target === panel && event.propertyName === \"transform\") clear()\n }\n const returnToRest = () => {\n stopSettling()\n if (view.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) {\n clear()\n return\n }\n panel.style.transition = \"transform var(--motion-enter) var(--cubic-enter)\"\n panel.style.transform = \"\"\n panel.style.removeProperty(DRAG_TRANSFORM)\n const durationText = view.getComputedStyle(panel).transitionDuration\n const duration = Number.parseFloat(durationText) * (durationText.endsWith(\"ms\") ? 1 : 1000)\n if (duration === 0) {\n clear()\n return\n }\n panel.addEventListener(\"transitionend\", onSettled)\n // A theme can lengthen the token or remove the transition altogether.\n // This cleanup must not cut a valid longer transition at the veto timeout.\n settleTimer = view.setTimeout(clear, Math.max(SETTLE, Number.isFinite(duration) ? duration : 0))\n }\n\n const begin = (clientY: number, time: number) => {\n stopSettling()\n startY = clientY\n lastY = clientY\n lastTime = time\n speed = 0\n }\n\n // Every element from the target up to the panel: one that can scroll up, or pans by itself, keeps the move.\n const contentTakes = (target: Element) => {\n for (let element: Element | null = target; element; element = element.parentElement) {\n if (element.scrollTop > 0) return true\n const touchAction = view.getComputedStyle(element).touchAction\n if (touchAction && touchAction !== \"auto\" && touchAction !== \"manipulation\" && !touchAction.includes(\"pan-y\")) return true\n if (element === panel) break\n }\n return false\n }\n\n const onStart = (event: TouchEvent) => {\n pending = null\n fromContent = false\n const phone = isPhoneLayout(panel)\n if (event.touches.length !== 1 || !phone || panel.closest(EXITING)) return\n const { clientX, clientY } = event.touches[0]\n const target = event.target instanceof view.Element ? event.target : null\n if (clientY - panel.getBoundingClientRect().top <= GRIP) {\n if (target?.closest(INTERACTIVE)) return\n begin(clientY, event.timeStamp)\n return\n }\n if (!target || target.closest(EDITABLE)) return\n pending = { x: clientX, y: clientY, time: event.timeStamp, target }\n }\n\n // The first move of a touch in the content: a pull down from the top takes the sheet from here on.\n const decide = (event: TouchEvent, touch: Touch) => {\n const start = pending!\n const dx = touch.clientX - start.x\n const dy = touch.clientY - start.y\n if (Math.max(Math.abs(dx), Math.abs(dy)) < DECIDE) return\n pending = null\n if (event.defaultPrevented || !event.cancelable || event.timeStamp - start.time > HOLD) return\n if (dy <= 0 || Math.abs(dx) > dy || contentTakes(start.target)) return\n fromContent = true\n begin(start.y, start.time)\n }\n\n const onMove = (event: TouchEvent) => {\n const touch = event.touches[0]\n if (startY === null && pending && touch) decide(event, touch)\n if (startY === null || !touch) return\n event.preventDefault()\n const { clientY } = touch\n speed = (clientY - lastY) / Math.max(1, event.timeStamp - lastTime)\n lastY = clientY\n lastTime = event.timeStamp\n panel.style.transition = \"none\"\n panel.style.transform = `translateY(${Math.max(0, clientY - startY)}px)`\n }\n\n const onEnd = (event: TouchEvent) => {\n pending = null\n if (startY === null) return\n const travelled = lastY - startY\n // A pull from the content ends where it lifted, not in a press of the row under it. A finger that barely\n // moved keeps its tap.\n if (fromContent && travelled > DECIDE && event.cancelable) event.preventDefault()\n fromContent = false\n // A finger that rested before lifting is no flick.\n const flick = speed > CLOSE_SPEED && event.timeStamp - lastTime < REST\n startY = null\n if (travelled <= 0) {\n clear()\n return\n }\n if (travelled > panel.getBoundingClientRect().height * CLOSE_SHARE || flick) {\n // The normal/exit-start CSS states retain this exact release position.\n // No inline transform or transition may mask the active CSS exit.\n panel.style.setProperty(DRAG_TRANSFORM, `translateY(${travelled}px)`)\n clearInline()\n // An owner can veto close. Register before close, which can detach us.\n settleTimer = view.setTimeout(() => {\n settleTimer = undefined\n if (panel.isConnected && !panel.closest(EXITING)) returnToRest()\n }, SETTLE)\n if (close(event) === false) returnToRest()\n return\n }\n returnToRest()\n }\n\n const onCancel = () => {\n startY = null\n pending = null\n fromContent = false\n clear()\n }\n\n // A retained panel can reopen before its exit completes. Its new entrance\n // must return to rest, not finish at the old gesture's release offset.\n const dialog = panel.closest(\"[data-plex-dialog]\")\n const stateObserver = dialog ? new view.MutationObserver((records) => {\n if (panel.style.getPropertyValue(DRAG_TRANSFORM) &&\n dialog.getAttribute(\"data-state\") === \"open\" &&\n records.some((record) => record.oldValue === \"closed\")) clear()\n }) : undefined\n stateObserver?.observe(dialog ?? panel, {\n attributes: true, attributeFilter: [\"data-state\"], attributeOldValue: true,\n })\n\n panel.addEventListener(\"touchstart\", onStart, { passive: true })\n panel.addEventListener(\"touchmove\", onMove, { passive: false })\n panel.addEventListener(\"touchend\", onEnd)\n panel.addEventListener(\"touchcancel\", onCancel)\n\n return () => {\n unwatchFull()\n stateObserver?.disconnect()\n panel.removeEventListener(\"touchstart\", onStart)\n panel.removeEventListener(\"touchmove\", onMove)\n panel.removeEventListener(\"touchend\", onEnd)\n panel.removeEventListener(\"touchcancel\", onCancel)\n startY = null\n pending = null\n clear()\n }\n}\n"]}
@@ -1,22 +1,79 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
+ import { useLayoutEffect, useRef, useState } from "react";
4
5
  import s from "@plexui/styles/components/NavigationRow/NavigationRow.module.css";
5
6
  import { Button, ButtonLink } from "../Button/index.js";
6
7
  import { Disclosure } from "../Icon/index.js";
8
+ import { useFieldColumns } from "../../lib/fieldRow.js";
7
9
  const shown = (value) => value !== null && value !== undefined && value !== false && value !== "";
10
+ /** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */
11
+ const valueFitsBeside = (row) => {
12
+ const content = row.querySelector("[data-navigation-row-content]");
13
+ if (!content)
14
+ return true;
15
+ const below = row.hasAttribute("data-value-below");
16
+ row.removeAttribute("data-value-below");
17
+ row.setAttribute("data-measuring", "");
18
+ const fits = [content, ...content.querySelectorAll("[data-navigation-row-part]")].every((element) => element.scrollWidth <= element.clientWidth + 0.5);
19
+ row.removeAttribute("data-measuring");
20
+ if (below)
21
+ row.setAttribute("data-value-below", "");
22
+ return fits;
23
+ };
8
24
  /**
9
25
  * A FieldGroup row that opens what it holds, as an iOS Settings drill-in: label, current value, chevron, one press.
10
26
  * Every other prop (id, events, ARIA, data attributes, className) goes to the pressable, so a caller states what
11
27
  * the row opens (`aria-haspopup`, `aria-expanded`) itself.
12
28
  */
13
29
  export function NavigationRow(props) {
14
- const { label, value, description, href, external, as, disabled, className, ref, target, rel, download, hrefLang, ping, referrerPolicy, ...rest } = props;
30
+ const { label, value, description, href, external, as, disabled, valuePlacement = "end", className, ref, target, rel, download, hrefLang, ping, referrerPolicy, ...rest } = props;
15
31
  // Only the link attributes given: an undefined `target` would override the new tab of an external link
16
32
  const linkAttributes = Object.fromEntries(Object.entries({ target, rel, download, hrefLang, ping, referrerPolicy }).filter(([, attribute]) => attribute !== undefined));
17
33
  const hasValue = shown(value);
18
34
  const hasDescription = shown(description);
19
- const content = (_jsxs("span", { className: s.Content, children: [_jsxs("span", { className: s.Text, children: [_jsx("span", { className: s.Label, children: label }), hasDescription && _jsx("span", { className: s.Description, children: description })] }), hasValue && _jsx("span", { className: s.Value, children: value }), _jsx(Disclosure, { className: s.Disclosure, "aria-hidden": "true", "data-no-autosize": "" })] }));
35
+ const rowRef = useRef(null);
36
+ // FieldGroup columns give the label a column of its own: a change of them measures again
37
+ const columns = useFieldColumns();
38
+ const [fits, setFits] = useState(true);
39
+ const auto = valuePlacement === "auto" && hasValue;
40
+ // "auto": measure on mount, when the label or value changes, and when the row's width changes
41
+ useLayoutEffect(() => {
42
+ const row = rowRef.current;
43
+ if (!auto || !row)
44
+ return;
45
+ let live = true;
46
+ const check = () => {
47
+ if (live)
48
+ setFits(valueFitsBeside(row));
49
+ };
50
+ check();
51
+ // A web font that arrives late (font-display: swap) changes the words' widths, not the row's
52
+ const fonts = typeof document !== "undefined" ? document.fonts : undefined;
53
+ fonts?.ready.then(check);
54
+ fonts?.addEventListener?.("loadingdone", check);
55
+ const stop = () => {
56
+ live = false;
57
+ fonts?.removeEventListener?.("loadingdone", check);
58
+ };
59
+ if (typeof ResizeObserver === "undefined")
60
+ return stop;
61
+ let width = row.getBoundingClientRect().width;
62
+ const observer = new ResizeObserver(() => {
63
+ const next = row.getBoundingClientRect().width;
64
+ if (next === width)
65
+ return;
66
+ width = next;
67
+ check();
68
+ });
69
+ observer.observe(row);
70
+ return () => {
71
+ stop();
72
+ observer.disconnect();
73
+ };
74
+ }, [auto, label, value, description, columns]);
75
+ const below = hasValue && (valuePlacement === "below" || (auto && !fits));
76
+ const content = (_jsxs("span", { className: s.Content, "data-navigation-row-content": "", children: [_jsxs("span", { className: s.Text, children: [_jsx("span", { className: s.Label, "data-navigation-row-part": "", children: label }), hasDescription && _jsx("span", { className: s.Description, children: description })] }), hasValue && _jsx("span", { className: s.Value, "data-navigation-row-part": "", children: value }), _jsx(Disclosure, { className: s.Disclosure, "aria-hidden": "true", "data-no-autosize": "" })] }));
20
77
  const shared = {
21
78
  className: clsx(s.Pressable, className),
22
79
  block: true,
@@ -24,6 +81,6 @@ export function NavigationRow(props) {
24
81
  variant: "ghost",
25
82
  "data-navigation-row": "",
26
83
  };
27
- return (_jsx("div", { className: s.NavigationRow, "data-row": "", "data-value": hasValue ? "" : undefined, "data-description": hasDescription ? "" : undefined, children: href !== undefined && !disabled ? (_jsx(ButtonLink, { ...rest, ...shared, ref: ref, href: href, external: external, as: as, ...linkAttributes, children: content })) : (_jsx(Button, { ...rest, ...shared, ref: ref, disabled: disabled, children: content })) }));
84
+ return (_jsx("div", { ref: rowRef, className: s.NavigationRow, "data-row": "", "data-value-below": below ? "" : undefined, "data-value": hasValue ? "" : undefined, "data-description": hasDescription ? "" : undefined, children: href !== undefined && !disabled ? (_jsx(ButtonLink, { ...rest, ...shared, ref: ref, href: href, external: external, as: as, ...linkAttributes, children: content })) : (_jsx(Button, { ...rest, ...shared, ref: ref, disabled: disabled, children: content })) }));
28
85
  }
29
86
  //# sourceMappingURL=NavigationRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationRow.js","sourceRoot":"","sources":["../../../../src/components/NavigationRow/NavigationRow.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AA6BpC,MAAM,KAAK,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAA;AAE5G;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,K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AAS,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjC,KAAC,UAAU,OACJ,IAAgC,KACjC,MAAM,EACV,GAAG,EAAE,GAA6B,EAClC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,EAA0B,KAC1B,cAAc,YAEjB,OAAO,GACG,CACd,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,OAAM,IAAgD,KAAM,MAAM,EAAE,GAAG,EAAE,GAA6B,EAAE,QAAQ,EAAE,QAAQ,YAC9H,OAAO,GACD,CACV,GACG,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport type { AnchorHTMLAttributes, ButtonHTMLAttributes, ComponentType, ReactNode, Ref } from \"react\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\nimport { Button, ButtonLink } from \"../Button\"\nimport { Disclosure } from \"../Icon\"\n\ntype LinkAttributes = Pick<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n \"target\" | \"rel\" | \"download\" | \"hrefLang\" | \"ping\" | \"referrerPolicy\"\n>\n\n// Events come from a button or, with `href`, a link (a disabled link is a button again), so handlers see either\nexport type NavigationRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, \"children\" | \"value\" | \"type\"> &\n LinkAttributes & {\n /** The row's name, where a row's label starts */\n label: ReactNode\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value?: ReactNode\n /** A line under the label; the row grows from 52 to hold it */\n description?: ReactNode\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href?: string\n /** Force external-link behavior for `href` */\n external?: boolean\n /** Link component for `href`, e.g. a router's link. @default PlexUIProvider linkComponent */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n as?: ComponentType<any> | \"a\"\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled?: boolean\n /** Ref for the row's pressable (a `button`, or the link's element) */\n ref?: Ref<HTMLButtonElement | HTMLAnchorElement | null>\n}\n\nconst shown = (value: ReactNode) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/**\n * A FieldGroup row that opens what it holds, as an iOS Settings drill-in: label, current value, chevron, one press.\n * Every other prop (id, events, ARIA, data attributes, className) goes to the pressable, so a caller states what\n * the row opens (`aria-haspopup`, `aria-expanded`) itself.\n */\nexport function NavigationRow(props: NavigationRowProps) {\n const { label, value, description, href, external, as, disabled, className, ref, target, rel, download, hrefLang, ping, referrerPolicy, ...rest } = props\n // Only the link attributes given: an undefined `target` would override the new tab of an external link\n const linkAttributes = Object.fromEntries(\n Object.entries({ target, rel, download, hrefLang, ping, referrerPolicy }).filter(([, attribute]) => attribute !== undefined),\n )\n const hasValue = shown(value)\n const hasDescription = shown(description)\n\n const content = (\n <span className={s.Content}>\n <span className={s.Text}>\n <span className={s.Label}>{label}</span>\n {hasDescription && <span className={s.Description}>{description}</span>}\n </span>\n {hasValue && <span className={s.Value}>{value}</span>}\n <Disclosure className={s.Disclosure} aria-hidden=\"true\" data-no-autosize=\"\" />\n </span>\n )\n\n const shared = {\n className: clsx(s.Pressable, className),\n block: true,\n color: \"secondary\",\n variant: \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n\n return (\n <div\n className={s.NavigationRow}\n data-row=\"\"\n data-value={hasValue ? \"\" : undefined}\n data-description={hasDescription ? \"\" : undefined}\n >\n {href !== undefined && !disabled ? (\n <ButtonLink\n {...(rest as Record<string, unknown>)}\n {...shared}\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n external={external}\n as={as as PlexUI.LinkComponent}\n {...linkAttributes}\n >\n {content}\n </ButtonLink>\n ) : (\n <Button {...(rest as ButtonHTMLAttributes<HTMLButtonElement>)} {...shared} ref={ref as Ref<HTMLButtonElement>} disabled={disabled}>\n {content}\n </Button>\n )}\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"NavigationRow.js","sourceRo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CACF,KAAC,MAAM,OAAM,IAAgD,KAAM,MAAM,EAAE,GAAG,EAAE,GAA6B,EAAE,QAAQ,EAAE,QAAQ,YAC9H,OAAO,GACD,CACV,GACG,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentType, type ReactNode, type Ref, useLayoutEffect, useRef, useState } from \"react\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\nimport { Button, ButtonLink } from \"../Button\"\nimport { Disclosure } from \"../Icon\"\nimport { useFieldColumns } from \"../../lib/fieldRow\"\n\ntype LinkAttributes = Pick<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n \"target\" | \"rel\" | \"download\" | \"hrefLang\" | \"ping\" | \"referrerPolicy\"\n>\n\n// Events come from a button or, with `href`, a link (a disabled link is a button again), so handlers see either\nexport type NavigationRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, \"children\" | \"value\" | \"type\"> &\n LinkAttributes & {\n /** The row's name, where a row's label starts */\n label: ReactNode\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value?: ReactNode\n /** A line under the label; the row grows from 52 to hold it */\n description?: ReactNode\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href?: string\n /** Force external-link behavior for `href` */\n external?: boolean\n /** Link component for `href`, e.g. a router's link. @default PlexUIProvider linkComponent */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n as?: ComponentType<any> | \"a\"\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled?: boolean\n /**\n * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while\n * it fits beside the label on one line, otherwise below (as Calendar sets a long value). @default \"end\"\n */\n valuePlacement?: \"end\" | \"below\" | \"auto\"\n /** Ref for the row's pressable (a `button`, or the link's element) */\n ref?: Ref<HTMLButtonElement | HTMLAnchorElement | null>\n}\n\nconst shown = (value: ReactNode) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */\nconst valueFitsBeside = (row: HTMLElement) => {\n const content = row.querySelector<HTMLElement>(\"[data-navigation-row-content]\")\n if (!content) return true\n const below = row.hasAttribute(\"data-value-below\")\n row.removeAttribute(\"data-value-below\")\n row.setAttribute(\"data-measuring\", \"\")\n const fits = [content, ...content.querySelectorAll<HTMLElement>(\"[data-navigation-row-part]\")].every(\n (element) => element.scrollWidth <= element.clientWidth + 0.5,\n )\n row.removeAttribute(\"data-measuring\")\n if (below) row.setAttribute(\"data-value-below\", \"\")\n return fits\n}\n\n/**\n * A FieldGroup row that opens what it holds, as an iOS Settings drill-in: label, current value, chevron, one press.\n * Every other prop (id, events, ARIA, data attributes, className) goes to the pressable, so a caller states what\n * the row opens (`aria-haspopup`, `aria-expanded`) itself.\n */\nexport function NavigationRow(props: NavigationRowProps) {\n const { label, value, description, href, external, as, disabled, valuePlacement = \"end\", className, ref, target, rel, download, hrefLang, ping, referrerPolicy, ...rest } = props\n // Only the link attributes given: an undefined `target` would override the new tab of an external link\n const linkAttributes = Object.fromEntries(\n Object.entries({ target, rel, download, hrefLang, ping, referrerPolicy }).filter(([, attribute]) => attribute !== undefined),\n )\n const hasValue = shown(value)\n const hasDescription = shown(description)\n const rowRef = useRef<HTMLDivElement>(null)\n // FieldGroup columns give the label a column of its own: a change of them measures again\n const columns = useFieldColumns()\n const [fits, setFits] = useState(true)\n const auto = valuePlacement === \"auto\" && hasValue\n\n // \"auto\": measure on mount, when the label or value changes, and when the row's width changes\n useLayoutEffect(() => {\n const row = rowRef.current\n if (!auto || !row) return\n let live = true\n const check = () => {\n if (live) setFits(valueFitsBeside(row))\n }\n check()\n // A web font that arrives late (font-display: swap) changes the words' widths, not the row's\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined\n fonts?.ready.then(check)\n fonts?.addEventListener?.(\"loadingdone\", check)\n const stop = () => {\n live = false\n fonts?.removeEventListener?.(\"loadingdone\", check)\n }\n if (typeof ResizeObserver === \"undefined\") return stop\n let width = row.getBoundingClientRect().width\n const observer = new ResizeObserver(() => {\n const next = row.getBoundingClientRect().width\n if (next === width) return\n width = next\n check()\n })\n observer.observe(row)\n return () => {\n stop()\n observer.disconnect()\n }\n }, [auto, label, value, description, columns])\n\n const below = hasValue && (valuePlacement === \"below\" || (auto && !fits))\n\n const content = (\n <span className={s.Content} data-navigation-row-content=\"\">\n <span className={s.Text}>\n <span className={s.Label} data-navigation-row-part=\"\">{label}</span>\n {hasDescription && <span className={s.Description}>{description}</span>}\n </span>\n {hasValue && <span className={s.Value} data-navigation-row-part=\"\">{value}</span>}\n <Disclosure className={s.Disclosure} aria-hidden=\"true\" data-no-autosize=\"\" />\n </span>\n )\n\n const shared = {\n className: clsx(s.Pressable, className),\n block: true,\n color: \"secondary\",\n variant: \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n\n return (\n <div\n ref={rowRef}\n className={s.NavigationRow}\n data-row=\"\"\n data-value-below={below ? \"\" : undefined}\n data-value={hasValue ? \"\" : undefined}\n data-description={hasDescription ? \"\" : undefined}\n >\n {href !== undefined && !disabled ? (\n <ButtonLink\n {...(rest as Record<string, unknown>)}\n {...shared}\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n external={external}\n as={as as PlexUI.LinkComponent}\n {...linkAttributes}\n >\n {content}\n </ButtonLink>\n ) : (\n <Button {...(rest as ButtonHTMLAttributes<HTMLButtonElement>)} {...shared} ref={ref as Ref<HTMLButtonElement>} disabled={disabled}>\n {content}\n </Button>\n )}\n </div>\n )\n}\n"]}
@@ -12,8 +12,8 @@ export type ColorWellProps = Omit<ColorPickerProps, "value" | "defaultValue" | "
12
12
  title?: string;
13
13
  /** Shows the eyedropper in the picker where the browser can pick a color from the screen (EyeDropper API). @default true */
14
14
  supportsEyedropper?: boolean;
15
- /** The kit's Picker Button sizes: `sm` 28px, `lg` 36px. @default "sm" */
16
- size?: "sm" | "lg";
15
+ /** The kit's Picker Button sizes, `sm` 28px and `lg` 36px, and `xs` 24px for the start of a 32px field. @default "sm" */
16
+ size?: "xs" | "sm" | "lg";
17
17
  /** When `true`, prevents the user from opening the picker. */
18
18
  disabled?: boolean;
19
19
  /** The name of the well. Submits its color with the owning form. */
@@ -1,4 +1,4 @@
1
- import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ComponentType, ReactNode, Ref } from "react";
1
+ import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentType, type ReactNode, type Ref } from "react";
2
2
  type LinkAttributes = Pick<AnchorHTMLAttributes<HTMLAnchorElement>, "target" | "rel" | "download" | "hrefLang" | "ping" | "referrerPolicy">;
3
3
  export type NavigationRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, "children" | "value" | "type"> & LinkAttributes & {
4
4
  /** The row's name, where a row's label starts */
@@ -15,6 +15,11 @@ export type NavigationRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement | H
15
15
  as?: ComponentType<any> | "a";
16
16
  /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */
17
17
  disabled?: boolean;
18
+ /**
19
+ * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while
20
+ * it fits beside the label on one line, otherwise below (as Calendar sets a long value). @default "end"
21
+ */
22
+ valuePlacement?: "end" | "below" | "auto";
18
23
  /** Ref for the row's pressable (a `button`, or the link's element) */
19
24
  ref?: Ref<HTMLButtonElement | HTMLAnchorElement | null>;
20
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/ui",
3
- "version": "0.54.0",
3
+ "version": "0.55.0",
4
4
  "description": "Modern design system for building high-quality applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -99,7 +99,7 @@
99
99
  "@maskito/core": "^5.2.2",
100
100
  "@maskito/kit": "^5.2.2",
101
101
  "@maskito/react": "^5.2.2",
102
- "@plexui/styles": "^0.12.0",
102
+ "@plexui/styles": "^0.13.0",
103
103
  "@radix-ui/react-dismissable-layer": "1.2.1",
104
104
  "@radix-ui/react-focus-guards": "1.2.0",
105
105
  "@radix-ui/react-focus-scope": "1.3.1",