@slurp-ui/react 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/AccentScope/AccentScope.d.ts +15 -0
- package/dist/AccentScope/AccentScope.js +31 -0
- package/dist/AccentScope/AccentScope.js.map +1 -0
- package/dist/AccentScope/index.d.ts +3 -0
- package/dist/AccentScope/index.js +2 -0
- package/dist/Avatar/Avatar.d.ts +17 -0
- package/dist/Avatar/Avatar.js +42 -0
- package/dist/Avatar/Avatar.js.map +1 -0
- package/dist/Avatar/index.d.ts +3 -0
- package/dist/Avatar/index.js +2 -0
- package/dist/Bento/Bento.d.ts +14 -0
- package/dist/Bento/Bento.js +42 -0
- package/dist/Bento/Bento.js.map +1 -0
- package/dist/Bento/index.d.ts +3 -0
- package/dist/Bento/index.js +2 -0
- package/dist/Bloom/Bloom.d.ts +42 -0
- package/dist/Bloom/Bloom.js +183 -0
- package/dist/Bloom/Bloom.js.map +1 -0
- package/dist/Bloom/index.d.ts +3 -0
- package/dist/Bloom/index.js +2 -0
- package/dist/Bubble/Bubble.d.ts +20 -0
- package/dist/Bubble/Bubble.js +30 -0
- package/dist/Bubble/Bubble.js.map +1 -0
- package/dist/Bubble/index.d.ts +3 -0
- package/dist/Bubble/index.js +2 -0
- package/dist/Button/Button.d.ts +26 -0
- package/dist/Button/Button.js +50 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/index.d.ts +3 -0
- package/dist/Button/index.js +2 -0
- package/dist/Card/Card.d.ts +26 -0
- package/dist/Card/Card.js +70 -0
- package/dist/Card/Card.js.map +1 -0
- package/dist/Card/index.d.ts +3 -0
- package/dist/Card/index.js +2 -0
- package/dist/Cell/Cell.d.ts +7 -0
- package/dist/Cell/Cell.js +20 -0
- package/dist/Cell/Cell.js.map +1 -0
- package/dist/Cell/index.d.ts +3 -0
- package/dist/Cell/index.js +2 -0
- package/dist/Checkbox/Checkbox.d.ts +27 -0
- package/dist/Checkbox/Checkbox.js +82 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/index.d.ts +3 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Chip/Chip.d.ts +15 -0
- package/dist/Chip/Chip.js +40 -0
- package/dist/Chip/Chip.js.map +1 -0
- package/dist/Chip/index.d.ts +3 -0
- package/dist/Chip/index.js +2 -0
- package/dist/Choice/Choice.d.ts +37 -0
- package/dist/Choice/Choice.js +134 -0
- package/dist/Choice/Choice.js.map +1 -0
- package/dist/Choice/index.d.ts +3 -0
- package/dist/Choice/index.js +2 -0
- package/dist/Count/Count.d.ts +19 -0
- package/dist/Count/Count.js +30 -0
- package/dist/Count/Count.js.map +1 -0
- package/dist/Count/index.d.ts +3 -0
- package/dist/Count/index.js +2 -0
- package/dist/Dialog/Dialog.d.ts +26 -0
- package/dist/Dialog/Dialog.js +152 -0
- package/dist/Dialog/Dialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +3 -0
- package/dist/Dialog/index.js +2 -0
- package/dist/Dock/Dock.d.ts +124 -0
- package/dist/Dock/Dock.js +359 -0
- package/dist/Dock/Dock.js.map +1 -0
- package/dist/Dock/index.d.ts +3 -0
- package/dist/Dock/index.js +2 -0
- package/dist/Empty/Empty.d.ts +17 -0
- package/dist/Empty/Empty.js +40 -0
- package/dist/Empty/Empty.js.map +1 -0
- package/dist/Empty/index.d.ts +3 -0
- package/dist/Empty/index.js +2 -0
- package/dist/Fact/Fact.d.ts +11 -0
- package/dist/Fact/Fact.js +27 -0
- package/dist/Fact/Fact.js.map +1 -0
- package/dist/Fact/index.d.ts +3 -0
- package/dist/Fact/index.js +2 -0
- package/dist/Field/Field.d.ts +44 -0
- package/dist/Field/Field.js +105 -0
- package/dist/Field/Field.js.map +1 -0
- package/dist/Field/index.d.ts +3 -0
- package/dist/Field/index.js +2 -0
- package/dist/Filters/Filters.d.ts +37 -0
- package/dist/Filters/Filters.js +64 -0
- package/dist/Filters/Filters.js.map +1 -0
- package/dist/Filters/index.d.ts +3 -0
- package/dist/Filters/index.js +2 -0
- package/dist/Flow/Flow.d.ts +17 -0
- package/dist/Flow/Flow.js +26 -0
- package/dist/Flow/Flow.js.map +1 -0
- package/dist/Flow/index.d.ts +3 -0
- package/dist/Flow/index.js +2 -0
- package/dist/Fold/Fold.d.ts +17 -0
- package/dist/Fold/Fold.js +64 -0
- package/dist/Fold/Fold.js.map +1 -0
- package/dist/Fold/index.d.ts +3 -0
- package/dist/Fold/index.js +2 -0
- package/dist/Frame/Frame.d.ts +7 -0
- package/dist/Frame/Frame.js +20 -0
- package/dist/Frame/Frame.js.map +1 -0
- package/dist/Frame/index.d.ts +3 -0
- package/dist/Frame/index.js +2 -0
- package/dist/Ground/Ground.d.ts +7 -0
- package/dist/Ground/Ground.js +19 -0
- package/dist/Ground/Ground.js.map +1 -0
- package/dist/Ground/index.d.ts +3 -0
- package/dist/Ground/index.js +2 -0
- package/dist/Hint/Hint.d.ts +21 -0
- package/dist/Hint/Hint.js +104 -0
- package/dist/Hint/Hint.js.map +1 -0
- package/dist/Hint/index.d.ts +3 -0
- package/dist/Hint/index.js +2 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +20 -0
- package/dist/Link/Link.js.map +1 -0
- package/dist/Link/index.d.ts +3 -0
- package/dist/Link/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +25 -0
- package/dist/ListRow/ListRow.js +80 -0
- package/dist/ListRow/ListRow.js.map +1 -0
- package/dist/ListRow/index.d.ts +3 -0
- package/dist/ListRow/index.js +2 -0
- package/dist/Mark/Mark.d.ts +14 -0
- package/dist/Mark/Mark.js +28 -0
- package/dist/Mark/Mark.js.map +1 -0
- package/dist/Mark/index.d.ts +3 -0
- package/dist/Mark/index.js +2 -0
- package/dist/Menu/Menu.d.ts +29 -0
- package/dist/Menu/Menu.js +64 -0
- package/dist/Menu/Menu.js.map +1 -0
- package/dist/Menu/index.d.ts +3 -0
- package/dist/Menu/index.js +2 -0
- package/dist/Notice/Notice.d.ts +31 -0
- package/dist/Notice/Notice.js +82 -0
- package/dist/Notice/Notice.js.map +1 -0
- package/dist/Notice/index.d.ts +3 -0
- package/dist/Notice/index.js +2 -0
- package/dist/Placeholder/Placeholder.d.ts +15 -0
- package/dist/Placeholder/Placeholder.js +28 -0
- package/dist/Placeholder/Placeholder.js.map +1 -0
- package/dist/Placeholder/index.d.ts +3 -0
- package/dist/Placeholder/index.js +2 -0
- package/dist/Portal/Portal.d.ts +10 -0
- package/dist/Portal/Portal.js +13 -0
- package/dist/Portal/Portal.js.map +1 -0
- package/dist/Portal/index.d.ts +3 -0
- package/dist/Portal/index.js +2 -0
- package/dist/Progress/Progress.d.ts +22 -0
- package/dist/Progress/Progress.js +65 -0
- package/dist/Progress/Progress.js.map +1 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Radio/Radio.d.ts +39 -0
- package/dist/Radio/Radio.js +118 -0
- package/dist/Radio/Radio.js.map +1 -0
- package/dist/Radio/index.d.ts +3 -0
- package/dist/Radio/index.js +2 -0
- package/dist/Range/Range.d.ts +26 -0
- package/dist/Range/Range.js +68 -0
- package/dist/Range/Range.js.map +1 -0
- package/dist/Range/index.d.ts +3 -0
- package/dist/Range/index.js +2 -0
- package/dist/ResultRow/ResultRow.d.ts +17 -0
- package/dist/ResultRow/ResultRow.js +46 -0
- package/dist/ResultRow/ResultRow.js.map +1 -0
- package/dist/ResultRow/index.d.ts +3 -0
- package/dist/ResultRow/index.js +2 -0
- package/dist/Score/Score.d.ts +16 -0
- package/dist/Score/Score.js +55 -0
- package/dist/Score/Score.js.map +1 -0
- package/dist/Score/index.d.ts +3 -0
- package/dist/Score/index.js +2 -0
- package/dist/Search/Search.d.ts +29 -0
- package/dist/Search/Search.js +94 -0
- package/dist/Search/Search.js.map +1 -0
- package/dist/Search/index.d.ts +3 -0
- package/dist/Search/index.js +2 -0
- package/dist/Segmented/Segmented.d.ts +24 -0
- package/dist/Segmented/Segmented.js +69 -0
- package/dist/Segmented/Segmented.js.map +1 -0
- package/dist/Segmented/index.d.ts +3 -0
- package/dist/Segmented/index.js +2 -0
- package/dist/Settings/Settings.d.ts +49 -0
- package/dist/Settings/Settings.js +93 -0
- package/dist/Settings/Settings.js.map +1 -0
- package/dist/Settings/index.d.ts +3 -0
- package/dist/Settings/index.js +2 -0
- package/dist/Sheet/Sheet.d.ts +7 -0
- package/dist/Sheet/Sheet.js +11 -0
- package/dist/Sheet/Sheet.js.map +1 -0
- package/dist/Sheet/index.d.ts +3 -0
- package/dist/Sheet/index.js +2 -0
- package/dist/Shelf/Shelf.d.ts +7 -0
- package/dist/Shelf/Shelf.js +23 -0
- package/dist/Shelf/Shelf.js.map +1 -0
- package/dist/Shelf/index.d.ts +3 -0
- package/dist/Shelf/index.js +2 -0
- package/dist/SlurpProvider/ColorSchemeScript.d.ts +15 -0
- package/dist/SlurpProvider/ColorSchemeScript.js +18 -0
- package/dist/SlurpProvider/ColorSchemeScript.js.map +1 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +18 -0
- package/dist/SlurpProvider/SlurpProvider.js +106 -0
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -0
- package/dist/SlurpProvider/index.d.ts +5 -0
- package/dist/SlurpProvider/index.js +5 -0
- package/dist/Stage/Stage.d.ts +14 -0
- package/dist/Stage/Stage.js +38 -0
- package/dist/Stage/Stage.js.map +1 -0
- package/dist/Stage/index.d.ts +3 -0
- package/dist/Stage/index.js +2 -0
- package/dist/Surface/Surface.d.ts +16 -0
- package/dist/Surface/Surface.js +25 -0
- package/dist/Surface/Surface.js.map +1 -0
- package/dist/Surface/index.d.ts +3 -0
- package/dist/Surface/index.js +2 -0
- package/dist/Swatch/Swatch.d.ts +31 -0
- package/dist/Swatch/Swatch.js +72 -0
- package/dist/Swatch/Swatch.js.map +1 -0
- package/dist/Swatch/index.d.ts +3 -0
- package/dist/Swatch/index.js +2 -0
- package/dist/Switch/Switch.d.ts +15 -0
- package/dist/Switch/Switch.js +62 -0
- package/dist/Switch/Switch.js.map +1 -0
- package/dist/Switch/index.d.ts +3 -0
- package/dist/Switch/index.js +2 -0
- package/dist/Tabs/Tabs.d.ts +21 -0
- package/dist/Tabs/Tabs.js +105 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/index.d.ts +3 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Text/Text.d.ts +17 -0
- package/dist/Text/Text.js +33 -0
- package/dist/Text/Text.js.map +1 -0
- package/dist/Text/index.d.ts +3 -0
- package/dist/Text/index.js +2 -0
- package/dist/Tile/Tile.d.ts +25 -0
- package/dist/Tile/Tile.js +67 -0
- package/dist/Tile/Tile.js.map +1 -0
- package/dist/Tile/index.d.ts +3 -0
- package/dist/Tile/index.js +2 -0
- package/dist/Toast/Toast.d.ts +43 -0
- package/dist/Toast/Toast.js +132 -0
- package/dist/Toast/Toast.js.map +1 -0
- package/dist/Toast/index.d.ts +3 -0
- package/dist/Toast/index.js +2 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +7 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden/index.d.ts +3 -0
- package/dist/VisuallyHidden/index.js +2 -0
- package/dist/fonts/poppins-latin-400-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-500-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-600-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-700-normal.woff2 +0 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +69 -0
- package/dist/internal/animation.js +26 -0
- package/dist/internal/animation.js.map +1 -0
- package/dist/internal/context.d.ts +14 -0
- package/dist/internal/context.js +21 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/styled.js +79 -0
- package/dist/internal/styled.js.map +1 -0
- package/dist/lib/color.d.ts +21 -0
- package/dist/lib/color.js +151 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/crumb.d.ts +9 -0
- package/dist/lib/crumb.js +69 -0
- package/dist/lib/crumb.js.map +1 -0
- package/dist/lib/css.d.ts +53 -0
- package/dist/lib/css.js +142 -0
- package/dist/lib/css.js.map +1 -0
- package/dist/lib/ground.js +15 -0
- package/dist/lib/ground.js.map +1 -0
- package/dist/lib/layout.d.ts +24 -0
- package/dist/lib/layout.js +88 -0
- package/dist/lib/layout.js.map +1 -0
- package/dist/lib/polymorphic.d.ts +28 -0
- package/dist/lib/theme.d.ts +292 -0
- package/dist/lib/theme.js +90 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/motion/AnimationGroup.d.ts +10 -0
- package/dist/motion/AnimationGroup.js +14 -0
- package/dist/motion/AnimationGroup.js.map +1 -0
- package/dist/motion/context.js +8 -0
- package/dist/motion/context.js.map +1 -0
- package/dist/motion/index.d.ts +7 -0
- package/dist/motion/index.js +7 -0
- package/dist/motion/navigation.d.ts +51 -0
- package/dist/motion/navigation.js +122 -0
- package/dist/motion/navigation.js.map +1 -0
- package/dist/motion/useAnimationTarget.d.ts +22 -0
- package/dist/motion/useAnimationTarget.js +34 -0
- package/dist/motion/useAnimationTarget.js.map +1 -0
- package/dist/motion/useSlurp.d.ts +18 -0
- package/dist/motion/useSlurp.js +48 -0
- package/dist/motion/useSlurp.js.map +1 -0
- package/dist/styles.css +3439 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens.css +178 -0
- package/dist/utils/focus.d.ts +20 -0
- package/dist/utils/focus.js +50 -0
- package/dist/utils/focus.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/src/index.js +9 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/useControlled.d.ts +14 -0
- package/dist/utils/useControlled.js +23 -0
- package/dist/utils/useControlled.js.map +1 -0
- package/dist/utils/useDismiss.d.ts +24 -0
- package/dist/utils/useDismiss.js +60 -0
- package/dist/utils/useDismiss.js.map +1 -0
- package/dist/utils/useFindInPage.d.ts +18 -0
- package/dist/utils/useFindInPage.js +51 -0
- package/dist/utils/useFindInPage.js.map +1 -0
- package/dist/utils/useForkRef.d.ts +5 -0
- package/dist/utils/useForkRef.js +33 -0
- package/dist/utils/useForkRef.js.map +1 -0
- package/dist/utils/useMediaQuery.d.ts +11 -0
- package/dist/utils/useMediaQuery.js +21 -0
- package/dist/utils/useMediaQuery.js.map +1 -0
- package/dist/utils/useRovingFocus.d.ts +17 -0
- package/dist/utils/useRovingFocus.js +26 -0
- package/dist/utils/useRovingFocus.js.map +1 -0
- package/package.json +107 -3
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bloom.js","names":[],"sources":["../../src/Bloom/Bloom.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type ElementType,\n type MouseEvent,\n type ReactNode,\n} from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\n\nexport type BloomPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';\n\nexport interface BloomOwnProps extends PartsProps<'surface' | 'trigger' | 'panel'> {\n /** Content of the trigger button (text, icon, both). */\n trigger: ReactNode;\n /**\n * Name of the trigger when it shows only an icon. An icon trigger stays in its corner when open, 44px and inset by\n * space-2 like the Dock's actions; the panel's first row (its title) sits beside it.\n */\n label?: string;\n /** Trigger content while open (an icon trigger usually becomes a close icon). */\n openTrigger?: ReactNode;\n /** Name of an icon trigger while open (\"Chiudi impostazioni\"). */\n closeLabel?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * Corner the surface grows from: `bottom-start` (default) grows right and down. It flips by itself when the panel\n * would leave the viewport.\n */\n placement?: BloomPlacement;\n /** Open width in px (never wider than the viewport minus 32px). Default 300. */\n width?: number;\n /** Role of the panel: a non-modal `dialog` (default), a `menu` or a `listbox`. */\n role?: 'dialog' | 'menu' | 'listbox';\n /** Name of the panel; default the trigger. */\n panelLabel?: string;\n disabled?: boolean;\n /** The panel. A function gets `close(restoreFocus = true)`. */\n children?: ReactNode | ((close: (restoreFocus?: boolean) => void) => ReactNode);\n}\n\nexport type BloomProps<E extends ElementType = 'div'> = PolymorphicProps<E, BloomOwnProps>;\n\n/** The Dock's motion: 0.6s, cubic-bezier(0.2, 0.8, 0.2, 1). */\nconst DURATION = 600;\nconst VIEWPORT_MARGIN = 16;\n\nconst reduced = () =>\n typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/**\n * The design system's rule for floating panels: **the button becomes the panel**. One surface grows from the trigger\n * (width, height through grid rows, radius) and shrinks back into it. Closes on a press outside, Escape or Tab out;\n * opening moves focus into the panel; Escape gives it back to the trigger.\n */\nexport function Bloom<E extends ElementType = 'div'>(props: BloomProps<E>) {\n const {\n as,\n css,\n className,\n trigger: triggerContent,\n label,\n openTrigger,\n closeLabel,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placement = 'bottom-start',\n width = 300,\n role = 'dialog',\n panelLabel,\n disabled,\n children,\n style,\n parts,\n partProps,\n classNames,\n ref,\n ...rest\n } = useThemeProps('Bloom', props as BloomProps);\n const [open, setOpen] = useControlled({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const [closing, setClosing] = useState(false);\n const [side, setSide] = useState<BloomPlacement>(placement);\n const [box, setBox] = useState<{ w: number; h: number; panel: number } | null>(null);\n const rootRef = useRef<HTMLElement>(null);\n const surface = useRef<HTMLDivElement>(null);\n const trigger = useRef<HTMLButtonElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const wasOpen = useRef(open);\n const boxRef = useRef(box);\n const id = useId();\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Bloom', 'root', css);\n const { part, style: partsStyle } = useParts('Bloom', { parts, partProps, classNames });\n const root = useAnimationRoot({ ...rest, ref: useForkRef(ref as never, rootRef) });\n\n const popover = useDismiss({\n ref: rootRef,\n open,\n onDismiss: () => setOpen(false),\n fallbackFocus: () => trigger.current,\n });\n\n // Opening: lock the trigger's box in the layout, pick the side with room, grow from the trigger size.\n useLayoutEffect(() => {\n const s = surface.current;\n const t = trigger.current;\n if (!open || !s || !t) return;\n const r = t.getBoundingClientRect();\n const w = r.width + 2;\n const h = r.height + 2;\n const target = Math.min(width, innerWidth - 2 * VIEWPORT_MARGIN);\n const at = rootRef.current?.getBoundingClientRect() ?? r;\n const panelHeight = panel.current?.scrollHeight ?? 0;\n let [v, x] = placement.split('-') as ['top' | 'bottom', 'start' | 'end'];\n if (x === 'start' && at.left + target > innerWidth - VIEWPORT_MARGIN) x = 'end';\n else if (x === 'end' && at.right - target < VIEWPORT_MARGIN) x = 'start';\n if (\n v === 'bottom' &&\n at.top + h + panelHeight > innerHeight - VIEWPORT_MARGIN &&\n at.top - panelHeight > VIEWPORT_MARGIN\n )\n v = 'top';\n else if (v === 'top' && at.top - panelHeight < VIEWPORT_MARGIN) v = 'bottom';\n setSide(`${v}-${x}`);\n boxRef.current = { w, h, panel: target };\n setBox(boxRef.current);\n // Start exactly from the trigger's box (no transition into the start values), then grow.\n s.style.transition = 'none';\n s.style.width = `${w}px`;\n s.style.borderRadius = `${h / 2}px`;\n void s.offsetWidth;\n s.style.transition = '';\n s.style.width = `${target}px`;\n s.style.borderRadius = '';\n }, [open, placement, width]);\n\n // Closing: shrink back into the trigger, then return to the flow.\n useLayoutEffect(() => {\n const s = surface.current;\n if (open || !wasOpen.current) {\n wasOpen.current = open;\n return;\n }\n wasOpen.current = open;\n const last = boxRef.current;\n // The trigger's label may have changed while open (a Choice shows the new value): shrink to its size now.\n const t = trigger.current;\n const w = last && !label && t ? t.getBoundingClientRect().width + 2 : last?.w;\n if (s && last && w) {\n boxRef.current = { ...last, w };\n setBox(boxRef.current);\n s.style.width = `${w}px`;\n s.style.borderRadius = `${last.h / 2}px`;\n }\n setClosing(true);\n const timer = setTimeout(\n () => {\n setClosing(false);\n if (s) {\n s.style.width = '';\n s.style.borderRadius = '';\n }\n },\n reduced() ? 0 : DURATION,\n );\n return () => clearTimeout(timer);\n }, [open, label]);\n\n useEffect(() => {\n if (open) focusFirst(panel.current);\n }, [open]);\n\n const phase = open ? 'open' : closing ? 'closing' : 'closed';\n const floating = phase !== 'closed' && box;\n const [v, x] = side.split('-');\n const close = (restoreFocus = true) => popover.dismiss(restoreFocus);\n\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-bloom', styled.className, className)}\n data-phase={phase}\n data-icon={label ? '' : undefined}\n data-side={v}\n data-align={x}\n style={\n {\n ...(floating ? { width: box.w, height: box.h } : null),\n ...style,\n } as CSSProperties\n }\n onKeyDown={popover.containerProps.onKeyDown}\n onBlur={popover.containerProps.onBlur}\n {...root}\n >\n {part('surface', 'div', {\n ref: surface,\n className: 'slurp-bloom-surface',\n children: (\n <>\n {part('trigger', 'button', {\n ref: trigger,\n type: 'button',\n id: `${id}-trigger`,\n className: 'slurp-bloom-trigger',\n 'aria-label': open && closeLabel ? closeLabel : label,\n 'aria-haspopup': role === 'dialog' ? 'dialog' : role,\n 'aria-expanded': open,\n 'aria-controls': `${id}-panel`,\n disabled,\n onClick: (e: MouseEvent<HTMLButtonElement>) => {\n if (open) return popover.dismiss(false);\n popover.opened(e.currentTarget);\n setOpen(true);\n },\n children: open && openTrigger !== undefined ? openTrigger : triggerContent,\n })}\n <div className=\"slurp-bloom-clip\">\n {part('panel', 'div', {\n ref: panel,\n id: `${id}-panel`,\n role,\n 'aria-label': panelLabel,\n 'aria-labelledby': panelLabel ? undefined : `${id}-trigger`,\n className: 'slurp-bloom-panel',\n inert: !open,\n style: box ? { width: box.panel - 2 } : undefined,\n children: typeof children === 'function' ? children(close) : children,\n })}\n </div>\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { Appearance, ButtonTone, ControlSize } from "../Button/Button.js";
|
|
4
|
+
import { ElementType, ReactNode } from "react";
|
|
5
|
+
export interface BubbleOwnProps {
|
|
6
|
+
/** Accessible name: an icon-only button must say what it does (also the tooltip text, if any). */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The icon. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Default `plain`. */
|
|
11
|
+
appearance?: Appearance;
|
|
12
|
+
/** Default `neutral`. */
|
|
13
|
+
tone?: ButtonTone;
|
|
14
|
+
/** Default `md` (48px). */
|
|
15
|
+
size?: ControlSize;
|
|
16
|
+
}
|
|
17
|
+
export type BubbleProps<E extends ElementType = 'button'> = PolymorphicProps<E, BubbleOwnProps>;
|
|
18
|
+
/** Round icon-only button. In a Bloom it is the trigger that grows into its panel. */
|
|
19
|
+
export declare function Bubble<E extends ElementType = 'button'>(props: BubbleProps<E>): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=Bubble.d.ts.map
|