@cdx-ui/components 0.0.1-beta.12 → 0.0.1-beta.13
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/lib/commonjs/components/Checkbox/styles.js +1 -1
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +9 -9
- package/lib/commonjs/components/ListItem/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 +12 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/styles/primitives.js +36 -2
- package/lib/commonjs/styles/primitives.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +2 -2
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +10 -10
- package/lib/module/components/ListItem/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 +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/styles/primitives.js +36 -2
- package/lib/module/styles/primitives.js.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts.map +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 +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/styles/primitives.d.ts +35 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Checkbox/styles.ts +7 -9
- package/src/components/ListItem/styles.ts +12 -19
- package/src/components/Tile/index.tsx +296 -0
- package/src/components/Tile/styles.ts +82 -0
- package/src/components/index.ts +1 -0
- package/src/styles/primitives.ts +36 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { Text, View, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
import { type ITileGroupMultipleProps, type ITileGroupSingleProps, type ITileIndicatorProps, type ITileLeadingSlotProps, type ITileProps, type ITileTrailingSlotProps, useTileContext } from '@cdx-ui/primitives';
|
|
4
|
+
import { type TileGroupVariantProps, type TileVariantProps } from './styles';
|
|
5
|
+
/**
|
|
6
|
+
* Discriminated union mirroring `ITileGroupProps`, with `className` and layout variants added at
|
|
7
|
+
* the styled layer. Distributing the intersection across each branch keeps `interface … extends`
|
|
8
|
+
* ergonomics and avoids tripping `@typescript-eslint` on `(union) & { ... }`.
|
|
9
|
+
*
|
|
10
|
+
* `direction` and `spacing` constrain the group layout to the three supported patterns:
|
|
11
|
+
* - `direction="column"` + `spacing="default"` — vertical stack with gaps (default).
|
|
12
|
+
* - `direction="column"` + `spacing="none"` — tight vertical stack (rows touch).
|
|
13
|
+
* - `direction="row"` + `spacing="default"` — side-by-side horizontal layout.
|
|
14
|
+
*
|
|
15
|
+
* `shape` (when set) is propagated to child `Tile`s via `withStyleContext`, matching the
|
|
16
|
+
* Avatar size-propagation pattern. A per-tile `shape` prop overrides the inherited value.
|
|
17
|
+
*/
|
|
18
|
+
export interface TileGroupSingleProps extends ITileGroupSingleProps, TileGroupVariantProps {
|
|
19
|
+
className?: string;
|
|
20
|
+
/** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
|
|
21
|
+
shape?: TileVariantProps['shape'];
|
|
22
|
+
}
|
|
23
|
+
export interface TileGroupMultipleProps extends ITileGroupMultipleProps, TileGroupVariantProps {
|
|
24
|
+
className?: string;
|
|
25
|
+
/** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
|
|
26
|
+
shape?: TileVariantProps['shape'];
|
|
27
|
+
}
|
|
28
|
+
export type TileGroupProps = TileGroupSingleProps | TileGroupMultipleProps;
|
|
29
|
+
declare const TileGroup: import("react").ForwardRefExoticComponent<TileGroupProps & import("react").RefAttributes<View>>;
|
|
30
|
+
export interface TileProps extends ITileProps, TileVariantProps {
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare const TileRoot: import("react").ForwardRefExoticComponent<TileProps & import("react").RefAttributes<View>>;
|
|
34
|
+
export interface TileLeadingSlotProps extends ITileLeadingSlotProps {
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
declare const TileLeadingSlot: import("react").ForwardRefExoticComponent<TileLeadingSlotProps & import("react").RefAttributes<View>>;
|
|
38
|
+
export interface TileContentProps extends ViewProps {
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const TileContent: import("react").ForwardRefExoticComponent<TileContentProps & import("react").RefAttributes<View>>;
|
|
42
|
+
export interface TileTitleProps extends TextProps {
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
declare const TileTitle: import("react").ForwardRefExoticComponent<TileTitleProps & import("react").RefAttributes<Text>>;
|
|
46
|
+
export interface TileDescriptionProps extends TextProps {
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
declare const TileDescription: import("react").ForwardRefExoticComponent<TileDescriptionProps & import("react").RefAttributes<Text>>;
|
|
50
|
+
export interface TileIndicatorProps extends ITileIndicatorProps {
|
|
51
|
+
className?: string;
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
declare const TileIndicator: import("react").ForwardRefExoticComponent<TileIndicatorProps & import("react").RefAttributes<View>>;
|
|
55
|
+
export interface TileTrailingSlotProps extends ITileTrailingSlotProps {
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
declare const TileTrailingSlot: import("react").ForwardRefExoticComponent<TileTrailingSlotProps & import("react").RefAttributes<View>>;
|
|
59
|
+
type TileCompound = typeof TileRoot & {
|
|
60
|
+
Group: typeof TileGroup;
|
|
61
|
+
LeadingSlot: typeof TileLeadingSlot;
|
|
62
|
+
Content: typeof TileContent;
|
|
63
|
+
Title: typeof TileTitle;
|
|
64
|
+
Description: typeof TileDescription;
|
|
65
|
+
Indicator: typeof TileIndicator;
|
|
66
|
+
TrailingSlot: typeof TileTrailingSlot;
|
|
67
|
+
};
|
|
68
|
+
export declare const Tile: TileCompound;
|
|
69
|
+
export { useTileContext };
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Tile/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAa,IAAI,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,cAAc,EACf,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EASL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAmClB;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB,EAAE,qBAAqB;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACnC;AACD,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB,EAAE,qBAAqB;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,KAAK,CAAC,EAAE,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OAAO,eAAe,CAAC;IACpC,SAAS,EAAE,OAAO,aAAa,CAAC;IAChC,YAAY,EAAE,OAAO,gBAAgB,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,IAAI,EAQX,YAAY,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
export declare const tileGroupVariants: (props?: ({
|
|
3
|
+
direction?: "row" | "column" | null | undefined;
|
|
4
|
+
spacing?: "default" | "none" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export type TileGroupVariantProps = VariantProps<typeof tileGroupVariants>;
|
|
7
|
+
export declare const tileRootVariants: (props?: ({
|
|
8
|
+
shape?: "flat" | "card" | null | undefined;
|
|
9
|
+
showSeparator?: boolean | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
export declare const tileLeadingSlotVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
12
|
+
export declare const tileTrailingSlotVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
13
|
+
export declare const tileContentVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
14
|
+
export declare const tileTitleVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
15
|
+
export declare const tileDescriptionVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
16
|
+
export declare const tileIndicatorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
17
|
+
export type TileVariantProps = VariantProps<typeof tileRootVariants>;
|
|
18
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Tile/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,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C;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
@@ -1,22 +1,53 @@
|
|
|
1
|
+
/** @deprecated Use `bg-surface-primary` (--color-surface-primary) instead. */
|
|
1
2
|
export declare const COLOR_BG_PRIMARY = "bg-white";
|
|
3
|
+
/** @deprecated Use `bg-surface-secondary` (--color-surface-secondary) instead. */
|
|
2
4
|
export declare const COLOR_BG_SUBTLE = "bg-slate-50";
|
|
5
|
+
/** @deprecated Use `bg-surface-neutral-subtle` (--color-surface-neutral-subtle) instead. */
|
|
3
6
|
export declare const COLOR_BG_MUTED = "bg-slate-100";
|
|
7
|
+
/** @deprecated Use `bg-base-950` (--color-base-950) instead. */
|
|
4
8
|
export declare const COLOR_BG_INVERSE = "bg-slate-900";
|
|
9
|
+
/** @deprecated Use `border-stroke-secondary` (--color-stroke-secondary) instead. */
|
|
5
10
|
export declare const COLOR_BORDER_DEFAULT = "border-slate-200";
|
|
11
|
+
/** @deprecated Use `border-stroke-hover` (--color-stroke-hover) instead. */
|
|
6
12
|
export declare const COLOR_BORDER_STRONG = "border-slate-300";
|
|
13
|
+
/** @deprecated Use `border-stroke-focus` (--color-stroke-focus) instead. */
|
|
7
14
|
export declare const COLOR_BORDER_FOCUS = "border-slate-900";
|
|
15
|
+
/** @deprecated Use `border-stroke-danger` (--color-stroke-danger) instead. */
|
|
8
16
|
export declare const COLOR_BORDER_INVALID = "border-red-500";
|
|
17
|
+
/** @deprecated Use `text-content-primary` (--color-content-primary) instead. */
|
|
9
18
|
export declare const COLOR_TEXT_PRIMARY = "text-slate-900";
|
|
19
|
+
/** @deprecated Use `text-content-secondary` (--color-content-secondary) instead. */
|
|
10
20
|
export declare const COLOR_TEXT_SECONDARY = "text-slate-500";
|
|
21
|
+
/** @deprecated Use `text-content-tertiary` (--color-content-tertiary) instead. */
|
|
11
22
|
export declare const COLOR_TEXT_MUTED = "text-slate-400";
|
|
23
|
+
/** @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). */
|
|
12
24
|
export declare const COLOR_TEXT_INVERSE = "text-white";
|
|
25
|
+
/** @deprecated Use `text-content-tertiary` (--color-content-tertiary) instead. */
|
|
13
26
|
export declare const COLOR_TEXT_PLACEHOLDER = "text-slate-400";
|
|
27
|
+
/** @deprecated Use `text-content-danger` (--color-content-danger) instead. */
|
|
14
28
|
export declare const COLOR_TEXT_INVALID = "text-red-600";
|
|
29
|
+
/** @deprecated Use `bg-surface-action-strong` (--color-surface-action-strong) instead. */
|
|
15
30
|
export declare const COLOR_BRAND_DEFAULT = "bg-slate-900";
|
|
31
|
+
/** @deprecated Use `bg-surface-action-strong-hover` (--color-surface-action-strong-hover) instead. */
|
|
16
32
|
export declare const COLOR_BRAND_HOVER = "bg-slate-800";
|
|
33
|
+
/** @deprecated Use `bg-surface-action-strong-active` (--color-surface-action-strong-active) instead. */
|
|
17
34
|
export declare const COLOR_BRAND_ACTIVE = "bg-slate-700";
|
|
35
|
+
/** @deprecated Use `bg-surface-action-strong` (--color-surface-action-strong) instead. */
|
|
18
36
|
export declare const COLOR_ACCENT_DEFAULT = "bg-slate-900";
|
|
37
|
+
/** @deprecated Use `border-stroke-action` (--color-stroke-action) instead. */
|
|
19
38
|
export declare const COLOR_ACCENT_BORDER = "border-slate-900";
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use semantic token classes directly instead. Map each color key to its
|
|
41
|
+
* corresponding `--color-surface-*`, `--color-stroke-*`, and `--color-content-*` tokens:
|
|
42
|
+
* - `bg` → `bg-surface-{color}-strong` (--color-surface-{color}-strong)
|
|
43
|
+
* - `bgHover` → `bg-surface-{color}-strong-hover` (--color-surface-{color}-strong-hover)
|
|
44
|
+
* - `bgActive` → `bg-surface-{color}-strong-active` (--color-surface-{color}-strong-active)
|
|
45
|
+
* - `border` → `border-stroke-{color}` (--color-stroke-{color})
|
|
46
|
+
* - `text` → `text-content-{color}` (--color-content-{color})
|
|
47
|
+
* - `ring` → `ring-[--color-stroke-focus]` (--color-stroke-focus)
|
|
48
|
+
*
|
|
49
|
+
* See Button/styles.ts for a complete migration example.
|
|
50
|
+
*/
|
|
20
51
|
export declare const SEMANTIC_COLORS: {
|
|
21
52
|
readonly action: {
|
|
22
53
|
readonly bg: "bg-slate-900";
|
|
@@ -59,12 +90,16 @@ export declare const SEMANTIC_COLORS: {
|
|
|
59
90
|
readonly ring: "ring-sky-400/50";
|
|
60
91
|
};
|
|
61
92
|
};
|
|
93
|
+
/** @deprecated Use `ring-2 ring-[--color-stroke-focus] ring-offset-2` (--color-stroke-focus) instead. */
|
|
62
94
|
export declare const FOCUS_RING = "ring-2 ring-slate-400/50 ring-offset-2";
|
|
63
95
|
export declare const RADIUS_SM = "rounded-lg";
|
|
64
96
|
export declare const RADIUS_MD = "rounded-xl";
|
|
65
97
|
export declare const RADIUS_FULL = "rounded-full";
|
|
98
|
+
/** @deprecated Use `shadow-sm` directly instead */
|
|
66
99
|
export declare const SHADOW_SM = "shadow-sm";
|
|
100
|
+
/** @deprecated Use `shadow-md` directly instead */
|
|
67
101
|
export declare const SHADOW_MD = "shadow-md";
|
|
102
|
+
/** @deprecated */
|
|
68
103
|
export declare const SIZE_SCALE: {
|
|
69
104
|
readonly default: {
|
|
70
105
|
readonly height: "h-10";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../../src/styles/primitives.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAC7C,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAG/C,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AACrD,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAGrD,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AACjD,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAC/C,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAGjD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAChD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAGjD,eAAO,MAAM,oBAAo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H,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClB,CAAC;AAGX,yGAAyG;AACzG,eAAO,MAAM,UAAU,2CAA2C,CAAC;AAGnE,eAAO,MAAM,SAAS,eAAe,CAAC;AACtC,eAAO,MAAM,SAAS,eAAe,CAAC;AACtC,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAI1C,mDAAmD;AACnD,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,mDAAmD;AACnD,eAAO,MAAM,SAAS,cAAc,CAAC;AAMrC,kBAAkB;AAClB,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAGb,CAAC;AAGX,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAGlE,eAAO,MAAM,gBAAgB,oCAAoC,CAAC;AAClE,eAAO,MAAM,eAAe,qFACwD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.13",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@gorhom/bottom-sheet": "^5.2.6",
|
|
68
68
|
"class-variance-authority": "^0.7.1",
|
|
69
69
|
"uniwind": "1.6.1",
|
|
70
|
-
"@cdx-ui/
|
|
71
|
-
"@cdx-ui/
|
|
72
|
-
"@cdx-ui/
|
|
70
|
+
"@cdx-ui/utils": "0.0.1-beta.13",
|
|
71
|
+
"@cdx-ui/icons": "0.0.1-beta.13",
|
|
72
|
+
"@cdx-ui/primitives": "0.0.1-beta.13"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/react": "*",
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import {
|
|
4
|
-
COLOR_BG_PRIMARY,
|
|
5
|
-
COLOR_BORDER_STRONG,
|
|
6
4
|
COLOR_TEXT_PRIMARY,
|
|
7
5
|
DISABLED_CURSOR,
|
|
8
6
|
DISABLED_OPACITY,
|
|
@@ -29,14 +27,14 @@ export const checkboxIndicatorVariants = cva(
|
|
|
29
27
|
'items-center justify-center',
|
|
30
28
|
'rounded',
|
|
31
29
|
'border-2',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'data-[checked=true]:bg-
|
|
35
|
-
'data-[indeterminate=true]:bg-
|
|
30
|
+
'border-stroke-secondary',
|
|
31
|
+
'bg-surface-primary',
|
|
32
|
+
'data-[checked=true]:bg-surface-action-strong data-[checked=true]:border-stroke-action',
|
|
33
|
+
'data-[indeterminate=true]:bg-surface-action-strong data-[indeterminate=true]:border-stroke-action',
|
|
36
34
|
'data-[disabled=true]:opacity-50',
|
|
37
|
-
'data-[invalid=true]:border-
|
|
38
|
-
'data-[checked=true]:data-[invalid=true]:bg-
|
|
39
|
-
'data-[indeterminate=true]:data-[invalid=true]:bg-
|
|
35
|
+
'data-[invalid=true]:border-stroke-danger',
|
|
36
|
+
'data-[checked=true]:data-[invalid=true]:bg-surface-danger-strong data-[checked=true]:data-[invalid=true]:border-stroke-danger',
|
|
37
|
+
'data-[indeterminate=true]:data-[invalid=true]:bg-surface-danger-strong data-[indeterminate=true]:data-[invalid=true]:border-stroke-danger',
|
|
40
38
|
Platform.select({
|
|
41
39
|
web: [
|
|
42
40
|
TRANSITION_COLORS,
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import {
|
|
4
|
-
COLOR_BORDER_DEFAULT,
|
|
5
|
-
COLOR_TEXT_MUTED,
|
|
6
|
-
COLOR_TEXT_PRIMARY,
|
|
7
|
-
COLOR_TEXT_SECONDARY,
|
|
8
|
-
TRANSITION_COLORS,
|
|
9
|
-
} from '../../styles/primitives';
|
|
3
|
+
import { TRANSITION_COLORS } from '../../styles/primitives';
|
|
10
4
|
|
|
11
5
|
// ── Root (row): density, surface, separator, interactive feedback ──────────
|
|
12
6
|
|
|
@@ -19,7 +13,7 @@ export const listItemRootVariants = cva(
|
|
|
19
13
|
Platform.select({
|
|
20
14
|
web: [
|
|
21
15
|
'outline-none',
|
|
22
|
-
'web:data-[
|
|
16
|
+
'web:data-[hover=true]:bg-slate-50',
|
|
23
17
|
'web:focus-visible:data-[disabled=false]:bg-slate-50',
|
|
24
18
|
'web:focus-visible:data-[disabled=false]:ring-2 web:focus-visible:data-[disabled=false]:ring-slate-400/40 web:focus-visible:data-[disabled=false]:ring-offset-2',
|
|
25
19
|
].join(' '),
|
|
@@ -37,7 +31,7 @@ export const listItemRootVariants = cva(
|
|
|
37
31
|
negative: 'bg-red-50',
|
|
38
32
|
},
|
|
39
33
|
showSeparator: {
|
|
40
|
-
true:
|
|
34
|
+
true: 'border-b border-solid border-stroke-secondary',
|
|
41
35
|
false: 'border-b-0',
|
|
42
36
|
},
|
|
43
37
|
crossAlign: {
|
|
@@ -49,7 +43,7 @@ export const listItemRootVariants = cva(
|
|
|
49
43
|
{
|
|
50
44
|
surface: 'negative',
|
|
51
45
|
className: Platform.select({
|
|
52
|
-
web: 'web:data-[
|
|
46
|
+
web: 'web:data-[hover=true]:bg-red-100/90',
|
|
53
47
|
default: '',
|
|
54
48
|
}),
|
|
55
49
|
},
|
|
@@ -81,7 +75,7 @@ export const listItemTrailingSlotVariants = cva(['flex shrink-0 flex-row justify
|
|
|
81
75
|
|
|
82
76
|
// ── Content stack (title / description / meta) ───────────────────────────────
|
|
83
77
|
|
|
84
|
-
export const listItemContentVariants = cva(
|
|
78
|
+
export const listItemContentVariants = cva('flex min-w-0 flex-1 flex-col gap-1', {
|
|
85
79
|
variants: {
|
|
86
80
|
crossAlign: {
|
|
87
81
|
center: 'justify-center',
|
|
@@ -95,7 +89,7 @@ export const listItemContentVariants = cva(['flex min-w-0 flex-1 flex-col gap-1'
|
|
|
95
89
|
|
|
96
90
|
// ── Typography ───────────────────────────────────────────────────────────────
|
|
97
91
|
|
|
98
|
-
export const listItemTitleVariants = cva(
|
|
92
|
+
export const listItemTitleVariants = cva('text-content-primary font-medium', {
|
|
99
93
|
variants: {
|
|
100
94
|
size: {
|
|
101
95
|
default: 'text-base leading-snug',
|
|
@@ -107,7 +101,7 @@ export const listItemTitleVariants = cva([COLOR_TEXT_PRIMARY, 'font-medium'], {
|
|
|
107
101
|
},
|
|
108
102
|
});
|
|
109
103
|
|
|
110
|
-
export const listItemDescriptionVariants = cva(
|
|
104
|
+
export const listItemDescriptionVariants = cva('text-content-secondary', {
|
|
111
105
|
variants: {
|
|
112
106
|
size: {
|
|
113
107
|
default: 'text-sm leading-normal',
|
|
@@ -119,7 +113,7 @@ export const listItemDescriptionVariants = cva([COLOR_TEXT_SECONDARY], {
|
|
|
119
113
|
},
|
|
120
114
|
});
|
|
121
115
|
|
|
122
|
-
export const listItemMetaVariants = cva(
|
|
116
|
+
export const listItemMetaVariants = cva('text-content-tertiary', {
|
|
123
117
|
variants: {
|
|
124
118
|
size: {
|
|
125
119
|
default: 'text-xs leading-normal',
|
|
@@ -136,7 +130,7 @@ export const listItemMetaVariants = cva([COLOR_TEXT_MUTED], {
|
|
|
136
130
|
export const listItemSectionHeaderVariants = cva(
|
|
137
131
|
[
|
|
138
132
|
'flex-row items-center justify-between gap-2 border-b border-solid px-4 py-3',
|
|
139
|
-
|
|
133
|
+
'border-stroke-secondary',
|
|
140
134
|
],
|
|
141
135
|
{
|
|
142
136
|
variants: {
|
|
@@ -152,9 +146,8 @@ export const listItemSectionHeaderVariants = cva(
|
|
|
152
146
|
);
|
|
153
147
|
|
|
154
148
|
/** Default section-title typography; applied by `ListItem.SectionHeader` for string/number children. Exported for rare custom composition. */
|
|
155
|
-
export const listItemSectionHeaderLabelVariants = cva(
|
|
156
|
-
'text-xs font-semibold uppercase tracking-wide',
|
|
157
|
-
|
|
158
|
-
]);
|
|
149
|
+
export const listItemSectionHeaderLabelVariants = cva(
|
|
150
|
+
'text-xs font-semibold uppercase tracking-wide text-content-secondary',
|
|
151
|
+
);
|
|
159
152
|
|
|
160
153
|
export type ListItemVariantProps = VariantProps<typeof listItemRootVariants>;
|
|
@@ -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 };
|