@cdx-ui/components 0.0.1-beta.4 → 0.0.1-beta.40
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/README.md +18 -11
- package/lib/commonjs/components/Avatar/index.js +1 -1
- package/lib/commonjs/components/Avatar/styles.js +36 -29
- package/lib/commonjs/components/Avatar/styles.js.map +1 -1
- package/lib/commonjs/components/Button/styles.js +2 -2
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/CLAUDE.md +90 -0
- package/lib/commonjs/components/Card/index.js +22 -4
- package/lib/commonjs/components/Card/index.js.map +1 -1
- package/lib/commonjs/components/Card/styles.js +27 -5
- package/lib/commonjs/components/Card/styles.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js +5 -29
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Checkbox/styles.js +39 -47
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/Chip/index.js +78 -9
- package/lib/commonjs/components/Chip/index.js.map +1 -1
- package/lib/commonjs/components/Chip/styles.js +207 -21
- package/lib/commonjs/components/Chip/styles.js.map +1 -1
- package/lib/commonjs/components/Field/index.js +8 -2
- package/lib/commonjs/components/Field/index.js.map +1 -1
- package/lib/commonjs/components/Field/styles.js +4 -4
- package/lib/commonjs/components/Field/styles.js.map +1 -1
- package/lib/commonjs/components/Heading/styles.js +1 -1
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +1 -2
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/index.js +6 -1
- package/lib/commonjs/components/IconButton/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/styles.js +135 -10
- package/lib/commonjs/components/IconButton/styles.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +7 -6
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js +283 -0
- package/lib/commonjs/components/ListItem/index.js.map +1 -0
- package/lib/commonjs/components/ListItem/styles.js +130 -0
- package/lib/commonjs/components/ListItem/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressSegmented/index.js +22 -10
- package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -1
- package/lib/commonjs/components/Radio/index.js +167 -0
- package/lib/commonjs/components/Radio/index.js.map +1 -0
- package/lib/commonjs/components/Radio/styles.js +31 -0
- package/lib/commonjs/components/Radio/styles.js.map +1 -0
- package/lib/commonjs/components/Text/styles.js +2 -2
- package/lib/commonjs/components/Text/styles.js.map +1 -1
- package/lib/commonjs/components/Tile/index.js +251 -0
- package/lib/commonjs/components/Tile/index.js.map +1 -0
- package/lib/commonjs/components/Tile/styles.js +52 -0
- package/lib/commonjs/components/Tile/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +36 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/Avatar.figma.js +54 -0
- package/lib/commonjs/figma/Avatar.figma.js.map +1 -0
- package/lib/commonjs/figma/Button.figma.js +28 -11
- package/lib/commonjs/figma/Button.figma.js.map +1 -1
- package/lib/commonjs/figma/CLAUDE.md +30 -0
- package/lib/commonjs/figma/Card.Header.figma.js +28 -0
- package/lib/commonjs/figma/Card.Header.figma.js.map +1 -0
- package/lib/commonjs/figma/Card.figma.js +42 -0
- package/lib/commonjs/figma/Card.figma.js.map +1 -0
- package/lib/commonjs/figma/Checkbox.figma.js +55 -0
- package/lib/commonjs/figma/Checkbox.figma.js.map +1 -0
- package/lib/commonjs/figma/Chip.figma.js +68 -0
- package/lib/commonjs/figma/Chip.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Input.figma.js +57 -0
- package/lib/commonjs/figma/Field.Input.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Select.figma.js +57 -0
- package/lib/commonjs/figma/Field.Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Heading.figma.js +30 -0
- package/lib/commonjs/figma/Heading.figma.js.map +1 -0
- package/lib/commonjs/figma/Icon.figma.js +20 -0
- package/lib/commonjs/figma/Icon.figma.js.map +1 -0
- package/lib/commonjs/figma/IconButton.figma.js +47 -0
- package/lib/commonjs/figma/IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/Input.figma.js +52 -0
- package/lib/commonjs/figma/Input.figma.js.map +1 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js +39 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/commonjs/figma/Radio.figma.js +38 -0
- package/lib/commonjs/figma/Radio.figma.js.map +1 -0
- package/lib/commonjs/figma/Select.figma.js +53 -0
- package/lib/commonjs/figma/Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Text.figma.js +29 -0
- package/lib/commonjs/figma/Text.figma.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.js +27 -0
- package/lib/commonjs/figma/icons.figma.batch.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.json +17705 -0
- package/lib/commonjs/styles/primitives.js +42 -5
- package/lib/commonjs/styles/primitives.js.map +1 -1
- package/lib/module/components/Avatar/index.js +1 -1
- package/lib/module/components/Avatar/styles.js +36 -29
- package/lib/module/components/Avatar/styles.js.map +1 -1
- package/lib/module/components/Button/styles.js +2 -2
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/CLAUDE.md +90 -0
- package/lib/module/components/Card/index.js +23 -4
- package/lib/module/components/Card/index.js.map +1 -1
- package/lib/module/components/Card/styles.js +27 -5
- package/lib/module/components/Card/styles.js.map +1 -1
- package/lib/module/components/Checkbox/index.js +6 -30
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +40 -48
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/Chip/index.js +82 -13
- package/lib/module/components/Chip/index.js.map +1 -1
- package/lib/module/components/Chip/styles.js +206 -20
- package/lib/module/components/Chip/styles.js.map +1 -1
- package/lib/module/components/Field/index.js +9 -3
- package/lib/module/components/Field/index.js.map +1 -1
- package/lib/module/components/Field/styles.js +4 -4
- package/lib/module/components/Field/styles.js.map +1 -1
- package/lib/module/components/Heading/styles.js +1 -1
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/Icon/index.js +1 -2
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/IconButton/index.js +6 -1
- package/lib/module/components/IconButton/index.js.map +1 -1
- package/lib/module/components/IconButton/styles.js +135 -10
- package/lib/module/components/IconButton/styles.js.map +1 -1
- package/lib/module/components/Input/styles.js +7 -6
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js +226 -0
- package/lib/module/components/ListItem/index.js.map +1 -0
- package/lib/module/components/ListItem/styles.js +127 -0
- package/lib/module/components/ListItem/styles.js.map +1 -0
- package/lib/module/components/ProgressSegmented/index.js +23 -11
- package/lib/module/components/ProgressSegmented/index.js.map +1 -1
- package/lib/module/components/Radio/index.js +164 -0
- package/lib/module/components/Radio/index.js.map +1 -0
- package/lib/module/components/Radio/styles.js +27 -0
- package/lib/module/components/Radio/styles.js.map +1 -0
- package/lib/module/components/Text/styles.js +2 -2
- package/lib/module/components/Text/styles.js.map +1 -1
- package/lib/module/components/Tile/index.js +243 -0
- package/lib/module/components/Tile/index.js.map +1 -0
- package/lib/module/components/Tile/styles.js +48 -0
- package/lib/module/components/Tile/styles.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/Avatar.figma.js +48 -0
- package/lib/module/figma/Avatar.figma.js.map +1 -0
- package/lib/module/figma/Button.figma.js +28 -11
- package/lib/module/figma/Button.figma.js.map +1 -1
- package/lib/module/figma/CLAUDE.md +30 -0
- package/lib/module/figma/Card.Header.figma.js +22 -0
- package/lib/module/figma/Card.Header.figma.js.map +1 -0
- package/lib/module/figma/Card.figma.js +36 -0
- package/lib/module/figma/Card.figma.js.map +1 -0
- package/lib/module/figma/Checkbox.figma.js +49 -0
- package/lib/module/figma/Checkbox.figma.js.map +1 -0
- package/lib/module/figma/Chip.figma.js +62 -0
- package/lib/module/figma/Chip.figma.js.map +1 -0
- package/lib/module/figma/Field.Input.figma.js +51 -0
- package/lib/module/figma/Field.Input.figma.js.map +1 -0
- package/lib/module/figma/Field.Select.figma.js +51 -0
- package/lib/module/figma/Field.Select.figma.js.map +1 -0
- package/lib/module/figma/Heading.figma.js +24 -0
- package/lib/module/figma/Heading.figma.js.map +1 -0
- package/lib/module/figma/Icon.figma.js +14 -0
- package/lib/module/figma/Icon.figma.js.map +1 -0
- package/lib/module/figma/IconButton.figma.js +41 -0
- package/lib/module/figma/IconButton.figma.js.map +1 -0
- package/lib/module/figma/Input.figma.js +46 -0
- package/lib/module/figma/Input.figma.js.map +1 -0
- package/lib/module/figma/ProgressSegmented.figma.js +33 -0
- package/lib/module/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/module/figma/Radio.figma.js +32 -0
- package/lib/module/figma/Radio.figma.js.map +1 -0
- package/lib/module/figma/Select.figma.js +47 -0
- package/lib/module/figma/Select.figma.js.map +1 -0
- package/lib/module/figma/Text.figma.js +23 -0
- package/lib/module/figma/Text.figma.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.js +22 -0
- package/lib/module/figma/icons.figma.batch.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.json +17705 -0
- package/lib/module/styles/primitives.js +42 -5
- package/lib/module/styles/primitives.js.map +1 -1
- package/lib/typescript/components/Avatar/styles.d.ts +4 -4
- package/lib/typescript/components/Avatar/styles.d.ts.map +1 -1
- package/lib/typescript/components/Card/index.d.ts +4 -3
- package/lib/typescript/components/Card/index.d.ts.map +1 -1
- package/lib/typescript/components/Card/styles.d.ts +13 -3
- package/lib/typescript/components/Card/styles.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/index.d.ts +1 -2
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts +4 -14
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/Chip/index.d.ts +19 -6
- package/lib/typescript/components/Chip/index.d.ts.map +1 -1
- package/lib/typescript/components/Chip/styles.d.ts +13 -4
- package/lib/typescript/components/Chip/styles.d.ts.map +1 -1
- package/lib/typescript/components/Field/FieldLabel.web.d.ts +2 -2
- package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +1 -1
- package/lib/typescript/components/Field/index.d.ts.map +1 -1
- package/lib/typescript/components/Field/styles.d.ts.map +1 -1
- package/lib/typescript/components/Heading/styles.d.ts +1 -1
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/styles.d.ts +6 -2
- package/lib/typescript/components/IconButton/styles.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +49 -0
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -0
- package/lib/typescript/components/ListItem/styles.d.ts +30 -0
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressSegmented/index.d.ts +14 -3
- package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -1
- package/lib/typescript/components/Radio/index.d.ts +40 -0
- package/lib/typescript/components/Radio/index.d.ts.map +1 -0
- package/lib/typescript/components/Radio/styles.d.ts +8 -0
- package/lib/typescript/components/Radio/styles.d.ts.map +1 -0
- package/lib/typescript/components/Stack/styles.d.ts +2 -2
- package/lib/typescript/components/Text/styles.d.ts +1 -1
- package/lib/typescript/components/Tile/index.d.ts +70 -0
- package/lib/typescript/components/Tile/index.d.ts.map +1 -0
- package/lib/typescript/components/Tile/styles.d.ts +18 -0
- package/lib/typescript/components/Tile/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/Avatar.figma.d.ts +8 -0
- package/lib/typescript/figma/Avatar.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Button.figma.d.ts.map +1 -1
- package/lib/typescript/figma/Card.Header.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Card.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts +8 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Chip.figma.d.ts +8 -0
- package/lib/typescript/figma/Chip.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Heading.figma.d.ts +8 -0
- package/lib/typescript/figma/Heading.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Icon.figma.d.ts +8 -0
- package/lib/typescript/figma/Icon.figma.d.ts.map +1 -0
- package/lib/typescript/figma/IconButton.figma.d.ts +8 -0
- package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts +8 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Radio.figma.d.ts +8 -0
- package/lib/typescript/figma/Radio.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Text.figma.d.ts +8 -0
- package/lib/typescript/figma/Text.figma.d.ts.map +1 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts +14 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts.map +1 -0
- package/lib/typescript/styles/primitives.d.ts +38 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Avatar/index.tsx +1 -1
- package/src/components/Avatar/styles.ts +49 -34
- package/src/components/Button/styles.ts +2 -2
- package/src/components/CLAUDE.md +90 -0
- package/src/components/Card/index.tsx +41 -16
- package/src/components/Card/styles.ts +43 -23
- package/src/components/Checkbox/index.tsx +8 -19
- package/src/components/Checkbox/styles.ts +82 -86
- package/src/components/Chip/index.tsx +104 -27
- package/src/components/Chip/styles.ts +232 -18
- package/src/components/Field/FieldLabel.web.tsx +1 -1
- package/src/components/Field/index.tsx +10 -3
- package/src/components/Field/styles.ts +5 -4
- package/src/components/Heading/styles.ts +1 -1
- package/src/components/Icon/index.tsx +1 -2
- package/src/components/IconButton/index.tsx +3 -2
- package/src/components/IconButton/styles.ts +136 -10
- package/src/components/Input/styles.ts +14 -9
- package/src/components/ListItem/index.tsx +285 -0
- package/src/components/ListItem/styles.ts +153 -0
- package/src/components/ProgressSegmented/index.tsx +49 -14
- package/src/components/Radio/index.tsx +192 -0
- package/src/components/Radio/styles.ts +59 -0
- package/src/components/Text/styles.ts +2 -2
- package/src/components/Tile/index.tsx +296 -0
- package/src/components/Tile/styles.ts +82 -0
- package/src/components/index.ts +3 -0
- package/src/styles/primitives.ts +42 -5
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Pressable, Text, View, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
createTile,
|
|
5
|
+
type ITileGroupMultipleProps,
|
|
6
|
+
type ITileGroupSingleProps,
|
|
7
|
+
type ITileIndicatorProps,
|
|
8
|
+
type ITileLeadingSlotProps,
|
|
9
|
+
type ITileProps,
|
|
10
|
+
type ITileTrailingSlotProps,
|
|
11
|
+
useTileContext,
|
|
12
|
+
} from '@cdx-ui/primitives';
|
|
13
|
+
import { Check } from '@cdx-ui/icons';
|
|
14
|
+
import { dataAttributes } from '@cdx-ui/primitives';
|
|
15
|
+
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
16
|
+
import { checkboxIndicatorVariants, checkboxIconVariants } from '../Checkbox/styles';
|
|
17
|
+
import { Icon } from '../Icon';
|
|
18
|
+
import { radioIndicatorVariants, radioInnerDotVariants } from '../Radio/styles';
|
|
19
|
+
import {
|
|
20
|
+
tileContentVariants,
|
|
21
|
+
tileDescriptionVariants,
|
|
22
|
+
tileGroupVariants,
|
|
23
|
+
tileIndicatorVariants,
|
|
24
|
+
tileLeadingSlotVariants,
|
|
25
|
+
tileRootVariants,
|
|
26
|
+
tileTitleVariants,
|
|
27
|
+
tileTrailingSlotVariants,
|
|
28
|
+
type TileGroupVariantProps,
|
|
29
|
+
type TileVariantProps,
|
|
30
|
+
} from './styles';
|
|
31
|
+
|
|
32
|
+
const TILE_SCOPE = 'TILE';
|
|
33
|
+
const TILE_GROUP_SCOPE = 'TILE_GROUP';
|
|
34
|
+
|
|
35
|
+
const RootPressable = withStyleContext(Pressable, TILE_SCOPE);
|
|
36
|
+
const GroupView = withStyleContext(View, TILE_GROUP_SCOPE);
|
|
37
|
+
|
|
38
|
+
interface TileGroupStyleContext {
|
|
39
|
+
shape?: TileVariantProps['shape'];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const useTileGroupStyleContext = (): TileGroupStyleContext => {
|
|
43
|
+
// `useStyleContext` types the result as a `Record`, but at runtime the value is
|
|
44
|
+
// `undefined` when no provider is in scope (e.g. standalone Tile). Cast through
|
|
45
|
+
// `unknown` to acknowledge that.
|
|
46
|
+
const ctx = useStyleContext(TILE_GROUP_SCOPE) as unknown as TileGroupStyleContext | undefined;
|
|
47
|
+
return ctx ?? {};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const TilePrimitive = createTile({
|
|
51
|
+
Pressable: RootPressable,
|
|
52
|
+
Group: GroupView,
|
|
53
|
+
LeadingSlot: View,
|
|
54
|
+
Content: View,
|
|
55
|
+
Title: Text,
|
|
56
|
+
Description: Text,
|
|
57
|
+
Indicator: View,
|
|
58
|
+
TrailingSlot: View,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// TILE GROUP
|
|
63
|
+
// =============================================================================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Discriminated union mirroring `ITileGroupProps`, with `className` and layout variants added at
|
|
67
|
+
* the styled layer. Distributing the intersection across each branch keeps `interface … extends`
|
|
68
|
+
* ergonomics and avoids tripping `@typescript-eslint` on `(union) & { ... }`.
|
|
69
|
+
*
|
|
70
|
+
* `direction` and `spacing` constrain the group layout to the three supported patterns:
|
|
71
|
+
* - `direction="column"` + `spacing="default"` — vertical stack with gaps (default).
|
|
72
|
+
* - `direction="column"` + `spacing="none"` — tight vertical stack (rows touch).
|
|
73
|
+
* - `direction="row"` + `spacing="default"` — side-by-side horizontal layout.
|
|
74
|
+
*
|
|
75
|
+
* `shape` (when set) is propagated to child `Tile`s via `withStyleContext`, matching the
|
|
76
|
+
* Avatar size-propagation pattern. A per-tile `shape` prop overrides the inherited value.
|
|
77
|
+
*/
|
|
78
|
+
export interface TileGroupSingleProps extends ITileGroupSingleProps, TileGroupVariantProps {
|
|
79
|
+
className?: string;
|
|
80
|
+
/** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
|
|
81
|
+
shape?: TileVariantProps['shape'];
|
|
82
|
+
}
|
|
83
|
+
export interface TileGroupMultipleProps extends ITileGroupMultipleProps, TileGroupVariantProps {
|
|
84
|
+
className?: string;
|
|
85
|
+
/** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
|
|
86
|
+
shape?: TileVariantProps['shape'];
|
|
87
|
+
}
|
|
88
|
+
export type TileGroupProps = TileGroupSingleProps | TileGroupMultipleProps;
|
|
89
|
+
|
|
90
|
+
const TileGroup = forwardRef<View, TileGroupProps>(
|
|
91
|
+
({ className, style, children, direction, spacing, shape, ...props }, ref) => (
|
|
92
|
+
<TilePrimitive.Group
|
|
93
|
+
ref={ref as never}
|
|
94
|
+
className={cn(tileGroupVariants({ direction, spacing }), className)}
|
|
95
|
+
style={style}
|
|
96
|
+
context={{ shape }}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</TilePrimitive.Group>
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
TileGroup.displayName = 'Tile.Group';
|
|
105
|
+
|
|
106
|
+
// =============================================================================
|
|
107
|
+
// TILE ROOT
|
|
108
|
+
// =============================================================================
|
|
109
|
+
|
|
110
|
+
export interface TileProps extends ITileProps, TileVariantProps {
|
|
111
|
+
className?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const TileRoot = forwardRef<View, TileProps>(
|
|
115
|
+
({ shape: shapeProp, showSeparator, className, style, context, ...props }, ref) => {
|
|
116
|
+
const { shape: inheritedShape } = useTileGroupStyleContext();
|
|
117
|
+
const shape = shapeProp ?? inheritedShape ?? 'card';
|
|
118
|
+
const computedClassName = cn(tileRootVariants({ shape, showSeparator }), className);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<TilePrimitive
|
|
122
|
+
ref={ref as never}
|
|
123
|
+
className={computedClassName}
|
|
124
|
+
context={{ ...context, shape }}
|
|
125
|
+
style={style}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
TileRoot.displayName = 'Tile';
|
|
133
|
+
|
|
134
|
+
// =============================================================================
|
|
135
|
+
// SLOTS
|
|
136
|
+
// =============================================================================
|
|
137
|
+
|
|
138
|
+
export interface TileLeadingSlotProps extends ITileLeadingSlotProps {
|
|
139
|
+
className?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const TileLeadingSlot = forwardRef<View, TileLeadingSlotProps>(
|
|
143
|
+
({ className, style, ...props }, ref) => (
|
|
144
|
+
<TilePrimitive.LeadingSlot
|
|
145
|
+
ref={ref as never}
|
|
146
|
+
className={cn(tileLeadingSlotVariants(), className)}
|
|
147
|
+
style={style}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
TileLeadingSlot.displayName = 'Tile.LeadingSlot';
|
|
154
|
+
|
|
155
|
+
export interface TileContentProps extends ViewProps {
|
|
156
|
+
className?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const TileContent = forwardRef<View, TileContentProps>(({ className, style, ...props }, ref) => (
|
|
160
|
+
<TilePrimitive.Content
|
|
161
|
+
ref={ref as never}
|
|
162
|
+
className={cn(tileContentVariants(), className)}
|
|
163
|
+
style={style}
|
|
164
|
+
{...props}
|
|
165
|
+
/>
|
|
166
|
+
));
|
|
167
|
+
|
|
168
|
+
TileContent.displayName = 'Tile.Content';
|
|
169
|
+
|
|
170
|
+
export interface TileTitleProps extends TextProps {
|
|
171
|
+
className?: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const TileTitle = forwardRef<Text, TileTitleProps>(
|
|
175
|
+
({ className, style, numberOfLines = 1, ...props }, ref) => (
|
|
176
|
+
<TilePrimitive.Title
|
|
177
|
+
ref={ref as never}
|
|
178
|
+
className={cn(tileTitleVariants(), className)}
|
|
179
|
+
style={style}
|
|
180
|
+
numberOfLines={numberOfLines}
|
|
181
|
+
{...props}
|
|
182
|
+
/>
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
TileTitle.displayName = 'Tile.Title';
|
|
187
|
+
|
|
188
|
+
export interface TileDescriptionProps extends TextProps {
|
|
189
|
+
className?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const TileDescription = forwardRef<Text, TileDescriptionProps>(
|
|
193
|
+
({ className, style, ...props }, ref) => (
|
|
194
|
+
<TilePrimitive.Description
|
|
195
|
+
ref={ref as never}
|
|
196
|
+
className={cn(tileDescriptionVariants(), className)}
|
|
197
|
+
style={style}
|
|
198
|
+
{...props}
|
|
199
|
+
/>
|
|
200
|
+
),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
TileDescription.displayName = 'Tile.Description';
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Decorative selection affordance. Renders pure CVA-styled Views — no interactive hooks,
|
|
207
|
+
* no nested Pressable, zero runtime overhead. The Tile root owns the press target and
|
|
208
|
+
* ARIA role; this subtree is `aria-hidden` via `createTileIndicator`.
|
|
209
|
+
*
|
|
210
|
+
* The visual is inferred from the tile context: `single` (radio semantics) → radio ring,
|
|
211
|
+
* `multiple` (checkbox semantics) → checkbox square. An explicit `indicatorType` prop
|
|
212
|
+
* overrides — primarily for standalone tiles that want a radio-style visual.
|
|
213
|
+
*/
|
|
214
|
+
function TileIndicatorVisual({ indicatorType }: { indicatorType?: 'radio' | 'checkbox' }) {
|
|
215
|
+
const { isSelected, isDisabled, selectionType } = useTileContext();
|
|
216
|
+
const effectiveType: 'radio' | 'checkbox' =
|
|
217
|
+
indicatorType ?? (selectionType === 'single' ? 'radio' : 'checkbox');
|
|
218
|
+
const stateAttrs = dataAttributes({ checked: isSelected, disabled: isDisabled });
|
|
219
|
+
|
|
220
|
+
if (effectiveType === 'radio') {
|
|
221
|
+
return (
|
|
222
|
+
<View className={radioIndicatorVariants()} {...stateAttrs}>
|
|
223
|
+
<View
|
|
224
|
+
className={radioInnerDotVariants()}
|
|
225
|
+
{...dataAttributes({ checked: isSelected, invalid: false })}
|
|
226
|
+
/>
|
|
227
|
+
</View>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<View className={cn(checkboxIndicatorVariants())} {...stateAttrs}>
|
|
233
|
+
{isSelected && <Icon as={Check} className={checkboxIconVariants()} />}
|
|
234
|
+
</View>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface TileIndicatorProps extends ITileIndicatorProps {
|
|
239
|
+
className?: string;
|
|
240
|
+
children?: ReactNode;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const TileIndicator = forwardRef<View, TileIndicatorProps>(
|
|
244
|
+
({ className, children, style, indicatorType, ...props }, ref) => (
|
|
245
|
+
<TilePrimitive.Indicator
|
|
246
|
+
ref={ref as never}
|
|
247
|
+
className={cn(tileIndicatorVariants(), className)}
|
|
248
|
+
style={style}
|
|
249
|
+
indicatorType={indicatorType}
|
|
250
|
+
{...props}
|
|
251
|
+
>
|
|
252
|
+
{children ?? <TileIndicatorVisual indicatorType={indicatorType} />}
|
|
253
|
+
</TilePrimitive.Indicator>
|
|
254
|
+
),
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
TileIndicator.displayName = 'Tile.Indicator';
|
|
258
|
+
|
|
259
|
+
export interface TileTrailingSlotProps extends ITileTrailingSlotProps {
|
|
260
|
+
className?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const TileTrailingSlot = forwardRef<View, TileTrailingSlotProps>(
|
|
264
|
+
({ className, style, ...props }, ref) => (
|
|
265
|
+
<TilePrimitive.TrailingSlot
|
|
266
|
+
ref={ref as never}
|
|
267
|
+
className={cn(tileTrailingSlotVariants(), className)}
|
|
268
|
+
style={style}
|
|
269
|
+
{...props}
|
|
270
|
+
/>
|
|
271
|
+
),
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
TileTrailingSlot.displayName = 'Tile.TrailingSlot';
|
|
275
|
+
|
|
276
|
+
type TileCompound = typeof TileRoot & {
|
|
277
|
+
Group: typeof TileGroup;
|
|
278
|
+
LeadingSlot: typeof TileLeadingSlot;
|
|
279
|
+
Content: typeof TileContent;
|
|
280
|
+
Title: typeof TileTitle;
|
|
281
|
+
Description: typeof TileDescription;
|
|
282
|
+
Indicator: typeof TileIndicator;
|
|
283
|
+
TrailingSlot: typeof TileTrailingSlot;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export const Tile = Object.assign(TileRoot, {
|
|
287
|
+
Group: TileGroup,
|
|
288
|
+
LeadingSlot: TileLeadingSlot,
|
|
289
|
+
Content: TileContent,
|
|
290
|
+
Title: TileTitle,
|
|
291
|
+
Description: TileDescription,
|
|
292
|
+
Indicator: TileIndicator,
|
|
293
|
+
TrailingSlot: TileTrailingSlot,
|
|
294
|
+
}) as TileCompound;
|
|
295
|
+
|
|
296
|
+
export { useTileContext };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { TRANSITION_COLORS } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
export const tileGroupVariants = cva(['flex w-full'], {
|
|
6
|
+
variants: {
|
|
7
|
+
direction: {
|
|
8
|
+
column: 'flex-col',
|
|
9
|
+
row: 'flex-row',
|
|
10
|
+
},
|
|
11
|
+
spacing: {
|
|
12
|
+
default: 'gap-2',
|
|
13
|
+
none: 'gap-0',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
direction: 'column',
|
|
18
|
+
spacing: 'default',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type TileGroupVariantProps = VariantProps<typeof tileGroupVariants>;
|
|
23
|
+
|
|
24
|
+
export const tileRootVariants = cva(
|
|
25
|
+
[
|
|
26
|
+
'flex-row self-stretch gap-3 px-4 py-3',
|
|
27
|
+
'data-[disabled=true]:opacity-50',
|
|
28
|
+
TRANSITION_COLORS,
|
|
29
|
+
Platform.select({
|
|
30
|
+
web: [
|
|
31
|
+
'outline-none',
|
|
32
|
+
'data-[hover=true]:data-[disabled=false]:bg-surface-action-tint-hover',
|
|
33
|
+
'data-[active=true]:data-[disabled=false]:data-[hover=true]:bg-surface-action-tint-active',
|
|
34
|
+
'data-[hover=true]:data-[disabled=false]:data-[state=unselected]:border-stroke-action',
|
|
35
|
+
'focus-visible:data-[disabled=false]:ring-2 focus-visible:data-[disabled=false]:ring-stroke-focus focus-visible:data-[disabled=false]:ring-offset-2',
|
|
36
|
+
].join(' '),
|
|
37
|
+
default: [
|
|
38
|
+
'data-[active=true]:bg-surface-action-tint-hover',
|
|
39
|
+
'data-[active=true]:border-stroke-action',
|
|
40
|
+
].join(' '),
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
{
|
|
44
|
+
variants: {
|
|
45
|
+
shape: {
|
|
46
|
+
flat: 'rounded-none border-0 bg-transparent',
|
|
47
|
+
card: [
|
|
48
|
+
'rounded-[var(--border-radius-default)] border-1 border-solid',
|
|
49
|
+
'border-stroke-secondary',
|
|
50
|
+
'bg-surface-primary',
|
|
51
|
+
'data-[state=selected]:border-stroke-action',
|
|
52
|
+
'data-[state=selected]:border-1.5',
|
|
53
|
+
'data-[state=selected]:bg-surface-action-tint',
|
|
54
|
+
].join(' '),
|
|
55
|
+
},
|
|
56
|
+
showSeparator: {
|
|
57
|
+
true: [
|
|
58
|
+
'border-b border-solid border-stroke-secondary! native:data-[active=true]:border-stroke-secondary', // Override border-stroke-action on hover
|
|
59
|
+
],
|
|
60
|
+
false: '',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
defaultVariants: {
|
|
64
|
+
shape: 'card',
|
|
65
|
+
showSeparator: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export const tileLeadingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
|
|
71
|
+
|
|
72
|
+
export const tileTrailingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
|
|
73
|
+
|
|
74
|
+
export const tileContentVariants = cva(['min-w-0 flex-1 flex-col gap-0.5 no-underline']);
|
|
75
|
+
|
|
76
|
+
export const tileTitleVariants = cva(['text-base font-medium text-content-primary no-underline']);
|
|
77
|
+
|
|
78
|
+
export const tileDescriptionVariants = cva(['text-sm text-content-secondary no-underline']);
|
|
79
|
+
|
|
80
|
+
export const tileIndicatorVariants = cva(['flex shrink-0 items-center justify-center']);
|
|
81
|
+
|
|
82
|
+
export type TileVariantProps = VariantProps<typeof tileRootVariants>;
|
package/src/components/index.ts
CHANGED
|
@@ -13,11 +13,14 @@ export * from './Image';
|
|
|
13
13
|
export * from './Input';
|
|
14
14
|
export * from './OtpInput';
|
|
15
15
|
export * from './Link';
|
|
16
|
+
export * from './ListItem';
|
|
16
17
|
export * from './ProgressBar';
|
|
17
18
|
export * from './ProgressSegmented';
|
|
19
|
+
export * from './Radio';
|
|
18
20
|
export * from './Select';
|
|
19
21
|
export * from './VirtualizedList';
|
|
20
22
|
export * from './Switch';
|
|
23
|
+
export * from './Tile';
|
|
21
24
|
export { HStack, VStack } from './Stack';
|
|
22
25
|
export * from './Heading';
|
|
23
26
|
export * from './Text';
|
package/src/styles/primitives.ts
CHANGED
|
@@ -3,36 +3,65 @@
|
|
|
3
3
|
|
|
4
4
|
// ─── Colors ──────────────────────────────────────────────
|
|
5
5
|
// Surface & background
|
|
6
|
+
/** @deprecated Use `bg-surface-primary` (--color-surface-primary) instead. */
|
|
6
7
|
export const COLOR_BG_PRIMARY = 'bg-white';
|
|
8
|
+
/** @deprecated Use `bg-surface-secondary` (--color-surface-secondary) instead. */
|
|
7
9
|
export const COLOR_BG_SUBTLE = 'bg-slate-50';
|
|
10
|
+
/** @deprecated Use `bg-surface-neutral-subtle` (--color-surface-neutral-subtle) instead. */
|
|
8
11
|
export const COLOR_BG_MUTED = 'bg-slate-100';
|
|
12
|
+
/** @deprecated Use `bg-base-950` (--color-base-950) instead. */
|
|
9
13
|
export const COLOR_BG_INVERSE = 'bg-slate-900';
|
|
10
14
|
|
|
11
15
|
// Border
|
|
16
|
+
/** @deprecated Use `border-stroke-secondary` (--color-stroke-secondary) instead. */
|
|
12
17
|
export const COLOR_BORDER_DEFAULT = 'border-slate-200';
|
|
18
|
+
/** @deprecated Use `border-stroke-hover` (--color-stroke-hover) instead. */
|
|
13
19
|
export const COLOR_BORDER_STRONG = 'border-slate-300';
|
|
20
|
+
/** @deprecated Use `border-stroke-focus` (--color-stroke-focus) instead. */
|
|
14
21
|
export const COLOR_BORDER_FOCUS = 'border-slate-900';
|
|
22
|
+
/** @deprecated Use `border-stroke-danger` (--color-stroke-danger) instead. */
|
|
15
23
|
export const COLOR_BORDER_INVALID = 'border-red-500';
|
|
16
24
|
|
|
17
25
|
// Text
|
|
26
|
+
/** @deprecated Use `text-content-primary` (--color-content-primary) instead. */
|
|
18
27
|
export const COLOR_TEXT_PRIMARY = 'text-slate-900';
|
|
28
|
+
/** @deprecated Use `text-content-secondary` (--color-content-secondary) instead. */
|
|
19
29
|
export const COLOR_TEXT_SECONDARY = 'text-slate-500';
|
|
30
|
+
/** @deprecated Use `text-content-tertiary` (--color-content-tertiary) instead. */
|
|
20
31
|
export const COLOR_TEXT_MUTED = 'text-slate-400';
|
|
32
|
+
/** @deprecated Use the appropriate `text-content-*-on-strong` token for the surface color, e.g. `text-content-action-on-strong` (--color-content-action-on-strong). */
|
|
21
33
|
export const COLOR_TEXT_INVERSE = 'text-white';
|
|
34
|
+
/** @deprecated Use `text-content-tertiary` (--color-content-tertiary) instead. */
|
|
22
35
|
export const COLOR_TEXT_PLACEHOLDER = 'text-slate-400';
|
|
36
|
+
/** @deprecated Use `text-content-danger` (--color-content-danger) instead. */
|
|
23
37
|
export const COLOR_TEXT_INVALID = 'text-red-600';
|
|
24
38
|
|
|
25
39
|
// Brand / Action
|
|
40
|
+
/** @deprecated Use `bg-surface-action-strong` (--color-surface-action-strong) instead. */
|
|
26
41
|
export const COLOR_BRAND_DEFAULT = 'bg-slate-900';
|
|
42
|
+
/** @deprecated Use `bg-surface-action-strong-hover` (--color-surface-action-strong-hover) instead. */
|
|
27
43
|
export const COLOR_BRAND_HOVER = 'bg-slate-800';
|
|
44
|
+
/** @deprecated Use `bg-surface-action-strong-active` (--color-surface-action-strong-active) instead. */
|
|
28
45
|
export const COLOR_BRAND_ACTIVE = 'bg-slate-700';
|
|
29
46
|
|
|
30
47
|
// Accent (for checked states, active indicators)
|
|
48
|
+
/** @deprecated Use `bg-surface-action-strong` (--color-surface-action-strong) instead. */
|
|
31
49
|
export const COLOR_ACCENT_DEFAULT = 'bg-slate-900';
|
|
50
|
+
/** @deprecated Use `border-stroke-action` (--color-stroke-action) instead. */
|
|
32
51
|
export const COLOR_ACCENT_BORDER = 'border-slate-900';
|
|
33
52
|
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use semantic token classes directly instead. Map each color key to its
|
|
55
|
+
* corresponding `--color-surface-*`, `--color-stroke-*`, and `--color-content-*` tokens:
|
|
56
|
+
* - `bg` → `bg-surface-{color}-strong` (--color-surface-{color}-strong)
|
|
57
|
+
* - `bgHover` → `bg-surface-{color}-strong-hover` (--color-surface-{color}-strong-hover)
|
|
58
|
+
* - `bgActive` → `bg-surface-{color}-strong-active` (--color-surface-{color}-strong-active)
|
|
59
|
+
* - `border` → `border-stroke-{color}` (--color-stroke-{color})
|
|
60
|
+
* - `text` → `text-content-{color}` (--color-content-{color})
|
|
61
|
+
* - `ring` → `ring-[--color-stroke-focus]` (--color-stroke-focus)
|
|
62
|
+
*
|
|
63
|
+
* See Button/styles.ts for a complete migration example.
|
|
64
|
+
*/
|
|
36
65
|
export const SEMANTIC_COLORS = {
|
|
37
66
|
action: {
|
|
38
67
|
bg: 'bg-slate-900',
|
|
@@ -77,21 +106,29 @@ export const SEMANTIC_COLORS = {
|
|
|
77
106
|
} as const;
|
|
78
107
|
|
|
79
108
|
// ─── Focus ───────────────────────────────────────────────
|
|
109
|
+
/** @deprecated Use `ring-2 ring-[--color-stroke-focus] ring-offset-2` (--color-stroke-focus) instead. */
|
|
80
110
|
export const FOCUS_RING = 'ring-2 ring-slate-400/50 ring-offset-2';
|
|
81
111
|
|
|
82
112
|
// ─── Radius ──────────────────────────────────────────────
|
|
83
|
-
|
|
84
|
-
export const
|
|
85
|
-
|
|
113
|
+
/** @deprecated Use `rounded-[var(--border-radius-button)]` for buttons/inputs or `rounded-[var(--border-radius-default)]` for containers. */
|
|
114
|
+
export const RADIUS_SM = 'rounded-lg';
|
|
115
|
+
/** @deprecated Use `rounded-[var(--border-radius-default)]` for cards/containers. */
|
|
116
|
+
export const RADIUS_MD = 'rounded-xl';
|
|
117
|
+
/** @deprecated Use `rounded-[var(--border-radius-round)]` for circular elements (icon buttons, radio, pills). */
|
|
118
|
+
export const RADIUS_FULL = 'rounded-full';
|
|
86
119
|
|
|
87
120
|
// ─── Shadows ─────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
/** @deprecated Use `shadow-sm` directly instead */
|
|
88
123
|
export const SHADOW_SM = 'shadow-sm';
|
|
124
|
+
/** @deprecated Use `shadow-md` directly instead */
|
|
89
125
|
export const SHADOW_MD = 'shadow-md';
|
|
90
126
|
|
|
91
127
|
// ─── Sizing ──────────────────────────────────────────────
|
|
92
128
|
// Unified size scale for interactive/form components (Button, Input, Select, Checkbox).
|
|
93
129
|
// Only two sizes: 'default' (regular) and 'small' (compact).
|
|
94
130
|
// NOTE: Text and Heading use a separate typography scale (xs/sm/md/lg/xl) — not this.
|
|
131
|
+
/** @deprecated */
|
|
95
132
|
export const SIZE_SCALE = {
|
|
96
133
|
default: { height: 'h-10', px: 'px-4', gap: 'gap-2', text: 'text-base' },
|
|
97
134
|
small: { height: 'h-8', px: 'px-3', gap: 'gap-1.5', text: 'text-sm' },
|