@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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @slurp-ui/react
|
|
2
|
+
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9aec3d3: The package now includes its CHANGELOG.md.
|
|
8
|
+
- Updated dependencies [9aec3d3]
|
|
9
|
+
- @slurp-ui/motion@1.0.1
|
|
10
|
+
- @slurp-ui/tokens@1.0.1
|
|
11
|
+
- @slurp-ui/icons@1.0.1
|
|
12
|
+
|
|
13
|
+
## 1.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- da26ea0: First stable release: the Slurp design system's tokens, icons, collapse / expand engine and React components, with a documentation page per component (props, accessibility, classes, variables and states). From here on the public API follows semver.
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 56e94d4: First release of the Slurp design tokens: `--slurp-*` custom properties for the light and dark themes (`tokens.css`, inside `@layer slurp.base`), Poppins `@font-face` rules (`fonts.css`) and typed TS constants (`color`, `hue`, `space`, `radius`, `font`, `vars`, `cssVar()`, `COMPACT_QUERY`). `@slurp-ui/react` re-exports them from `@slurp-ui/react/tokens`, `@slurp-ui/react/tokens.css` and `@slurp-ui/react/styles.css`.
|
|
22
|
+
- 3b1c343: Add `AccentScope`: scopes `accent`, `on-accent`, `accent-soft`, `accent-ink` and `focus` to a `hue-*` preset or any colour (through `vivid()`), with a 0.9s cross-fade.
|
|
23
|
+
- 5e42219: Add `Avatar`: round photo with initials as fallback.
|
|
24
|
+
- cec612b: Add `Bento` (12 fluid columns, two below 860px) and `bentoLayout()`: with `layout="auto"` the children's `weight` shapes the spans, the first section tall on the left.
|
|
25
|
+
- 5e42219: Add `Bloom`: the button becomes the panel. One surface grows from the trigger (width, height, radius) and shrinks back, flipping when there is no room; built on `useDismiss` and `focusFirst`.
|
|
26
|
+
- 5e42219: Add `Bubble`, the round icon-only button with a required `label`.
|
|
27
|
+
- 5e42219: Add `Button`: `fill`, `soft`, `outline` or `plain` appearance, `accent` or `neutral` tone, sizes `sm`/`md`/`lg` (44px minimum), icons and `href`.
|
|
28
|
+
- cec612b: Add `Card` (one tinted surface, title and description pills inside, link or button) and `Shelf`, the auto-fill list of cards.
|
|
29
|
+
- 3b1c343: Add `Cell`, the base primitive: any element (`as`) styled with `css`.
|
|
30
|
+
- 5e42219: Add `Checkbox` on a native input, with the indeterminate state.
|
|
31
|
+
- 5e42219: Add `Chip`, a toggle with `aria-pressed`: selected is an accent fill plus a check.
|
|
32
|
+
- 5e42219: Add `Choice`, the select whose trigger becomes the list (Bloom), with full keyboard support and a hidden form input.
|
|
33
|
+
- 551769e: Add the colour utilities of the design system: `vivid()`, `contrast()`, `meetsContrast()`, `onColor()`, `alpha()`.
|
|
34
|
+
- 5e42219: Add `Count`, a badge whose `label` joins the accessible name of the control around it.
|
|
35
|
+
- 3b1c343: Add the `css` prop runtime: design tokens (`p: 4`, `bg: 'accent-soft'`, `radius: 'card'`, `font: 'title-l'`), nested selectors and `{ base, compact, wide }` breakpoints, compiled to hashed atomic classes in `@layer slurp.utilities` and hoisted with React 19 `<style>` (SSR included).
|
|
36
|
+
- 5e42219: Add `Dialog` (native modal `<dialog>`, grows out of the control that opened it) and `Sheet` (from the bottom edge).
|
|
37
|
+
- cec612b: Add `Dock`, the single navigation: `Dock.Crumbs` with `Dock.Back` and `Dock.Crumb` drawn as interlocking SVG pieces (`crumbPath()`), `Dock.Search` with the find-in-page counter, `Dock.Actions` / `Dock.Action`, and panels that grow above the bar. On phones earlier crumbs become icons and search becomes an action.
|
|
38
|
+
- cec612b: Add `Empty`: a message and a single way out, announced politely.
|
|
39
|
+
- cec612b: Add `Fact` (label and value as one pill) and `Score` (one decimal in an accent-ink ring, fully named for assistive tech).
|
|
40
|
+
- 5e42219: Add `Field`: label, input or textarea with a 3:1 boundary, hint and error wired with aria-describedby.
|
|
41
|
+
- cec612b: Add `Filters` and `Filters.Group`: the filter panel with "Azzera filtri", off when nothing is active.
|
|
42
|
+
- 3b1c343: Add `Flow`: column or row with a gap from the space scale; `direction`, `gap`, `align`, `justify` accept breakpoints.
|
|
43
|
+
- 5e42219: Add `Fold`, a disclosure that grows in height; closed content is inert.
|
|
44
|
+
- 3b1c343: Add `Frame`: centred page column, max 1280px, gutter 24px (16px on phones).
|
|
45
|
+
- 3b1c343: Add `Ground`: opt-in page baseline (box-sizing, Poppins body text, `bg` tinted 7% by the accent, 2px focus ring) in `@layer slurp.reset`.
|
|
46
|
+
- 5e42219: Add `Hint`, a tooltip in the top layer: hover (with delay) and focus, Escape, stays while hovered.
|
|
47
|
+
- cec612b: Add `List` and `ListRow`: mark, title with a highlight tag (with a check), meta, value and one action link named after its row; `Link` for text links.
|
|
48
|
+
- cec612b: Add `Mark` and `useFindInPage()` for find in page (case- and accent-insensitive, the active match filled and scrolled to the middle), with `matchesAll`, `matchRanges` and `focusHit`.
|
|
49
|
+
- 5e42219: Add `Menu` and `MenuItem` on Bloom: looping arrow keys, items close the menu and give focus back.
|
|
50
|
+
- f8991cf: Add opt-in motion: every component accepts `animationId`, `animationGroup`, `animationLead`, `animationDisabled` and `animationGhost` and only registers its root (nothing is allocated without them). `useSlurp()` starts collapse / expand transitions with the theme defaults (`createTheme({ motion })` now covers duration, stagger, curve, swell, drop, goo, ghost, order, reduced motion and interruptions), `<AnimationGroup>` groups descendants, `useAnimationTarget()` registers custom elements. The engine is re-exported from `@slurp-ui/react/motion`.
|
|
51
|
+
- 4b675d4: Add `useSlurpNavigate` and `useSlurpEnter` for transitions across routes: the first wraps any router's navigate function (no router is imported) and measures the source before navigating, the second plays the transition in the route that mounts and, with `content`, fades the rest of the page in while the droplets land. A stale handoff or missing targets fade; a direct visit or the browser's history only render the route.
|
|
52
|
+
- 5e42219: Add `Notice`: icon plus word for each tone, optional close button.
|
|
53
|
+
- 5e42219: Add `Placeholder`, rounded loading shapes (circle, capsule, soft square).
|
|
54
|
+
- 5e42219: Add `VisuallyHidden` and `Portal`.
|
|
55
|
+
- 5e42219: Add `Progress` as a bar or a ring, with value or indeterminate.
|
|
56
|
+
- 5e42219: Add `Radio` and `RadioGroup` (fieldset and legend, native arrow keys).
|
|
57
|
+
- 5e42219: Add `Range`, a slider on a native range input with a 44px target and a formatted value text.
|
|
58
|
+
- cec612b: Add `ResultRow`, a search result whose rows move with the arrow keys.
|
|
59
|
+
- 5e42219: Add `Search`: contextual placeholder, result count in a polite live region, clear button, Enter to search.
|
|
60
|
+
- 5e42219: Add `Segmented`, a single choice among a few: one tab stop, arrow keys move and select, the selected segment is filled and checked.
|
|
61
|
+
- cec612b: Add `Settings`: the round button that grows into its panel, with Tema always and Lingua when configured; `RadioGroup` gains `appearance="rows"` and `Radio` an `icon`.
|
|
62
|
+
- cec612b: Add `Stage`, the media stage with one breathing glow and one ring.
|
|
63
|
+
- 3b1c343: Add `Surface`: floating surface with `level` (`surface`, `dock`, `solid`) and `radius`.
|
|
64
|
+
- 5e42219: Add `Swatch` and `SwatchGroup`: colour choices with a ring for the selected one, arrow keys in the group.
|
|
65
|
+
- 5e42219: Add `Switch` (`role="switch"`): on shows the thumb at the end with a check.
|
|
66
|
+
- 5e42219: Add `Tabs`: the pill indicator moves on a spring (CSS `linear()` easing), arrow keys move and select.
|
|
67
|
+
- 3b1c343: Add `Text`: the 13 type styles of the design system (`font`), element chosen from the style, `tone` and `muted`.
|
|
68
|
+
- 3b1c343: Add `createTheme()`, `SlurpProvider`, `useTheme()`, `useColorScheme()` and `ColorSchemeScript`: accent, token overrides, per-component defaults and `css`, light / dark / system colour scheme remembered in localStorage. Nested providers theme only their subtree.
|
|
69
|
+
- cec612b: Add `Tile`, the entry grid cell tinted by its colour, with a drifting blob and container-scaled text and media; a collapse saturates toward its colour.
|
|
70
|
+
- 5e42219: Add `ToastProvider` and `useToast()`: toasts in a polite live region above the Dock, paused while hovered or focused.
|
|
71
|
+
- 5e42219: Add the shared behaviour of the components, also at `@slurp-ui/react/utils`: `useDismiss` (press outside, Escape, Tab out, focus back), `focusFirst`, `moveFocus`, `useRovingFocus`, `useControlled`, `useForkRef`, `useMediaQuery` with `COMPACT_QUERY`.
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [5cac9b1]
|
|
76
|
+
- Updated dependencies [201df15]
|
|
77
|
+
- Updated dependencies [878fd91]
|
|
78
|
+
- Updated dependencies [8b092aa]
|
|
79
|
+
- Updated dependencies [da26ea0]
|
|
80
|
+
- Updated dependencies [56e94d4]
|
|
81
|
+
- Updated dependencies [228b034]
|
|
82
|
+
- @slurp-ui/icons@1.0.0
|
|
83
|
+
- @slurp-ui/motion@1.0.0
|
|
84
|
+
- @slurp-ui/tokens@1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SpaM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @slurp-ui/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ready-made React components of the Slurp design system: an entry grid of tiles, lists of cards, detail pages and one floating Dock that carries all navigation, with the optional collapse / expand ("slurp") transition between them. Light and dark themes, WCAG 2.2 AA.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i @slurp-ui/react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
React 19 or later. ESM only.
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import '@slurp-ui/react/styles.css';
|
|
15
|
+
import { Button, createTheme, Ground, SlurpProvider } from '@slurp-ui/react';
|
|
16
|
+
|
|
17
|
+
const theme = createTheme({ accent: 'hue-violet' });
|
|
18
|
+
|
|
19
|
+
export function App() {
|
|
20
|
+
return (
|
|
21
|
+
<SlurpProvider theme={theme}>
|
|
22
|
+
<Ground />
|
|
23
|
+
<Button>Aggiungi al carrello</Button>
|
|
24
|
+
</SlurpProvider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`styles.css` holds the tokens (`--slurp-*`), the fonts and every component's CSS inside `@layer slurp.*`: your own CSS wins without `!important`.
|
|
30
|
+
|
|
31
|
+
## Customise
|
|
32
|
+
|
|
33
|
+
1. **Theme**: `createTheme({ accent, tokens, components, motion })` for the accent, token overrides, per-component defaults and the motion defaults.
|
|
34
|
+
2. **`css` prop**: tokens (`p: 4`, `bg: 'accent-soft'`, `radius: 'card'`), selectors (`'&:hover'`) and breakpoints (`{ base, compact }`) on any component.
|
|
35
|
+
3. **CSS variables and classes**: every component documents its `.slurp-*` classes, `--slurp-*` variables and `data-*` states.
|
|
36
|
+
|
|
37
|
+
## Motion
|
|
38
|
+
|
|
39
|
+
Components only register (`animationId`, `animationGroup`); transitions start from `useSlurp()`:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
const { collapse, expand } = useSlurp();
|
|
43
|
+
collapse({ items: { group: 'tiles' }, target: 'crumb', lead: 'tile-audio' });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Across routes, `useSlurpNavigate(navigate)` measures before navigating and `useSlurpEnter()` plays the transition in the next route. No router is imported: it works with Next.js, React Router or your own. With `prefers-reduced-motion` every transition becomes a short fade.
|
|
47
|
+
|
|
48
|
+
## Next.js (App Router)
|
|
49
|
+
|
|
50
|
+
Component modules carry `'use client'`, so server components can render them; `createTheme` runs on the server. Put the colour scheme script in `<head>` to avoid a flash of the wrong theme:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
// app/layout.tsx
|
|
54
|
+
import '@slurp-ui/react/styles.css';
|
|
55
|
+
import { ColorSchemeScript, Ground, SlurpProvider } from '@slurp-ui/react';
|
|
56
|
+
|
|
57
|
+
export default function RootLayout({ children }) {
|
|
58
|
+
return (
|
|
59
|
+
<html lang="it" suppressHydrationWarning>
|
|
60
|
+
<head>
|
|
61
|
+
<ColorSchemeScript />
|
|
62
|
+
</head>
|
|
63
|
+
<body>
|
|
64
|
+
<SlurpProvider>
|
|
65
|
+
<Ground />
|
|
66
|
+
{children}
|
|
67
|
+
</SlurpProvider>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Entry points
|
|
75
|
+
|
|
76
|
+
| Import | Contents |
|
|
77
|
+
| ---------------------------- | ------------------------------------------------------------------- |
|
|
78
|
+
| `@slurp-ui/react` | components, theme, provider, hooks |
|
|
79
|
+
| `@slurp-ui/react/styles.css` | tokens, fonts and component styles |
|
|
80
|
+
| `@slurp-ui/react/motion` | the collapse / expand engine (`@slurp-ui/motion`) and hooks |
|
|
81
|
+
| `@slurp-ui/react/tokens` | token values, `cssVar()`, `COMPACT_QUERY` |
|
|
82
|
+
| `@slurp-ui/react/icons` | the icon set (`@slurp-ui/icons`) |
|
|
83
|
+
| `@slurp-ui/react/utils` | shared behaviours: `useDismiss`, `useRovingFocus`, `useFindInPage`… |
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface AccentScopeOwnProps {
|
|
5
|
+
/** A `hue-*` preset (used as is) or any hex colour, turned into an accessible accent with `vivid()`. */
|
|
6
|
+
color: string;
|
|
7
|
+
}
|
|
8
|
+
export type AccentScopeProps<E extends ElementType = 'div'> = PolymorphicProps<E, AccentScopeOwnProps>;
|
|
9
|
+
/**
|
|
10
|
+
* Scopes the dynamic accent: everything inside reads `accent`, `on-accent`, `accent-soft`, `accent-ink` and `focus`
|
|
11
|
+
* from `color`. The accent cross-fades over 0.9s when it changes (not with reduced motion).
|
|
12
|
+
* Put `data-theme` subtrees outside the scope: the derived colours resolve against the scope's own `fg`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function AccentScope<E extends ElementType = 'div'>(props: AccentScopeProps<E>): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=AccentScope.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { accentVars, resolveAccent } from "../lib/color.js";
|
|
3
|
+
import { cx } from "../utils/src/index.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/AccentScope/AccentScope.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Scopes the dynamic accent: everything inside reads `accent`, `on-accent`, `accent-soft`, `accent-ink` and `focus`
|
|
11
|
+
* from `color`. The accent cross-fades over 0.9s when it changes (not with reduced motion).
|
|
12
|
+
* Put `data-theme` subtrees outside the scope: the derived colours resolve against the scope's own `fg`.
|
|
13
|
+
*/
|
|
14
|
+
function AccentScope(props) {
|
|
15
|
+
const { as, css, className, style, color, ...rest } = useThemeProps("AccentScope", props);
|
|
16
|
+
const Root = as ?? "div";
|
|
17
|
+
const styled = useCss("AccentScope", "root", css);
|
|
18
|
+
const vars = useMemo(() => accentVars(resolveAccent(color)), [color]);
|
|
19
|
+
const root = useAnimationRoot(rest);
|
|
20
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
21
|
+
className: cx("slurp-accent-scope", styled.className, className),
|
|
22
|
+
style: {
|
|
23
|
+
...vars,
|
|
24
|
+
...style
|
|
25
|
+
},
|
|
26
|
+
...root
|
|
27
|
+
})] });
|
|
28
|
+
}
|
|
29
|
+
export { AccentScope };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=AccentScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccentScope.js","names":[],"sources":["../../src/AccentScope/AccentScope.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport { useMemo, type CSSProperties, type ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { accentVars, resolveAccent } from '../lib/color';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface AccentScopeOwnProps {\n /** A `hue-*` preset (used as is) or any hex colour, turned into an accessible accent with `vivid()`. */\n color: string;\n}\n\nexport type AccentScopeProps<E extends ElementType = 'div'> = PolymorphicProps<\n E,\n AccentScopeOwnProps\n>;\n\n/**\n * Scopes the dynamic accent: everything inside reads `accent`, `on-accent`, `accent-soft`, `accent-ink` and `focus`\n * from `color`. The accent cross-fades over 0.9s when it changes (not with reduced motion).\n * Put `data-theme` subtrees outside the scope: the derived colours resolve against the scope's own `fg`.\n */\nexport function AccentScope<E extends ElementType = 'div'>(props: AccentScopeProps<E>) {\n const { as, css, className, style, color, ...rest } = useThemeProps(\n 'AccentScope',\n props as AccentScopeProps,\n );\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('AccentScope', 'root', css);\n const vars = useMemo(() => accentVars(resolveAccent(color)), [color]);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-accent-scope', styled.className, className)}\n style={{ ...vars, ...style } as CSSProperties}\n {...root}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,SAAgB,YAA2C,OAA4B;CACrF,MAAM,EAAE,IAAI,KAAK,WAAW,OAAO,OAAO,GAAG,SAAS,cACpD,eACA,KACF;CACA,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,eAAe,QAAQ,GAAG;CAChD,MAAM,OAAO,cAAc,WAAW,cAAc,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;CACpE,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,sBAAsB,OAAO,WAAW,SAAS;EAC/D,OAAO;GAAE,GAAG;GAAM,GAAG;EAAM;EAC3B,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface AvatarOwnProps {
|
|
5
|
+
/** Who it is: the image's alt text and the source of the initials. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Photo; when missing or broken, the initials show. */
|
|
8
|
+
src?: string;
|
|
9
|
+
/** `sm` 32 · `md` 44 (default) · `lg` 64. */
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
/** Next to the visible name already: hidden from assistive tech. */
|
|
12
|
+
decorative?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type AvatarProps<E extends ElementType = 'span'> = PolymorphicProps<E, AvatarOwnProps>;
|
|
15
|
+
/** A person (or a brand): round photo, initials when there is none. */
|
|
16
|
+
export declare function Avatar<E extends ElementType = 'span'>(props: AvatarProps<E>): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Avatar/Avatar.tsx
|
|
8
|
+
/** First letters of the first and last word. */
|
|
9
|
+
function initials(name) {
|
|
10
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
11
|
+
return ((words[0]?.[0] ?? "") + (words.length > 1 ? words.at(-1)?.[0] ?? "" : "")).toLocaleUpperCase();
|
|
12
|
+
}
|
|
13
|
+
/** A person (or a brand): round photo, initials when there is none. */
|
|
14
|
+
function Avatar(props) {
|
|
15
|
+
const { as, css, className, name, src, size = "md", decorative = false, ...rest } = useThemeProps("Avatar", props);
|
|
16
|
+
const [failed, setFailed] = useState(null);
|
|
17
|
+
const Root = as ?? "span";
|
|
18
|
+
const styled = useCss("Avatar", "root", css);
|
|
19
|
+
const root = useAnimationRoot(rest);
|
|
20
|
+
const photo = src && failed !== src;
|
|
21
|
+
const a11y = decorative ? { "aria-hidden": true } : photo ? {} : {
|
|
22
|
+
role: "img",
|
|
23
|
+
"aria-label": name
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
26
|
+
className: cx("slurp-avatar", styled.className, className),
|
|
27
|
+
"data-size": size,
|
|
28
|
+
...a11y,
|
|
29
|
+
...root,
|
|
30
|
+
children: photo ? /* @__PURE__ */ jsx("img", {
|
|
31
|
+
src,
|
|
32
|
+
alt: decorative ? "" : name,
|
|
33
|
+
onError: () => setFailed(src)
|
|
34
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
children: initials(name)
|
|
37
|
+
})
|
|
38
|
+
})] });
|
|
39
|
+
}
|
|
40
|
+
export { Avatar, initials };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=Avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":[],"sources":["../../src/Avatar/Avatar.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport { useState, type ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface AvatarOwnProps {\n /** Who it is: the image's alt text and the source of the initials. */\n name: string;\n /** Photo; when missing or broken, the initials show. */\n src?: string;\n /** `sm` 32 · `md` 44 (default) · `lg` 64. */\n size?: 'sm' | 'md' | 'lg';\n /** Next to the visible name already: hidden from assistive tech. */\n decorative?: boolean;\n}\n\nexport type AvatarProps<E extends ElementType = 'span'> = PolymorphicProps<E, AvatarOwnProps>;\n\n/** First letters of the first and last word. */\nexport function initials(name: string): string {\n const words = name.trim().split(/\\s+/).filter(Boolean);\n const first = words[0]?.[0] ?? '';\n const last = words.length > 1 ? (words.at(-1)?.[0] ?? '') : '';\n return (first + last).toLocaleUpperCase();\n}\n\n/** A person (or a brand): round photo, initials when there is none. */\nexport function Avatar<E extends ElementType = 'span'>(props: AvatarProps<E>) {\n const {\n as,\n css,\n className,\n name,\n src,\n size = 'md',\n decorative = false,\n ...rest\n } = useThemeProps('Avatar', props as AvatarProps);\n const [failed, setFailed] = useState<string | null>(null);\n const Root = (as ?? 'span') as ElementType;\n const styled = useCss('Avatar', 'root', css);\n const root = useAnimationRoot(rest);\n const photo = src && failed !== src;\n const a11y = decorative\n ? { 'aria-hidden': true }\n : photo\n ? {}\n : { role: 'img', 'aria-label': name };\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-avatar', styled.className, className)}\n data-size={size}\n {...a11y}\n {...root}\n >\n {photo ? (\n <img src={src} alt={decorative ? '' : name} onError={() => setFailed(src)} />\n ) : (\n <span aria-hidden=\"true\">{initials(name)}</span>\n )}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,SAAS,MAAsB;CAC7C,MAAM,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CAGrD,SAFc,MAAM,EAAE,GAAG,MAAM,OAClB,MAAM,SAAS,IAAK,MAAM,GAAG,EAAE,CAAC,GAAG,MAAM,KAAM,IAAA,CACtC,kBAAkB;AAC1C;;AAGA,SAAgB,OAAuC,OAAuB;CAC5E,MAAM,EACJ,IACA,KACA,WACA,MACA,KACA,OAAO,MACP,aAAa,OACb,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,CAAC,QAAQ,aAAa,SAAwB,IAAI;CACxD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,OAAO,WAAW;CAChC,MAAM,OAAO,aACT,EAAE,eAAe,KAAK,IACtB,QACE,CAAC,IACD;EAAE,MAAM;EAAO,cAAc;CAAK;CACxC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;EACzD,aAAW;EACX,GAAI;EACJ,GAAI;EAEH,UAAA,QACC,oBAAC,OAAD;GAAU;GAAK,KAAK,aAAa,KAAK;GAAM,eAAe,UAAU,GAAG;EAAI,CAAA,IAE5E,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA,SAAS,IAAI;EAAQ,CAAA;CAE7C,CAAA,CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface BentoOwnProps {
|
|
5
|
+
/**
|
|
6
|
+
* `auto` (default): spans from `bentoLayout()` — children in priority order, each `weight` prop (a size measure)
|
|
7
|
+
* shaping the grid. `manual`: set `--slurp-bento-cols` / `--slurp-bento-rows` on the children yourself.
|
|
8
|
+
*/
|
|
9
|
+
layout?: 'auto' | 'manual';
|
|
10
|
+
}
|
|
11
|
+
export type BentoProps<E extends ElementType = 'div'> = PolymorphicProps<E, BentoOwnProps>;
|
|
12
|
+
/** The entry grid: 12 fluid columns; 2 columns on narrow screens (the first item two rows tall). */
|
|
13
|
+
export declare function Bento<E extends ElementType = 'div'>(props: BentoProps<E>): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=Bento.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { bentoLayout } from "../lib/layout.js";
|
|
6
|
+
import { Children, cloneElement, isValidElement } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/Bento/Bento.tsx
|
|
9
|
+
/** The entry grid: 12 fluid columns; 2 columns on narrow screens (the first item two rows tall). */
|
|
10
|
+
function Bento(props) {
|
|
11
|
+
const { as, css, className, layout = "auto", children, ...rest } = useThemeProps("Bento", props);
|
|
12
|
+
const Root = as ?? "div";
|
|
13
|
+
const styled = useCss("Bento", "root", css);
|
|
14
|
+
const root = useAnimationRoot(rest);
|
|
15
|
+
const items = Children.toArray(children).filter(isValidElement);
|
|
16
|
+
const spans = layout === "auto" ? bentoLayout(items.map((c, i) => ({
|
|
17
|
+
id: String(i),
|
|
18
|
+
weight: c.props.weight
|
|
19
|
+
}))) : null;
|
|
20
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
21
|
+
className: cx("slurp-bento", styled.className, className),
|
|
22
|
+
...root,
|
|
23
|
+
children: spans ? items.map((child, i) => {
|
|
24
|
+
const s = spans[i];
|
|
25
|
+
if (!s) return child;
|
|
26
|
+
const { weight: _weight, ...childProps } = child.props;
|
|
27
|
+
return cloneElement(child, {
|
|
28
|
+
...childProps,
|
|
29
|
+
weight: void 0,
|
|
30
|
+
size: childProps.size ?? s.size,
|
|
31
|
+
style: {
|
|
32
|
+
"--slurp-bento-cols": s.colSpan,
|
|
33
|
+
"--slurp-bento-rows": s.rowSpan,
|
|
34
|
+
...childProps.style
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}) : children
|
|
38
|
+
})] });
|
|
39
|
+
}
|
|
40
|
+
export { Bento };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=Bento.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bento.js","names":[],"sources":["../../src/Bento/Bento.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n Children,\n cloneElement,\n isValidElement,\n type CSSProperties,\n type ElementType,\n type ReactElement,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { bentoLayout } from '../lib/layout';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface BentoOwnProps {\n /**\n * `auto` (default): spans from `bentoLayout()` — children in priority order, each `weight` prop (a size measure)\n * shaping the grid. `manual`: set `--slurp-bento-cols` / `--slurp-bento-rows` on the children yourself.\n */\n layout?: 'auto' | 'manual';\n}\n\nexport type BentoProps<E extends ElementType = 'div'> = PolymorphicProps<E, BentoOwnProps>;\n\ntype ChildProps = { weight?: number; style?: CSSProperties; size?: string };\n\n/** The entry grid: 12 fluid columns; 2 columns on narrow screens (the first item two rows tall). */\nexport function Bento<E extends ElementType = 'div'>(props: BentoProps<E>) {\n const {\n as,\n css,\n className,\n layout = 'auto',\n children,\n ...rest\n } = useThemeProps('Bento', props as BentoProps);\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Bento', 'root', css);\n const root = useAnimationRoot(rest);\n const items = Children.toArray(children).filter(isValidElement) as ReactElement<ChildProps>[];\n const spans =\n layout === 'auto'\n ? bentoLayout(items.map((c, i) => ({ id: String(i), weight: c.props.weight })))\n : null;\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-bento', styled.className, className)} {...root}>\n {spans\n ? items.map((child, i) => {\n const s = spans[i];\n if (!s) return child;\n const { weight: _weight, ...childProps } = child.props;\n return cloneElement(child, {\n ...childProps,\n weight: undefined,\n size: childProps.size ?? s.size,\n style: {\n '--slurp-bento-cols': s.colSpan,\n '--slurp-bento-rows': s.rowSpan,\n ...childProps.style,\n } as CSSProperties,\n });\n })\n : children}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AA4BA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EACJ,IACA,KACA,WACA,SAAS,QACT,UACA,GAAG,SACD,cAAc,SAAS,KAAmB;CAC9C,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,SAAS,QAAQ,QAAQ,CAAC,CAAC,OAAO,cAAc;CAC9D,MAAM,QACJ,WAAW,SACP,YAAY,MAAM,KAAK,GAAG,OAAO;EAAE,IAAI,OAAO,CAAC;EAAG,QAAQ,EAAE,MAAM;CAAO,EAAE,CAAC,IAC5E;CACN,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,QACG,MAAM,KAAK,OAAO,MAAM;GACtB,MAAM,IAAI,MAAM;GAChB,IAAI,CAAC,GAAG,OAAO;GACf,MAAM,EAAE,QAAQ,SAAS,GAAG,eAAe,MAAM;GACjD,OAAO,aAAa,OAAO;IACzB,GAAG;IACH,QAAQ,KAAA;IACR,MAAM,WAAW,QAAQ,EAAE;IAC3B,OAAO;KACL,sBAAsB,EAAE;KACxB,sBAAsB,EAAE;KACxB,GAAG,WAAW;IAChB;GACF,CAAC;EACH,CAAC,IACD;CACA,CAAA,CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export type BloomPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
|
|
5
|
+
export interface BloomOwnProps extends PartsProps<'surface' | 'trigger' | 'panel'> {
|
|
6
|
+
/** Content of the trigger button (text, icon, both). */
|
|
7
|
+
trigger: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Name of the trigger when it shows only an icon. An icon trigger stays in its corner when open, 44px and inset by
|
|
10
|
+
* space-2 like the Dock's actions; the panel's first row (its title) sits beside it.
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/** Trigger content while open (an icon trigger usually becomes a close icon). */
|
|
14
|
+
openTrigger?: ReactNode;
|
|
15
|
+
/** Name of an icon trigger while open ("Chiudi impostazioni"). */
|
|
16
|
+
closeLabel?: string;
|
|
17
|
+
open?: boolean;
|
|
18
|
+
defaultOpen?: boolean;
|
|
19
|
+
onOpenChange?: (open: boolean) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Corner the surface grows from: `bottom-start` (default) grows right and down. It flips by itself when the panel
|
|
22
|
+
* would leave the viewport.
|
|
23
|
+
*/
|
|
24
|
+
placement?: BloomPlacement;
|
|
25
|
+
/** Open width in px (never wider than the viewport minus 32px). Default 300. */
|
|
26
|
+
width?: number;
|
|
27
|
+
/** Role of the panel: a non-modal `dialog` (default), a `menu` or a `listbox`. */
|
|
28
|
+
role?: 'dialog' | 'menu' | 'listbox';
|
|
29
|
+
/** Name of the panel; default the trigger. */
|
|
30
|
+
panelLabel?: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** The panel. A function gets `close(restoreFocus = true)`. */
|
|
33
|
+
children?: ReactNode | ((close: (restoreFocus?: boolean) => void) => ReactNode);
|
|
34
|
+
}
|
|
35
|
+
export type BloomProps<E extends ElementType = 'div'> = PolymorphicProps<E, BloomOwnProps>;
|
|
36
|
+
/**
|
|
37
|
+
* The design system's rule for floating panels: **the button becomes the panel**. One surface grows from the trigger
|
|
38
|
+
* (width, height through grid rows, radius) and shrinks back into it. Closes on a press outside, Escape or Tab out;
|
|
39
|
+
* opening moves focus into the panel; Escape gives it back to the trigger.
|
|
40
|
+
*/
|
|
41
|
+
export declare function Bloom<E extends ElementType = 'div'>(props: BloomProps<E>): import("react").JSX.Element;
|
|
42
|
+
//# sourceMappingURL=Bloom.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
7
|
+
import { focusFirst } from "../utils/focus.js";
|
|
8
|
+
import { useDismiss } from "../utils/useDismiss.js";
|
|
9
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/Bloom/Bloom.tsx
|
|
12
|
+
/** The Dock's motion: 0.6s, cubic-bezier(0.2, 0.8, 0.2, 1). */
|
|
13
|
+
const DURATION = 600;
|
|
14
|
+
const VIEWPORT_MARGIN = 16;
|
|
15
|
+
const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
16
|
+
/**
|
|
17
|
+
* The design system's rule for floating panels: **the button becomes the panel**. One surface grows from the trigger
|
|
18
|
+
* (width, height through grid rows, radius) and shrinks back into it. Closes on a press outside, Escape or Tab out;
|
|
19
|
+
* opening moves focus into the panel; Escape gives it back to the trigger.
|
|
20
|
+
*/
|
|
21
|
+
function Bloom(props) {
|
|
22
|
+
const { as, css, className, trigger: triggerContent, label, openTrigger, closeLabel, open: openProp, defaultOpen = false, onOpenChange, placement = "bottom-start", width = 300, role = "dialog", panelLabel, disabled, children, style, parts, partProps, classNames, ref, ...rest } = useThemeProps("Bloom", props);
|
|
23
|
+
const [open, setOpen] = useControlled({
|
|
24
|
+
value: openProp,
|
|
25
|
+
defaultValue: defaultOpen,
|
|
26
|
+
onChange: onOpenChange
|
|
27
|
+
});
|
|
28
|
+
const [closing, setClosing] = useState(false);
|
|
29
|
+
const [side, setSide] = useState(placement);
|
|
30
|
+
const [box, setBox] = useState(null);
|
|
31
|
+
const rootRef = useRef(null);
|
|
32
|
+
const surface = useRef(null);
|
|
33
|
+
const trigger = useRef(null);
|
|
34
|
+
const panel = useRef(null);
|
|
35
|
+
const wasOpen = useRef(open);
|
|
36
|
+
const boxRef = useRef(box);
|
|
37
|
+
const id = useId();
|
|
38
|
+
const Root = as ?? "div";
|
|
39
|
+
const styled = useCss("Bloom", "root", css);
|
|
40
|
+
const { part, style: partsStyle } = useParts("Bloom", {
|
|
41
|
+
parts,
|
|
42
|
+
partProps,
|
|
43
|
+
classNames
|
|
44
|
+
});
|
|
45
|
+
const root = useAnimationRoot({
|
|
46
|
+
...rest,
|
|
47
|
+
ref: useForkRef(ref, rootRef)
|
|
48
|
+
});
|
|
49
|
+
const popover = useDismiss({
|
|
50
|
+
ref: rootRef,
|
|
51
|
+
open,
|
|
52
|
+
onDismiss: () => setOpen(false),
|
|
53
|
+
fallbackFocus: () => trigger.current
|
|
54
|
+
});
|
|
55
|
+
useLayoutEffect(() => {
|
|
56
|
+
const s = surface.current;
|
|
57
|
+
const t = trigger.current;
|
|
58
|
+
if (!open || !s || !t) return;
|
|
59
|
+
const r = t.getBoundingClientRect();
|
|
60
|
+
const w = r.width + 2;
|
|
61
|
+
const h = r.height + 2;
|
|
62
|
+
const target = Math.min(width, innerWidth - 32);
|
|
63
|
+
const at = rootRef.current?.getBoundingClientRect() ?? r;
|
|
64
|
+
const panelHeight = panel.current?.scrollHeight ?? 0;
|
|
65
|
+
let [v, x] = placement.split("-");
|
|
66
|
+
if (x === "start" && at.left + target > innerWidth - VIEWPORT_MARGIN) x = "end";
|
|
67
|
+
else if (x === "end" && at.right - target < VIEWPORT_MARGIN) x = "start";
|
|
68
|
+
if (v === "bottom" && at.top + h + panelHeight > innerHeight - VIEWPORT_MARGIN && at.top - panelHeight > VIEWPORT_MARGIN) v = "top";
|
|
69
|
+
else if (v === "top" && at.top - panelHeight < VIEWPORT_MARGIN) v = "bottom";
|
|
70
|
+
setSide(`${v}-${x}`);
|
|
71
|
+
boxRef.current = {
|
|
72
|
+
w,
|
|
73
|
+
h,
|
|
74
|
+
panel: target
|
|
75
|
+
};
|
|
76
|
+
setBox(boxRef.current);
|
|
77
|
+
s.style.transition = "none";
|
|
78
|
+
s.style.width = `${w}px`;
|
|
79
|
+
s.style.borderRadius = `${h / 2}px`;
|
|
80
|
+
s.offsetWidth;
|
|
81
|
+
s.style.transition = "";
|
|
82
|
+
s.style.width = `${target}px`;
|
|
83
|
+
s.style.borderRadius = "";
|
|
84
|
+
}, [
|
|
85
|
+
open,
|
|
86
|
+
placement,
|
|
87
|
+
width
|
|
88
|
+
]);
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
const s = surface.current;
|
|
91
|
+
if (open || !wasOpen.current) {
|
|
92
|
+
wasOpen.current = open;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
wasOpen.current = open;
|
|
96
|
+
const last = boxRef.current;
|
|
97
|
+
const t = trigger.current;
|
|
98
|
+
const w = last && !label && t ? t.getBoundingClientRect().width + 2 : last?.w;
|
|
99
|
+
if (s && last && w) {
|
|
100
|
+
boxRef.current = {
|
|
101
|
+
...last,
|
|
102
|
+
w
|
|
103
|
+
};
|
|
104
|
+
setBox(boxRef.current);
|
|
105
|
+
s.style.width = `${w}px`;
|
|
106
|
+
s.style.borderRadius = `${last.h / 2}px`;
|
|
107
|
+
}
|
|
108
|
+
setClosing(true);
|
|
109
|
+
const timer = setTimeout(() => {
|
|
110
|
+
setClosing(false);
|
|
111
|
+
if (s) {
|
|
112
|
+
s.style.width = "";
|
|
113
|
+
s.style.borderRadius = "";
|
|
114
|
+
}
|
|
115
|
+
}, reduced() ? 0 : DURATION);
|
|
116
|
+
return () => clearTimeout(timer);
|
|
117
|
+
}, [open, label]);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (open) focusFirst(panel.current);
|
|
120
|
+
}, [open]);
|
|
121
|
+
const phase = open ? "open" : closing ? "closing" : "closed";
|
|
122
|
+
const floating = phase !== "closed" && box;
|
|
123
|
+
const [v, x] = side.split("-");
|
|
124
|
+
const close = (restoreFocus = true) => popover.dismiss(restoreFocus);
|
|
125
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
126
|
+
styled.style,
|
|
127
|
+
partsStyle,
|
|
128
|
+
/* @__PURE__ */ jsx(Root, {
|
|
129
|
+
className: cx("slurp-bloom", styled.className, className),
|
|
130
|
+
"data-phase": phase,
|
|
131
|
+
"data-icon": label ? "" : void 0,
|
|
132
|
+
"data-side": v,
|
|
133
|
+
"data-align": x,
|
|
134
|
+
style: {
|
|
135
|
+
...floating ? {
|
|
136
|
+
width: box.w,
|
|
137
|
+
height: box.h
|
|
138
|
+
} : null,
|
|
139
|
+
...style
|
|
140
|
+
},
|
|
141
|
+
onKeyDown: popover.containerProps.onKeyDown,
|
|
142
|
+
onBlur: popover.containerProps.onBlur,
|
|
143
|
+
...root,
|
|
144
|
+
children: part("surface", "div", {
|
|
145
|
+
ref: surface,
|
|
146
|
+
className: "slurp-bloom-surface",
|
|
147
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [part("trigger", "button", {
|
|
148
|
+
ref: trigger,
|
|
149
|
+
type: "button",
|
|
150
|
+
id: `${id}-trigger`,
|
|
151
|
+
className: "slurp-bloom-trigger",
|
|
152
|
+
"aria-label": open && closeLabel ? closeLabel : label,
|
|
153
|
+
"aria-haspopup": role === "dialog" ? "dialog" : role,
|
|
154
|
+
"aria-expanded": open,
|
|
155
|
+
"aria-controls": `${id}-panel`,
|
|
156
|
+
disabled,
|
|
157
|
+
onClick: (e) => {
|
|
158
|
+
if (open) return popover.dismiss(false);
|
|
159
|
+
popover.opened(e.currentTarget);
|
|
160
|
+
setOpen(true);
|
|
161
|
+
},
|
|
162
|
+
children: open && openTrigger !== void 0 ? openTrigger : triggerContent
|
|
163
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
164
|
+
className: "slurp-bloom-clip",
|
|
165
|
+
children: part("panel", "div", {
|
|
166
|
+
ref: panel,
|
|
167
|
+
id: `${id}-panel`,
|
|
168
|
+
role,
|
|
169
|
+
"aria-label": panelLabel,
|
|
170
|
+
"aria-labelledby": panelLabel ? void 0 : `${id}-trigger`,
|
|
171
|
+
className: "slurp-bloom-panel",
|
|
172
|
+
inert: !open,
|
|
173
|
+
style: box ? { width: box.panel - 2 } : void 0,
|
|
174
|
+
children: typeof children === "function" ? children(close) : children
|
|
175
|
+
})
|
|
176
|
+
})] })
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
export { Bloom };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=Bloom.js.map
|