@slurp-ui/react 1.1.1 → 1.3.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 +56 -0
- package/dist/AvatarGroup/AvatarGroup.d.ts +26 -0
- package/dist/AvatarGroup/AvatarGroup.js +46 -0
- package/dist/AvatarGroup/AvatarGroup.js.map +1 -0
- package/dist/AvatarGroup/index.d.ts +3 -0
- package/dist/AvatarGroup/index.js +2 -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/Compare/Compare.d.ts +23 -0
- package/dist/Compare/Compare.js +61 -0
- package/dist/Compare/Compare.js.map +1 -0
- package/dist/Compare/index.d.ts +3 -0
- package/dist/Compare/index.js +2 -0
- package/dist/Consent/Consent.d.ts +30 -0
- package/dist/Consent/Consent.js +70 -0
- package/dist/Consent/Consent.js.map +1 -0
- package/dist/Consent/index.d.ts +3 -0
- package/dist/Consent/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.d.ts +2 -0
- package/dist/Dialog/Dialog.js +89 -30
- 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/Lightbox/Lightbox.d.ts +30 -0
- package/dist/Lightbox/Lightbox.js +74 -0
- package/dist/Lightbox/Lightbox.js.map +1 -0
- package/dist/Lightbox/index.d.ts +3 -0
- package/dist/Lightbox/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/Menu/Menu.d.ts +13 -0
- package/dist/Menu/Menu.js +43 -11
- package/dist/Menu/Menu.js.map +1 -1
- package/dist/Menu/index.d.ts +2 -2
- package/dist/Menu/index.js +1 -1
- package/dist/MultiSuggest/MultiSuggest.d.ts +39 -0
- package/dist/MultiSuggest/MultiSuggest.js +267 -0
- package/dist/MultiSuggest/MultiSuggest.js.map +1 -0
- package/dist/MultiSuggest/index.d.ts +3 -0
- package/dist/MultiSuggest/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/Sheet/Sheet.d.ts +8 -3
- package/dist/Sheet/Sheet.js +1 -1
- package/dist/Sheet/Sheet.js.map +1 -1
- package/dist/Sheet/index.d.ts +2 -2
- 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.d.ts +12 -0
- package/dist/Table/Table.js +56 -10
- 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/Timeline/Timeline.d.ts +23 -0
- package/dist/Timeline/Timeline.js +49 -0
- package/dist/Timeline/Timeline.js.map +1 -0
- package/dist/Timeline/index.d.ts +3 -0
- package/dist/Timeline/index.js +2 -0
- package/dist/Toast/Toast.js +31 -7
- package/dist/Toast/Toast.js.map +1 -1
- package/dist/Tree/Tree.d.ts +24 -0
- package/dist/Tree/Tree.js +113 -0
- package/dist/Tree/Tree.js.map +1 -0
- package/dist/Tree/index.d.ts +3 -0
- package/dist/Tree/index.js +2 -0
- package/dist/index.d.ts +63 -8
- package/dist/index.js +31 -2
- package/dist/internal/labels.js +12 -0
- package/dist/internal/labels.js.map +1 -0
- package/dist/lib/labels.d.ts +210 -0
- package/dist/lib/labels.js +139 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/theme.d.ts +134 -4
- package/dist/lib/theme.js.map +1 -1
- package/dist/styles.css +1912 -138
- 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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { BloomPlacement } from "../Bloom/Bloom.js";
|
|
4
|
+
import { CalendarProps, CalendarValue } from "../Calendar/Calendar.js";
|
|
5
|
+
import { ElementType, ReactNode } from "react";
|
|
6
|
+
export interface DateFieldLabels {
|
|
7
|
+
/** Shown while nothing is chosen. */
|
|
8
|
+
placeholder: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const DATEFIELD_LABELS: DateFieldLabels;
|
|
11
|
+
export interface DateFieldOwnProps extends Pick<CalendarProps, 'range' | 'min' | 'max' | 'isDateDisabled' | 'weekStartsOn'> {
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
hint?: ReactNode;
|
|
14
|
+
value?: CalendarValue;
|
|
15
|
+
defaultValue?: CalendarValue;
|
|
16
|
+
onValueChange?: (value: CalendarValue) => void;
|
|
17
|
+
/** Form names: one hidden input with the day, or two (`<name>-start`, `<name>-end`) for a period. */
|
|
18
|
+
name?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
placement?: BloomPlacement;
|
|
21
|
+
labels?: Partial<DateFieldLabels>;
|
|
22
|
+
}
|
|
23
|
+
export type DateFieldProps<E extends ElementType = 'div'> = PolymorphicProps<E, DateFieldOwnProps>;
|
|
24
|
+
/**
|
|
25
|
+
* A date, or a period with `range`: the field shows it in the theme's language and grows into a Calendar (the Bloom
|
|
26
|
+
* rule: the control becomes the panel). It closes once a day, or a period's end, is picked.
|
|
27
|
+
*/
|
|
28
|
+
export declare function DateField<E extends ElementType = 'div'>(props: DateFieldProps<E>): import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=DateField.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useTheme } from "../internal/context.js";
|
|
3
|
+
import { useLabels } from "../internal/labels.js";
|
|
4
|
+
import { cx } from "../utils/src/index.js";
|
|
5
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
6
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
7
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
8
|
+
import { Bloom } from "../Bloom/Bloom.js";
|
|
9
|
+
import { toDate } from "../Calendar/dates.js";
|
|
10
|
+
import { Calendar } from "../Calendar/Calendar.js";
|
|
11
|
+
import { useId, useMemo } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { CalendarIcon } from "@slurp-ui/icons";
|
|
14
|
+
// src/DateField/DateField.tsx
|
|
15
|
+
const DATEFIELD_LABELS = { placeholder: "Scegli una data" };
|
|
16
|
+
/**
|
|
17
|
+
* A date, or a period with `range`: the field shows it in the theme's language and grows into a Calendar (the Bloom
|
|
18
|
+
* rule: the control becomes the panel). It closes once a day, or a period's end, is picked.
|
|
19
|
+
*/
|
|
20
|
+
function DateField(props) {
|
|
21
|
+
const { as, css, className, label, hint, value: valueProp, defaultValue = null, onValueChange, range = false, min, max, isDateDisabled, weekStartsOn, name, disabled, placement, labels: labelsProp, ...rest } = useThemeProps("DateField", props);
|
|
22
|
+
const labels = {
|
|
23
|
+
...DATEFIELD_LABELS,
|
|
24
|
+
...useLabels("DateField"),
|
|
25
|
+
...labelsProp
|
|
26
|
+
};
|
|
27
|
+
const { locale } = useTheme();
|
|
28
|
+
const [value, setValue] = useControlled({
|
|
29
|
+
value: valueProp,
|
|
30
|
+
defaultValue,
|
|
31
|
+
onChange: onValueChange
|
|
32
|
+
});
|
|
33
|
+
const [open, setOpen] = useControlled({
|
|
34
|
+
value: void 0,
|
|
35
|
+
defaultValue: false
|
|
36
|
+
});
|
|
37
|
+
const id = useId();
|
|
38
|
+
const Root = as ?? "div";
|
|
39
|
+
const styled = useCss("DateField", "root", css);
|
|
40
|
+
const root = useAnimationRoot(rest);
|
|
41
|
+
const fmt = useMemo(() => new Intl.DateTimeFormat(locale, {
|
|
42
|
+
day: "numeric",
|
|
43
|
+
month: "long",
|
|
44
|
+
year: "numeric"
|
|
45
|
+
}), [locale]);
|
|
46
|
+
const text = value == null ? null : typeof value === "string" ? fmt.format(toDate(value)) : value.end ? fmt.formatRange(toDate(value.start), toDate(value.end)) : `${fmt.format(toDate(value.start))} –`;
|
|
47
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
48
|
+
className: cx("slurp-date-field", styled.className, className),
|
|
49
|
+
"data-disabled": disabled || void 0,
|
|
50
|
+
...root,
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: "slurp-field-label",
|
|
54
|
+
id: `${id}-label`,
|
|
55
|
+
children: label
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx(Bloom, {
|
|
58
|
+
open,
|
|
59
|
+
onOpenChange: setOpen,
|
|
60
|
+
role: "dialog",
|
|
61
|
+
width: 352,
|
|
62
|
+
placement,
|
|
63
|
+
disabled,
|
|
64
|
+
trigger: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CalendarIcon, { size: 18 }), /* @__PURE__ */ jsx("span", {
|
|
65
|
+
className: cx("slurp-date-field-value", !text && "slurp-date-field-placeholder"),
|
|
66
|
+
children: text ?? labels.placeholder
|
|
67
|
+
})] }),
|
|
68
|
+
partProps: {
|
|
69
|
+
trigger: {
|
|
70
|
+
"aria-labelledby": `${id}-label ${id}-value`,
|
|
71
|
+
"aria-describedby": hint != null ? `${id}-hint` : void 0
|
|
72
|
+
},
|
|
73
|
+
panel: { "aria-labelledby": `${id}-label` }
|
|
74
|
+
},
|
|
75
|
+
children: (close) => /* @__PURE__ */ jsx(Calendar, {
|
|
76
|
+
className: "slurp-date-field-calendar",
|
|
77
|
+
value,
|
|
78
|
+
range,
|
|
79
|
+
min,
|
|
80
|
+
max,
|
|
81
|
+
isDateDisabled,
|
|
82
|
+
weekStartsOn,
|
|
83
|
+
autoFocus: true,
|
|
84
|
+
onValueChange: (next) => {
|
|
85
|
+
setValue(next);
|
|
86
|
+
if (next != null && (typeof next === "string" || next.end !== null)) close(true);
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ jsx("span", {
|
|
91
|
+
id: `${id}-value`,
|
|
92
|
+
hidden: true,
|
|
93
|
+
children: text ?? labels.placeholder
|
|
94
|
+
}),
|
|
95
|
+
hint != null && /* @__PURE__ */ jsx("p", {
|
|
96
|
+
className: "slurp-field-hint",
|
|
97
|
+
id: `${id}-hint`,
|
|
98
|
+
children: hint
|
|
99
|
+
}),
|
|
100
|
+
name != null && (range ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
|
|
101
|
+
type: "hidden",
|
|
102
|
+
name: `${name}-start`,
|
|
103
|
+
value: value != null && typeof value === "object" ? value.start : ""
|
|
104
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
105
|
+
type: "hidden",
|
|
106
|
+
name: `${name}-end`,
|
|
107
|
+
value: value != null && typeof value === "object" ? value.end ?? "" : ""
|
|
108
|
+
})] }) : /* @__PURE__ */ jsx("input", {
|
|
109
|
+
type: "hidden",
|
|
110
|
+
name,
|
|
111
|
+
value: typeof value === "string" ? value : ""
|
|
112
|
+
}))
|
|
113
|
+
]
|
|
114
|
+
})] });
|
|
115
|
+
}
|
|
116
|
+
export { DATEFIELD_LABELS, DateField };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=DateField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateField.js","names":[],"sources":["../../src/DateField/DateField.tsx"],"sourcesContent":["import { CalendarIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, useMemo, type ElementType, type ReactNode } from 'react';\n\nimport { Bloom, type BloomPlacement } from '../Bloom/Bloom';\nimport { Calendar, type CalendarProps, type CalendarValue } from '../Calendar/Calendar';\nimport { toDate } from '../Calendar/dates';\nimport { useTheme } from '../internal/context';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useLabels } from '../internal/labels';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface DateFieldLabels {\n /** Shown while nothing is chosen. */\n placeholder: string;\n}\n\nexport const DATEFIELD_LABELS: DateFieldLabels = { placeholder: 'Scegli una data' };\n\nexport interface DateFieldOwnProps extends Pick<\n CalendarProps,\n 'range' | 'min' | 'max' | 'isDateDisabled' | 'weekStartsOn'\n> {\n label: ReactNode;\n hint?: ReactNode;\n value?: CalendarValue;\n defaultValue?: CalendarValue;\n onValueChange?: (value: CalendarValue) => void;\n /** Form names: one hidden input with the day, or two (`<name>-start`, `<name>-end`) for a period. */\n name?: string;\n disabled?: boolean;\n placement?: BloomPlacement;\n labels?: Partial<DateFieldLabels>;\n}\n\nexport type DateFieldProps<E extends ElementType = 'div'> = PolymorphicProps<E, DateFieldOwnProps>;\n\n/**\n * A date, or a period with `range`: the field shows it in the theme's language and grows into a Calendar (the Bloom\n * rule: the control becomes the panel). It closes once a day, or a period's end, is picked.\n */\nexport function DateField<E extends ElementType = 'div'>(props: DateFieldProps<E>) {\n const {\n as,\n css,\n className,\n label,\n hint,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n range = false,\n min,\n max,\n isDateDisabled,\n weekStartsOn,\n name,\n disabled,\n placement,\n labels: labelsProp,\n ...rest\n } = useThemeProps('DateField', props as DateFieldProps);\n const labels = { ...DATEFIELD_LABELS, ...useLabels('DateField'), ...labelsProp };\n const { locale } = useTheme();\n const [value, setValue] = useControlled<CalendarValue>({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const [open, setOpen] = useControlled({ value: undefined, defaultValue: false });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('DateField', 'root', css);\n const root = useAnimationRoot(rest);\n const fmt = useMemo(\n () => new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }),\n [locale],\n );\n\n const text =\n value == null\n ? null\n : typeof value === 'string'\n ? fmt.format(toDate(value))\n : value.end\n ? fmt.formatRange(toDate(value.start), toDate(value.end))\n : `${fmt.format(toDate(value.start))} –`;\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-date-field', 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 <Bloom\n open={open}\n onOpenChange={setOpen}\n role=\"dialog\"\n width={352}\n placement={placement}\n disabled={disabled}\n trigger={\n <>\n <CalendarIcon size={18} />\n <span\n className={cx('slurp-date-field-value', !text && 'slurp-date-field-placeholder')}\n >\n {text ?? labels.placeholder}\n </span>\n </>\n }\n partProps={{\n trigger: {\n 'aria-labelledby': `${id}-label ${id}-value`,\n 'aria-describedby': hint != null ? `${id}-hint` : undefined,\n },\n panel: { 'aria-labelledby': `${id}-label` },\n }}\n >\n {(close) => (\n <Calendar\n className=\"slurp-date-field-calendar\"\n value={value}\n range={range}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n weekStartsOn={weekStartsOn}\n autoFocus\n onValueChange={(next) => {\n setValue(next);\n if (next != null && (typeof next === 'string' || next.end !== null)) close(true);\n }}\n />\n )}\n </Bloom>\n <span id={`${id}-value`} hidden>\n {text ?? labels.placeholder}\n </span>\n {hint != null && (\n <p className=\"slurp-field-hint\" id={`${id}-hint`}>\n {hint}\n </p>\n )}\n {name != null &&\n (range ? (\n <>\n <input\n type=\"hidden\"\n name={`${name}-start`}\n value={value != null && typeof value === 'object' ? value.start : ''}\n />\n <input\n type=\"hidden\"\n name={`${name}-end`}\n value={value != null && typeof value === 'object' ? (value.end ?? '') : ''}\n />\n </>\n ) : (\n <input type=\"hidden\" name={name} value={typeof value === 'string' ? value : ''} />\n ))}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,mBAAoC,EAAE,aAAa,kBAAkB;;;;;AAwBlF,SAAgB,UAAyC,OAA0B;CACjF,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,OAAO,WACP,eAAe,MACf,eACA,QAAQ,OACR,KACA,KACA,gBACA,cACA,MACA,UACA,WACA,QAAQ,YACR,GAAG,SACD,cAAc,aAAa,KAAuB;CACtD,MAAM,SAAS;EAAE,GAAG;EAAkB,GAAG,UAAU,WAAW;EAAG,GAAG;CAAW;CAC/E,MAAM,EAAE,WAAW,SAAS;CAC5B,MAAM,CAAC,OAA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AAE,mBAAmB,GAAG,GAAG,QAAQ;IAC5C;IAEE,WAAA,UACA,oBAAC,UAAD;KACE,WAAU;KACH;KACA;KACF;KACA;KACW;KACF;KACd,WAAA;KACA,gBAAgB,SAAS;MACvB,SAAS,IAAI;MACb,IAAI,QAAQ,SAAS,OAAO,SAAS,YAAY,KAAK,QAAQ,OAAO,MAAM,IAAI;KACjF;IACD,CAAA;GAEE,CAAA;GACP,oBAAC,QAAD;IAAM,IAAI,GAAG,GAAG;IAAS,QAAA;IACtB,UAAA,QAAQ,OAAO;GACZ,CAAA;GACL,QAAQ,QACP,oBAAC,KAAD;IAAG,WAAU;IAAmB,IAAI,GAAG,GAAG;IACvC,UAAA;GACA,CAAA;GAEJ,QAAQ,SACN,QACC,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,SAAD;IACE,MAAK;IACL,MAAM,GAAG,KAAK;IACd,OAAO,SAAS,QAAQ,OAAO,UAAU,WAAW,MAAM,QAAQ;GACnE,CAAA,GACD,oBAAC,SAAD;IACE,MAAK;IACL,MAAM,GAAG,KAAK;IACd,OAAO,SAAS,QAAQ,OAAO,UAAU,WAAY,MAAM,OAAO,KAAM;GACzE,CAAA,CACD,EAAA,CAAA,IAEF,oBAAC,SAAD;IAAO,MAAK;IAAe;IAAM,OAAO,OAAO,UAAU,WAAW,QAAQ;GAAK,CAAA;EAEjF;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface DialogOwnProps extends PartsProps<'header' | 'title' | 'descrip
|
|
|
21
21
|
children?: ReactNode;
|
|
22
22
|
}
|
|
23
23
|
export type DialogProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, DialogOwnProps>;
|
|
24
|
+
/** The edge a sheet is attached to: `bottom` (default), or the `start` / `end` side (flipped in RTL). */
|
|
25
|
+
export type SheetSide = 'bottom' | 'start' | 'end';
|
|
24
26
|
/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */
|
|
25
27
|
export declare function Dialog<E extends ElementType = 'dialog'>(props: DialogProps<E>): import("react").JSX.Element;
|
|
26
28
|
//# sourceMappingURL=Dialog.d.ts.map
|
package/dist/Dialog/Dialog.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";
|
|
@@ -6,6 +7,7 @@ import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
|
6
7
|
import { Bubble } from "../Bubble/Bubble.js";
|
|
7
8
|
import { useControlled } from "../utils/useControlled.js";
|
|
8
9
|
import { useEffect, useId, useLayoutEffect, useRef } from "react";
|
|
10
|
+
import { duration, ease } from "@slurp-ui/tokens";
|
|
9
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
12
|
import { CloseIcon } from "@slurp-ui/icons";
|
|
11
13
|
// src/Dialog/Dialog.tsx
|
|
@@ -13,9 +15,10 @@ const DIALOG_LABELS = { close: "Chiudi" };
|
|
|
13
15
|
const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
14
16
|
/** Shared by Dialog and Sheet: a native modal <dialog> (top layer, focus contained, Escape, inert page). */
|
|
15
17
|
function useModal(props, variant) {
|
|
16
|
-
const { as, css, className, title, description, open: openProp, defaultOpen = false, onOpenChange, actions, dismissible = true, labels: labelsProp, children, parts, partProps, classNames, ref, ...rest } = props;
|
|
18
|
+
const { side = "bottom", as, css, className, title, description, open: openProp, defaultOpen = false, onOpenChange, actions, dismissible = true, labels: labelsProp, children, parts, partProps, classNames, ref, ...rest } = props;
|
|
17
19
|
const labels = {
|
|
18
20
|
...DIALOG_LABELS,
|
|
21
|
+
...useLabels("Dialog"),
|
|
19
22
|
...labelsProp
|
|
20
23
|
};
|
|
21
24
|
const [open, setOpen] = useControlled({
|
|
@@ -37,21 +40,43 @@ function useModal(props, variant) {
|
|
|
37
40
|
...rest,
|
|
38
41
|
ref: useForkRef(ref, dialog)
|
|
39
42
|
});
|
|
43
|
+
const leaving = useRef(null);
|
|
40
44
|
useLayoutEffect(() => {
|
|
41
45
|
const el = dialog.current;
|
|
42
46
|
if (!el) return;
|
|
47
|
+
if (open && leaving.current) {
|
|
48
|
+
leaving.current.cancel();
|
|
49
|
+
leaving.current = null;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
43
52
|
if (open && !el.open) {
|
|
44
53
|
opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
45
54
|
if (typeof el.showModal === "function") el.showModal();
|
|
46
55
|
else el.setAttribute("open", "");
|
|
47
|
-
grow(el, opener.current, variant);
|
|
48
|
-
} else if (!open && el.open) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
grow(el, opener.current, variant, side);
|
|
57
|
+
} else if (!open && el.open && !leaving.current) {
|
|
58
|
+
const close = () => {
|
|
59
|
+
leaving.current = null;
|
|
60
|
+
if (typeof el.close === "function") el.close();
|
|
61
|
+
else el.removeAttribute("open");
|
|
62
|
+
opener.current?.focus();
|
|
63
|
+
opener.current = null;
|
|
64
|
+
};
|
|
65
|
+
const exit = shrink(el, opener.current, variant, side);
|
|
66
|
+
if (!exit) return close();
|
|
67
|
+
leaving.current = exit;
|
|
68
|
+
exit.finished.then(() => {
|
|
69
|
+
if (leaving.current === exit) {
|
|
70
|
+
close();
|
|
71
|
+
exit.cancel();
|
|
72
|
+
}
|
|
73
|
+
}, () => {});
|
|
53
74
|
}
|
|
54
|
-
}, [
|
|
75
|
+
}, [
|
|
76
|
+
open,
|
|
77
|
+
variant,
|
|
78
|
+
side
|
|
79
|
+
]);
|
|
55
80
|
useEffect(() => () => opener.current?.focus(), []);
|
|
56
81
|
const Root = as ?? "dialog";
|
|
57
82
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -60,6 +85,7 @@ function useModal(props, variant) {
|
|
|
60
85
|
/* @__PURE__ */ jsx(Root, {
|
|
61
86
|
className: cx("slurp-dialog", styled.className, className),
|
|
62
87
|
"data-variant": variant,
|
|
88
|
+
"data-side": variant === "sheet" ? side : void 0,
|
|
63
89
|
"aria-labelledby": `${id}-title`,
|
|
64
90
|
"aria-describedby": description != null ? `${id}-description` : void 0,
|
|
65
91
|
onCancel: (e) => {
|
|
@@ -107,42 +133,75 @@ function useModal(props, variant) {
|
|
|
107
133
|
})
|
|
108
134
|
] });
|
|
109
135
|
}
|
|
136
|
+
/** Offset and uniform scale that put `el` on its opener's box (uniform, so the text never stretches). */
|
|
137
|
+
function fromOpener(el, from) {
|
|
138
|
+
const to = el.getBoundingClientRect();
|
|
139
|
+
const at = from?.isConnected ? from.getBoundingClientRect() : void 0;
|
|
140
|
+
if (!at || !to.width || !to.height || !at.width) return void 0;
|
|
141
|
+
return `translate(${at.left + at.width / 2 - (to.left + to.width / 2)}px, ${at.top + at.height / 2 - (to.top + to.height / 2)}px) scale(${Math.min(1, Math.max(.5, Math.min(at.width / to.width, at.height / to.height)))})`;
|
|
142
|
+
}
|
|
143
|
+
/** The transform that puts a sheet fully off its edge. */
|
|
144
|
+
function offscreen(el, side) {
|
|
145
|
+
if (side === "bottom") return "translateY(100%)";
|
|
146
|
+
const rtl = getComputedStyle(el).direction === "rtl";
|
|
147
|
+
return `translateX(${side === "end" !== rtl ? "" : "-"}100%)`;
|
|
148
|
+
}
|
|
149
|
+
const EASE = ease.settle;
|
|
150
|
+
/** Milliseconds of a duration token (`'450ms'` → 450). */
|
|
151
|
+
const ms = (t) => Number.parseFloat(t);
|
|
110
152
|
/**
|
|
111
153
|
* The dialog grows out of the control that opened it (the Bloom rule applied to a modal): it starts at the opener's
|
|
112
|
-
*
|
|
154
|
+
* place and settles in the centre. A sheet rises from the bottom edge. Reduced motion: a 150ms fade, as the engine.
|
|
113
155
|
*/
|
|
114
|
-
function grow(el, from, variant) {
|
|
115
|
-
if (
|
|
156
|
+
function grow(el, from, variant, side) {
|
|
157
|
+
if (typeof el.animate !== "function") return;
|
|
158
|
+
if (reduced()) {
|
|
159
|
+
el.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150 });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
116
162
|
const timing = {
|
|
117
|
-
duration:
|
|
118
|
-
easing:
|
|
163
|
+
duration: ms(duration.panel),
|
|
164
|
+
easing: EASE
|
|
119
165
|
};
|
|
120
166
|
if (variant === "sheet") {
|
|
121
|
-
el.animate([{ transform:
|
|
167
|
+
el.animate([{ transform: offscreen(el, side) }, { transform: "none" }], timing);
|
|
122
168
|
return;
|
|
123
169
|
}
|
|
124
|
-
const
|
|
125
|
-
const at = from?.getBoundingClientRect();
|
|
126
|
-
if (!at || !to.width || !to.height) {
|
|
127
|
-
el.animate([{
|
|
128
|
-
opacity: 0,
|
|
129
|
-
transform: "scale(0.96)"
|
|
130
|
-
}, {
|
|
131
|
-
opacity: 1,
|
|
132
|
-
transform: "none"
|
|
133
|
-
}], timing);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const dx = at.left + at.width / 2 - (to.left + to.width / 2);
|
|
137
|
-
const dy = at.top + at.height / 2 - (to.top + to.height / 2);
|
|
170
|
+
const start = fromOpener(el, from) ?? "scale(0.96)";
|
|
138
171
|
el.animate([{
|
|
139
|
-
transform:
|
|
140
|
-
opacity:
|
|
172
|
+
transform: start,
|
|
173
|
+
opacity: 0
|
|
141
174
|
}, {
|
|
142
175
|
transform: "none",
|
|
143
176
|
opacity: 1
|
|
144
177
|
}], timing);
|
|
145
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The way out, quicker than the way in (200ms): back toward the opener, a sheet back down. Returns the animation to
|
|
181
|
+
* wait for before closing, or nothing when there is nothing to play.
|
|
182
|
+
*/
|
|
183
|
+
function shrink(el, to, variant, side) {
|
|
184
|
+
if (typeof el.animate !== "function") return void 0;
|
|
185
|
+
const fill = "forwards";
|
|
186
|
+
if (reduced()) return el.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
187
|
+
duration: 150,
|
|
188
|
+
fill
|
|
189
|
+
});
|
|
190
|
+
const timing = {
|
|
191
|
+
duration: ms(duration.quick),
|
|
192
|
+
easing: EASE,
|
|
193
|
+
fill
|
|
194
|
+
};
|
|
195
|
+
if (variant === "sheet") return el.animate([{ transform: "none" }, { transform: offscreen(el, side) }], timing);
|
|
196
|
+
const end = fromOpener(el, to) ?? "scale(0.96)";
|
|
197
|
+
return el.animate([{
|
|
198
|
+
transform: "none",
|
|
199
|
+
opacity: 1
|
|
200
|
+
}, {
|
|
201
|
+
transform: end,
|
|
202
|
+
opacity: 0
|
|
203
|
+
}], timing);
|
|
204
|
+
}
|
|
146
205
|
/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */
|
|
147
206
|
function Dialog(props) {
|
|
148
207
|
return useModal(useThemeProps("Dialog", props), "dialog");
|
|
@@ -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;CAEhF,sBAAsB;EACpB,MAAM,KAAK,OAAO;EAClB,IAAI,CAAC,IAAI;EACT,IAAI,QAAQ,CAAC,GAAG,MAAM;GACpB,OAAO,UACL,SAAS,yBAAyB,cAAc,SAAS,gBAAgB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x"],"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 an edge. */\ntype Variant = 'dialog' | 'sheet';\n\n/** The edge a sheet is attached to: `bottom` (default), or the `start` / `end` side (flipped in RTL). */\nexport type SheetSide = 'bottom' | 'start' | 'end';\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 & { side?: SheetSide }, variant: Variant) {\n const {\n side = 'bottom',\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, side);\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, side);\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, side]);\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 data-side={variant === 'sheet' ? side : undefined}\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\n/** The transform that puts a sheet fully off its edge. */\nfunction offscreen(el: HTMLElement, side: SheetSide) {\n if (side === 'bottom') return 'translateY(100%)';\n const rtl = getComputedStyle(el).direction === 'rtl';\n return `translateX(${(side === 'end') !== rtl ? '' : '-'}100%)`;\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, side: SheetSide) {\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: offscreen(el, side) }, { 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(\n el: HTMLElement,\n to: HTMLElement | null,\n variant: Variant,\n side: SheetSide,\n): 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: offscreen(el, side) }], 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;AA2B7D,MAAM,gBACJ,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;;AAGrF,SAAgB,SAAS,OAA2C,SAAkB;CACpF,MAAM,EACJ,OAAO,UACP,IACA,KACA,WACA,OACA,aACA,MAAM,UACN,cAAc,OACd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AE,WAAW,UAAU,IAAI,IAAI,EAAE,GAAG,EAAE,WAAW,OAAO,CAAC,GAAG,MAAM;EAC9E;CACF;CACA,MAAM,QAAQ,WAAW,IAAI,IAAI,KAAK;CACtC,GAAG,QACD,CACE;EAAE,WAAW;EAAO,SAAS;CAAE,GAC/B;EAAE,WAAW;EAAQ,SAAS;CAAE,CAClC,GACA,MACF;AACF;;;;;AAMA,SAAS,OACP,IACA,IACA,SACA,MACuB;CACvB,IAAI,OAAO,GAAG,YAAY,YAAY,OAAO,KAAA;CAC7C,MAAM,OAAO;CACb,IAAI,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,GAAG;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,UAAU,IAAI,IAAI,EAAE,CAAC,GAAG,MAAM;CAEvF,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,G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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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