react-native-ui-lib 7.39.0-snapshot.6682 → 7.39.0-snapshot.6685

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.39.0-snapshot.6682",
3
+ "version": "7.39.0-snapshot.6685",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -15,6 +15,7 @@ import { PickerModes } from "./types";
15
15
  import PickerContext from "./PickerContext";
16
16
  import PickerItem from "./PickerItem";
17
17
  import { Constants } from "../../commons/new";
18
+ import PickerSelectionStatusBar from "./PickerSelectionStatusBar";
18
19
  const keyExtractor = (_item, index) => index.toString();
19
20
  const PickerItemsList = props => {
20
21
  const {
@@ -35,7 +36,8 @@ const PickerItemsList = props => {
35
36
  testID,
36
37
  showLoader,
37
38
  customLoaderElement,
38
- renderCustomTopElement
39
+ renderCustomTopElement,
40
+ selectionStatus: selectionStatusProps
39
41
  } = props;
40
42
  const context = useContext(PickerContext);
41
43
  const [wheelPickerValue, setWheelPickerValue] = useState(context.value ?? items?.[0]?.value);
@@ -130,10 +132,12 @@ const PickerItemsList = props => {
130
132
  <ActivityIndicator />
131
133
  </View>;
132
134
  };
135
+ const selectionStatus = useMemo(() => mode === PickerModes.MULTI && selectionStatusProps && <PickerSelectionStatusBar {...selectionStatusProps} />, [selectionStatusProps, mode]);
133
136
  const renderContent = () => {
134
137
  return useWheelPicker ? renderWheel() : <>
135
138
  {renderSearchInput()}
136
139
  {renderCustomTopElement?.(context.value)}
140
+ {selectionStatus}
137
141
  {renderList()}
138
142
  </>;
139
143
  };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { PickerSelectionStatusProps } from './types';
3
+ export default function PickerSelectionStatusBar(props: PickerSelectionStatusProps): React.JSX.Element;
@@ -0,0 +1,60 @@
1
+ import React, { useCallback, useContext } from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import Button from "../button";
4
+ import Checkbox from "../checkbox";
5
+ import View from "../view";
6
+ import Text from "../text";
7
+ import Dividers from "../../style/dividers";
8
+ import PickerContext from "./PickerContext";
9
+ export default function PickerSelectionStatusBar(props) {
10
+ const {
11
+ containerStyle,
12
+ getLabel,
13
+ showLabel = true
14
+ } = props;
15
+ const context = useContext(PickerContext);
16
+ const {
17
+ toggleAllItemsSelection,
18
+ selectedCount,
19
+ areAllItemsSelected
20
+ } = context;
21
+ const checkboxIndeterminate = selectedCount > 0 && !areAllItemsSelected;
22
+ const label = getLabel?.({
23
+ selectedCount,
24
+ areAllItemsSelected
25
+ }) ?? `${selectedCount} Selected ${areAllItemsSelected ? '(All)' : ''}`;
26
+ const handlePress = useCallback(() => {
27
+ const newSelectionState = !areAllItemsSelected;
28
+ toggleAllItemsSelection?.(newSelectionState);
29
+ if (props.selectAllType === 'button') {
30
+ props?.buttonProps?.onPress?.({
31
+ customValue: newSelectionState
32
+ });
33
+ } else if (props.selectAllType === 'checkbox') {
34
+ props?.checkboxProps?.onValueChange?.(newSelectionState);
35
+ }
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, [areAllItemsSelected, toggleAllItemsSelection]);
38
+ const renderSelectionStatus = () => {
39
+ return <View flexG={!showLabel} style={!showLabel && styles.componentContainer}>
40
+ {props.selectAllType === 'button' ? <Button label={areAllItemsSelected ? 'Deselect All' : 'Select All'} link {...props?.buttonProps} onPress={handlePress} /> : props.selectAllType === 'checkbox' && <Checkbox {...props.checkboxProps} value={selectedCount > 0} indeterminate={checkboxIndeterminate} onValueChange={handlePress} />}
41
+ </View>;
42
+ };
43
+ const renderLabel = () => {
44
+ if (showLabel) {
45
+ return <Text>{label}</Text>;
46
+ }
47
+ };
48
+ return <View>
49
+ <View row spread paddingH-page marginV-s4 style={containerStyle}>
50
+ {renderLabel()}
51
+ {renderSelectionStatus()}
52
+ </View>
53
+ <View style={Dividers.d20} />
54
+ </View>;
55
+ }
56
+ const styles = StyleSheet.create({
57
+ componentContainer: {
58
+ alignItems: 'flex-end'
59
+ }
60
+ });
@@ -108,13 +108,395 @@
108
108
  ],
109
109
  "snippet": [
110
110
  "<Picker",
111
- " value={currentValue$1}",
111
+ " value={2$1}",
112
112
  " placeholder={'Placeholder'$2}",
113
113
  " onChange={() => console.log('changed')$3}",
114
+ " trailingAccessory={<Icon source={Assets.icons.demo.chevronDown}/>}",
115
+ " items={[{label: 'Item 1', value: 1}, {label: 'Item 2', value: 2},{label: 'Item 3', value: 3}]}",
114
116
  ">",
115
- " {_.map(items, item => (",
116
- " return renderItem(item, index);",
117
- " ))$4}",
118
117
  "</Picker>"
119
- ]
118
+ ],
119
+ "docs": {
120
+ "hero": {
121
+ "title": "Picker",
122
+ "description": "Picker allows the user to select an option from a variety of choices available.Pressing the Picker Field, will open a dialog or modal displaying a list of available options for selection.",
123
+ "type": "hero",
124
+ "layout": "horizontal",
125
+ "content": [
126
+ {
127
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_cover.png"
128
+ }
129
+ ]
130
+ },
131
+ "tabs": [
132
+ {
133
+ "title": "Overview",
134
+ "sections": [
135
+ {
136
+ "type": "section",
137
+ "title": "Usage Example",
138
+ "description": "Pickers allow selection of an option or multiple options from a list usually displayed using an actionSheet. Pickers can be used in forms, settings screens or as part of an interactive flow.",
139
+ "content": [
140
+ {
141
+ "value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=4415-185562&embed-host=share"
142
+ }
143
+ ]
144
+ },
145
+ {
146
+ "type": "list",
147
+ "items": [
148
+ {
149
+ "title": "Form Field (default)",
150
+ "description": "Mainly used as part of a form, works cohesively with the text field component and other form related components.",
151
+ "content": [
152
+ {
153
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_types_form.png"
154
+ }
155
+ ]
156
+ },
157
+ {
158
+ "title": "Filter Field",
159
+ "description": "Used mostly for filtering a screen or part of it. Can be combined with search functionality.\nThe colon symbol in the Label is not part of the component itself and should be included as part of the text string.",
160
+ "content": [
161
+ {
162
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_types_filter.png"
163
+ }
164
+ ]
165
+ },
166
+ {
167
+ "title": "Settings Field",
168
+ "description": "Based on ListItem component.\nUsed mostly when the picker is part of a settings screen.",
169
+ "content": [
170
+ {
171
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_types_settings.png"
172
+ }
173
+ ]
174
+ }
175
+ ],
176
+ "layout": "horizontal",
177
+ "title": "Picker Types",
178
+ "description": "Various types of pickers are available to accommodate different needs and use cases. "
179
+ },
180
+ {
181
+ "type": "section",
182
+ "title": "Picker Types Examples",
183
+ "content": [
184
+ {
185
+ "value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=4415-185650&embed-host=share"
186
+ }
187
+ ]
188
+ },
189
+ {
190
+ "type": "table",
191
+ "columns": ["State/Type/Preset", "Preview"],
192
+ "items": [
193
+ {
194
+ "title": "Default",
195
+ "content": [
196
+ {
197
+ "flexed": true,
198
+ "snippet": "<Picker preset='outline' placeholder='select' items={[{label: 'Selected Value', value: 1}]} value={1} trailingAccessory={<Icon source={Assets.icons.demo.chevronDown}/>}/>",
199
+ "props": {
200
+ "preset": "outline",
201
+ "label": "Label",
202
+ "placeholder": "Select"
203
+ }
204
+ }
205
+ ]
206
+ },
207
+ {
208
+ "title": "Value selected + icon prefix ",
209
+ "content": [
210
+ {
211
+ "flexed": true,
212
+ "snippet": "<Picker preset='outline' placeholder='select' leadingAccessory={<Icon source={Assets.icons.demo.star} marginR-s2/>} trailingAccessory={<Icon source={Assets.icons.demo.chevronDown}/>} items={[{label: 'Selected Value', value: 1}]} value={1}/>"
213
+ }
214
+ ]
215
+ },
216
+ {
217
+ "title": "Disabled",
218
+ "content": [
219
+ {
220
+ "flexed": true,
221
+ "snippet": "<Picker preset='outline' label='Label' placeholder='Select' editable={false} trailingAccessory={<Icon source={Assets.icons.demo.chevronDown}/>} />"
222
+ }
223
+ ]
224
+ },
225
+ {
226
+ "title": "Validation error (value not selected)",
227
+ "content": [
228
+ {
229
+ "flexed": true,
230
+ "snippet": "<Picker preset='outline' label='Label' placeholder='Select' validationMessage='Validation Message' trailingAccessory={<Icon source={Assets.icons.demo.chevronDown}/>} />"
231
+ }
232
+ ]
233
+ }
234
+ ],
235
+ "title": "Form Field"
236
+ },
237
+ {
238
+ "type": "table",
239
+ "columns": ["State/Type/Preset", "Preview"],
240
+ "items": [
241
+ {
242
+ "title": "Default",
243
+ "content": [
244
+ {
245
+ "props": {
246
+ "items": [
247
+ {
248
+ "label": "Selected Value",
249
+ "value": 1
250
+ }
251
+ ],
252
+ "value": 1,
253
+ "fieldType": "filter"
254
+ }
255
+ }
256
+ ]
257
+ },
258
+ {
259
+ "title": "With label",
260
+ "content": [
261
+ {
262
+ "props": {
263
+ "label": "Label: ",
264
+ "items": [
265
+ {
266
+ "label": "Selected Value",
267
+ "value": 1
268
+ }
269
+ ],
270
+ "value": 1,
271
+ "fieldType": "filter"
272
+ }
273
+ }
274
+ ]
275
+ },
276
+ {
277
+ "title": "Multiple values selected",
278
+ "content": [
279
+ {
280
+ "props": {
281
+ "mode": "MULTI",
282
+ "items": [
283
+ {
284
+ "label": "Value 1",
285
+ "value": 1
286
+ },
287
+ {
288
+ "label": "Value 2",
289
+ "value": 2
290
+ }
291
+ ],
292
+ "value": [1, 2],
293
+ "fieldType": "filter"
294
+ }
295
+ }
296
+ ]
297
+ }
298
+ ],
299
+ "title": "Filter Field"
300
+ },
301
+ {
302
+ "type": "table",
303
+ "columns": ["State/Type/Preset", "Preview"],
304
+ "items": [
305
+ {
306
+ "title": "Default",
307
+ "content": [
308
+ {
309
+ "background": "#E8ECF0",
310
+ "flexed": true,
311
+ "snippet": "<Picker label='Label' placeholder='Select' fieldType='settings' containerStyle={{padding: 20, backgroundColor: Colors.$backgroundDefault}}/>"
312
+ }
313
+ ]
314
+ },
315
+ {
316
+ "title": "Value selected + icon prefix ",
317
+ "content": [
318
+ {
319
+ "background": "#E8ECF0",
320
+ "flexed": true,
321
+ "snippet": "<Picker label='Label' placeholder='Select' value={1} fieldType='settings' items={[{label: 'Selected value', value: 1}]} containerStyle={{padding: 20, backgroundColor: Colors.$backgroundDefault}}/>",
322
+ "props": {
323
+ "label": "Label",
324
+ "placeholder": "Select",
325
+ "fieldType": "settings",
326
+ "items": [
327
+ {
328
+ "label": "Selected Value",
329
+ "value": 1
330
+ }
331
+ ],
332
+ "value": 1
333
+ }
334
+ }
335
+ ]
336
+ }
337
+ ],
338
+ "title": "Settings Field"
339
+ },
340
+ {
341
+ "type": "list",
342
+ "items": [
343
+ {
344
+ "title": "Dialog",
345
+ "description": "Recommended for short value lists.",
346
+ "content": [
347
+ {
348
+ "value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=4415-185705&embed-host=share"
349
+ }
350
+ ]
351
+ },
352
+ {
353
+ "title": "Modal",
354
+ "description": "Used for longer lists like country selection, currency selection or a language picker.",
355
+ "content": [
356
+ {
357
+ "value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=4415-185740&embed-host=share"
358
+ }
359
+ ]
360
+ }
361
+ ],
362
+ "layout": "horizontal",
363
+ "title": "Picker Values display options",
364
+ "description": "The Picker component serves as an entry point to a list of selectable values, usually displayed in a modal or a dialog."
365
+ },
366
+ {
367
+ "type": "list",
368
+ "items": [
369
+ {
370
+ "title": "Single selection",
371
+ "description": "Tapping on an item will select it and close the dialog. In scrollable long lists, the selected item will be displayed at the top of the list to stay visible. ",
372
+ "content": [
373
+ {
374
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_values_dialog_single.png"
375
+ }
376
+ ]
377
+ },
378
+ {
379
+ "title": "Multi-select",
380
+ "description": "In multi-select dialogs, a clear CTA for “Done” or “Save” is required to confirm the selection and dismiss the dialog.",
381
+ "content": [
382
+ {
383
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_values_dialog_multiple.png"
384
+ }
385
+ ]
386
+ }
387
+ ],
388
+ "layout": "horizontal",
389
+ "title": "Values displayed in Dialog",
390
+ "description": "The Picker component serves as an entry point to a list of selectable values, usually displayed in a modal or a dialog."
391
+ },
392
+ {
393
+ "type": "list",
394
+ "items": [
395
+ {
396
+ "title": "Maximum Selected",
397
+ "description": "When the user reaches the limited amount of options allowed to select, the non-selected options will become disabled to restrict the user from selecting more options.",
398
+ "content": [
399
+ {
400
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_dialog_states_max.png"
401
+ }
402
+ ]
403
+ },
404
+ {
405
+ "title": "Validation Error",
406
+ "description": "markdown:Product can set the minimum amount for the selected options. If the user selects less options than the minimum: \n- Display a validation error in the picker header. The error text should explain the user should select at least one option.\n- The dialog CTA will become disabled.\n- If the user will close the dialog, the changes won’t be saved.\n- When the user selects the minimum required options, the validation error will disappear and the CTA will become active.",
407
+ "content": [
408
+ {
409
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_dialog_states_validation.png"
410
+ }
411
+ ]
412
+ },
413
+ {
414
+ "title": "Loading Data",
415
+ "description": "If the data can't be loaded before opening the dialog, a Loader should be shown to let the user know that content is being fetched.\nThe search input is hidden while loading.\nSince the number of items to be loaded is unpredictable, a fixed spacing of 120px below and above the loader has been set.",
416
+ "content": [
417
+ {
418
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_dialog_states_loading.png"
419
+ }
420
+ ]
421
+ }
422
+ ],
423
+ "title": "Dialog States",
424
+ "layout": "horizontal"
425
+ },
426
+ {
427
+ "type": "list",
428
+ "items": [
429
+ {
430
+ "title": "Single selection",
431
+ "description": "Tapping on one of the list items will select it and close the modal. The CTA is optional and disabled by default. It can be added in cases where users might not expect or want the modal to auto-dismiss upon selection.\nThe selected Item is hoisted on top of long lists by default (placed above other values). This can also be set for short lists.\nA search bar can be added on top of the values list.",
432
+ "content": [
433
+ {
434
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_modal_single.png"
435
+ }
436
+ ]
437
+ },
438
+ {
439
+ "title": "Multi-select",
440
+ "description": "In multi-selection dialogs, a CTA for “Done” or “Save” is required to confirm the selection and dismiss the modal.",
441
+ "content": [
442
+ {
443
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_modal_multiple.png"
444
+ }
445
+ ]
446
+ },
447
+ {
448
+ "title": "Select all",
449
+ "description": "Providing a clear “select all” action is a good practice. In case all items are selected, display a “clear all” action. Make sure items number is clearly displayed according to the selection.",
450
+ "content": [
451
+ {
452
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_modal_selectAll.png"
453
+ }
454
+ ]
455
+ },
456
+ {
457
+ "title": "Select all checkbox",
458
+ "description": "In some cases, using checkbox for the “select all” action will be more appropriate. Note that “select all” checkbox can use an “indeterminate” state, if needed. \nMake sure that selected items number is clearly displayed. ",
459
+ "content": [
460
+ {
461
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_modal_selectAll_checkbox.png"
462
+ }
463
+ ]
464
+ },
465
+ {
466
+ "title": "Loading Data",
467
+ "description": "If the data can't be loaded prior to opening the modal, a Loader should be shown, indicating that content is being fetched.\nSearch input is hidden while loading, and the loader is aligned to the center of the screen.",
468
+ "content": [
469
+ {
470
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_modal_loading.png"
471
+ }
472
+ ]
473
+ }
474
+ ],
475
+ "layout": "horizontal",
476
+ "title": "Values displayed in Modal",
477
+ "description": "This type of selection list is used for long lists, e.g. contacts, countries and currencies."
478
+ },
479
+ {
480
+ "type": "section",
481
+ "title": "Picker Presets",
482
+ "description": "Pickers allow selection of an option/value or multiple options/values from a list. Pickers can be used in forms, settings screens or as part of an interactive flow. ",
483
+ "content": [
484
+ {
485
+ "value": "https://embed.figma.com/design/xFjvYNkGTmYTGYMLrmz9Ir/Guidelines-to-Docs?node-id=4418-192956&embed-host=share"
486
+ }
487
+ ]
488
+ },
489
+ {
490
+ "type": "section",
491
+ "title": "Spec",
492
+ "content": [
493
+ {
494
+ "value": "https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/mads-docs-assets/assets/Components%20Docs/Picker/picker_spec.png"
495
+ }
496
+ ]
497
+ }
498
+ ]
499
+ }
500
+ ]
501
+ }
120
502
  }
