@wecareu/select 0.1.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 (77) hide show
  1. package/README.md +165 -0
  2. package/lib/commonjs/Select.js +272 -0
  3. package/lib/commonjs/Select.js.map +1 -0
  4. package/lib/commonjs/Select.types.js +6 -0
  5. package/lib/commonjs/Select.types.js.map +1 -0
  6. package/lib/commonjs/SelectChip.js +74 -0
  7. package/lib/commonjs/SelectChip.js.map +1 -0
  8. package/lib/commonjs/SelectDropdown.js +156 -0
  9. package/lib/commonjs/SelectDropdown.js.map +1 -0
  10. package/lib/commonjs/SelectErrorMessage.js +32 -0
  11. package/lib/commonjs/SelectErrorMessage.js.map +1 -0
  12. package/lib/commonjs/SelectIcon.js +64 -0
  13. package/lib/commonjs/SelectIcon.js.map +1 -0
  14. package/lib/commonjs/SelectOption.js +140 -0
  15. package/lib/commonjs/SelectOption.js.map +1 -0
  16. package/lib/commonjs/SelectSearch.js +79 -0
  17. package/lib/commonjs/SelectSearch.js.map +1 -0
  18. package/lib/commonjs/animations/shake.js +45 -0
  19. package/lib/commonjs/animations/shake.js.map +1 -0
  20. package/lib/commonjs/index.js +13 -0
  21. package/lib/commonjs/index.js.map +1 -0
  22. package/lib/commonjs/index.stories.js +383 -0
  23. package/lib/commonjs/index.stories.js.map +1 -0
  24. package/lib/module/Select.js +265 -0
  25. package/lib/module/Select.js.map +1 -0
  26. package/lib/module/Select.types.js +2 -0
  27. package/lib/module/Select.types.js.map +1 -0
  28. package/lib/module/SelectChip.js +67 -0
  29. package/lib/module/SelectChip.js.map +1 -0
  30. package/lib/module/SelectDropdown.js +149 -0
  31. package/lib/module/SelectDropdown.js.map +1 -0
  32. package/lib/module/SelectErrorMessage.js +25 -0
  33. package/lib/module/SelectErrorMessage.js.map +1 -0
  34. package/lib/module/SelectIcon.js +57 -0
  35. package/lib/module/SelectIcon.js.map +1 -0
  36. package/lib/module/SelectOption.js +133 -0
  37. package/lib/module/SelectOption.js.map +1 -0
  38. package/lib/module/SelectSearch.js +72 -0
  39. package/lib/module/SelectSearch.js.map +1 -0
  40. package/lib/module/animations/shake.js +39 -0
  41. package/lib/module/animations/shake.js.map +1 -0
  42. package/lib/module/index.js +2 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/module/index.stories.js +376 -0
  45. package/lib/module/index.stories.js.map +1 -0
  46. package/lib/typescript/src/Select.d.ts +3 -0
  47. package/lib/typescript/src/Select.d.ts.map +1 -0
  48. package/lib/typescript/src/Select.types.d.ts +245 -0
  49. package/lib/typescript/src/Select.types.d.ts.map +1 -0
  50. package/lib/typescript/src/SelectChip.d.ts +3 -0
  51. package/lib/typescript/src/SelectChip.d.ts.map +1 -0
  52. package/lib/typescript/src/SelectDropdown.d.ts +3 -0
  53. package/lib/typescript/src/SelectDropdown.d.ts.map +1 -0
  54. package/lib/typescript/src/SelectErrorMessage.d.ts +3 -0
  55. package/lib/typescript/src/SelectErrorMessage.d.ts.map +1 -0
  56. package/lib/typescript/src/SelectIcon.d.ts +3 -0
  57. package/lib/typescript/src/SelectIcon.d.ts.map +1 -0
  58. package/lib/typescript/src/SelectOption.d.ts +3 -0
  59. package/lib/typescript/src/SelectOption.d.ts.map +1 -0
  60. package/lib/typescript/src/SelectSearch.d.ts +3 -0
  61. package/lib/typescript/src/SelectSearch.d.ts.map +1 -0
  62. package/lib/typescript/src/animations/shake.d.ts +32 -0
  63. package/lib/typescript/src/animations/shake.d.ts.map +1 -0
  64. package/lib/typescript/src/index.d.ts +3 -0
  65. package/lib/typescript/src/index.d.ts.map +1 -0
  66. package/package.json +66 -0
  67. package/src/Select.tsx +338 -0
  68. package/src/Select.types.ts +256 -0
  69. package/src/SelectChip.tsx +75 -0
  70. package/src/SelectDropdown.tsx +184 -0
  71. package/src/SelectErrorMessage.tsx +31 -0
  72. package/src/SelectIcon.tsx +63 -0
  73. package/src/SelectOption.tsx +168 -0
  74. package/src/SelectSearch.tsx +81 -0
  75. package/src/animations/shake.ts +76 -0
  76. package/src/index.stories.tsx +336 -0
  77. package/src/index.tsx +2 -0
