@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
package/dist/lib/css.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
|
|
2
|
+
import { COMPACT_QUERY, color, font, hue, radius, shadow, space } from "@slurp-ui/tokens";
|
|
3
|
+
// src/lib/css.ts
|
|
4
|
+
const LAYER_ORDER = "@layer slurp.reset, slurp.base, slurp.components, slurp.utilities;";
|
|
5
|
+
const SPACE_ALIASES = {
|
|
6
|
+
p: ["padding"],
|
|
7
|
+
px: ["padding-inline"],
|
|
8
|
+
py: ["padding-block"],
|
|
9
|
+
pt: ["padding-top"],
|
|
10
|
+
pr: ["padding-right"],
|
|
11
|
+
pb: ["padding-bottom"],
|
|
12
|
+
pl: ["padding-left"],
|
|
13
|
+
m: ["margin"],
|
|
14
|
+
mx: ["margin-inline"],
|
|
15
|
+
my: ["margin-block"],
|
|
16
|
+
mt: ["margin-top"],
|
|
17
|
+
mr: ["margin-right"],
|
|
18
|
+
mb: ["margin-bottom"],
|
|
19
|
+
ml: ["margin-left"]
|
|
20
|
+
};
|
|
21
|
+
const SPACE_PROPS = /* @__PURE__ */ new Set([
|
|
22
|
+
"gap",
|
|
23
|
+
"row-gap",
|
|
24
|
+
"column-gap",
|
|
25
|
+
...Object.values(SPACE_ALIASES).flat()
|
|
26
|
+
]);
|
|
27
|
+
const SPACE_PROPS_PREFIXES = [
|
|
28
|
+
"padding",
|
|
29
|
+
"margin",
|
|
30
|
+
"inset",
|
|
31
|
+
"top",
|
|
32
|
+
"right",
|
|
33
|
+
"bottom",
|
|
34
|
+
"left"
|
|
35
|
+
];
|
|
36
|
+
const COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
37
|
+
"color",
|
|
38
|
+
"background",
|
|
39
|
+
"background-color",
|
|
40
|
+
"border-color",
|
|
41
|
+
"outline-color",
|
|
42
|
+
"fill",
|
|
43
|
+
"stroke"
|
|
44
|
+
]);
|
|
45
|
+
const UNITLESS = /* @__PURE__ */ new Set([
|
|
46
|
+
"opacity",
|
|
47
|
+
"z-index",
|
|
48
|
+
"flex",
|
|
49
|
+
"flex-grow",
|
|
50
|
+
"flex-shrink",
|
|
51
|
+
"font-weight",
|
|
52
|
+
"line-height",
|
|
53
|
+
"order",
|
|
54
|
+
"aspect-ratio",
|
|
55
|
+
"scale",
|
|
56
|
+
"grid-column",
|
|
57
|
+
"grid-row"
|
|
58
|
+
]);
|
|
59
|
+
const MEDIA = {
|
|
60
|
+
compact: COMPACT_QUERY,
|
|
61
|
+
wide: `not all and ${COMPACT_QUERY}`
|
|
62
|
+
};
|
|
63
|
+
const kebab = (key) => key.startsWith("--") ? key : key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
64
|
+
const isSpaceProp = (prop) => SPACE_PROPS.has(prop) || SPACE_PROPS_PREFIXES.some((p) => prop === p || prop.startsWith(`${p}-`));
|
|
65
|
+
/** One CSS value for `prop`, with design tokens resolved to custom properties. */
|
|
66
|
+
function value(prop, raw) {
|
|
67
|
+
if (isSpaceProp(prop) && String(raw) in space) return `var(--slurp-space-${raw})`;
|
|
68
|
+
if (COLOR_PROPS.has(prop) && typeof raw === "string") {
|
|
69
|
+
if (raw in color) return `var(--slurp-${raw})`;
|
|
70
|
+
if (raw.startsWith("hue-") && raw.slice(4) in hue) return `var(--slurp-${raw})`;
|
|
71
|
+
}
|
|
72
|
+
if (prop === "border-radius" && typeof raw === "string" && raw in radius) return `var(--slurp-radius-${raw})`;
|
|
73
|
+
if (prop === "box-shadow" && typeof raw === "string" && raw in shadow) return `var(--slurp-shadow-${raw})`;
|
|
74
|
+
if (typeof raw === "number" && raw !== 0 && !UNITLESS.has(prop) && !prop.startsWith("--")) return `${raw}px`;
|
|
75
|
+
return String(raw);
|
|
76
|
+
}
|
|
77
|
+
/** Expands aliases (`p`, `bg`, `radius`, `font`, …) into real declarations. */
|
|
78
|
+
function declarations(key, raw) {
|
|
79
|
+
if (key === "font") return String(raw) in font ? [["font", `var(--slurp-font-${raw})`], ["letter-spacing", `var(--slurp-font-${raw}-tracking)`]] : [["font", String(raw)]];
|
|
80
|
+
return (SPACE_ALIASES[key] ?? (key === "bg" ? ["background"] : key === "radius" ? ["border-radius"] : key === "shadow" ? ["box-shadow"] : [kebab(key)])).map((prop) => [prop, value(prop, raw)]);
|
|
81
|
+
}
|
|
82
|
+
/** FNV-1a, base 36: short, stable class names. */
|
|
83
|
+
function hash(input) {
|
|
84
|
+
let h = 2166136261;
|
|
85
|
+
for (let i = 0; i < input.length; i++) {
|
|
86
|
+
h ^= input.charCodeAt(i);
|
|
87
|
+
h = Math.imul(h, 16777619);
|
|
88
|
+
}
|
|
89
|
+
return (h >>> 0).toString(36);
|
|
90
|
+
}
|
|
91
|
+
const isResponsive = (v) => typeof v === "object" && v !== null && Object.keys(v).every((k) => k === "base" || k === "compact" || k === "wide");
|
|
92
|
+
/**
|
|
93
|
+
* Compiles a `css` object. Each declaration becomes one class: `.slurp-x<hash>`.
|
|
94
|
+
* Breakpoint rules double the class (higher specificity than the base rule, whatever the order).
|
|
95
|
+
*/
|
|
96
|
+
function compileCss(style) {
|
|
97
|
+
if (!style) return {
|
|
98
|
+
className: "",
|
|
99
|
+
css: ""
|
|
100
|
+
};
|
|
101
|
+
const classes = /* @__PURE__ */ new Set();
|
|
102
|
+
const rules = [];
|
|
103
|
+
const walk = (obj, selector) => {
|
|
104
|
+
for (const [key, raw] of Object.entries(obj)) {
|
|
105
|
+
if (raw === void 0 || raw === null || raw === false) continue;
|
|
106
|
+
if (key.startsWith("&")) {
|
|
107
|
+
walk(raw, selector + key.slice(1));
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const variants = isResponsive(raw) ? Object.entries(raw) : [["base", raw]];
|
|
111
|
+
for (const [bp, v] of variants) {
|
|
112
|
+
if (v === void 0) continue;
|
|
113
|
+
for (const [prop, val] of declarations(key, v)) {
|
|
114
|
+
const name = `slurp-x${hash(`${bp}|${selector}|${prop}|${val}`)}`;
|
|
115
|
+
if (classes.has(name)) continue;
|
|
116
|
+
classes.add(name);
|
|
117
|
+
const rule = `${(bp === "base" ? `.${name}` : `.${name}.${name}`) + selector.replaceAll("&", `.${name}`)}{${prop}:${val}}`;
|
|
118
|
+
rules.push(bp === "base" ? rule : `@media ${MEDIA[bp]}{${rule}}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
walk(style, "");
|
|
124
|
+
return {
|
|
125
|
+
className: [...classes].join(" "),
|
|
126
|
+
css: rules.length ? `${LAYER_ORDER}@layer slurp.utilities{${rules.join("")}}` : ""
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** Deep merge of `css` objects, later ones win (theme defaults first, instance last). */
|
|
130
|
+
function mergeCss(...styles) {
|
|
131
|
+
const present = styles.filter((s) => !!s);
|
|
132
|
+
if (present.length <= 1) return present[0];
|
|
133
|
+
const out = {};
|
|
134
|
+
for (const style of present) for (const [key, v] of Object.entries(style)) {
|
|
135
|
+
const prev = out[key];
|
|
136
|
+
out[key] = key.startsWith("&") && prev && v ? mergeCss(prev, v) : v;
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
export { LAYER_ORDER, compileCss, hash, mergeCss };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","names":[],"sources":["../../src/lib/css.ts"],"sourcesContent":["// The `css` prop: a style object with design tokens, pseudo/nested selectors and breakpoints, compiled to hashed atomic\n// classes in `@layer slurp.utilities`. Pure and server-safe: components render the result through a React 19 <style>.\nimport {\n color,\n COMPACT_QUERY,\n font,\n hue,\n radius,\n shadow,\n space,\n type ColorToken,\n type FontToken,\n type HueToken,\n type RadiusToken,\n type SpaceToken,\n} from '@slurp-ui/tokens';\nimport type { CSSProperties } from 'react';\n\nexport const LAYER_ORDER = '@layer slurp.reset, slurp.base, slurp.components, slurp.utilities;';\n\n/** Breakpoint keys: `compact` is the design system's phone layout (COMPACT_QUERY), `wide` everything above it. */\nexport interface Responsive<T> {\n base?: T;\n compact?: T;\n wide?: T;\n}\nexport type MaybeResponsive<T> = T | Responsive<T>;\n\ntype SpaceStep = SpaceToken extends `${infer N extends number}` ? N : never;\n/** A step of the space scale (`4` → `var(--slurp-space-4)`), or any CSS length. */\nexport type SpaceValue = SpaceStep | (string & {}) | (number & {});\n/** A colour token (`'accent-soft'`, `'hue-teal'`), or any CSS colour. */\nexport type ColorValue = ColorToken | `hue-${HueToken}` | (string & {});\nexport type RadiusValue = RadiusToken | (string & {}) | (number & {});\n\ninterface TokenProps {\n p?: MaybeResponsive<SpaceValue>;\n px?: MaybeResponsive<SpaceValue>;\n py?: MaybeResponsive<SpaceValue>;\n pt?: MaybeResponsive<SpaceValue>;\n pr?: MaybeResponsive<SpaceValue>;\n pb?: MaybeResponsive<SpaceValue>;\n pl?: MaybeResponsive<SpaceValue>;\n m?: MaybeResponsive<SpaceValue>;\n mx?: MaybeResponsive<SpaceValue>;\n my?: MaybeResponsive<SpaceValue>;\n mt?: MaybeResponsive<SpaceValue>;\n mr?: MaybeResponsive<SpaceValue>;\n mb?: MaybeResponsive<SpaceValue>;\n ml?: MaybeResponsive<SpaceValue>;\n gap?: MaybeResponsive<SpaceValue>;\n rowGap?: MaybeResponsive<SpaceValue>;\n columnGap?: MaybeResponsive<SpaceValue>;\n bg?: MaybeResponsive<ColorValue>;\n color?: MaybeResponsive<ColorValue>;\n borderColor?: MaybeResponsive<ColorValue>;\n outlineColor?: MaybeResponsive<ColorValue>;\n fill?: MaybeResponsive<ColorValue>;\n stroke?: MaybeResponsive<ColorValue>;\n radius?: MaybeResponsive<RadiusValue>;\n /** A type style: sets `font` and `letter-spacing`. */\n font?: MaybeResponsive<FontToken>;\n shadow?: MaybeResponsive<keyof typeof shadow | (string & {})>;\n}\n\ntype PlainProps = {\n [K in Exclude<keyof CSSProperties, keyof TokenProps>]?: MaybeResponsive<CSSProperties[K]>;\n};\n\n/** Style object of the `css` prop. Keys starting with `&` are nested selectors (`'&:hover'`, `'& .slurp-card-media'`). */\nexport type SlurpCss = TokenProps &\n PlainProps & {\n [selector: `&${string}`]: SlurpCss | undefined;\n [customProperty: `--${string}`]: MaybeResponsive<string | number> | undefined;\n };\n\nconst SPACE_ALIASES: Record<string, string[]> = {\n p: ['padding'],\n px: ['padding-inline'],\n py: ['padding-block'],\n pt: ['padding-top'],\n pr: ['padding-right'],\n pb: ['padding-bottom'],\n pl: ['padding-left'],\n m: ['margin'],\n mx: ['margin-inline'],\n my: ['margin-block'],\n mt: ['margin-top'],\n mr: ['margin-right'],\n mb: ['margin-bottom'],\n ml: ['margin-left'],\n};\nconst SPACE_PROPS = new Set([\n 'gap',\n 'row-gap',\n 'column-gap',\n ...Object.values(SPACE_ALIASES).flat(),\n]);\nconst SPACE_PROPS_PREFIXES = ['padding', 'margin', 'inset', 'top', 'right', 'bottom', 'left'];\nconst COLOR_PROPS = new Set([\n 'color',\n 'background',\n 'background-color',\n 'border-color',\n 'outline-color',\n 'fill',\n 'stroke',\n]);\nconst UNITLESS = new Set([\n 'opacity',\n 'z-index',\n 'flex',\n 'flex-grow',\n 'flex-shrink',\n 'font-weight',\n 'line-height',\n 'order',\n 'aspect-ratio',\n 'scale',\n 'grid-column',\n 'grid-row',\n]);\n\nconst MEDIA = {\n compact: COMPACT_QUERY,\n wide: `not all and ${COMPACT_QUERY}`,\n} as const;\n\nconst kebab = (key: string) =>\n key.startsWith('--') ? key : key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n\nconst isSpaceProp = (prop: string) =>\n SPACE_PROPS.has(prop) || SPACE_PROPS_PREFIXES.some((p) => prop === p || prop.startsWith(`${p}-`));\n\n/** One CSS value for `prop`, with design tokens resolved to custom properties. */\nfunction value(prop: string, raw: string | number): string {\n if (isSpaceProp(prop) && String(raw) in space) return `var(--slurp-space-${raw})`;\n if (COLOR_PROPS.has(prop) && typeof raw === 'string') {\n if (raw in color) return `var(--slurp-${raw})`;\n if (raw.startsWith('hue-') && raw.slice(4) in hue) return `var(--slurp-${raw})`;\n }\n if (prop === 'border-radius' && typeof raw === 'string' && raw in radius)\n return `var(--slurp-radius-${raw})`;\n if (prop === 'box-shadow' && typeof raw === 'string' && raw in shadow)\n return `var(--slurp-shadow-${raw})`;\n if (typeof raw === 'number' && raw !== 0 && !UNITLESS.has(prop) && !prop.startsWith('--'))\n return `${raw}px`;\n return String(raw);\n}\n\n/** Expands aliases (`p`, `bg`, `radius`, `font`, …) into real declarations. */\nfunction declarations(key: string, raw: string | number): [string, string][] {\n if (key === 'font') {\n return String(raw) in font\n ? [\n ['font', `var(--slurp-font-${raw})`],\n ['letter-spacing', `var(--slurp-font-${raw}-tracking)`],\n ]\n : [['font', String(raw)]];\n }\n const props =\n SPACE_ALIASES[key] ??\n (key === 'bg'\n ? ['background']\n : key === 'radius'\n ? ['border-radius']\n : key === 'shadow'\n ? ['box-shadow']\n : [kebab(key)]);\n return props.map((prop) => [prop, value(prop, raw)]);\n}\n\n/** FNV-1a, base 36: short, stable class names. */\nexport function hash(input: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return (h >>> 0).toString(36);\n}\n\nconst isResponsive = (v: unknown): v is Responsive<string | number> =>\n typeof v === 'object' &&\n v !== null &&\n Object.keys(v).every((k) => k === 'base' || k === 'compact' || k === 'wide');\n\nexport interface CompiledCss {\n /** Space-separated atomic class names. */\n className: string;\n /** The rules, inside `@layer slurp.utilities` (empty when there is nothing to emit). */\n css: string;\n}\n\n/**\n * Compiles a `css` object. Each declaration becomes one class: `.slurp-x<hash>`.\n * Breakpoint rules double the class (higher specificity than the base rule, whatever the order).\n */\nexport function compileCss(style: SlurpCss | undefined): CompiledCss {\n if (!style) return { className: '', css: '' };\n const classes = new Set<string>();\n const rules: string[] = [];\n\n const walk = (obj: SlurpCss, selector: string) => {\n for (const [key, raw] of Object.entries(obj)) {\n if (raw === undefined || raw === null || raw === false) continue;\n if (key.startsWith('&')) {\n walk(raw as SlurpCss, selector + key.slice(1));\n continue;\n }\n const variants = isResponsive(raw)\n ? (Object.entries(raw) as ['base' | 'compact' | 'wide', string | number | undefined][])\n : [['base', raw as string | number] as const];\n for (const [bp, v] of variants) {\n if (v === undefined) continue;\n for (const [prop, val] of declarations(key, v)) {\n const name = `slurp-x${hash(`${bp}|${selector}|${prop}|${val}`)}`;\n if (classes.has(name)) continue;\n classes.add(name);\n const target =\n (bp === 'base' ? `.${name}` : `.${name}.${name}`) +\n selector.replaceAll('&', `.${name}`);\n const rule = `${target}{${prop}:${val}}`;\n rules.push(bp === 'base' ? rule : `@media ${MEDIA[bp]}{${rule}}`);\n }\n }\n }\n };\n walk(style, '');\n\n return {\n className: [...classes].join(' '),\n css: rules.length ? `${LAYER_ORDER}@layer slurp.utilities{${rules.join('')}}` : '',\n };\n}\n\n/** Deep merge of `css` objects, later ones win (theme defaults first, instance last). */\nexport function mergeCss(...styles: (SlurpCss | undefined)[]): SlurpCss | undefined {\n const present = styles.filter((s): s is SlurpCss => !!s);\n if (present.length <= 1) return present[0];\n const out: Record<string, unknown> = {};\n for (const style of present) {\n for (const [key, v] of Object.entries(style)) {\n const prev = out[key];\n out[key] = key.startsWith('&') && prev && v ? mergeCss(prev as SlurpCss, v as SlurpCss) : v;\n }\n }\n return out as SlurpCss;\n}\n"],"mappings":";;;AAkBA,MAAa,cAAc;AA0D3B,MAAM,gBAA0C;CAC9C,GAAG,CAAC,SAAS;CACb,IAAI,CAAC,gBAAgB;CACrB,IAAI,CAAC,eAAe;CACpB,IAAI,CAAC,aAAa;CAClB,IAAI,CAAC,eAAe;CACpB,IAAI,CAAC,gBAAgB;CACrB,IAAI,CAAC,cAAc;CACnB,GAAG,CAAC,QAAQ;CACZ,IAAI,CAAC,eAAe;CACpB,IAAI,CAAC,cAAc;CACnB,IAAI,CAAC,YAAY;CACjB,IAAI,CAAC,cAAc;CACnB,IAAI,CAAC,eAAe;CACpB,IAAI,CAAC,aAAa;AACpB;AACA,MAAM,8BAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA,GAAG,OAAO,OAAO,aAAa,CAAC,CAAC,KAAK;AACvC,CAAC;AACD,MAAM,uBAAuB;CAAC;CAAW;CAAU;CAAS;CAAO;CAAS;CAAU;AAAM;AAC5F,MAAM,8BAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,QAAQ;CACZ,SAAS;CACT,MAAM,eAAe;AACvB;AAEA,MAAM,SAAS,QACb,IAAI,WAAW,IAAI,IAAI,MAAM,IAAI,QAAQ,WAAW,MAAM,IAAI,EAAE,YAAY,GAAG;AAEjF,MAAM,eAAe,SACnB,YAAY,IAAI,IAAI,KAAK,qBAAqB,MAAM,MAAM,SAAS,KAAK,KAAK,WAAW,GAAG,EAAE,EAAE,CAAC;;AAGlG,SAAS,MAAM,MAAc,KAA8B;CACzD,IAAI,YAAY,IAAI,KAAK,OAAO,GAAG,KAAK,OAAO,OAAO,qBA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F;AACF;;AAGA,SAAgB,SAAS,GAAG,QAAwD;CAClF,MAAM,UAAU,OAAO,QAAQ,MAAqB,CAAC,CAAC,CAAC;CACvD,IAAI,QAAQ,UAAU,GAAG,OAAO,QAAQ;CACxC,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,SAClB,KAAK,MAAM,CAAC,KAAK,MAAM,OAAO,QAAQ,KAAK,GAAG;EAC5C,MAAM,OAAO,IAAI;EACjB,IAAI,OAAO,IAAI,WAAW,GAAG,KAAK,QAAQ,IAAI,SAAS,MAAkB,CAAa,IAAI;CAC5F;CAEF,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import { LAYER_ORDER } from "./css.js";
|
|
3
|
+
// src/lib/ground.ts
|
|
4
|
+
/** Global baseline of <Ground />, in `@layer slurp.reset` (lowest priority: everything else overrides it). */
|
|
5
|
+
const GROUND_CSS = `${LAYER_ORDER}@layer slurp.reset{\
|
|
6
|
+
*,*::before,*::after{box-sizing:border-box}\
|
|
7
|
+
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}\
|
|
8
|
+
body{margin:0;min-height:100vh;background:color-mix(in oklab,var(--slurp-accent) 7%,var(--slurp-bg));color:var(--slurp-fg);font:var(--slurp-font-body);letter-spacing:var(--slurp-font-body-tracking);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}\
|
|
9
|
+
img,video{max-width:100%;height:auto}\
|
|
10
|
+
button,input,select,textarea{font:inherit;color:inherit}\
|
|
11
|
+
:focus-visible{outline:2px solid var(--slurp-focus);outline-offset:2px}\
|
|
12
|
+
}`;
|
|
13
|
+
export { GROUND_CSS };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=ground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ground.js","names":[],"sources":["../../src/lib/ground.ts"],"sourcesContent":["import { LAYER_ORDER } from './css';\n\n/** Global baseline of <Ground />, in `@layer slurp.reset` (lowest priority: everything else overrides it). */\nexport const GROUND_CSS = `${LAYER_ORDER}@layer slurp.reset{\\\n*,*::before,*::after{box-sizing:border-box}\\\nhtml{-webkit-text-size-adjust:100%;text-size-adjust:100%}\\\nbody{margin:0;min-height:100vh;background:color-mix(in oklab,var(--slurp-accent) 7%,var(--slurp-bg));color:var(--slurp-fg);font:var(--slurp-font-body);letter-spacing:var(--slurp-font-body-tracking);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}\\\nimg,video{max-width:100%;height:auto}\\\nbutton,input,select,textarea{font:inherit;color:inherit}\\\n:focus-visible{outline:2px solid var(--slurp-focus);outline-offset:2px}\\\n}`;\n"],"mappings":";;;;AAGA,MAAa,aAAa,GAAG,YAAY"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
export interface BentoItem {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Any size measure (how many entries a section has). Default 1. */
|
|
5
|
+
weight?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BentoSpan {
|
|
8
|
+
id: string;
|
|
9
|
+
colSpan: number;
|
|
10
|
+
rowSpan: number;
|
|
11
|
+
size: 'large' | 'small';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Spans of the entry grid (12 columns), items in priority order. score = weight × (1 + 0.35 × (n − 1 − rank)).
|
|
15
|
+
* #1 tall on the left (4–6 columns, 2 rows) · #2 beside it · #3–#4 below #2 · the rest in rows of up to 3.
|
|
16
|
+
*/
|
|
17
|
+
export declare function bentoLayout(items: BentoItem[], columns?: number): BentoSpan[];
|
|
18
|
+
/** Case- and accent-insensitive form ("Più" → "piu"). */
|
|
19
|
+
export declare function normalizeText(s: string): string;
|
|
20
|
+
/** List search: true when every word of the query appears in the text, in any order. */
|
|
21
|
+
export declare function matchesAll(text: string, query: string): boolean;
|
|
22
|
+
/** In-page search: [start, end) ranges of the original text where the phrase appears. */
|
|
23
|
+
export declare function matchRanges(text: string, query: string): [number, number][];
|
|
24
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
// src/lib/layout.ts
|
|
3
|
+
/** Splits `total` columns by weight, at least `min` each; leftovers go to the largest remainders. */
|
|
4
|
+
function split(total, weights, min) {
|
|
5
|
+
const n = weights.length;
|
|
6
|
+
if (!n) return [];
|
|
7
|
+
const free = total - min * n;
|
|
8
|
+
const sum = weights.reduce((a, b) => a + b, 0) || 1;
|
|
9
|
+
const raw = weights.map((w) => free * w / sum);
|
|
10
|
+
const out = raw.map((r) => min + Math.floor(r));
|
|
11
|
+
const left = total - out.reduce((a, b) => a + b, 0);
|
|
12
|
+
raw.map((r, i) => [r - Math.floor(r), i]).sort((a, b) => b[0] - a[0]).slice(0, left).forEach(([, i]) => out[i] = (out[i] ?? min) + 1);
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Spans of the entry grid (12 columns), items in priority order. score = weight × (1 + 0.35 × (n − 1 − rank)).
|
|
17
|
+
* #1 tall on the left (4–6 columns, 2 rows) · #2 beside it · #3–#4 below #2 · the rest in rows of up to 3.
|
|
18
|
+
*/
|
|
19
|
+
function bentoLayout(items, columns = 12) {
|
|
20
|
+
const n = items.length;
|
|
21
|
+
const w = items.map((it, i) => Math.max(1, it.weight ?? 1) * (1 + .35 * (n - 1 - i)));
|
|
22
|
+
const res = items.map((it) => ({
|
|
23
|
+
id: it.id,
|
|
24
|
+
colSpan: columns,
|
|
25
|
+
rowSpan: 1,
|
|
26
|
+
size: "small"
|
|
27
|
+
}));
|
|
28
|
+
const [a, b] = res;
|
|
29
|
+
if (!a) return res;
|
|
30
|
+
if (!b) {
|
|
31
|
+
a.rowSpan = 2;
|
|
32
|
+
a.size = "large";
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
const w0 = w[0] ?? 1;
|
|
36
|
+
const w1 = w[1] ?? 1;
|
|
37
|
+
const first = Math.min(columns - 6, Math.max(4, Math.round(columns * w0 / (w0 + w1))));
|
|
38
|
+
const right = columns - first;
|
|
39
|
+
Object.assign(a, {
|
|
40
|
+
colSpan: first,
|
|
41
|
+
rowSpan: 2,
|
|
42
|
+
size: "large"
|
|
43
|
+
});
|
|
44
|
+
Object.assign(b, {
|
|
45
|
+
colSpan: right,
|
|
46
|
+
size: "large"
|
|
47
|
+
});
|
|
48
|
+
if (n === 3 && res[2]) res[2].colSpan = right;
|
|
49
|
+
if (n >= 4) split(right, [w[2] ?? 1, w[3] ?? 1], 3).forEach((s, i) => {
|
|
50
|
+
const item = res[i + 2];
|
|
51
|
+
if (item) item.colSpan = s;
|
|
52
|
+
});
|
|
53
|
+
for (let start = 4; start < n; start += 3) split(columns, w.slice(start, start + 3), 3).forEach((s, i) => {
|
|
54
|
+
const item = res[start + i];
|
|
55
|
+
if (item) Object.assign(item, {
|
|
56
|
+
colSpan: s,
|
|
57
|
+
size: s >= 6 ? "large" : "small"
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
/** Case- and accent-insensitive form ("Più" → "piu"). */
|
|
63
|
+
function normalizeText(s) {
|
|
64
|
+
return String(s).normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
65
|
+
}
|
|
66
|
+
const terms = (q) => normalizeText(q).split(/\s+/).filter(Boolean);
|
|
67
|
+
/** List search: true when every word of the query appears in the text, in any order. */
|
|
68
|
+
function matchesAll(text, query) {
|
|
69
|
+
const t = normalizeText(text);
|
|
70
|
+
return terms(query).every((w) => t.includes(w));
|
|
71
|
+
}
|
|
72
|
+
/** In-page search: [start, end) ranges of the original text where the phrase appears. */
|
|
73
|
+
function matchRanges(text, query) {
|
|
74
|
+
const needle = terms(query).join(" ");
|
|
75
|
+
const out = [];
|
|
76
|
+
if (!needle) return out;
|
|
77
|
+
let flat = "";
|
|
78
|
+
const map = [];
|
|
79
|
+
for (let i = 0; i < text.length; i++) for (const ch of normalizeText(text[i] ?? "")) {
|
|
80
|
+
flat += ch;
|
|
81
|
+
map.push(i);
|
|
82
|
+
}
|
|
83
|
+
for (let at = flat.indexOf(needle); at !== -1; at = flat.indexOf(needle, at + needle.length)) out.push([map[at] ?? 0, (map[at + needle.length - 1] ?? 0) + 1]);
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
export { bentoLayout, matchRanges, matchesAll, normalizeText };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../src/lib/layout.ts"],"sourcesContent":["// Server-safe layout math of the design system (bentoLayout) and its search helpers (matchesAll, matchRanges).\n\nexport interface BentoItem {\n id: string;\n /** Any size measure (how many entries a section has). Default 1. */\n weight?: number;\n}\n\nexport interface BentoSpan {\n id: string;\n colSpan: number;\n rowSpan: number;\n size: 'large' | 'small';\n}\n\n/** Splits `total` columns by weight, at least `min` each; leftovers go to the largest remainders. */\nfunction split(total: number, weights: number[], min: number): number[] {\n const n = weights.length;\n if (!n) return [];\n const free = total - min * n;\n const sum = weights.reduce((a, b) => a + b, 0) || 1;\n const raw = weights.map((w) => (free * w) / sum);\n const out = raw.map((r) => min + Math.floor(r));\n const left = total - out.reduce((a, b) => a + b, 0);\n raw\n .map((r, i) => [r - Math.floor(r), i] as const)\n .sort((a, b) => b[0] - a[0])\n .slice(0, left)\n .forEach(([, i]) => (out[i] = (out[i] ?? min) + 1));\n return out;\n}\n\n/**\n * Spans of the entry grid (12 columns), items in priority order. score = weight × (1 + 0.35 × (n − 1 − rank)).\n * #1 tall on the left (4–6 columns, 2 rows) · #2 beside it · #3–#4 below #2 · the rest in rows of up to 3.\n */\nexport function bentoLayout(items: BentoItem[], columns = 12): BentoSpan[] {\n const n = items.length;\n const w = items.map((it, i) => Math.max(1, it.weight ?? 1) * (1 + 0.35 * (n - 1 - i)));\n const res: BentoSpan[] = items.map((it) => ({\n id: it.id,\n colSpan: columns,\n rowSpan: 1,\n size: 'small',\n }));\n const [a, b] = res;\n if (!a) return res;\n if (!b) {\n a.rowSpan = 2;\n a.size = 'large';\n return res;\n }\n const w0 = w[0] ?? 1;\n const w1 = w[1] ?? 1;\n const first = Math.min(columns - 6, Math.max(4, Math.round((columns * w0) / (w0 + w1))));\n const right = columns - first;\n Object.assign(a, { colSpan: first, rowSpan: 2, size: 'large' });\n Object.assign(b, { colSpan: right, size: 'large' });\n if (n === 3 && res[2]) res[2].colSpan = right;\n if (n >= 4) {\n split(right, [w[2] ?? 1, w[3] ?? 1], 3).forEach((s, i) => {\n const item = res[i + 2];\n if (item) item.colSpan = s;\n });\n }\n for (let start = 4; start < n; start += 3) {\n split(columns, w.slice(start, start + 3), 3).forEach((s, i) => {\n const item = res[start + i];\n if (item) Object.assign(item, { colSpan: s, size: s >= 6 ? 'large' : 'small' });\n });\n }\n return res;\n}\n\n/** Case- and accent-insensitive form (\"Più\" → \"piu\"). */\nexport function normalizeText(s: string): string {\n return String(s).normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();\n}\n\nconst terms = (q: string) => normalizeText(q).split(/\\s+/).filter(Boolean);\n\n/** List search: true when every word of the query appears in the text, in any order. */\nexport function matchesAll(text: string, query: string): boolean {\n const t = normalizeText(text);\n return terms(query).every((w) => t.includes(w));\n}\n\n/** In-page search: [start, end) ranges of the original text where the phrase appears. */\nexport function matchRanges(text: string, query: string): [number, number][] {\n const needle = terms(query).join(' ');\n const out: [number, number][] = [];\n if (!needle) return out;\n let flat = '';\n const map: number[] = [];\n for (let i = 0; i < text.length; i++) {\n for (const ch of normalizeText(text[i] ?? '')) {\n flat += ch;\n map.push(i);\n }\n }\n for (let at = flat.indexOf(needle); at !== -1; at = flat.indexOf(needle, at + needle.length)) {\n out.push([map[at] ?? 0, (map[at + needle.length - 1] ?? 0) + 1]);\n }\n return out;\n}\n"],"mappings":";;;AAgBA,SAAS,MAAM,OAAe,SAAmB,KAAuB;CACtE,MAAM,IAAI,QAAQ;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AQ,KAC/B,KAAK,MAAM,MAAM,cAAc,KAAK,MAAM,EAAE,GAAG;EAC7C,QAAQ;EACR,IAAI,KAAK,CAAC;CACZ;CAEF,KAAK,IAAI,KAAK,KAAK,QAAQ,MAAM,GAAG,OAAO,IAAI,KAAK,KAAK,QAAQ,QAAQ,KAAK,OAAO,MAAM,GACzF,IAAI,KAAK,CAAC,IAAI,OAAO,IAAI,IAAI,KAAK,OAAO,SAAS,MAAM,KAAK,CAAC,CAAC;CAEjE,OAAO;AACT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import { AnimationProps } from "../motion/useAnimationTarget.js";
|
|
3
|
+
import { SlurpCss } from "./css.js";
|
|
4
|
+
import { ComponentPropsWithRef, ElementType } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Props shared by every Slurp component: per-instance `css`, the animation* registration props, plus `className` /
|
|
7
|
+
* `style` forwarded to the root.
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseProps extends AnimationProps {
|
|
10
|
+
/** Per-instance style with design tokens, pseudo selectors and breakpoints. */
|
|
11
|
+
css?: SlurpCss;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Own props + `as` + the props of the rendered element (ref included, React 19). Unknown props go to the root element.
|
|
15
|
+
*/
|
|
16
|
+
export type PolymorphicProps<E extends ElementType, Own extends object = object> = Own & BaseProps & {
|
|
17
|
+
as?: E;
|
|
18
|
+
} & Omit<ComponentPropsWithRef<E>, keyof Own | keyof BaseProps | 'as'>;
|
|
19
|
+
/** Inner parts of a composed component (`root` is styled through `className` / `css`). */
|
|
20
|
+
export interface PartsProps<P extends string> {
|
|
21
|
+
/** Replaces an inner element with another tag or component. */
|
|
22
|
+
parts?: Partial<Record<P, ElementType>>;
|
|
23
|
+
/** Extra props for an inner element. */
|
|
24
|
+
partProps?: Partial<Record<P, Record<string, unknown>>>;
|
|
25
|
+
/** Extra class names for an inner element. */
|
|
26
|
+
classNames?: Partial<Record<P, string>>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=polymorphic.d.ts.map
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
|
|
2
|
+
import { SlurpCss } from "./css.js";
|
|
3
|
+
import { AccentScopeProps } from "../AccentScope/AccentScope.js";
|
|
4
|
+
import { AvatarProps } from "../Avatar/Avatar.js";
|
|
5
|
+
import { BentoProps } from "../Bento/Bento.js";
|
|
6
|
+
import { BloomProps } from "../Bloom/Bloom.js";
|
|
7
|
+
import { ButtonProps } from "../Button/Button.js";
|
|
8
|
+
import { BubbleProps } from "../Bubble/Bubble.js";
|
|
9
|
+
import { CardProps } from "../Card/Card.js";
|
|
10
|
+
import { CellProps } from "../Cell/Cell.js";
|
|
11
|
+
import { CheckboxProps } from "../Checkbox/Checkbox.js";
|
|
12
|
+
import { ChipProps } from "../Chip/Chip.js";
|
|
13
|
+
import { ChoiceProps } from "../Choice/Choice.js";
|
|
14
|
+
import { CountProps } from "../Count/Count.js";
|
|
15
|
+
import { DialogProps } from "../Dialog/Dialog.js";
|
|
16
|
+
import { DockProps } from "../Dock/Dock.js";
|
|
17
|
+
import { EmptyProps } from "../Empty/Empty.js";
|
|
18
|
+
import { FactProps } from "../Fact/Fact.js";
|
|
19
|
+
import { FieldProps } from "../Field/Field.js";
|
|
20
|
+
import { FiltersProps } from "../Filters/Filters.js";
|
|
21
|
+
import { FlowProps } from "../Flow/Flow.js";
|
|
22
|
+
import { FoldProps } from "../Fold/Fold.js";
|
|
23
|
+
import { FrameProps } from "../Frame/Frame.js";
|
|
24
|
+
import { HintProps } from "../Hint/Hint.js";
|
|
25
|
+
import { LinkProps } from "../Link/Link.js";
|
|
26
|
+
import { ListProps, ListRowProps } from "../ListRow/ListRow.js";
|
|
27
|
+
import { MenuProps } from "../Menu/Menu.js";
|
|
28
|
+
import { NoticeProps } from "../Notice/Notice.js";
|
|
29
|
+
import { PlaceholderProps } from "../Placeholder/Placeholder.js";
|
|
30
|
+
import { ProgressProps } from "../Progress/Progress.js";
|
|
31
|
+
import { RadioGroupProps, RadioProps } from "../Radio/Radio.js";
|
|
32
|
+
import { RangeProps } from "../Range/Range.js";
|
|
33
|
+
import { ResultRowProps } from "../ResultRow/ResultRow.js";
|
|
34
|
+
import { ScoreProps } from "../Score/Score.js";
|
|
35
|
+
import { SearchProps } from "../Search/Search.js";
|
|
36
|
+
import { SegmentedProps } from "../Segmented/Segmented.js";
|
|
37
|
+
import { SettingsProps } from "../Settings/Settings.js";
|
|
38
|
+
import { SheetProps } from "../Sheet/Sheet.js";
|
|
39
|
+
import { ShelfProps } from "../Shelf/Shelf.js";
|
|
40
|
+
import { StageProps } from "../Stage/Stage.js";
|
|
41
|
+
import { TileProps } from "../Tile/Tile.js";
|
|
42
|
+
import { SurfaceProps } from "../Surface/Surface.js";
|
|
43
|
+
import { SwatchGroupProps, SwatchProps } from "../Swatch/Swatch.js";
|
|
44
|
+
import { SwitchProps } from "../Switch/Switch.js";
|
|
45
|
+
import { TabsProps } from "../Tabs/Tabs.js";
|
|
46
|
+
import { TextProps } from "../Text/Text.js";
|
|
47
|
+
import { GhostKind, SlurpDefaults } from "@slurp-ui/motion";
|
|
48
|
+
import { ColorToken, HueToken, RadiusToken, SpaceToken, blur, shadow } from "@slurp-ui/tokens";
|
|
49
|
+
export type ColorSchemeMode = 'light' | 'dark' | 'system';
|
|
50
|
+
export type ResolvedColorScheme = 'light' | 'dark';
|
|
51
|
+
/** A `hue-*` preset (used as is) or any hex colour (turned into an accent with `vivid()`). */
|
|
52
|
+
export type AccentInput = `hue-${HueToken}` | `#${string}`;
|
|
53
|
+
type Themed = string | {
|
|
54
|
+
light: string;
|
|
55
|
+
dark: string;
|
|
56
|
+
};
|
|
57
|
+
type Length = string | number;
|
|
58
|
+
export interface TokenOverrides {
|
|
59
|
+
color?: Partial<Record<ColorToken | `hue-${HueToken}`, Themed>>;
|
|
60
|
+
space?: Partial<Record<SpaceToken, Length>>;
|
|
61
|
+
radius?: Partial<Record<RadiusToken, Length>>;
|
|
62
|
+
shadow?: Partial<Record<keyof typeof shadow, Themed>>;
|
|
63
|
+
blur?: Partial<Record<keyof typeof blur, Length>>;
|
|
64
|
+
}
|
|
65
|
+
/** Defaults of the collapse / expand transitions started with useSlurp() (serialisable values only). */
|
|
66
|
+
export interface MotionOptions extends Pick<SlurpDefaults, 'duration' | 'stagger' | 'curve' | 'swell' | 'drop' | 'reducedMotion' | 'interrupt'> {
|
|
67
|
+
goo: boolean | 'auto';
|
|
68
|
+
ghost: GhostKind;
|
|
69
|
+
order: 'distance' | 'dom';
|
|
70
|
+
}
|
|
71
|
+
/** Components that read defaults and `css` overrides from the theme, with their parts. */
|
|
72
|
+
export interface ThemeComponents {
|
|
73
|
+
AccentScope: {
|
|
74
|
+
props: AccentScopeProps;
|
|
75
|
+
parts: 'root';
|
|
76
|
+
};
|
|
77
|
+
Bento: {
|
|
78
|
+
props: BentoProps;
|
|
79
|
+
parts: 'root';
|
|
80
|
+
};
|
|
81
|
+
Card: {
|
|
82
|
+
props: CardProps;
|
|
83
|
+
parts: 'root' | 'media' | 'badge' | 'title' | 'description';
|
|
84
|
+
};
|
|
85
|
+
Dock: {
|
|
86
|
+
props: DockProps;
|
|
87
|
+
parts: 'root';
|
|
88
|
+
};
|
|
89
|
+
Empty: {
|
|
90
|
+
props: EmptyProps;
|
|
91
|
+
parts: 'root';
|
|
92
|
+
};
|
|
93
|
+
Fact: {
|
|
94
|
+
props: FactProps;
|
|
95
|
+
parts: 'root';
|
|
96
|
+
};
|
|
97
|
+
Filters: {
|
|
98
|
+
props: FiltersProps;
|
|
99
|
+
parts: 'root';
|
|
100
|
+
};
|
|
101
|
+
Link: {
|
|
102
|
+
props: LinkProps;
|
|
103
|
+
parts: 'root';
|
|
104
|
+
};
|
|
105
|
+
List: {
|
|
106
|
+
props: ListProps;
|
|
107
|
+
parts: 'root';
|
|
108
|
+
};
|
|
109
|
+
ListRow: {
|
|
110
|
+
props: ListRowProps;
|
|
111
|
+
parts: 'root' | 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action';
|
|
112
|
+
};
|
|
113
|
+
ResultRow: {
|
|
114
|
+
props: ResultRowProps;
|
|
115
|
+
parts: 'root';
|
|
116
|
+
};
|
|
117
|
+
Score: {
|
|
118
|
+
props: ScoreProps;
|
|
119
|
+
parts: 'root';
|
|
120
|
+
};
|
|
121
|
+
Settings: {
|
|
122
|
+
props: SettingsProps;
|
|
123
|
+
parts: 'root';
|
|
124
|
+
};
|
|
125
|
+
Shelf: {
|
|
126
|
+
props: ShelfProps;
|
|
127
|
+
parts: 'root';
|
|
128
|
+
};
|
|
129
|
+
Stage: {
|
|
130
|
+
props: StageProps;
|
|
131
|
+
parts: 'root';
|
|
132
|
+
};
|
|
133
|
+
Tile: {
|
|
134
|
+
props: TileProps;
|
|
135
|
+
parts: 'root' | 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media';
|
|
136
|
+
};
|
|
137
|
+
Avatar: {
|
|
138
|
+
props: AvatarProps;
|
|
139
|
+
parts: 'root';
|
|
140
|
+
};
|
|
141
|
+
Bloom: {
|
|
142
|
+
props: BloomProps;
|
|
143
|
+
parts: 'root' | 'surface' | 'trigger' | 'panel';
|
|
144
|
+
};
|
|
145
|
+
Bubble: {
|
|
146
|
+
props: BubbleProps;
|
|
147
|
+
parts: 'root';
|
|
148
|
+
};
|
|
149
|
+
Button: {
|
|
150
|
+
props: ButtonProps;
|
|
151
|
+
parts: 'root' | 'icon' | 'label' | 'endIcon';
|
|
152
|
+
};
|
|
153
|
+
Cell: {
|
|
154
|
+
props: CellProps;
|
|
155
|
+
parts: 'root';
|
|
156
|
+
};
|
|
157
|
+
Checkbox: {
|
|
158
|
+
props: CheckboxProps;
|
|
159
|
+
parts: 'root' | 'input' | 'box' | 'label';
|
|
160
|
+
};
|
|
161
|
+
Chip: {
|
|
162
|
+
props: ChipProps;
|
|
163
|
+
parts: 'root';
|
|
164
|
+
};
|
|
165
|
+
Choice: {
|
|
166
|
+
props: ChoiceProps;
|
|
167
|
+
parts: 'root';
|
|
168
|
+
};
|
|
169
|
+
Count: {
|
|
170
|
+
props: CountProps;
|
|
171
|
+
parts: 'root';
|
|
172
|
+
};
|
|
173
|
+
Dialog: {
|
|
174
|
+
props: DialogProps;
|
|
175
|
+
parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';
|
|
176
|
+
};
|
|
177
|
+
Field: {
|
|
178
|
+
props: FieldProps;
|
|
179
|
+
parts: 'root' | 'label' | 'control' | 'hint' | 'error';
|
|
180
|
+
};
|
|
181
|
+
Flow: {
|
|
182
|
+
props: FlowProps;
|
|
183
|
+
parts: 'root';
|
|
184
|
+
};
|
|
185
|
+
Fold: {
|
|
186
|
+
props: FoldProps;
|
|
187
|
+
parts: 'root' | 'heading' | 'trigger' | 'region';
|
|
188
|
+
};
|
|
189
|
+
Frame: {
|
|
190
|
+
props: FrameProps;
|
|
191
|
+
parts: 'root';
|
|
192
|
+
};
|
|
193
|
+
Hint: {
|
|
194
|
+
props: HintProps;
|
|
195
|
+
parts: 'root';
|
|
196
|
+
};
|
|
197
|
+
Menu: {
|
|
198
|
+
props: MenuProps;
|
|
199
|
+
parts: 'root';
|
|
200
|
+
};
|
|
201
|
+
Notice: {
|
|
202
|
+
props: NoticeProps;
|
|
203
|
+
parts: 'root' | 'icon' | 'title' | 'body' | 'dismiss';
|
|
204
|
+
};
|
|
205
|
+
Placeholder: {
|
|
206
|
+
props: PlaceholderProps;
|
|
207
|
+
parts: 'root';
|
|
208
|
+
};
|
|
209
|
+
Progress: {
|
|
210
|
+
props: ProgressProps;
|
|
211
|
+
parts: 'root';
|
|
212
|
+
};
|
|
213
|
+
Radio: {
|
|
214
|
+
props: RadioProps;
|
|
215
|
+
parts: 'root' | 'input' | 'dot' | 'label';
|
|
216
|
+
};
|
|
217
|
+
RadioGroup: {
|
|
218
|
+
props: RadioGroupProps;
|
|
219
|
+
parts: 'root' | 'legend';
|
|
220
|
+
};
|
|
221
|
+
Range: {
|
|
222
|
+
props: RangeProps;
|
|
223
|
+
parts: 'root' | 'label' | 'value' | 'control';
|
|
224
|
+
};
|
|
225
|
+
Search: {
|
|
226
|
+
props: SearchProps;
|
|
227
|
+
parts: 'root' | 'icon' | 'control' | 'clear' | 'status';
|
|
228
|
+
};
|
|
229
|
+
Segmented: {
|
|
230
|
+
props: SegmentedProps;
|
|
231
|
+
parts: 'root' | 'item';
|
|
232
|
+
};
|
|
233
|
+
Sheet: {
|
|
234
|
+
props: SheetProps;
|
|
235
|
+
parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';
|
|
236
|
+
};
|
|
237
|
+
Surface: {
|
|
238
|
+
props: SurfaceProps;
|
|
239
|
+
parts: 'root';
|
|
240
|
+
};
|
|
241
|
+
Swatch: {
|
|
242
|
+
props: SwatchProps;
|
|
243
|
+
parts: 'root';
|
|
244
|
+
};
|
|
245
|
+
SwatchGroup: {
|
|
246
|
+
props: SwatchGroupProps;
|
|
247
|
+
parts: 'root';
|
|
248
|
+
};
|
|
249
|
+
Switch: {
|
|
250
|
+
props: SwitchProps;
|
|
251
|
+
parts: 'root' | 'input' | 'track' | 'thumb' | 'label';
|
|
252
|
+
};
|
|
253
|
+
Tabs: {
|
|
254
|
+
props: TabsProps;
|
|
255
|
+
parts: 'root' | 'list' | 'tab' | 'indicator' | 'panel';
|
|
256
|
+
};
|
|
257
|
+
Text: {
|
|
258
|
+
props: TextProps;
|
|
259
|
+
parts: 'root';
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export type ComponentName = keyof ThemeComponents;
|
|
263
|
+
export type ComponentsConfig = { [K in ComponentName]?: {
|
|
264
|
+
defaults?: Partial<Omit<ThemeComponents[K]['props'], 'ref' | 'children' | 'css'>>;
|
|
265
|
+
css?: Partial<Record<ThemeComponents[K]['parts'], SlurpCss>>;
|
|
266
|
+
}; };
|
|
267
|
+
export interface ThemeOptions {
|
|
268
|
+
/** Initial colour scheme, until the person chooses one (default `system`). */
|
|
269
|
+
colorScheme?: ColorSchemeMode;
|
|
270
|
+
/** Default `hue-violet`. */
|
|
271
|
+
accent?: AccentInput;
|
|
272
|
+
/** Used only by Intl (numbers, prices). Not an i18n system. Default `it-IT`. */
|
|
273
|
+
locale?: string;
|
|
274
|
+
tokens?: TokenOverrides;
|
|
275
|
+
motion?: Partial<MotionOptions>;
|
|
276
|
+
components?: ComponentsConfig;
|
|
277
|
+
}
|
|
278
|
+
export interface Theme {
|
|
279
|
+
colorScheme: ColorSchemeMode;
|
|
280
|
+
accent: AccentInput;
|
|
281
|
+
/** The accent actually painted (hex). */
|
|
282
|
+
accentColor: string;
|
|
283
|
+
locale: string;
|
|
284
|
+
tokens: TokenOverrides;
|
|
285
|
+
motion: MotionOptions;
|
|
286
|
+
components: ComponentsConfig;
|
|
287
|
+
}
|
|
288
|
+
/** localStorage key of the chosen colour scheme (same as the design system's setTheme()). */
|
|
289
|
+
export declare const DEFAULT_STORAGE_KEY = "slurp-theme";
|
|
290
|
+
export declare function createTheme(options?: ThemeOptions): Theme;
|
|
291
|
+
export {};
|
|
292
|
+
//# sourceMappingURL=theme.d.ts.map
|