@slurp-ui/react 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/AccentScope/AccentScope.d.ts +15 -0
- package/dist/AccentScope/AccentScope.js +31 -0
- package/dist/AccentScope/AccentScope.js.map +1 -0
- package/dist/AccentScope/index.d.ts +3 -0
- package/dist/AccentScope/index.js +2 -0
- package/dist/Avatar/Avatar.d.ts +17 -0
- package/dist/Avatar/Avatar.js +42 -0
- package/dist/Avatar/Avatar.js.map +1 -0
- package/dist/Avatar/index.d.ts +3 -0
- package/dist/Avatar/index.js +2 -0
- package/dist/Bento/Bento.d.ts +14 -0
- package/dist/Bento/Bento.js +42 -0
- package/dist/Bento/Bento.js.map +1 -0
- package/dist/Bento/index.d.ts +3 -0
- package/dist/Bento/index.js +2 -0
- package/dist/Bloom/Bloom.d.ts +42 -0
- package/dist/Bloom/Bloom.js +183 -0
- package/dist/Bloom/Bloom.js.map +1 -0
- package/dist/Bloom/index.d.ts +3 -0
- package/dist/Bloom/index.js +2 -0
- package/dist/Bubble/Bubble.d.ts +20 -0
- package/dist/Bubble/Bubble.js +30 -0
- package/dist/Bubble/Bubble.js.map +1 -0
- package/dist/Bubble/index.d.ts +3 -0
- package/dist/Bubble/index.js +2 -0
- package/dist/Button/Button.d.ts +26 -0
- package/dist/Button/Button.js +50 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/index.d.ts +3 -0
- package/dist/Button/index.js +2 -0
- package/dist/Card/Card.d.ts +26 -0
- package/dist/Card/Card.js +70 -0
- package/dist/Card/Card.js.map +1 -0
- package/dist/Card/index.d.ts +3 -0
- package/dist/Card/index.js +2 -0
- package/dist/Cell/Cell.d.ts +7 -0
- package/dist/Cell/Cell.js +20 -0
- package/dist/Cell/Cell.js.map +1 -0
- package/dist/Cell/index.d.ts +3 -0
- package/dist/Cell/index.js +2 -0
- package/dist/Checkbox/Checkbox.d.ts +27 -0
- package/dist/Checkbox/Checkbox.js +82 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/index.d.ts +3 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Chip/Chip.d.ts +15 -0
- package/dist/Chip/Chip.js +40 -0
- package/dist/Chip/Chip.js.map +1 -0
- package/dist/Chip/index.d.ts +3 -0
- package/dist/Chip/index.js +2 -0
- package/dist/Choice/Choice.d.ts +37 -0
- package/dist/Choice/Choice.js +134 -0
- package/dist/Choice/Choice.js.map +1 -0
- package/dist/Choice/index.d.ts +3 -0
- package/dist/Choice/index.js +2 -0
- package/dist/Count/Count.d.ts +19 -0
- package/dist/Count/Count.js +30 -0
- package/dist/Count/Count.js.map +1 -0
- package/dist/Count/index.d.ts +3 -0
- package/dist/Count/index.js +2 -0
- package/dist/Dialog/Dialog.d.ts +26 -0
- package/dist/Dialog/Dialog.js +152 -0
- package/dist/Dialog/Dialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +3 -0
- package/dist/Dialog/index.js +2 -0
- package/dist/Dock/Dock.d.ts +124 -0
- package/dist/Dock/Dock.js +359 -0
- package/dist/Dock/Dock.js.map +1 -0
- package/dist/Dock/index.d.ts +3 -0
- package/dist/Dock/index.js +2 -0
- package/dist/Empty/Empty.d.ts +17 -0
- package/dist/Empty/Empty.js +40 -0
- package/dist/Empty/Empty.js.map +1 -0
- package/dist/Empty/index.d.ts +3 -0
- package/dist/Empty/index.js +2 -0
- package/dist/Fact/Fact.d.ts +11 -0
- package/dist/Fact/Fact.js +27 -0
- package/dist/Fact/Fact.js.map +1 -0
- package/dist/Fact/index.d.ts +3 -0
- package/dist/Fact/index.js +2 -0
- package/dist/Field/Field.d.ts +44 -0
- package/dist/Field/Field.js +105 -0
- package/dist/Field/Field.js.map +1 -0
- package/dist/Field/index.d.ts +3 -0
- package/dist/Field/index.js +2 -0
- package/dist/Filters/Filters.d.ts +37 -0
- package/dist/Filters/Filters.js +64 -0
- package/dist/Filters/Filters.js.map +1 -0
- package/dist/Filters/index.d.ts +3 -0
- package/dist/Filters/index.js +2 -0
- package/dist/Flow/Flow.d.ts +17 -0
- package/dist/Flow/Flow.js +26 -0
- package/dist/Flow/Flow.js.map +1 -0
- package/dist/Flow/index.d.ts +3 -0
- package/dist/Flow/index.js +2 -0
- package/dist/Fold/Fold.d.ts +17 -0
- package/dist/Fold/Fold.js +64 -0
- package/dist/Fold/Fold.js.map +1 -0
- package/dist/Fold/index.d.ts +3 -0
- package/dist/Fold/index.js +2 -0
- package/dist/Frame/Frame.d.ts +7 -0
- package/dist/Frame/Frame.js +20 -0
- package/dist/Frame/Frame.js.map +1 -0
- package/dist/Frame/index.d.ts +3 -0
- package/dist/Frame/index.js +2 -0
- package/dist/Ground/Ground.d.ts +7 -0
- package/dist/Ground/Ground.js +19 -0
- package/dist/Ground/Ground.js.map +1 -0
- package/dist/Ground/index.d.ts +3 -0
- package/dist/Ground/index.js +2 -0
- package/dist/Hint/Hint.d.ts +21 -0
- package/dist/Hint/Hint.js +104 -0
- package/dist/Hint/Hint.js.map +1 -0
- package/dist/Hint/index.d.ts +3 -0
- package/dist/Hint/index.js +2 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +20 -0
- package/dist/Link/Link.js.map +1 -0
- package/dist/Link/index.d.ts +3 -0
- package/dist/Link/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +25 -0
- package/dist/ListRow/ListRow.js +80 -0
- package/dist/ListRow/ListRow.js.map +1 -0
- package/dist/ListRow/index.d.ts +3 -0
- package/dist/ListRow/index.js +2 -0
- package/dist/Mark/Mark.d.ts +14 -0
- package/dist/Mark/Mark.js +28 -0
- package/dist/Mark/Mark.js.map +1 -0
- package/dist/Mark/index.d.ts +3 -0
- package/dist/Mark/index.js +2 -0
- package/dist/Menu/Menu.d.ts +29 -0
- package/dist/Menu/Menu.js +64 -0
- package/dist/Menu/Menu.js.map +1 -0
- package/dist/Menu/index.d.ts +3 -0
- package/dist/Menu/index.js +2 -0
- package/dist/Notice/Notice.d.ts +31 -0
- package/dist/Notice/Notice.js +82 -0
- package/dist/Notice/Notice.js.map +1 -0
- package/dist/Notice/index.d.ts +3 -0
- package/dist/Notice/index.js +2 -0
- package/dist/Placeholder/Placeholder.d.ts +15 -0
- package/dist/Placeholder/Placeholder.js +28 -0
- package/dist/Placeholder/Placeholder.js.map +1 -0
- package/dist/Placeholder/index.d.ts +3 -0
- package/dist/Placeholder/index.js +2 -0
- package/dist/Portal/Portal.d.ts +10 -0
- package/dist/Portal/Portal.js +13 -0
- package/dist/Portal/Portal.js.map +1 -0
- package/dist/Portal/index.d.ts +3 -0
- package/dist/Portal/index.js +2 -0
- package/dist/Progress/Progress.d.ts +22 -0
- package/dist/Progress/Progress.js +65 -0
- package/dist/Progress/Progress.js.map +1 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Radio/Radio.d.ts +39 -0
- package/dist/Radio/Radio.js +118 -0
- package/dist/Radio/Radio.js.map +1 -0
- package/dist/Radio/index.d.ts +3 -0
- package/dist/Radio/index.js +2 -0
- package/dist/Range/Range.d.ts +26 -0
- package/dist/Range/Range.js +68 -0
- package/dist/Range/Range.js.map +1 -0
- package/dist/Range/index.d.ts +3 -0
- package/dist/Range/index.js +2 -0
- package/dist/ResultRow/ResultRow.d.ts +17 -0
- package/dist/ResultRow/ResultRow.js +46 -0
- package/dist/ResultRow/ResultRow.js.map +1 -0
- package/dist/ResultRow/index.d.ts +3 -0
- package/dist/ResultRow/index.js +2 -0
- package/dist/Score/Score.d.ts +16 -0
- package/dist/Score/Score.js +55 -0
- package/dist/Score/Score.js.map +1 -0
- package/dist/Score/index.d.ts +3 -0
- package/dist/Score/index.js +2 -0
- package/dist/Search/Search.d.ts +29 -0
- package/dist/Search/Search.js +94 -0
- package/dist/Search/Search.js.map +1 -0
- package/dist/Search/index.d.ts +3 -0
- package/dist/Search/index.js +2 -0
- package/dist/Segmented/Segmented.d.ts +24 -0
- package/dist/Segmented/Segmented.js +69 -0
- package/dist/Segmented/Segmented.js.map +1 -0
- package/dist/Segmented/index.d.ts +3 -0
- package/dist/Segmented/index.js +2 -0
- package/dist/Settings/Settings.d.ts +49 -0
- package/dist/Settings/Settings.js +93 -0
- package/dist/Settings/Settings.js.map +1 -0
- package/dist/Settings/index.d.ts +3 -0
- package/dist/Settings/index.js +2 -0
- package/dist/Sheet/Sheet.d.ts +7 -0
- package/dist/Sheet/Sheet.js +11 -0
- package/dist/Sheet/Sheet.js.map +1 -0
- package/dist/Sheet/index.d.ts +3 -0
- package/dist/Sheet/index.js +2 -0
- package/dist/Shelf/Shelf.d.ts +7 -0
- package/dist/Shelf/Shelf.js +23 -0
- package/dist/Shelf/Shelf.js.map +1 -0
- package/dist/Shelf/index.d.ts +3 -0
- package/dist/Shelf/index.js +2 -0
- package/dist/SlurpProvider/ColorSchemeScript.d.ts +15 -0
- package/dist/SlurpProvider/ColorSchemeScript.js +18 -0
- package/dist/SlurpProvider/ColorSchemeScript.js.map +1 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +18 -0
- package/dist/SlurpProvider/SlurpProvider.js +106 -0
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -0
- package/dist/SlurpProvider/index.d.ts +5 -0
- package/dist/SlurpProvider/index.js +5 -0
- package/dist/Stage/Stage.d.ts +14 -0
- package/dist/Stage/Stage.js +38 -0
- package/dist/Stage/Stage.js.map +1 -0
- package/dist/Stage/index.d.ts +3 -0
- package/dist/Stage/index.js +2 -0
- package/dist/Surface/Surface.d.ts +16 -0
- package/dist/Surface/Surface.js +25 -0
- package/dist/Surface/Surface.js.map +1 -0
- package/dist/Surface/index.d.ts +3 -0
- package/dist/Surface/index.js +2 -0
- package/dist/Swatch/Swatch.d.ts +31 -0
- package/dist/Swatch/Swatch.js +72 -0
- package/dist/Swatch/Swatch.js.map +1 -0
- package/dist/Swatch/index.d.ts +3 -0
- package/dist/Swatch/index.js +2 -0
- package/dist/Switch/Switch.d.ts +15 -0
- package/dist/Switch/Switch.js +62 -0
- package/dist/Switch/Switch.js.map +1 -0
- package/dist/Switch/index.d.ts +3 -0
- package/dist/Switch/index.js +2 -0
- package/dist/Tabs/Tabs.d.ts +21 -0
- package/dist/Tabs/Tabs.js +105 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/index.d.ts +3 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Text/Text.d.ts +17 -0
- package/dist/Text/Text.js +33 -0
- package/dist/Text/Text.js.map +1 -0
- package/dist/Text/index.d.ts +3 -0
- package/dist/Text/index.js +2 -0
- package/dist/Tile/Tile.d.ts +25 -0
- package/dist/Tile/Tile.js +67 -0
- package/dist/Tile/Tile.js.map +1 -0
- package/dist/Tile/index.d.ts +3 -0
- package/dist/Tile/index.js +2 -0
- package/dist/Toast/Toast.d.ts +43 -0
- package/dist/Toast/Toast.js +132 -0
- package/dist/Toast/Toast.js.map +1 -0
- package/dist/Toast/index.d.ts +3 -0
- package/dist/Toast/index.js +2 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +7 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden/index.d.ts +3 -0
- package/dist/VisuallyHidden/index.js +2 -0
- package/dist/fonts/poppins-latin-400-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-500-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-600-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-700-normal.woff2 +0 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +69 -0
- package/dist/internal/animation.js +26 -0
- package/dist/internal/animation.js.map +1 -0
- package/dist/internal/context.d.ts +14 -0
- package/dist/internal/context.js +21 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/styled.js +79 -0
- package/dist/internal/styled.js.map +1 -0
- package/dist/lib/color.d.ts +21 -0
- package/dist/lib/color.js +151 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/crumb.d.ts +9 -0
- package/dist/lib/crumb.js +69 -0
- package/dist/lib/crumb.js.map +1 -0
- package/dist/lib/css.d.ts +53 -0
- package/dist/lib/css.js +142 -0
- package/dist/lib/css.js.map +1 -0
- package/dist/lib/ground.js +15 -0
- package/dist/lib/ground.js.map +1 -0
- package/dist/lib/layout.d.ts +24 -0
- package/dist/lib/layout.js +88 -0
- package/dist/lib/layout.js.map +1 -0
- package/dist/lib/polymorphic.d.ts +28 -0
- package/dist/lib/theme.d.ts +292 -0
- package/dist/lib/theme.js +90 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/motion/AnimationGroup.d.ts +10 -0
- package/dist/motion/AnimationGroup.js +14 -0
- package/dist/motion/AnimationGroup.js.map +1 -0
- package/dist/motion/context.js +8 -0
- package/dist/motion/context.js.map +1 -0
- package/dist/motion/index.d.ts +7 -0
- package/dist/motion/index.js +7 -0
- package/dist/motion/navigation.d.ts +51 -0
- package/dist/motion/navigation.js +122 -0
- package/dist/motion/navigation.js.map +1 -0
- package/dist/motion/useAnimationTarget.d.ts +22 -0
- package/dist/motion/useAnimationTarget.js +34 -0
- package/dist/motion/useAnimationTarget.js.map +1 -0
- package/dist/motion/useSlurp.d.ts +18 -0
- package/dist/motion/useSlurp.js +48 -0
- package/dist/motion/useSlurp.js.map +1 -0
- package/dist/styles.css +3439 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens.css +178 -0
- package/dist/utils/focus.d.ts +20 -0
- package/dist/utils/focus.js +50 -0
- package/dist/utils/focus.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/src/index.js +9 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/useControlled.d.ts +14 -0
- package/dist/utils/useControlled.js +23 -0
- package/dist/utils/useControlled.js.map +1 -0
- package/dist/utils/useDismiss.d.ts +24 -0
- package/dist/utils/useDismiss.js +60 -0
- package/dist/utils/useDismiss.js.map +1 -0
- package/dist/utils/useFindInPage.d.ts +18 -0
- package/dist/utils/useFindInPage.js +51 -0
- package/dist/utils/useFindInPage.js.map +1 -0
- package/dist/utils/useForkRef.d.ts +5 -0
- package/dist/utils/useForkRef.js +33 -0
- package/dist/utils/useForkRef.js.map +1 -0
- package/dist/utils/useMediaQuery.d.ts +11 -0
- package/dist/utils/useMediaQuery.js +21 -0
- package/dist/utils/useMediaQuery.js.map +1 -0
- package/dist/utils/useRovingFocus.d.ts +17 -0
- package/dist/utils/useRovingFocus.js +26 -0
- package/dist/utils/useRovingFocus.js.map +1 -0
- package/package.json +107 -3
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
6
|
+
import { moveFocus } from "../utils/focus.js";
|
|
7
|
+
import { Bloom } from "../Bloom/Bloom.js";
|
|
8
|
+
import { useId, useRef } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { CheckIcon, ChevronDownIcon } from "@slurp-ui/icons";
|
|
11
|
+
// src/Choice/Choice.tsx
|
|
12
|
+
const CHOICE_LABELS = { placeholder: "Scegli…" };
|
|
13
|
+
/**
|
|
14
|
+
* Select: the trigger **becomes** the list (Bloom). ArrowDown / ArrowUp / Enter / Space open it on the trigger;
|
|
15
|
+
* in the list arrows move, Enter or Space choose, Escape closes and gives focus back.
|
|
16
|
+
*/
|
|
17
|
+
function Choice(props) {
|
|
18
|
+
const { as, css, className, label, options, value: valueProp, defaultValue = null, onValueChange, name, disabled, width = 280, placement, labels: labelsProp, ...rest } = useThemeProps("Choice", props);
|
|
19
|
+
const labels = {
|
|
20
|
+
...CHOICE_LABELS,
|
|
21
|
+
...labelsProp
|
|
22
|
+
};
|
|
23
|
+
const [value, setValue] = useControlled({
|
|
24
|
+
value: valueProp,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onChange: onValueChange
|
|
27
|
+
});
|
|
28
|
+
const [open, setOpen] = useControlled({
|
|
29
|
+
value: void 0,
|
|
30
|
+
defaultValue: false
|
|
31
|
+
});
|
|
32
|
+
const list = useRef(null);
|
|
33
|
+
const labelId = useId();
|
|
34
|
+
const Root = as ?? "div";
|
|
35
|
+
const styled = useCss("Choice", "root", css);
|
|
36
|
+
const root = useAnimationRoot(rest);
|
|
37
|
+
const chosen = options.find((o) => o.value === value);
|
|
38
|
+
const choose = (o, close) => {
|
|
39
|
+
if (o.disabled) return;
|
|
40
|
+
setValue(o.value);
|
|
41
|
+
close(true);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
44
|
+
className: cx("slurp-choice", styled.className, className),
|
|
45
|
+
...root,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx("span", {
|
|
48
|
+
id: labelId,
|
|
49
|
+
className: "slurp-choice-label",
|
|
50
|
+
children: label
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(Bloom, {
|
|
53
|
+
open,
|
|
54
|
+
onOpenChange: setOpen,
|
|
55
|
+
role: "listbox",
|
|
56
|
+
width,
|
|
57
|
+
placement,
|
|
58
|
+
disabled,
|
|
59
|
+
trigger: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
60
|
+
className: cx("slurp-choice-value", !chosen && "slurp-choice-placeholder"),
|
|
61
|
+
children: chosen?.label ?? labels.placeholder
|
|
62
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, { size: 18 })] }),
|
|
63
|
+
partProps: {
|
|
64
|
+
trigger: {
|
|
65
|
+
"aria-labelledby": `${labelId} ${labelId}-value`,
|
|
66
|
+
onKeyDown: (e) => {
|
|
67
|
+
if (!open && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
setOpen(true);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
panel: { "aria-labelledby": labelId }
|
|
74
|
+
},
|
|
75
|
+
children: (close) => /* @__PURE__ */ jsx("div", {
|
|
76
|
+
ref: list,
|
|
77
|
+
className: "slurp-choice-list",
|
|
78
|
+
onKeyDown: (e) => {
|
|
79
|
+
if (moveFocus(e, list.current, "[role=\"option\"]")) return;
|
|
80
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
81
|
+
const at = e.target.closest("[role=\"option\"]");
|
|
82
|
+
const o = options.find((x) => x.value === at?.dataset.value);
|
|
83
|
+
if (o) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
choose(o, close);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
children: options.map((o) => {
|
|
90
|
+
const on = o.value === value;
|
|
91
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
92
|
+
role: "option",
|
|
93
|
+
tabIndex: -1,
|
|
94
|
+
"aria-selected": on,
|
|
95
|
+
"aria-disabled": o.disabled || void 0,
|
|
96
|
+
"data-value": o.value,
|
|
97
|
+
className: "slurp-bloom-item",
|
|
98
|
+
onClick: () => choose(o, close),
|
|
99
|
+
children: [
|
|
100
|
+
o.icon != null && /* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: "slurp-bloom-item-icon",
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
children: o.icon
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("span", {
|
|
106
|
+
className: "slurp-bloom-item-label",
|
|
107
|
+
children: o.label
|
|
108
|
+
}),
|
|
109
|
+
on && /* @__PURE__ */ jsx("span", {
|
|
110
|
+
className: "slurp-bloom-item-check",
|
|
111
|
+
"aria-hidden": "true",
|
|
112
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { size: 18 })
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
}, o.value);
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsx("span", {
|
|
120
|
+
id: `${labelId}-value`,
|
|
121
|
+
hidden: true,
|
|
122
|
+
children: chosen?.label ?? labels.placeholder
|
|
123
|
+
}),
|
|
124
|
+
name && /* @__PURE__ */ jsx("input", {
|
|
125
|
+
type: "hidden",
|
|
126
|
+
name,
|
|
127
|
+
value: value ?? ""
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
})] });
|
|
131
|
+
}
|
|
132
|
+
export { CHOICE_LABELS, Choice };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=Choice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Choice.js","names":[],"sources":["../../src/Choice/Choice.tsx"],"sourcesContent":["import { CheckIcon, ChevronDownIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, useRef, type ElementType, type KeyboardEvent, type ReactNode } from 'react';\n\nimport { Bloom, type BloomPlacement } from '../Bloom/Bloom';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface ChoiceOption<V extends string = string> {\n value: V;\n label: string;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface ChoiceLabels {\n /** Trigger text while nothing is chosen. */\n placeholder: string;\n}\n\nexport const CHOICE_LABELS: ChoiceLabels = { placeholder: 'Scegli…' };\n\nexport interface ChoiceOwnProps<V extends string = string> {\n /** Visible label (\"Ordina per\"). */\n label: ReactNode;\n options: ChoiceOption<V>[];\n value?: V | null;\n defaultValue?: V | null;\n onValueChange?: (value: V) => void;\n /** Form field name: a hidden input carries the value. */\n name?: string;\n disabled?: boolean;\n /** Panel width. Default 280. */\n width?: number;\n placement?: BloomPlacement;\n labels?: Partial<ChoiceLabels>;\n}\n\nexport type ChoiceProps<\n V extends string = string,\n E extends ElementType = 'div',\n> = PolymorphicProps<E, ChoiceOwnProps<V>>;\n\n/**\n * Select: the trigger **becomes** the list (Bloom). ArrowDown / ArrowUp / Enter / Space open it on the trigger;\n * in the list arrows move, Enter or Space choose, Escape closes and gives focus back.\n */\nexport function Choice<V extends string = string, E extends ElementType = 'div'>(\n props: ChoiceProps<V, E>,\n) {\n const {\n as,\n css,\n className,\n label,\n options,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n name,\n disabled,\n width = 280,\n placement,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Choice', props as unknown as ChoiceProps);\n const labels = { ...CHOICE_LABELS, ...labelsProp };\n const [value, setValue] = useControlled<string | null>({\n value: valueProp,\n defaultValue,\n onChange: onValueChange as ((v: string | null) => void) | undefined,\n });\n const [open, setOpen] = useControlled({ value: undefined, defaultValue: false });\n const list = useRef<HTMLDivElement>(null);\n const labelId = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Choice', 'root', css);\n const root = useAnimationRoot(rest);\n const chosen = options.find((o) => o.value === value);\n\n const choose = (o: ChoiceOption, close: (restore?: boolean) => void) => {\n if (o.disabled) return;\n setValue(o.value);\n close(true);\n };\n\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-choice', styled.className, className)} {...root}>\n <span id={labelId} className=\"slurp-choice-label\">\n {label}\n </span>\n <Bloom\n open={open}\n onOpenChange={setOpen}\n role=\"listbox\"\n width={width}\n placement={placement}\n disabled={disabled}\n trigger={\n <>\n <span className={cx('slurp-choice-value', !chosen && 'slurp-choice-placeholder')}>\n {chosen?.label ?? labels.placeholder}\n </span>\n <ChevronDownIcon size={18} />\n </>\n }\n partProps={{\n trigger: {\n 'aria-labelledby': `${labelId} ${labelId}-value`,\n onKeyDown: (e: KeyboardEvent) => {\n if (!open && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n setOpen(true);\n }\n },\n },\n panel: { 'aria-labelledby': labelId },\n }}\n >\n {(close) => (\n <div\n ref={list}\n className=\"slurp-choice-list\"\n onKeyDown={(e) => {\n if (moveFocus(e, list.current, '[role=\"option\"]')) return;\n if (e.key === 'Enter' || e.key === ' ') {\n const at = (e.target as HTMLElement).closest<HTMLElement>('[role=\"option\"]');\n const o = options.find((x) => x.value === at?.dataset.value);\n if (o) {\n e.preventDefault();\n choose(o, close);\n }\n }\n }}\n >\n {options.map((o) => {\n const on = o.value === value;\n return (\n <div\n key={o.value}\n role=\"option\"\n tabIndex={-1}\n aria-selected={on}\n aria-disabled={o.disabled || undefined}\n data-value={o.value}\n className=\"slurp-bloom-item\"\n onClick={() => choose(o, close)}\n >\n {o.icon != null && (\n <span className=\"slurp-bloom-item-icon\" aria-hidden=\"true\">\n {o.icon}\n </span>\n )}\n <span className=\"slurp-bloom-item-label\">{o.label}</span>\n {on && (\n <span className=\"slurp-bloom-item-check\" aria-hidden=\"true\">\n <CheckIcon size={18} />\n </span>\n )}\n </div>\n );\n })}\n </div>\n )}\n </Bloom>\n <span id={`${labelId}-value`} hidden>\n {chosen?.label ?? labels.placeholder}\n </span>\n {name && <input type=\"hidden\" name={name} value={value ?? ''} />}\n </Root>\n </>\n );\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface CountOwnProps {
|
|
5
|
+
value: number;
|
|
6
|
+
/** Above it the badge shows `max+`. Default 99. */
|
|
7
|
+
max?: number;
|
|
8
|
+
/**
|
|
9
|
+
* What the number counts, for assistive tech: `(n) => \`${n} filtri attivi\``. The text joins the accessible name
|
|
10
|
+
* of the control around it (a count is never only visual).
|
|
11
|
+
*/
|
|
12
|
+
label?: string | ((value: number) => string);
|
|
13
|
+
/** Default `accent`. */
|
|
14
|
+
tone?: 'accent' | 'neutral';
|
|
15
|
+
}
|
|
16
|
+
export type CountProps<E extends ElementType = 'span'> = PolymorphicProps<E, CountOwnProps>;
|
|
17
|
+
/** Count badge. Pair it with `label` so the number is part of the accessible name. */
|
|
18
|
+
export declare function Count<E extends ElementType = 'span'>(props: CountProps<E>): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=Count.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Count/Count.tsx
|
|
7
|
+
/** Count badge. Pair it with `label` so the number is part of the accessible name. */
|
|
8
|
+
function Count(props) {
|
|
9
|
+
const { as, css, className, value, max = 99, label, tone = "accent", ...rest } = useThemeProps("Count", props);
|
|
10
|
+
const Root = as ?? "span";
|
|
11
|
+
const styled = useCss("Count", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
const shown = value > max ? `${max}+` : String(value);
|
|
14
|
+
const spoken = typeof label === "function" ? label(value) : label;
|
|
15
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
16
|
+
className: cx("slurp-count", styled.className, className),
|
|
17
|
+
"data-tone": tone,
|
|
18
|
+
...root,
|
|
19
|
+
children: spoken ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: shown
|
|
22
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: "slurp-visually-hidden",
|
|
24
|
+
children: spoken
|
|
25
|
+
})] }) : shown
|
|
26
|
+
})] });
|
|
27
|
+
}
|
|
28
|
+
export { Count };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=Count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Count.js","names":[],"sources":["../../src/Count/Count.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface CountOwnProps {\n value: number;\n /** Above it the badge shows `max+`. Default 99. */\n max?: number;\n /**\n * What the number counts, for assistive tech: `(n) => \\`${n} filtri attivi\\``. The text joins the accessible name\n * of the control around it (a count is never only visual).\n */\n label?: string | ((value: number) => string);\n /** Default `accent`. */\n tone?: 'accent' | 'neutral';\n}\n\nexport type CountProps<E extends ElementType = 'span'> = PolymorphicProps<E, CountOwnProps>;\n\n/** Count badge. Pair it with `label` so the number is part of the accessible name. */\nexport function Count<E extends ElementType = 'span'>(props: CountProps<E>) {\n const {\n as,\n css,\n className,\n value,\n max = 99,\n label,\n tone = 'accent',\n ...rest\n } = useThemeProps('Count', props as CountProps);\n const Root = (as ?? 'span') as ElementType;\n const styled = useCss('Count', 'root', css);\n const root = useAnimationRoot(rest);\n const shown = value > max ? `${max}+` : String(value);\n const spoken = typeof label === 'function' ? label(value) : label;\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-count', styled.className, className)} data-tone={tone} {...root}>\n {spoken ? (\n <>\n <span aria-hidden=\"true\">{shown}</span>\n <span className=\"slurp-visually-hidden\">{spoken}</span>\n </>\n ) : (\n shown\n )}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,MAAsC,OAAsB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,OACA,MAAM,IACN,OACA,OAAO,UACP,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,QAAQ,MAAM,GAAG,IAAI,KAAK,OAAO,KAAK;CACpD,MAAM,SAAS,OAAO,UAAU,aAAa,MAAM,KAAK,IAAI;CAC5D,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;EAAG,aAAW;EAAM,GAAI;EACnF,UAAA,SACC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA;EAAY,CAAA,GACtC,oBAAC,QAAD;GAAM,WAAU;GAAyB,UAAA;EAAa,CAAA,CACtD,EAAA,CAAA,IAEF;CAEE,CAAA,CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface DialogLabels {
|
|
5
|
+
/** Name of the close button. */
|
|
6
|
+
close: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const DIALOG_LABELS: DialogLabels;
|
|
9
|
+
export interface DialogOwnProps extends PartsProps<'header' | 'title' | 'description' | 'body' | 'footer' | 'close'> {
|
|
10
|
+
/** The dialog's name (its heading). */
|
|
11
|
+
title: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
open?: boolean;
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
/** Buttons at the bottom (one primary action). */
|
|
17
|
+
actions?: ReactNode;
|
|
18
|
+
/** A press on the backdrop closes it. Default true. */
|
|
19
|
+
dismissible?: boolean;
|
|
20
|
+
labels?: Partial<DialogLabels>;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export type DialogProps<E extends ElementType = 'dialog'> = PolymorphicProps<E, DialogOwnProps>;
|
|
24
|
+
/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */
|
|
25
|
+
export declare function Dialog<E extends ElementType = 'dialog'>(props: DialogProps<E>): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { Bubble } from "../Bubble/Bubble.js";
|
|
7
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
8
|
+
import { useEffect, useId, useLayoutEffect, useRef } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { CloseIcon } from "@slurp-ui/icons";
|
|
11
|
+
// src/Dialog/Dialog.tsx
|
|
12
|
+
const DIALOG_LABELS = { close: "Chiudi" };
|
|
13
|
+
const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
14
|
+
/** Shared by Dialog and Sheet: a native modal <dialog> (top layer, focus contained, Escape, inert page). */
|
|
15
|
+
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;
|
|
17
|
+
const labels = {
|
|
18
|
+
...DIALOG_LABELS,
|
|
19
|
+
...labelsProp
|
|
20
|
+
};
|
|
21
|
+
const [open, setOpen] = useControlled({
|
|
22
|
+
value: openProp,
|
|
23
|
+
defaultValue: defaultOpen,
|
|
24
|
+
onChange: onOpenChange
|
|
25
|
+
});
|
|
26
|
+
const dialog = useRef(null);
|
|
27
|
+
const opener = useRef(null);
|
|
28
|
+
const id = useId();
|
|
29
|
+
const name = variant === "sheet" ? "Sheet" : "Dialog";
|
|
30
|
+
const styled = useCss(name, "root", css);
|
|
31
|
+
const { part, style } = useParts(name, {
|
|
32
|
+
parts,
|
|
33
|
+
partProps,
|
|
34
|
+
classNames
|
|
35
|
+
});
|
|
36
|
+
const root = useAnimationRoot({
|
|
37
|
+
...rest,
|
|
38
|
+
ref: useForkRef(ref, dialog)
|
|
39
|
+
});
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
const el = dialog.current;
|
|
42
|
+
if (!el) return;
|
|
43
|
+
if (open && !el.open) {
|
|
44
|
+
opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
45
|
+
if (typeof el.showModal === "function") el.showModal();
|
|
46
|
+
else el.setAttribute("open", "");
|
|
47
|
+
grow(el, opener.current, variant);
|
|
48
|
+
} else if (!open && el.open) {
|
|
49
|
+
if (typeof el.close === "function") el.close();
|
|
50
|
+
else el.removeAttribute("open");
|
|
51
|
+
opener.current?.focus();
|
|
52
|
+
opener.current = null;
|
|
53
|
+
}
|
|
54
|
+
}, [open, variant]);
|
|
55
|
+
useEffect(() => () => opener.current?.focus(), []);
|
|
56
|
+
const Root = as ?? "dialog";
|
|
57
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
58
|
+
styled.style,
|
|
59
|
+
style,
|
|
60
|
+
/* @__PURE__ */ jsx(Root, {
|
|
61
|
+
className: cx("slurp-dialog", styled.className, className),
|
|
62
|
+
"data-variant": variant,
|
|
63
|
+
"aria-labelledby": `${id}-title`,
|
|
64
|
+
"aria-describedby": description != null ? `${id}-description` : void 0,
|
|
65
|
+
onCancel: (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
setOpen(false);
|
|
68
|
+
},
|
|
69
|
+
onClick: (e) => {
|
|
70
|
+
if (dismissible && e.target === e.currentTarget) setOpen(false);
|
|
71
|
+
},
|
|
72
|
+
...root,
|
|
73
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: "slurp-dialog-inner",
|
|
75
|
+
children: [
|
|
76
|
+
part("header", "div", {
|
|
77
|
+
className: "slurp-dialog-header",
|
|
78
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
79
|
+
className: "slurp-dialog-heading",
|
|
80
|
+
children: [part("title", "h2", {
|
|
81
|
+
id: `${id}-title`,
|
|
82
|
+
className: "slurp-dialog-title",
|
|
83
|
+
children: title
|
|
84
|
+
}), description != null && part("description", "p", {
|
|
85
|
+
id: `${id}-description`,
|
|
86
|
+
className: "slurp-dialog-description",
|
|
87
|
+
children: description
|
|
88
|
+
})]
|
|
89
|
+
}), part("close", Bubble, {
|
|
90
|
+
className: "slurp-dialog-close",
|
|
91
|
+
label: labels.close,
|
|
92
|
+
size: "sm",
|
|
93
|
+
onClick: () => setOpen(false),
|
|
94
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
95
|
+
})] })
|
|
96
|
+
}),
|
|
97
|
+
children != null && part("body", "div", {
|
|
98
|
+
className: "slurp-dialog-body",
|
|
99
|
+
children
|
|
100
|
+
}),
|
|
101
|
+
actions != null && part("footer", "div", {
|
|
102
|
+
className: "slurp-dialog-footer",
|
|
103
|
+
children: actions
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The dialog grows out of the control that opened it (the Bloom rule applied to a modal): it starts at the opener's
|
|
112
|
+
* box and settles in the centre. A sheet rises from the bottom edge.
|
|
113
|
+
*/
|
|
114
|
+
function grow(el, from, variant) {
|
|
115
|
+
if (reduced() || typeof el.animate !== "function") return;
|
|
116
|
+
const timing = {
|
|
117
|
+
duration: 450,
|
|
118
|
+
easing: "cubic-bezier(0.2, 0.8, 0.2, 1)"
|
|
119
|
+
};
|
|
120
|
+
if (variant === "sheet") {
|
|
121
|
+
el.animate([{ transform: "translateY(100%)" }, { transform: "none" }], timing);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const to = el.getBoundingClientRect();
|
|
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);
|
|
138
|
+
el.animate([{
|
|
139
|
+
transform: `translate(${dx}px, ${dy}px) scale(${at.width / to.width}, ${at.height / to.height})`,
|
|
140
|
+
opacity: .4
|
|
141
|
+
}, {
|
|
142
|
+
transform: "none",
|
|
143
|
+
opacity: 1
|
|
144
|
+
}], timing);
|
|
145
|
+
}
|
|
146
|
+
/** Modal dialog, centred, opened from a trigger: title, description, content and one primary action. */
|
|
147
|
+
function Dialog(props) {
|
|
148
|
+
return useModal(useThemeProps("Dialog", props), "dialog");
|
|
149
|
+
}
|
|
150
|
+
export { DIALOG_LABELS, Dialog, useModal };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=Dialog.js.map
|
|
@@ -0,0 +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":"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"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface DockLabels {
|
|
5
|
+
/** Name of the navigation landmark. */
|
|
6
|
+
navigation: string;
|
|
7
|
+
/** Name of the breadcrumb list. */
|
|
8
|
+
crumbs: string;
|
|
9
|
+
/** Name of the back button. */
|
|
10
|
+
back: string;
|
|
11
|
+
/** Name of the search field and of the phone search action. */
|
|
12
|
+
search: string;
|
|
13
|
+
/** Placeholder: say where it looks ("Cerca in Smartphone…"). */
|
|
14
|
+
searchPlaceholder: string;
|
|
15
|
+
/** Find in page with no match. */
|
|
16
|
+
noResults: string;
|
|
17
|
+
/** Spoken count of find in page. */
|
|
18
|
+
matches: (index: number, count: number) => string;
|
|
19
|
+
/** Name of the "2/5" counter button. */
|
|
20
|
+
nextMatch: (index: number, count: number) => string;
|
|
21
|
+
/** How to move into results from the field. */
|
|
22
|
+
resultsHint: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const DOCK_LABELS: DockLabels;
|
|
25
|
+
export interface DockOwnProps {
|
|
26
|
+
/** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
/** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */
|
|
29
|
+
panel?: ReactNode;
|
|
30
|
+
/** Name of the panel region ("Filtri"). */
|
|
31
|
+
panelLabel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.
|
|
34
|
+
*/
|
|
35
|
+
focusPanel?: boolean;
|
|
36
|
+
/** A press outside, Escape or Tab out: close your panel here. */
|
|
37
|
+
onDismiss?: () => void;
|
|
38
|
+
/** In the flow (previews, docs) instead of fixed at the bottom. */
|
|
39
|
+
inline?: boolean;
|
|
40
|
+
labels?: Partial<DockLabels>;
|
|
41
|
+
}
|
|
42
|
+
export type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;
|
|
43
|
+
/**
|
|
44
|
+
* The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search
|
|
45
|
+
* and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press
|
|
46
|
+
* outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.
|
|
47
|
+
*/
|
|
48
|
+
declare function DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>): import("react").JSX.Element;
|
|
49
|
+
export interface DockCrumbsProps {
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/** Name of the list; default `labels.crumbs`. */
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */
|
|
55
|
+
declare function DockCrumbs({ children, label }: DockCrumbsProps): import("react").JSX.Element;
|
|
56
|
+
export type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<E, {
|
|
57
|
+
label?: string;
|
|
58
|
+
}>;
|
|
59
|
+
/** The back button: the first crumb (the root), round on the left. */
|
|
60
|
+
declare function DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>): import("react").JSX.Element;
|
|
61
|
+
export interface DockCrumbOwnProps {
|
|
62
|
+
/** The level's name. */
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
/** The page you are on: accent-filled, `aria-current="page"`. */
|
|
65
|
+
current?: boolean;
|
|
66
|
+
/** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */
|
|
67
|
+
icon?: ReactNode;
|
|
68
|
+
/** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */
|
|
69
|
+
expanded?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<E, DockCrumbOwnProps>;
|
|
72
|
+
/** A level of the path. Every crumb triggers the transition: give it an animationId. */
|
|
73
|
+
declare function DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>): import("react").JSX.Element;
|
|
74
|
+
export interface DockSearchProps {
|
|
75
|
+
value?: string;
|
|
76
|
+
defaultValue?: string;
|
|
77
|
+
onValueChange?: (value: string) => void;
|
|
78
|
+
/** Name of the field; default `labels.search`. */
|
|
79
|
+
label?: string;
|
|
80
|
+
/** Default `labels.searchPlaceholder`: say where it looks. */
|
|
81
|
+
placeholder?: string;
|
|
82
|
+
/** Enter, when this is not find in page. */
|
|
83
|
+
onSearch?: (value: string) => void;
|
|
84
|
+
/** Find in page: how many matches (shows "2/5" or "Nessun risultato"). */
|
|
85
|
+
count?: number;
|
|
86
|
+
/** Find in page: the active match, 0-based. */
|
|
87
|
+
index?: number;
|
|
88
|
+
/** Find in page: Enter / Shift+Enter / a tap on the counter. */
|
|
89
|
+
onStep?: (delta: 1 | -1) => void;
|
|
90
|
+
}
|
|
91
|
+
/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */
|
|
92
|
+
declare function DockSearch({ value: valueProp, defaultValue, onValueChange, label, placeholder, onSearch, count, index, onStep }: DockSearchProps): import("react").JSX.Element;
|
|
93
|
+
/** Actions at the right end of the bar (search before filters). */
|
|
94
|
+
declare function DockActions({ children }: {
|
|
95
|
+
children?: ReactNode;
|
|
96
|
+
}): import("react").JSX.Element;
|
|
97
|
+
export interface DockActionOwnProps {
|
|
98
|
+
/** Accessible name ("Filtri"); the count is added to it. */
|
|
99
|
+
label: string;
|
|
100
|
+
/** The icon. */
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
/** Its panel is open: accent fill and aria-expanded. */
|
|
103
|
+
expanded?: boolean;
|
|
104
|
+
/** Badge count (active filters). */
|
|
105
|
+
count?: number;
|
|
106
|
+
/** How the count is said; default `${n} attivi`. */
|
|
107
|
+
countLabel?: (count: number) => string;
|
|
108
|
+
/** A small accent dot (a query is active while the search panel is closed). */
|
|
109
|
+
dot?: boolean;
|
|
110
|
+
}
|
|
111
|
+
export type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<E, DockActionOwnProps>;
|
|
112
|
+
/** Round 48px action of the bar (filters, the phone search). */
|
|
113
|
+
declare function DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>): import("react").JSX.Element;
|
|
114
|
+
type DockComponent = typeof DockRoot & {
|
|
115
|
+
Crumbs: typeof DockCrumbs;
|
|
116
|
+
Back: typeof DockBack;
|
|
117
|
+
Crumb: typeof DockCrumb;
|
|
118
|
+
Search: typeof DockSearch;
|
|
119
|
+
Actions: typeof DockActions;
|
|
120
|
+
Action: typeof DockAction;
|
|
121
|
+
};
|
|
122
|
+
export declare const Dock: DockComponent;
|
|
123
|
+
export { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };
|
|
124
|
+
//# sourceMappingURL=Dock.d.ts.map
|