@@ -0,0 +1,383 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithRowColors = exports.WithIconsAndLabelColors = exports.WithFlags = exports.WithError = exports.WithDisabledOptions = exports.Selected = exports.Readonly = exports.MultipleWithInitialValues = exports.MultipleWithDisabledOptions = exports.MultipleSelect = exports.MultipleSearchable = exports.Disabled = exports.Default = exports.Clearable = exports.AllStates = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _addonActions = require("@storybook/addon-actions");
10
+ var _ = require(".");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
13
+ const GENDER_OPTIONS = [{
14
+ label: 'Female',
15
+ value: 'F'
16
+ }, {
17
+ label: 'Male',
18
+ value: 'M'
19
+ }, {
20
+ label: 'Non-binary',
21
+ value: 'NB'
22
+ }, {
23
+ label: 'Prefer not to say',
24
+ value: 'X'
25
+ }];
26
+ const COUNTRIES_OPTIONS = [{
27
+ description: 'South America',
28
+ flagCode: 'AR',
29
+ label: 'Argentina',
30
+ value: 'AR'
31
+ }, {
32
+ description: 'Oceania',
33
+ flagCode: 'AU',
34
+ label: 'Australia',
35
+ value: 'AU'
36
+ }, {
37
+ description: 'South America',
38
+ flagCode: 'BR',
39
+ label: 'Brazil',
40
+ value: 'BR'
41
+ }, {
42
+ description: 'North America',
43
+ flagCode: 'CA',
44
+ label: 'Canada',
45
+ value: 'CA'
46
+ }, {
47
+ description: 'South America',
48
+ flagCode: 'CL',
49
+ label: 'Chile',
50
+ value: 'CL'
51
+ }, {
52
+ description: 'Asia',
53
+ flagCode: 'CN',
54
+ label: 'China',
55
+ value: 'CN'
56
+ }, {
57
+ description: 'Europe',
58
+ flagCode: 'FR',
59
+ label: 'France',
60
+ value: 'FR'
61
+ }, {
62
+ description: 'Europe',
63
+ flagCode: 'DE',
64
+ label: 'Germany',
65
+ value: 'DE'
66
+ }, {
67
+ description: 'Asia',
68
+ flagCode: 'IN',
69
+ label: 'India',
70
+ value: 'IN'
71
+ }, {
72
+ description: 'Europe',
73
+ flagCode: 'IT',
74
+ label: 'Italy',
75
+ value: 'IT'
76
+ }, {
77
+ description: 'Asia',
78
+ flagCode: 'JP',
79
+ label: 'Japan',
80
+ value: 'JP'
81
+ }, {
82
+ description: 'Europe',
83
+ flagCode: 'PT',
84
+ label: 'Portugal',
85
+ value: 'PT'
86
+ }, {
87
+ description: 'Europe',
88
+ flagCode: 'ES',
89
+ label: 'Spain',
90
+ value: 'ES'
91
+ }, {
92
+ description: 'North America',
93
+ flagCode: 'US',
94
+ label: 'United States',
95
+ value: 'US'
96
+ }];
97
+ const TAGS_OPTIONS = [{
98
+ label: 'Design System',
99
+ value: 'ds'
100
+ }, {
101
+ label: 'Expo',
102
+ value: 'expo'
103
+ }, {
104
+ label: 'React Native',
105
+ value: 'rn'
106
+ }, {
107
+ label: 'Storybook',
108
+ value: 'sb'
109
+ }, {
110
+ label: 'Testing',
111
+ value: 'test'
112
+ }, {
113
+ label: 'TypeScript',
114
+ value: 'ts'
115
+ }];
116
+ const STATUS_OPTIONS = [{
117
+ description: 'User is available',
118
+ icon: 'correct',
119
+ label: 'Available',
120
+ labelColor: '#22c55e',
121
+ value: 'available'
122
+ }, {
123
+ description: 'User is in a meeting',
124
+ icon: 'time',
125
+ label: 'Busy',
126
+ labelColor: '#f59e0b',
127
+ value: 'busy'
128
+ }, {
129
+ description: 'User is not here',
130
+ disabled: true,
131
+ icon: 'close',
132
+ label: 'Away',
133
+ value: 'away'
134
+ }, {
135
+ description: 'Appears offline to others',
136
+ icon: 'notificationOff',
137
+ label: 'Offline',
138
+ labelColor: '#94a3b8',
139
+ value: 'offline'
140
+ }];
141
+ const ROLE_OPTIONS = [{
142
+ color: '#fef9c3',
143
+ label: 'Admin',
144
+ labelColor: '#854d0e',
145
+ value: 'admin'
146
+ }, {
147
+ color: '#dcfce7',
148
+ label: 'Editor',
149
+ labelColor: '#166534',
150
+ value: 'editor'
151
+ }, {
152
+ color: '#dbeafe',
153
+ label: 'Viewer',
154
+ labelColor: '#1e40af',
155
+ value: 'viewer'
156
+ }, {
157
+ color: '#fee2e2',
158
+ disabled: true,
159
+ label: 'Banned',
160
+ labelColor: '#991b1b',
161
+ value: 'banned'
162
+ }];
163
+ function StatefulSingleSelect({
164
+ initialValue = null,
165
+ ...rest
166
+ }) {
167
+ const [value, setValue] = _react.default.useState(initialValue);
168
+ const handleChange = _react.default.useCallback(next => {
169
+ setValue(next);
170
+ (0, _addonActions.action)('onChange')(next);
171
+ }, []);
172
+ return /*#__PURE__*/_react.default.createElement(_.Select, _extends({}, rest, {
173
+ onChange: handleChange,
174
+ value: value
175
+ }));
176
+ }
177
+ function StatefulMultiSelect({
178
+ initialValues = [],
179
+ ...rest
180
+ }) {
181
+ const [values, setValues] = _react.default.useState(initialValues);
182
+ const handleChange = _react.default.useCallback(next => {
183
+ setValues(next);
184
+ (0, _addonActions.action)('onChange')(next);
185
+ }, []);
186
+ return /*#__PURE__*/_react.default.createElement(_.Select, _extends({}, rest, {
187
+ multiple: true,
188
+ onChange: handleChange,
189
+ value: values
190
+ }));
191
+ }
192
+ const meta = {
193
+ component: _.Select,
194
+ parameters: {
195
+ layout: 'centered'
196
+ },
197
+ tags: ['autodocs'],
198
+ title: 'Forms/Select'
199
+ };
200
+ var _default = exports.default = meta;
201
+ const Default = exports.Default = {
202
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
203
+ style: styles.container
204
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
205
+ options: GENDER_OPTIONS,
206
+ placeholder: "Select gender"
207
+ }))
208
+ };
209
+ const Selected = exports.Selected = {
210
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
211
+ style: styles.container
212
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
213
+ initialValue: "BR",
214
+ options: COUNTRIES_OPTIONS,
215
+ placeholder: "Select country"
216
+ }))
217
+ };
218
+ const WithFlags = exports.WithFlags = {
219
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
220
+ style: styles.container
221
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
222
+ clearable: true,
223
+ options: COUNTRIES_OPTIONS,
224
+ placeholder: "Select country",
225
+ searchable: true
226
+ }))
227
+ };
228
+ const WithIconsAndLabelColors = exports.WithIconsAndLabelColors = {
229
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
230
+ style: styles.container
231
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
232
+ clearable: true,
233
+ options: STATUS_OPTIONS,
234
+ placeholder: "Select status"
235
+ }))
236
+ };
237
+ const WithRowColors = exports.WithRowColors = {
238
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
239
+ style: styles.container
240
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
241
+ clearable: true,
242
+ options: ROLE_OPTIONS,
243
+ placeholder: "Select role"
244
+ }))
245
+ };
246
+ const MultipleSelect = exports.MultipleSelect = {
247
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
248
+ style: styles.container
249
+ }, /*#__PURE__*/_react.default.createElement(StatefulMultiSelect, {
250
+ clearable: true,
251
+ options: TAGS_OPTIONS,
252
+ placeholder: "Select tags"
253
+ }))
254
+ };
255
+ const MultipleWithInitialValues = exports.MultipleWithInitialValues = {
256
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
257
+ style: styles.container
258
+ }, /*#__PURE__*/_react.default.createElement(StatefulMultiSelect, {
259
+ clearable: true,
260
+ initialValues: ['rn', 'ts'],
261
+ options: TAGS_OPTIONS,
262
+ placeholder: "Select tags"
263
+ }))
264
+ };
265
+ const MultipleSearchable = exports.MultipleSearchable = {
266
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
267
+ style: styles.container
268
+ }, /*#__PURE__*/_react.default.createElement(StatefulMultiSelect, {
269
+ clearable: true,
270
+ options: COUNTRIES_OPTIONS,
271
+ placeholder: "Select countries",
272
+ searchable: true
273
+ }))
274
+ };
275
+ const MultipleWithDisabledOptions = exports.MultipleWithDisabledOptions = {
276
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
277
+ style: styles.container
278
+ }, /*#__PURE__*/_react.default.createElement(StatefulMultiSelect, {
279
+ clearable: true,
280
+ options: STATUS_OPTIONS,
281
+ placeholder: "Select statuses"
282
+ }))
283
+ };
284
+ const Clearable = exports.Clearable = {
285
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
286
+ style: styles.container
287
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
288
+ clearable: true,
289
+ initialValue: "M",
290
+ options: GENDER_OPTIONS,
291
+ placeholder: "Select gender"
292
+ }))
293
+ };
294
+ const WithError = exports.WithError = {
295
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
296
+ style: styles.container
297
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
298
+ errorMessage: "This field is required",
299
+ inputError: true,
300
+ options: GENDER_OPTIONS,
301
+ placeholder: "Select gender",
302
+ required: true
303
+ }))
304
+ };
305
+ const Disabled = exports.Disabled = {
306
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
307
+ style: styles.container
308
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
309
+ disabled: true,
310
+ initialValue: "M",
311
+ options: GENDER_OPTIONS,
312
+ placeholder: "Select gender"
313
+ }))
314
+ };
315
+ const Readonly = exports.Readonly = {
316
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
317
+ style: styles.container
318
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
319
+ initialValue: "BR",
320
+ options: COUNTRIES_OPTIONS,
321
+ placeholder: "Select country",
322
+ readonly: true
323
+ }))
324
+ };
325
+ const WithDisabledOptions = exports.WithDisabledOptions = {
326
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
327
+ style: styles.container
328
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
329
+ options: STATUS_OPTIONS,
330
+ placeholder: "Select status"
331
+ }))
332
+ };
333
+ const AllStates = exports.AllStates = {
334
+ render: () => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
335
+ style: styles.column
336
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
337
+ style: styles.storyItem
338
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
339
+ options: GENDER_OPTIONS,
340
+ placeholder: "Default - empty"
341
+ })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
342
+ style: styles.storyItem
343
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
344
+ clearable: true,
345
+ initialValue: "M",
346
+ options: GENDER_OPTIONS,
347
+ placeholder: "With value + clearable"
348
+ })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
349
+ style: styles.storyItem
350
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
351
+ errorMessage: "Required field",
352
+ inputError: true,
353
+ options: GENDER_OPTIONS,
354
+ placeholder: "Error state"
355
+ })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
356
+ style: styles.storyItem
357
+ }, /*#__PURE__*/_react.default.createElement(StatefulSingleSelect, {
358
+ disabled: true,
359
+ initialValue: "F",
360
+ options: GENDER_OPTIONS,
361
+ placeholder: "Disabled"
362
+ })), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
363
+ style: styles.storyItem
364
+ }, /*#__PURE__*/_react.default.createElement(StatefulMultiSelect, {
365
+ clearable: true,
366
+ initialValues: ['ts', 'rn'],
367
+ options: TAGS_OPTIONS,
368
+ placeholder: "Multi select with chips"
369
+ })))
370
+ };
371
+ const styles = _reactNative.StyleSheet.create({
372
+ column: {
373
+ gap: 12,
374
+ width: 320
375
+ },
376
+ container: {
377
+ width: 320
378
+ },
379
+ storyItem: {
380
+ width: '100%'
381
+ }
382
+ });
383
+ //# sourceMappingURL=index.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_addonActions","_","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","GENDER_OPTIONS","label","value","COUNTRIES_OPTIONS","description","flagCode","TAGS_OPTIONS","STATUS_OPTIONS","icon","labelColor","disabled","ROLE_OPTIONS","color","StatefulSingleSelect","initialValue","rest","setValue","React","useState","handleChange","useCallback","next","action","createElement","Select","onChange","StatefulMultiSelect","initialValues","values","setValues","multiple","meta","component","parameters","layout","tags","title","_default","exports","Default","render","View","style","styles","container","options","placeholder","Selected","WithFlags","clearable","searchable","WithIconsAndLabelColors","WithRowColors","MultipleSelect","MultipleWithInitialValues","MultipleSearchable","MultipleWithDisabledOptions","Clearable","WithError","errorMessage","inputError","required","Disabled","Readonly","readonly","WithDisabledOptions","AllStates","column","storyItem","StyleSheet","create","gap","width"],"sourceRoot":"..\\..\\src","sources":["index.stories.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAGA,IAAAG,CAAA,GAAAH,OAAA;AAA0B,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP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;IACxB8C,WAAW,EAAC;EAAa,CAC1B,CACG,CAAC,eACPnE,MAAA,CAAAQ,OAAA,CAAAoC,aAAA,CAACzC,YAAA,CAAA2D,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACyB;EAAU,gBAC5BzF,MAAA,CAAAQ,OAAA,CAAAoC,aAAA,CAACV,oBAAoB;IACnBH,QAAQ;IACRI,YAAY,EAAC,GAAG;IAChB+B,OAAO,EAAE7C,cAAe;IACxB8C,WAAW,EAAC;EAAU,CACvB,CACG,CAAC,eACPnE,MAAA,CAAAQ,OAAA,CAAAoC,aAAA,CAACzC,YAAA,CAAA2D,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACyB;EAAU,gBAC5BzF,MAAA,CAAAQ,OAAA,CAAAoC,aAAA,CAACG,mBAAmB;IAClBuB,SAAS;IACTtB,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAE;IAC5BkB,OAAO,EAAEvC,YAAa;IACtBwC,WAAW,EAAC;EAAyB,CACtC,CACG,CACF;AAEV,CAAC;AAED,MAAMH,MAAM,GAAG0B,uBAAU,CAACC,MAAM,CAAC;EAC/BH,MAAM,EAAE;IACNI,GAAG,EAAE,EAAE;IACPC,KAAK,EAAE;EACT,CAAC;EACD5B,SAAS,EAAE;IACT4B,KAAK,EAAE;EACT,CAAC;EACDJ,SAAS,EAAE;IACTI,KAAK,EAAE;EACT;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,265 @@
1
+ import React from 'react';
2
+ import { Animated, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
3
+ import { useTheme } from '@wecareu/theme';
4
+ import { useShakeAnimation } from './animations/shake';
5
+ import { SelectChip } from './SelectChip';
6
+ import { SelectDropdown } from './SelectDropdown';
7
+ import { SelectErrorMessage } from './SelectErrorMessage';
8
+ import { SelectIcon } from './SelectIcon';
9
+ export function Select(props) {
10
+ const theme = useTheme();
11
+ const styles = React.useMemo(() => createStyles(theme), [theme]);
12
+ const {
13
+ clearable = false,
14
+ disabled = false,
15
+ errorMessage,
16
+ inputError = false,
17
+ labels,
18
+ leftIcon,
19
+ multiple,
20
+ onValidation,
21
+ options,
22
+ placeholder,
23
+ readonly = false,
24
+ required = false,
25
+ searchable = false,
26
+ style,
27
+ testID,
28
+ value
29
+ } = props;
30
+ if (!options || options.length === 0) {
31
+ console.error('[Select] The "options" prop must be a non-empty array. Received:', options);
32
+ return null;
33
+ }
34
+ const isInteractive = !(disabled || readonly);
35
+ const [isOpen, setIsOpen] = React.useState(false);
36
+ const [touched, setTouched] = React.useState(false);
37
+ const {
38
+ animatedStyle,
39
+ triggerShake
40
+ } = useShakeAnimation({
41
+ distance: theme.spacing.sm
42
+ });
43
+ const isEmpty = multiple ? value.length === 0 : value === null || value === undefined;
44
+ const internalHasError = React.useMemo(() => {
45
+ if (!required || !touched) {
46
+ return false;
47
+ }
48
+ return isEmpty;
49
+ }, [isEmpty, required, touched]);
50
+ React.useEffect(() => {
51
+ if (!required || !touched) {
52
+ return;
53
+ }
54
+ onValidation?.(!internalHasError);
55
+ }, [internalHasError, onValidation, required, touched]);
56
+ const shouldShowError = inputError || internalHasError;
57
+ const requiredErrorMessage = labels?.requiredError ?? 'This field is required';
58
+ const effectiveErrorMessage = inputError ? errorMessage : internalHasError ? requiredErrorMessage : undefined;
59
+ const previousErrorRef = React.useRef(false);
60
+ React.useEffect(() => {
61
+ if (shouldShowError && !previousErrorRef.current) {
62
+ triggerShake();
63
+ }
64
+ previousErrorRef.current = shouldShowError;
65
+ }, [shouldShowError, triggerShake]);
66
+ const selectedValues = React.useMemo(() => {
67
+ if (multiple) {
68
+ return value ?? [];
69
+ }
70
+ if (value !== null && value !== undefined) {
71
+ return [value];
72
+ }
73
+ return [];
74
+ }, [multiple, value]);
75
+ const selectedOptions = React.useMemo(() => options.filter(o => selectedValues.includes(o.value)), [options, selectedValues]);
76
+ const singleLabel = React.useMemo(() => {
77
+ if (multiple || isEmpty) {
78
+ return null;
79
+ }
80
+ return options.find(o => o.value === value)?.label ?? null;
81
+ }, [isEmpty, multiple, options, value]);
82
+ const handleOpen = React.useCallback(() => {
83
+ if (!isInteractive) {
84
+ return;
85
+ }
86
+ setTouched(true);
87
+ setIsOpen(true);
88
+ }, [isInteractive]);
89
+ const handleClose = React.useCallback(() => {
90
+ setIsOpen(false);
91
+ }, []);
92
+ const handleToggleOption = React.useCallback(option => {
93
+ if (multiple) {
94
+ const multiProps = props;
95
+ const current = multiProps.value;
96
+ const isSelected = current.includes(option.value);
97
+ const next = isSelected ? current.filter(v => v !== option.value) : [...current, option.value];
98
+ multiProps.onChange(next);
99
+ } else {
100
+ const singleProps = props;
101
+ singleProps.onChange(option.value);
102
+ setIsOpen(false);
103
+ }
104
+ }, [multiple, props]);
105
+ const handleClear = React.useCallback(() => {
106
+ if (multiple) {
107
+ const multiProps = props;
108
+ multiProps.onChange([]);
109
+ } else {
110
+ const singleProps = props;
111
+ singleProps.onChange(null);
112
+ }
113
+ }, [multiple, props]);
114
+ const handleRemoveChip = React.useCallback(optionValue => {
115
+ if (!multiple) {
116
+ return;
117
+ }
118
+ const multiProps = props;
119
+ multiProps.onChange(multiProps.value.filter(v => v !== optionValue));
120
+ }, [multiple, props]);
121
+ const showClearButton = clearable && !isEmpty && isInteractive;
122
+ const renderFieldContent = () => {
123
+ if (multiple && selectedOptions.length > 0) {
124
+ return /*#__PURE__*/React.createElement(ScrollView, {
125
+ horizontal: true,
126
+ keyboardShouldPersistTaps: "handled",
127
+ showsHorizontalScrollIndicator: false,
128
+ style: styles.chipsScroll,
129
+ contentContainerStyle: styles.chipsContainer
130
+ }, selectedOptions.map(opt => /*#__PURE__*/React.createElement(SelectChip, {
131
+ key: String(opt.value),
132
+ disabled: disabled,
133
+ label: opt.label,
134
+ onRemove: () => handleRemoveChip(opt.value)
135
+ })));
136
+ }
137
+ if (!isEmpty && singleLabel) {
138
+ return /*#__PURE__*/React.createElement(Text, {
139
+ numberOfLines: 1,
140
+ style: styles.selectedLabel
141
+ }, singleLabel);
142
+ }
143
+ return /*#__PURE__*/React.createElement(Text, {
144
+ numberOfLines: 1,
145
+ style: styles.placeholder
146
+ }, placeholder ?? 'Select...');
147
+ };
148
+ return /*#__PURE__*/React.createElement(View, {
149
+ style: styles.wrapper
150
+ }, /*#__PURE__*/React.createElement(Animated.View, {
151
+ accessible: false,
152
+ style: [styles.container, !isInteractive && styles.containerDisabled, shouldShowError && styles.containerError, animatedStyle, style],
153
+ testID: testID
154
+ }, leftIcon ? /*#__PURE__*/React.createElement(View, {
155
+ style: styles.iconLeft
156
+ }, /*#__PURE__*/React.createElement(SelectIcon, leftIcon)) : null, /*#__PURE__*/React.createElement(Pressable, {
157
+ accessibilityHint: placeholder,
158
+ accessibilityLabel: singleLabel ?? placeholder ?? 'Select option',
159
+ accessibilityRole: "combobox",
160
+ accessibilityState: {
161
+ disabled: !isInteractive,
162
+ expanded: isOpen
163
+ },
164
+ disabled: !isInteractive,
165
+ onPress: handleOpen,
166
+ style: styles.fieldPressable
167
+ }, renderFieldContent()), /*#__PURE__*/React.createElement(View, {
168
+ style: styles.rightIcons
169
+ }, showClearButton ? /*#__PURE__*/React.createElement(Pressable, {
170
+ accessibilityLabel: "Clear selection",
171
+ accessibilityRole: "button",
172
+ hitSlop: 8,
173
+ onPress: handleClear
174
+ }, /*#__PURE__*/React.createElement(SelectIcon, {
175
+ color: theme.colors.text.tertiary,
176
+ name: "close",
177
+ size: theme.spacing.md
178
+ })) : /*#__PURE__*/React.createElement(Pressable, {
179
+ accessibilityLabel: isOpen ? 'Close options' : 'Open options',
180
+ accessibilityRole: "button",
181
+ disabled: !isInteractive,
182
+ hitSlop: 8,
183
+ onPress: handleOpen
184
+ }, /*#__PURE__*/React.createElement(SelectIcon, {
185
+ color: theme.colors.text.tertiary,
186
+ name: isOpen ? 'chevronUp' : 'chevronDown',
187
+ size: theme.spacing.md
188
+ })))), /*#__PURE__*/React.createElement(SelectErrorMessage, {
189
+ message: shouldShowError ? effectiveErrorMessage : undefined,
190
+ testID: effectiveErrorMessage ? `${testID ?? 'select'}-error` : undefined
191
+ }), /*#__PURE__*/React.createElement(SelectDropdown, {
192
+ isMulti: multiple,
193
+ isOpen: isOpen,
194
+ onClose: handleClose,
195
+ onToggleOption: handleToggleOption,
196
+ options: options,
197
+ searchable: searchable,
198
+ selectedValues: selectedValues
199
+ }));
200
+ }
201
+ function createStyles(theme) {
202
+ return StyleSheet.create({
203
+ chipsContainer: {
204
+ alignItems: 'center',
205
+ flexDirection: 'row',
206
+ gap: theme.spacing.xs,
207
+ paddingVertical: 2
208
+ },
209
+ chipsScroll: {
210
+ flex: 1
211
+ },
212
+ container: {
213
+ alignItems: 'center',
214
+ backgroundColor: 'transparent',
215
+ borderColor: theme.colors.brand.primary,
216
+ borderRadius: theme.radius.xxl,
217
+ borderWidth: 1,
218
+ flexDirection: 'row',
219
+ minHeight: 48,
220
+ paddingHorizontal: theme.spacing.xl,
221
+ paddingVertical: theme.spacing.xs,
222
+ width: '100%'
223
+ },
224
+ containerDisabled: {
225
+ backgroundColor: theme.colors.surface.disabled,
226
+ borderColor: theme.colors.border.disabled
227
+ },
228
+ containerError: {
229
+ borderColor: theme.colors.status.error
230
+ },
231
+ fieldPressable: {
232
+ alignItems: 'center',
233
+ flex: 1,
234
+ flexDirection: 'row',
235
+ justifyContent: 'center',
236
+ minHeight: 32
237
+ },
238
+ iconLeft: {
239
+ marginRight: theme.spacing.xs
240
+ },
241
+ placeholder: {
242
+ color: theme.colors.text.tertiary,
243
+ flex: 1,
244
+ fontFamily: theme.typography.fontFamily.body,
245
+ lineHeight: theme.typography.lineHeight.bodySmall,
246
+ textAlign: 'center'
247
+ },
248
+ rightIcons: {
249
+ alignItems: 'center',
250
+ flexDirection: 'row',
251
+ marginLeft: theme.spacing.xs
252
+ },
253
+ selectedLabel: {
254
+ color: theme.colors.text.primary,
255
+ flex: 1,
256
+ fontFamily: theme.typography.fontFamily.body,
257
+ lineHeight: theme.typography.lineHeight.bodySmall,
258
+ textAlign: 'center'
259
+ },
260
+ wrapper: {
261
+ width: '100%'
262
+ }
263
+ });
264
+ }
265
+ //# sourceMappingURL=Select.js.map