@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
|
@@ -0,0 +1,30 @@
|
|
|
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/Bubble/Bubble.tsx
|
|
7
|
+
/** Round icon-only button. In a Bloom it is the trigger that grows into its panel. */
|
|
8
|
+
function Bubble(props) {
|
|
9
|
+
const { as, css, className, label, appearance = "plain", tone = "neutral", size = "md", children, ...rest } = useThemeProps("Bubble", props);
|
|
10
|
+
const Root = as ?? "button";
|
|
11
|
+
const styled = useCss("Bubble", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
14
|
+
className: cx("slurp-button", "slurp-bubble", styled.className, className),
|
|
15
|
+
"data-appearance": appearance,
|
|
16
|
+
"data-tone": tone,
|
|
17
|
+
"data-size": size,
|
|
18
|
+
"aria-label": label,
|
|
19
|
+
...Root === "button" ? { type: "button" } : null,
|
|
20
|
+
...root,
|
|
21
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "slurp-button-icon",
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
children
|
|
25
|
+
})
|
|
26
|
+
})] });
|
|
27
|
+
}
|
|
28
|
+
export { Bubble };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=Bubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bubble.js","names":[],"sources":["../../src/Bubble/Bubble.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType, ReactNode } from 'react';\n\nimport type { Appearance, ButtonTone, ControlSize } from '../Button/Button';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface BubbleOwnProps {\n /** Accessible name: an icon-only button must say what it does (also the tooltip text, if any). */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Default `plain`. */\n appearance?: Appearance;\n /** Default `neutral`. */\n tone?: ButtonTone;\n /** Default `md` (48px). */\n size?: ControlSize;\n}\n\nexport type BubbleProps<E extends ElementType = 'button'> = PolymorphicProps<E, BubbleOwnProps>;\n\n/** Round icon-only button. In a Bloom it is the trigger that grows into its panel. */\nexport function Bubble<E extends ElementType = 'button'>(props: BubbleProps<E>) {\n const {\n as,\n css,\n className,\n label,\n appearance = 'plain',\n tone = 'neutral',\n size = 'md',\n children,\n ...rest\n } = useThemeProps('Bubble', props as BubbleProps);\n const Root = (as ?? 'button') as ElementType;\n const styled = useCss('Bubble', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-button', 'slurp-bubble', styled.className, className)}\n data-appearance={appearance}\n data-tone={tone}\n data-size={size}\n aria-label={label}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n <span className=\"slurp-button-icon\" aria-hidden=\"true\">\n {children}\n </span>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,OAAyC,OAAuB;CAC9E,MAAM,EACJ,IACA,KACA,WACA,OACA,aAAa,SACb,OAAO,WACP,OAAO,MACP,UACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EACE,WAAW,GAAG,gBAAgB,gBAAgB,OAAO,WAAW,SAAS;EACzE,mBAAiB;EACjB,aAAW;EACX,aAAW;EACX,cAAY;EACZ,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;EAC9C,GAAI;EAEJ,UAAA,oBAAC,QAAD;GAAM,WAAU;GAAoB,eAAY;GAC7C;EACG,CAAA;CACF,CAAA,CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export type Appearance = 'fill' | 'soft' | 'outline' | 'plain';
|
|
5
|
+
/** Fills carry `on-accent` content; the design system has no on-* pair for status colours, so buttons stop at these. */
|
|
6
|
+
export type ButtonTone = 'accent' | 'neutral';
|
|
7
|
+
/** Every size keeps the 44px minimum target. `sm` 44 · `md` 48 · `lg` 56. */
|
|
8
|
+
export type ControlSize = 'sm' | 'md' | 'lg';
|
|
9
|
+
export interface ButtonOwnProps extends PartsProps<'icon' | 'label' | 'endIcon'> {
|
|
10
|
+
/** Default `fill`. */
|
|
11
|
+
appearance?: Appearance;
|
|
12
|
+
/** Default `accent`. */
|
|
13
|
+
tone?: ButtonTone;
|
|
14
|
+
/** Default `md`. */
|
|
15
|
+
size?: ControlSize;
|
|
16
|
+
/** Leading icon (decorative: hidden from assistive tech). */
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
/** Trailing icon (decorative). */
|
|
19
|
+
endIcon?: ReactNode;
|
|
20
|
+
/** Renders a link (`<a href>`) that looks like a button. */
|
|
21
|
+
href?: string;
|
|
22
|
+
}
|
|
23
|
+
export type ButtonProps<E extends ElementType = 'button'> = PolymorphicProps<E, ButtonOwnProps>;
|
|
24
|
+
/** The primary action: a pill with `fill` (accent), `soft`, `outline` or `plain` appearance. */
|
|
25
|
+
export declare function Button<E extends ElementType = 'button'>(props: ButtonProps<E>): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Button/Button.tsx
|
|
7
|
+
/** The primary action: a pill with `fill` (accent), `soft`, `outline` or `plain` appearance. */
|
|
8
|
+
function Button(props) {
|
|
9
|
+
const { as, css, className, appearance = "fill", tone = "accent", size = "md", icon, endIcon, href, parts, partProps, classNames, children, ...rest } = useThemeProps("Button", props);
|
|
10
|
+
const Root = as ?? (href ? "a" : "button");
|
|
11
|
+
const styled = useCss("Button", "root", css);
|
|
12
|
+
const { part, style } = useParts("Button", {
|
|
13
|
+
parts,
|
|
14
|
+
partProps,
|
|
15
|
+
classNames
|
|
16
|
+
});
|
|
17
|
+
const root = useAnimationRoot(rest);
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
styled.style,
|
|
20
|
+
style,
|
|
21
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
22
|
+
className: cx("slurp-button", styled.className, className),
|
|
23
|
+
"data-appearance": appearance,
|
|
24
|
+
"data-tone": tone,
|
|
25
|
+
"data-size": size,
|
|
26
|
+
href,
|
|
27
|
+
...Root === "button" ? { type: "button" } : null,
|
|
28
|
+
...root,
|
|
29
|
+
children: [
|
|
30
|
+
icon != null && part("icon", "span", {
|
|
31
|
+
className: "slurp-button-icon",
|
|
32
|
+
"aria-hidden": true,
|
|
33
|
+
children: icon
|
|
34
|
+
}),
|
|
35
|
+
children != null && part("label", "span", {
|
|
36
|
+
className: "slurp-button-label",
|
|
37
|
+
children
|
|
38
|
+
}),
|
|
39
|
+
endIcon != null && part("endIcon", "span", {
|
|
40
|
+
className: "slurp-button-icon",
|
|
41
|
+
"aria-hidden": true,
|
|
42
|
+
children: endIcon
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
48
|
+
export { Button };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../src/Button/Button.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport type Appearance = 'fill' | 'soft' | 'outline' | 'plain';\n/** Fills carry `on-accent` content; the design system has no on-* pair for status colours, so buttons stop at these. */\nexport type ButtonTone = 'accent' | 'neutral';\n/** Every size keeps the 44px minimum target. `sm` 44 · `md` 48 · `lg` 56. */\nexport type ControlSize = 'sm' | 'md' | 'lg';\n\nexport interface ButtonOwnProps extends PartsProps<'icon' | 'label' | 'endIcon'> {\n /** Default `fill`. */\n appearance?: Appearance;\n /** Default `accent`. */\n tone?: ButtonTone;\n /** Default `md`. */\n size?: ControlSize;\n /** Leading icon (decorative: hidden from assistive tech). */\n icon?: ReactNode;\n /** Trailing icon (decorative). */\n endIcon?: ReactNode;\n /** Renders a link (`<a href>`) that looks like a button. */\n href?: string;\n}\n\nexport type ButtonProps<E extends ElementType = 'button'> = PolymorphicProps<E, ButtonOwnProps>;\n\n/** The primary action: a pill with `fill` (accent), `soft`, `outline` or `plain` appearance. */\nexport function Button<E extends ElementType = 'button'>(props: ButtonProps<E>) {\n const {\n as,\n css,\n className,\n appearance = 'fill',\n tone = 'accent',\n size = 'md',\n icon,\n endIcon,\n href,\n parts,\n partProps,\n classNames,\n children,\n ...rest\n } = useThemeProps('Button', props as ButtonProps);\n const Root = (as ?? (href ? 'a' : 'button')) as ElementType;\n const styled = useCss('Button', 'root', css);\n const { part, style } = useParts('Button', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-button', styled.className, className)}\n data-appearance={appearance}\n data-tone={tone}\n data-size={size}\n href={href}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {icon != null &&\n part('icon', 'span', {\n className: 'slurp-button-icon',\n 'aria-hidden': true,\n children: icon,\n })}\n {children != null && part('label', 'span', { className: 'slurp-button-label', children })}\n {endIcon != null &&\n part('endIcon', 'span', {\n className: 'slurp-button-icon',\n 'aria-hidden': true,\n children: endIcon,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AA+BA,SAAgB,OAAyC,OAAuB;CAC9E,MAAM,EACJ,IACA,KACA,WACA,aAAa,QACb,OAAO,UACP,OAAO,MACP,MACA,SACA,MACA,OACA,WACA,YACA,UACA,GAAG,SACD,cAAc,UAAU,KAAoB;CAChD,MAAM,OAAQ,OAAO,OAAO,MAAM;CAClC,MAAM,SAAS,OAAO,UAAU,QAAQ,GAAG;CAC3C,MAAM,EAAE,MAAM,UAAU,SAAS,UAAU;EAAE;EAAO;EAAW;CAAW,CAAC;CAC3E,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,gBAAgB,OAAO,WAAW,SAAS;GACzD,mBAAiB;GACjB,aAAW;GACX,aAAW;GACL;GACN,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;GAC9C,GAAI;GAPN,UAAA;IASG,QAAQ,QACP,KAAK,QAAQ,QAAQ;KACnB,WAAW;KACX,eAAe;KACf,UAAU;IACZ,CAAC;IACF,YAAY,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAsB;IAAS,CAAC;IACvF,WAAW,QACV,KAAK,WAAW,QAAQ;KACtB,WAAW;KACX,eAAe;KACf,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
/** A value shown strong in the description pill ("1.239 €"). */
|
|
8
|
+
value?: ReactNode;
|
|
9
|
+
/** Before the value ("da"). */
|
|
10
|
+
valuePrefix?: ReactNode;
|
|
11
|
+
/** Pill at the top right ("−15%"). */
|
|
12
|
+
badge?: ReactNode;
|
|
13
|
+
/** Tint (any hex); default the accent. */
|
|
14
|
+
color?: string;
|
|
15
|
+
/** The media in the middle (illustration, photo), decorative. */
|
|
16
|
+
media?: ReactNode;
|
|
17
|
+
/** Renders a link. */
|
|
18
|
+
href?: string;
|
|
19
|
+
}
|
|
20
|
+
export type CardProps<E extends ElementType = 'a'> = PolymorphicProps<E, CardOwnProps>;
|
|
21
|
+
/**
|
|
22
|
+
* One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the
|
|
23
|
+
* bottom left, never covering it. A link with `href`, a button with `onClick`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function Card<E extends ElementType = 'a'>(props: CardProps<E>): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
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, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Card/Card.tsx
|
|
8
|
+
/**
|
|
9
|
+
* One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the
|
|
10
|
+
* bottom left, never covering it. A link with `href`, a button with `onClick`.
|
|
11
|
+
*/
|
|
12
|
+
function Card(props) {
|
|
13
|
+
const { as, css, className, title, description, value, valuePrefix, badge, color, media, href, style, parts, partProps, classNames, ...rest } = useThemeProps("Card", props);
|
|
14
|
+
const Root = as ?? (href ? "a" : rest.onClick ? "button" : "div");
|
|
15
|
+
const styled = useCss("Card", "root", css);
|
|
16
|
+
const { part, style: partsStyle } = useParts("Card", {
|
|
17
|
+
parts,
|
|
18
|
+
partProps,
|
|
19
|
+
classNames
|
|
20
|
+
});
|
|
21
|
+
const root = useAnimationRoot(rest);
|
|
22
|
+
const vars = {
|
|
23
|
+
...color ? {
|
|
24
|
+
"--slurp-card-color": color,
|
|
25
|
+
"--slurp-card-on": /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : "var(--slurp-fg)",
|
|
26
|
+
"--slurp-animation-tint": color
|
|
27
|
+
} : null,
|
|
28
|
+
...style
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
styled.style,
|
|
32
|
+
partsStyle,
|
|
33
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
34
|
+
className: cx("slurp-card", styled.className, className),
|
|
35
|
+
href,
|
|
36
|
+
style: vars,
|
|
37
|
+
...Root === "button" ? { type: "button" } : null,
|
|
38
|
+
...root,
|
|
39
|
+
children: [
|
|
40
|
+
part("media", "span", {
|
|
41
|
+
className: "slurp-card-media",
|
|
42
|
+
"aria-hidden": true,
|
|
43
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx("span", { className: "slurp-stage-glow" }),
|
|
45
|
+
/* @__PURE__ */ jsx("span", { className: "slurp-stage-ring" }),
|
|
46
|
+
media != null && /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: "slurp-card-art",
|
|
48
|
+
children: media
|
|
49
|
+
})
|
|
50
|
+
] })
|
|
51
|
+
}),
|
|
52
|
+
badge != null && part("badge", "span", {
|
|
53
|
+
className: "slurp-card-badge",
|
|
54
|
+
children: badge
|
|
55
|
+
}),
|
|
56
|
+
part("title", "span", {
|
|
57
|
+
className: "slurp-card-title",
|
|
58
|
+
children: title
|
|
59
|
+
}),
|
|
60
|
+
(description != null || value != null) && part("description", "span", {
|
|
61
|
+
className: "slurp-card-description",
|
|
62
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [description != null && /* @__PURE__ */ jsx("span", { children: description }), value != null && /* @__PURE__ */ jsxs("strong", { children: [valuePrefix != null && /* @__PURE__ */ jsxs(Fragment, { children: [valuePrefix, " "] }), value] })] })
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
export { Card };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","names":[],"sources":["../../src/Card/Card.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 CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {\n title: ReactNode;\n description?: ReactNode;\n /** A value shown strong in the description pill (\"1.239 €\"). */\n value?: ReactNode;\n /** Before the value (\"da\"). */\n valuePrefix?: ReactNode;\n /** Pill at the top right (\"−15%\"). */\n badge?: ReactNode;\n /** Tint (any hex); default the accent. */\n color?: string;\n /** The media in the middle (illustration, photo), decorative. */\n media?: ReactNode;\n /** Renders a link. */\n href?: string;\n}\n\nexport type CardProps<E extends ElementType = 'a'> = PolymorphicProps<E, CardOwnProps>;\n\n/**\n * One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the\n * bottom left, never covering it. A link with `href`, a button with `onClick`.\n */\nexport function Card<E extends ElementType = 'a'>(props: CardProps<E>) {\n const {\n as,\n css,\n className,\n title,\n description,\n value,\n valuePrefix,\n badge,\n color,\n media,\n href,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Card', props as CardProps);\n const Root = (as ?? (href ? 'a' : rest.onClick ? 'button' : 'div')) as ElementType;\n const styled = useCss('Card', 'root', css);\n const { part, style: partsStyle } = useParts('Card', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const vars = {\n ...(color\n ? {\n '--slurp-card-color': color,\n '--slurp-card-on': /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : 'var(--slurp-fg)',\n '--slurp-animation-tint': color,\n }\n : null),\n ...style,\n } as CSSProperties;\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-card', styled.className, className)}\n href={href}\n style={vars}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {part('media', 'span', {\n className: 'slurp-card-media',\n 'aria-hidden': true,\n children: (\n <>\n <span className=\"slurp-stage-glow\" />\n <span className=\"slurp-stage-ring\" />\n {media != null && <span className=\"slurp-card-art\">{media}</span>}\n </>\n ),\n })}\n {badge != null && part('badge', 'span', { className: 'slurp-card-badge', children: badge })}\n {part('title', 'span', { className: 'slurp-card-title', children: title })}\n {(description != null || value != null) &&\n part('description', 'span', {\n className: 'slurp-card-description',\n children: (\n <>\n {description != null && <span>{description}</span>}\n {value != null && (\n <strong>\n {valuePrefix != null && <>{valuePrefix} </>}\n {value}\n </strong>\n )}\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,OACA,aACA,OACA,OACA,OACA,MACA,OACA,OACA,WACA,YACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,OAAQ,OAAO,OAAO,MAAM,KAAK,UAAU,WAAW;CAC5D,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,GAAI,QACA;GACE,sBAAsB;GACtB,mBAAmB,kBAAkB,KAAK,KAAK,IAAI,QAAQ,KAAK,IAAI;GACpE,0BAA0B;EAC5B,IACA;EACJ,GAAG;CACL;CACA,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;GACjD;GACN,OAAO;GACP,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;GAC9C,GAAI;GALN,UAAA;IAOG,KAAK,SAAS,QAAQ;KACrB,WAAW;KACX,eAAe;KACf,UACE,qBAAA,UAAA,EAAA,UAAA;MACE,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACpC,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA;MACnC,SAAS,QAAQ,oBAAC,QAAD;OAAM,WAAU;OAAkB,UAAA;MAAY,CAAA;KAChE,EAAA,CAAA;IAEN,CAAC;IACA,SAAS,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;IACzF,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAoB,UAAU;IAAM,CAAC;KACvE,eAAe,QAAQ,SAAS,SAChC,KAAK,eAAe,QAAQ;KAC1B,WAAW;KACX,UACE,qBAAA,UAAA,EAAA,UAAA,CACG,eAAe,QAAQ,oBAAC,QAAD,EAAA,UAAO,YAAkB,CAAA,GAChD,SAAS,QACR,qBAAC,UAAD,EAAA,UAAA,CACG,eAAe,QAAQ,qBAAA,UAAA,EAAA,UAAA,CAAG,aAAY,GAAG,EAAA,CAAA,GACzC,KACK,EAAA,CAAA,CAEV,EAAA,CAAA;IAEN,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export type CellProps<E extends ElementType = 'div'> = PolymorphicProps<E>;
|
|
5
|
+
/** The base primitive: any element, styled with `css`. */
|
|
6
|
+
export declare function Cell<E extends ElementType = 'div'>(props: CellProps<E>): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=Cell.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Cell/Cell.tsx
|
|
7
|
+
/** The base primitive: any element, styled with `css`. */
|
|
8
|
+
function Cell(props) {
|
|
9
|
+
const { as, css, className, ...rest } = useThemeProps("Cell", props);
|
|
10
|
+
const Root = as ?? "div";
|
|
11
|
+
const styled = useCss("Cell", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
14
|
+
className: cx("slurp-cell", styled.className, className),
|
|
15
|
+
...root
|
|
16
|
+
})] });
|
|
17
|
+
}
|
|
18
|
+
export { Cell };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=Cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cell.js","names":[],"sources":["../../src/Cell/Cell.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport type CellProps<E extends ElementType = 'div'> = PolymorphicProps<E>;\n\n/** The base primitive: any element, styled with `css`. */\nexport function Cell<E extends ElementType = 'div'>(props: CellProps<E>) {\n const { as, css, className, ...rest } = useThemeProps('Cell', props as CellProps);\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Cell', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-cell', styled.className, className)} {...root} />\n </>\n );\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EAAE,IAAI,KAAK,WAAW,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAChF,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;CAAO,CAAA,CAC3E,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
/** Props of the native input, shared by Checkbox, Radio and Switch. */
|
|
5
|
+
export interface ToggleInputAttributes {
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Submitted value. */
|
|
8
|
+
value?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
/** id of the input. */
|
|
13
|
+
id?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CheckboxOwnProps extends ToggleInputAttributes, PartsProps<'input' | 'box' | 'label'> {
|
|
16
|
+
checked?: boolean;
|
|
17
|
+
defaultChecked?: boolean;
|
|
18
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
19
|
+
/** Mixed state (part of a set is checked): a dash instead of the check. */
|
|
20
|
+
indeterminate?: boolean;
|
|
21
|
+
/** The label. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export type CheckboxProps<E extends ElementType = 'label'> = PolymorphicProps<E, CheckboxOwnProps>;
|
|
25
|
+
/** Native checkbox with the design system's box: checked = accent fill + check (a shape, not only colour). */
|
|
26
|
+
export declare function Checkbox<E extends ElementType = 'label'>(props: CheckboxProps<E>): import("react").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { CheckIcon, MinusIcon } from "@slurp-ui/icons";
|
|
9
|
+
// src/Checkbox/Checkbox.tsx
|
|
10
|
+
const TOGGLE_KEYS = [
|
|
11
|
+
"name",
|
|
12
|
+
"value",
|
|
13
|
+
"required",
|
|
14
|
+
"disabled",
|
|
15
|
+
"autoFocus",
|
|
16
|
+
"id"
|
|
17
|
+
];
|
|
18
|
+
/** Splits the native input's props from the root's. */
|
|
19
|
+
function splitToggleProps(props) {
|
|
20
|
+
const input = {};
|
|
21
|
+
const root = {};
|
|
22
|
+
for (const [k, v] of Object.entries(props)) if (TOGGLE_KEYS.includes(k)) input[k] = v;
|
|
23
|
+
else root[k] = v;
|
|
24
|
+
return {
|
|
25
|
+
input,
|
|
26
|
+
root
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Native checkbox with the design system's box: checked = accent fill + check (a shape, not only colour). */
|
|
30
|
+
function Checkbox(props) {
|
|
31
|
+
const { as, css, className, checked: checkedProp, defaultChecked = false, onCheckedChange, indeterminate = false, children, parts, partProps, classNames, ...others } = useThemeProps("Checkbox", props);
|
|
32
|
+
const { input, root: rest } = splitToggleProps(others);
|
|
33
|
+
const [checked, setChecked] = useControlled({
|
|
34
|
+
value: checkedProp,
|
|
35
|
+
defaultValue: defaultChecked,
|
|
36
|
+
onChange: onCheckedChange
|
|
37
|
+
});
|
|
38
|
+
const syncIndeterminate = useCallback((el) => {
|
|
39
|
+
if (el) el.indeterminate = indeterminate;
|
|
40
|
+
}, [indeterminate]);
|
|
41
|
+
const Root = as ?? "label";
|
|
42
|
+
const styled = useCss("Checkbox", "root", css);
|
|
43
|
+
const { part, style } = useParts("Checkbox", {
|
|
44
|
+
parts,
|
|
45
|
+
partProps,
|
|
46
|
+
classNames
|
|
47
|
+
});
|
|
48
|
+
const root = useAnimationRoot(rest);
|
|
49
|
+
const state = indeterminate ? "mixed" : checked ? "on" : "off";
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
51
|
+
styled.style,
|
|
52
|
+
style,
|
|
53
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
54
|
+
className: cx("slurp-toggle", "slurp-checkbox", styled.className, className),
|
|
55
|
+
"data-state": state,
|
|
56
|
+
"data-disabled": input.disabled ? "" : void 0,
|
|
57
|
+
...root,
|
|
58
|
+
children: [
|
|
59
|
+
part("input", "input", {
|
|
60
|
+
...input,
|
|
61
|
+
ref: syncIndeterminate,
|
|
62
|
+
type: "checkbox",
|
|
63
|
+
className: "slurp-toggle-input",
|
|
64
|
+
checked,
|
|
65
|
+
onChange: (e) => setChecked(e.target.checked)
|
|
66
|
+
}),
|
|
67
|
+
part("box", "span", {
|
|
68
|
+
className: "slurp-checkbox-box",
|
|
69
|
+
"aria-hidden": true,
|
|
70
|
+
children: state === "mixed" ? /* @__PURE__ */ jsx(MinusIcon, { size: 16 }) : state === "on" ? /* @__PURE__ */ jsx(CheckIcon, { size: 16 }) : null
|
|
71
|
+
}),
|
|
72
|
+
children != null && part("label", "span", {
|
|
73
|
+
className: "slurp-toggle-label",
|
|
74
|
+
children
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export { Checkbox, splitToggleProps };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/Checkbox/Checkbox.tsx"],"sourcesContent":["import { CheckIcon, MinusIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { useCallback, type ChangeEvent, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\n/** Props of the native input, shared by Checkbox, Radio and Switch. */\nexport interface ToggleInputAttributes {\n name?: string;\n /** Submitted value. */\n value?: string;\n required?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** id of the input. */\n id?: string;\n}\n\nconst TOGGLE_KEYS = ['name', 'value', 'required', 'disabled', 'autoFocus', 'id'] as const;\n\n/** Splits the native input's props from the root's. */\nexport function splitToggleProps<P extends object>(props: P) {\n const input: Record<string, unknown> = {};\n const root: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(props)) {\n if ((TOGGLE_KEYS as readonly string[]).includes(k)) input[k] = v;\n else root[k] = v;\n }\n return { input, root };\n}\n\nexport interface CheckboxOwnProps\n extends ToggleInputAttributes, PartsProps<'input' | 'box' | 'label'> {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n /** Mixed state (part of a set is checked): a dash instead of the check. */\n indeterminate?: boolean;\n /** The label. */\n children?: ReactNode;\n}\n\nexport type CheckboxProps<E extends ElementType = 'label'> = PolymorphicProps<E, CheckboxOwnProps>;\n\n/** Native checkbox with the design system's box: checked = accent fill + check (a shape, not only colour). */\nexport function Checkbox<E extends ElementType = 'label'>(props: CheckboxProps<E>) {\n const {\n as,\n css,\n className,\n checked: checkedProp,\n defaultChecked = false,\n onCheckedChange,\n indeterminate = false,\n children,\n parts,\n partProps,\n classNames,\n ...others\n } = useThemeProps('Checkbox', props as CheckboxProps);\n const { input, root: rest } = splitToggleProps(others);\n const [checked, setChecked] = useControlled({\n value: checkedProp,\n defaultValue: defaultChecked,\n onChange: onCheckedChange,\n });\n const syncIndeterminate = useCallback(\n (el: HTMLInputElement | null) => {\n if (el) el.indeterminate = indeterminate;\n },\n [indeterminate],\n );\n const Root = (as ?? 'label') as ElementType;\n const styled = useCss('Checkbox', 'root', css);\n const { part, style } = useParts('Checkbox', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const state = indeterminate ? 'mixed' : checked ? 'on' : 'off';\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-toggle', 'slurp-checkbox', styled.className, className)}\n data-state={state}\n data-disabled={input.disabled ? '' : undefined}\n {...root}\n >\n {part('input', 'input', {\n ...input,\n ref: syncIndeterminate,\n type: 'checkbox',\n className: 'slurp-toggle-input',\n checked,\n onChange: (e: ChangeEvent<HTMLInputElement>) => setChecked(e.target.checked),\n })}\n {part('box', 'span', {\n className: 'slurp-checkbox-box',\n 'aria-hidden': true,\n children:\n state === 'mixed' ? (\n <MinusIcon size={16} />\n ) : state === 'on' ? (\n <CheckIcon size={16} />\n ) : null,\n })}\n {children != null && part('label', 'span', { className: 'slurp-toggle-label', children })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,cAAc;CAAC;CAAQ;CAAS;CAAY;CAAY;CAAa;AAAI;;AAG/E,SAAgB,iBAAmC,OAAU;CAC3D,MAAM,QAAiC,CAAC;CACxC,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,IAAK,YAAkC,SAAS,CAAC,GAAG,MAAM,KAAK;MAC1D,KAAK,KAAK;CAEjB,OAAO;EAAE;EAAO;CAAK;AACvB;;AAgBA,SAAgB,SAA0C,OAAyB;CACjF,MAAM,EACJ,IACA,KACA,WACA,SAAS,aACT,iBAAiB,OACjB,iBACA,gBAAgB,OAChB,UACA,OACA,WACA,YACA,GAAG,WACD,cAAc,YAAY,KAAsB;CACpD,MAAM,EAAE,OAAO,MAAM,SAAS,iBAAiB,MAAM;CACrD,MAAM,CAAC,SAAS,cAAc,cAAc;EAC1C,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,oBAAoB,aACvB,OAAgC;EAC/B,IAAI,IAAI,GAAG,gBAAgB;CAC7B,GACA,CAAC,aAAa,CAChB;CACA,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,YAAY,QAAQ,GAAG;CAC7C,MAAM,EAAE,MAAM,UAAU,SAAS,YAAY;EAAE;EAAO;EAAW;CAAW,CAAC;CAC7E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,QAAQ,gBAAgB,UAAU,UAAU,OAAO;CACzD,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,gBAAgB,kBAAkB,OAAO,WAAW,SAAS;GAC3E,cAAY;GACZ,iBAAe,MAAM,WAAW,KAAK,KAAA;GACrC,GAAI;GAJN,UAAA;IAMG,KAAK,SAAS,SAAS;KACtB,GAAG;KACH,KAAK;KACL,MAAM;KACN,WAAW;KACX;KACA,WAAW,MAAqC,WAAW,EAAE,OAAO,OAAO;IAC7E,CAAC;IACA,KAAK,OAAO,QAAQ;KACnB,WAAW;KACX,eAAe;KACf,UACE,UAAU,UACR,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,IACpB,UAAU,OACZ,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,IACpB;IACR,CAAC;IACA,YAAY,QAAQ,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAsB;IAAS,CAAC;GACpF;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface ChipOwnProps {
|
|
5
|
+
/** Selected (controlled). Selected = accent fill PLUS a check: never colour alone. */
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
defaultSelected?: boolean;
|
|
8
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
9
|
+
/** Leading icon, replaced by the check while selected. */
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export type ChipProps<E extends ElementType = 'button'> = PolymorphicProps<E, ChipOwnProps>;
|
|
13
|
+
/** Toggle chip (filters, options): `aria-pressed` reflects the state. */
|
|
14
|
+
export declare function Chip<E extends ElementType = 'button'>(props: ChipProps<E>): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { useControlled } from "../utils/useControlled.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { CheckIcon } from "@slurp-ui/icons";
|
|
8
|
+
// src/Chip/Chip.tsx
|
|
9
|
+
/** Toggle chip (filters, options): `aria-pressed` reflects the state. */
|
|
10
|
+
function Chip(props) {
|
|
11
|
+
const { as, css, className, selected: selectedProp, defaultSelected = false, onSelectedChange, icon, children, onClick, ...rest } = useThemeProps("Chip", props);
|
|
12
|
+
const [selected, setSelected] = useControlled({
|
|
13
|
+
value: selectedProp,
|
|
14
|
+
defaultValue: defaultSelected,
|
|
15
|
+
onChange: onSelectedChange
|
|
16
|
+
});
|
|
17
|
+
const Root = as ?? "button";
|
|
18
|
+
const styled = useCss("Chip", "root", css);
|
|
19
|
+
const root = useAnimationRoot(rest);
|
|
20
|
+
const mark = selected ? /* @__PURE__ */ jsx(CheckIcon, { size: 16 }) : icon;
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
22
|
+
className: cx("slurp-chip", styled.className, className),
|
|
23
|
+
"aria-pressed": selected,
|
|
24
|
+
"data-selected": selected || void 0,
|
|
25
|
+
...Root === "button" ? { type: "button" } : null,
|
|
26
|
+
onClick: (e) => {
|
|
27
|
+
onClick?.(e);
|
|
28
|
+
if (!e.defaultPrevented) setSelected(!selected);
|
|
29
|
+
},
|
|
30
|
+
...root,
|
|
31
|
+
children: [mark != null && /* @__PURE__ */ jsx("span", {
|
|
32
|
+
className: "slurp-chip-icon",
|
|
33
|
+
"aria-hidden": "true",
|
|
34
|
+
children: mark
|
|
35
|
+
}), /* @__PURE__ */ jsx("span", { children })]
|
|
36
|
+
})] });
|
|
37
|
+
}
|
|
38
|
+
export { Chip };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=Chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip.js","names":[],"sources":["../../src/Chip/Chip.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport type { ElementType, MouseEvent, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface ChipOwnProps {\n /** Selected (controlled). Selected = accent fill PLUS a check: never colour alone. */\n selected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (selected: boolean) => void;\n /** Leading icon, replaced by the check while selected. */\n icon?: ReactNode;\n}\n\nexport type ChipProps<E extends ElementType = 'button'> = PolymorphicProps<E, ChipOwnProps>;\n\n/** Toggle chip (filters, options): `aria-pressed` reflects the state. */\nexport function Chip<E extends ElementType = 'button'>(props: ChipProps<E>) {\n const {\n as,\n css,\n className,\n selected: selectedProp,\n defaultSelected = false,\n onSelectedChange,\n icon,\n children,\n onClick,\n ...rest\n } = useThemeProps('Chip', props as ChipProps);\n const [selected, setSelected] = useControlled({\n value: selectedProp,\n defaultValue: defaultSelected,\n onChange: onSelectedChange,\n });\n const Root = (as ?? 'button') as ElementType;\n const styled = useCss('Chip', 'root', css);\n const root = useAnimationRoot(rest);\n const mark = selected ? <CheckIcon size={16} /> : icon;\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-chip', styled.className, className)}\n aria-pressed={selected}\n data-selected={selected || undefined}\n {...(Root === 'button' ? { type: 'button' } : null)}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n (onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined)?.(e);\n if (!e.defaultPrevented) setSelected(!selected);\n }}\n {...root}\n >\n {mark != null && (\n <span className=\"slurp-chip-icon\" aria-hidden=\"true\">\n {mark}\n </span>\n )}\n <span>{children}</span>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAqBA,SAAgB,KAAuC,OAAqB;CAC1E,MAAM,EACJ,IACA,KACA,WACA,UAAU,cACV,kBAAkB,OAClB,kBACA,MACA,UACA,SACA,GAAG,SACD,cAAc,QAAQ,KAAkB;CAC5C,MAAM,CAAC,UAAU,eAAe,cAAc;EAC5C,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,OAAO,WAAW,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,IAAI;CAClD,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EACE,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EACvD,gBAAc;EACd,iBAAe,YAAY,KAAA;EAC3B,GAAK,SAAS,WAAW,EAAE,MAAM,SAAS,IAAI;EAC9C,UAAU,MAAqC;GAC7C,UAAwE,CAAC;GACzE,IAAI,CAAC,EAAE,kBAAkB,YAAY,CAAC,QAAQ;EAChD;EACA,GAAI;EATN,UAAA,CAWG,QAAQ,QACP,oBAAC,QAAD;GAAM,WAAU;GAAkB,eAAY;GAC3C,UAAA;EACG,CAAA,GAER,oBAAC,QAAD,EAAO,SAAe,CAAA,CAClB;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { BloomPlacement } from "../Bloom/Bloom.js";
|
|
4
|
+
import { ElementType, ReactNode } from "react";
|
|
5
|
+
export interface ChoiceOption<V extends string = string> {
|
|
6
|
+
value: V;
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ChoiceLabels {
|
|
12
|
+
/** Trigger text while nothing is chosen. */
|
|
13
|
+
placeholder: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const CHOICE_LABELS: ChoiceLabels;
|
|
16
|
+
export interface ChoiceOwnProps<V extends string = string> {
|
|
17
|
+
/** Visible label ("Ordina per"). */
|
|
18
|
+
label: ReactNode;
|
|
19
|
+
options: ChoiceOption<V>[];
|
|
20
|
+
value?: V | null;
|
|
21
|
+
defaultValue?: V | null;
|
|
22
|
+
onValueChange?: (value: V) => void;
|
|
23
|
+
/** Form field name: a hidden input carries the value. */
|
|
24
|
+
name?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Panel width. Default 280. */
|
|
27
|
+
width?: number;
|
|
28
|
+
placement?: BloomPlacement;
|
|
29
|
+
labels?: Partial<ChoiceLabels>;
|
|
30
|
+
}
|
|
31
|
+
export type ChoiceProps<V extends string = string, E extends ElementType = 'div'> = PolymorphicProps<E, ChoiceOwnProps<V>>;
|
|
32
|
+
/**
|
|
33
|
+
* Select: the trigger **becomes** the list (Bloom). ArrowDown / ArrowUp / Enter / Space open it on the trigger;
|
|
34
|
+
* in the list arrows move, Enter or Space choose, Escape closes and gives focus back.
|
|
35
|
+
*/
|
|
36
|
+
export declare function Choice<V extends string = string, E extends ElementType = 'div'>(props: ChoiceProps<V, E>): import("react").JSX.Element;
|
|
37
|
+
//# sourceMappingURL=Choice.d.ts.map
|