@slurp-ui/react 0.0.0-stage → 1.0.1
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 +84 -0
- 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 +108 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ErrorIcon } from "@slurp-ui/icons";
|
|
9
|
+
// src/Field/Field.tsx
|
|
10
|
+
const INPUT_KEYS = [
|
|
11
|
+
"name",
|
|
12
|
+
"type",
|
|
13
|
+
"placeholder",
|
|
14
|
+
"autoComplete",
|
|
15
|
+
"autoFocus",
|
|
16
|
+
"inputMode",
|
|
17
|
+
"enterKeyHint",
|
|
18
|
+
"maxLength",
|
|
19
|
+
"minLength",
|
|
20
|
+
"pattern",
|
|
21
|
+
"readOnly",
|
|
22
|
+
"required",
|
|
23
|
+
"disabled",
|
|
24
|
+
"spellCheck",
|
|
25
|
+
"onBlur",
|
|
26
|
+
"onFocus",
|
|
27
|
+
"onKeyDown"
|
|
28
|
+
];
|
|
29
|
+
/** Splits the native input's props from the root's. */
|
|
30
|
+
function splitInputProps(props) {
|
|
31
|
+
const input = {};
|
|
32
|
+
const root = {};
|
|
33
|
+
for (const [k, v] of Object.entries(props)) if (INPUT_KEYS.includes(k)) input[k] = v;
|
|
34
|
+
else root[k] = v;
|
|
35
|
+
return {
|
|
36
|
+
input,
|
|
37
|
+
root
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Text field: label, input (boundary `border-control`, 3:1), hint and error, wired for assistive tech. */
|
|
41
|
+
function Field(props) {
|
|
42
|
+
const { as, css, className, label, hint, error, value: valueProp, defaultValue = "", onValueChange, multiline = false, rows = 3, id: idProp, parts, partProps, classNames, ...others } = useThemeProps("Field", props);
|
|
43
|
+
const { input, root: rest } = splitInputProps(others);
|
|
44
|
+
const [value, setValue] = useControlled({
|
|
45
|
+
value: valueProp,
|
|
46
|
+
defaultValue,
|
|
47
|
+
onChange: void 0
|
|
48
|
+
});
|
|
49
|
+
const auto = useId();
|
|
50
|
+
const id = idProp ?? `${auto}-input`;
|
|
51
|
+
const hintId = hint != null ? `${auto}-hint` : void 0;
|
|
52
|
+
const errorId = error != null && error !== false ? `${auto}-error` : void 0;
|
|
53
|
+
const Root = as ?? "div";
|
|
54
|
+
const styled = useCss("Field", "root", css);
|
|
55
|
+
const { part, style } = useParts("Field", {
|
|
56
|
+
parts,
|
|
57
|
+
partProps,
|
|
58
|
+
classNames
|
|
59
|
+
});
|
|
60
|
+
const root = useAnimationRoot(rest);
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
62
|
+
styled.style,
|
|
63
|
+
style,
|
|
64
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
65
|
+
className: cx("slurp-field", styled.className, className),
|
|
66
|
+
"data-invalid": errorId ? "" : void 0,
|
|
67
|
+
"data-disabled": input.disabled ? "" : void 0,
|
|
68
|
+
...root,
|
|
69
|
+
children: [
|
|
70
|
+
part("label", "label", {
|
|
71
|
+
htmlFor: id,
|
|
72
|
+
className: "slurp-field-label",
|
|
73
|
+
children: label
|
|
74
|
+
}),
|
|
75
|
+
part("control", multiline ? "textarea" : "input", {
|
|
76
|
+
...input,
|
|
77
|
+
id,
|
|
78
|
+
rows: multiline ? rows : void 0,
|
|
79
|
+
type: multiline ? void 0 : input.type ?? "text",
|
|
80
|
+
className: "slurp-field-control",
|
|
81
|
+
value,
|
|
82
|
+
"aria-invalid": errorId ? true : void 0,
|
|
83
|
+
"aria-describedby": cx(errorId, hintId) || void 0,
|
|
84
|
+
onChange: (e) => {
|
|
85
|
+
setValue(e.target.value);
|
|
86
|
+
onValueChange?.(e.target.value, e);
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
hintId && part("hint", "p", {
|
|
90
|
+
id: hintId,
|
|
91
|
+
className: "slurp-field-hint",
|
|
92
|
+
children: hint
|
|
93
|
+
}),
|
|
94
|
+
errorId && part("error", "p", {
|
|
95
|
+
id: errorId,
|
|
96
|
+
className: "slurp-field-error",
|
|
97
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ErrorIcon, { size: 16 }), /* @__PURE__ */ jsx("span", { children: error })] })
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
export { Field, splitInputProps };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=Field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Field.js","names":[],"sources":["../../src/Field/Field.tsx"],"sourcesContent":["import { ErrorIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n useId,\n type ChangeEvent,\n type ElementType,\n type FocusEventHandler,\n type HTMLInputTypeAttribute,\n type KeyboardEventHandler,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\n/** Props that belong to the native input (the rest goes to the root, like every component). */\nexport interface InputAttributes {\n name?: string;\n type?: HTMLInputTypeAttribute;\n placeholder?: string;\n autoComplete?: string;\n autoFocus?: boolean;\n inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n readOnly?: boolean;\n required?: boolean;\n disabled?: boolean;\n spellCheck?: boolean;\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n}\n\nconst INPUT_KEYS = [\n 'name',\n 'type',\n 'placeholder',\n 'autoComplete',\n 'autoFocus',\n 'inputMode',\n 'enterKeyHint',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'readOnly',\n 'required',\n 'disabled',\n 'spellCheck',\n 'onBlur',\n 'onFocus',\n 'onKeyDown',\n] as const;\n\n/** Splits the native input's props from the root's. */\nexport function splitInputProps<P extends object>(props: P) {\n const input: Record<string, unknown> = {};\n const root: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(props)) {\n if ((INPUT_KEYS as readonly string[]).includes(k)) input[k] = v;\n else root[k] = v;\n }\n return { input, root };\n}\n\nexport interface FieldOwnProps\n extends InputAttributes, PartsProps<'label' | 'control' | 'hint' | 'error'> {\n /** Visible label (always: placeholders are not labels). */\n label: ReactNode;\n /** Help text under the field, linked with aria-describedby. */\n hint?: ReactNode;\n /** Error message: marks the field invalid and shows the message with an icon. */\n error?: ReactNode;\n value?: string;\n defaultValue?: string;\n onValueChange?: (\n value: string,\n event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,\n ) => void;\n /** A textarea instead of an input. */\n multiline?: boolean;\n /** Rows of the textarea. Default 3. */\n rows?: number;\n /** id of the input (generated by default). */\n id?: string;\n}\n\nexport type FieldProps<E extends ElementType = 'div'> = PolymorphicProps<E, FieldOwnProps>;\n\n/** Text field: label, input (boundary `border-control`, 3:1), hint and error, wired for assistive tech. */\nexport function Field<E extends ElementType = 'div'>(props: FieldProps<E>) {\n const {\n as,\n css,\n className,\n label,\n hint,\n error,\n value: valueProp,\n defaultValue = '',\n onValueChange,\n multiline = false,\n rows = 3,\n id: idProp,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Field', props as FieldProps);\n const { input, root: rest } = splitInputProps(others);\n const [value, setValue] = useControlled({ value: valueProp, defaultValue, onChange: undefined });\n const auto = useId();\n const id = idProp ?? `${auto}-input`;\n const hintId = hint != null ? `${auto}-hint` : undefined;\n const errorId = error != null && error !== false ? `${auto}-error` : undefined;\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Field', 'root', css);\n const { part, style } = useParts('Field', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-field', styled.className, className)}\n data-invalid={errorId ? '' : undefined}\n data-disabled={input.disabled ? '' : undefined}\n {...root}\n >\n {part('label', 'label', { htmlFor: id, className: 'slurp-field-label', children: label })}\n {part('control', multiline ? 'textarea' : 'input', {\n ...input,\n id,\n rows: multiline ? rows : undefined,\n type: multiline ? undefined : (input.type ?? 'text'),\n className: 'slurp-field-control',\n value,\n 'aria-invalid': errorId ? true : undefined,\n 'aria-describedby': cx(errorId, hintId) || undefined,\n onChange: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setValue(e.target.value);\n onValueChange?.(e.target.value, e);\n },\n })}\n {hintId && part('hint', 'p', { id: hintId, className: 'slurp-field-hint', children: hint })}\n {errorId &&\n part('error', 'p', {\n id: errorId,\n className: 'slurp-field-error',\n children: (\n <>\n <ErrorIcon size={16} />\n <span>{error}</span>\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAsCA,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,gBAAkC,OAAU;CAC1D,MAAM,QAAiC,CAAC;CACxC,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,IAAK,WAAiC,SAAS,CAAC,GAAG,MAAM,KAAK;MACzD,KAAK,KAAK;CAEjB,OAAO;EAAE;EAAO;CAAK;AACvB;;AA2BA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,OACA,OAAO,WACP,eAAe,IACf,eACA,YAAY,OACZ,OAAO,GACP,IAAI,QACJ,OACA,WACA,YACA,GAAG,WACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,EAAE,OAAO,MAAM,SAAS,gBAAgB,MAAM;CACpD,MAAM,CAAC,OAAO,YAAY,cAAc;EAAE,OAAO;EAAW;EAAc,UAAU,KAAA;CAAU,CAAC;CAC/F,MAAM,OAAO,MAAM;CACnB,MAAM,KAAK,UAAU,GAAG,KAAK;CAC7B,MAAM,SAAS,QAAQ,OAAO,GAAG,KAAK,SAAS,KAAA;CAC/C,MAAM,UAAU,SAAS,QAAQ,UAAU,QAAQ,GAAG,KAAK,UAAU,KAAA;CACrE,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,EAAE,MAAM,UAAU,SAAS,SAAS;EAAE;EAAO;EAAW;CAAW,CAAC;CAC1E,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;GACxD,gBAAc,UAAU,KAAK,KAAA;GAC7B,iBAAe,MAAM,WAAW,KAAK,KAAA;GACrC,GAAI;GAJN,UAAA;IAMG,KAAK,SAAS,SAAS;KAAE,SAAS;KAAI,WAAW;KAAqB,UAAU;IAAM,CAAC;IACvF,KAAK,WAAW,YAAY,aAAa,SAAS;KACjD,GAAG;KACH;KACA,MAAM,YAAY,OAAO,KAAA;KACzB,MAAM,YAAY,KAAA,IAAa,MAAM,QAAQ;KAC7C,WAAW;KACX;KACA,gBAAgB,UAAU,OAAO,KAAA;KACjC,oBAAoB,GAAG,SAAS,MAAM,KAAK,KAAA;KAC3C,WAAW,MAA2D;MACpE,SAAS,EAAE,OAAO,KAAK;MACvB,gBAAgB,EAAE,OAAO,OAAO,CAAC;KACnC;IACF,CAAC;IACA,UAAU,KAAK,QAAQ,KAAK;KAAE,IAAI;KAAQ,WAAW;KAAoB,UAAU;IAAK,CAAC;IACzF,WACC,KAAK,SAAS,KAAK;KACjB,IAAI;KACJ,WAAW;KACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACtB,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,CACnB,EAAA,CAAA;IAEN,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface FiltersLabels {
|
|
5
|
+
title: string;
|
|
6
|
+
reset: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const FILTERS_LABELS: FiltersLabels;
|
|
9
|
+
export interface FiltersOwnProps {
|
|
10
|
+
/** Clears every filter. Off (muted outline) when nothing is active. */
|
|
11
|
+
onReset?: () => void;
|
|
12
|
+
/** How many filters are active: the reset is disabled at 0. */
|
|
13
|
+
active?: number;
|
|
14
|
+
labels?: Partial<FiltersLabels>;
|
|
15
|
+
/** Filters.Group elements. */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export type FiltersProps<E extends ElementType = 'div'> = PolymorphicProps<E, FiltersOwnProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Filter panel content (in the Dock's panel or a Sheet): a title, "Azzera filtri" at the top right, then groups of
|
|
21
|
+
* chips.
|
|
22
|
+
*/
|
|
23
|
+
declare function FiltersRoot<E extends ElementType = 'div'>(props: FiltersProps<E>): import("react").JSX.Element;
|
|
24
|
+
export interface FiltersGroupProps {
|
|
25
|
+
/** Name of the group ("Condizione"). */
|
|
26
|
+
label: ReactNode;
|
|
27
|
+
/** Chips. */
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
/** A group of filter chips with its name (a fieldset and legend). */
|
|
32
|
+
declare function FiltersGroup({ label, children, className }: FiltersGroupProps): import("react").JSX.Element;
|
|
33
|
+
export declare const Filters: typeof FiltersRoot & {
|
|
34
|
+
Group: typeof FiltersGroup;
|
|
35
|
+
};
|
|
36
|
+
export { FiltersGroup };
|
|
37
|
+
//# sourceMappingURL=Filters.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { useId } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ResetIcon } from "@slurp-ui/icons";
|
|
8
|
+
// src/Filters/Filters.tsx
|
|
9
|
+
const FILTERS_LABELS = {
|
|
10
|
+
title: "Filtri",
|
|
11
|
+
reset: "Azzera filtri"
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Filter panel content (in the Dock's panel or a Sheet): a title, "Azzera filtri" at the top right, then groups of
|
|
15
|
+
* chips.
|
|
16
|
+
*/
|
|
17
|
+
function FiltersRoot(props) {
|
|
18
|
+
const { as, css, className, onReset, active = 0, labels: labelsProp, children, ...rest } = useThemeProps("Filters", props);
|
|
19
|
+
const labels = {
|
|
20
|
+
...FILTERS_LABELS,
|
|
21
|
+
...labelsProp
|
|
22
|
+
};
|
|
23
|
+
const Root = as ?? "div";
|
|
24
|
+
const styled = useCss("Filters", "root", css);
|
|
25
|
+
const root = useAnimationRoot(rest);
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
27
|
+
className: cx("slurp-filters", styled.className, className),
|
|
28
|
+
...root,
|
|
29
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
30
|
+
className: "slurp-filters-head",
|
|
31
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
32
|
+
className: "slurp-filters-title",
|
|
33
|
+
children: labels.title
|
|
34
|
+
}), onReset && /* @__PURE__ */ jsxs("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
className: "slurp-filters-reset",
|
|
37
|
+
disabled: active === 0,
|
|
38
|
+
onClick: onReset,
|
|
39
|
+
children: [/* @__PURE__ */ jsx(ResetIcon, { size: 16 }), labels.reset]
|
|
40
|
+
})]
|
|
41
|
+
}), children]
|
|
42
|
+
})] });
|
|
43
|
+
}
|
|
44
|
+
/** A group of filter chips with its name (a fieldset and legend). */
|
|
45
|
+
function FiltersGroup({ label, children, className }) {
|
|
46
|
+
const id = useId();
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
role: "group",
|
|
49
|
+
"aria-labelledby": id,
|
|
50
|
+
className: cx("slurp-filters-group", className),
|
|
51
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
52
|
+
id,
|
|
53
|
+
className: "slurp-filters-legend",
|
|
54
|
+
children: label
|
|
55
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: "slurp-filters-chips",
|
|
57
|
+
children
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const Filters = Object.assign(FiltersRoot, { Group: FiltersGroup });
|
|
62
|
+
export { FILTERS_LABELS, Filters, FiltersGroup };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filters.js","names":[],"sources":["../../src/Filters/Filters.tsx"],"sourcesContent":["import { ResetIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FiltersLabels {\n title: string;\n reset: string;\n}\n\nexport const FILTERS_LABELS: FiltersLabels = { title: 'Filtri', reset: 'Azzera filtri' };\n\nexport interface FiltersOwnProps {\n /** Clears every filter. Off (muted outline) when nothing is active. */\n onReset?: () => void;\n /** How many filters are active: the reset is disabled at 0. */\n active?: number;\n labels?: Partial<FiltersLabels>;\n /** Filters.Group elements. */\n children?: ReactNode;\n}\n\nexport type FiltersProps<E extends ElementType = 'div'> = PolymorphicProps<E, FiltersOwnProps>;\n\n/**\n * Filter panel content (in the Dock's panel or a Sheet): a title, \"Azzera filtri\" at the top right, then groups of\n * chips.\n */\nfunction FiltersRoot<E extends ElementType = 'div'>(props: FiltersProps<E>) {\n const {\n as,\n css,\n className,\n onReset,\n active = 0,\n labels: labelsProp,\n children,\n ...rest\n } = useThemeProps('Filters', props as FiltersProps);\n const labels = { ...FILTERS_LABELS, ...labelsProp };\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Filters', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-filters', styled.className, className)} {...root}>\n <div className=\"slurp-filters-head\">\n <h2 className=\"slurp-filters-title\">{labels.title}</h2>\n {onReset && (\n <button\n type=\"button\"\n className=\"slurp-filters-reset\"\n disabled={active === 0}\n onClick={onReset}\n >\n <ResetIcon size={16} />\n {labels.reset}\n </button>\n )}\n </div>\n {children}\n </Root>\n </>\n );\n}\n\nexport interface FiltersGroupProps {\n /** Name of the group (\"Condizione\"). */\n label: ReactNode;\n /** Chips. */\n children?: ReactNode;\n className?: string;\n}\n\n/** A group of filter chips with its name (a fieldset and legend). */\nfunction FiltersGroup({ label, children, className }: FiltersGroupProps) {\n const id = useId();\n return (\n <div role=\"group\" aria-labelledby={id} className={cx('slurp-filters-group', className)}>\n <span id={id} className=\"slurp-filters-legend\">\n {label}\n </span>\n <div className=\"slurp-filters-chips\">{children}</div>\n </div>\n );\n}\n\nexport const Filters = Object.assign(FiltersRoot, { Group: FiltersGroup });\nexport { FiltersGroup };\n"],"mappings":";;;;;;;;AAaA,MAAa,iBAAgC;CAAE,OAAO;CAAU,OAAO;AAAgB;;;;;AAkBvF,SAAS,YAA2C,OAAwB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,SACA,SAAS,GACT,QAAQ,YACR,UACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS;EAAE,GAAG;EAAgB,GAAG;CAAW;CAClD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EAAM,WAAW,GAAG,iBAAiB,OAAO,WAAW,SAAS;EAAG,GAAI;EAAvE,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,MAAD;IAAI,WAAU;IAAuB,UAAA,OAAO;GAAU,CAAA,GACrD,WACC,qBAAC,UAAD;IACE,MAAK;IACL,WAAU;IACV,UAAU,WAAW;IACrB,SAAS;IAJX,UAAA,CAME,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,OAAO,KACF;GAEP,CAAA,CAAA;EACJ,CAAA,GAAA,QACG;CACN,CAAA,CAAA,EAAA,CAAA;AAEN;;AAWA,SAAS,aAAa,EAAE,OAAO,UAAU,aAAgC;CACvE,MAAM,KAAK,MAAM;CACjB,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,mBAAiB;EAAI,WAAW,GAAG,uBAAuB,SAAS;EAArF,UAAA,CACE,oBAAC,QAAD;GAAU;GAAI,WAAU;GACrB,UAAA;EACG,CAAA,GACN,oBAAC,OAAD;GAAK,WAAU;GAAuB;EAAc,CAAA,CACjD;;AAET;AAEA,MAAa,UAAU,OAAO,OAAO,aAAa,EAAE,OAAO,aAAa,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { MaybeResponsive, SpaceValue } from "../lib/css.js";
|
|
3
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
4
|
+
import { CSSProperties, ElementType } from "react";
|
|
5
|
+
export interface FlowOwnProps {
|
|
6
|
+
/** Default `column`. */
|
|
7
|
+
direction?: MaybeResponsive<'column' | 'row'>;
|
|
8
|
+
/** Step of the space scale or any length. Default `4` (`--slurp-flow-gap`). */
|
|
9
|
+
gap?: MaybeResponsive<SpaceValue>;
|
|
10
|
+
align?: MaybeResponsive<CSSProperties['alignItems']>;
|
|
11
|
+
justify?: MaybeResponsive<CSSProperties['justifyContent']>;
|
|
12
|
+
wrap?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type FlowProps<E extends ElementType = 'div'> = PolymorphicProps<E, FlowOwnProps>;
|
|
15
|
+
/** A column or a row of children with a gap from the space scale. */
|
|
16
|
+
export declare function Flow<E extends ElementType = 'div'>(props: FlowProps<E>): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Flow.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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/Flow/Flow.tsx
|
|
7
|
+
/** A column or a row of children with a gap from the space scale. */
|
|
8
|
+
function Flow(props) {
|
|
9
|
+
const { as, css, className, direction, gap, align, justify, wrap, ...rest } = useThemeProps("Flow", props);
|
|
10
|
+
const Root = as ?? "div";
|
|
11
|
+
const styled = useCss("Flow", "root", {
|
|
12
|
+
flexDirection: direction,
|
|
13
|
+
gap,
|
|
14
|
+
alignItems: align,
|
|
15
|
+
justifyContent: justify,
|
|
16
|
+
flexWrap: wrap ? "wrap" : void 0
|
|
17
|
+
}, css);
|
|
18
|
+
const root = useAnimationRoot(rest);
|
|
19
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
20
|
+
className: cx("slurp-flow", styled.className, className),
|
|
21
|
+
...root
|
|
22
|
+
})] });
|
|
23
|
+
}
|
|
24
|
+
export { Flow };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=Flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.js","names":[],"sources":["../../src/Flow/Flow.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { MaybeResponsive, SlurpCss, SpaceValue } from '../lib/css';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FlowOwnProps {\n /** Default `column`. */\n direction?: MaybeResponsive<'column' | 'row'>;\n /** Step of the space scale or any length. Default `4` (`--slurp-flow-gap`). */\n gap?: MaybeResponsive<SpaceValue>;\n align?: MaybeResponsive<CSSProperties['alignItems']>;\n justify?: MaybeResponsive<CSSProperties['justifyContent']>;\n wrap?: boolean;\n}\n\nexport type FlowProps<E extends ElementType = 'div'> = PolymorphicProps<E, FlowOwnProps>;\n\n/** A column or a row of children with a gap from the space scale. */\nexport function Flow<E extends ElementType = 'div'>(props: FlowProps<E>) {\n const { as, css, className, direction, gap, align, justify, wrap, ...rest } = useThemeProps(\n 'Flow',\n props as FlowProps,\n );\n const Root = (as ?? 'div') as ElementType;\n const layout: SlurpCss = {\n flexDirection: direction,\n gap,\n alignItems: align,\n justifyContent: justify,\n flexWrap: wrap ? 'wrap' : undefined,\n };\n const styled = useCss('Flow', 'root', layout, css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-flow', styled.className, className)} {...root} />\n </>\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EAAE,IAAI,KAAK,WAAW,WAAW,KAAK,OAAO,SAAS,MAAM,GAAG,SAAS,cAC5E,QACA,KACF;CACA,MAAM,OAAQ,MAAM;CAQpB,MAAM,SAAS,OAAO,QAAQ,QAAQ;EANpC,eAAe;EACf;EACA,YAAY;EACZ,gBAAgB;EAChB,UAAU,OAAO,SAAS,KAAA;CAEe,GAAG,GAAG;CACjD,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;CAAO,CAAA,CAC3E,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface FoldOwnProps extends PartsProps<'heading' | 'trigger' | 'region'> {
|
|
5
|
+
/** The always-visible row (the button's text). */
|
|
6
|
+
summary: ReactNode;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
/** Level of the heading that wraps the button. Default 3. */
|
|
11
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export type FoldProps<E extends ElementType = 'div'> = PolymorphicProps<E, FoldOwnProps>;
|
|
15
|
+
/** Disclosure (accordion item): opens by growing in height; closed content is out of the tab order. */
|
|
16
|
+
export declare function Fold<E extends ElementType = 'div'>(props: FoldProps<E>): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Fold.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ChevronDownIcon } from "@slurp-ui/icons";
|
|
9
|
+
// src/Fold/Fold.tsx
|
|
10
|
+
/** Disclosure (accordion item): opens by growing in height; closed content is out of the tab order. */
|
|
11
|
+
function Fold(props) {
|
|
12
|
+
const { as, css, className, summary, open: openProp, defaultOpen = false, onOpenChange, headingLevel = 3, children, parts, partProps, classNames, ...rest } = useThemeProps("Fold", props);
|
|
13
|
+
const [open, setOpen] = useControlled({
|
|
14
|
+
value: openProp,
|
|
15
|
+
defaultValue: defaultOpen,
|
|
16
|
+
onChange: onOpenChange
|
|
17
|
+
});
|
|
18
|
+
const id = useId();
|
|
19
|
+
const Root = as ?? "div";
|
|
20
|
+
const styled = useCss("Fold", "root", css);
|
|
21
|
+
const { part, style } = useParts("Fold", {
|
|
22
|
+
parts,
|
|
23
|
+
partProps,
|
|
24
|
+
classNames
|
|
25
|
+
});
|
|
26
|
+
const root = useAnimationRoot(rest);
|
|
27
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
28
|
+
styled.style,
|
|
29
|
+
style,
|
|
30
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
31
|
+
className: cx("slurp-fold", styled.className, className),
|
|
32
|
+
"data-state": open ? "open" : "closed",
|
|
33
|
+
...root,
|
|
34
|
+
children: [part("heading", `h${headingLevel}`, {
|
|
35
|
+
className: "slurp-fold-heading",
|
|
36
|
+
children: part("trigger", "button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
id: `${id}-trigger`,
|
|
39
|
+
className: "slurp-fold-trigger",
|
|
40
|
+
"aria-expanded": open,
|
|
41
|
+
"aria-controls": `${id}-region`,
|
|
42
|
+
onClick: () => setOpen(!open),
|
|
43
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "slurp-fold-summary",
|
|
45
|
+
children: summary
|
|
46
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, { className: "slurp-fold-chevron" })] })
|
|
47
|
+
})
|
|
48
|
+
}), part("region", "div", {
|
|
49
|
+
id: `${id}-region`,
|
|
50
|
+
role: "region",
|
|
51
|
+
"aria-labelledby": `${id}-trigger`,
|
|
52
|
+
className: "slurp-fold-region",
|
|
53
|
+
inert: !open,
|
|
54
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
55
|
+
className: "slurp-fold-content",
|
|
56
|
+
children
|
|
57
|
+
})
|
|
58
|
+
})]
|
|
59
|
+
})
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
export { Fold };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Fold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fold.js","names":[],"sources":["../../src/Fold/Fold.tsx"],"sourcesContent":["import { ChevronDownIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useId, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface FoldOwnProps extends PartsProps<'heading' | 'trigger' | 'region'> {\n /** The always-visible row (the button's text). */\n summary: ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Level of the heading that wraps the button. Default 3. */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n children?: ReactNode;\n}\n\nexport type FoldProps<E extends ElementType = 'div'> = PolymorphicProps<E, FoldOwnProps>;\n\n/** Disclosure (accordion item): opens by growing in height; closed content is out of the tab order. */\nexport function Fold<E extends ElementType = 'div'>(props: FoldProps<E>) {\n const {\n as,\n css,\n className,\n summary,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n headingLevel = 3,\n children,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Fold', props as FoldProps);\n const [open, setOpen] = useControlled({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Fold', 'root', css);\n const { part, style } = useParts('Fold', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-fold', styled.className, className)}\n data-state={open ? 'open' : 'closed'}\n {...root}\n >\n {part('heading', `h${headingLevel}`, {\n className: 'slurp-fold-heading',\n children: part('trigger', 'button', {\n type: 'button',\n id: `${id}-trigger`,\n className: 'slurp-fold-trigger',\n 'aria-expanded': open,\n 'aria-controls': `${id}-region`,\n onClick: () => setOpen(!open),\n children: (\n <>\n <span className=\"slurp-fold-summary\">{summary}</span>\n <ChevronDownIcon className=\"slurp-fold-chevron\" />\n </>\n ),\n }),\n })}\n {part('region', 'div', {\n id: `${id}-region`,\n role: 'region',\n 'aria-labelledby': `${id}-trigger`,\n className: 'slurp-fold-region',\n inert: !open,\n children: <div className=\"slurp-fold-content\">{children}</div>,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EACJ,IACA,KACA,WACA,SACA,MAAM,UACN,cAAc,OACd,cACA,eAAe,GACf,UACA,OACA,WACA,YACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,CAAC,MAAM,WAAW,cAAc;EACpC,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,KAAK,MAAM;CACjB,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,EAAE,MAAM,UAAU,SAAS,QAAQ;EAAE;EAAO;EAAW;CAAW,CAAC;CACzE,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACvD,cAAY,OAAO,SAAS;GAC5B,GAAI;GAHN,UAAA,CAKG,KAAK,WAAW,IAAI,gBAAgB;IACnC,WAAW;IACX,UAAU,KAAK,WAAW,UAAU;KAClC,MAAM;KACN,IAAI,GAAG,GAAG;KACV,WAAW;KACX,iBAAiB;KACjB,iBAAiB,GAAG,GAAG;KACvB,eAAe,QAAQ,CAAC,IAAI;KAC5B,UACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,QAAD;MAAM,WAAU;MAAsB,UAAA;KAAc,CAAA,GACpD,oBAAC,iBAAD,EAAiB,WAAU,qBAAsB,CAAA,CACjD,EAAA,CAAA;IAEN,CAAC;GACH,CAAC,GACA,KAAK,UAAU,OAAO;IACrB,IAAI,GAAG,GAAG;IACV,MAAM;IACN,mBAAmB,GAAG,GAAG;IACzB,WAAW;IACX,OAAO,CAAC;IACR,UAAU,oBAAC,OAAD;KAAK,WAAU;KAAsB;IAAc,CAAA;GAC/D,CAAC,CACG;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export type FrameProps<E extends ElementType = 'div'> = PolymorphicProps<E>;
|
|
5
|
+
/** Centred page column: max 1280px, gutter 24px (16px on phones). `--slurp-frame-max`, `--slurp-frame-gutter`. */
|
|
6
|
+
export declare function Frame<E extends ElementType = 'div'>(props: FrameProps<E>): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=Frame.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
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/Frame/Frame.tsx
|
|
7
|
+
/** Centred page column: max 1280px, gutter 24px (16px on phones). `--slurp-frame-max`, `--slurp-frame-gutter`. */
|
|
8
|
+
function Frame(props) {
|
|
9
|
+
const { as, css, className, ...rest } = useThemeProps("Frame", props);
|
|
10
|
+
const Root = as ?? "div";
|
|
11
|
+
const styled = useCss("Frame", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
14
|
+
className: cx("slurp-frame", styled.className, className),
|
|
15
|
+
...root
|
|
16
|
+
})] });
|
|
17
|
+
}
|
|
18
|
+
export { Frame };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=Frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frame.js","names":[],"sources":["../../src/Frame/Frame.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 type FrameProps<E extends ElementType = 'div'> = PolymorphicProps<E>;\n\n/** Centred page column: max 1280px, gutter 24px (16px on phones). `--slurp-frame-max`, `--slurp-frame-gutter`. */\nexport function Frame<E extends ElementType = 'div'>(props: FrameProps<E>) {\n const { as, css, className, ...rest } = useThemeProps('Frame', props as FrameProps);\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Frame', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-frame', styled.className, className)} {...root} />\n </>\n );\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EAAE,IAAI,KAAK,WAAW,GAAG,SAAS,cAAc,SAAS,KAAmB;CAClF,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;EAAG,GAAI;CAAO,CAAA,CAC5E,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Page baseline (opt-in, like a CSS reset): border-box, no body margin, Poppins body text, the `bg` ground tinted 7%
|
|
4
|
+
* by the accent, visible 2px focus ring. Renders a single hoisted <style>, no element.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Ground(): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=Ground.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styleId } from "../lib/theme.js";
|
|
3
|
+
import { GROUND_CSS } from "../lib/ground.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/Ground/Ground.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Page baseline (opt-in, like a CSS reset): border-box, no body margin, Poppins body text, the `bg` ground tinted 7%
|
|
8
|
+
* by the accent, visible 2px focus ring. Renders a single hoisted <style>, no element.
|
|
9
|
+
*/
|
|
10
|
+
function Ground() {
|
|
11
|
+
return /* @__PURE__ */ jsx("style", {
|
|
12
|
+
href: styleId("ground", GROUND_CSS),
|
|
13
|
+
precedence: "slurp",
|
|
14
|
+
children: GROUND_CSS
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { Ground };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=Ground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ground.js","names":[],"sources":["../../src/Ground/Ground.tsx"],"sourcesContent":["import { GROUND_CSS } from '../lib/ground';\nimport { styleId } from '../lib/theme';\n\n/**\n * Page baseline (opt-in, like a CSS reset): border-box, no body margin, Poppins body text, the `bg` ground tinted 7%\n * by the accent, visible 2px focus ring. Renders a single hoisted <style>, no element.\n */\nexport function Ground() {\n return (\n <style href={styleId('ground', GROUND_CSS)} precedence=\"slurp\">\n {GROUND_CSS}\n </style>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,SAAS;CACvB,OACE,oBAAC,SAAD;EAAO,MAAM,QAAQ,UAAU,UAAU;EAAG,YAAW;EACpD,UAAA;CACI,CAAA;AAEX"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
import { SlurpCss } from "../lib/css.js";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
|
+
export interface HintProps {
|
|
5
|
+
/** The text: short, never essential (the trigger must make sense without it). */
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
/** One element that takes focus (a button, a link). */
|
|
8
|
+
children: ReactElement;
|
|
9
|
+
/** Preferred side; it flips when there is no room. Default `top`. */
|
|
10
|
+
placement?: 'top' | 'bottom';
|
|
11
|
+
/** Hover delay in ms before it shows (focus shows it at once). Default 400. */
|
|
12
|
+
delay?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
css?: SlurpCss;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is
|
|
18
|
+
* over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).
|
|
19
|
+
*/
|
|
20
|
+
export declare function Hint(props: HintProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=Hint.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Children, cloneElement, isValidElement, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Hint/Hint.tsx
|
|
8
|
+
const GAP = 8;
|
|
9
|
+
const EDGE = 8;
|
|
10
|
+
/**
|
|
11
|
+
* Tooltip: shows on hover (after `delay`) and on focus, hides on Escape, blur or leave; it stays while the pointer is
|
|
12
|
+
* over it (WCAG 1.4.13). Linked to the trigger with aria-describedby. Rendered in the top layer (popover).
|
|
13
|
+
*/
|
|
14
|
+
function Hint(props) {
|
|
15
|
+
const { content, children, placement = "top", delay = 400, className, css } = useThemeProps("Hint", props);
|
|
16
|
+
const id = useId();
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const [side, setSide] = useState(placement);
|
|
19
|
+
const trigger = useRef(null);
|
|
20
|
+
const tip = useRef(null);
|
|
21
|
+
const timer = useRef(void 0);
|
|
22
|
+
const styled = useCss("Hint", "root", css);
|
|
23
|
+
const child = Children.only(children);
|
|
24
|
+
const childProps = isValidElement(child) ? child.props : {};
|
|
25
|
+
const ref = useForkRef(childProps.ref, trigger);
|
|
26
|
+
const later = (fn, ms) => {
|
|
27
|
+
clearTimeout(timer.current);
|
|
28
|
+
timer.current = setTimeout(fn, ms);
|
|
29
|
+
};
|
|
30
|
+
const show = (now) => later(() => setOpen(true), now ? 0 : delay);
|
|
31
|
+
const hide = () => later(() => setOpen(false), 100);
|
|
32
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
const el = tip.current;
|
|
35
|
+
const anchor = trigger.current;
|
|
36
|
+
if (!open || !el || !anchor) return;
|
|
37
|
+
el.showPopover?.();
|
|
38
|
+
const place = () => {
|
|
39
|
+
const a = anchor.getBoundingClientRect();
|
|
40
|
+
const t = el.getBoundingClientRect();
|
|
41
|
+
const above = a.top - GAP - t.height;
|
|
42
|
+
const below = a.bottom + GAP;
|
|
43
|
+
const fitsAbove = above >= EDGE;
|
|
44
|
+
const fitsBelow = below + t.height <= innerHeight - EDGE;
|
|
45
|
+
const top = placement === "top" ? fitsAbove || !fitsBelow ? "top" : "bottom" : fitsBelow || !fitsAbove ? "bottom" : "top";
|
|
46
|
+
const left = Math.min(Math.max(EDGE, a.left + a.width / 2 - t.width / 2), innerWidth - EDGE - t.width);
|
|
47
|
+
el.style.left = `${left}px`;
|
|
48
|
+
el.style.top = `${top === "top" ? above : below}px`;
|
|
49
|
+
setSide(top);
|
|
50
|
+
};
|
|
51
|
+
place();
|
|
52
|
+
const onKey = (e) => {
|
|
53
|
+
if (e.key === "Escape") setOpen(false);
|
|
54
|
+
};
|
|
55
|
+
document.addEventListener("keydown", onKey);
|
|
56
|
+
addEventListener("scroll", place, true);
|
|
57
|
+
addEventListener("resize", place);
|
|
58
|
+
return () => {
|
|
59
|
+
document.removeEventListener("keydown", onKey);
|
|
60
|
+
removeEventListener("scroll", place, true);
|
|
61
|
+
removeEventListener("resize", place);
|
|
62
|
+
el.hidePopover?.();
|
|
63
|
+
};
|
|
64
|
+
}, [open, placement]);
|
|
65
|
+
const triggerElement = isValidElement(child) ? cloneElement(child, {
|
|
66
|
+
ref,
|
|
67
|
+
"aria-describedby": cx(childProps["aria-describedby"], id),
|
|
68
|
+
onPointerEnter: (e) => {
|
|
69
|
+
childProps.onPointerEnter?.(e);
|
|
70
|
+
if (e.pointerType !== "touch") show(false);
|
|
71
|
+
},
|
|
72
|
+
onPointerLeave: (e) => {
|
|
73
|
+
childProps.onPointerLeave?.(e);
|
|
74
|
+
hide();
|
|
75
|
+
},
|
|
76
|
+
onFocus: (e) => {
|
|
77
|
+
childProps.onFocus?.(e);
|
|
78
|
+
show(true);
|
|
79
|
+
},
|
|
80
|
+
onBlur: (e) => {
|
|
81
|
+
childProps.onBlur?.(e);
|
|
82
|
+
later(() => setOpen(false), 0);
|
|
83
|
+
}
|
|
84
|
+
}) : child;
|
|
85
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
86
|
+
styled.style,
|
|
87
|
+
triggerElement,
|
|
88
|
+
/* @__PURE__ */ jsx("span", {
|
|
89
|
+
ref: tip,
|
|
90
|
+
id,
|
|
91
|
+
role: "tooltip",
|
|
92
|
+
popover: "manual",
|
|
93
|
+
className: cx("slurp-hint", styled.className, className),
|
|
94
|
+
"data-open": open || void 0,
|
|
95
|
+
"data-side": side,
|
|
96
|
+
onPointerEnter: () => clearTimeout(timer.current),
|
|
97
|
+
onPointerLeave: hide,
|
|
98
|
+
children: content
|
|
99
|
+
})
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
102
|
+
export { Hint };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=Hint.js.map
|