@cdx-ui/primitives 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.
Files changed (91) hide show
  1. package/lib/commonjs/index.js +12 -0
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/list-item/createListItemRoot.js +36 -21
  4. package/lib/commonjs/list-item/createListItemRoot.js.map +1 -1
  5. package/lib/commonjs/tile/context.js +30 -0
  6. package/lib/commonjs/tile/context.js.map +1 -0
  7. package/lib/commonjs/tile/createTileContent.js +30 -0
  8. package/lib/commonjs/tile/createTileContent.js.map +1 -0
  9. package/lib/commonjs/tile/createTileDescription.js +28 -0
  10. package/lib/commonjs/tile/createTileDescription.js.map +1 -0
  11. package/lib/commonjs/tile/createTileGroup.js +112 -0
  12. package/lib/commonjs/tile/createTileGroup.js.map +1 -0
  13. package/lib/commonjs/tile/createTileIndicator.js +46 -0
  14. package/lib/commonjs/tile/createTileIndicator.js.map +1 -0
  15. package/lib/commonjs/tile/createTileLeadingSlot.js +34 -0
  16. package/lib/commonjs/tile/createTileLeadingSlot.js.map +1 -0
  17. package/lib/commonjs/tile/createTileRoot.js +133 -0
  18. package/lib/commonjs/tile/createTileRoot.js.map +1 -0
  19. package/lib/commonjs/tile/createTileTitle.js +28 -0
  20. package/lib/commonjs/tile/createTileTitle.js.map +1 -0
  21. package/lib/commonjs/tile/createTileTrailingSlot.js +35 -0
  22. package/lib/commonjs/tile/createTileTrailingSlot.js.map +1 -0
  23. package/lib/commonjs/tile/index.js +55 -0
  24. package/lib/commonjs/tile/index.js.map +1 -0
  25. package/lib/commonjs/tile/types.js +6 -0
  26. package/lib/commonjs/tile/types.js.map +1 -0
  27. package/lib/module/index.js +1 -0
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/list-item/createListItemRoot.js +36 -21
  30. package/lib/module/list-item/createListItemRoot.js.map +1 -1
  31. package/lib/module/tile/context.js +21 -0
  32. package/lib/module/tile/context.js.map +1 -0
  33. package/lib/module/tile/createTileContent.js +24 -0
  34. package/lib/module/tile/createTileContent.js.map +1 -0
  35. package/lib/module/tile/createTileDescription.js +22 -0
  36. package/lib/module/tile/createTileDescription.js.map +1 -0
  37. package/lib/module/tile/createTileGroup.js +106 -0
  38. package/lib/module/tile/createTileGroup.js.map +1 -0
  39. package/lib/module/tile/createTileIndicator.js +40 -0
  40. package/lib/module/tile/createTileIndicator.js.map +1 -0
  41. package/lib/module/tile/createTileLeadingSlot.js +28 -0
  42. package/lib/module/tile/createTileLeadingSlot.js.map +1 -0
  43. package/lib/module/tile/createTileRoot.js +127 -0
  44. package/lib/module/tile/createTileRoot.js.map +1 -0
  45. package/lib/module/tile/createTileTitle.js +22 -0
  46. package/lib/module/tile/createTileTitle.js.map +1 -0
  47. package/lib/module/tile/createTileTrailingSlot.js +29 -0
  48. package/lib/module/tile/createTileTrailingSlot.js.map +1 -0
  49. package/lib/module/tile/index.js +39 -0
  50. package/lib/module/tile/index.js.map +1 -0
  51. package/lib/module/tile/types.js +4 -0
  52. package/lib/module/tile/types.js.map +1 -0
  53. package/lib/typescript/index.d.ts +1 -0
  54. package/lib/typescript/index.d.ts.map +1 -1
  55. package/lib/typescript/list-item/createListItemRoot.d.ts.map +1 -1
  56. package/lib/typescript/tile/context.d.ts +9 -0
  57. package/lib/typescript/tile/context.d.ts.map +1 -0
  58. package/lib/typescript/tile/createTileContent.d.ts +3 -0
  59. package/lib/typescript/tile/createTileContent.d.ts.map +1 -0
  60. package/lib/typescript/tile/createTileDescription.d.ts +3 -0
  61. package/lib/typescript/tile/createTileDescription.d.ts.map +1 -0
  62. package/lib/typescript/tile/createTileGroup.d.ts +4 -0
  63. package/lib/typescript/tile/createTileGroup.d.ts.map +1 -0
  64. package/lib/typescript/tile/createTileIndicator.d.ts +4 -0
  65. package/lib/typescript/tile/createTileIndicator.d.ts.map +1 -0
  66. package/lib/typescript/tile/createTileLeadingSlot.d.ts +4 -0
  67. package/lib/typescript/tile/createTileLeadingSlot.d.ts.map +1 -0
  68. package/lib/typescript/tile/createTileRoot.d.ts +4 -0
  69. package/lib/typescript/tile/createTileRoot.d.ts.map +1 -0
  70. package/lib/typescript/tile/createTileTitle.d.ts +3 -0
  71. package/lib/typescript/tile/createTileTitle.d.ts.map +1 -0
  72. package/lib/typescript/tile/createTileTrailingSlot.d.ts +9 -0
  73. package/lib/typescript/tile/createTileTrailingSlot.d.ts.map +1 -0
  74. package/lib/typescript/tile/index.d.ts +15 -0
  75. package/lib/typescript/tile/index.d.ts.map +1 -0
  76. package/lib/typescript/tile/types.d.ts +119 -0
  77. package/lib/typescript/tile/types.d.ts.map +1 -0
  78. package/package.json +2 -2
  79. package/src/index.ts +1 -0
  80. package/src/list-item/createListItemRoot.tsx +37 -22
  81. package/src/tile/context.tsx +23 -0
  82. package/src/tile/createTileContent.tsx +23 -0
  83. package/src/tile/createTileDescription.tsx +19 -0
  84. package/src/tile/createTileGroup.tsx +134 -0
  85. package/src/tile/createTileIndicator.tsx +38 -0
  86. package/src/tile/createTileLeadingSlot.tsx +30 -0
  87. package/src/tile/createTileRoot.tsx +124 -0
  88. package/src/tile/createTileTitle.tsx +19 -0
  89. package/src/tile/createTileTrailingSlot.tsx +25 -0
  90. package/src/tile/index.ts +88 -0
  91. package/src/tile/types.ts +153 -0
