cpk-ui 0.5.4 β†’ 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +80 -147
  2. package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
  3. package/components/modals/AlertDialog/AlertDialog.js +14 -7
  4. package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
  5. package/components/modals/Snackbar/Snackbar.js +20 -17
  6. package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
  7. package/components/uis/Accordion/AccordionItem.js +41 -17
  8. package/components/uis/Button/Button.d.ts +2 -1
  9. package/components/uis/Button/Button.d.ts.map +1 -1
  10. package/components/uis/Button/Button.js +11 -11
  11. package/components/uis/Card/Card.d.ts +2 -1
  12. package/components/uis/Card/Card.d.ts.map +1 -1
  13. package/components/uis/Card/Card.js +12 -3
  14. package/components/uis/Checkbox/Checkbox.d.ts +2 -1
  15. package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
  16. package/components/uis/Checkbox/Checkbox.js +2 -2
  17. package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
  18. package/components/uis/CustomPressable/CustomPressable.js +6 -6
  19. package/components/uis/EditText/EditText.d.ts +1 -0
  20. package/components/uis/EditText/EditText.d.ts.map +1 -1
  21. package/components/uis/EditText/EditText.js +18 -13
  22. package/components/uis/Fab/Fab.d.ts +2 -2
  23. package/components/uis/Fab/Fab.d.ts.map +1 -1
  24. package/components/uis/Fab/Fab.js +22 -4
  25. package/components/uis/Icon/Icon.d.ts.map +1 -1
  26. package/components/uis/Icon/Icon.js +6 -3
  27. package/components/uis/IconButton/IconButton.d.ts +2 -1
  28. package/components/uis/IconButton/IconButton.d.ts.map +1 -1
  29. package/components/uis/IconButton/IconButton.js +44 -42
  30. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +2 -1
  31. package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
  32. package/components/uis/LoadingIndicator/LoadingIndicator.js +4 -4
  33. package/components/uis/RadioGroup/RadioButton.d.ts +2 -1
  34. package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
  35. package/components/uis/RadioGroup/RadioButton.js +2 -2
  36. package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
  37. package/components/uis/RadioGroup/RadioGroup.js +16 -3
  38. package/components/uis/Rating/Rating.d.ts.map +1 -1
  39. package/components/uis/Rating/Rating.js +23 -19
  40. package/components/uis/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  41. package/components/uis/SegmentedControl/SegmentedControl.js +1 -1
  42. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
  43. package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
  44. package/components/uis/StatusbarBrightness/StatusBarBrightness.js +1 -1
  45. package/components/uis/SwitchToggle/SwitchToggle.d.ts +2 -1
  46. package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
  47. package/components/uis/SwitchToggle/SwitchToggle.js +2 -2
  48. package/hooks/useHoverState.d.ts +8 -0
  49. package/hooks/useHoverState.d.ts.map +1 -0
  50. package/hooks/useHoverState.js +16 -0
  51. package/package.json +18 -6
  52. package/providers/ThemeProvider.d.ts.map +1 -1
  53. package/providers/ThemeProvider.js +0 -1
  54. package/providers/index.d.ts.map +1 -1
  55. package/providers/index.js +3 -2
  56. package/components/uis/Icon/selection.json +0 -1
  57. package/src/components/common/ErrorBoundary/ErrorBoundary.tsx +0 -75
  58. package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +0 -216
  59. package/src/components/modals/AlertDialog/AlertDialog.test.tsx +0 -251
  60. package/src/components/modals/AlertDialog/AlertDialog.tsx +0 -356
  61. package/src/components/modals/Snackbar/Snackbar.stories.tsx +0 -182
  62. package/src/components/modals/Snackbar/Snackbar.test.tsx +0 -319
  63. package/src/components/modals/Snackbar/Snackbar.tsx +0 -260
  64. package/src/components/modals/Snackbar/const.ts +0 -4
  65. package/src/components/uis/Accordion/Accordion.stories.tsx +0 -167
  66. package/src/components/uis/Accordion/Accordion.test.tsx +0 -272
  67. package/src/components/uis/Accordion/Accordion.tsx +0 -109
  68. package/src/components/uis/Accordion/AccordionItem.tsx +0 -306
  69. package/src/components/uis/Button/Button.stories.tsx +0 -218
  70. package/src/components/uis/Button/Button.test.tsx +0 -620
  71. package/src/components/uis/Button/Button.tsx +0 -436
  72. package/src/components/uis/Card/Card.test.tsx +0 -146
  73. package/src/components/uis/Card/Card.tsx +0 -102
  74. package/src/components/uis/Checkbox/Checkbox.stories.tsx +0 -216
  75. package/src/components/uis/Checkbox/Checkbox.test.tsx +0 -173
  76. package/src/components/uis/Checkbox/Checkbox.tsx +0 -220
  77. package/src/components/uis/CustomPressable/CustomPressable.tsx +0 -48
  78. package/src/components/uis/EditText/EditText.stories.tsx +0 -124
  79. package/src/components/uis/EditText/EditText.test.tsx +0 -477
  80. package/src/components/uis/EditText/EditText.tsx +0 -590
  81. package/src/components/uis/Fab/Fab.stories.tsx +0 -133
  82. package/src/components/uis/Fab/Fab.test.tsx +0 -110
  83. package/src/components/uis/Fab/Fab.tsx +0 -168
  84. package/src/components/uis/Hr/Hr.test.tsx +0 -26
  85. package/src/components/uis/Hr/Hr.tsx +0 -19
  86. package/src/components/uis/Icon/Icon.stories.tsx +0 -98
  87. package/src/components/uis/Icon/Icon.test.tsx +0 -49
  88. package/src/components/uis/Icon/Icon.tsx +0 -3819
  89. package/src/components/uis/IconButton/IconButton.test.tsx +0 -165
  90. package/src/components/uis/IconButton/IconButton.tsx +0 -275
  91. package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +0 -126
  92. package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +0 -81
  93. package/src/components/uis/PinchZoom/PinchZoom.stories.tsx +0 -266
  94. package/src/components/uis/PinchZoom/PinchZoom.test.tsx +0 -113
  95. package/src/components/uis/PinchZoom/PinchZoom.tsx +0 -424
  96. package/src/components/uis/RadioGroup/RadioButton.tsx +0 -188
  97. package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
  98. package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -287
  99. package/src/components/uis/RadioGroup/RadioGroup.tsx +0 -109
  100. package/src/components/uis/Rating/Rating.test.tsx +0 -98
  101. package/src/components/uis/Rating/Rating.tsx +0 -200
  102. package/src/components/uis/SegmentedControl/SegmentedControl.stories.tsx +0 -546
  103. package/src/components/uis/SegmentedControl/SegmentedControl.test.tsx +0 -274
  104. package/src/components/uis/SegmentedControl/SegmentedControl.tsx +0 -229
  105. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +0 -41
  106. package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +0 -26
  107. package/src/components/uis/Styled/StyledComponents.tsx +0 -217
  108. package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +0 -75
  109. package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +0 -105
  110. package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -305
  111. package/src/components/uis/Typography/Typography.stories.tsx +0 -149
  112. package/src/components/uis/Typography/Typography.test.tsx +0 -58
  113. package/src/components/uis/Typography/Typography.tsx +0 -386
  114. package/src/hooks/index.ts +0 -2
  115. package/src/hooks/useAnimations.ts +0 -71
  116. package/src/hooks/useDebouncedColorScheme.tsx +0 -30
  117. package/src/hooks/useOptimizedStyles.ts +0 -22
  118. package/src/hooks/usePerformance.ts +0 -93
  119. package/src/index.tsx +0 -38
  120. package/src/providers/ThemeProvider.tsx +0 -177
  121. package/src/providers/index.tsx +0 -130
  122. package/src/test/testUtils.tsx +0 -101
  123. package/src/types/common.ts +0 -77
  124. package/src/types/index.ts +0 -1
  125. package/src/types/kstyled.d.ts +0 -6
  126. package/src/utils/accessibility.ts +0 -110
  127. package/src/utils/colors.ts +0 -151
  128. package/src/utils/createCtx.tsx +0 -26
  129. package/src/utils/guards.ts +0 -93
  130. package/src/utils/index.ts +0 -2
  131. package/src/utils/performanceTest.ts +0 -174
  132. package/src/utils/platform.ts +0 -69
  133. package/src/utils/theme.ts +0 -38
  134. package/test/testUtils.d.ts +0 -113
  135. package/test/testUtils.d.ts.map +0 -1
  136. package/test/testUtils.js +0 -65
