@boostdev/design-system-components 1.2.3 → 1.2.4

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 (191) hide show
  1. package/README.md +29 -1
  2. package/dist/client.cjs +50 -50
  3. package/dist/client.css +470 -470
  4. package/dist/client.js +50 -50
  5. package/dist/index.cjs +50 -50
  6. package/dist/index.css +470 -470
  7. package/dist/index.js +50 -50
  8. package/dist/native/index.cjs +3692 -352
  9. package/dist/native/index.d.cts +359 -3
  10. package/dist/native/index.d.ts +359 -3
  11. package/dist/native/index.js +3811 -364
  12. package/package.json +1 -1
  13. package/src/components/interaction/Button/Button.native.stories.tsx +10 -12
  14. package/src/components/interaction/Button/Button.native.tsx +3 -3
  15. package/src/components/interaction/Dialog/Dialog.native.mdx +61 -0
  16. package/src/components/interaction/Dialog/Dialog.native.spec.tsx +73 -0
  17. package/src/components/interaction/Dialog/Dialog.native.stories.tsx +53 -0
  18. package/src/components/interaction/Dialog/Dialog.native.tsx +128 -0
  19. package/src/components/interaction/Drawer/Drawer.native.mdx +58 -0
  20. package/src/components/interaction/Drawer/Drawer.native.spec.tsx +81 -0
  21. package/src/components/interaction/Drawer/Drawer.native.stories.tsx +33 -0
  22. package/src/components/interaction/Drawer/Drawer.native.tsx +175 -0
  23. package/src/components/interaction/DropdownMenu/DropdownMenu.native.mdx +74 -0
  24. package/src/components/interaction/DropdownMenu/DropdownMenu.native.spec.tsx +78 -0
  25. package/src/components/interaction/DropdownMenu/DropdownMenu.native.stories.tsx +51 -0
  26. package/src/components/interaction/DropdownMenu/DropdownMenu.native.tsx +254 -0
  27. package/src/components/interaction/Popover/Popover.native.mdx +61 -0
  28. package/src/components/interaction/Popover/Popover.native.spec.tsx +73 -0
  29. package/src/components/interaction/Popover/Popover.native.stories.tsx +44 -0
  30. package/src/components/interaction/Popover/Popover.native.tsx +87 -0
  31. package/src/components/interaction/Rating/Rating.native.mdx +55 -0
  32. package/src/components/interaction/Rating/Rating.native.spec.tsx +38 -0
  33. package/src/components/interaction/Rating/Rating.native.stories.tsx +37 -0
  34. package/src/components/interaction/Rating/Rating.native.tsx +50 -0
  35. package/src/components/interaction/Toast/Toast.native.mdx +81 -0
  36. package/src/components/interaction/Toast/Toast.native.spec.tsx +80 -0
  37. package/src/components/interaction/Toast/Toast.native.stories.tsx +47 -0
  38. package/src/components/interaction/Toast/Toast.native.tsx +202 -0
  39. package/src/components/interaction/form/Checkbox/Checkbox.native.stories.tsx +2 -4
  40. package/src/components/interaction/form/Checkbox/Checkbox.native.tsx +1 -1
  41. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.mdx +78 -0
  42. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.spec.tsx +57 -0
  43. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.stories.tsx +96 -0
  44. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.tsx +61 -0
  45. package/src/components/interaction/form/Combobox/Combobox.native.mdx +86 -0
  46. package/src/components/interaction/form/Combobox/Combobox.native.spec.tsx +60 -0
  47. package/src/components/interaction/form/Combobox/Combobox.native.stories.tsx +99 -0
  48. package/src/components/interaction/form/Combobox/Combobox.native.tsx +211 -0
  49. package/src/components/interaction/form/FileInput/FileInput.native.mdx +86 -0
  50. package/src/components/interaction/form/FileInput/FileInput.native.spec.tsx +73 -0
  51. package/src/components/interaction/form/FileInput/FileInput.native.stories.tsx +69 -0
  52. package/src/components/interaction/form/FileInput/FileInput.native.tsx +129 -0
  53. package/src/components/interaction/form/FormInput/FormInput.native.mdx +81 -0
  54. package/src/components/interaction/form/FormInput/FormInput.native.spec.tsx +51 -0
  55. package/src/components/interaction/form/FormInput/FormInput.native.stories.tsx +54 -0
  56. package/src/components/interaction/form/FormInput/FormInput.native.tsx +122 -0
  57. package/src/components/interaction/form/NumberInput/NumberInput.native.mdx +87 -0
  58. package/src/components/interaction/form/NumberInput/NumberInput.native.spec.tsx +63 -0
  59. package/src/components/interaction/form/NumberInput/NumberInput.native.stories.tsx +63 -0
  60. package/src/components/interaction/form/NumberInput/NumberInput.native.tsx +198 -0
  61. package/src/components/interaction/form/Radio/Radio.native.spec.tsx +79 -0
  62. package/src/components/interaction/form/Radio/Radio.native.stories.tsx +12 -14
  63. package/src/components/interaction/form/Radio/Radio.native.tsx +1 -1
  64. package/src/components/interaction/form/RadioGroup/RadioGroup.native.mdx +79 -0
  65. package/src/components/interaction/form/RadioGroup/RadioGroup.native.spec.tsx +66 -0
  66. package/src/components/interaction/form/RadioGroup/RadioGroup.native.stories.tsx +96 -0
  67. package/src/components/interaction/form/RadioGroup/RadioGroup.native.tsx +61 -0
  68. package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.mdx +78 -0
  69. package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.spec.tsx +82 -0
  70. package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.stories.tsx +99 -0
  71. package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.tsx +121 -0
  72. package/src/components/interaction/form/Select/Select.native.mdx +85 -0
  73. package/src/components/interaction/form/Select/Select.native.spec.tsx +64 -0
  74. package/src/components/interaction/form/Select/Select.native.stories.tsx +75 -0
  75. package/src/components/interaction/form/Select/Select.native.tsx +252 -0
  76. package/src/components/interaction/form/Slider/Slider.native.mdx +83 -0
  77. package/src/components/interaction/form/Slider/Slider.native.spec.tsx +51 -0
  78. package/src/components/interaction/form/Slider/Slider.native.stories.tsx +58 -0
  79. package/src/components/interaction/form/Slider/Slider.native.tsx +188 -0
  80. package/src/components/interaction/form/Switch/Switch.native.stories.tsx +2 -4
  81. package/src/components/interaction/form/Textarea/Textarea.native.mdx +76 -0
  82. package/src/components/interaction/form/Textarea/Textarea.native.spec.tsx +50 -0
  83. package/src/components/interaction/form/Textarea/Textarea.native.stories.tsx +50 -0
  84. package/src/components/interaction/form/Textarea/Textarea.native.tsx +108 -0
  85. package/src/components/interaction/form/atoms/Label.native.spec.tsx +39 -0
  86. package/src/components/interaction/form/atoms/Label.native.stories.tsx +1 -1
  87. package/src/components/interaction/form/atoms/Message.native.stories.tsx +1 -1
  88. package/src/components/layout/ButtonGroup/ButtonGroup.native.spec.tsx +83 -0
  89. package/src/components/layout/ButtonGroup/ButtonGroup.native.stories.tsx +13 -19
  90. package/src/components/layout/Card/Card.native.spec.tsx +102 -0
  91. package/src/components/layout/Card/Card.native.stories.tsx +9 -11
  92. package/src/components/layout/Card/Card.native.tsx +1 -1
  93. package/src/components/layout/IconWrapper/IconWrapper.native.stories.tsx +7 -11
  94. package/src/components/layout/SectionHeader/SectionHeader.native.spec.tsx +51 -0
  95. package/src/components/layout/SectionHeader/SectionHeader.native.stories.tsx +6 -8
  96. package/src/components/ui/Accordion/Accordion.native.mdx +65 -0
  97. package/src/components/ui/Accordion/Accordion.native.spec.tsx +69 -0
  98. package/src/components/ui/Accordion/Accordion.native.stories.tsx +52 -0
  99. package/src/components/ui/Accordion/Accordion.native.tsx +141 -0
  100. package/src/components/ui/Alert/Alert.native.spec.tsx +76 -0
  101. package/src/components/ui/Alert/Alert.native.stories.tsx +8 -10
  102. package/src/components/ui/Alert/Alert.native.tsx +7 -7
  103. package/src/components/ui/Avatar/Avatar.native.stories.tsx +6 -8
  104. package/src/components/ui/Avatar/Avatar.native.tsx +2 -2
  105. package/src/components/ui/Badge/Badge.native.spec.tsx +45 -0
  106. package/src/components/ui/Badge/Badge.native.stories.tsx +6 -8
  107. package/src/components/ui/Badge/Badge.native.tsx +2 -2
  108. package/src/components/ui/Breadcrumb/Breadcrumb.native.mdx +52 -0
  109. package/src/components/ui/Breadcrumb/Breadcrumb.native.spec.tsx +49 -0
  110. package/src/components/ui/Breadcrumb/Breadcrumb.native.stories.tsx +46 -0
  111. package/src/components/ui/Breadcrumb/Breadcrumb.native.tsx +83 -0
  112. package/src/components/ui/Calendar/Calendar.native.mdx +58 -0
  113. package/src/components/ui/Calendar/Calendar.native.spec.tsx +92 -0
  114. package/src/components/ui/Calendar/Calendar.native.stories.tsx +45 -0
  115. package/src/components/ui/Calendar/Calendar.native.tsx +294 -0
  116. package/src/components/ui/Carousel/Carousel.native.mdx +55 -0
  117. package/src/components/ui/Carousel/Carousel.native.spec.tsx +55 -0
  118. package/src/components/ui/Carousel/Carousel.native.stories.tsx +59 -0
  119. package/src/components/ui/Carousel/Carousel.native.tsx +184 -0
  120. package/src/components/ui/Collapsible/Collapsible.native.mdx +53 -0
  121. package/src/components/ui/Collapsible/Collapsible.native.spec.tsx +68 -0
  122. package/src/components/ui/Collapsible/Collapsible.native.stories.tsx +48 -0
  123. package/src/components/ui/Collapsible/Collapsible.native.tsx +139 -0
  124. package/src/components/ui/DescriptionList/DescriptionList.native.mdx +50 -0
  125. package/src/components/ui/DescriptionList/DescriptionList.native.spec.tsx +37 -0
  126. package/src/components/ui/DescriptionList/DescriptionList.native.stories.tsx +48 -0
  127. package/src/components/ui/DescriptionList/DescriptionList.native.tsx +54 -0
  128. package/src/components/ui/Link/Link.native.mdx +53 -0
  129. package/src/components/ui/Link/Link.native.spec.tsx +35 -0
  130. package/src/components/ui/Link/Link.native.stories.tsx +46 -0
  131. package/src/components/ui/Link/Link.native.tsx +48 -0
  132. package/src/components/ui/Loading/Loading.native.stories.tsx +6 -8
  133. package/src/components/ui/NotificationBanner/NotificationBanner.native.spec.tsx +85 -0
  134. package/src/components/ui/NotificationBanner/NotificationBanner.native.stories.tsx +8 -10
  135. package/src/components/ui/NotificationBanner/NotificationBanner.native.tsx +7 -7
  136. package/src/components/ui/Pagination/Pagination.native.mdx +62 -0
  137. package/src/components/ui/Pagination/Pagination.native.spec.tsx +86 -0
  138. package/src/components/ui/Pagination/Pagination.native.stories.tsx +47 -0
  139. package/src/components/ui/Pagination/Pagination.native.tsx +157 -0
  140. package/src/components/ui/Progress/Progress.native.spec.tsx +56 -0
  141. package/src/components/ui/Progress/Progress.native.stories.tsx +1 -1
  142. package/src/components/ui/Progress/Progress.native.tsx +2 -2
  143. package/src/components/ui/ProgressCircle/ProgressCircle.native.mdx +63 -0
  144. package/src/components/ui/ProgressCircle/ProgressCircle.native.spec.tsx +39 -0
  145. package/src/components/ui/ProgressCircle/ProgressCircle.native.stories.tsx +36 -0
  146. package/src/components/ui/ProgressCircle/ProgressCircle.native.tsx +176 -0
  147. package/src/components/ui/Separator/Separator.native.spec.tsx +39 -0
  148. package/src/components/ui/Separator/Separator.native.stories.tsx +10 -14
  149. package/src/components/ui/Skeleton/Skeleton.native.spec.tsx +39 -0
  150. package/src/components/ui/Skeleton/Skeleton.native.stories.tsx +6 -8
  151. package/src/components/ui/Skeleton/Skeleton.native.tsx +2 -1
  152. package/src/components/ui/Table/Table.native.mdx +72 -0
  153. package/src/components/ui/Table/Table.native.spec.tsx +83 -0
  154. package/src/components/ui/Table/Table.native.stories.tsx +55 -0
  155. package/src/components/ui/Table/Table.native.tsx +196 -0
  156. package/src/components/ui/Tabs/Tabs.native.mdx +65 -0
  157. package/src/components/ui/Tabs/Tabs.native.spec.tsx +65 -0
  158. package/src/components/ui/Tabs/Tabs.native.stories.tsx +57 -0
  159. package/src/components/ui/Tabs/Tabs.native.tsx +133 -0
  160. package/src/components/ui/Tooltip/Tooltip.native.mdx +47 -0
  161. package/src/components/ui/Tooltip/Tooltip.native.spec.tsx +37 -0
  162. package/src/components/ui/Tooltip/Tooltip.native.stories.tsx +38 -0
  163. package/src/components/ui/Tooltip/Tooltip.native.tsx +57 -0
  164. package/src/components/ui/Typography/Typography.native.spec.tsx +49 -0
  165. package/src/components/ui/Typography/Typography.native.stories.tsx +8 -10
  166. package/src/native/ThemeContext.tsx +3 -3
  167. package/src/native.ts +37 -0
  168. package/src/stories/ReactNative.mdx +48 -13
  169. package/src/web-components/interaction/BdsAccordion.stories.tsx +1 -1
  170. package/src/web-components/interaction/BdsCollapsible.stories.tsx +1 -1
  171. package/src/web-components/interaction/BdsSkipLink.stories.tsx +1 -1
  172. package/src/web-components/interaction/BdsTabs.stories.tsx +1 -1
  173. package/src/web-components/interaction/BdsTooltip.stories.tsx +1 -1
  174. package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +1 -1
  175. package/src/web-components/interaction/form/BdsCheckboxGroup.stories.tsx +1 -1
  176. package/src/web-components/interaction/form/BdsCombobox.stories.tsx +1 -1
  177. package/src/web-components/interaction/form/BdsFileInput.stories.tsx +1 -1
  178. package/src/web-components/interaction/form/BdsFormInput.stories.tsx +1 -1
  179. package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +1 -1
  180. package/src/web-components/interaction/form/BdsRadio.stories.tsx +1 -1
  181. package/src/web-components/interaction/form/BdsRadioGroup.stories.tsx +1 -1
  182. package/src/web-components/interaction/form/BdsSegmentedControl.stories.tsx +1 -1
  183. package/src/web-components/interaction/form/BdsSelect.stories.tsx +1 -1
  184. package/src/web-components/interaction/form/BdsSlider.stories.tsx +1 -1
  185. package/src/web-components/interaction/form/BdsSwitch.stories.tsx +1 -1
  186. package/src/web-components/interaction/form/BdsTextarea.stories.tsx +1 -1
  187. package/src/web-components/ui/BdsButtonGroup.stories.tsx +1 -1
  188. package/src/web-components/ui/BdsCard.stories.tsx +1 -1
  189. package/src/web-components/ui/BdsIconWrapper.stories.tsx +1 -1
  190. package/src/web-components/ui/BdsRating.stories.tsx +1 -1
  191. package/src/web-components/ui/BdsSectionHeader.stories.tsx +1 -1
