@misoto22/kioku-ui 0.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 +21 -0
- package/dist/Alert/Alert.d.ts +7 -0
- package/dist/Alert/Alert.doc.d.ts +11 -0
- package/dist/Alert/Alert.doc.js +15 -0
- package/dist/Alert/Alert.js +149 -0
- package/dist/Alert/index.d.ts +1 -0
- package/dist/Alert/index.js +2 -0
- package/dist/AsyncState/AsyncState.d.ts +30 -0
- package/dist/AsyncState/AsyncState.doc.d.ts +16 -0
- package/dist/AsyncState/AsyncState.doc.js +16 -0
- package/dist/AsyncState/AsyncState.js +36 -0
- package/dist/AsyncState/index.d.ts +1 -0
- package/dist/AsyncState/index.js +2 -0
- package/dist/Badge/Badge.d.ts +10 -0
- package/dist/Badge/Badge.doc.d.ts +11 -0
- package/dist/Badge/Badge.doc.js +12 -0
- package/dist/Badge/Badge.js +58 -0
- package/dist/Badge/index.d.ts +1 -0
- package/dist/Badge/index.js +2 -0
- package/dist/Button/Button.d.ts +18 -0
- package/dist/Button/Button.doc.d.ts +11 -0
- package/dist/Button/Button.doc.js +18 -0
- package/dist/Button/Button.js +151 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Button/index.js +2 -0
- package/dist/Card/Card.d.ts +6 -0
- package/dist/Card/Card.doc.d.ts +11 -0
- package/dist/Card/Card.doc.js +15 -0
- package/dist/Card/Card.js +41 -0
- package/dist/Card/index.d.ts +1 -0
- package/dist/Card/index.js +2 -0
- package/dist/CardFooter/CardFooter.d.ts +3 -0
- package/dist/CardFooter/CardFooter.doc.d.ts +11 -0
- package/dist/CardFooter/CardFooter.doc.js +12 -0
- package/dist/CardFooter/CardFooter.js +16 -0
- package/dist/CardFooter/index.d.ts +1 -0
- package/dist/CardFooter/index.js +2 -0
- package/dist/CardHeader/CardHeader.d.ts +3 -0
- package/dist/CardHeader/CardHeader.doc.d.ts +11 -0
- package/dist/CardHeader/CardHeader.doc.js +12 -0
- package/dist/CardHeader/CardHeader.js +16 -0
- package/dist/CardHeader/index.d.ts +1 -0
- package/dist/CardHeader/index.js +2 -0
- package/dist/Center/Center.d.ts +3 -0
- package/dist/Center/Center.doc.d.ts +11 -0
- package/dist/Center/Center.doc.js +12 -0
- package/dist/Center/Center.js +15 -0
- package/dist/Center/index.d.ts +1 -0
- package/dist/Center/index.js +2 -0
- package/dist/Divider/Divider.d.ts +3 -0
- package/dist/Divider/Divider.doc.d.ts +11 -0
- package/dist/Divider/Divider.doc.js +12 -0
- package/dist/Divider/Divider.js +12 -0
- package/dist/Divider/index.d.ts +1 -0
- package/dist/Divider/index.js +2 -0
- package/dist/EmptyState/EmptyState.d.ts +11 -0
- package/dist/EmptyState/EmptyState.doc.d.ts +16 -0
- package/dist/EmptyState/EmptyState.doc.js +25 -0
- package/dist/EmptyState/EmptyState.js +55 -0
- package/dist/EmptyState/index.d.ts +1 -0
- package/dist/EmptyState/index.js +2 -0
- package/dist/Field/Field.d.ts +21 -0
- package/dist/Field/Field.doc.d.ts +16 -0
- package/dist/Field/Field.doc.js +28 -0
- package/dist/Field/Field.js +117 -0
- package/dist/Field/index.d.ts +1 -0
- package/dist/Field/index.js +2 -0
- package/dist/Grid/Grid.d.ts +7 -0
- package/dist/Grid/Grid.doc.d.ts +11 -0
- package/dist/Grid/Grid.doc.js +15 -0
- package/dist/Grid/Grid.js +76 -0
- package/dist/Grid/index.d.ts +1 -0
- package/dist/Grid/index.js +2 -0
- package/dist/Heading/Heading.d.ts +293 -0
- package/dist/Heading/Heading.doc.d.ts +16 -0
- package/dist/Heading/Heading.doc.js +19 -0
- package/dist/Heading/Heading.js +47 -0
- package/dist/Heading/index.d.ts +1 -0
- package/dist/Heading/index.js +2 -0
- package/dist/IconButton/IconButton.d.ts +9 -0
- package/dist/IconButton/IconButton.doc.d.ts +16 -0
- package/dist/IconButton/IconButton.doc.js +22 -0
- package/dist/IconButton/IconButton.js +11 -0
- package/dist/IconButton/index.d.ts +1 -0
- package/dist/IconButton/index.js +2 -0
- package/dist/MetricGrid/MetricGrid.d.ts +10 -0
- package/dist/MetricGrid/MetricGrid.doc.d.ts +12 -0
- package/dist/MetricGrid/MetricGrid.doc.js +13 -0
- package/dist/MetricGrid/MetricGrid.js +37 -0
- package/dist/MetricGrid/index.d.ts +1 -0
- package/dist/MetricGrid/index.js +2 -0
- package/dist/Section/Section.d.ts +6 -0
- package/dist/Section/Section.doc.d.ts +11 -0
- package/dist/Section/Section.doc.js +12 -0
- package/dist/Section/Section.js +49 -0
- package/dist/Section/index.d.ts +1 -0
- package/dist/Section/index.js +2 -0
- package/dist/SegmentedControl/SegmentedControl.d.ts +31 -0
- package/dist/SegmentedControl/SegmentedControl.doc.d.ts +16 -0
- package/dist/SegmentedControl/SegmentedControl.doc.js +34 -0
- package/dist/SegmentedControl/SegmentedControl.js +108 -0
- package/dist/SegmentedControl/index.d.ts +1 -0
- package/dist/SegmentedControl/index.js +2 -0
- package/dist/Skeleton/Skeleton.d.ts +5 -0
- package/dist/Skeleton/Skeleton.doc.d.ts +11 -0
- package/dist/Skeleton/Skeleton.doc.js +12 -0
- package/dist/Skeleton/Skeleton.js +20 -0
- package/dist/Skeleton/index.d.ts +1 -0
- package/dist/Skeleton/index.js +2 -0
- package/dist/Spinner/Spinner.d.ts +6 -0
- package/dist/Spinner/Spinner.doc.d.ts +12 -0
- package/dist/Spinner/Spinner.doc.js +13 -0
- package/dist/Spinner/Spinner.js +25 -0
- package/dist/Spinner/index.d.ts +1 -0
- package/dist/Spinner/index.js +2 -0
- package/dist/Stack/Stack.d.ts +7 -0
- package/dist/Stack/Stack.doc.d.ts +11 -0
- package/dist/Stack/Stack.doc.js +15 -0
- package/dist/Stack/Stack.js +77 -0
- package/dist/Stack/index.d.ts +1 -0
- package/dist/Stack/index.js +2 -0
- package/dist/StatusDot/StatusDot.d.ts +8 -0
- package/dist/StatusDot/StatusDot.doc.d.ts +16 -0
- package/dist/StatusDot/StatusDot.doc.js +16 -0
- package/dist/StatusDot/StatusDot.js +46 -0
- package/dist/StatusDot/index.d.ts +1 -0
- package/dist/StatusDot/index.js +2 -0
- package/dist/Table/Table.d.ts +20 -0
- package/dist/Table/Table.doc.d.ts +92 -0
- package/dist/Table/Table.doc.js +94 -0
- package/dist/Table/Table.js +205 -0
- package/dist/Table/index.d.ts +1 -0
- package/dist/Table/index.js +2 -0
- package/dist/Text/Text.d.ts +7 -0
- package/dist/Text/Text.doc.d.ts +11 -0
- package/dist/Text/Text.doc.js +15 -0
- package/dist/Text/Text.js +50 -0
- package/dist/Text/index.d.ts +1 -0
- package/dist/Text/index.js +2 -0
- package/dist/TextArea/TextArea.d.ts +16 -0
- package/dist/TextArea/TextArea.doc.d.ts +11 -0
- package/dist/TextArea/TextArea.doc.js +30 -0
- package/dist/TextArea/TextArea.js +47 -0
- package/dist/TextArea/index.d.ts +1 -0
- package/dist/TextArea/index.js +2 -0
- package/dist/TextInput/TextInput.d.ts +16 -0
- package/dist/TextInput/TextInput.doc.d.ts +11 -0
- package/dist/TextInput/TextInput.doc.js +30 -0
- package/dist/TextInput/TextInput.js +49 -0
- package/dist/TextInput/index.d.ts +1 -0
- package/dist/TextInput/index.js +2 -0
- package/dist/Toggle/Toggle.d.ts +16 -0
- package/dist/Toggle/Toggle.doc.d.ts +11 -0
- package/dist/Toggle/Toggle.doc.js +21 -0
- package/dist/Toggle/Toggle.js +64 -0
- package/dist/Toggle/index.d.ts +1 -0
- package/dist/Toggle/index.js +2 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +3 -0
- package/dist/VisuallyHidden/VisuallyHidden.doc.d.ts +11 -0
- package/dist/VisuallyHidden/VisuallyHidden.doc.js +12 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/VisuallyHidden/index.d.ts +1 -0
- package/dist/VisuallyHidden/index.js +2 -0
- package/dist/authoring.stylex.d.ts +75 -0
- package/dist/authoring.stylex.js +77 -0
- package/dist/components/Alert.d.ts +7 -0
- package/dist/components/Alert.doc.d.ts +11 -0
- package/dist/components/Alert.doc.js +15 -0
- package/dist/components/Alert.js +149 -0
- package/dist/components/AsyncState.d.ts +30 -0
- package/dist/components/AsyncState.doc.d.ts +16 -0
- package/dist/components/AsyncState.doc.js +16 -0
- package/dist/components/AsyncState.js +36 -0
- package/dist/components/Badge.d.ts +10 -0
- package/dist/components/Badge.doc.d.ts +11 -0
- package/dist/components/Badge.doc.js +12 -0
- package/dist/components/Badge.js +58 -0
- package/dist/components/Button.d.ts +18 -0
- package/dist/components/Button.doc.d.ts +11 -0
- package/dist/components/Button.doc.js +18 -0
- package/dist/components/Button.js +151 -0
- package/dist/components/Card.d.ts +6 -0
- package/dist/components/Card.doc.d.ts +11 -0
- package/dist/components/Card.doc.js +15 -0
- package/dist/components/Card.js +41 -0
- package/dist/components/CardFooter.d.ts +3 -0
- package/dist/components/CardFooter.doc.d.ts +11 -0
- package/dist/components/CardFooter.doc.js +12 -0
- package/dist/components/CardFooter.js +16 -0
- package/dist/components/CardHeader.d.ts +3 -0
- package/dist/components/CardHeader.doc.d.ts +11 -0
- package/dist/components/CardHeader.doc.js +12 -0
- package/dist/components/CardHeader.js +16 -0
- package/dist/components/Center.d.ts +3 -0
- package/dist/components/Center.doc.d.ts +11 -0
- package/dist/components/Center.doc.js +12 -0
- package/dist/components/Center.js +15 -0
- package/dist/components/Divider.d.ts +3 -0
- package/dist/components/Divider.doc.d.ts +11 -0
- package/dist/components/Divider.doc.js +12 -0
- package/dist/components/Divider.js +12 -0
- package/dist/components/EmptyState.d.ts +11 -0
- package/dist/components/EmptyState.doc.d.ts +16 -0
- package/dist/components/EmptyState.doc.js +25 -0
- package/dist/components/EmptyState.js +55 -0
- package/dist/components/Field.d.ts +21 -0
- package/dist/components/Field.doc.d.ts +16 -0
- package/dist/components/Field.doc.js +28 -0
- package/dist/components/Field.js +117 -0
- package/dist/components/Grid.d.ts +7 -0
- package/dist/components/Grid.doc.d.ts +11 -0
- package/dist/components/Grid.doc.js +15 -0
- package/dist/components/Grid.js +76 -0
- package/dist/components/Heading.d.ts +293 -0
- package/dist/components/Heading.doc.d.ts +16 -0
- package/dist/components/Heading.doc.js +19 -0
- package/dist/components/Heading.js +46 -0
- package/dist/components/IconButton.d.ts +9 -0
- package/dist/components/IconButton.doc.d.ts +16 -0
- package/dist/components/IconButton.doc.js +22 -0
- package/dist/components/IconButton.js +11 -0
- package/dist/components/MetricGrid.d.ts +10 -0
- package/dist/components/MetricGrid.doc.d.ts +12 -0
- package/dist/components/MetricGrid.doc.js +13 -0
- package/dist/components/MetricGrid.js +37 -0
- package/dist/components/Section.d.ts +6 -0
- package/dist/components/Section.doc.d.ts +11 -0
- package/dist/components/Section.doc.js +12 -0
- package/dist/components/Section.js +49 -0
- package/dist/components/SegmentedControl.d.ts +31 -0
- package/dist/components/SegmentedControl.doc.d.ts +16 -0
- package/dist/components/SegmentedControl.doc.js +34 -0
- package/dist/components/SegmentedControl.js +108 -0
- package/dist/components/Skeleton.d.ts +5 -0
- package/dist/components/Skeleton.doc.d.ts +11 -0
- package/dist/components/Skeleton.doc.js +12 -0
- package/dist/components/Skeleton.js +20 -0
- package/dist/components/Spinner.d.ts +6 -0
- package/dist/components/Spinner.doc.d.ts +12 -0
- package/dist/components/Spinner.doc.js +13 -0
- package/dist/components/Spinner.js +25 -0
- package/dist/components/Stack.d.ts +7 -0
- package/dist/components/Stack.doc.d.ts +11 -0
- package/dist/components/Stack.doc.js +15 -0
- package/dist/components/Stack.js +77 -0
- package/dist/components/StatusDot.d.ts +8 -0
- package/dist/components/StatusDot.doc.d.ts +16 -0
- package/dist/components/StatusDot.doc.js +16 -0
- package/dist/components/StatusDot.js +46 -0
- package/dist/components/Table.d.ts +20 -0
- package/dist/components/Table.doc.d.ts +92 -0
- package/dist/components/Table.doc.js +94 -0
- package/dist/components/Table.js +205 -0
- package/dist/components/Text.d.ts +7 -0
- package/dist/components/Text.doc.d.ts +11 -0
- package/dist/components/Text.doc.js +15 -0
- package/dist/components/Text.js +50 -0
- package/dist/components/TextArea.d.ts +16 -0
- package/dist/components/TextArea.doc.d.ts +11 -0
- package/dist/components/TextArea.doc.js +30 -0
- package/dist/components/TextArea.js +47 -0
- package/dist/components/TextInput.d.ts +16 -0
- package/dist/components/TextInput.doc.d.ts +11 -0
- package/dist/components/TextInput.doc.js +30 -0
- package/dist/components/TextInput.js +49 -0
- package/dist/components/Toggle.d.ts +16 -0
- package/dist/components/Toggle.doc.d.ts +11 -0
- package/dist/components/Toggle.doc.js +21 -0
- package/dist/components/Toggle.js +64 -0
- package/dist/components/VisuallyHidden.d.ts +3 -0
- package/dist/components/VisuallyHidden.doc.d.ts +11 -0
- package/dist/components/VisuallyHidden.doc.js +12 -0
- package/dist/components/VisuallyHidden.js +15 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.js +28 -0
- package/dist/docs/index.d.ts +33 -0
- package/dist/docs/index.js +33 -0
- package/dist/docs/types.d.ts +15 -0
- package/dist/docs/types.js +25 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +32 -0
- package/dist/navigation/LinkProvider.d.ts +9 -0
- package/dist/navigation/LinkProvider.doc.d.ts +27 -0
- package/dist/navigation/LinkProvider.doc.js +27 -0
- package/dist/navigation/LinkProvider.js +22 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +2 -0
- package/dist/styles/global.stylex.d.ts +20 -0
- package/dist/styles/global.stylex.js +22 -0
- package/dist/styles/index.css +14 -0
- package/dist/styles/reset.css +35 -0
- package/dist/styles/stylex.css +212 -0
- package/dist/theme/Theme.d.ts +24 -0
- package/dist/theme/Theme.doc.d.ts +16 -0
- package/dist/theme/Theme.doc.js +27 -0
- package/dist/theme/Theme.js +110 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/tokens/contracts.d.ts +140 -0
- package/dist/tokens/contracts.js +102 -0
- package/package.json +93 -0
- package/src/Alert/Alert.doc.ts +21 -0
- package/src/Alert/Alert.tsx +129 -0
- package/src/Alert/index.ts +1 -0
- package/src/AsyncState/AsyncState.doc.ts +21 -0
- package/src/AsyncState/AsyncState.tsx +75 -0
- package/src/AsyncState/index.ts +5 -0
- package/src/Badge/Badge.doc.ts +15 -0
- package/src/Badge/Badge.tsx +58 -0
- package/src/Badge/index.ts +6 -0
- package/src/Button/Button.doc.ts +17 -0
- package/src/Button/Button.tsx +176 -0
- package/src/Button/index.ts +7 -0
- package/src/Card/Card.doc.ts +22 -0
- package/src/Card/Card.tsx +44 -0
- package/src/Card/index.ts +1 -0
- package/src/CardFooter/CardFooter.doc.ts +12 -0
- package/src/CardFooter/CardFooter.tsx +27 -0
- package/src/CardFooter/index.ts +1 -0
- package/src/CardHeader/CardHeader.doc.ts +12 -0
- package/src/CardHeader/CardHeader.tsx +27 -0
- package/src/CardHeader/index.ts +1 -0
- package/src/Center/Center.doc.ts +12 -0
- package/src/Center/Center.tsx +20 -0
- package/src/Center/index.ts +1 -0
- package/src/Divider/Divider.doc.ts +12 -0
- package/src/Divider/Divider.tsx +20 -0
- package/src/Divider/index.ts +1 -0
- package/src/EmptyState/EmptyState.doc.ts +31 -0
- package/src/EmptyState/EmptyState.tsx +87 -0
- package/src/EmptyState/index.ts +6 -0
- package/src/Field/Field.doc.ts +34 -0
- package/src/Field/Field.tsx +126 -0
- package/src/Field/index.ts +6 -0
- package/src/Grid/Grid.doc.ts +16 -0
- package/src/Grid/Grid.tsx +54 -0
- package/src/Grid/index.ts +1 -0
- package/src/Heading/Heading.doc.ts +26 -0
- package/src/Heading/Heading.tsx +48 -0
- package/src/Heading/index.ts +1 -0
- package/src/IconButton/IconButton.doc.ts +24 -0
- package/src/IconButton/IconButton.tsx +18 -0
- package/src/IconButton/index.ts +1 -0
- package/src/MetricGrid/MetricGrid.doc.ts +19 -0
- package/src/MetricGrid/MetricGrid.tsx +72 -0
- package/src/MetricGrid/index.ts +5 -0
- package/src/Section/Section.doc.ts +12 -0
- package/src/Section/Section.tsx +38 -0
- package/src/Section/index.ts +1 -0
- package/src/SegmentedControl/SegmentedControl.doc.ts +51 -0
- package/src/SegmentedControl/SegmentedControl.tsx +238 -0
- package/src/SegmentedControl/index.ts +5 -0
- package/src/Skeleton/Skeleton.doc.ts +15 -0
- package/src/Skeleton/Skeleton.tsx +45 -0
- package/src/Skeleton/index.ts +1 -0
- package/src/Spinner/Spinner.doc.ts +19 -0
- package/src/Spinner/Spinner.tsx +47 -0
- package/src/Spinner/index.ts +1 -0
- package/src/Stack/Stack.doc.ts +13 -0
- package/src/Stack/Stack.tsx +57 -0
- package/src/Stack/index.ts +1 -0
- package/src/StatusDot/StatusDot.doc.ts +23 -0
- package/src/StatusDot/StatusDot.tsx +35 -0
- package/src/StatusDot/index.ts +1 -0
- package/src/Table/Table.doc.ts +104 -0
- package/src/Table/Table.tsx +222 -0
- package/src/Table/index.ts +18 -0
- package/src/Text/Text.doc.ts +17 -0
- package/src/Text/Text.tsx +43 -0
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.doc.ts +43 -0
- package/src/TextArea/TextArea.tsx +119 -0
- package/src/TextArea/index.ts +1 -0
- package/src/TextInput/TextInput.doc.ts +43 -0
- package/src/TextInput/TextInput.tsx +122 -0
- package/src/TextInput/index.ts +1 -0
- package/src/Toggle/Toggle.doc.ts +30 -0
- package/src/Toggle/Toggle.tsx +139 -0
- package/src/Toggle/index.ts +1 -0
- package/src/VisuallyHidden/VisuallyHidden.doc.ts +18 -0
- package/src/VisuallyHidden/VisuallyHidden.tsx +28 -0
- package/src/VisuallyHidden/index.ts +1 -0
- package/src/authoring.stylex.ts +76 -0
- package/src/docs/index.ts +122 -0
- package/src/docs/types.ts +51 -0
- package/src/index.ts +102 -0
- package/src/navigation/LinkProvider.doc.ts +32 -0
- package/src/navigation/LinkProvider.tsx +32 -0
- package/src/navigation/index.ts +7 -0
- package/src/styles/global.stylex.ts +23 -0
- package/src/styles/index.css +14 -0
- package/src/styles/reset.css +35 -0
- package/src/theme/Theme.doc.ts +38 -0
- package/src/theme/Theme.tsx +195 -0
- package/src/theme/index.ts +9 -0
- package/src/tokens/contracts.ts +210 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
type Roles<Group extends string, Role extends string> = Readonly<{
|
|
2
|
+
[Name in Role]: `${Group}.${Name}`;
|
|
3
|
+
}>;
|
|
4
|
+
type ColorRole = 'canvas' | 'surface' | 'surfaceRaised' | 'surfaceMuted' | 'text' | 'textSecondary' | 'textMuted' | 'textOnAccent' | 'accent' | 'accentHover' | 'accentActive' | 'overlayHover' | 'overlayActive' | 'disabledSurface' | 'disabledText' | 'focus';
|
|
5
|
+
type BorderRole = 'default' | 'strong' | 'interactive' | 'disabled' | 'width' | 'style';
|
|
6
|
+
type StatusRole = 'infoSurface' | 'infoText' | 'successSurface' | 'successText' | 'warningSurface' | 'warningText' | 'dangerSurface' | 'dangerText';
|
|
7
|
+
type FocusRole = 'width' | 'offset';
|
|
8
|
+
type TypographyRole = 'fontFamilyBody' | 'fontFamilyHeading' | 'fontFamilyDisplay' | 'fontFamilyMono' | 'fontFeatureSettings' | 'fontSizeXs' | 'fontSizeSm' | 'fontSizeMd' | 'fontSizeLg' | 'fontSizeXl' | 'fontSize2xl' | 'fontWeightRegular' | 'fontWeightMedium' | 'fontWeightStrong' | 'lineHeightBody' | 'lineHeightHeading';
|
|
9
|
+
type SpacingRole = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
10
|
+
type RadiusRole = 'inner' | 'element' | 'container' | 'page' | 'full';
|
|
11
|
+
type SizeRole = 'controlSm' | 'controlMd' | 'controlLg' | 'hitTarget';
|
|
12
|
+
type TextureRole = 'grain';
|
|
13
|
+
type ElevationRole = 'low' | 'medium' | 'high';
|
|
14
|
+
type MotionRole = 'durationFast' | 'durationModerate' | 'durationSlow' | 'easingStandard' | 'easingEmphasized';
|
|
15
|
+
export interface TokenContract {
|
|
16
|
+
readonly color: Roles<'color', ColorRole>;
|
|
17
|
+
readonly border: Roles<'border', BorderRole>;
|
|
18
|
+
readonly status: Roles<'status', StatusRole>;
|
|
19
|
+
readonly focus: Roles<'focus', FocusRole>;
|
|
20
|
+
readonly typography: Roles<'typography', TypographyRole>;
|
|
21
|
+
readonly spacing: Roles<'spacing', SpacingRole>;
|
|
22
|
+
readonly radius: Roles<'radius', RadiusRole>;
|
|
23
|
+
readonly size: Roles<'size', SizeRole>;
|
|
24
|
+
readonly elevation: Roles<'elevation', ElevationRole>;
|
|
25
|
+
readonly texture: Roles<'texture', TextureRole>;
|
|
26
|
+
readonly motion: Roles<'motion', MotionRole>;
|
|
27
|
+
}
|
|
28
|
+
export declare const tokenContract: {
|
|
29
|
+
readonly color: {
|
|
30
|
+
readonly canvas: "color.canvas";
|
|
31
|
+
readonly surface: "color.surface";
|
|
32
|
+
readonly surfaceRaised: "color.surfaceRaised";
|
|
33
|
+
readonly surfaceMuted: "color.surfaceMuted";
|
|
34
|
+
readonly text: "color.text";
|
|
35
|
+
readonly textSecondary: "color.textSecondary";
|
|
36
|
+
readonly textMuted: "color.textMuted";
|
|
37
|
+
readonly textOnAccent: "color.textOnAccent";
|
|
38
|
+
readonly accent: "color.accent";
|
|
39
|
+
readonly accentHover: "color.accentHover";
|
|
40
|
+
readonly accentActive: "color.accentActive";
|
|
41
|
+
readonly overlayHover: "color.overlayHover";
|
|
42
|
+
readonly overlayActive: "color.overlayActive";
|
|
43
|
+
readonly disabledSurface: "color.disabledSurface";
|
|
44
|
+
readonly disabledText: "color.disabledText";
|
|
45
|
+
readonly focus: "color.focus";
|
|
46
|
+
};
|
|
47
|
+
readonly border: {
|
|
48
|
+
readonly default: "border.default";
|
|
49
|
+
readonly strong: "border.strong";
|
|
50
|
+
readonly interactive: "border.interactive";
|
|
51
|
+
readonly disabled: "border.disabled";
|
|
52
|
+
readonly width: "border.width";
|
|
53
|
+
readonly style: "border.style";
|
|
54
|
+
};
|
|
55
|
+
readonly status: {
|
|
56
|
+
readonly infoSurface: "status.infoSurface";
|
|
57
|
+
readonly infoText: "status.infoText";
|
|
58
|
+
readonly successSurface: "status.successSurface";
|
|
59
|
+
readonly successText: "status.successText";
|
|
60
|
+
readonly warningSurface: "status.warningSurface";
|
|
61
|
+
readonly warningText: "status.warningText";
|
|
62
|
+
readonly dangerSurface: "status.dangerSurface";
|
|
63
|
+
readonly dangerText: "status.dangerText";
|
|
64
|
+
};
|
|
65
|
+
readonly focus: {
|
|
66
|
+
readonly width: "focus.width";
|
|
67
|
+
readonly offset: "focus.offset";
|
|
68
|
+
};
|
|
69
|
+
readonly typography: {
|
|
70
|
+
readonly fontFamilyBody: "typography.fontFamilyBody";
|
|
71
|
+
readonly fontFamilyHeading: "typography.fontFamilyHeading";
|
|
72
|
+
readonly fontFamilyDisplay: "typography.fontFamilyDisplay";
|
|
73
|
+
readonly fontFamilyMono: "typography.fontFamilyMono";
|
|
74
|
+
readonly fontFeatureSettings: "typography.fontFeatureSettings";
|
|
75
|
+
readonly fontSizeXs: "typography.fontSizeXs";
|
|
76
|
+
readonly fontSizeSm: "typography.fontSizeSm";
|
|
77
|
+
readonly fontSizeMd: "typography.fontSizeMd";
|
|
78
|
+
readonly fontSizeLg: "typography.fontSizeLg";
|
|
79
|
+
readonly fontSizeXl: "typography.fontSizeXl";
|
|
80
|
+
readonly fontSize2xl: "typography.fontSize2xl";
|
|
81
|
+
readonly fontWeightRegular: "typography.fontWeightRegular";
|
|
82
|
+
readonly fontWeightMedium: "typography.fontWeightMedium";
|
|
83
|
+
readonly fontWeightStrong: "typography.fontWeightStrong";
|
|
84
|
+
readonly lineHeightBody: "typography.lineHeightBody";
|
|
85
|
+
readonly lineHeightHeading: "typography.lineHeightHeading";
|
|
86
|
+
};
|
|
87
|
+
readonly spacing: {
|
|
88
|
+
readonly xs: "spacing.xs";
|
|
89
|
+
readonly sm: "spacing.sm";
|
|
90
|
+
readonly md: "spacing.md";
|
|
91
|
+
readonly lg: "spacing.lg";
|
|
92
|
+
readonly xl: "spacing.xl";
|
|
93
|
+
readonly '2xl': "spacing.2xl";
|
|
94
|
+
};
|
|
95
|
+
readonly radius: {
|
|
96
|
+
readonly inner: "radius.inner";
|
|
97
|
+
readonly element: "radius.element";
|
|
98
|
+
readonly container: "radius.container";
|
|
99
|
+
readonly page: "radius.page";
|
|
100
|
+
readonly full: "radius.full";
|
|
101
|
+
};
|
|
102
|
+
readonly size: {
|
|
103
|
+
readonly controlSm: "size.controlSm";
|
|
104
|
+
readonly controlMd: "size.controlMd";
|
|
105
|
+
readonly controlLg: "size.controlLg";
|
|
106
|
+
readonly hitTarget: "size.hitTarget";
|
|
107
|
+
};
|
|
108
|
+
readonly elevation: {
|
|
109
|
+
readonly low: "elevation.low";
|
|
110
|
+
readonly medium: "elevation.medium";
|
|
111
|
+
readonly high: "elevation.high";
|
|
112
|
+
};
|
|
113
|
+
readonly texture: {
|
|
114
|
+
readonly grain: "texture.grain";
|
|
115
|
+
};
|
|
116
|
+
readonly motion: {
|
|
117
|
+
readonly durationFast: "motion.durationFast";
|
|
118
|
+
readonly durationModerate: "motion.durationModerate";
|
|
119
|
+
readonly durationSlow: "motion.durationSlow";
|
|
120
|
+
readonly easingStandard: "motion.easingStandard";
|
|
121
|
+
readonly easingEmphasized: "motion.easingEmphasized";
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
type ContractGroup = (typeof tokenContract)[keyof typeof tokenContract];
|
|
125
|
+
type Values<Value> = Value extends unknown ? Value[keyof Value] : never;
|
|
126
|
+
export type TokenName = Values<ContractGroup>;
|
|
127
|
+
export declare const tokenNames: readonly TokenName[];
|
|
128
|
+
export interface ThemeDefinition {
|
|
129
|
+
readonly id: string;
|
|
130
|
+
readonly label: string;
|
|
131
|
+
readonly tokens: Readonly<Record<TokenName, string>>;
|
|
132
|
+
}
|
|
133
|
+
export interface ThemeDefinitionCandidate {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
readonly label?: string;
|
|
136
|
+
readonly tokens: Readonly<Partial<Record<TokenName, string>>>;
|
|
137
|
+
}
|
|
138
|
+
export declare function validateThemeDefinition(theme: ThemeDefinitionCandidate): TokenName[];
|
|
139
|
+
export declare const tokenCustomProperties: Readonly<Record<TokenName, `--kioku-ui-${string}`>>;
|
|
140
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import "../styles/stylex.css";
|
|
2
|
+
export const tokenContract = {
|
|
3
|
+
color: {
|
|
4
|
+
canvas: 'color.canvas',
|
|
5
|
+
surface: 'color.surface',
|
|
6
|
+
surfaceRaised: 'color.surfaceRaised',
|
|
7
|
+
surfaceMuted: 'color.surfaceMuted',
|
|
8
|
+
text: 'color.text',
|
|
9
|
+
textSecondary: 'color.textSecondary',
|
|
10
|
+
textMuted: 'color.textMuted',
|
|
11
|
+
textOnAccent: 'color.textOnAccent',
|
|
12
|
+
accent: 'color.accent',
|
|
13
|
+
accentHover: 'color.accentHover',
|
|
14
|
+
accentActive: 'color.accentActive',
|
|
15
|
+
overlayHover: 'color.overlayHover',
|
|
16
|
+
overlayActive: 'color.overlayActive',
|
|
17
|
+
disabledSurface: 'color.disabledSurface',
|
|
18
|
+
disabledText: 'color.disabledText',
|
|
19
|
+
focus: 'color.focus'
|
|
20
|
+
},
|
|
21
|
+
border: {
|
|
22
|
+
default: 'border.default',
|
|
23
|
+
strong: 'border.strong',
|
|
24
|
+
interactive: 'border.interactive',
|
|
25
|
+
disabled: 'border.disabled',
|
|
26
|
+
width: 'border.width',
|
|
27
|
+
style: 'border.style'
|
|
28
|
+
},
|
|
29
|
+
status: {
|
|
30
|
+
infoSurface: 'status.infoSurface',
|
|
31
|
+
infoText: 'status.infoText',
|
|
32
|
+
successSurface: 'status.successSurface',
|
|
33
|
+
successText: 'status.successText',
|
|
34
|
+
warningSurface: 'status.warningSurface',
|
|
35
|
+
warningText: 'status.warningText',
|
|
36
|
+
dangerSurface: 'status.dangerSurface',
|
|
37
|
+
dangerText: 'status.dangerText'
|
|
38
|
+
},
|
|
39
|
+
focus: {
|
|
40
|
+
width: 'focus.width',
|
|
41
|
+
offset: 'focus.offset'
|
|
42
|
+
},
|
|
43
|
+
typography: {
|
|
44
|
+
fontFamilyBody: 'typography.fontFamilyBody',
|
|
45
|
+
fontFamilyHeading: 'typography.fontFamilyHeading',
|
|
46
|
+
fontFamilyDisplay: 'typography.fontFamilyDisplay',
|
|
47
|
+
fontFamilyMono: 'typography.fontFamilyMono',
|
|
48
|
+
fontFeatureSettings: 'typography.fontFeatureSettings',
|
|
49
|
+
fontSizeXs: 'typography.fontSizeXs',
|
|
50
|
+
fontSizeSm: 'typography.fontSizeSm',
|
|
51
|
+
fontSizeMd: 'typography.fontSizeMd',
|
|
52
|
+
fontSizeLg: 'typography.fontSizeLg',
|
|
53
|
+
fontSizeXl: 'typography.fontSizeXl',
|
|
54
|
+
fontSize2xl: 'typography.fontSize2xl',
|
|
55
|
+
fontWeightRegular: 'typography.fontWeightRegular',
|
|
56
|
+
fontWeightMedium: 'typography.fontWeightMedium',
|
|
57
|
+
fontWeightStrong: 'typography.fontWeightStrong',
|
|
58
|
+
lineHeightBody: 'typography.lineHeightBody',
|
|
59
|
+
lineHeightHeading: 'typography.lineHeightHeading'
|
|
60
|
+
},
|
|
61
|
+
spacing: {
|
|
62
|
+
xs: 'spacing.xs',
|
|
63
|
+
sm: 'spacing.sm',
|
|
64
|
+
md: 'spacing.md',
|
|
65
|
+
lg: 'spacing.lg',
|
|
66
|
+
xl: 'spacing.xl',
|
|
67
|
+
'2xl': 'spacing.2xl'
|
|
68
|
+
},
|
|
69
|
+
radius: {
|
|
70
|
+
inner: 'radius.inner',
|
|
71
|
+
element: 'radius.element',
|
|
72
|
+
container: 'radius.container',
|
|
73
|
+
page: 'radius.page',
|
|
74
|
+
full: 'radius.full'
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
controlSm: 'size.controlSm',
|
|
78
|
+
controlMd: 'size.controlMd',
|
|
79
|
+
controlLg: 'size.controlLg',
|
|
80
|
+
hitTarget: 'size.hitTarget'
|
|
81
|
+
},
|
|
82
|
+
elevation: {
|
|
83
|
+
low: 'elevation.low',
|
|
84
|
+
medium: 'elevation.medium',
|
|
85
|
+
high: 'elevation.high'
|
|
86
|
+
},
|
|
87
|
+
texture: {
|
|
88
|
+
grain: 'texture.grain'
|
|
89
|
+
},
|
|
90
|
+
motion: {
|
|
91
|
+
durationFast: 'motion.durationFast',
|
|
92
|
+
durationModerate: 'motion.durationModerate',
|
|
93
|
+
durationSlow: 'motion.durationSlow',
|
|
94
|
+
easingStandard: 'motion.easingStandard',
|
|
95
|
+
easingEmphasized: 'motion.easingEmphasized'
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export const tokenNames = Object.freeze(Object.values(tokenContract).flatMap(group => Object.values(group)));
|
|
99
|
+
export function validateThemeDefinition(theme) {
|
|
100
|
+
return tokenNames.filter(name => theme.tokens[name] === undefined);
|
|
101
|
+
}
|
|
102
|
+
export const tokenCustomProperties = Object.freeze(Object.fromEntries(tokenNames.map(name => [name, `--kioku-ui-${name.replaceAll('.', '-').replace(/[A-Z]/g, character => `-${character.toLowerCase()}`)}`])));
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@misoto22/kioku-ui",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Product-neutral React design system foundations.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Misoto22/kioku-ui.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Misoto22/kioku-ui#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Misoto22/kioku-ui/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"**/*.css"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"!dist/**/*.test.*",
|
|
26
|
+
"!dist/**/*.spec.*",
|
|
27
|
+
"!dist/**/{__tests__,test,tests}/**",
|
|
28
|
+
"src",
|
|
29
|
+
"!src/**/*.test.*",
|
|
30
|
+
"!src/**/*.spec.*",
|
|
31
|
+
"!src/**/{__tests__,test,tests}/**",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"source": "./src/index.ts",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./source": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"import": "./src/index.ts",
|
|
44
|
+
"default": "./src/index.ts"
|
|
45
|
+
},
|
|
46
|
+
"./authoring.stylex": {
|
|
47
|
+
"types": "./dist/authoring.stylex.d.ts",
|
|
48
|
+
"import": "./src/authoring.stylex.ts",
|
|
49
|
+
"default": "./src/authoring.stylex.ts"
|
|
50
|
+
},
|
|
51
|
+
"./reset.css": "./dist/styles/reset.css",
|
|
52
|
+
"./styles.css": "./dist/styles/index.css",
|
|
53
|
+
"./theme": {
|
|
54
|
+
"types": "./dist/theme/index.d.ts",
|
|
55
|
+
"import": "./dist/theme/index.js",
|
|
56
|
+
"default": "./dist/theme/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./docs": {
|
|
59
|
+
"types": "./dist/docs/index.d.ts",
|
|
60
|
+
"import": "./dist/docs/index.js",
|
|
61
|
+
"default": "./dist/docs/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./authoring": {
|
|
64
|
+
"types": "./dist/authoring.stylex.d.ts",
|
|
65
|
+
"import": "./dist/authoring.stylex.js",
|
|
66
|
+
"default": "./dist/authoring.stylex.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"react": "^19.0.0",
|
|
71
|
+
"react-dom": "^19.0.0"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@stylexjs/stylex": "0.19.0"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
78
|
+
"@testing-library/react": "^16.3.2",
|
|
79
|
+
"@testing-library/user-event": "^14.6.4",
|
|
80
|
+
"@types/react": "^19.2.18",
|
|
81
|
+
"@types/react-dom": "^19.2.4",
|
|
82
|
+
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
|
83
|
+
"@babel/preset-typescript": "7.28.5",
|
|
84
|
+
"@stylexjs/cli": "0.19.0",
|
|
85
|
+
"jsdom": "^29.1.1",
|
|
86
|
+
"@misoto22/kioku-ui-test-utils": "0.0.0"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "stylex -i src -o dist -b styles/stylex.css --babelPresets @babel/preset-typescript --babelPluginsPost ./build/runtime-transform.cjs && tsc -p tsconfig.build.json",
|
|
90
|
+
"test": "vitest run src",
|
|
91
|
+
"typecheck": "tsc --noEmit"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const alertDoc = {
|
|
4
|
+
name: 'Alert',
|
|
5
|
+
description:
|
|
6
|
+
'Announces feedback with a quiet status boundary and polite or assertive live semantics.',
|
|
7
|
+
props: [
|
|
8
|
+
{
|
|
9
|
+
name: 'icon',
|
|
10
|
+
description:
|
|
11
|
+
'Overrides the tone-specific decorative status icon without adding an announcement.',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'tone',
|
|
15
|
+
description: 'Selects the semantic status tone and live behavior.',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
inheritedProps: ['HTMLAttributes<HTMLDivElement> except className and role'],
|
|
19
|
+
example: '<Alert tone="danger">Unable to save.</Alert>',
|
|
20
|
+
storyId: 'core-alert--default',
|
|
21
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import type {HTMLAttributes, ReactNode} from 'react';
|
|
3
|
+
|
|
4
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
5
|
+
import type {StatusTone} from '../Badge/index.js';
|
|
6
|
+
|
|
7
|
+
const styles = stylex.create({
|
|
8
|
+
base: {
|
|
9
|
+
alignItems: 'flex-start',
|
|
10
|
+
borderRadius: semanticTokens.radiusElement,
|
|
11
|
+
borderStyle: semanticTokens.borderStyle,
|
|
12
|
+
borderWidth: semanticTokens.borderWidth,
|
|
13
|
+
display: 'flex',
|
|
14
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
15
|
+
fontSize: semanticTokens.fontSizeMd,
|
|
16
|
+
gap: semanticTokens.spacingMd,
|
|
17
|
+
lineHeight: semanticTokens.lineHeightBody,
|
|
18
|
+
padding: semanticTokens.spacingMd,
|
|
19
|
+
},
|
|
20
|
+
info: {
|
|
21
|
+
backgroundColor: semanticTokens.statusInfoSurface,
|
|
22
|
+
borderColor: semanticTokens.statusInfoText,
|
|
23
|
+
color: semanticTokens.statusInfoText,
|
|
24
|
+
},
|
|
25
|
+
success: {
|
|
26
|
+
backgroundColor: semanticTokens.statusSuccessSurface,
|
|
27
|
+
borderColor: semanticTokens.statusSuccessText,
|
|
28
|
+
color: semanticTokens.statusSuccessText,
|
|
29
|
+
},
|
|
30
|
+
warning: {
|
|
31
|
+
backgroundColor: semanticTokens.statusWarningSurface,
|
|
32
|
+
borderColor: semanticTokens.statusWarningText,
|
|
33
|
+
color: semanticTokens.statusWarningText,
|
|
34
|
+
},
|
|
35
|
+
danger: {
|
|
36
|
+
backgroundColor: semanticTokens.statusDangerSurface,
|
|
37
|
+
borderColor: semanticTokens.statusDangerText,
|
|
38
|
+
color: semanticTokens.statusDangerText,
|
|
39
|
+
},
|
|
40
|
+
icon: {
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexShrink: 0,
|
|
44
|
+
height: semanticTokens.spacingLg,
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
width: semanticTokens.spacingLg,
|
|
47
|
+
},
|
|
48
|
+
content: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export interface AlertProps extends Omit<
|
|
55
|
+
HTMLAttributes<HTMLDivElement>,
|
|
56
|
+
'className' | 'role'
|
|
57
|
+
> {
|
|
58
|
+
readonly icon?: ReactNode;
|
|
59
|
+
readonly tone?: StatusTone;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function DefaultAlertIcon({tone}: {readonly tone: StatusTone}) {
|
|
63
|
+
const sharedProps = {
|
|
64
|
+
fill: 'none',
|
|
65
|
+
height: '100%',
|
|
66
|
+
stroke: 'currentColor',
|
|
67
|
+
strokeLinecap: 'round' as const,
|
|
68
|
+
strokeLinejoin: 'round' as const,
|
|
69
|
+
strokeWidth: 2,
|
|
70
|
+
viewBox: '0 0 20 20',
|
|
71
|
+
width: '100%',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (tone === 'success') {
|
|
75
|
+
return (
|
|
76
|
+
<svg {...sharedProps}>
|
|
77
|
+
<circle cx="10" cy="10" r="8" />
|
|
78
|
+
<path d="m6.5 10 2.2 2.2 4.8-5" />
|
|
79
|
+
</svg>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (tone === 'warning') {
|
|
83
|
+
return (
|
|
84
|
+
<svg {...sharedProps}>
|
|
85
|
+
<path d="M10 2.5 18 17H2L10 2.5Z" />
|
|
86
|
+
<path d="M10 7v4" />
|
|
87
|
+
<path d="M10 14h.01" />
|
|
88
|
+
</svg>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (tone === 'danger') {
|
|
92
|
+
return (
|
|
93
|
+
<svg {...sharedProps}>
|
|
94
|
+
<circle cx="10" cy="10" r="8" />
|
|
95
|
+
<path d="m7 7 6 6M13 7l-6 6" />
|
|
96
|
+
</svg>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return (
|
|
100
|
+
<svg {...sharedProps}>
|
|
101
|
+
<circle cx="10" cy="10" r="8" />
|
|
102
|
+
<path d="M10 9v5" />
|
|
103
|
+
<path d="M10 6h.01" />
|
|
104
|
+
</svg>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function Alert({children, icon, tone = 'info', ...props}: AlertProps) {
|
|
109
|
+
const isDanger = tone === 'danger';
|
|
110
|
+
const hasCustomIcon = icon !== undefined && icon !== null && icon !== false;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
{...props}
|
|
115
|
+
aria-live={isDanger ? 'assertive' : 'polite'}
|
|
116
|
+
role={isDanger ? 'alert' : 'status'}
|
|
117
|
+
{...stylex.props(styles.base, styles[tone])}
|
|
118
|
+
>
|
|
119
|
+
<span
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
data-alert-icon={hasCustomIcon ? 'custom' : tone}
|
|
122
|
+
{...stylex.props(styles.icon)}
|
|
123
|
+
>
|
|
124
|
+
{hasCustomIcon ? icon : <DefaultAlertIcon tone={tone} />}
|
|
125
|
+
</span>
|
|
126
|
+
<div {...stylex.props(styles.content)}>{children}</div>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Alert, type AlertProps} from './Alert.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const asyncStateDoc = {
|
|
4
|
+
name: 'AsyncState',
|
|
5
|
+
description: 'Renders distinct loading, empty, error, and ready states.',
|
|
6
|
+
props: [
|
|
7
|
+
{
|
|
8
|
+
name: 'children',
|
|
9
|
+
description: 'Renders ready data and is required for the ready state.',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'state',
|
|
13
|
+
description: 'Provides the current discriminated async state.',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
inheritedProps: ['No inherited DOM attributes'],
|
|
18
|
+
example:
|
|
19
|
+
'<AsyncState state={{kind: "ready", data}}>{renderData}</AsyncState>',
|
|
20
|
+
storyId: 'core-async-state--default',
|
|
21
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {ReactNode} from 'react';
|
|
2
|
+
|
|
3
|
+
import {Alert} from '../Alert/index.js';
|
|
4
|
+
import {EmptyStateContent} from '../EmptyState/index.js';
|
|
5
|
+
import {SpinnerVisual} from '../Spinner/index.js';
|
|
6
|
+
|
|
7
|
+
export type AsyncStateValue<T> =
|
|
8
|
+
| {readonly kind: 'loading'; readonly label?: string}
|
|
9
|
+
| {
|
|
10
|
+
readonly kind: 'empty';
|
|
11
|
+
readonly title: ReactNode;
|
|
12
|
+
readonly detail?: ReactNode;
|
|
13
|
+
readonly action?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
readonly kind: 'error';
|
|
17
|
+
readonly title: ReactNode;
|
|
18
|
+
readonly detail?: ReactNode;
|
|
19
|
+
readonly retry?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
| {readonly kind: 'ready'; readonly data: T};
|
|
22
|
+
|
|
23
|
+
type PendingAsyncStateValue<T> = Exclude<AsyncStateValue<T>, {kind: 'ready'}>;
|
|
24
|
+
|
|
25
|
+
export type AsyncStateProps<T> =
|
|
26
|
+
| {
|
|
27
|
+
readonly children: (data: T) => ReactNode;
|
|
28
|
+
readonly state: AsyncStateValue<T>;
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
readonly children?: never;
|
|
32
|
+
readonly state: PendingAsyncStateValue<T>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function AsyncState<T>({children, state}: AsyncStateProps<T>) {
|
|
36
|
+
if (state.kind === 'ready' && !children) {
|
|
37
|
+
throw new Error('AsyncState requires a renderer for ready data');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const loadingLabel =
|
|
41
|
+
state.kind === 'loading' ? (state.label ?? 'Loading') : undefined;
|
|
42
|
+
const statusContent =
|
|
43
|
+
state.kind === 'loading' ? (
|
|
44
|
+
<SpinnerVisual />
|
|
45
|
+
) : state.kind === 'empty' ? (
|
|
46
|
+
<EmptyStateContent
|
|
47
|
+
action={state.action}
|
|
48
|
+
detail={state.detail}
|
|
49
|
+
title={state.title}
|
|
50
|
+
/>
|
|
51
|
+
) : state.kind === 'ready' ? (
|
|
52
|
+
children!(state.data)
|
|
53
|
+
) : null;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<div
|
|
58
|
+
aria-atomic="true"
|
|
59
|
+
aria-busy={state.kind === 'loading'}
|
|
60
|
+
aria-label={loadingLabel}
|
|
61
|
+
aria-live="polite"
|
|
62
|
+
role="status"
|
|
63
|
+
>
|
|
64
|
+
{statusContent}
|
|
65
|
+
</div>
|
|
66
|
+
{state.kind === 'error' ? (
|
|
67
|
+
<Alert tone="danger">
|
|
68
|
+
<div>{state.title}</div>
|
|
69
|
+
{state.detail ? <div>{state.detail}</div> : null}
|
|
70
|
+
{state.retry}
|
|
71
|
+
</Alert>
|
|
72
|
+
) : null}
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const badgeDoc = {
|
|
4
|
+
name: 'Badge',
|
|
5
|
+
description: 'Displays compact, non-live status or category text.',
|
|
6
|
+
props: [
|
|
7
|
+
{
|
|
8
|
+
name: 'tone',
|
|
9
|
+
description: 'Selects the neutral default or a semantic status tone.',
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
inheritedProps: ['HTMLAttributes<HTMLSpanElement> except className'],
|
|
13
|
+
example: '<Badge tone="success">Available</Badge>',
|
|
14
|
+
storyId: 'core-badge--default',
|
|
15
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import type {HTMLAttributes} from 'react';
|
|
3
|
+
|
|
4
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
5
|
+
|
|
6
|
+
/** Semantic feedback tones shared by status components. */
|
|
7
|
+
export type StatusTone = 'info' | 'success' | 'warning' | 'danger';
|
|
8
|
+
|
|
9
|
+
/** Compact badge tones, including a non-status neutral treatment. */
|
|
10
|
+
export type BadgeTone = 'neutral' | StatusTone;
|
|
11
|
+
|
|
12
|
+
const styles = stylex.create({
|
|
13
|
+
base: {
|
|
14
|
+
borderRadius: semanticTokens.radiusElement,
|
|
15
|
+
display: 'inline-flex',
|
|
16
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
17
|
+
fontSize: semanticTokens.fontSizeXs,
|
|
18
|
+
fontWeight: semanticTokens.fontWeightMedium,
|
|
19
|
+
paddingBlock: semanticTokens.spacingXs,
|
|
20
|
+
paddingInline: semanticTokens.spacingSm,
|
|
21
|
+
},
|
|
22
|
+
neutral: {
|
|
23
|
+
backgroundColor: semanticTokens.colorSurfaceMuted,
|
|
24
|
+
color: semanticTokens.colorTextSecondary,
|
|
25
|
+
},
|
|
26
|
+
info: {
|
|
27
|
+
backgroundColor: semanticTokens.statusInfoSurface,
|
|
28
|
+
color: semanticTokens.statusInfoText,
|
|
29
|
+
},
|
|
30
|
+
success: {
|
|
31
|
+
backgroundColor: semanticTokens.statusSuccessSurface,
|
|
32
|
+
color: semanticTokens.statusSuccessText,
|
|
33
|
+
},
|
|
34
|
+
warning: {
|
|
35
|
+
backgroundColor: semanticTokens.statusWarningSurface,
|
|
36
|
+
color: semanticTokens.statusWarningText,
|
|
37
|
+
},
|
|
38
|
+
danger: {
|
|
39
|
+
backgroundColor: semanticTokens.statusDangerSurface,
|
|
40
|
+
color: semanticTokens.statusDangerText,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/** Props for compact status or category text. */
|
|
45
|
+
export interface BadgeProps extends Omit<
|
|
46
|
+
HTMLAttributes<HTMLSpanElement>,
|
|
47
|
+
'className'
|
|
48
|
+
> {
|
|
49
|
+
readonly tone?: BadgeTone;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Badge({children, tone = 'neutral', ...props}: BadgeProps) {
|
|
53
|
+
return (
|
|
54
|
+
<span {...props} {...stylex.props(styles.base, styles[tone])}>
|
|
55
|
+
{children}
|
|
56
|
+
</span>
|
|
57
|
+
);
|
|
58
|
+
}
|