@@ -1,6 +1,6 @@
1
1
  import { RefObject } from 'react';
2
2
  import { PickerProps, PickerValue, PickerSingleValue, PickerMultiValue } from '../types';
3
- interface UsePickerSelectionProps extends Pick<PickerProps, 'migrate' | 'value' | 'onChange' | 'getItemValue' | 'topBarProps' | 'mode'> {
3
+ interface UsePickerSelectionProps extends Pick<PickerProps, 'migrate' | 'value' | 'onChange' | 'getItemValue' | 'topBarProps' | 'mode' | 'items'> {
4
4
  pickerExpandableRef: RefObject<any>;
5
5
  setSearchValue: (searchValue: string) => void;
6
6
  }
@@ -9,5 +9,8 @@ declare const usePickerSelection: (props: UsePickerSelectionProps) => {
9
9
  onDoneSelecting: (item: PickerValue) => void;
10
10
  toggleItemSelection: (item: PickerSingleValue) => void;
11
11
  cancelSelect: () => void;
12
+ areAllItemsSelected: boolean;
13
+ selectedCount: number;
14
+ toggleAllItemsSelection: (selectAll: boolean) => void;
12
15
  };
13
16
  export default usePickerSelection;
@@ -1,6 +1,6 @@
1
1
  import _xor from "lodash/xor";
2
2
  import _xorBy from "lodash/xorBy";
3
- import { useCallback, useState, useEffect } from 'react';
3
+ import { useCallback, useState, useEffect, useMemo } from 'react';
4
4
  import { PickerModes } from "../types";
5
5
  const usePickerSelection = props => {
6
6
  const {
@@ -11,7 +11,8 @@ const usePickerSelection = props => {
11
11
  pickerExpandableRef,
12
12
  getItemValue,
13
13
  setSearchValue,
14
- mode
14
+ mode,
15
+ items
15
16
  } = props;
16
17
  const [multiDraftValue, setMultiDraftValue] = useState(value);
17
18
  const [multiFinalValue, setMultiFinalValue] = useState(value);
@@ -43,11 +44,26 @@ const usePickerSelection = props => {
43
44
  pickerExpandableRef.current?.closeExpandable?.();
44
45
  topBarProps?.onCancel?.();
45
46
  }, [multiFinalValue, topBarProps]);
47
+ const availableItems = useMemo(() => {
48
+ return items?.filter(item => !item.disabled).map(item => item.value) || [];
49
+ }, [items]);
50
+ const areAllItemsSelected = useMemo(() => {
51
+ return multiDraftValue?.length === availableItems.length;
52
+ }, [multiDraftValue, availableItems]);
53
+ const selectedCount = useMemo(() => {
54
+ return multiDraftValue?.length;
55
+ }, [multiDraftValue]);
56
+ const toggleAllItemsSelection = useCallback(selectAll => {
57
+ setMultiDraftValue(selectAll ? availableItems : []);
58
+ }, [availableItems]);
46
59
  return {
47
60
  multiDraftValue,
48
61
  onDoneSelecting,
49
62
  toggleItemSelection,
50
- cancelSelect
63
+ cancelSelect,
64
+ areAllItemsSelected,
65
+ selectedCount,
66
+ toggleAllItemsSelection
51
67
  };
52
68
  };
53
69
  export default usePickerSelection;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PickerItem from './PickerItem';
3
3
  import { extractPickerItems } from './PickerPresenter';
4
- import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from './types';
4
+ import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectionStatusProps } from './types';
5
5
  type PickerStatics = {
6
6
  Item: typeof PickerItem;
7
7
  modes: typeof PickerModes;
@@ -9,7 +9,7 @@ type PickerStatics = {
9
9
  extractPickerItems: typeof extractPickerItems;
10
10
  };
11
11
  declare const Picker: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>>;
12
- export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods };
12
+ export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectionStatusProps };
13
13
  export { Picker };
