@slurp-ui/react 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/Bloom/Bloom.js +3 -2
- package/dist/Bloom/Bloom.js.map +1 -1
- package/dist/Calendar/Calendar.d.ts +42 -0
- package/dist/Calendar/Calendar.js +178 -0
- package/dist/Calendar/Calendar.js.map +1 -0
- package/dist/Calendar/dates.d.ts +3 -0
- package/dist/Calendar/dates.js +46 -0
- package/dist/Calendar/dates.js.map +1 -0
- package/dist/Calendar/index.d.ts +3 -0
- package/dist/Calendar/index.js +2 -0
- package/dist/Carousel/Carousel.js +2 -0
- package/dist/Carousel/Carousel.js.map +1 -1
- package/dist/Choice/Choice.js +2 -0
- package/dist/Choice/Choice.js.map +1 -1
- package/dist/Code/Code.d.ts +38 -0
- package/dist/Code/Code.js +82 -0
- package/dist/Code/Code.js.map +1 -0
- package/dist/Code/index.d.ts +3 -0
- package/dist/Code/index.js +2 -0
- package/dist/Contents/Contents.d.ts +35 -0
- package/dist/Contents/Contents.js +63 -0
- package/dist/Contents/Contents.js.map +1 -0
- package/dist/Contents/index.d.ts +3 -0
- package/dist/Contents/index.js +2 -0
- package/dist/DateField/DateField.d.ts +29 -0
- package/dist/DateField/DateField.js +118 -0
- package/dist/DateField/DateField.js.map +1 -0
- package/dist/DateField/index.d.ts +3 -0
- package/dist/DateField/index.js +2 -0
- package/dist/Dialog/Dialog.js +73 -25
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dock/Dock.d.ts +5 -0
- package/dist/Dock/Dock.js +13 -2
- package/dist/Dock/Dock.js.map +1 -1
- package/dist/ErrorSummary/ErrorSummary.d.ts +26 -0
- package/dist/ErrorSummary/ErrorSummary.js +68 -0
- package/dist/ErrorSummary/ErrorSummary.js.map +1 -0
- package/dist/ErrorSummary/index.d.ts +3 -0
- package/dist/ErrorSummary/index.js +2 -0
- package/dist/FileDrop/FileDrop.d.ts +34 -0
- package/dist/FileDrop/FileDrop.js +145 -0
- package/dist/FileDrop/FileDrop.js.map +1 -0
- package/dist/FileDrop/index.d.ts +3 -0
- package/dist/FileDrop/index.js +2 -0
- package/dist/Filters/Filters.js +2 -0
- package/dist/Filters/Filters.js.map +1 -1
- package/dist/Footer/Footer.d.ts +37 -0
- package/dist/Footer/Footer.js +63 -0
- package/dist/Footer/Footer.js.map +1 -0
- package/dist/Footer/index.d.ts +3 -0
- package/dist/Footer/index.js +2 -0
- package/dist/Hairline/Hairline.d.ts +16 -0
- package/dist/Hairline/Hairline.js +23 -0
- package/dist/Hairline/Hairline.js.map +1 -0
- package/dist/Hairline/index.d.ts +3 -0
- package/dist/Hairline/index.js +2 -0
- package/dist/Hint/Hint.js +20 -1
- package/dist/Hint/Hint.js.map +1 -1
- package/dist/Kbd/Kbd.d.ts +7 -0
- package/dist/Kbd/Kbd.js +20 -0
- package/dist/Kbd/Kbd.js.map +1 -0
- package/dist/Kbd/index.d.ts +3 -0
- package/dist/Kbd/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +5 -1
- package/dist/ListRow/ListRow.js +5 -1
- package/dist/ListRow/ListRow.js.map +1 -1
- package/dist/Media/Media.d.ts +28 -0
- package/dist/Media/Media.js +65 -0
- package/dist/Media/Media.js.map +1 -0
- package/dist/Media/index.d.ts +3 -0
- package/dist/Media/index.js +2 -0
- package/dist/Notice/Notice.js +2 -0
- package/dist/Notice/Notice.js.map +1 -1
- package/dist/NumberField/NumberField.d.ts +32 -0
- package/dist/NumberField/NumberField.js +126 -0
- package/dist/NumberField/NumberField.js.map +1 -0
- package/dist/NumberField/index.d.ts +3 -0
- package/dist/NumberField/index.js +2 -0
- package/dist/PageNav/PageNav.d.ts +25 -0
- package/dist/PageNav/PageNav.js +57 -0
- package/dist/PageNav/PageNav.js.map +1 -0
- package/dist/PageNav/index.d.ts +3 -0
- package/dist/PageNav/index.js +2 -0
- package/dist/Pages/Pages.js +2 -0
- package/dist/Pages/Pages.js.map +1 -1
- package/dist/PinField/PinField.d.ts +26 -0
- package/dist/PinField/PinField.js +73 -0
- package/dist/PinField/PinField.js.map +1 -0
- package/dist/PinField/index.d.ts +3 -0
- package/dist/PinField/index.js +2 -0
- package/dist/Prose/Prose.d.ts +15 -0
- package/dist/Prose/Prose.js +25 -0
- package/dist/Prose/Prose.js.map +1 -0
- package/dist/Prose/index.d.ts +3 -0
- package/dist/Prose/index.js +2 -0
- package/dist/Quote/Quote.d.ts +19 -0
- package/dist/Quote/Quote.js +52 -0
- package/dist/Quote/Quote.js.map +1 -0
- package/dist/Quote/index.d.ts +3 -0
- package/dist/Quote/index.js +2 -0
- package/dist/Rail/Rail.d.ts +37 -0
- package/dist/Rail/Rail.js +61 -0
- package/dist/Rail/Rail.js.map +1 -0
- package/dist/Rail/index.d.ts +3 -0
- package/dist/Rail/index.js +2 -0
- package/dist/Rating/Rating.js +2 -0
- package/dist/Rating/Rating.js.map +1 -1
- package/dist/Search/Search.js +2 -0
- package/dist/Search/Search.js.map +1 -1
- package/dist/SecretField/SecretField.d.ts +17 -0
- package/dist/SecretField/SecretField.js +59 -0
- package/dist/SecretField/SecretField.js.map +1 -0
- package/dist/SecretField/index.d.ts +3 -0
- package/dist/SecretField/index.js +2 -0
- package/dist/Settings/Settings.js +2 -0
- package/dist/Settings/Settings.js.map +1 -1
- package/dist/SkipLink/SkipLink.d.ts +22 -0
- package/dist/SkipLink/SkipLink.js +32 -0
- package/dist/SkipLink/SkipLink.js.map +1 -0
- package/dist/SkipLink/index.d.ts +3 -0
- package/dist/SkipLink/index.js +2 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +7 -1
- package/dist/SlurpProvider/SlurpProvider.js +14 -6
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -1
- package/dist/Steps/Steps.js +2 -0
- package/dist/Steps/Steps.js.map +1 -1
- package/dist/Suggest/Suggest.js +2 -0
- package/dist/Suggest/Suggest.js.map +1 -1
- package/dist/Table/Table.js +2 -0
- package/dist/Table/Table.js.map +1 -1
- package/dist/Tag/Tag.d.ts +14 -0
- package/dist/Tag/Tag.js +26 -0
- package/dist/Tag/Tag.js.map +1 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/Tag/index.js +2 -0
- package/dist/Toast/Toast.js +31 -7
- package/dist/Toast/Toast.js.map +1 -1
- package/dist/index.d.ts +45 -4
- package/dist/index.js +23 -1
- package/dist/internal/labels.js +12 -0
- package/dist/internal/labels.js.map +1 -0
- package/dist/lib/labels.d.ts +175 -0
- package/dist/lib/labels.js +116 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/theme.d.ts +98 -3
- package/dist/lib/theme.js.map +1 -1
- package/dist/styles.css +1367 -111
- package/dist/tokens.css +9 -0
- package/dist/utils/focus.d.ts +1 -1
- package/dist/utils/focus.js +2 -2
- package/dist/utils/focus.js.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/useClipboard.d.ts +14 -0
- package/dist/utils/useClipboard.js +30 -0
- package/dist/utils/useClipboard.js.map +1 -0
- package/dist/utils/useScrollSpy.d.ts +14 -0
- package/dist/utils/useScrollSpy.js +27 -0
- package/dist/utils/useScrollSpy.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":[],"sources":["../../src/Dialog/Dialog.tsx"],"sourcesContent":["import { CloseIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n type ElementType,\n type MouseEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface DialogLabels {\n /** Name of the close button. */\n close: string;\n}\n\nexport const DIALOG_LABELS: DialogLabels = { close: 'Chiudi' };\n\nexport interface DialogOwnProps extends PartsProps<\n 'header' | 'title' | 'description' | 'body' | 'footer' | 'close'\n> {\n /** The dialog's name (its heading). */\n title: ReactNode;\n description?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Buttons at the bottom (one primary action). */\n actions?: ReactNode;\n /** A press on the backdrop closes it. Default true. */\n dismissible?: boolean;\n labels?: Partial<DialogLabels>;\n children?: ReactNode;\n}\n\nexport type DialogProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, DialogOwnProps>;\n\n/** Where a modal panel comes from: centred dialog, or a sheet from the bottom. */\ntype Variant = 'dialog' | 'sheet';\n\nconst reduced = () =>\n typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/** Shared by Dialog and Sheet: a native modal <dialog> (top layer, focus contained, Escape, inert page). */\nexport function useModal(props: DialogProps, variant: Variant) {\n const {\n as,\n css,\n className,\n title,\n description,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n actions,\n dismissible = true,\n labels: labelsProp,\n children,\n parts,\n partProps,\n classNames,\n ref,\n ...rest\n } = props;\n const labels = { ...DIALOG_LABELS, ...labelsProp };\n const [open, setOpen] = useControlled({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const dialog = useRef<HTMLDialogElement>(null);\n const opener = useRef<HTMLElement | null>(null);\n const id = useId();\n const name = variant === 'sheet' ? 'Sheet' : 'Dialog';\n const styled = useCss(name, 'root', css);\n const { part, style } = useParts(name, { parts, partProps, classNames });\n const root = useAnimationRoot({ ...rest, ref: useForkRef(ref as never, dialog) });\n\n useLayoutEffect(() => {\n const el = dialog.current;\n if (!el) return;\n if (open && !el.open) {\n opener.current =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n if (typeof el.showModal === 'function') el.showModal();\n else el.setAttribute('open', '');\n grow(el, opener.current, variant);\n } else if (!open && el.open) {\n if (typeof el.close === 'function') el.close();\n else el.removeAttribute('open');\n opener.current?.focus();\n opener.current = null;\n }\n }, [open, variant]);\n\n // Unmounting while open: give focus back.\n useEffect(() => () => opener.current?.focus(), []);\n\n const Root = (as ?? 'dialog') as ElementType;\n const element = (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-dialog', styled.className, className)}\n data-variant={variant}\n aria-labelledby={`${id}-title`}\n aria-describedby={description != null ? `${id}-description` : undefined}\n onCancel={(e: SyntheticEvent) => {\n // Escape: the state decides (controlled dialogs stay open until the parent closes them).\n e.preventDefault();\n setOpen(false);\n }}\n onClick={(e: MouseEvent<HTMLDialogElement>) => {\n if (dismissible && e.target === e.currentTarget) setOpen(false);\n }}\n {...root}\n >\n <div className=\"slurp-dialog-inner\">\n {part('header', 'div', {\n className: 'slurp-dialog-header',\n children: (\n <>\n <div className=\"slurp-dialog-heading\">\n {part('title', 'h2', {\n id: `${id}-title`,\n className: 'slurp-dialog-title',\n children: title,\n })}\n {description != null &&\n part('description', 'p', {\n id: `${id}-description`,\n className: 'slurp-dialog-description',\n children: description,\n })}\n </div>\n {part('close', Bubble, {\n className: 'slurp-dialog-close',\n label: labels.close,\n size: 'sm',\n onClick: () => setOpen(false),\n children: <CloseIcon />,\n })}\n </>\n ),\n })}\n {children != null && part('body', 'div', { className: 'slurp-dialog-body', children })}\n {actions != null &&\n part('footer', 'div', { className: 'slurp-dialog-footer', children: actions })}\n </div>\n </Root>\n </>\n );\n return element;\n}\n\n/**\n * The dialog grows out of the control that opened it (the Bloom rule applied to a modal): it starts at the opener's\n * box and settles in the centre. A sheet rises from the bottom edge.\n */\nfunction grow(el: HTMLElement, from: HTMLElement | null, variant: Variant) {\n if (reduced() || typeof el.animate !== 'function') return;\n const timing = { duration: 450, easing: 'cubic-bezier(0.2, 0.8, 0.2, 1)' };\n if (variant === 'sheet') {\n el.animate([{ transform: 'translateY(100%)' }, { transform: 'none' }], timing);\n return;\n }\n const to = el.getBoundingClientRect();\n const at = from?.getBoundingClientRect();\n if (!at || !to.width || !to.height) {\n el.animate(\n [\n { opacity: 0, transform: 'scale(0.96)' },\n { opacity: 1, transform: 'none' },\n ],\n timing,\n );\n return;\n }\n const dx = at.left + at.width / 2 - (to.left + to.width / 2);\n const dy = at.top + at.height / 2 - (to.top + to.height / 2);\n el.animate(\n [\n {\n transform: `translate(${dx}px, ${dy}px) scale(${at.width / to.width}, ${at.height / to.height})`,\n opacity: 0.4,\n },\n { transform: 'none', opacity: 1 },\n ],\n timing,\n );\n}\n\n/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */\nexport function Dialog<E extends ElementType = 'dialog'>(props: DialogProps<E>) {\n return useModal(useThemeProps('Dialog', props as DialogProps), 'dialog');\n}\n"],"mappings":";;;;;;;;;;;AAyBA,MAAa,gBAA8B,EAAE,OAAO,SAAS;AAwB7D,MAAM,gBACJ,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;;AAGrF,SAAgB,SAAS,OAAoB,SAAkB;CAC7D,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,MAAM,UACN,cAAc,OACd,cACA,SACA,cAAc,MACd,QAAQ,YACR,UACA,OACA,WACA,YACA,KACA,GAAG,SACD;CACJ,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG;CAAW;CACjD,MAAM,CAAC,MAAM,WAAW,cAAc;EACpC,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,SAAS,OAA0B,IAAI;CAC7C,MAAM,SAAS,OAA2B,IAAI;CAC9C,MAAM,KAAK,MAAM;CACjB,MAAM,OAAO,YAAY,UAAU,UAAU;CAC7C,MAAM,SAAS,OAAO,MAAM,QAAQ,GAAG;CACvC,MAAM,EAAE,MAAM,UAAU,SAAS,MAAM;EAAE;EAAO;EAAW;CAAW,CAAC;CACvE,MAAM,OAAO,iBAAiB;EAAE,GAAG;EAAM,KAAK,WAAW,KAAc,MAAM;CAAE,CAAC;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AAGA,SAAgB,OAAyC,OAAuB;CAC9E,OAAO,SAAS,cAAc,UAAU,KAAoB,GAAG,QAAQ;AACzE"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":[],"sources":["../../src/Dialog/Dialog.tsx"],"sourcesContent":["import { CloseIcon } from '@slurp-ui/icons';\nimport { duration, ease } from '@slurp-ui/tokens';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n type ElementType,\n type MouseEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { useLabels } from '../internal/labels';\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport interface DialogLabels {\n /** Name of the close button. */\n close: string;\n}\n\nexport const DIALOG_LABELS: DialogLabels = { close: 'Chiudi' };\n\nexport interface DialogOwnProps extends PartsProps<\n 'header' | 'title' | 'description' | 'body' | 'footer' | 'close'\n> {\n /** The dialog's name (its heading). */\n title: ReactNode;\n description?: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Buttons at the bottom (one primary action). */\n actions?: ReactNode;\n /** A press on the backdrop closes it. Default true. */\n dismissible?: boolean;\n labels?: Partial<DialogLabels>;\n children?: ReactNode;\n}\n\nexport type DialogProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, DialogOwnProps>;\n\n/** Where a modal panel comes from: centred dialog, or a sheet from the bottom. */\ntype Variant = 'dialog' | 'sheet';\n\nconst reduced = () =>\n typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/** Shared by Dialog and Sheet: a native modal <dialog> (top layer, focus contained, Escape, inert page). */\nexport function useModal(props: DialogProps, variant: Variant) {\n const {\n as,\n css,\n className,\n title,\n description,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n actions,\n dismissible = true,\n labels: labelsProp,\n children,\n parts,\n partProps,\n classNames,\n ref,\n ...rest\n } = props;\n const labels = { ...DIALOG_LABELS, ...useLabels('Dialog'), ...labelsProp };\n const [open, setOpen] = useControlled({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const dialog = useRef<HTMLDialogElement>(null);\n const opener = useRef<HTMLElement | null>(null);\n const id = useId();\n const name = variant === 'sheet' ? 'Sheet' : 'Dialog';\n const styled = useCss(name, 'root', css);\n const { part, style } = useParts(name, { parts, partProps, classNames });\n const root = useAnimationRoot({ ...rest, ref: useForkRef(ref as never, dialog) });\n\n const leaving = useRef<Animation | null>(null);\n\n useLayoutEffect(() => {\n const el = dialog.current;\n if (!el) return;\n if (open && leaving.current) {\n // Reopened while it was leaving: stop the exit, it is still open.\n leaving.current.cancel();\n leaving.current = null;\n return;\n }\n if (open && !el.open) {\n opener.current =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n if (typeof el.showModal === 'function') el.showModal();\n else el.setAttribute('open', '');\n grow(el, opener.current, variant);\n } else if (!open && el.open && !leaving.current) {\n const close = () => {\n leaving.current = null;\n if (typeof el.close === 'function') el.close();\n else el.removeAttribute('open');\n opener.current?.focus();\n opener.current = null;\n };\n const exit = shrink(el, opener.current, variant);\n if (!exit) return close();\n leaving.current = exit;\n exit.finished.then(\n () => {\n if (leaving.current === exit) {\n close();\n exit.cancel();\n }\n },\n () => {\n /* cancelled: reopened */\n },\n );\n }\n }, [open, variant]);\n\n // Unmounting while open: give focus back.\n useEffect(() => () => opener.current?.focus(), []);\n\n const Root = (as ?? 'dialog') as ElementType;\n const element = (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-dialog', styled.className, className)}\n data-variant={variant}\n aria-labelledby={`${id}-title`}\n aria-describedby={description != null ? `${id}-description` : undefined}\n onCancel={(e: SyntheticEvent) => {\n // Escape: the state decides (controlled dialogs stay open until the parent closes them).\n e.preventDefault();\n setOpen(false);\n }}\n onClick={(e: MouseEvent<HTMLDialogElement>) => {\n if (dismissible && e.target === e.currentTarget) setOpen(false);\n }}\n {...root}\n >\n <div className=\"slurp-dialog-inner\">\n {part('header', 'div', {\n className: 'slurp-dialog-header',\n children: (\n <>\n <div className=\"slurp-dialog-heading\">\n {part('title', 'h2', {\n id: `${id}-title`,\n className: 'slurp-dialog-title',\n children: title,\n })}\n {description != null &&\n part('description', 'p', {\n id: `${id}-description`,\n className: 'slurp-dialog-description',\n children: description,\n })}\n </div>\n {part('close', Bubble, {\n className: 'slurp-dialog-close',\n label: labels.close,\n size: 'sm',\n onClick: () => setOpen(false),\n children: <CloseIcon />,\n })}\n </>\n ),\n })}\n {children != null && part('body', 'div', { className: 'slurp-dialog-body', children })}\n {actions != null &&\n part('footer', 'div', { className: 'slurp-dialog-footer', children: actions })}\n </div>\n </Root>\n </>\n );\n return element;\n}\n\n/** Offset and uniform scale that put `el` on its opener's box (uniform, so the text never stretches). */\nfunction fromOpener(el: HTMLElement, from: HTMLElement | null) {\n const to = el.getBoundingClientRect();\n const at = from?.isConnected ? from.getBoundingClientRect() : undefined;\n if (!at || !to.width || !to.height || !at.width) return undefined;\n const dx = at.left + at.width / 2 - (to.left + to.width / 2);\n const dy = at.top + at.height / 2 - (to.top + to.height / 2);\n const s = Math.min(1, Math.max(0.5, Math.min(at.width / to.width, at.height / to.height)));\n return `translate(${dx}px, ${dy}px) scale(${s})`;\n}\n\nconst EASE = ease.settle;\n/** Milliseconds of a duration token (`'450ms'` → 450). */\nconst ms = (t: string) => Number.parseFloat(t);\n\n/**\n * The dialog grows out of the control that opened it (the Bloom rule applied to a modal): it starts at the opener's\n * place and settles in the centre. A sheet rises from the bottom edge. Reduced motion: a 150ms fade, as the engine.\n */\nfunction grow(el: HTMLElement, from: HTMLElement | null, variant: Variant) {\n if (typeof el.animate !== 'function') return;\n if (reduced()) {\n el.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150 });\n return;\n }\n const timing = { duration: ms(duration.panel), easing: EASE };\n if (variant === 'sheet') {\n el.animate([{ transform: 'translateY(100%)' }, { transform: 'none' }], timing);\n return;\n }\n const start = fromOpener(el, from) ?? 'scale(0.96)';\n el.animate(\n [\n { transform: start, opacity: 0 },\n { transform: 'none', opacity: 1 },\n ],\n timing,\n );\n}\n\n/**\n * The way out, quicker than the way in (200ms): back toward the opener, a sheet back down. Returns the animation to\n * wait for before closing, or nothing when there is nothing to play.\n */\nfunction shrink(el: HTMLElement, to: HTMLElement | null, variant: Variant): Animation | undefined {\n if (typeof el.animate !== 'function') return undefined;\n const fill = 'forwards' as const;\n if (reduced()) return el.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill });\n const timing = { duration: ms(duration.quick), easing: EASE, fill };\n if (variant === 'sheet') {\n return el.animate([{ transform: 'none' }, { transform: 'translateY(100%)' }], timing);\n }\n const end = fromOpener(el, to) ?? 'scale(0.96)';\n return el.animate(\n [\n { transform: 'none', opacity: 1 },\n { transform: end, opacity: 0 },\n ],\n timing,\n );\n}\n\n/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */\nexport function Dialog<E extends ElementType = 'dialog'>(props: DialogProps<E>) {\n return useModal(useThemeProps('Dialog', props as DialogProps), 'dialog');\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAa,gBAA8B,EAAE,OAAO,SAAS;AAwB7D,MAAM,gBACJ,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;;AAGrF,SAAgB,SAAS,OAAoB,SAAkB;CAC7D,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,MAAM,UACN,cAAc,OACd,cACA,SACA,cAAc,MACd,QAAQ,YACR,UACA,OACA,WACA,YACA,KACA,GAAG,SACD;CACJ,MAAM,SAAS;EAAE,GAAG;EAAe,GAAG,UAAU,QAAQ;EAAG,GAAG;CAAW;CACzE,MAAM,CAAC,MAAM,WAAW,cAAc;EACpC,OAAO;EACP,cAAc;EAC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G;EAAE,UAAU;EAAK;CAAK,CAAC;CAC1F,MAAM,SAAS;EAAE,UAAU,GAAG,SAAS,KAAK;EAAG,QAAQ;EAAM;CAAK;CAClE,IAAI,YAAY,SACd,OAAO,GAAG,QAAQ,CAAC,EAAE,WAAW,OAAO,GAAG,EAAE,WAAW,mBAAmB,CAAC,GAAG,MAAM;CAEtF,MAAM,MAAM,WAAW,IAAI,EAAE,KAAK;CAClC,OAAO,GAAG,QACR,CACE;EAAE,WAAW;EAAQ,SAAS;CAAE,GAChC;EAAE,WAAW;EAAK,SAAS;CAAE,CAC/B,GACA,MACF;AACF;;AAGA,SAAgB,OAAyC,OAAuB;CAC9E,OAAO,SAAS,cAAc,UAAU,KAAoB,GAAG,QAAQ;AACzE"}
|
package/dist/Dock/Dock.d.ts
CHANGED
|
@@ -107,6 +107,11 @@ export interface DockActionOwnProps {
|
|
|
107
107
|
countLabel?: (count: number) => string;
|
|
108
108
|
/** A small accent dot (a query is active while the search panel is closed). */
|
|
109
109
|
dot?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Text shown beside the icon when the bar has room for it (the phone search of a Dock without a path). The
|
|
112
|
+
* accessible name stays `label`.
|
|
113
|
+
*/
|
|
114
|
+
text?: string;
|
|
110
115
|
}
|
|
111
116
|
export type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<E, DockActionOwnProps>;
|
|
112
117
|
/** Round 48px action of the bar (filters, the phone search). */
|
package/dist/Dock/Dock.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useLabels } from "../internal/labels.js";
|
|
2
3
|
import { cx } from "../utils/src/index.js";
|
|
3
4
|
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
5
|
import { useAnimationRoot } from "../internal/animation.js";
|
|
@@ -39,6 +40,7 @@ function DockRoot(props) {
|
|
|
39
40
|
const { as, css, className, children, panel, panelLabel, focusPanel = true, onDismiss, inline = false, labels: labelsProp, ...rest } = useThemeProps("Dock", props);
|
|
40
41
|
const labels = {
|
|
41
42
|
...DOCK_LABELS,
|
|
43
|
+
...useLabels("Dock"),
|
|
42
44
|
...labelsProp
|
|
43
45
|
};
|
|
44
46
|
const compact = useMediaQuery(COMPACT_QUERY);
|
|
@@ -303,6 +305,7 @@ function DockSearch({ value: valueProp, defaultValue = "", onValueChange, label,
|
|
|
303
305
|
label: typed ? `${name}: “${value.trim()}”` : name,
|
|
304
306
|
expanded: ctx.searchOpen,
|
|
305
307
|
dot: typed && !ctx.searchOpen,
|
|
308
|
+
text: typed ? value.trim() : placeholder ?? labels.searchPlaceholder,
|
|
306
309
|
onClick: () => ctx.setSearchOpen(!ctx.searchOpen),
|
|
307
310
|
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
308
311
|
}), ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)] });
|
|
@@ -316,14 +319,17 @@ function DockActions({ children }) {
|
|
|
316
319
|
}
|
|
317
320
|
/** Round 48px action of the bar (filters, the phone search). */
|
|
318
321
|
function DockAction(props) {
|
|
319
|
-
const { label, children, expanded, count, countLabel = (n) => n === 1 ? "1 attivo" : `${n} attivi`, dot, className, css: _css, onClick, ...rest } = props;
|
|
322
|
+
const { label, children, expanded, count, countLabel = (n) => n === 1 ? "1 attivo" : `${n} attivi`, dot, text, className, css: _css, onClick, ...rest } = props;
|
|
320
323
|
const { panelId } = useDock("Dock.Action");
|
|
321
324
|
const root = useAnimationRoot(rest);
|
|
325
|
+
const shown = text?.replace(/…$/, "").trim();
|
|
326
|
+
const name = !shown ? label : shown.startsWith(label) ? shown : `${label}: ${shown}`;
|
|
322
327
|
return /* @__PURE__ */ jsxs("button", {
|
|
323
328
|
type: "button",
|
|
324
329
|
className: cx("slurp-dock-action", className),
|
|
325
330
|
"data-active": expanded || void 0,
|
|
326
|
-
"
|
|
331
|
+
"data-text": text ? "" : void 0,
|
|
332
|
+
"aria-label": count ? `${name}, ${countLabel(count)}` : name,
|
|
327
333
|
"aria-expanded": expanded,
|
|
328
334
|
"aria-controls": expanded !== void 0 ? panelId : void 0,
|
|
329
335
|
onClick,
|
|
@@ -334,6 +340,11 @@ function DockAction(props) {
|
|
|
334
340
|
className: "slurp-dock-action-icon",
|
|
335
341
|
children
|
|
336
342
|
}),
|
|
343
|
+
text ? /* @__PURE__ */ jsx("span", {
|
|
344
|
+
className: "slurp-dock-action-text",
|
|
345
|
+
"aria-hidden": "true",
|
|
346
|
+
children: text
|
|
347
|
+
}) : null,
|
|
337
348
|
count ? /* @__PURE__ */ jsx("span", {
|
|
338
349
|
className: "slurp-dock-action-count",
|
|
339
350
|
"aria-hidden": "true",
|
package/dist/Dock/Dock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Archivio…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n aria-label={count ? `${label}, ${countLabel(count)}` : label}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,\n Action: DockAction,\n}) as DockComponent;\n\nexport { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };\n"],"mappings":";;;;;;;;;;;;;;;AAoDA,MAAa,cAA0B;CACrC,YAAY;CACZ,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,mBAAmB;CACnB,WAAW;CACX,UAAU,GAAG,MAAM,GAAG,MAAM,IAAI,qBAAqB,GAAG,EAAE,iBAAiB,IAAI,EAAE,MAAM;CACvF,YAAY,GAAG,MAAM,qCAAqC,EAAE,MAAM;CAClE,aAAa;AACf;AAeA,MAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,QAAQ,MAAc;CAC7B,MAAM,MAAM,WAAW,WAAW;CAClC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,WAAW,KAAK,wBAAwB;CAClE,OAAO;AACT;;;;;;AA2BA,SAAS,SAAwC,OAAqB;CACpE,MAAM,EACJ,IACA,KACA,WACA,UACA,OACA,YACA,aAAa,MACb,WACA,SAAS,OACT,QAAQ,YACR,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,SAAS;EAAE,GAAG;EAAa,GAAG;CAAW;CAC/C,MAAM,UAAU,cAAc,aAAa;CAC3C,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,YAAY,iBAAiB,SAA6B,IAAI;CACrE,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,cAAc,OAAyB,IAAI;CACjD,MAAM,UAAU,GAAG,MAAM,EAAE;CAC3B,MAAM,YAAY,WAAW;CAC7B,MAAM,QAAQ,YAAY,OAAO;CACjC,MAAM,OAAO,aAAc,SAAS,QAAQ,UAAU;CACtD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI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MAAO,MAAM,IAAI,aAAa,GAAG,EAAE,UACjD,KACA,WACA,KAAK,MACL,SACA,GAAG,SACD;CACJ,MAAM,EAAE,YAAY,QAAQ,aAAa;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAC,UAAD;EACE,MAAK;EACL,WAAW,GAAG,qBAAqB,SAAS;EAC5C,eAAa,YAAY,KAAA;EACzB,cAAY,QAAQ,GAAG,MAAM,IAAI,WAAW,KAAK,MAAM;EACvD,iBAAe;EACf,iBAAe,aAAa,KAAA,IAAY,UAAU,KAAA;EACzC;EACT,GAAI;EARN,UAAA;GAUE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC;GACG,CAAA;GACL,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useLabels } from '../internal/labels';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Archivio…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...useLabels('Dock'), ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n text={typed ? value.trim() : (placeholder ?? labels.searchPlaceholder)}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n /**\n * Text shown beside the icon when the bar has room for it (the phone search of a Dock without a path). The\n * accessible name stays `label`.\n */\n text?: string;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n text,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n // The visible text is part of the name (WCAG 2.5.3): the placeholder when it already says it, else \"label: text\".\n const shown = text?.replace(/…$/, '').trim();\n const name = !shown ? label : shown.startsWith(label) ? shown : `${label}: ${shown}`;\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n data-text={text ? '' : undefined}\n aria-label={count ? `${name}, ${countLabel(count)}` : name}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {text ? (\n <span className=\"slurp-dock-action-text\" aria-hidden=\"true\">\n {text}\n </span>\n ) : null}\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,\n Action: DockAction,\n}) as DockComponent;\n\nexport { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,MAAa,cAA0B;CACrC,YAAY;CACZ,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,mBAAmB;CACnB,WAAW;CACX,UAAU,GAAG,MAAM,GAAG,MAAM,IAAI,qBAAqB,GAAG,EAAE,iBAAiB,IAAI,EAAE,MAAM;CACvF,YAAY,GAAG,MAAM,qCAAqC,EAAE,MAAM;CAClE,aAAa;AACf;AAeA,MAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,QAAQ,MAAc;CAC7B,MAAM,MAAM,WAAW,WAAW;CAClC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,WAAW,KAAK,wBAAwB;CAClE,OAAO;AACT;;;;;;A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a,KAAA,IAAY,UAAU,KAAA;EACzC;EACT,GAAI;EATN,UAAA;GAWE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC;GACG,CAAA;GACL,OACC,oBAAC,QAAD;IAAM,WAAU;IAAyB,eAAY;IAClD,UAAA;GACG,CAAA,IACJ;GACH,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface ErrorSummaryLabels {
|
|
5
|
+
/** The title, from the number of errors. */
|
|
6
|
+
title: (count: number) => string;
|
|
7
|
+
}
|
|
8
|
+
export declare const ERRORSUMMARY_LABELS: ErrorSummaryLabels;
|
|
9
|
+
export interface ErrorSummaryItem {
|
|
10
|
+
/** id of the field's input: the link goes there and focuses it. */
|
|
11
|
+
id: string;
|
|
12
|
+
message: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export interface ErrorSummaryOwnProps {
|
|
15
|
+
errors: readonly ErrorSummaryItem[];
|
|
16
|
+
/** Move focus to the summary when errors appear (after a submit). Default true. */
|
|
17
|
+
focusOnShow?: boolean;
|
|
18
|
+
labels?: Partial<ErrorSummaryLabels>;
|
|
19
|
+
}
|
|
20
|
+
export type ErrorSummaryProps<E extends ElementType = 'div'> = PolymorphicProps<E, ErrorSummaryOwnProps>;
|
|
21
|
+
/**
|
|
22
|
+
* The errors of a long form, at its top after a submit: a title with the count and one link per error that takes you to
|
|
23
|
+
* the field. It takes focus when it appears, so a screen reader reads it first. Each field still shows its own error.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ErrorSummary<E extends ElementType = 'div'>(props: ErrorSummaryProps<E>): import("react").JSX.Element | null;
|
|
26
|
+
//# sourceMappingURL=ErrorSummary.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels } from "../internal/labels.js";
|
|
3
|
+
import { cx } from "../utils/src/index.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { useEffect, useId } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ErrorIcon } from "@slurp-ui/icons";
|
|
9
|
+
// src/ErrorSummary/ErrorSummary.tsx
|
|
10
|
+
const ERRORSUMMARY_LABELS = { title: (n) => n === 1 ? "C’è un errore da correggere" : `Ci sono ${n} errori da correggere` };
|
|
11
|
+
/**
|
|
12
|
+
* The errors of a long form, at its top after a submit: a title with the count and one link per error that takes you to
|
|
13
|
+
* the field. It takes focus when it appears, so a screen reader reads it first. Each field still shows its own error.
|
|
14
|
+
*/
|
|
15
|
+
function ErrorSummary(props) {
|
|
16
|
+
const { as, css, className, errors, focusOnShow = true, labels: labelsProp, ...rest } = useThemeProps("ErrorSummary", props);
|
|
17
|
+
const labels = {
|
|
18
|
+
...ERRORSUMMARY_LABELS,
|
|
19
|
+
...useLabels("ErrorSummary"),
|
|
20
|
+
...labelsProp
|
|
21
|
+
};
|
|
22
|
+
const id = useId();
|
|
23
|
+
const Root = as ?? "div";
|
|
24
|
+
const styled = useCss("ErrorSummary", "root", css);
|
|
25
|
+
const root = useAnimationRoot(rest);
|
|
26
|
+
const key = errors.map((e) => e.id).join(" ");
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (focusOnShow && key) document.getElementById(id)?.focus();
|
|
29
|
+
}, [
|
|
30
|
+
focusOnShow,
|
|
31
|
+
key,
|
|
32
|
+
id
|
|
33
|
+
]);
|
|
34
|
+
if (!errors.length) return null;
|
|
35
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
36
|
+
id,
|
|
37
|
+
className: cx("slurp-error-summary", styled.className, className),
|
|
38
|
+
role: "alert",
|
|
39
|
+
tabIndex: -1,
|
|
40
|
+
"aria-labelledby": `${id}-title`,
|
|
41
|
+
...root,
|
|
42
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
43
|
+
className: "slurp-error-summary-title",
|
|
44
|
+
id: `${id}-title`,
|
|
45
|
+
children: [/* @__PURE__ */ jsx(ErrorIcon, {
|
|
46
|
+
size: 20,
|
|
47
|
+
"aria-hidden": true
|
|
48
|
+
}), labels.title(errors.length)]
|
|
49
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
50
|
+
className: "slurp-error-summary-list",
|
|
51
|
+
children: errors.map((e) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
|
|
52
|
+
className: "slurp-error-summary-link",
|
|
53
|
+
href: `#${e.id}`,
|
|
54
|
+
onClick: (event) => {
|
|
55
|
+
const field = document.getElementById(e.id);
|
|
56
|
+
if (!field) return;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
field.focus();
|
|
59
|
+
field.scrollIntoView({ block: "center" });
|
|
60
|
+
},
|
|
61
|
+
children: e.message
|
|
62
|
+
}) }, e.id))
|
|
63
|
+
})]
|
|
64
|
+
})] });
|
|
65
|
+
}
|
|
66
|
+
export { ERRORSUMMARY_LABELS, ErrorSummary };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=ErrorSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorSummary.js","names":[],"sources":["../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["import { ErrorIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useEffect, useId, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useLabels } from '../internal/labels';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface ErrorSummaryLabels {\n /** The title, from the number of errors. */\n title: (count: number) => string;\n}\n\nexport const ERRORSUMMARY_LABELS: ErrorSummaryLabels = {\n title: (n) => (n === 1 ? 'C’è un errore da correggere' : `Ci sono ${n} errori da correggere`),\n};\n\nexport interface ErrorSummaryItem {\n /** id of the field's input: the link goes there and focuses it. */\n id: string;\n message: ReactNode;\n}\n\nexport interface ErrorSummaryOwnProps {\n errors: readonly ErrorSummaryItem[];\n /** Move focus to the summary when errors appear (after a submit). Default true. */\n focusOnShow?: boolean;\n labels?: Partial<ErrorSummaryLabels>;\n}\n\nexport type ErrorSummaryProps<E extends ElementType = 'div'> = PolymorphicProps<\n E,\n ErrorSummaryOwnProps\n>;\n\n/**\n * The errors of a long form, at its top after a submit: a title with the count and one link per error that takes you to\n * the field. It takes focus when it appears, so a screen reader reads it first. Each field still shows its own error.\n */\nexport function ErrorSummary<E extends ElementType = 'div'>(props: ErrorSummaryProps<E>) {\n const {\n as,\n css,\n className,\n errors,\n focusOnShow = true,\n labels: labelsProp,\n ...rest\n } = useThemeProps('ErrorSummary', props as ErrorSummaryProps);\n const labels = { ...ERRORSUMMARY_LABELS, ...useLabels('ErrorSummary'), ...labelsProp };\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('ErrorSummary', 'root', css);\n const root = useAnimationRoot(rest);\n const key = errors.map((e) => e.id).join(' ');\n useEffect(() => {\n if (focusOnShow && key) document.getElementById(id)?.focus();\n }, [focusOnShow, key, id]);\n if (!errors.length) return null;\n return (\n <>\n {styled.style}\n <Root\n id={id}\n className={cx('slurp-error-summary', styled.className, className)}\n role=\"alert\"\n tabIndex={-1}\n aria-labelledby={`${id}-title`}\n {...root}\n >\n <p className=\"slurp-error-summary-title\" id={`${id}-title`}>\n <ErrorIcon size={20} aria-hidden />\n {labels.title(errors.length)}\n </p>\n <ul className=\"slurp-error-summary-list\">\n {errors.map((e) => (\n <li key={e.id}>\n <a\n className=\"slurp-error-summary-link\"\n href={`#${e.id}`}\n onClick={(event) => {\n const field = document.getElementById(e.id);\n if (!field) return;\n event.preventDefault();\n field.focus();\n field.scrollIntoView({ block: 'center' });\n }}\n >\n {e.message}\n </a>\n </li>\n ))}\n </ul>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAcA,MAAa,sBAA0C,EACrD,QAAQ,MAAO,MAAM,IAAI,gCAAgC,WAAW,EAAE,uBACxE;;;;;AAwBA,SAAgB,aAA4C,OAA6B;CACvF,MAAM,EACJ,IACA,KACA,WACA,QACA,cAAc,MACd,QAAQ,YACR,GAAG,SACD,cAAc,gBAAgB,KAA0B;CAC5D,MAAM,SAAS;EAAE,GAAG;EAAqB,GAAG,UAAU,cAAc;EAAG,GAAG;CAAW;CACrF,MAAM,KAAK,MAAM;CACjB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,gBAAgB,QAAQ,GAAG;CACjD,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,MAAM,OAAO,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG;CAC5C,gBAAgB;EACd,IAAI,eAAe,KAAK,SAAS,eAAe,EAAE,CAAC,EAAE,MAAM;CAC7D,GAAG;EAAC;EAAa;EAAK;CAAE,CAAC;CACzB,IAAI,CAAC,OAAO,QAAQ,OAAO;CAC3B,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EACM;EACJ,WAAW,GAAG,uBAAuB,OAAO,WAAW,SAAS;EAChE,MAAK;EACL,UAAU;EACV,mBAAiB,GAAG,GAAG;EACvB,GAAI;EANN,UAAA,CAQE,qBAAC,KAAD;GAAG,WAAU;GAA4B,IAAI,GAAG,GAAG;GAAnD,UAAA,CACE,oBAAC,WAAD;IAAW,MAAM;IAAI,eAAA;GAAa,CAAA,GACjC,OAAO,MAAM,OAAO,MAAM,CAC1B;EACH,CAAA,GAAA,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,OAAO,KAAK,MACX,oBAAC,MAAD,EAAA,UACE,oBAAC,KAAD;IACE,WAAU;IACV,MAAM,IAAI,EAAE;IACZ,UAAU,UAAU;KAClB,MAAM,QAAQ,SAAS,eAAe,EAAE,EAAE;KAC1C,IAAI,CAAC,OAAO;KACZ,MAAM,eAAe;KACrB,MAAM,MAAM;KACZ,MAAM,eAAe,EAAE,OAAO,SAAS,CAAC;IAC1C;IAEC,UAAA,EAAE;GACF,CAAA,EACD,GAdK,EAAE,EAcP,CACL;EACC,CAAA,CACA;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface FileDropLabels {
|
|
5
|
+
/** The button that opens the file picker. */
|
|
6
|
+
browse: string;
|
|
7
|
+
/** Beside it: you can drop files too. */
|
|
8
|
+
drop: string;
|
|
9
|
+
/** Name of each remove button. */
|
|
10
|
+
remove: (name: string) => string;
|
|
11
|
+
}
|
|
12
|
+
export declare const FILEDROP_LABELS: FileDropLabels;
|
|
13
|
+
export interface FileDropOwnProps {
|
|
14
|
+
label: ReactNode;
|
|
15
|
+
hint?: ReactNode;
|
|
16
|
+
value?: File[];
|
|
17
|
+
defaultValue?: File[];
|
|
18
|
+
onValueChange?: (files: File[]) => void;
|
|
19
|
+
/** `accept` of the input ("image/*,.pdf"). */
|
|
20
|
+
accept?: string;
|
|
21
|
+
/** Default true. */
|
|
22
|
+
multiple?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Upload progress by file name, 0–100: a bar under each file. */
|
|
25
|
+
progress?: Record<string, number>;
|
|
26
|
+
labels?: Partial<FileDropLabels>;
|
|
27
|
+
}
|
|
28
|
+
export type FileDropProps<E extends ElementType = 'div'> = PolymorphicProps<E, FileDropOwnProps>;
|
|
29
|
+
/**
|
|
30
|
+
* Files to upload: a drop area with a real file input (so the keyboard and the system picker work), then the list of
|
|
31
|
+
* chosen files with their size, a remove button and, while uploading, their progress.
|
|
32
|
+
*/
|
|
33
|
+
export declare function FileDrop<E extends ElementType = 'div'>(props: FileDropProps<E>): import("react").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=FileDrop.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels } from "../internal/labels.js";
|
|
3
|
+
import { cx } from "../utils/src/index.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { Bubble } from "../Bubble/Bubble.js";
|
|
7
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
8
|
+
import { Progress } from "../Progress/Progress.js";
|
|
9
|
+
import { useId, useState } from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { CloseIcon, UploadIcon } from "@slurp-ui/icons";
|
|
12
|
+
// src/FileDrop/FileDrop.tsx
|
|
13
|
+
const FILEDROP_LABELS = {
|
|
14
|
+
browse: "Scegli i file",
|
|
15
|
+
drop: "oppure trascinali qui",
|
|
16
|
+
remove: (name) => `Rimuovi ${name}`
|
|
17
|
+
};
|
|
18
|
+
const size = (bytes) => bytes < 1024 ? `${bytes} B` : bytes < 1024 ** 2 ? `${Math.round(bytes / 1024)} KB` : `${(bytes / 1024 ** 2).toFixed(1)} MB`;
|
|
19
|
+
/**
|
|
20
|
+
* Files to upload: a drop area with a real file input (so the keyboard and the system picker work), then the list of
|
|
21
|
+
* chosen files with their size, a remove button and, while uploading, their progress.
|
|
22
|
+
*/
|
|
23
|
+
function FileDrop(props) {
|
|
24
|
+
const { as, css, className, label, hint, value: valueProp, defaultValue = [], onValueChange, accept, multiple = true, disabled = false, progress, labels: labelsProp, ...rest } = useThemeProps("FileDrop", props);
|
|
25
|
+
const labels = {
|
|
26
|
+
...FILEDROP_LABELS,
|
|
27
|
+
...useLabels("FileDrop"),
|
|
28
|
+
...labelsProp
|
|
29
|
+
};
|
|
30
|
+
const [files, setFiles] = useControlled({
|
|
31
|
+
value: valueProp,
|
|
32
|
+
defaultValue,
|
|
33
|
+
onChange: onValueChange
|
|
34
|
+
});
|
|
35
|
+
const [over, setOver] = useState(false);
|
|
36
|
+
const id = useId();
|
|
37
|
+
const Root = as ?? "div";
|
|
38
|
+
const styled = useCss("FileDrop", "root", css);
|
|
39
|
+
const root = useAnimationRoot(rest);
|
|
40
|
+
const add = (list) => {
|
|
41
|
+
if (!list?.length) return;
|
|
42
|
+
const picked = [...list];
|
|
43
|
+
setFiles(multiple ? [...files, ...picked] : picked.slice(0, 1));
|
|
44
|
+
};
|
|
45
|
+
const drop = (e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
setOver(false);
|
|
48
|
+
if (!disabled) add(e.dataTransfer.files);
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
51
|
+
className: cx("slurp-file-drop", styled.className, className),
|
|
52
|
+
"data-disabled": disabled || void 0,
|
|
53
|
+
...root,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: "slurp-field-label",
|
|
57
|
+
id: `${id}-label`,
|
|
58
|
+
children: label
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ jsxs("div", {
|
|
61
|
+
className: "slurp-file-drop-area",
|
|
62
|
+
"data-over": over || void 0,
|
|
63
|
+
onDragOver: (e) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
if (!disabled) setOver(true);
|
|
66
|
+
},
|
|
67
|
+
onDragLeave: () => setOver(false),
|
|
68
|
+
onDrop: drop,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx(UploadIcon, {
|
|
71
|
+
size: 24,
|
|
72
|
+
"aria-hidden": true
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx("label", {
|
|
75
|
+
className: "slurp-file-drop-browse",
|
|
76
|
+
htmlFor: `${id}-input`,
|
|
77
|
+
children: labels.browse
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsx("span", {
|
|
80
|
+
className: "slurp-file-drop-hint",
|
|
81
|
+
children: labels.drop
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx("input", {
|
|
84
|
+
id: `${id}-input`,
|
|
85
|
+
className: "slurp-visually-hidden",
|
|
86
|
+
type: "file",
|
|
87
|
+
accept,
|
|
88
|
+
multiple,
|
|
89
|
+
disabled,
|
|
90
|
+
"aria-labelledby": `${id}-label ${id}-input-label`,
|
|
91
|
+
"aria-describedby": hint != null ? `${id}-hint` : void 0,
|
|
92
|
+
onChange: (e) => {
|
|
93
|
+
add(e.target.files);
|
|
94
|
+
e.target.value = "";
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ jsx("span", {
|
|
98
|
+
id: `${id}-input-label`,
|
|
99
|
+
hidden: true,
|
|
100
|
+
children: labels.browse
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}),
|
|
104
|
+
hint != null && /* @__PURE__ */ jsx("p", {
|
|
105
|
+
className: "slurp-field-hint",
|
|
106
|
+
id: `${id}-hint`,
|
|
107
|
+
children: hint
|
|
108
|
+
}),
|
|
109
|
+
files.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
110
|
+
className: "slurp-file-drop-list",
|
|
111
|
+
"aria-labelledby": `${id}-label`,
|
|
112
|
+
children: files.map((file, i) => /* @__PURE__ */ jsxs("li", {
|
|
113
|
+
className: "slurp-file-drop-file",
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx("span", {
|
|
116
|
+
className: "slurp-file-drop-name",
|
|
117
|
+
children: file.name
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsx("span", {
|
|
120
|
+
className: "slurp-file-drop-size",
|
|
121
|
+
children: size(file.size)
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsx(Bubble, {
|
|
124
|
+
appearance: "plain",
|
|
125
|
+
tone: "neutral",
|
|
126
|
+
size: "sm",
|
|
127
|
+
label: labels.remove(file.name),
|
|
128
|
+
disabled,
|
|
129
|
+
onClick: () => setFiles(files.filter((_, j) => j !== i)),
|
|
130
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { size: 18 })
|
|
131
|
+
}),
|
|
132
|
+
progress?.[file.name] !== void 0 && /* @__PURE__ */ jsx(Progress, {
|
|
133
|
+
className: "slurp-file-drop-progress",
|
|
134
|
+
value: progress[file.name],
|
|
135
|
+
label: file.name
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}, `${file.name}-${i}`))
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
})] });
|
|
142
|
+
}
|
|
143
|
+
export { FILEDROP_LABELS, FileDrop };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=FileDrop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDrop.js","names":[],"sources":["../../src/FileDrop/FileDrop.tsx"],"sourcesContent":["import { CloseIcon, UploadIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n useState,\n type ChangeEvent,\n type DragEvent,\n type ElementType,\n type ReactNode,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useLabels } from '../internal/labels';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { Progress } from '../Progress/Progress';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface FileDropLabels {\n /** The button that opens the file picker. */\n browse: string;\n /** Beside it: you can drop files too. */\n drop: string;\n /** Name of each remove button. */\n remove: (name: string) => string;\n}\n\nexport const FILEDROP_LABELS: FileDropLabels = {\n browse: 'Scegli i file',\n drop: 'oppure trascinali qui',\n remove: (name) => `Rimuovi ${name}`,\n};\n\nexport interface FileDropOwnProps {\n label: ReactNode;\n hint?: ReactNode;\n value?: File[];\n defaultValue?: File[];\n onValueChange?: (files: File[]) => void;\n /** `accept` of the input (\"image/*,.pdf\"). */\n accept?: string;\n /** Default true. */\n multiple?: boolean;\n disabled?: boolean;\n /** Upload progress by file name, 0–100: a bar under each file. */\n progress?: Record<string, number>;\n labels?: Partial<FileDropLabels>;\n}\n\nexport type FileDropProps<E extends ElementType = 'div'> = PolymorphicProps<E, FileDropOwnProps>;\n\nconst size = (bytes: number) =>\n bytes < 1024\n ? `${bytes} B`\n : bytes < 1024 ** 2\n ? `${Math.round(bytes / 1024)} KB`\n : `${(bytes / 1024 ** 2).toFixed(1)} MB`;\n\n/**\n * Files to upload: a drop area with a real file input (so the keyboard and the system picker work), then the list of\n * chosen files with their size, a remove button and, while uploading, their progress.\n */\nexport function FileDrop<E extends ElementType = 'div'>(props: FileDropProps<E>) {\n const {\n as,\n css,\n className,\n label,\n hint,\n value: valueProp,\n defaultValue = [],\n onValueChange,\n accept,\n multiple = true,\n disabled = false,\n progress,\n labels: labelsProp,\n ...rest\n } = useThemeProps('FileDrop', props as FileDropProps);\n const labels = { ...FILEDROP_LABELS, ...useLabels('FileDrop'), ...labelsProp };\n const [files, setFiles] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const [over, setOver] = useState(false);\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('FileDrop', 'root', css);\n const root = useAnimationRoot(rest);\n const add = (list: FileList | null) => {\n if (!list?.length) return;\n const picked = [...list];\n setFiles(multiple ? [...files, ...picked] : picked.slice(0, 1));\n };\n const drop = (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n setOver(false);\n if (!disabled) add(e.dataTransfer.files);\n };\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-file-drop', styled.className, className)}\n data-disabled={disabled || undefined}\n {...root}\n >\n <span className=\"slurp-field-label\" id={`${id}-label`}>\n {label}\n </span>\n <div\n className=\"slurp-file-drop-area\"\n data-over={over || undefined}\n onDragOver={(e) => {\n e.preventDefault();\n if (!disabled) setOver(true);\n }}\n onDragLeave={() => setOver(false)}\n onDrop={drop}\n >\n <UploadIcon size={24} aria-hidden />\n <label className=\"slurp-file-drop-browse\" htmlFor={`${id}-input`}>\n {labels.browse}\n </label>\n <span className=\"slurp-file-drop-hint\">{labels.drop}</span>\n <input\n id={`${id}-input`}\n className=\"slurp-visually-hidden\"\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n aria-labelledby={`${id}-label ${id}-input-label`}\n aria-describedby={hint != null ? `${id}-hint` : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n add(e.target.files);\n e.target.value = '';\n }}\n />\n <span id={`${id}-input-label`} hidden>\n {labels.browse}\n </span>\n </div>\n {hint != null && (\n <p className=\"slurp-field-hint\" id={`${id}-hint`}>\n {hint}\n </p>\n )}\n {files.length > 0 && (\n <ul className=\"slurp-file-drop-list\" aria-labelledby={`${id}-label`}>\n {files.map((file, i) => (\n <li key={`${file.name}-${i}`} className=\"slurp-file-drop-file\">\n <span className=\"slurp-file-drop-name\">{file.name}</span>\n <span className=\"slurp-file-drop-size\">{size(file.size)}</span>\n <Bubble\n appearance=\"plain\"\n tone=\"neutral\"\n size=\"sm\"\n label={labels.remove(file.name)}\n disabled={disabled}\n onClick={() => setFiles(files.filter((_, j) => j !== i))}\n >\n <CloseIcon size={18} />\n </Bubble>\n {progress?.[file.name] !== undefined && (\n <Progress\n className=\"slurp-file-drop-progress\"\n value={progress[file.name]}\n label={file.name}\n />\n )}\n </li>\n ))}\n </ul>\n )}\n </Root>\n </>\n );\n}\n"],"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,MAAK;OACL,MAAK;OACL,OAAO,OAAO,OAAO,KAAK,IAAI;OACpB;OACV,eAAe,SAAS,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC;OAEvD,UAAA,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;MAChB,CAAA;MACP,WAAW,KAAK,UAAU,KAAA,KACzB,oBAAC,UAAD;OACE,WAAU;OACV,OAAO,SAAS,KAAK;OACrB,OAAO,KAAK;MACb,CAAA;KAED;IApBK,GAAA,GAAG,KAAK,KAAK,GAAG,GAoBrB,CACL;GACC,CAAA;EAEF;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
package/dist/Filters/Filters.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useLabels } from "../internal/labels.js";
|
|
2
3
|
import { cx } from "../utils/src/index.js";
|
|
3
4
|
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
5
|
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
@@ -18,6 +19,7 @@ function FiltersRoot(props) {
|
|
|
18
19
|
const { as, css, className, onReset, active = 0, labels: labelsProp, children, ...rest } = useThemeProps("Filters", props);
|
|
19
20
|
const labels = {
|
|
20
21
|
...FILTERS_LABELS,
|
|
22
|
+
...useLabels("Filters"),
|
|
21
23
|
...labelsProp
|
|
22
24
|
};
|
|
23
25
|
const Root = as ?? "div";
|