@@ -1,546 +0,0 @@
1
- import {useState} from 'react';
2
- import type {Meta, StoryObj} from '@storybook/react';
3
- import {View} from 'react-native';
4
-
5
- import {withThemeProvider} from '../../../../.storybook/decorators';
6
- import {SegmentedControl, SegmentedControlColorType, SegmentedControlSizeType} from './SegmentedControl';
7
- import {Typography} from '../Typography/Typography';
8
-
9
- const meta = {
10
- title: 'SegmentedControl',
11
- component: (props) => <SegmentedControl {...props} />,
12
- parameters: {
13
- notes: `
14
- A iOS-style SegmentedControl component that allows users to select a single option from a set of choices.
15
-
16
- ## Features
17
- - **iOS-style Design**: Native iOS segmented control appearance
18
- - **Flexible Sizing**: Supports preset sizes (small, medium, large) and custom numeric values
19
- - **Color Variants**: Multiple color options for different contexts
20
- - **Disabled State**: Can disable the entire control
21
- - **Smooth Transitions**: Animated selection with visual feedback
22
-
23
- ## Size Options
24
- - \`small\`: 6px/8px padding
25
- - \`medium\`: 8px/12px padding (default)
26
- - \`large\`: 12px/16px padding
27
- - Custom number: Any pixel value for custom padding
28
-
29
- ## Usage
30
- \`\`\`tsx
31
- <SegmentedControl
32
- values={[
33
- {value: 'day', text: 'Day'},
34
- {value: 'week', text: 'Week'},
35
- {value: 'month', text: 'Month'},
36
- ]}
37
- selectedValue="day"
38
- onValueChange={setSelectedValue}
39
- size="medium"
40
- color="primary"
41
- />
42
- \`\`\`
43
- `,
44
- docs: {
45
- description: {
46
- component: `
47
- A iOS-style SegmentedControl component that allows users to select a single option from a set of choices.
48
-
49
- ## Features
50
- - **iOS-style Design**: Native iOS segmented control appearance
51
- - **Flexible Sizing**: Supports preset sizes (small, medium, large) and custom numeric values
52
- - **Color Variants**: Multiple color options for different contexts
53
- - **Disabled State**: Can disable the entire control
54
- - **Smooth Transitions**: Animated selection with visual feedback
55
-
56
- ## Size Options
57
- - \`small\`: 6px/8px padding
58
- - \`medium\`: 8px/12px padding (default)
59
- - \`large\`: 12px/16px padding
60
- - Custom number: Any pixel value for custom padding
61
-
62
- ## Usage
63
- \`\`\`tsx
64
- <SegmentedControl
65
- values={[
66
- {value: 'day', text: 'Day'},
67
- {value: 'week', text: 'Week'},
68
- {value: 'month', text: 'Month'},
69
- ]}
70
- selectedValue="day"
71
- onValueChange={setSelectedValue}
72
- size="medium"
73
- color="primary"
74
- />
75
- \`\`\`
76
- `,
77
- },
78
- },
79
- },
80
- argTypes: {
81
- color: {
82
- control: 'select',
83
- options: [
84
- 'primary',
85
- 'secondary',
86
- 'success',
87
- 'danger',
88
- 'warning',
89
- 'info',
90
- 'light',
91
- ] as SegmentedControlColorType[],
92
- description: 'Color variant of the selected segment',
93
- },
94
- size: {
95
- control: 'radio',
96
- options: ['small', 'medium', 'large', 16, 20, 24, 32],
97
- description: 'Size can be "small", "medium", "large" or a custom number in pixels',
98
- },
99
- disabled: {
100
- control: 'boolean',
101
- description: 'Disables the entire segmented control',
102
- },
103
- borderRadius: {
104
- control: {type: 'number', min: 0, max: 20, step: 1},
105
- description: 'Border radius of the control',
106
- },
107
- },
108
- decorators: [
109
- (Story, context) =>
110
- withThemeProvider(
111
- Story,
112
- context,
113
- // @ts-ignore
114
- context.args.theme,
115
- ),
116
- ],
117
- } satisfies Meta<typeof SegmentedControl>;
118
-
119
- export default meta;
120
-
121
- type Story = StoryObj<typeof meta>;
122
-
123
- export const Basic: Story = {
124
- render: (args) => {
125
- const [selectedValue, setSelectedValue] = useState<string | number>('day');
126
-
127
- return (
128
- <View style={{gap: 20}}>
129
- <SegmentedControl
130
- values={[
131
- {value: 'day', text: 'Day'},
132
- {value: 'week', text: 'Week'},
133
- {value: 'month', text: 'Month'},
134
- ]}
135
- color={args.color}
136
- size={args.size}
137
- disabled={args.disabled}
138
- borderRadius={args.borderRadius}
139
- selectedValue={selectedValue}
140
- onValueChange={setSelectedValue}
141
- />
142
- <View style={{padding: 16, alignItems: 'center'}}>
143
- <Typography.Heading2>Selected: {selectedValue}</Typography.Heading2>
144
- </View>
145
- </View>
146
- );
147
- },
148
- args: {
149
- theme: 'light',
150
- color: 'primary',
151
- size: 'medium',
152
- disabled: false,
153
- borderRadius: 8,
154
- },
155
- argTypes: {
156
- theme: {
157
- control: 'select',
158
- options: ['light', 'dark'],
159
- },
160
- },
161
- };
162
-
163
- export const WithDynamicContent: Story = {
164
- render: (args) => {
165
- const [selectedValue, setSelectedValue] = useState<string | number>('day');
166
-
167
- const contentMap = {
168
- day: {
169
- title: 'Daily View',
170
- description: 'View your daily activities and statistics',
171
- emoji: 'πŸ“…',
172
- },
173
- week: {
174
- title: 'Weekly View',
175
- description: 'See your weekly progress and trends',
176
- emoji: 'πŸ“Š',
177
- },
178
- month: {
179
- title: 'Monthly View',
180
- description: 'Analyze your monthly performance',
181
- emoji: 'πŸ“ˆ',
182
- },
183
- };
184
-
185
- const content = contentMap[selectedValue as keyof typeof contentMap];
186
-
187
- return (
188
- <View style={{gap: 20}}>
189
- <SegmentedControl
190
- values={[
191
- {value: 'day', text: 'Day'},
192
- {value: 'week', text: 'Week'},
193
- {value: 'month', text: 'Month'},
194
- ]}
195
- color={args.color}
196
- size={args.size}
197
- disabled={args.disabled}
198
- borderRadius={args.borderRadius}
199
- selectedValue={selectedValue}
200
- onValueChange={setSelectedValue}
201
- />
202
- <View style={{padding: 24, alignItems: 'center', gap: 12}}>
203
- <Typography.Heading1 style={{fontSize: 48}}>
204
- {content.emoji}
205
- </Typography.Heading1>
206
- <Typography.Heading2>{content.title}</Typography.Heading2>
207
- <Typography.Body1 style={{textAlign: 'center', opacity: 0.7}}>
208
- {content.description}
209
- </Typography.Body1>
210
- </View>
211
- </View>
212
- );
213
- },
214
- args: {
215
- theme: 'light',
216
- color: 'primary',
217
- size: 'medium',
218
- disabled: false,
219
- borderRadius: 8,
220
- },
221
- argTypes: {
222
- theme: {
223
- control: 'select',
224
- options: ['light', 'dark'],
225
- },
226
- },
227
- };
228
-
229
- export const PlatformSelector: Story = {
230
- render: (args) => {
231
- const [selectedValue, setSelectedValue] = useState<string | number>('ios');
232
-
233
- const platformInfo = {
234
- ios: {
235
- icon: '🍎',
236
- name: 'iOS',
237
- version: 'iOS 17+',
238
- features: ['Swift', 'SwiftUI', 'UIKit'],
239
- },
240
- android: {
241
- icon: 'πŸ€–',
242
- name: 'Android',
243
- version: 'Android 14+',
244
- features: ['Kotlin', 'Jetpack Compose', 'Material Design'],
245
- },
246
- web: {
247
- icon: '🌐',
248
- name: 'Web',
249
- version: 'Modern Browsers',
250
- features: ['React', 'TypeScript', 'Responsive Design'],
251
- },
252
- };
253
-
254
- const info = platformInfo[selectedValue as keyof typeof platformInfo];
255
-
256
- return (
257
- <View style={{gap: 20}}>
258
- <SegmentedControl
259
- values={[
260
- {value: 'ios', text: 'iOS'},
261
- {value: 'android', text: 'Android'},
262
- {value: 'web', text: 'Web'},
263
- ]}
264
- color={args.color}
265
- size={args.size}
266
- disabled={args.disabled}
267
- borderRadius={args.borderRadius}
268
- selectedValue={selectedValue}
269
- onValueChange={setSelectedValue}
270
- />
271
- <View style={{padding: 24, gap: 16}}>
272
- <View style={{alignItems: 'center', gap: 8}}>
273
- <Typography.Heading1 style={{fontSize: 56}}>
274
- {info.icon}
275
- </Typography.Heading1>
276
- <Typography.Heading2>{info.name}</Typography.Heading2>
277
- <Typography.Body2 style={{opacity: 0.6}}>
278
- {info.version}
279
- </Typography.Body2>
280
- </View>
281
- <View style={{gap: 8, marginTop: 8}}>
282
- <Typography.Heading3>Key Technologies:</Typography.Heading3>
283
- {info.features.map((feature) => (
284
- <Typography.Body1 key={feature} style={{paddingLeft: 12}}>
285
- β€’ {feature}
286
- </Typography.Body1>
287
- ))}
288
- </View>
289
- </View>
290
- </View>
291
- );
292
- },
293
- args: {
294
- theme: 'light',
295
- color: 'primary',
296
- size: 'medium',
297
- disabled: false,
298
- borderRadius: 8,
299
- },
300
- argTypes: {
301
- theme: {
302
- control: 'select',
303
- options: ['light', 'dark'],
304
- },
305
- },
306
- };
307
-
308
- export const AllSizes: Story = {
309
- render: (args) => {
310
- const [selectedSmall, setSelectedSmall] = useState<string | number>('day');
311
- const [selectedMedium, setSelectedMedium] = useState<string | number>('day');
312
- const [selectedLarge, setSelectedLarge] = useState<string | number>('day');
313
-
314
- const values = [
315
- {value: 'day', text: 'Day'},
316
- {value: 'week', text: 'Week'},
317
- {value: 'month', text: 'Month'},
318
- ];
319
-
320
- return (
321
- <View style={{gap: 24}}>
322
- <View style={{gap: 8}}>
323
- <Typography.Heading3>Small</Typography.Heading3>
324
- <SegmentedControl
325
- values={values}
326
- color="primary"
327
- size="small"
328
- borderRadius={8}
329
- selectedValue={selectedSmall}
330
- onValueChange={setSelectedSmall}
331
- />
332
- </View>
333
- <View style={{gap: 8}}>
334
- <Typography.Heading3>Medium</Typography.Heading3>
335
- <SegmentedControl
336
- values={values}
337
- color="primary"
338
- size="medium"
339
- borderRadius={8}
340
- selectedValue={selectedMedium}
341
- onValueChange={setSelectedMedium}
342
- />
343
- </View>
344
- <View style={{gap: 8}}>
345
- <Typography.Heading3>Large</Typography.Heading3>
346
- <SegmentedControl
347
- values={values}
348
- color="primary"
349
- size="large"
350
- borderRadius={8}
351
- selectedValue={selectedLarge}
352
- onValueChange={setSelectedLarge}
353
- />
354
- </View>
355
- </View>
356
- );
357
- },
358
- args: {
359
- theme: 'light',
360
- },
361
- argTypes: {
362
- theme: {
363
- control: 'select',
364
- options: ['light', 'dark'],
365
- },
366
- },
367
- };
368
-
369
- export const AllColors: Story = {
370
- render: (args) => {
371
- const [selected1, setSelected1] = useState<string | number>(1);
372
- const [selected2, setSelected2] = useState<string | number>(1);
373
- const [selected3, setSelected3] = useState<string | number>(1);
374
- const [selected4, setSelected4] = useState<string | number>(1);
375
- const [selected5, setSelected5] = useState<string | number>(1);
376
- const [selected6, setSelected6] = useState<string | number>(1);
377
-
378
- const values = [
379
- {value: 1, text: 'Option 1'},
380
- {value: 2, text: 'Option 2'},
381
- {value: 3, text: 'Option 3'},
382
- ];
383
-
384
- return (
385
- <View style={{gap: 20}}>
386
- <View style={{gap: 8}}>
387
- <Typography.Heading3>Primary</Typography.Heading3>
388
- <SegmentedControl
389
- values={values}
390
- color="primary"
391
- size="medium"
392
- borderRadius={8}
393
- selectedValue={selected1}
394
- onValueChange={setSelected1}
395
- />
396
- </View>
397
- <View style={{gap: 8}}>
398
- <Typography.Heading3>Secondary</Typography.Heading3>
399
- <SegmentedControl
400
- values={values}
401
- color="secondary"
402
- size="medium"
403
- borderRadius={8}
404
- selectedValue={selected2}
405
- onValueChange={setSelected2}
406
- />
407
- </View>
408
- <View style={{gap: 8}}>
409
- <Typography.Heading3>Success</Typography.Heading3>
410
- <SegmentedControl
411
- values={values}
412
- color="success"
413
- size="medium"
414
- borderRadius={8}
415
- selectedValue={selected3}
416
- onValueChange={setSelected3}
417
- />
418
- </View>
419
- <View style={{gap: 8}}>
420
- <Typography.Heading3>Danger</Typography.Heading3>
421
- <SegmentedControl
422
- values={values}
423
- color="danger"
424
- size="medium"
425
- borderRadius={8}
426
- selectedValue={selected4}
427
- onValueChange={setSelected4}
428
- />
429
- </View>
430
- <View style={{gap: 8}}>
431
- <Typography.Heading3>Warning</Typography.Heading3>
432
- <SegmentedControl
433
- values={values}
434
- color="warning"
435
- size="medium"
436
- borderRadius={8}
437
- selectedValue={selected5}
438
- onValueChange={setSelected5}
439
- />
440
- </View>
441
- <View style={{gap: 8}}>
442
- <Typography.Heading3>Info</Typography.Heading3>
443
- <SegmentedControl
444
- values={values}
445
- color="info"
446
- size="medium"
447
- borderRadius={8}
448
- selectedValue={selected6}
449
- onValueChange={setSelected6}
450
- />
451
- </View>
452
- </View>
453
- );
454
- },
455
- args: {
456
- theme: 'light',
457
- },
458
- argTypes: {
459
- theme: {
460
- control: 'select',
461
- options: ['light', 'dark'],
462
- },
463
- },
464
- };
465
-
466
- export const WithIcons: Story = {
467
- render: (args) => {
468
- const [selectedValue, setSelectedValue] = useState<string | number>('list');
469
-
470
- return (
471
- <View style={{gap: 20}}>
472
- <SegmentedControl
473
- values={[
474
- {value: 'grid', text: <Typography.Body2>πŸ“± Grid</Typography.Body2>},
475
- {value: 'list', text: <Typography.Body2>πŸ“‹ List</Typography.Body2>},
476
- {value: 'map', text: <Typography.Body2>πŸ—ΊοΈ Map</Typography.Body2>},
477
- ]}
478
- color={args.color}
479
- size={args.size}
480
- disabled={args.disabled}
481
- borderRadius={args.borderRadius}
482
- selectedValue={selectedValue}
483
- onValueChange={setSelectedValue}
484
- />
485
- <View style={{padding: 16, alignItems: 'center'}}>
486
- <Typography.Body1>View mode: {selectedValue}</Typography.Body1>
487
- </View>
488
- </View>
489
- );
490
- },
491
- args: {
492
- theme: 'light',
493
- color: 'primary',
494
- size: 'medium',
495
- disabled: false,
496
- borderRadius: 8,
497
- },
498
- argTypes: {
499
- theme: {
500
- control: 'select',
501
- options: ['light', 'dark'],
502
- },
503
- },
504
- };
505
-
506
- export const Disabled: Story = {
507
- render: (args) => {
508
- const [selectedValue, setSelectedValue] = useState<string | number>('second');
509
-
510
- return (
511
- <View style={{gap: 20}}>
512
- <SegmentedControl
513
- values={[
514
- {value: 'first', text: 'First'},
515
- {value: 'second', text: 'Second'},
516
- {value: 'third', text: 'Third'},
517
- ]}
518
- color={args.color}
519
- size={args.size}
520
- disabled={args.disabled}
521
- borderRadius={args.borderRadius}
522
- selectedValue={selectedValue}
523
- onValueChange={setSelectedValue}
524
- />
525
- <View style={{padding: 16, alignItems: 'center'}}>
526
- <Typography.Body1 style={{opacity: 0.5}}>
527
- This control is disabled
528
- </Typography.Body1>
529
- </View>
530
- </View>
531
- );
532
- },
533
- args: {
534
- theme: 'light',
535
- color: 'primary',
536
- size: 'medium',
537
- disabled: true,
538
- borderRadius: 8,
539
- },
540
- argTypes: {
541
- theme: {
542
- control: 'select',
543
- options: ['light', 'dark'],
544
- },
545
- },
546
- };