@@ -0,0 +1,153 @@
1
+ import type { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
2
+ import type { PressableProps, TextProps, ViewProps } from 'react-native';
3
+ import type { WithStyleContextProps } from '@cdx-ui/utils';
4
+
5
+ export type TileGroupType = 'single' | 'multiple';
6
+
7
+ export type TileGroupValue = string | string[] | undefined;
8
+
9
+ interface ITileGroupBaseProps extends ViewProps, WithStyleContextProps {
10
+ /** Disables the whole group. */
11
+ isDisabled?: boolean;
12
+ /** Accessible name for the group (radiogroup / group). */
13
+ 'aria-label'?: string;
14
+ }
15
+
16
+ export interface ITileGroupSingleProps extends ITileGroupBaseProps {
17
+ /** Single-select (radio semantics). One value at a time. */
18
+ type: 'single';
19
+ /** Controlled selected value. */
20
+ value?: string;
21
+ /** Uncontrolled initial value. */
22
+ defaultValue?: string;
23
+ /** Called when selection changes. */
24
+ onValueChange?: (value: string) => void;
25
+ }
26
+
27
+ export interface ITileGroupMultipleProps extends ITileGroupBaseProps {
28
+ /** Multi-select (checkbox semantics). Zero to `max` values at a time. */
29
+ type: 'multiple';
30
+ /** Controlled selected values. */
31
+ value?: string[];
32
+ /** Uncontrolled initial values. */
33
+ defaultValue?: string[];
34
+ /** Called when selection changes. */
35
+ onValueChange?: (value: string[]) => void;
36
+ /** Maximum selections allowed. @default Infinity */
37
+ max?: number;
38
+ }
39
+
40
+ /**
41
+ * Discriminated union: `type` narrows `value` / `defaultValue` / `onValueChange`,
42
+ * and `max` is only valid on `type="multiple"`.
43
+ */
44
+ export type ITileGroupProps = ITileGroupSingleProps | ITileGroupMultipleProps;
45
+
46
+ export interface ITileGroupContextValue {
47
+ type: TileGroupType;
48
+ /** Current selection (string for single, array for multiple). */
49
+ value: string | string[] | undefined;
50
+ toggleValue: (tileValue: string) => void;
51
+ isSelected: (tileValue: string) => boolean;
52
+ /** Group-level disabled or multi-select at max (unselected tiles). */
53
+ isTileDisabledByGroup: (tileValue: string) => boolean;
54
+ isGroupDisabled: boolean;
55
+ max: number;
56
+ }
57
+
58
+ export interface ITileContextValue {
59
+ /** This tile's `value`. */
60
+ value: string;
61
+ isSelected: boolean;
62
+ /** Effective disabled (group rules + tile `disabled`). */
63
+ isDisabled: boolean;
64
+ selectionType: TileGroupType;
65
+ }
66
+
67
+ export type ITilePressablePassthrough = Partial<
68
+ Pick<PressableProps, 'onPressIn' | 'onPressOut' | 'onHoverIn' | 'onHoverOut'>
69
+ >;
70
+
71
+ export interface ITileProps
72
+ extends PressableProps, ITilePressablePassthrough, WithStyleContextProps {
73
+ /**
74
+ * Identifies this tile within `Tile.Group`. Must be unique within the group.
75
+ * Standalone tiles still require a value (useful for form submission, analytics, etc.).
76
+ */
77
+ value: string;
78
+ /**
79
+ * Disables this tile (in addition to group rules such as multi-select max).
80
+ */
81
+ disabled?: boolean;
82
+ /**
83
+ * Controlled selected state for **standalone** usage (no parent `Tile.Group`).
84
+ * Ignored when the tile is rendered inside a `Tile.Group` — selection is owned by the group.
85
+ */
86
+ isSelected?: boolean;
87
+ /**
88
+ * Initial selected state for **standalone**, uncontrolled usage.
89
+ */
90
+ defaultSelected?: boolean;
91
+ /**
92
+ * Called when standalone selection state changes. Group context overrides this — when inside
93
+ * a `Tile.Group`, use the group's `onValueChange` instead.
94
+ */
95
+ onSelectedChange?: (isSelected: boolean) => void;
96
+ }
97
+
98
+ export interface ITileLeadingSlotProps extends ViewProps {
99
+ /**
100
+ * Leading content is decorative by default for screen readers.
101
+ * @default true
102
+ */
103
+ 'aria-hidden'?: boolean;
104
+ }
105
+
106
+ export type ITileContentProps = ViewProps;
107
+ export type ITileTitleProps = TextProps;
108
+ export type ITileDescriptionProps = TextProps;
109
+ export interface ITileIndicatorProps extends ViewProps {
110
+ /**
111
+ * Explicit indicator visual. When inside a `Tile.Group`, auto-infers from `type`
112
+ * (`single` → radio, `multiple` → checkbox). For standalone tiles, defaults to `'checkbox'`
113
+ * to match the standalone `checkbox` ARIA role; override with `indicatorType="radio"` if
114
+ * a radio-style visual is needed.
115
+ */
116
+ indicatorType?: 'radio' | 'checkbox';
117
+ children?: ReactNode;
118
+ }
119
+
120
+ /**
121
+ * Generic trailing content slot. Use for chevrons, amounts, chips, status text — anything that
122
+ * is **not** the radio/checkbox selection affordance. For that, use `Tile.Indicator`.
123
+ */
124
+ export type ITileTrailingSlotProps = ViewProps;
125
+
126
+ export type ITileComponentType<
127
+ RootRef,
128
+ LeadingSlot,
129
+ Content,
130
+ Title,
131
+ Description,
132
+ Indicator,
133
+ TrailingSlot,
134
+ Group,
135
+ > = ForwardRefExoticComponent<RefAttributes<RootRef> & ITileProps> & {
136
+ Group: ForwardRefExoticComponent<RefAttributes<Group> & PropsWithoutRef<Group> & ITileGroupProps>;
137
+ LeadingSlot: ForwardRefExoticComponent<
138
+ RefAttributes<LeadingSlot> & PropsWithoutRef<LeadingSlot> & ITileLeadingSlotProps
139
+ >;
140
+ Content: ForwardRefExoticComponent<
141
+ RefAttributes<Content> & PropsWithoutRef<Content> & ITileContentProps
142
+ >;
143
+ Title: ForwardRefExoticComponent<RefAttributes<Title> & PropsWithoutRef<Title> & ITileTitleProps>;
144
+ Description: ForwardRefExoticComponent<
145
+ RefAttributes<Description> & PropsWithoutRef<Description> & ITileDescriptionProps
146
+ >;
147
+ Indicator: ForwardRefExoticComponent<
148
+ RefAttributes<Indicator> & PropsWithoutRef<Indicator> & ITileIndicatorProps
149
+ >;
150
+ TrailingSlot: ForwardRefExoticComponent<
151
+ RefAttributes<TrailingSlot> & PropsWithoutRef<TrailingSlot> & ITileTrailingSlotProps
152
+ >;
153
+ };