@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,222 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import {createContext, useContext} from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
HTMLAttributes,
|
|
5
|
+
TableHTMLAttributes,
|
|
6
|
+
TdHTMLAttributes,
|
|
7
|
+
ThHTMLAttributes,
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
11
|
+
|
|
12
|
+
export type TableDensity = 'compact' | 'default' | 'spacious';
|
|
13
|
+
export type TableDividers = 'rows' | 'columns' | 'grid' | 'none';
|
|
14
|
+
|
|
15
|
+
type TableSection = 'body' | 'head' | undefined;
|
|
16
|
+
|
|
17
|
+
interface TableStyleContextValue {
|
|
18
|
+
readonly density: TableDensity;
|
|
19
|
+
readonly dividers: TableDividers;
|
|
20
|
+
readonly section: TableSection;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const defaultTableStyle: TableStyleContextValue = {
|
|
24
|
+
density: 'default',
|
|
25
|
+
dividers: 'rows',
|
|
26
|
+
section: undefined,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const TableStyleContext = createContext(defaultTableStyle);
|
|
30
|
+
|
|
31
|
+
const styles = stylex.create({
|
|
32
|
+
table: {
|
|
33
|
+
borderCollapse: 'collapse',
|
|
34
|
+
color: semanticTokens.colorText,
|
|
35
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
36
|
+
fontSize: semanticTokens.fontSizeMd,
|
|
37
|
+
width: '100%',
|
|
38
|
+
},
|
|
39
|
+
caption: {
|
|
40
|
+
fontFamily: semanticTokens.fontFamilyHeading,
|
|
41
|
+
fontWeight: semanticTokens.fontWeightStrong,
|
|
42
|
+
paddingBlock: semanticTokens.spacingSm,
|
|
43
|
+
textAlign: 'start',
|
|
44
|
+
},
|
|
45
|
+
bodyRow: {
|
|
46
|
+
transitionDuration: semanticTokens.durationFast,
|
|
47
|
+
transitionProperty: 'background-color',
|
|
48
|
+
transitionTimingFunction: semanticTokens.easingStandard,
|
|
49
|
+
':hover:not(:active)': {
|
|
50
|
+
backgroundColor: semanticTokens.colorOverlayHover,
|
|
51
|
+
},
|
|
52
|
+
':focus-within:not(:active)': {
|
|
53
|
+
backgroundColor: semanticTokens.colorOverlayHover,
|
|
54
|
+
},
|
|
55
|
+
':active': {
|
|
56
|
+
backgroundColor: semanticTokens.colorOverlayActive,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
headerCell: {
|
|
60
|
+
backgroundColor: semanticTokens.colorSurfaceMuted,
|
|
61
|
+
color: semanticTokens.colorTextSecondary,
|
|
62
|
+
fontWeight: semanticTokens.fontWeightStrong,
|
|
63
|
+
paddingInline: semanticTokens.spacingMd,
|
|
64
|
+
textAlign: 'start',
|
|
65
|
+
},
|
|
66
|
+
cell: {
|
|
67
|
+
paddingInline: semanticTokens.spacingMd,
|
|
68
|
+
},
|
|
69
|
+
compact: {paddingBlock: semanticTokens.spacingSm},
|
|
70
|
+
default: {paddingBlock: semanticTokens.spacingMd},
|
|
71
|
+
spacious: {paddingBlock: semanticTokens.spacingLg},
|
|
72
|
+
rowDivider: {
|
|
73
|
+
':not(:last-child)': {
|
|
74
|
+
borderBlockEndColor: semanticTokens.borderDefault,
|
|
75
|
+
borderBlockEndStyle: semanticTokens.borderStyle,
|
|
76
|
+
borderBlockEndWidth: semanticTokens.borderWidth,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
headerRowDivider: {
|
|
80
|
+
borderBlockEndColor: semanticTokens.borderDefault,
|
|
81
|
+
borderBlockEndStyle: semanticTokens.borderStyle,
|
|
82
|
+
borderBlockEndWidth: semanticTokens.borderWidth,
|
|
83
|
+
},
|
|
84
|
+
columnDivider: {
|
|
85
|
+
':not(:last-child)': {
|
|
86
|
+
borderInlineEndColor: semanticTokens.borderDefault,
|
|
87
|
+
borderInlineEndStyle: semanticTokens.borderStyle,
|
|
88
|
+
borderInlineEndWidth: semanticTokens.borderWidth,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export interface TableProps extends Omit<
|
|
94
|
+
TableHTMLAttributes<HTMLTableElement>,
|
|
95
|
+
'className'
|
|
96
|
+
> {
|
|
97
|
+
readonly density?: TableDensity;
|
|
98
|
+
readonly dividers?: TableDividers;
|
|
99
|
+
}
|
|
100
|
+
export type TableCaptionProps = Omit<
|
|
101
|
+
HTMLAttributes<HTMLTableCaptionElement>,
|
|
102
|
+
'className'
|
|
103
|
+
>;
|
|
104
|
+
export type TableHeadProps = Omit<
|
|
105
|
+
HTMLAttributes<HTMLTableSectionElement>,
|
|
106
|
+
'className'
|
|
107
|
+
>;
|
|
108
|
+
export type TableBodyProps = TableHeadProps;
|
|
109
|
+
export type TableRowProps = Omit<
|
|
110
|
+
HTMLAttributes<HTMLTableRowElement>,
|
|
111
|
+
'className'
|
|
112
|
+
>;
|
|
113
|
+
export type TableHeaderCellProps = Omit<
|
|
114
|
+
ThHTMLAttributes<HTMLTableCellElement>,
|
|
115
|
+
'className'
|
|
116
|
+
>;
|
|
117
|
+
export type TableCellProps = Omit<
|
|
118
|
+
TdHTMLAttributes<HTMLTableCellElement>,
|
|
119
|
+
'className'
|
|
120
|
+
>;
|
|
121
|
+
|
|
122
|
+
function usesRowDividers(dividers: TableDividers) {
|
|
123
|
+
return dividers === 'rows' || dividers === 'grid';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function usesColumnDividers(dividers: TableDividers) {
|
|
127
|
+
return dividers === 'columns' || dividers === 'grid';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function Table({
|
|
131
|
+
children,
|
|
132
|
+
density = 'default',
|
|
133
|
+
dividers = 'rows',
|
|
134
|
+
...props
|
|
135
|
+
}: TableProps) {
|
|
136
|
+
return (
|
|
137
|
+
<TableStyleContext.Provider value={{density, dividers, section: undefined}}>
|
|
138
|
+
<table {...props} {...stylex.props(styles.table)}>
|
|
139
|
+
{children}
|
|
140
|
+
</table>
|
|
141
|
+
</TableStyleContext.Provider>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function TableCaption({children, ...props}: TableCaptionProps) {
|
|
146
|
+
return (
|
|
147
|
+
<caption {...props} {...stylex.props(styles.caption)}>
|
|
148
|
+
{children}
|
|
149
|
+
</caption>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function TableHead({children, ...props}: TableHeadProps) {
|
|
154
|
+
const tableStyle = useContext(TableStyleContext);
|
|
155
|
+
return (
|
|
156
|
+
<TableStyleContext.Provider value={{...tableStyle, section: 'head'}}>
|
|
157
|
+
<thead {...props}>{children}</thead>
|
|
158
|
+
</TableStyleContext.Provider>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function TableBody({children, ...props}: TableBodyProps) {
|
|
163
|
+
const tableStyle = useContext(TableStyleContext);
|
|
164
|
+
return (
|
|
165
|
+
<TableStyleContext.Provider value={{...tableStyle, section: 'body'}}>
|
|
166
|
+
<tbody {...props}>{children}</tbody>
|
|
167
|
+
</TableStyleContext.Provider>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function TableRow({children, ...props}: TableRowProps) {
|
|
172
|
+
const {dividers, section} = useContext(TableStyleContext);
|
|
173
|
+
return (
|
|
174
|
+
<tr
|
|
175
|
+
{...props}
|
|
176
|
+
{...stylex.props(
|
|
177
|
+
section === 'body' && styles.bodyRow,
|
|
178
|
+
section === 'body' && usesRowDividers(dividers) && styles.rowDivider,
|
|
179
|
+
)}
|
|
180
|
+
>
|
|
181
|
+
{children}
|
|
182
|
+
</tr>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function TableHeaderCell({
|
|
187
|
+
children,
|
|
188
|
+
scope = 'col',
|
|
189
|
+
...props
|
|
190
|
+
}: TableHeaderCellProps) {
|
|
191
|
+
const {density, dividers} = useContext(TableStyleContext);
|
|
192
|
+
return (
|
|
193
|
+
<th
|
|
194
|
+
{...props}
|
|
195
|
+
scope={scope}
|
|
196
|
+
{...stylex.props(
|
|
197
|
+
styles.headerCell,
|
|
198
|
+
styles[density],
|
|
199
|
+
usesRowDividers(dividers) && styles.headerRowDivider,
|
|
200
|
+
usesColumnDividers(dividers) && styles.columnDivider,
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
{children}
|
|
204
|
+
</th>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function TableCell({children, ...props}: TableCellProps) {
|
|
209
|
+
const {density, dividers} = useContext(TableStyleContext);
|
|
210
|
+
return (
|
|
211
|
+
<td
|
|
212
|
+
{...props}
|
|
213
|
+
{...stylex.props(
|
|
214
|
+
styles.cell,
|
|
215
|
+
styles[density],
|
|
216
|
+
usesColumnDividers(dividers) && styles.columnDivider,
|
|
217
|
+
)}
|
|
218
|
+
>
|
|
219
|
+
{children}
|
|
220
|
+
</td>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Table,
|
|
3
|
+
TableBody,
|
|
4
|
+
TableCaption,
|
|
5
|
+
TableCell,
|
|
6
|
+
TableHead,
|
|
7
|
+
TableHeaderCell,
|
|
8
|
+
TableRow,
|
|
9
|
+
type TableBodyProps,
|
|
10
|
+
type TableCaptionProps,
|
|
11
|
+
type TableCellProps,
|
|
12
|
+
type TableDensity,
|
|
13
|
+
type TableDividers,
|
|
14
|
+
type TableHeadProps,
|
|
15
|
+
type TableHeaderCellProps,
|
|
16
|
+
type TableProps,
|
|
17
|
+
type TableRowProps,
|
|
18
|
+
} from './Table.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const textDoc = {
|
|
4
|
+
name: 'Text',
|
|
5
|
+
description: 'Renders body copy with semantic typography tokens.',
|
|
6
|
+
props: [
|
|
7
|
+
{name: 'size', description: 'Optional semantic size: "sm", "md", or "lg".'},
|
|
8
|
+
{
|
|
9
|
+
name: 'tone',
|
|
10
|
+
description:
|
|
11
|
+
'Optional hierarchy tone: "primary", "secondary", or "muted".',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
inheritedProps: ['HTMLAttributes<HTMLParagraphElement> except className'],
|
|
15
|
+
example: '<Text size="md" tone="secondary">Supporting copy.</Text>',
|
|
16
|
+
storyId: 'core-text--default',
|
|
17
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import type {HTMLAttributes} from 'react';
|
|
3
|
+
|
|
4
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
5
|
+
|
|
6
|
+
const styles = stylex.create({
|
|
7
|
+
base: {
|
|
8
|
+
color: semanticTokens.colorText,
|
|
9
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
10
|
+
fontWeight: semanticTokens.fontWeightRegular,
|
|
11
|
+
lineHeight: semanticTokens.lineHeightBody,
|
|
12
|
+
margin: 0,
|
|
13
|
+
},
|
|
14
|
+
sm: {fontSize: semanticTokens.fontSizeSm},
|
|
15
|
+
md: {fontSize: semanticTokens.fontSizeMd},
|
|
16
|
+
lg: {fontSize: semanticTokens.fontSizeLg},
|
|
17
|
+
primary: {color: semanticTokens.colorText},
|
|
18
|
+
secondary: {color: semanticTokens.colorTextSecondary},
|
|
19
|
+
muted: {color: semanticTokens.colorTextMuted},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type TextTone = 'primary' | 'secondary' | 'muted';
|
|
23
|
+
|
|
24
|
+
export interface TextProps extends Omit<
|
|
25
|
+
HTMLAttributes<HTMLParagraphElement>,
|
|
26
|
+
'className'
|
|
27
|
+
> {
|
|
28
|
+
readonly size?: 'sm' | 'md' | 'lg';
|
|
29
|
+
readonly tone?: TextTone;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function Text({
|
|
33
|
+
children,
|
|
34
|
+
size = 'md',
|
|
35
|
+
tone = 'primary',
|
|
36
|
+
...props
|
|
37
|
+
}: TextProps) {
|
|
38
|
+
return (
|
|
39
|
+
<p {...props} {...stylex.props(styles.base, styles[size], styles[tone])}>
|
|
40
|
+
{children}
|
|
41
|
+
</p>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Text, type TextProps, type TextTone} from './Text.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const textAreaDoc = {
|
|
4
|
+
name: 'TextArea',
|
|
5
|
+
description: 'Collects multiple lines of controlled or uncontrolled text.',
|
|
6
|
+
props: [
|
|
7
|
+
{
|
|
8
|
+
name: 'aria-invalid',
|
|
9
|
+
description:
|
|
10
|
+
'Exposes invalid semantics and danger styling; an explicit value overrides Field status inference.',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'defaultValue',
|
|
14
|
+
description: 'Sets the initial value for an uncontrolled text area.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'disabled',
|
|
18
|
+
description: 'Disables editing and native form interaction.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'onValueChange',
|
|
22
|
+
description: 'Receives the current string value after input.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'readOnly',
|
|
26
|
+
description: 'Keeps the value legible while preventing edits.',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'required',
|
|
30
|
+
description:
|
|
31
|
+
'Sets native required semantics; an explicit value overrides the enclosing Field necessity.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'value',
|
|
35
|
+
description: 'Controls the current value when onValueChange is supplied.',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
inheritedProps: [
|
|
39
|
+
'TextareaHTMLAttributes<HTMLTextAreaElement> except children, className, defaultValue, onChange, and value',
|
|
40
|
+
],
|
|
41
|
+
example: '<Field label="Notes"><TextArea /></Field>',
|
|
42
|
+
storyId: 'core-text-area--default',
|
|
43
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import type {ChangeEvent, TextareaHTMLAttributes} from 'react';
|
|
3
|
+
|
|
4
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
5
|
+
import {useFieldControl} from '../Field/index.js';
|
|
6
|
+
|
|
7
|
+
const controlStyles = stylex.create({
|
|
8
|
+
base: {
|
|
9
|
+
backgroundColor: semanticTokens.colorSurface,
|
|
10
|
+
boxSizing: 'border-box',
|
|
11
|
+
borderColor: semanticTokens.borderDefault,
|
|
12
|
+
borderRadius: semanticTokens.radiusElement,
|
|
13
|
+
borderStyle: semanticTokens.borderStyle,
|
|
14
|
+
borderWidth: semanticTokens.borderWidth,
|
|
15
|
+
color: semanticTokens.colorText,
|
|
16
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
17
|
+
fontSize: semanticTokens.fontSizeMd,
|
|
18
|
+
lineHeight: semanticTokens.lineHeightBody,
|
|
19
|
+
minHeight: '96px',
|
|
20
|
+
paddingBlock: semanticTokens.spacingXs,
|
|
21
|
+
paddingInline: semanticTokens.spacingSm,
|
|
22
|
+
'::placeholder': {color: semanticTokens.colorTextMuted},
|
|
23
|
+
':disabled': {
|
|
24
|
+
backgroundColor: semanticTokens.colorDisabledSurface,
|
|
25
|
+
borderColor: semanticTokens.borderDisabled,
|
|
26
|
+
color: semanticTokens.colorDisabledText,
|
|
27
|
+
},
|
|
28
|
+
':focus-visible': {
|
|
29
|
+
borderColor: semanticTokens.borderInteractive,
|
|
30
|
+
outlineColor: semanticTokens.colorFocus,
|
|
31
|
+
outlineOffset: semanticTokens.focusOffset,
|
|
32
|
+
outlineStyle: semanticTokens.borderStyle,
|
|
33
|
+
outlineWidth: semanticTokens.focusWidth,
|
|
34
|
+
},
|
|
35
|
+
':active:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
36
|
+
borderColor: semanticTokens.colorAccentActive,
|
|
37
|
+
},
|
|
38
|
+
':hover:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
39
|
+
borderColor: semanticTokens.borderInteractive,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
readOnly: {
|
|
43
|
+
backgroundColor: semanticTokens.colorSurfaceMuted,
|
|
44
|
+
color: semanticTokens.colorText,
|
|
45
|
+
},
|
|
46
|
+
invalid: {
|
|
47
|
+
borderColor: semanticTokens.statusDangerText,
|
|
48
|
+
':focus-visible': {borderColor: semanticTokens.statusDangerText},
|
|
49
|
+
':active:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
50
|
+
borderColor: semanticTokens.statusDangerText,
|
|
51
|
+
},
|
|
52
|
+
':hover:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
53
|
+
borderColor: semanticTokens.statusDangerText,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
type SharedTextAreaProps = Omit<
|
|
59
|
+
TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
60
|
+
'children' | 'className' | 'defaultValue' | 'onChange' | 'value'
|
|
61
|
+
> & {
|
|
62
|
+
readonly onValueChange?: (value: string) => void;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type ControlledTextAreaProps = SharedTextAreaProps & {
|
|
66
|
+
readonly defaultValue?: never;
|
|
67
|
+
readonly onValueChange: (value: string) => void;
|
|
68
|
+
readonly value: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type UncontrolledTextAreaProps = SharedTextAreaProps & {
|
|
72
|
+
readonly defaultValue?: string;
|
|
73
|
+
readonly value?: never;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type TextAreaProps = ControlledTextAreaProps | UncontrolledTextAreaProps;
|
|
77
|
+
|
|
78
|
+
export function TextArea({
|
|
79
|
+
'aria-describedby': ariaDescribedBy,
|
|
80
|
+
'aria-invalid': ariaInvalid,
|
|
81
|
+
disabled,
|
|
82
|
+
id,
|
|
83
|
+
onValueChange,
|
|
84
|
+
readOnly,
|
|
85
|
+
required,
|
|
86
|
+
...props
|
|
87
|
+
}: TextAreaProps) {
|
|
88
|
+
const field = useFieldControl();
|
|
89
|
+
const describedBy =
|
|
90
|
+
[field?.describedBy, ariaDescribedBy].filter(Boolean).join(' ') ||
|
|
91
|
+
undefined;
|
|
92
|
+
const resolvedInvalid = ariaInvalid ?? field?.invalid;
|
|
93
|
+
const isInvalid =
|
|
94
|
+
resolvedInvalid !== undefined &&
|
|
95
|
+
resolvedInvalid !== false &&
|
|
96
|
+
resolvedInvalid !== 'false';
|
|
97
|
+
|
|
98
|
+
function handleChange(event: ChangeEvent<HTMLTextAreaElement>) {
|
|
99
|
+
onValueChange?.(event.currentTarget.value);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<textarea
|
|
104
|
+
{...props}
|
|
105
|
+
aria-describedby={describedBy}
|
|
106
|
+
aria-invalid={resolvedInvalid}
|
|
107
|
+
disabled={disabled}
|
|
108
|
+
id={field?.controlId ?? id}
|
|
109
|
+
onChange={handleChange}
|
|
110
|
+
readOnly={readOnly}
|
|
111
|
+
required={required ?? field?.required}
|
|
112
|
+
{...stylex.props(
|
|
113
|
+
controlStyles.base,
|
|
114
|
+
readOnly && !disabled ? controlStyles.readOnly : undefined,
|
|
115
|
+
isInvalid && !disabled ? controlStyles.invalid : undefined,
|
|
116
|
+
)}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {TextArea, type TextAreaProps} from './TextArea.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const textInputDoc = {
|
|
4
|
+
name: 'TextInput',
|
|
5
|
+
description: 'Collects one line of controlled or uncontrolled text.',
|
|
6
|
+
props: [
|
|
7
|
+
{
|
|
8
|
+
name: 'aria-invalid',
|
|
9
|
+
description:
|
|
10
|
+
'Exposes invalid semantics and danger styling; an explicit value overrides Field status inference.',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'defaultValue',
|
|
14
|
+
description: 'Sets the initial value for an uncontrolled input.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'disabled',
|
|
18
|
+
description: 'Disables editing and native form interaction.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'onValueChange',
|
|
22
|
+
description: 'Receives the current string value after input.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'readOnly',
|
|
26
|
+
description: 'Keeps the value legible while preventing edits.',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'required',
|
|
30
|
+
description:
|
|
31
|
+
'Sets native required semantics; an explicit value overrides the enclosing Field necessity.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'value',
|
|
35
|
+
description: 'Controls the current value when onValueChange is supplied.',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
inheritedProps: [
|
|
39
|
+
'InputHTMLAttributes<HTMLInputElement> except children, className, defaultValue, onChange, and value',
|
|
40
|
+
],
|
|
41
|
+
example: '<Field label="Name"><TextInput defaultValue="" /></Field>',
|
|
42
|
+
storyId: 'core-text-input--default',
|
|
43
|
+
} satisfies ComponentDoc;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
import type {ChangeEvent, InputHTMLAttributes} from 'react';
|
|
3
|
+
|
|
4
|
+
import {semanticTokens} from '../authoring.stylex.js';
|
|
5
|
+
import {useFieldControl} from '../Field/index.js';
|
|
6
|
+
|
|
7
|
+
const controlStyles = stylex.create({
|
|
8
|
+
base: {
|
|
9
|
+
backgroundColor: semanticTokens.colorSurface,
|
|
10
|
+
boxSizing: 'border-box',
|
|
11
|
+
borderColor: semanticTokens.borderDefault,
|
|
12
|
+
borderRadius: semanticTokens.radiusElement,
|
|
13
|
+
borderStyle: semanticTokens.borderStyle,
|
|
14
|
+
borderWidth: semanticTokens.borderWidth,
|
|
15
|
+
color: semanticTokens.colorText,
|
|
16
|
+
fontFamily: semanticTokens.fontFamilyBody,
|
|
17
|
+
fontSize: semanticTokens.fontSizeMd,
|
|
18
|
+
height: semanticTokens.sizeControlMd,
|
|
19
|
+
lineHeight: semanticTokens.lineHeightBody,
|
|
20
|
+
paddingBlock: semanticTokens.spacingXs,
|
|
21
|
+
paddingInline: semanticTokens.spacingSm,
|
|
22
|
+
'::placeholder': {color: semanticTokens.colorTextMuted},
|
|
23
|
+
':disabled': {
|
|
24
|
+
backgroundColor: semanticTokens.colorDisabledSurface,
|
|
25
|
+
borderColor: semanticTokens.borderDisabled,
|
|
26
|
+
color: semanticTokens.colorDisabledText,
|
|
27
|
+
},
|
|
28
|
+
':focus-visible': {
|
|
29
|
+
borderColor: semanticTokens.borderInteractive,
|
|
30
|
+
outlineColor: semanticTokens.colorFocus,
|
|
31
|
+
outlineOffset: semanticTokens.focusOffset,
|
|
32
|
+
outlineStyle: semanticTokens.borderStyle,
|
|
33
|
+
outlineWidth: semanticTokens.focusWidth,
|
|
34
|
+
},
|
|
35
|
+
':active:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
36
|
+
borderColor: semanticTokens.colorAccentActive,
|
|
37
|
+
},
|
|
38
|
+
':hover:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
39
|
+
borderColor: semanticTokens.borderInteractive,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
readOnly: {
|
|
43
|
+
backgroundColor: semanticTokens.colorSurfaceMuted,
|
|
44
|
+
color: semanticTokens.colorText,
|
|
45
|
+
},
|
|
46
|
+
invalid: {
|
|
47
|
+
borderColor: semanticTokens.statusDangerText,
|
|
48
|
+
':focus-visible': {borderColor: semanticTokens.statusDangerText},
|
|
49
|
+
':active:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
50
|
+
borderColor: semanticTokens.statusDangerText,
|
|
51
|
+
},
|
|
52
|
+
':hover:not(:disabled):not(:read-only):not(:focus-visible)': {
|
|
53
|
+
borderColor: semanticTokens.statusDangerText,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
type SharedTextInputProps = Omit<
|
|
59
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
60
|
+
'children' | 'className' | 'defaultValue' | 'onChange' | 'value'
|
|
61
|
+
> & {
|
|
62
|
+
readonly onValueChange?: (value: string) => void;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type ControlledTextInputProps = SharedTextInputProps & {
|
|
66
|
+
readonly defaultValue?: never;
|
|
67
|
+
readonly onValueChange: (value: string) => void;
|
|
68
|
+
readonly value: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type UncontrolledTextInputProps = SharedTextInputProps & {
|
|
72
|
+
readonly defaultValue?: string;
|
|
73
|
+
readonly value?: never;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type TextInputProps =
|
|
77
|
+
ControlledTextInputProps | UncontrolledTextInputProps;
|
|
78
|
+
|
|
79
|
+
export function TextInput({
|
|
80
|
+
'aria-describedby': ariaDescribedBy,
|
|
81
|
+
'aria-invalid': ariaInvalid,
|
|
82
|
+
disabled,
|
|
83
|
+
id,
|
|
84
|
+
onValueChange,
|
|
85
|
+
readOnly,
|
|
86
|
+
required,
|
|
87
|
+
type = 'text',
|
|
88
|
+
...props
|
|
89
|
+
}: TextInputProps) {
|
|
90
|
+
const field = useFieldControl();
|
|
91
|
+
const describedBy =
|
|
92
|
+
[field?.describedBy, ariaDescribedBy].filter(Boolean).join(' ') ||
|
|
93
|
+
undefined;
|
|
94
|
+
const resolvedInvalid = ariaInvalid ?? field?.invalid;
|
|
95
|
+
const isInvalid =
|
|
96
|
+
resolvedInvalid !== undefined &&
|
|
97
|
+
resolvedInvalid !== false &&
|
|
98
|
+
resolvedInvalid !== 'false';
|
|
99
|
+
|
|
100
|
+
function handleChange(event: ChangeEvent<HTMLInputElement>) {
|
|
101
|
+
onValueChange?.(event.currentTarget.value);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<input
|
|
106
|
+
{...props}
|
|
107
|
+
aria-describedby={describedBy}
|
|
108
|
+
aria-invalid={resolvedInvalid}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
id={field?.controlId ?? id}
|
|
111
|
+
onChange={handleChange}
|
|
112
|
+
readOnly={readOnly}
|
|
113
|
+
required={required ?? field?.required}
|
|
114
|
+
{...stylex.props(
|
|
115
|
+
controlStyles.base,
|
|
116
|
+
readOnly && !disabled ? controlStyles.readOnly : undefined,
|
|
117
|
+
isInvalid && !disabled ? controlStyles.invalid : undefined,
|
|
118
|
+
)}
|
|
119
|
+
type={type}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {TextInput, type TextInputProps} from './TextInput.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {ComponentDoc} from '../docs/types.js';
|
|
2
|
+
|
|
3
|
+
export const toggleDoc = {
|
|
4
|
+
name: 'Toggle',
|
|
5
|
+
description: 'Switches a controlled or uncontrolled boolean setting.',
|
|
6
|
+
props: [
|
|
7
|
+
{
|
|
8
|
+
name: 'defaultPressed',
|
|
9
|
+
description: 'Sets the initial state for an uncontrolled switch.',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'disabled',
|
|
13
|
+
description: 'Disables native switch activation and focus behavior.',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'onPressedChange',
|
|
17
|
+
description: 'Receives the next boolean state after activation.',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'pressed',
|
|
21
|
+
description:
|
|
22
|
+
'Controls the current switch state without internal updates.',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
inheritedProps: [
|
|
26
|
+
'ButtonHTMLAttributes<HTMLButtonElement> except aria-checked, aria-pressed, className, onChange, and role',
|
|
27
|
+
],
|
|
28
|
+
example: '<Toggle aria-label="Enable option" defaultPressed />',
|
|
29
|
+
storyId: 'core-toggle--default',
|
|
30
|
+
} satisfies ComponentDoc;
|