@@ -0,0 +1,202 @@
1
+ import {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useCallback,
6
+ useMemo,
7
+ createContext,
8
+ useContext,
9
+ ReactNode,
10
+ } from 'react';
11
+ import {
12
+ View,
13
+ Text,
14
+ Pressable,
15
+ Animated,
16
+ StyleSheet,
17
+ StyleProp,
18
+ ViewStyle,
19
+ } from 'react-native';
20
+ import { spacing, font, border } from '../../../native/tokens';
21
+ import { useTheme } from '../../../native/ThemeContext';
22
+
23
+ type ToastVariant = 'success' | 'error' | 'info';
24
+
25
+ interface Toast {
26
+ id: string;
27
+ message: string;
28
+ variant: ToastVariant;
29
+ }
30
+
31
+ interface ToastContextType {
32
+ showToast: (message: string, variant: ToastVariant) => void;
33
+ }
34
+
35
+ const ToastContext = createContext<ToastContextType | undefined>(undefined);
36
+
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ position: 'absolute',
40
+ top: 0,
41
+ start: 0,
42
+ end: 0,
43
+ paddingTop: spacing.xxxl,
44
+ paddingHorizontal: spacing.m,
45
+ zIndex: 9999,
46
+ pointerEvents: 'box-none',
47
+ },
48
+ toast: {
49
+ flexDirection: 'row',
50
+ alignItems: 'center',
51
+ justifyContent: 'space-between',
52
+ paddingVertical: spacing.s,
53
+ paddingHorizontal: spacing.m,
54
+ borderRadius: border.radius.s,
55
+ marginBottom: spacing.xs,
56
+ minHeight: 48,
57
+ },
58
+ message: {
59
+ fontFamily: font.family.body,
60
+ fontSize: font.size.body,
61
+ fontWeight: font.weight.semibold,
62
+ flex: 1,
63
+ },
64
+ closeButton: {
65
+ width: 44,
66
+ height: 44,
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
69
+ marginStart: spacing.xs,
70
+ },
71
+ closeText: {
72
+ fontFamily: font.family.body,
73
+ fontSize: 16,
74
+ lineHeight: 20,
75
+ },
76
+ });
77
+
78
+ function ToastItem({
79
+ toast,
80
+ onRemove,
81
+ }: {
82
+ toast: Toast;
83
+ onRemove: () => void;
84
+ }) {
85
+ const { colors } = useTheme();
86
+ const slideAnim = useRef(new Animated.Value(-100)).current;
87
+ const opacityAnim = useRef(new Animated.Value(0)).current;
88
+
89
+ const variantColors: Record<
90
+ ToastVariant,
91
+ { bg: string; text: string }
92
+ > = useMemo(
93
+ () => ({
94
+ success: { bg: colors.colorSuccess, text: colors.colorOnSuccess },
95
+ error: { bg: colors.colorError, text: colors.colorOnError },
96
+ info: { bg: colors.colorBgSubtle, text: colors.colorOnBgSubtle },
97
+ }),
98
+ [colors],
99
+ );
100
+
101
+ useEffect(() => {
102
+ Animated.parallel([
103
+ Animated.timing(slideAnim, {
104
+ toValue: 0,
105
+ duration: 200,
106
+ useNativeDriver: true,
107
+ }),
108
+ Animated.timing(opacityAnim, {
109
+ toValue: 1,
110
+ duration: 200,
111
+ useNativeDriver: true,
112
+ }),
113
+ ]).start();
114
+ }, [slideAnim, opacityAnim]);
115
+
116
+ useEffect(() => {
117
+ const timer = setTimeout(onRemove, 5000);
118
+ return () => clearTimeout(timer);
119
+ }, [onRemove]);
120
+
121
+ const { bg, text } = variantColors[toast.variant];
122
+
123
+ return (
124
+ <Animated.View
125
+ style={[
126
+ styles.toast,
127
+ {
128
+ backgroundColor: bg,
129
+ transform: [{ translateY: slideAnim }],
130
+ opacity: opacityAnim,
131
+ },
132
+ ]}
133
+ accessibilityRole="alert"
134
+ accessibilityLiveRegion="polite"
135
+ >
136
+ <Text style={[styles.message, { color: text }]}>{toast.message}</Text>
137
+ <Pressable
138
+ style={styles.closeButton}
139
+ onPress={onRemove}
140
+ accessibilityRole="button"
141
+ accessibilityLabel="Dismiss"
142
+ hitSlop={8}
143
+ >
144
+ <Text style={[styles.closeText, { color: text }]} aria-hidden>
145
+ {'\u2715'}
146
+ </Text>
147
+ </Pressable>
148
+ </Animated.View>
149
+ );
150
+ }
151
+
152
+ export function ToastProvider({
153
+ children,
154
+ style,
155
+ }: {
156
+ children: ReactNode;
157
+ style?: StyleProp<ViewStyle>;
158
+ }) {
159
+ const [toasts, setToasts] = useState<Toast[]>([]);
160
+
161
+ const showToast = useCallback((message: string, variant: ToastVariant) => {
162
+ const id = Math.random().toString(36).substring(2, 9);
163
+ setToasts((prev) => [...prev, { id, message, variant }]);
164
+ }, []);
165
+
166
+ const removeToast = useCallback((id: string) => {
167
+ setToasts((prev) => prev.filter((t) => t.id !== id));
168
+ }, []);
169
+
170
+ const value = useMemo(() => ({ showToast }), [showToast]);
171
+
172
+ return (
173
+ <ToastContext.Provider value={value}>
174
+ <View style={[{ flex: 1 }, style]}>
175
+ {children}
176
+ {toasts.length > 0 && (
177
+ <View
178
+ style={styles.container}
179
+ accessibilityRole="summary"
180
+ accessibilityLabel="Notifications"
181
+ >
182
+ {toasts.map((toast) => (
183
+ <ToastItem
184
+ key={toast.id}
185
+ toast={toast}
186
+ onRemove={() => removeToast(toast.id)}
187
+ />
188
+ ))}
189
+ </View>
190
+ )}
191
+ </View>
192
+ </ToastContext.Provider>
193
+ );
194
+ }
195
+
196
+ export function useToast(): ToastContextType {
197
+ const context = useContext(ToastContext);
198
+ if (!context) {
199
+ throw new Error('useToast must be used within a ToastProvider');
200
+ }
201
+ return context;
202
+ }
@@ -7,7 +7,7 @@ const meta = {
7
7
  tags: ['!stable', 'alpha'],
8
8
  title: 'React Native/Form/Checkbox',
9
9
  component: Checkbox,
10
- decorators: [(Story) => <ThemeProvider><Story /></ThemeProvider>],
10
+ decorators: [(Story) => <ThemeProvider colorScheme="light"><Story /></ThemeProvider>],
11
11
  parameters: { layout: 'padded' },
12
12
  } satisfies Meta<typeof Checkbox>;
