@slurp-ui/react 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/AccentScope/AccentScope.d.ts +15 -0
- package/dist/AccentScope/AccentScope.js +31 -0
- package/dist/AccentScope/AccentScope.js.map +1 -0
- package/dist/AccentScope/index.d.ts +3 -0
- package/dist/AccentScope/index.js +2 -0
- package/dist/Avatar/Avatar.d.ts +17 -0
- package/dist/Avatar/Avatar.js +42 -0
- package/dist/Avatar/Avatar.js.map +1 -0
- package/dist/Avatar/index.d.ts +3 -0
- package/dist/Avatar/index.js +2 -0
- package/dist/Bento/Bento.d.ts +14 -0
- package/dist/Bento/Bento.js +42 -0
- package/dist/Bento/Bento.js.map +1 -0
- package/dist/Bento/index.d.ts +3 -0
- package/dist/Bento/index.js +2 -0
- package/dist/Bloom/Bloom.d.ts +42 -0
- package/dist/Bloom/Bloom.js +183 -0
- package/dist/Bloom/Bloom.js.map +1 -0
- package/dist/Bloom/index.d.ts +3 -0
- package/dist/Bloom/index.js +2 -0
- package/dist/Bubble/Bubble.d.ts +20 -0
- package/dist/Bubble/Bubble.js +30 -0
- package/dist/Bubble/Bubble.js.map +1 -0
- package/dist/Bubble/index.d.ts +3 -0
- package/dist/Bubble/index.js +2 -0
- package/dist/Button/Button.d.ts +26 -0
- package/dist/Button/Button.js +50 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/index.d.ts +3 -0
- package/dist/Button/index.js +2 -0
- package/dist/Card/Card.d.ts +26 -0
- package/dist/Card/Card.js +70 -0
- package/dist/Card/Card.js.map +1 -0
- package/dist/Card/index.d.ts +3 -0
- package/dist/Card/index.js +2 -0
- package/dist/Cell/Cell.d.ts +7 -0
- package/dist/Cell/Cell.js +20 -0
- package/dist/Cell/Cell.js.map +1 -0
- package/dist/Cell/index.d.ts +3 -0
- package/dist/Cell/index.js +2 -0
- package/dist/Checkbox/Checkbox.d.ts +27 -0
- package/dist/Checkbox/Checkbox.js +82 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/index.d.ts +3 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Chip/Chip.d.ts +15 -0
- package/dist/Chip/Chip.js +40 -0
- package/dist/Chip/Chip.js.map +1 -0
- package/dist/Chip/index.d.ts +3 -0
- package/dist/Chip/index.js +2 -0
- package/dist/Choice/Choice.d.ts +37 -0
- package/dist/Choice/Choice.js +134 -0
- package/dist/Choice/Choice.js.map +1 -0
- package/dist/Choice/index.d.ts +3 -0
- package/dist/Choice/index.js +2 -0
- package/dist/Count/Count.d.ts +19 -0
- package/dist/Count/Count.js +30 -0
- package/dist/Count/Count.js.map +1 -0
- package/dist/Count/index.d.ts +3 -0
- package/dist/Count/index.js +2 -0
- package/dist/Dialog/Dialog.d.ts +26 -0
- package/dist/Dialog/Dialog.js +152 -0
- package/dist/Dialog/Dialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +3 -0
- package/dist/Dialog/index.js +2 -0
- package/dist/Dock/Dock.d.ts +124 -0
- package/dist/Dock/Dock.js +359 -0
- package/dist/Dock/Dock.js.map +1 -0
- package/dist/Dock/index.d.ts +3 -0
- package/dist/Dock/index.js +2 -0
- package/dist/Empty/Empty.d.ts +17 -0
- package/dist/Empty/Empty.js +40 -0
- package/dist/Empty/Empty.js.map +1 -0
- package/dist/Empty/index.d.ts +3 -0
- package/dist/Empty/index.js +2 -0
- package/dist/Fact/Fact.d.ts +11 -0
- package/dist/Fact/Fact.js +27 -0
- package/dist/Fact/Fact.js.map +1 -0
- package/dist/Fact/index.d.ts +3 -0
- package/dist/Fact/index.js +2 -0
- package/dist/Field/Field.d.ts +44 -0
- package/dist/Field/Field.js +105 -0
- package/dist/Field/Field.js.map +1 -0
- package/dist/Field/index.d.ts +3 -0
- package/dist/Field/index.js +2 -0
- package/dist/Filters/Filters.d.ts +37 -0
- package/dist/Filters/Filters.js +64 -0
- package/dist/Filters/Filters.js.map +1 -0
- package/dist/Filters/index.d.ts +3 -0
- package/dist/Filters/index.js +2 -0
- package/dist/Flow/Flow.d.ts +17 -0
- package/dist/Flow/Flow.js +26 -0
- package/dist/Flow/Flow.js.map +1 -0
- package/dist/Flow/index.d.ts +3 -0
- package/dist/Flow/index.js +2 -0
- package/dist/Fold/Fold.d.ts +17 -0
- package/dist/Fold/Fold.js +64 -0
- package/dist/Fold/Fold.js.map +1 -0
- package/dist/Fold/index.d.ts +3 -0
- package/dist/Fold/index.js +2 -0
- package/dist/Frame/Frame.d.ts +7 -0
- package/dist/Frame/Frame.js +20 -0
- package/dist/Frame/Frame.js.map +1 -0
- package/dist/Frame/index.d.ts +3 -0
- package/dist/Frame/index.js +2 -0
- package/dist/Ground/Ground.d.ts +7 -0
- package/dist/Ground/Ground.js +19 -0
- package/dist/Ground/Ground.js.map +1 -0
- package/dist/Ground/index.d.ts +3 -0
- package/dist/Ground/index.js +2 -0
- package/dist/Hint/Hint.d.ts +21 -0
- package/dist/Hint/Hint.js +104 -0
- package/dist/Hint/Hint.js.map +1 -0
- package/dist/Hint/index.d.ts +3 -0
- package/dist/Hint/index.js +2 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +20 -0
- package/dist/Link/Link.js.map +1 -0
- package/dist/Link/index.d.ts +3 -0
- package/dist/Link/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +25 -0
- package/dist/ListRow/ListRow.js +80 -0
- package/dist/ListRow/ListRow.js.map +1 -0
- package/dist/ListRow/index.d.ts +3 -0
- package/dist/ListRow/index.js +2 -0
- package/dist/Mark/Mark.d.ts +14 -0
- package/dist/Mark/Mark.js +28 -0
- package/dist/Mark/Mark.js.map +1 -0
- package/dist/Mark/index.d.ts +3 -0
- package/dist/Mark/index.js +2 -0
- package/dist/Menu/Menu.d.ts +29 -0
- package/dist/Menu/Menu.js +64 -0
- package/dist/Menu/Menu.js.map +1 -0
- package/dist/Menu/index.d.ts +3 -0
- package/dist/Menu/index.js +2 -0
- package/dist/Notice/Notice.d.ts +31 -0
- package/dist/Notice/Notice.js +82 -0
- package/dist/Notice/Notice.js.map +1 -0
- package/dist/Notice/index.d.ts +3 -0
- package/dist/Notice/index.js +2 -0
- package/dist/Placeholder/Placeholder.d.ts +15 -0
- package/dist/Placeholder/Placeholder.js +28 -0
- package/dist/Placeholder/Placeholder.js.map +1 -0
- package/dist/Placeholder/index.d.ts +3 -0
- package/dist/Placeholder/index.js +2 -0
- package/dist/Portal/Portal.d.ts +10 -0
- package/dist/Portal/Portal.js +13 -0
- package/dist/Portal/Portal.js.map +1 -0
- package/dist/Portal/index.d.ts +3 -0
- package/dist/Portal/index.js +2 -0
- package/dist/Progress/Progress.d.ts +22 -0
- package/dist/Progress/Progress.js +65 -0
- package/dist/Progress/Progress.js.map +1 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Radio/Radio.d.ts +39 -0
- package/dist/Radio/Radio.js +118 -0
- package/dist/Radio/Radio.js.map +1 -0
- package/dist/Radio/index.d.ts +3 -0
- package/dist/Radio/index.js +2 -0
- package/dist/Range/Range.d.ts +26 -0
- package/dist/Range/Range.js +68 -0
- package/dist/Range/Range.js.map +1 -0
- package/dist/Range/index.d.ts +3 -0
- package/dist/Range/index.js +2 -0
- package/dist/ResultRow/ResultRow.d.ts +17 -0
- package/dist/ResultRow/ResultRow.js +46 -0
- package/dist/ResultRow/ResultRow.js.map +1 -0
- package/dist/ResultRow/index.d.ts +3 -0
- package/dist/ResultRow/index.js +2 -0
- package/dist/Score/Score.d.ts +16 -0
- package/dist/Score/Score.js +55 -0
- package/dist/Score/Score.js.map +1 -0
- package/dist/Score/index.d.ts +3 -0
- package/dist/Score/index.js +2 -0
- package/dist/Search/Search.d.ts +29 -0
- package/dist/Search/Search.js +94 -0
- package/dist/Search/Search.js.map +1 -0
- package/dist/Search/index.d.ts +3 -0
- package/dist/Search/index.js +2 -0
- package/dist/Segmented/Segmented.d.ts +24 -0
- package/dist/Segmented/Segmented.js +69 -0
- package/dist/Segmented/Segmented.js.map +1 -0
- package/dist/Segmented/index.d.ts +3 -0
- package/dist/Segmented/index.js +2 -0
- package/dist/Settings/Settings.d.ts +49 -0
- package/dist/Settings/Settings.js +93 -0
- package/dist/Settings/Settings.js.map +1 -0
- package/dist/Settings/index.d.ts +3 -0
- package/dist/Settings/index.js +2 -0
- package/dist/Sheet/Sheet.d.ts +7 -0
- package/dist/Sheet/Sheet.js +11 -0
- package/dist/Sheet/Sheet.js.map +1 -0
- package/dist/Sheet/index.d.ts +3 -0
- package/dist/Sheet/index.js +2 -0
- package/dist/Shelf/Shelf.d.ts +7 -0
- package/dist/Shelf/Shelf.js +23 -0
- package/dist/Shelf/Shelf.js.map +1 -0
- package/dist/Shelf/index.d.ts +3 -0
- package/dist/Shelf/index.js +2 -0
- package/dist/SlurpProvider/ColorSchemeScript.d.ts +15 -0
- package/dist/SlurpProvider/ColorSchemeScript.js +18 -0
- package/dist/SlurpProvider/ColorSchemeScript.js.map +1 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +18 -0
- package/dist/SlurpProvider/SlurpProvider.js +106 -0
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -0
- package/dist/SlurpProvider/index.d.ts +5 -0
- package/dist/SlurpProvider/index.js +5 -0
- package/dist/Stage/Stage.d.ts +14 -0
- package/dist/Stage/Stage.js +38 -0
- package/dist/Stage/Stage.js.map +1 -0
- package/dist/Stage/index.d.ts +3 -0
- package/dist/Stage/index.js +2 -0
- package/dist/Surface/Surface.d.ts +16 -0
- package/dist/Surface/Surface.js +25 -0
- package/dist/Surface/Surface.js.map +1 -0
- package/dist/Surface/index.d.ts +3 -0
- package/dist/Surface/index.js +2 -0
- package/dist/Swatch/Swatch.d.ts +31 -0
- package/dist/Swatch/Swatch.js +72 -0
- package/dist/Swatch/Swatch.js.map +1 -0
- package/dist/Swatch/index.d.ts +3 -0
- package/dist/Swatch/index.js +2 -0
- package/dist/Switch/Switch.d.ts +15 -0
- package/dist/Switch/Switch.js +62 -0
- package/dist/Switch/Switch.js.map +1 -0
- package/dist/Switch/index.d.ts +3 -0
- package/dist/Switch/index.js +2 -0
- package/dist/Tabs/Tabs.d.ts +21 -0
- package/dist/Tabs/Tabs.js +105 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/index.d.ts +3 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Text/Text.d.ts +17 -0
- package/dist/Text/Text.js +33 -0
- package/dist/Text/Text.js.map +1 -0
- package/dist/Text/index.d.ts +3 -0
- package/dist/Text/index.js +2 -0
- package/dist/Tile/Tile.d.ts +25 -0
- package/dist/Tile/Tile.js +67 -0
- package/dist/Tile/Tile.js.map +1 -0
- package/dist/Tile/index.d.ts +3 -0
- package/dist/Tile/index.js +2 -0
- package/dist/Toast/Toast.d.ts +43 -0
- package/dist/Toast/Toast.js +132 -0
- package/dist/Toast/Toast.js.map +1 -0
- package/dist/Toast/index.d.ts +3 -0
- package/dist/Toast/index.js +2 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +7 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden/index.d.ts +3 -0
- package/dist/VisuallyHidden/index.js +2 -0
- package/dist/fonts/poppins-latin-400-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-500-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-600-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-700-normal.woff2 +0 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +69 -0
- package/dist/internal/animation.js +26 -0
- package/dist/internal/animation.js.map +1 -0
- package/dist/internal/context.d.ts +14 -0
- package/dist/internal/context.js +21 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/styled.js +79 -0
- package/dist/internal/styled.js.map +1 -0
- package/dist/lib/color.d.ts +21 -0
- package/dist/lib/color.js +151 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/crumb.d.ts +9 -0
- package/dist/lib/crumb.js +69 -0
- package/dist/lib/crumb.js.map +1 -0
- package/dist/lib/css.d.ts +53 -0
- package/dist/lib/css.js +142 -0
- package/dist/lib/css.js.map +1 -0
- package/dist/lib/ground.js +15 -0
- package/dist/lib/ground.js.map +1 -0
- package/dist/lib/layout.d.ts +24 -0
- package/dist/lib/layout.js +88 -0
- package/dist/lib/layout.js.map +1 -0
- package/dist/lib/polymorphic.d.ts +28 -0
- package/dist/lib/theme.d.ts +292 -0
- package/dist/lib/theme.js +90 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/motion/AnimationGroup.d.ts +10 -0
- package/dist/motion/AnimationGroup.js +14 -0
- package/dist/motion/AnimationGroup.js.map +1 -0
- package/dist/motion/context.js +8 -0
- package/dist/motion/context.js.map +1 -0
- package/dist/motion/index.d.ts +7 -0
- package/dist/motion/index.js +7 -0
- package/dist/motion/navigation.d.ts +51 -0
- package/dist/motion/navigation.js +122 -0
- package/dist/motion/navigation.js.map +1 -0
- package/dist/motion/useAnimationTarget.d.ts +22 -0
- package/dist/motion/useAnimationTarget.js +34 -0
- package/dist/motion/useAnimationTarget.js.map +1 -0
- package/dist/motion/useSlurp.d.ts +18 -0
- package/dist/motion/useSlurp.js +48 -0
- package/dist/motion/useSlurp.js.map +1 -0
- package/dist/styles.css +3439 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens.css +178 -0
- package/dist/utils/focus.d.ts +20 -0
- package/dist/utils/focus.js +50 -0
- package/dist/utils/focus.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/src/index.js +9 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/useControlled.d.ts +14 -0
- package/dist/utils/useControlled.js +23 -0
- package/dist/utils/useControlled.js.map +1 -0
- package/dist/utils/useDismiss.d.ts +24 -0
- package/dist/utils/useDismiss.js +60 -0
- package/dist/utils/useDismiss.js.map +1 -0
- package/dist/utils/useFindInPage.d.ts +18 -0
- package/dist/utils/useFindInPage.js +51 -0
- package/dist/utils/useFindInPage.js.map +1 -0
- package/dist/utils/useForkRef.d.ts +5 -0
- package/dist/utils/useForkRef.js +33 -0
- package/dist/utils/useForkRef.js.map +1 -0
- package/dist/utils/useMediaQuery.d.ts +11 -0
- package/dist/utils/useMediaQuery.js +21 -0
- package/dist/utils/useMediaQuery.js.map +1 -0
- package/dist/utils/useRovingFocus.d.ts +17 -0
- package/dist/utils/useRovingFocus.js +26 -0
- package/dist/utils/useRovingFocus.js.map +1 -0
- package/package.json +108 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
import { FontToken } from "@slurp-ui/tokens";
|
|
5
|
+
export type TextTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
6
|
+
export interface TextOwnProps {
|
|
7
|
+
/** Type style of the design system. Default `body`. Display styles shrink on phones by themselves. */
|
|
8
|
+
font?: FontToken;
|
|
9
|
+
/** Colour role: `accent` uses accent-ink; status tones are for text that also carries an icon or a word. */
|
|
10
|
+
tone?: TextTone;
|
|
11
|
+
/** Secondary text (`muted`). Default for `caption` and `eyebrow`. */
|
|
12
|
+
muted?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type TextProps<E extends ElementType = 'p'> = PolymorphicProps<E, TextOwnProps>;
|
|
15
|
+
/** Text in one of the type styles. The element follows the style (`display-*` → h1 … `body` → p), `as` changes it. */
|
|
16
|
+
export declare function Text<E extends ElementType = 'p'>(props: TextProps<E>): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Text/Text.tsx
|
|
7
|
+
const ELEMENT = {
|
|
8
|
+
"display-xl": "h1",
|
|
9
|
+
"display-l": "h1",
|
|
10
|
+
"title-xl": "h2",
|
|
11
|
+
"title-l": "h3",
|
|
12
|
+
"title-s": "h4",
|
|
13
|
+
label: "span",
|
|
14
|
+
caption: "span",
|
|
15
|
+
eyebrow: "span"
|
|
16
|
+
};
|
|
17
|
+
/** Text in one of the type styles. The element follows the style (`display-*` → h1 … `body` → p), `as` changes it. */
|
|
18
|
+
function Text(props) {
|
|
19
|
+
const { as, css, className, font = "body", tone, muted, ...rest } = useThemeProps("Text", props);
|
|
20
|
+
const Root = as ?? ELEMENT[font] ?? "p";
|
|
21
|
+
const styled = useCss("Text", "root", css);
|
|
22
|
+
const root = useAnimationRoot(rest);
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
24
|
+
className: cx("slurp-text", styled.className, className),
|
|
25
|
+
"data-font": font,
|
|
26
|
+
"data-tone": tone,
|
|
27
|
+
"data-muted": muted === void 0 ? void 0 : String(muted),
|
|
28
|
+
...root
|
|
29
|
+
})] });
|
|
30
|
+
}
|
|
31
|
+
export { Text };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.js","names":[],"sources":["../../src/Text/Text.tsx"],"sourcesContent":["import type { FontToken } from '@slurp-ui/tokens';\nimport { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport type TextTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';\n\nexport interface TextOwnProps {\n /** Type style of the design system. Default `body`. Display styles shrink on phones by themselves. */\n font?: FontToken;\n /** Colour role: `accent` uses accent-ink; status tones are for text that also carries an icon or a word. */\n tone?: TextTone;\n /** Secondary text (`muted`). Default for `caption` and `eyebrow`. */\n muted?: boolean;\n}\n\nexport type TextProps<E extends ElementType = 'p'> = PolymorphicProps<E, TextOwnProps>;\n\nconst ELEMENT: Partial<Record<FontToken, ElementType>> = {\n 'display-xl': 'h1',\n 'display-l': 'h1',\n 'title-xl': 'h2',\n 'title-l': 'h3',\n 'title-s': 'h4',\n label: 'span',\n caption: 'span',\n eyebrow: 'span',\n};\n\n/** Text in one of the type styles. The element follows the style (`display-*` → h1 … `body` → p), `as` changes it. */\nexport function Text<E extends ElementType = 'p'>(props: TextProps<E>) {\n const {\n as,\n css,\n className,\n font = 'body',\n tone,\n muted,\n ...rest\n } = useThemeProps('Text', props as TextProps);\n const Root = (as ?? ELEMENT[font] ?? 'p') as ElementType;\n const styled = useCss('Text', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-text', styled.className, className)}\n data-font={font}\n data-tone={tone}\n data-muted={muted === undefined ? undefined : String(muted)}\n {...root}\n />\n </>\n );\n}\n"],"mappings":";;;;;;AAqBA,MAAM,UAAmD;CACvD,cAAc;CACd,aAAa;CACb,YAAY;CACZ,WAAW;CACX,WAAW;CACX,OAAO;CACP,SAAS;CACT,SAAS;AACX;;AAGA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EACJ,IACA,KACA,WACA,OAAO,QACP,MACA,OACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,OAAQ,MAAM,QAAQ,SAAS;CACrC,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EACvD,aAAW;EACX,aAAW;EACX,cAAY,UAAU,KAAA,IAAY,KAAA,IAAY,OAAO,KAAK;EAC1D,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface TileOwnProps extends PartsProps<'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media'> {
|
|
5
|
+
/** The section's name. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
subtitle?: ReactNode;
|
|
8
|
+
/** Small pill at the top (a count, "Novità"). */
|
|
9
|
+
badge?: ReactNode;
|
|
10
|
+
/** The section's colour: the tile is tinted by it (and a collapse saturates toward it). Any hex. */
|
|
11
|
+
color: string;
|
|
12
|
+
/** `large` for the first tiles of a Bento (bigger media); Bento sets it with `layout="auto"`. */
|
|
13
|
+
size?: 'large' | 'small';
|
|
14
|
+
/** Inside `<Bento layout="auto">`: how big the section is (how many entries), shaping its span. */
|
|
15
|
+
weight?: number;
|
|
16
|
+
/** Illustration or photo, decorative. */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export type TileProps<E extends ElementType = 'button'> = PolymorphicProps<E, TileOwnProps>;
|
|
20
|
+
/**
|
|
21
|
+
* A cell of the entry grid, tinted by its own colour, with a slow drifting blob (moved only with `transform`).
|
|
22
|
+
* Text and media scale with the tile (container units).
|
|
23
|
+
*/
|
|
24
|
+
export declare function Tile<E extends ElementType = 'button'>(props: TileProps<E>): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=Tile.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { onColor } from "../lib/color.js";
|
|
3
|
+
import { cx } from "../utils/src/index.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { Fragment, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Tile/Tile.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A cell of the entry grid, tinted by its own colour, with a slow drifting blob (moved only with `transform`).
|
|
10
|
+
* Text and media scale with the tile (container units).
|
|
11
|
+
*/
|
|
12
|
+
function Tile(props) {
|
|
13
|
+
const { as, css, className, title, subtitle, badge, color, size = "small", weight: _weight, children, style, parts, partProps, classNames, ...rest } = useThemeProps("Tile", props);
|
|
14
|
+
const Root = as ?? "button";
|
|
15
|
+
const styled = useCss("Tile", "root", css);
|
|
16
|
+
const { part, style: partsStyle } = useParts("Tile", {
|
|
17
|
+
parts,
|
|
18
|
+
partProps,
|
|
19
|
+
classNames
|
|
20
|
+
});
|
|
21
|
+
const root = useAnimationRoot(rest);
|
|
22
|
+
const vars = {
|
|
23
|
+
"--slurp-tile-color": color,
|
|
24
|
+
"--slurp-tile-on": /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : "var(--slurp-fg)",
|
|
25
|
+
"--slurp-animation-tint": color,
|
|
26
|
+
...style
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
styled.style,
|
|
30
|
+
partsStyle,
|
|
31
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
32
|
+
className: cx("slurp-tile", styled.className, className),
|
|
33
|
+
"data-size": size,
|
|
34
|
+
style: vars,
|
|
35
|
+
...Root === "button" ? { type: "button" } : null,
|
|
36
|
+
...root,
|
|
37
|
+
children: [
|
|
38
|
+
part("blob", "span", {
|
|
39
|
+
className: "slurp-tile-blob",
|
|
40
|
+
"aria-hidden": true
|
|
41
|
+
}),
|
|
42
|
+
part("text", "span", {
|
|
43
|
+
className: "slurp-tile-text",
|
|
44
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [part("title", "span", {
|
|
45
|
+
className: "slurp-tile-title",
|
|
46
|
+
children: title
|
|
47
|
+
}), subtitle != null && part("subtitle", "span", {
|
|
48
|
+
className: "slurp-tile-subtitle",
|
|
49
|
+
children: subtitle
|
|
50
|
+
})] })
|
|
51
|
+
}),
|
|
52
|
+
badge != null && part("badge", "span", {
|
|
53
|
+
className: "slurp-tile-badge",
|
|
54
|
+
children: badge
|
|
55
|
+
}),
|
|
56
|
+
children != null && part("media", "span", {
|
|
57
|
+
className: "slurp-tile-media",
|
|
58
|
+
"aria-hidden": true,
|
|
59
|
+
children
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
export { Tile };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=Tile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tile.js","names":[],"sources":["../../src/Tile/Tile.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport { onColor } from '../lib/color';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface TileOwnProps extends PartsProps<\n 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media'\n> {\n /** The section's name. */\n title: ReactNode;\n subtitle?: ReactNode;\n /** Small pill at the top (a count, \"Novità\"). */\n badge?: ReactNode;\n /** The section's colour: the tile is tinted by it (and a collapse saturates toward it). Any hex. */\n color: string;\n /** `large` for the first tiles of a Bento (bigger media); Bento sets it with `layout=\"auto\"`. */\n size?: 'large' | 'small';\n /** Inside `<Bento layout=\"auto\">`: how big the section is (how many entries), shaping its span. */\n weight?: number;\n /** Illustration or photo, decorative. */\n children?: ReactNode;\n}\n\nexport type TileProps<E extends ElementType = 'button'> = PolymorphicProps<E, TileOwnProps>;\n\n/**\n * A cell of the entry grid, tinted by its own colour, with a slow drifting blob (moved only with `transform`).\n * Text and media scale with the tile (container units).\n */\nexport function Tile<E extends ElementType = 'button'>(props: TileProps<E>) {\n const {\n as,\n css,\n className,\n title,\n subtitle,\n badge,\n color,\n size = 'small',\n weight: _weight,\n children,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Tile', props as TileProps);\n const Root = (as ?? 'button') as ElementType;\n const styled = useCss('Tile', 'root', css);\n const { part, style: partsStyle } = useParts('Tile', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const vars = {\n '--slurp-tile-color': color,\n '--slurp-tile-on': /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : 'var(--slurp-fg)',\n '--slurp-animation-tint': color,\n ...style,\n } as CSSProperties;\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-tile', styled.className, className)}\n data-size={size}\n style={vars}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {part('blob', 'span', { className: 'slurp-tile-blob', 'aria-hidden': true })}\n {part('text', 'span', {\n className: 'slurp-tile-text',\n children: (\n <>\n {part('title', 'span', { className: 'slurp-tile-title', children: title })}\n {subtitle != null &&\n part('subtitle', 'span', { className: 'slurp-tile-subtitle', children: subtitle })}\n </>\n ),\n })}\n {badge != null && part('badge', 'span', { className: 'slurp-tile-badge', children: badge })}\n {children != null &&\n part('media', 'span', { className: 'slurp-tile-media', 'aria-hidden': true, children })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,KAAuC,OAAqB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,OACA,UACA,OACA,OACA,OAAO,SACP,QAAQ,SACR,UACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,EAAE,MAAM,OAAO,eAAe,SAAS,QAAQ;EAAE;EAAO;EAAW;CAAW,CAAC;CACrF,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,OAAO;EACX,sBAAsB;EACtB,mBAAmB,kBAAkB,KAAK,KAAK,IAAI,QAAQ,KAAK,IAAI;EACpE,0BAA0B;EAC1B,GAAG;CACL;CACA,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACvD,aAAW;GACX,OAAO;GACP,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;GAC9C,GAAI;GALN,UAAA;IAOG,KAAK,QAAQ,QAAQ;KAAE,WAAW;KAAmB,eAAe;IAAK,CAAC;IAC1E,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,UACE,qBAAA,UAAA,EAAA,UAAA,CACG,KAAK,SAAS,QAAQ;MAAE,WAAW;MAAoB,UAAU;KAAM,CAAC,GACxE,YAAY,QACX,KAAK,YAAY,QAAQ;MAAE,WAAW;MAAuB,UAAU;KAAS,CAAC,CACnF,EAAA,CAAA;IAEN,CAAC;IACA,SAAS,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;IACzF,YAAY,QACX,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,eAAe;KAAM;IAAS,CAAC;GACpF;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import { StatusTone } from "../Notice/Notice.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
export interface ToastOptions {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
/** Default `neutral`: icon + text, never colour alone. */
|
|
8
|
+
tone?: StatusTone;
|
|
9
|
+
/** One action ("Annulla"). */
|
|
10
|
+
action?: {
|
|
11
|
+
label: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
/** ms before it goes away; paused while hovered or focused. `Infinity` keeps it. Default 5000. */
|
|
15
|
+
duration?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ToastLabels {
|
|
18
|
+
/** Name of the region that holds the toasts. */
|
|
19
|
+
region: string;
|
|
20
|
+
/** Name of each close button. */
|
|
21
|
+
dismiss: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const TOAST_LABELS: ToastLabels;
|
|
24
|
+
interface ToastApi {
|
|
25
|
+
/** Shows a toast; returns its id. */
|
|
26
|
+
toast: (options: ToastOptions) => number;
|
|
27
|
+
dismiss: (id: number) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface ToastProviderProps {
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
labels?: Partial<ToastLabels>;
|
|
32
|
+
/** At most this many on screen; the oldest go first. Default 3. */
|
|
33
|
+
limit?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Short confirmations at the bottom of the screen, above the Dock (`--slurp-toast-offset`). The list is a polite live
|
|
37
|
+
* region, present from the start so new toasts are announced.
|
|
38
|
+
*/
|
|
39
|
+
export declare function ToastProvider({ children, labels: labelsProp, limit }: ToastProviderProps): import("react").JSX.Element;
|
|
40
|
+
/** `toast(options)` and `dismiss(id)`, from the nearest ToastProvider. */
|
|
41
|
+
export declare function useToast(): ToastApi;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { Button } from "../Button/Button.js";
|
|
4
|
+
import { Bubble } from "../Bubble/Bubble.js";
|
|
5
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from "@slurp-ui/icons";
|
|
8
|
+
// src/Toast/Toast.tsx
|
|
9
|
+
const TOAST_LABELS = {
|
|
10
|
+
region: "Notifiche",
|
|
11
|
+
dismiss: "Chiudi notifica"
|
|
12
|
+
};
|
|
13
|
+
const ToastContext = createContext(null);
|
|
14
|
+
const ICONS = {
|
|
15
|
+
neutral: InfoIcon,
|
|
16
|
+
success: SuccessIcon,
|
|
17
|
+
warning: WarningIcon,
|
|
18
|
+
danger: ErrorIcon
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Short confirmations at the bottom of the screen, above the Dock (`--slurp-toast-offset`). The list is a polite live
|
|
22
|
+
* region, present from the start so new toasts are announced.
|
|
23
|
+
*/
|
|
24
|
+
function ToastProvider({ children, labels: labelsProp, limit = 3 }) {
|
|
25
|
+
const labels = {
|
|
26
|
+
...TOAST_LABELS,
|
|
27
|
+
...labelsProp
|
|
28
|
+
};
|
|
29
|
+
const [items, setItems] = useState([]);
|
|
30
|
+
const next = useRef(1);
|
|
31
|
+
const dismiss = useCallback((id) => setItems((all) => all.filter((t) => t.id !== id)), []);
|
|
32
|
+
const toast = useCallback((options) => {
|
|
33
|
+
const id = next.current++;
|
|
34
|
+
setItems((all) => [...all, {
|
|
35
|
+
...options,
|
|
36
|
+
id
|
|
37
|
+
}].slice(-limit));
|
|
38
|
+
return id;
|
|
39
|
+
}, [limit]);
|
|
40
|
+
const api = useMemo(() => ({
|
|
41
|
+
toast,
|
|
42
|
+
dismiss
|
|
43
|
+
}), [toast, dismiss]);
|
|
44
|
+
return /* @__PURE__ */ jsxs(ToastContext, {
|
|
45
|
+
value: api,
|
|
46
|
+
children: [children, /* @__PURE__ */ jsx("section", {
|
|
47
|
+
className: "slurp-toasts",
|
|
48
|
+
"aria-label": labels.region,
|
|
49
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
50
|
+
"aria-live": "polite",
|
|
51
|
+
"aria-relevant": "additions text",
|
|
52
|
+
className: "slurp-toasts-list",
|
|
53
|
+
children: items.map((t) => /* @__PURE__ */ jsx(ToastItem, {
|
|
54
|
+
entry: t,
|
|
55
|
+
onDismiss: () => dismiss(t.id),
|
|
56
|
+
dismissLabel: labels.dismiss
|
|
57
|
+
}, t.id))
|
|
58
|
+
})
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function ToastItem({ entry, onDismiss, dismissLabel }) {
|
|
63
|
+
const { title, description, tone = "neutral", action, duration = 5e3 } = entry;
|
|
64
|
+
const [paused, setPaused] = useState(false);
|
|
65
|
+
const left = useRef(duration);
|
|
66
|
+
const latest = useRef(onDismiss);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
latest.current = onDismiss;
|
|
69
|
+
});
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (paused || !Number.isFinite(left.current)) return;
|
|
72
|
+
const started = Date.now();
|
|
73
|
+
const t = setTimeout(() => latest.current(), left.current);
|
|
74
|
+
return () => {
|
|
75
|
+
clearTimeout(t);
|
|
76
|
+
left.current -= Date.now() - started;
|
|
77
|
+
};
|
|
78
|
+
}, [paused]);
|
|
79
|
+
const Icon = ICONS[tone];
|
|
80
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
81
|
+
className: "slurp-toast",
|
|
82
|
+
"data-tone": tone,
|
|
83
|
+
onPointerEnter: () => setPaused(true),
|
|
84
|
+
onPointerLeave: () => setPaused(false),
|
|
85
|
+
onFocus: () => setPaused(true),
|
|
86
|
+
onBlur: (e) => {
|
|
87
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setPaused(false);
|
|
88
|
+
},
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("span", {
|
|
91
|
+
className: "slurp-toast-icon",
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
children: /* @__PURE__ */ jsx(Icon, { size: 22 })
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ jsxs("div", {
|
|
96
|
+
className: "slurp-toast-text",
|
|
97
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
98
|
+
className: "slurp-toast-title",
|
|
99
|
+
children: title
|
|
100
|
+
}), description != null && /* @__PURE__ */ jsx("p", {
|
|
101
|
+
className: "slurp-toast-description",
|
|
102
|
+
children: description
|
|
103
|
+
})]
|
|
104
|
+
}),
|
|
105
|
+
action && /* @__PURE__ */ jsx(Button, {
|
|
106
|
+
appearance: "plain",
|
|
107
|
+
size: "sm",
|
|
108
|
+
onClick: () => {
|
|
109
|
+
action.onClick();
|
|
110
|
+
onDismiss();
|
|
111
|
+
},
|
|
112
|
+
children: action.label
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsx(Bubble, {
|
|
115
|
+
label: dismissLabel,
|
|
116
|
+
size: "sm",
|
|
117
|
+
className: cx("slurp-toast-dismiss"),
|
|
118
|
+
onClick: onDismiss,
|
|
119
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { size: 18 })
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** `toast(options)` and `dismiss(id)`, from the nearest ToastProvider. */
|
|
125
|
+
function useToast() {
|
|
126
|
+
const api = useContext(ToastContext);
|
|
127
|
+
if (!api) throw new Error("Slurp: useToast() needs a <ToastProvider> above it.");
|
|
128
|
+
return api;
|
|
129
|
+
}
|
|
130
|
+
export { TOAST_LABELS, ToastProvider, useToast };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.js","names":[],"sources":["../../src/Toast/Toast.tsx"],"sourcesContent":["import { CloseIcon, ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { Button } from '../Button/Button';\nimport type { StatusTone } from '../Notice/Notice';\n\nexport interface ToastOptions {\n title: ReactNode;\n description?: ReactNode;\n /** Default `neutral`: icon + text, never colour alone. */\n tone?: StatusTone;\n /** One action (\"Annulla\"). */\n action?: { label: string; onClick: () => void };\n /** ms before it goes away; paused while hovered or focused. `Infinity` keeps it. Default 5000. */\n duration?: number;\n}\n\ninterface ToastEntry extends ToastOptions {\n id: number;\n}\n\nexport interface ToastLabels {\n /** Name of the region that holds the toasts. */\n region: string;\n /** Name of each close button. */\n dismiss: string;\n}\n\nexport const TOAST_LABELS: ToastLabels = { region: 'Notifiche', dismiss: 'Chiudi notifica' };\n\ninterface ToastApi {\n /** Shows a toast; returns its id. */\n toast: (options: ToastOptions) => number;\n dismiss: (id: number) => void;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\nexport interface ToastProviderProps {\n children?: ReactNode;\n labels?: Partial<ToastLabels>;\n /** At most this many on screen; the oldest go first. Default 3. */\n limit?: number;\n}\n\nconst ICONS = { neutral: InfoIcon, success: SuccessIcon, warning: WarningIcon, danger: ErrorIcon };\n\n/**\n * Short confirmations at the bottom of the screen, above the Dock (`--slurp-toast-offset`). The list is a polite live\n * region, present from the start so new toasts are announced.\n */\nexport function ToastProvider({ children, labels: labelsProp, limit = 3 }: ToastProviderProps) {\n const labels = { ...TOAST_LABELS, ...labelsProp };\n const [items, setItems] = useState<ToastEntry[]>([]);\n const next = useRef(1);\n const dismiss = useCallback(\n (id: number) => setItems((all) => all.filter((t) => t.id !== id)),\n [],\n );\n const toast = useCallback(\n (options: ToastOptions) => {\n const id = next.current++;\n setItems((all) => [...all, { ...options, id }].slice(-limit));\n return id;\n },\n [limit],\n );\n const api = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n return (\n <ToastContext value={api}>\n {children}\n <section className=\"slurp-toasts\" aria-label={labels.region}>\n <ol aria-live=\"polite\" aria-relevant=\"additions text\" className=\"slurp-toasts-list\">\n {items.map((t) => (\n <ToastItem\n key={t.id}\n entry={t}\n onDismiss={() => dismiss(t.id)}\n dismissLabel={labels.dismiss}\n />\n ))}\n </ol>\n </section>\n </ToastContext>\n );\n}\n\nfunction ToastItem({\n entry,\n onDismiss,\n dismissLabel,\n}: {\n entry: ToastEntry;\n onDismiss: () => void;\n dismissLabel: string;\n}) {\n const { title, description, tone = 'neutral', action, duration = 5000 } = entry;\n const [paused, setPaused] = useState(false);\n const left = useRef(duration);\n const latest = useRef(onDismiss);\n useEffect(() => {\n latest.current = onDismiss;\n });\n\n useEffect(() => {\n if (paused || !Number.isFinite(left.current)) return;\n const started = Date.now();\n const t = setTimeout(() => latest.current(), left.current);\n return () => {\n clearTimeout(t);\n left.current -= Date.now() - started;\n };\n }, [paused]);\n\n const Icon = ICONS[tone];\n return (\n <li\n className=\"slurp-toast\"\n data-tone={tone}\n onPointerEnter={() => setPaused(true)}\n onPointerLeave={() => setPaused(false)}\n onFocus={() => setPaused(true)}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget)) setPaused(false);\n }}\n >\n <span className=\"slurp-toast-icon\" aria-hidden=\"true\">\n <Icon size={22} />\n </span>\n <div className=\"slurp-toast-text\">\n <p className=\"slurp-toast-title\">{title}</p>\n {description != null && <p className=\"slurp-toast-description\">{description}</p>}\n </div>\n {action && (\n <Button\n appearance=\"plain\"\n size=\"sm\"\n onClick={() => {\n action.onClick();\n onDismiss();\n }}\n >\n {action.label}\n </Button>\n )}\n <Bubble\n label={dismissLabel}\n size=\"sm\"\n className={cx('slurp-toast-dismiss')}\n onClick={onDismiss}\n >\n <CloseIcon size={18} />\n </Bubble>\n </li>\n );\n}\n\n/** `toast(options)` and `dismiss(id)`, from the nearest ToastProvider. */\nexport function useToast(): ToastApi {\n const api = useContext(ToastContext);\n if (!api) throw new Error('Slurp: useToast() needs a <ToastProvider> above it.');\n return api;\n}\n"],"mappings":";;;;;;;;AAuCA,MAAa,eAA4B;CAAE,QAAQ;CAAa,SAAS;AAAkB;AAQ3F,MAAM,eAAe,cAA+B,IAAI;AASxD,MAAM,QAAQ;CAAE,SAAS;CAAU,SAAS;CAAa,SAAS;CAAa,QAAQ;AAAU;;;;;AAMjG,SAAgB,cAAc,EAAE,UAAU,QAAQ,YAAY,QAAQ,KAAyB;CAC7F,MAAM,SAAS;EAAE,GAAG;EAAc,GAAG;CAAW;CAChD,MAAM,CAAC,OAAO,YAAY,SAAuB,CAAC,CAAC;CACnD,MAAM,OAAO,OAAO,CAAC;CACrB,MAAM,UAAU,aACb,OAAe,UAAU,QAAQ,IAAI,QAAQ,MAAM,EAAE,OAAO,EAAE,CAAC,GAChE,CAAC,CACH;CACA,MAAM,QAAQ,aACX,YAA0B;EACzB,MAAM,KAAK,KAAK;EAChB,UAAU,QAAQ,CAAC,GAAG,KAAK;GAAE,GAAG;GAAS;EAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;EAC5D,OAAO;CACT,GACA,CAAC,KAAK,CACR;CACA,MAAM,MAAM,eAAe;EAAE;EAAO;CAAQ,IAAI,CAAC,OAAO,OAAO,CAAC;CAChE,OACE,qBAAC,cAAD;EAAc,OAAO;EAArB,UAAA,CACG,UACD,oBAAC,WAAD;GAAS,WAAU;GAAe,cAAY,OAAO;GACnD,UAAA,oBAAC,MAAD;IAAI,aAAU;IAAS,iBAAc;IAAiB,WAAU;IAC7D,UAAA,MAAM,KAAK,MACV,oBAAC,WAAD;KAEE,OAAO;KACP,iBAAiB,QAAQ,EAAE,EAAE;KAC7B,cAAc,OAAO;IACtB,GAJM,EAAE,EAIR,CACF;GACC,CAAA;EACG,CAAA,CACG;;AAElB;AAEA,SAAS,UAAU,EACjB,OACA,WACA,gBAKC;CACD,MAAM,EAAE,OAAO,aAAa,OAAO,WAAW,QAAQ,WAAW,QAAS;CAC1E,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,SAAS,OAAO,SAAS;CAC/B,gBAAgB;EACd,OAAO,UAAU;CACnB,CAAC;CAED,gBAAgB;EACd,IAAI,UAAU,CAAC,OAAO,SAAS,KAAK,OAAO,GAAG;EAC9C,MAAM,UAAU,KAAK,IAAI;EACzB,MAAM,IAAI,iBAAiB,OAAO,QAAQ,GAAG,KAAK,OAAO;EACzD,aAAa;GACX,aAAa,CAAC;GACd,KAAK,WAAW,KAAK,IAAI,IAAI;EAC/B;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,MAAM,OAAO,MAAM;CACnB,OACE,qBAAC,MAAD;EACE,WAAU;EACV,aAAW;EACX,sBAAsB,UAAU,IAAI;EACpC,sBAAsB,UAAU,KAAK;EACrC,eAAe,UAAU,IAAI;EAC7B,SAAS,MAAM;GACb,IAAI,CAAC,EAAE,cAAc,SAAS,EAAE,aAAa,GAAG,UAAU,KAAK;EACjE;EARF,UAAA;GAUE,oBAAC,QAAD;IAAM,WAAU;IAAmB,eAAY;IAC7C,UAAA,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;GACb,CAAA;GACN,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,KAAD;KAAG,WAAU;KAAqB,UAAA;IAAS,CAAA,GAC1C,eAAe,QAAQ,oBAAC,KAAD;KAAG,WAAU;KAA2B,UAAA;IAAe,CAAA,CAC5E;;GACJ,UACC,oBAAC,QAAD;IACE,YAAW;IACX,MAAK;IACL,eAAe;KACb,OAAO,QAAQ;KACf,UAAU;IACZ;IAEC,UAAA,OAAO;GACF,CAAA;GAEV,oBAAC,QAAD;IACE,OAAO;IACP,MAAK;IACL,WAAW,GAAG,qBAAqB;IACnC,SAAS;IAET,UAAA,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;GAChB,CAAA;EACN;;AAER;;AAGA,SAAgB,WAAqB;CACnC,MAAM,MAAM,WAAW,YAAY;CACnC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,qDAAqD;CAC/E,OAAO;AACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export type VisuallyHiddenProps<E extends ElementType = 'span'> = PolymorphicProps<E>;
|
|
5
|
+
/** Content for assistive technology only: read by screen readers, not shown. */
|
|
6
|
+
export declare function VisuallyHidden<E extends ElementType = 'span'>(props: VisuallyHiddenProps<E>): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=VisuallyHidden.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/VisuallyHidden/VisuallyHidden.tsx
|
|
5
|
+
/** Content for assistive technology only: read by screen readers, not shown. */
|
|
6
|
+
function VisuallyHidden(props) {
|
|
7
|
+
const { as, className, css: _css, ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(as ?? "span", {
|
|
9
|
+
className: cx("slurp-visually-hidden", className),
|
|
10
|
+
...rest
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { VisuallyHidden };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=VisuallyHidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.js","names":[],"sources":["../../src/VisuallyHidden/VisuallyHidden.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport type VisuallyHiddenProps<E extends ElementType = 'span'> = PolymorphicProps<E>;\n\n/** Content for assistive technology only: read by screen readers, not shown. */\nexport function VisuallyHidden<E extends ElementType = 'span'>(props: VisuallyHiddenProps<E>) {\n const { as, className, css: _css, ...rest } = props as VisuallyHiddenProps;\n const Root = (as ?? 'span') as ElementType;\n return <Root className={cx('slurp-visually-hidden', className)} {...rest} />;\n}\n"],"mappings":";;;;;AAQA,SAAgB,eAA+C,OAA+B;CAC5F,MAAM,EAAE,IAAI,WAAW,KAAK,MAAM,GAAG,SAAS;CAE9C,OAAO,oBADO,MAAM,QACb;EAAM,WAAW,GAAG,yBAAyB,SAAS;EAAG,GAAI;CAAO,CAAA;AAC7E"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
import { AnimationProps, useAnimationTarget } from "./motion/useAnimationTarget.js";
|
|
3
|
+
import { ColorValue, MaybeResponsive, RadiusValue, Responsive, SlurpCss, SpaceValue } from "./lib/css.js";
|
|
4
|
+
import { BaseProps, PolymorphicProps } from "./lib/polymorphic.js";
|
|
5
|
+
import { AccentScope, AccentScopeProps } from "./AccentScope/AccentScope.js";
|
|
6
|
+
import "./AccentScope/index.js";
|
|
7
|
+
import { Avatar, AvatarProps } from "./Avatar/Avatar.js";
|
|
8
|
+
import "./Avatar/index.js";
|
|
9
|
+
import { Bento, BentoProps } from "./Bento/Bento.js";
|
|
10
|
+
import "./Bento/index.js";
|
|
11
|
+
import { Bloom, BloomPlacement, BloomProps } from "./Bloom/Bloom.js";
|
|
12
|
+
import "./Bloom/index.js";
|
|
13
|
+
import { Appearance, Button, ButtonProps, ButtonTone, ControlSize } from "./Button/Button.js";
|
|
14
|
+
import { Bubble, BubbleProps } from "./Bubble/Bubble.js";
|
|
15
|
+
import "./Bubble/index.js";
|
|
16
|
+
import "./Button/index.js";
|
|
17
|
+
import { Card, CardProps } from "./Card/Card.js";
|
|
18
|
+
import "./Card/index.js";
|
|
19
|
+
import { Cell, CellProps } from "./Cell/Cell.js";
|
|
20
|
+
import "./Cell/index.js";
|
|
21
|
+
import { Checkbox, CheckboxProps } from "./Checkbox/Checkbox.js";
|
|
22
|
+
import "./Checkbox/index.js";
|
|
23
|
+
import { Chip, ChipProps } from "./Chip/Chip.js";
|
|
24
|
+
import "./Chip/index.js";
|
|
25
|
+
import { CHOICE_LABELS, Choice, ChoiceLabels, ChoiceOption, ChoiceProps } from "./Choice/Choice.js";
|
|
26
|
+
import "./Choice/index.js";
|
|
27
|
+
import { Count, CountProps } from "./Count/Count.js";
|
|
28
|
+
import "./Count/index.js";
|
|
29
|
+
import { DIALOG_LABELS, Dialog, DialogLabels, DialogProps } from "./Dialog/Dialog.js";
|
|
30
|
+
import "./Dialog/index.js";
|
|
31
|
+
import { DOCK_LABELS, Dock, DockActionProps, DockBackProps, DockCrumbProps, DockCrumbsProps, DockLabels, DockProps, DockSearchProps } from "./Dock/Dock.js";
|
|
32
|
+
import "./Dock/index.js";
|
|
33
|
+
import { Empty, EmptyProps } from "./Empty/Empty.js";
|
|
34
|
+
import "./Empty/index.js";
|
|
35
|
+
import { Fact, FactProps } from "./Fact/Fact.js";
|
|
36
|
+
import "./Fact/index.js";
|
|
37
|
+
import { Field, FieldProps } from "./Field/Field.js";
|
|
38
|
+
import "./Field/index.js";
|
|
39
|
+
import { FILTERS_LABELS, Filters, FiltersGroupProps, FiltersLabels, FiltersProps } from "./Filters/Filters.js";
|
|
40
|
+
import "./Filters/index.js";
|
|
41
|
+
import { Flow, FlowProps } from "./Flow/Flow.js";
|
|
42
|
+
import "./Flow/index.js";
|
|
43
|
+
import { Fold, FoldProps } from "./Fold/Fold.js";
|
|
44
|
+
import "./Fold/index.js";
|
|
45
|
+
import { Frame, FrameProps } from "./Frame/Frame.js";
|
|
46
|
+
import "./Frame/index.js";
|
|
47
|
+
import { Ground } from "./Ground/Ground.js";
|
|
48
|
+
import { Hint, HintProps } from "./Hint/Hint.js";
|
|
49
|
+
import "./Hint/index.js";
|
|
50
|
+
import { Link, LinkProps } from "./Link/Link.js";
|
|
51
|
+
import "./Link/index.js";
|
|
52
|
+
import { List, ListProps, ListRow, ListRowProps } from "./ListRow/ListRow.js";
|
|
53
|
+
import "./ListRow/index.js";
|
|
54
|
+
import { Mark, MarkProps } from "./Mark/Mark.js";
|
|
55
|
+
import "./Mark/index.js";
|
|
56
|
+
import { Menu, MenuItem, MenuItemProps, MenuProps } from "./Menu/Menu.js";
|
|
57
|
+
import "./Menu/index.js";
|
|
58
|
+
import { NOTICE_LABELS, Notice, NoticeLabels, NoticeProps, StatusTone } from "./Notice/Notice.js";
|
|
59
|
+
import "./Notice/index.js";
|
|
60
|
+
import { Placeholder, PlaceholderProps } from "./Placeholder/Placeholder.js";
|
|
61
|
+
import "./Placeholder/index.js";
|
|
62
|
+
import { Portal, PortalProps } from "./Portal/Portal.js";
|
|
63
|
+
import "./Portal/index.js";
|
|
64
|
+
import { Progress, ProgressProps } from "./Progress/Progress.js";
|
|
65
|
+
import "./Progress/index.js";
|
|
66
|
+
import { Radio, RadioGroup, RadioGroupProps, RadioProps } from "./Radio/Radio.js";
|
|
67
|
+
import "./Radio/index.js";
|
|
68
|
+
import { Range, RangeProps } from "./Range/Range.js";
|
|
69
|
+
import "./Range/index.js";
|
|
70
|
+
import { ResultRow, ResultRowProps } from "./ResultRow/ResultRow.js";
|
|
71
|
+
import "./ResultRow/index.js";
|
|
72
|
+
import { Score, ScoreProps } from "./Score/Score.js";
|
|
73
|
+
import "./Score/index.js";
|
|
74
|
+
import { SEARCH_LABELS, Search, SearchLabels, SearchProps } from "./Search/Search.js";
|
|
75
|
+
import "./Search/index.js";
|
|
76
|
+
import { Segmented, SegmentedOption, SegmentedProps } from "./Segmented/Segmented.js";
|
|
77
|
+
import "./Segmented/index.js";
|
|
78
|
+
import { SETTINGS_LABELS, Settings, SettingsLabels, SettingsLanguage, SettingsProps } from "./Settings/Settings.js";
|
|
79
|
+
import "./Settings/index.js";
|
|
80
|
+
import { Sheet, SheetProps } from "./Sheet/Sheet.js";
|
|
81
|
+
import "./Sheet/index.js";
|
|
82
|
+
import { Shelf, ShelfProps } from "./Shelf/Shelf.js";
|
|
83
|
+
import "./Shelf/index.js";
|
|
84
|
+
import { Stage, StageProps } from "./Stage/Stage.js";
|
|
85
|
+
import { Tile, TileProps } from "./Tile/Tile.js";
|
|
86
|
+
import { Surface, SurfaceProps } from "./Surface/Surface.js";
|
|
87
|
+
import { Swatch, SwatchGroup, SwatchGroupProps, SwatchOption, SwatchProps } from "./Swatch/Swatch.js";
|
|
88
|
+
import { Switch, SwitchProps } from "./Switch/Switch.js";
|
|
89
|
+
import { TabItem, Tabs, TabsProps } from "./Tabs/Tabs.js";
|
|
90
|
+
import { Text, TextProps, TextTone } from "./Text/Text.js";
|
|
91
|
+
import { AccentInput, ColorSchemeMode, ComponentsConfig, DEFAULT_STORAGE_KEY, MotionOptions, ResolvedColorScheme, Theme, ThemeOptions, TokenOverrides, createTheme } from "./lib/theme.js";
|
|
92
|
+
import { SlurpProvider, SlurpProviderProps } from "./SlurpProvider/SlurpProvider.js";
|
|
93
|
+
import { ColorSchemeScript, ColorSchemeScriptProps } from "./SlurpProvider/ColorSchemeScript.js";
|
|
94
|
+
import { ColorSchemeState, useColorScheme, useTheme } from "./internal/context.js";
|
|
95
|
+
import "./SlurpProvider/index.js";
|
|
96
|
+
import "./Stage/index.js";
|
|
97
|
+
import "./Surface/index.js";
|
|
98
|
+
import "./Swatch/index.js";
|
|
99
|
+
import "./Switch/index.js";
|
|
100
|
+
import "./Tabs/index.js";
|
|
101
|
+
import "./Text/index.js";
|
|
102
|
+
import "./Tile/index.js";
|
|
103
|
+
import { TOAST_LABELS, ToastLabels, ToastOptions, ToastProvider, ToastProviderProps, useToast } from "./Toast/Toast.js";
|
|
104
|
+
import "./Toast/index.js";
|
|
105
|
+
import { VisuallyHidden, VisuallyHiddenProps } from "./VisuallyHidden/VisuallyHidden.js";
|
|
106
|
+
import "./VisuallyHidden/index.js";
|
|
107
|
+
import { CONTRAST_MIN, alpha, contrast, meetsContrast, onColor, vivid } from "./lib/color.js";
|
|
108
|
+
import { AnimationGroup, AnimationGroupProps } from "./motion/AnimationGroup.js";
|
|
109
|
+
import { SlurpControls, useSlurp } from "./motion/useSlurp.js";
|
|
110
|
+
import { ContentRef, SlurpEnterOptions, SlurpNavigate, SlurpNavigateOptions, useSlurpEnter, useSlurpNavigate } from "./motion/navigation.js";
|
|
111
|
+
import { BentoItem, BentoSpan, bentoLayout, matchRanges, matchesAll, normalizeText } from "./lib/layout.js";
|
|
112
|
+
import { CrumbEnd, crumbPath } from "./lib/crumb.js";
|
|
113
|
+
import { FOCUSABLE, MoveFocusOptions, focusFirst, moveFocus } from "./utils/focus.js";
|
|
114
|
+
import { ControlledOptions, useControlled } from "./utils/useControlled.js";
|
|
115
|
+
import { DismissOptions, useDismiss } from "./utils/useDismiss.js";
|
|
116
|
+
import { useForkRef } from "./utils/useForkRef.js";
|
|
117
|
+
import { COMPACT_QUERY, useMediaQuery } from "./utils/useMediaQuery.js";
|
|
118
|
+
import { RovingFocusOptions, useRovingFocus } from "./utils/useRovingFocus.js";
|
|
119
|
+
import { FindInPage, focusHit, useFindInPage } from "./utils/useFindInPage.js";
|
|
120
|
+
import "./utils/index.js";
|
|
121
|
+
export { type AccentInput, AccentScope, type AccentScopeProps, AnimationGroup, type AnimationGroupProps, type AnimationProps, type Appearance, Avatar, type AvatarProps, type BaseProps, Bento, type BentoItem, type BentoProps, type BentoSpan, Bloom, type BloomPlacement, type BloomProps, Bubble, type BubbleProps, Button, type ButtonProps, type ButtonTone, CHOICE_LABELS, COMPACT_QUERY, CONTRAST_MIN, Card, type CardProps, Cell, type CellProps, Checkbox, type CheckboxProps, Chip, type ChipProps, Choice, type ChoiceLabels, type ChoiceOption, type ChoiceProps, type ColorSchemeMode, ColorSchemeScript, type ColorSchemeScriptProps, type ColorSchemeState, type ColorValue, type ComponentsConfig, type ContentRef, type ControlSize, type ControlledOptions, Count, type CountProps, type CrumbEnd, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, Dialog, type DialogLabels, type DialogProps, type DismissOptions, Dock, type DockActionProps, type DockBackProps, type DockCrumbProps, type DockCrumbsProps, type DockLabels, type DockProps, type DockSearchProps, Empty, type EmptyProps, FILTERS_LABELS, FOCUSABLE, Fact, type FactProps, Field, type FieldProps, Filters, type FiltersGroupProps, type FiltersLabels, type FiltersProps, type FindInPage, Flow, type FlowProps, Fold, type FoldProps, Frame, type FrameProps, Ground, Hint, type HintProps, Link, type LinkProps, List, type ListProps, ListRow, type ListRowProps, Mark, type MarkProps, type MaybeResponsive, Menu, MenuItem, type MenuItemProps, type MenuProps, type MotionOptions, type MoveFocusOptions, NOTICE_LABELS, Notice, type NoticeLabels, type NoticeProps, Placeholder, type PlaceholderProps, type PolymorphicProps, Portal, type PortalProps, Progress, type ProgressProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadiusValue, Range, type RangeProps, type ResolvedColorScheme, type Responsive, ResultRow, type ResultRowProps, type RovingFocusOptions, SEARCH_LABELS, SETTINGS_LABELS, Score, type ScoreProps, Search, type SearchLabels, type SearchProps, Segmented, type SegmentedOption, type SegmentedProps, Settings, type SettingsLabels, type SettingsLanguage, type SettingsProps, Sheet, type SheetProps, Shelf, type ShelfProps, type SlurpControls, type SlurpCss, type SlurpEnterOptions, type SlurpNavigate, type SlurpNavigateOptions, SlurpProvider, type SlurpProviderProps, type SpaceValue, Stage, type StageProps, type StatusTone, Surface, type SurfaceProps, Swatch, SwatchGroup, type SwatchGroupProps, type SwatchOption, type SwatchProps, Switch, type SwitchProps, TOAST_LABELS, type TabItem, Tabs, type TabsProps, Text, type TextProps, type TextTone, type Theme, type ThemeOptions, Tile, type TileProps, type ToastLabels, type ToastOptions, ToastProvider, type ToastProviderProps, type TokenOverrides, VisuallyHidden, type VisuallyHiddenProps, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, useAnimationTarget, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|