14
14
  declare const _default: React.ForwardRefExoticComponent<PickerProps & React.RefAttributes<unknown>> & PickerStatics;
15
15
  export default _default;
@@ -18,7 +18,7 @@ import useFieldType from "./helpers/useFieldType";
18
18
  import useNewPickerProps from "./helpers/useNewPickerProps";
19
19
  // import usePickerMigrationWarnings from './helpers/usePickerMigrationWarnings';
20
20
  import { extractPickerItems } from "./PickerPresenter";
21
- import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from "./types";
21
+ import { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectionStatusProps } from "./types";
22
22
  const DEFAULT_DIALOG_PROPS = {
23
23
  bottom: true,
24
24
  width: '100%'
@@ -58,6 +58,7 @@ const Picker = React.forwardRef((props, ref) => {
58
58
  showLoader,
59
59
  customLoaderElement,
60
60
  renderCustomTopElement,
61
+ selectionStatus,
61
62
  ...others
62
63
  } = themeProps;
63
64
  const {
@@ -101,7 +102,10 @@ const Picker = React.forwardRef((props, ref) => {
101
102
  multiDraftValue,
102
103
  onDoneSelecting,
103
104
  toggleItemSelection,
104
- cancelSelect
105
+ cancelSelect,
106
+ areAllItemsSelected,
107
+ selectedCount,
108
+ toggleAllItemsSelection
105
109
  } = usePickerSelection({
106
110
  migrate,
107
111
  value,
@@ -110,7 +114,8 @@ const Picker = React.forwardRef((props, ref) => {
110
114
  getItemValue,
111
115
  topBarProps,
112
116
  setSearchValue,
113
- mode
117
+ mode,
118
+ items
114
119
  });
115
120
  const {
116
121
  label,
@@ -154,9 +159,12 @@ const Picker = React.forwardRef((props, ref) => {
154
159
  getItemLabel,
155
160
  onSelectedLayout: onSelectedItemLayout,
156
161
  renderItem,
157
- selectionLimit
162
+ selectionLimit,
163
+ areAllItemsSelected,
164
+ selectedCount,
165
+ toggleAllItemsSelection
158
166
  };
159
- }, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting]);
167
+ }, [migrate, mode, value, multiDraftValue, renderItem, getItemValue, getItemLabel, selectionLimit, onSelectedItemLayout, toggleItemSelection, onDoneSelecting, areAllItemsSelected, selectedCount, toggleAllItemsSelection]);
160
168
  const renderPickerItem = useCallback((item, index) => {
161
169
  return <PickerItem key={`${index}-${item.value}`} {...item} />;
162
170
  }, []);
@@ -201,7 +209,7 @@ const Picker = React.forwardRef((props, ref) => {
201
209
  ...topBarProps,
202
210
  onCancel: cancelSelect,
203
211
  onDone: mode === PickerModes.MULTI ? () => onDoneSelecting(multiDraftValue) : undefined
204
- }} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement}>
212
+ }} showSearch={showSearch} searchStyle={searchStyle} searchPlaceholder={searchPlaceholder} onSearchChange={_onSearchChange} renderCustomSearch={renderCustomSearch} renderHeader={renderHeader} listProps={listProps} useSafeArea={useSafeArea} showLoader={showLoader} customLoaderElement={customLoaderElement} renderCustomTopElement={renderCustomTopElement} selectionStatus={selectionStatus}>
205
213
  {filteredItems}