13
13
 
@@ -28,9 +28,7 @@ export const Interactive: Story = {
28
28
  render: () => {
29
29
  const [checked, setChecked] = useState(false);
30
30
  return (
31
- <ThemeProvider>
32
- <Checkbox label="Accept terms and conditions" name="terms" checked={checked} onChange={setChecked} />
33
- </ThemeProvider>
31
+ <Checkbox label="Accept terms and conditions" name="terms" checked={checked} onChange={setChecked} />
34
32
  );
35
33
  },
36
34
  };
@@ -55,7 +55,7 @@ export function Checkbox({
55
55
  }: CheckboxProps) {
56
56
  const { colors } = useTheme();
57
57
 
58
- const borderColor = error ? colors.colorError : checked ? colors.colorInteractive : colors.colorBgSubtle;
58
+ const borderColor = error ? colors.colorError : checked ? colors.colorInteractive : colors.colorOnBg;
59
59
  const bgColor = checked ? colors.colorInteractive : 'transparent';
60
60
 
61
61
  return (
@@ -0,0 +1,78 @@
1
+ import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
2
+ import * as Stories from './CheckboxGroup.native.stories';
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # CheckboxGroup (React Native)
7
+
8
+ Groups related checkboxes under a common legend with optional hint and error messages.
9
+
10
+ > **Status: alpha** -- API may change before stable release.
11
+
12
+ ## Usage
13
+
14
+ ```tsx
15
+ import { CheckboxGroup, Checkbox } from '@boostdev/components';
16
+ import { useState } from 'react';
17
+
18
+ function Example() {
19
+ const [checked, setChecked] = useState({ email: false, sms: false });
20
+
21
+ return (
22
+ <CheckboxGroup legend="Notifications">
23
+ <Checkbox
24
+ label="Email"
25
+ name="email"
26
+ checked={checked.email}
27
+ onChange={(v) => setChecked(s => ({ ...s, email: v }))}
28
+ />
29
+ <Checkbox
30
+ label="SMS"
31
+ name="sms"
32
+ checked={checked.sms}
33
+ onChange={(v) => setChecked(s => ({ ...s, sms: v }))}
34
+ />
35
+ </CheckboxGroup>
36
+ );
37
+ }
38
+ ```
39
+
40
+ ## Examples
41
+
42
+ ### Default
43
+ <Canvas of={Stories.Default} />
44
+
45
+ ### Required
46
+ <Canvas of={Stories.Required} />
47
+
48
+ ### With hint
49
+ <Canvas of={Stories.WithHint} />
50
+
51
+ ### With error
52
+ <Canvas of={Stories.WithError} />
53
+
54
+ ### Disabled
55
+ <Canvas of={Stories.Disabled} />
56
+
57
+ ### Interactive
58
+ <Canvas of={Stories.Interactive} />
59
+
60
+ ## Props
61
+
62
+ <ArgTypes of={Stories} />
63
+
64
+ ## Props reference
65
+
66
+ | Prop | Type | Default | Description |
67
+ |------|------|---------|-------------|
68
+ | `legend` | string | -- | Group label displayed above the checkboxes |
69
+ | `children` | ReactNode | -- | Checkbox components |
70
+ | `error` | string | -- | Error message displayed below the group |
71
+ | `hint` | string | -- | Helper text displayed below the group |
72
+ | `required` | boolean | -- | Appends asterisk to legend |
73
+ | `disabled` | boolean | `false` | Reduces opacity of the entire group |
74
+
75
+ ## Accessibility
76
+
77
+ - The group is labelled via `accessibilityLabel` matching the legend text
78
+ - Error messages use `accessibilityRole="alert"` for screen reader announcement
@@ -0,0 +1,57 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { ThemeProvider } from '../../../../native/ThemeContext';
3
+ import { CheckboxGroup } from './CheckboxGroup.native';
4
+ import { Checkbox } from '../Checkbox/Checkbox.native';
5
+
6
+ function renderWithTheme(ui: React.ReactElement) {
7
+ return render(<ThemeProvider>{ui}</ThemeProvider>);
8
+ }
9
+
10
+ describe('CheckboxGroup (native)', () => {
11
+ it('renders the legend text', () => {
12
+ renderWithTheme(
13
+ <CheckboxGroup legend="Notifications">
14
+ <Checkbox label="Email" name="email" />
15
+ </CheckboxGroup>,
16
+ );
17
+ expect(screen.getByText('Notifications')).toBeInTheDocument();
18
+ });
19
+
20
+ it('renders children', () => {
21
+ renderWithTheme(
22
+ <CheckboxGroup legend="Preferences">
23
+ <Checkbox label="Option A" name="a" />
24
+ <Checkbox label="Option B" name="b" />
25
+ </CheckboxGroup>,
26
+ );
27
+ expect(screen.getByText('Option A')).toBeInTheDocument();
28
+ expect(screen.getByText('Option B')).toBeInTheDocument();
29
+ });
30
+
31
+ it('appends asterisk when required', () => {
32
+ renderWithTheme(
33
+ <CheckboxGroup legend="Accept" required>
34
+ <Checkbox label="Terms" name="terms" />
35
+ </CheckboxGroup>,
36
+ );
37
+ expect(screen.getByText('*', { exact: false })).toBeInTheDocument();
38
+ });
39
+
40
+ it('renders error message', () => {
41
+ renderWithTheme(
42
+ <CheckboxGroup legend="Options" error="Select at least one.">
43
+ <Checkbox label="A" name="a" />
44
+ </CheckboxGroup>,
45
+ );
46
+ expect(screen.getByRole('alert')).toHaveTextContent('Select at least one.');
47
+ });
48
+
49
+ it('renders hint message', () => {
50
+ renderWithTheme(
51
+ <CheckboxGroup legend="Options" hint="Select all that apply.">
52
+ <Checkbox label="A" name="a" />
53
+ </CheckboxGroup>,
54
+ );
55
+ expect(screen.getByText('Select all that apply.')).toBeInTheDocument();
56
+ });
57
+ });
@@ -0,0 +1,96 @@
1
+ import React, { useState } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import { ThemeProvider } from '../../../../native/ThemeContext';
4
+ import { CheckboxGroup } from './CheckboxGroup.native';
5
+ import { Checkbox } from '../Checkbox/Checkbox.native';
6
+
7
+ const meta = {
8
+ tags: ['!stable', 'alpha'],
9
+ title: 'React Native/Form/CheckboxGroup',
10
+ component: CheckboxGroup,
11
+ decorators: [(Story) => <ThemeProvider colorScheme="light"><Story /></ThemeProvider>],
12
+ parameters: { layout: 'padded' },
13
+ } satisfies Meta<typeof CheckboxGroup>;
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ export const Default: Story = {
19
+ args: {
20
+ legend: 'Notifications',
21
+ children: (
22
+ <>
23
+ <Checkbox label="Email" name="email" />
24
+ <Checkbox label="SMS" name="sms" />
25
+ <Checkbox label="Push" name="push" />
26
+ </>
27
+ ),
28
+ },
29
+ };
30
+
31
+ export const Required: Story = {
32
+ args: {
33
+ legend: 'Accept terms',
34
+ required: true,
35
+ children: (
36
+ <>
37
+ <Checkbox label="Terms of service" name="tos" />
38
+ <Checkbox label="Privacy policy" name="privacy" />
39
+ </>
40
+ ),
41
+ },
42
+ };
43
+
44
+ export const Disabled: Story = {
45
+ args: {
46
+ legend: 'Notifications',
47
+ disabled: true,
48
+ children: (
49
+ <>
50
+ <Checkbox label="Email" name="email" checked disabled />
51
+ <Checkbox label="SMS" name="sms" disabled />
52
+ </>
53
+ ),
54
+ },
55
+ };
56
+
57
+ export const WithError: Story = {
58
+ args: {
59
+ legend: 'Select at least one',
60
+ error: 'Please select at least one option.',
61
+ children: (
62
+ <>
63
+ <Checkbox label="Option A" name="a" />
64
+ <Checkbox label="Option B" name="b" />
65
+ </>
66
+ ),
67
+ },
68
+ };
69
+
70
+ export const WithHint: Story = {
71
+ args: {
72
+ legend: 'Preferences',
73
+ hint: 'Select all that apply.',
74
+ children: (
75
+ <>
76
+ <Checkbox label="Newsletter" name="newsletter" />
77
+ <Checkbox label="Product updates" name="updates" />
78
+ </>
79
+ ),
80
+ },
81
+ };
82
+
83
+ function InteractiveComponent() {
84
+ const [checked, setChecked] = useState({ email: false, sms: false, push: false });
85
+ return (
86
+ <CheckboxGroup legend="Notifications">
87
+ <Checkbox label="Email" name="email" checked={checked.email} onChange={(v) => setChecked(s => ({ ...s, email: v }))} />
88
+ <Checkbox label="SMS" name="sms" checked={checked.sms} onChange={(v) => setChecked(s => ({ ...s, sms: v }))} />
89
+ <Checkbox label="Push" name="push" checked={checked.push} onChange={(v) => setChecked(s => ({ ...s, push: v }))} />
90
+ </CheckboxGroup>
91
+ );
92
+ }
93
+
94
+ export const Interactive: Story = {
95
+ render: () => <InteractiveComponent />,
96
+ };
@@ -0,0 +1,61 @@
1
+ import { ReactNode } from 'react';
2
+ import { StyleSheet, View, Text, StyleProp, ViewStyle } from 'react-native';
3
+ import { spacing, font, lineHeight } from '../../../../native/tokens';
4
+ import { useTheme } from '../../../../native/ThemeContext';
5
+ import { Message } from '../atoms/Message.native';
6
+
7
+ interface CheckboxGroupProps {
8
+ legend: string;
9
+ children: ReactNode;
10
+ error?: string;
11
+ hint?: string;
12
+ required?: boolean;
13
+ disabled?: boolean;
14
+ style?: StyleProp<ViewStyle>;
15
+ }
16
+
17
+ const styles = StyleSheet.create({
18
+ container: {
19
+ gap: spacing.xs,
20
+ },
21
+ legend: {
22
+ fontFamily: font.family.body,
23
+ fontSize: font.size.body,
24
+ lineHeight: lineHeight.body,
25
+ fontWeight: font.weight.semibold,
26
+ },
27
+ required: {
28
+ fontWeight: font.weight.body,
29
+ },
30
+ items: {
31
+ gap: spacing.xxs,
32
+ },
33
+ });
34
+
35
+ export function CheckboxGroup({
36
+ legend,
37
+ children,
38
+ error,
39
+ hint,
40
+ required,
41
+ disabled = false,
42
+ style,
43
+ }: Readonly<CheckboxGroupProps>) {
44
+ const { colors } = useTheme();
45
+
46
+ return (
47
+ <View
48
+ style={[styles.container, disabled && { opacity: 0.4 }, style]}
49
+ accessibilityRole="none"
50
+ accessibilityLabel={legend}
51
+ >
52
+ <Text style={[styles.legend, { color: colors.colorOnBg }]}>
53
+ {legend}
54
+ {required && <Text style={[styles.required, { color: colors.colorOnBgSubtle }]}> *</Text>}
55
+ </Text>
56
+ <View style={styles.items}>{children}</View>
57
+ <Message type="error" message={error} />
58
+ <Message type="hint" message={hint} />
59
+ </View>
60
+ );
61
+ }
@@ -0,0 +1,86 @@
1
+ import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
2
+ import * as Stories from './Combobox.native.stories';
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # Combobox (React Native)
7
+
8
+ A text input with a filterable dropdown list. Type to filter options, tap to select. Supports error and hint messages.
9
+
10
+ > **Status: alpha** -- API may change before stable release.
11
+
12
+ ## Usage
13
+
14
+ ```tsx
15
+ import { Combobox } from '@boostdev/components';
16
+ import { useState } from 'react';
17
+
18
+ const options = [
19
+ { value: 'apple', label: 'Apple' },
20
+ { value: 'banana', label: 'Banana' },
21
+ { value: 'cherry', label: 'Cherry' },
22
+ ];
23
+
24
+ function Example() {
25
+ const [value, setValue] = useState('');
26
+
27
+ return (
28
+ <Combobox
29
+ label="Fruit"
30
+ name="fruit"
31
+ options={options}
32
+ placeholder="Search fruit..."
33
+ value={value}
34
+ onChange={setValue}
35
+ />
36
+ );
37
+ }
38
+ ```
39
+
40
+ ## Examples
41
+
42
+ ### Default
43
+ <Canvas of={Stories.Default} />
44
+
45
+ ### With value
46
+ <Canvas of={Stories.WithValue} />
47
+
48
+ ### With hint
49
+ <Canvas of={Stories.WithHint} />
50
+
51
+ ### With error
52
+ <Canvas of={Stories.WithError} />
53
+
54
+ ### Disabled
55
+ <Canvas of={Stories.Disabled} />
56
+
57
+ ### With disabled option
58
+ <Canvas of={Stories.WithDisabledOption} />
59
+
60
+ ### Interactive
61
+ <Canvas of={Stories.Interactive} />
62
+
63
+ ## Props
64
+
65
+ <ArgTypes of={Stories} />
66
+
67
+ ## Props reference
68
+
69
+ | Prop | Type | Default | Description |
70
+ |------|------|---------|-------------|
71
+ | `label` | string | -- | Visible label text |
72
+ | `name` | string | -- | Field name |
73
+ | `options` | `ComboboxOption[]` | -- | Array of `{ value, label, disabled? }` |
74
+ | `placeholder` | string | -- | Input placeholder text |
75
+ | `value` | string | -- | Currently selected option value |
76
+ | `onChange` | `(value: string) => void` | -- | Called with the selected option value |
77
+ | `disabled` | boolean | `false` | Disables the entire input |
78
+ | `error` | string | -- | Error message displayed below |
79
+ | `hint` | string | -- | Helper text displayed below |
80
+
81
+ ## Accessibility
82
+
83
+ - Uses `accessibilityRole="combobox"` on the input
84
+ - Options use `accessibilityRole="menuitem"` with selected/disabled states
85
+ - Selected option is highlighted with `accessibilityState.selected`
86
+ - Disabled options are communicated via `accessibilityState.disabled`
@@ -0,0 +1,60 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { ThemeProvider } from '../../../../native/ThemeContext';
3
+ import { Combobox } from './Combobox.native';
4
+ import type { ComboboxOption } from './Combobox.native';
5
+
6
+ function renderWithTheme(ui: React.ReactElement) {
7
+ return render(<ThemeProvider>{ui}</ThemeProvider>);
8
+ }
9
+
10
+ const fruits: ComboboxOption[] = [
11
+ { value: 'apple', label: 'Apple' },
12
+ { value: 'banana', label: 'Banana' },
13
+ { value: 'cherry', label: 'Cherry' },
14
+ ];
15
+
16
+ describe('Combobox (native)', () => {
17
+ it('renders with label', () => {
18
+ renderWithTheme(
19
+ <Combobox label="Fruit" name="fruit" options={fruits} />,
20
+ );
21
+ expect(screen.getByText('Fruit')).toBeInTheDocument();
22
+ });
23
+
24
+ it('has combobox role', () => {
25
+ renderWithTheme(
26
+ <Combobox label="Fruit" name="fruit" options={fruits} />,
27
+ );
28
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
29
+ });
30
+
31
+ it('shows placeholder text', () => {
32
+ renderWithTheme(
33
+ <Combobox label="Fruit" name="fruit" options={fruits} placeholder="Search..." />,
34
+ );
35
+ expect(screen.getByPlaceholderText('Search...')).toBeInTheDocument();
36
+ });
37
+
38
+ it('displays the selected option label when value is set', () => {
39
+ renderWithTheme(
40
+ <Combobox label="Fruit" name="fruit" options={fruits} value="cherry" />,
41
+ );
42
+ // react-native-web renders TextInput as <input>, so we can check the DOM value
43
+ const input = screen.getByRole('combobox') as HTMLInputElement;
44
+ expect(input.value).toBe('Cherry');
45
+ });
46
+
47
+ it('renders error message', () => {
48
+ renderWithTheme(
49
+ <Combobox label="Fruit" name="fruit" options={fruits} error="Required." />,
50
+ );
51
+ expect(screen.getByRole('alert')).toHaveTextContent('Required.');
52
+ });
53
+
54
+ it('renders hint message', () => {
55
+ renderWithTheme(
56
+ <Combobox label="Fruit" name="fruit" options={fruits} hint="Type to filter." />,
57
+ );
58
+ expect(screen.getByText('Type to filter.')).toBeInTheDocument();
59
+ });
60
+ });