206
214
  </PickerItemsList>;
207
215
  }, [testID, mode, useDialog, selectedItemPosition, topBarProps, cancelSelect, onDoneSelecting, multiDraftValue, showSearch, searchStyle, searchPlaceholder, _onSearchChange, renderCustomSearch, renderHeader, listProps, filteredItems, useSafeArea, useWheelPicker, items, showLoader]);
@@ -221,6 +229,6 @@ Picker.modes = PickerModes;
221
229
  Picker.fieldTypes = PickerFieldTypes;
222
230
  // @ts-expect-error
223
231
  Picker.extractPickerItems = extractPickerItems;
224
- export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods };
232
+ export { PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectionStatusProps };
225
233
  export { Picker }; // For tests
226
234
  export default Picker;
@@ -4,6 +4,8 @@ import { ExpandableOverlayProps, ExpandableOverlayMethods } from '../../incubato
4
4
  import { ModalTopBarProps } from '../modal/TopBar';
5
5
  import { TextFieldMethods, TextFieldProps } from '../textField';
6
6
  import { TouchableOpacityProps } from '../touchableOpacity';
7
+ import { ButtonProps } from '../button';
8
+ import { CheckboxProps } from '../checkbox';
7
9
  export declare enum PickerModes {
8
10
  SINGLE = "SINGLE",
9
11
  MULTI = "MULTI"
@@ -147,6 +149,44 @@ type PickerExpandableOverlayProps = {
147
149
  */
148
150
  enableModalBlur?: boolean;
149
151
  };
152
+ interface PickerSelectionStatusLabelData {
153
+ selectedCount: number;
154
+ areAllItemsSelected: boolean;
155
+ }
156
+ export type ButtonSelectionStatus = {
157
+ /**
158
+ * Select all element type
159
+ */
160
+ selectAllType?: 'button';
161
+ /**
162
+ * Button props
163
+ */
164
+ buttonProps?: ButtonProps;
165
+ };
166
+ export type CheckboxSelectionStatus = {
167
+ /**
168
+ * Select all element type
169
+ */
170
+ selectAllType?: 'checkbox';
171
+ /**
172
+ * Checkbox props
173
+ */
174
+ checkboxProps?: CheckboxProps;
175
+ };
176
+ export type PickerSelectionStatusProps = {
177
+ /**
178
+ * A function that generates a label based on the selected items' count and status
179
+ */
180
+ getLabel?: (data: PickerSelectionStatusLabelData) => string;
181
+ /**
182
+ * Custom container style
183
+ */
184
+ containerStyle?: StyleProp<ViewStyle>;
185
+ /**
186
+ * Control weather to show the label or not
187
+ */
188
+ showLabel?: boolean;
189
+ } & (ButtonSelectionStatus | CheckboxSelectionStatus);
150
190
  export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & PickerPropsDeprecation & PickerExpandableOverlayProps & PickerListProps & {
151
191
  /**
152
192
  * Use dialog instead of modal picker
@@ -193,6 +233,10 @@ export type PickerBaseProps = Omit<TextFieldProps, 'value' | 'onChange'> & Picke
193
233
  * Render custom top element
194
234
  */
195
235
  renderCustomTopElement?: (value?: PickerValue) => React.ReactElement;
236
+ /**
237
+ * Selection status bar props
238
+ */
239
+ selectionStatus?: PickerSelectionStatusProps;
196
240
  /**
197
241
  * Add onPress callback for when pressing the picker
198
242
  */
@@ -286,8 +330,11 @@ export interface PickerContextProps extends Pick<PickerProps, 'migrate' | 'value
286
330
  isMultiMode: boolean;
287
331
  onSelectedLayout: (event: any) => any;
288
332
  selectionLimit: PickerProps['selectionLimit'];
333
+ areAllItemsSelected: boolean;
334
+ selectedCount: number;
335
+ toggleAllItemsSelection?: (selectAll: boolean) => void;
289
336
  }
290
- export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'children' | 'useWheelPicker' | 'useDialog' | 'mode' | 'testID'> & {
337
+ export type PickerItemsListProps = Pick<PropsWithChildren<PickerProps>, 'topBarProps' | 'listProps' | 'renderHeader' | 'useSafeArea' | 'showLoader' | 'customLoaderElement' | 'renderCustomTopElement' | 'selectionStatus' | 'showSearch' | 'searchStyle' | 'searchPlaceholder' | 'onSearchChange' | 'renderCustomSearch' | 'children' | 'useWheelPicker' | 'useDialog' | 'mode' | 'testID'> & {
291
338
  items?: {
292
339
  value: any;
293
340
  label: any;
@@ -102,7 +102,6 @@
102
102
  "title": "Generic",
103
103
  "content": [
104
104
  {
105
- "component": "Incubator.Toast",
106
105
  "props": {
107
106
  "visible": true,
108
107
  "message": "Mika Or was saved to contacts.",
@@ -115,7 +114,6 @@
115
114
  "title": "Success",
116
115
  "content": [
117
116
  {
118
- "component": "Incubator.Toast",
119
117
  "props": {
120
118
  "visible": true,
121
119
  "message": "Post published.",
@@ -128,7 +126,6 @@
128
126
  "title": "Validation",
129
127
  "content": [
130
128
  {
131
- "component": "Incubator.Toast",
132
129
  "props": {
133
130
  "visible": true,
134
131
  "message": "Enter a card number.",
@@ -141,7 +138,6 @@
141
138
  "title": "Offline Error",
142
139
  "content": [
143
140
  {
144
- "component": "Incubator.Toast",
145
141
  "props": {
146
142
  "visible": true,
147
143
  "message": "This action is not available offline.",
@@ -161,7 +157,6 @@
161
157
  "title": "None",
162
158
  "content": [
163
159
  {
164
- "component": "Incubator.Toast",
165
160
  "props": {
166
161
  "visible": true,
167
162
  "message": "Action completed."
@@ -181,7 +176,6 @@
181
176
  "title": "With loader",
182
177
  "content": [
183
178
  {
184
- "component": "Incubator.Toast",
185
179
  "props": {
186
180
  "visible": true,
187
181
  "message": "Action completed.",
package/src/index.d.ts CHANGED
@@ -67,7 +67,7 @@ export { default as PanningContext } from './components/panningViews/panningCont
67
67
  export { default as PanningProvider, PanningDirections, PanLocationProps, PanAmountsProps, PanDirectionsProps } from './components/panningViews/panningProvider';
68
68
  export { default as PanResponderView, PanResponderViewProps } from './components/panningViews/panResponderView';
69
69
  export { default as asPanViewConsumer } from './components/panningViews/asPanViewConsumer';
70
- export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from './components/picker';
70
+ export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods, PickerSelectionStatusProps } from './components/picker';
71
71
  export { default as PieChart, type PieChartProps, PieChartSegmentProps } from './components/pieChart';
72
72
  export { default as ProgressBar, ProgressBarProps } from './components/progressBar';
73
73
  export { default as ProgressiveImage, ProgressiveImageProps } from './components/progressiveImage';
package/src/index.js CHANGED
@@ -166,6 +166,7 @@ var _exportNames = {
166
166
  RenderCustomModalProps: true,
167
167
  PickerItemsListProps: true,
168
168
  PickerMethods: true,
169
+ PickerSelectionStatusProps: true,
169
170
  PieChart: true,
170
171
  PieChartSegmentProps: true,
171
172
  ProgressBar: true,
@@ -1110,6 +1111,12 @@ Object.defineProperty(exports, "PickerSearchStyle", {
1110
1111
  return _picker().PickerSearchStyle;
1111
1112
  }
1112
1113
  });
1114
+ Object.defineProperty(exports, "PickerSelectionStatusProps", {
1115
+ enumerable: true,
1116
+ get: function () {
1117
+ return _picker().PickerSelectionStatusProps;
1118
+ }
1119
+ });
1113
1120
  Object.defineProperty(exports, "PickerValue", {
1114
1121
  enumerable: true,
1115
1122
  get: function () {