@dropi/react-native-design-system 0.3.25 → 0.3.26

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.
@@ -14,7 +14,8 @@ type MultipleSelectProps = {
14
14
  errorMessage?: string;
15
15
  title?: string;
16
16
  disabled?: boolean;
17
+ searchFilter?: boolean;
17
18
  onRestablish?: () => void;
18
19
  };
19
- export declare const MultipleSelect: ({ options, selectedValues, onChange, label, placeholder, helper, hasError, errorMessage, title, disabled, onRestablish, }: MultipleSelectProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const MultipleSelect: ({ options, selectedValues, onChange, label, placeholder, helper, hasError, errorMessage, title, disabled, searchFilter, onRestablish, }: MultipleSelectProps) => import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
9
9
  var _reactNative2 = _interopRequireDefault(require("dropi-lib-icons/react-native"));
10
10
  var _BottomSheet = require("../BottomSheet");
11
11
  var _atoms = require("../../atoms");
12
+ var _Search = require("../Search");
12
13
  var _constants = require("../../constants");
13
14
  var _reactNativeGestureHandler = require("react-native-gesture-handler");
14
15
  var _Checkbox = require("../Checkbox");
@@ -25,11 +26,13 @@ const MultipleSelect = ({
25
26
  errorMessage,
26
27
  title,
27
28
  disabled = false,
29
+ searchFilter = false,
28
30
  onRestablish
29
31
  }) => {
30
32
  const bottomSheetRef = (0, _react.useRef)(null);
31
33
  const [isFocus, setIsFocus] = (0, _react.useState)(false);
32
34
  const [draftSelection, setDraftSelection] = (0, _react.useState)([]);
35
+ const [filterText, setFilterText] = (0, _react.useState)("");
33
36
  const getBorderColor = () => {
34
37
  if (hasError) return _constants.colors["Error-500"].light;
35
38
  if (isFocus) return _constants.colors["Info-500"].light;
@@ -69,6 +72,7 @@ const MultipleSelect = ({
69
72
  const handleDismiss = (0, _react.useCallback)(() => {
70
73
  setIsFocus(false);
71
74
  setDraftSelection([]);
75
+ setFilterText("");
72
76
  }, []);
73
77
  const handleRestablish = (0, _react.useCallback)(() => {
74
78
  if (onRestablish) {
@@ -77,6 +81,10 @@ const MultipleSelect = ({
77
81
  setIsFocus(false);
78
82
  }
79
83
  }, [onRestablish]);
84
+ const filteredOptions = (0, _react.useMemo)(() => {
85
+ if (!searchFilter || !filterText) return options;
86
+ return options.filter(opt => opt.label.toLowerCase().includes(filterText.toLowerCase()));
87
+ }, [options, searchFilter, filterText]);
80
88
  const renderOption = (0, _react.useCallback)(({
81
89
  item
82
90
  }) => {
@@ -179,19 +187,25 @@ const MultipleSelect = ({
179
187
  style: styles.errorText,
180
188
  children: errorMessage
181
189
  })]
182
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_BottomSheet.BottomSheetComponent, {
190
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_BottomSheet.BottomSheetComponent, {
183
191
  ref: bottomSheetRef,
184
192
  title: title ?? label ?? "Seleccionar",
185
193
  snapPoints: ["90%"],
186
194
  onDismiss: handleDismiss,
187
195
  footer: footer,
188
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.FlatList, {
189
- data: options,
196
+ children: [searchFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
197
+ style: styles.searchContainer,
198
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Search.Search, {
199
+ filterText: filterText,
200
+ setFilterText: setFilterText
201
+ })
202
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.FlatList, {
203
+ data: filteredOptions,
190
204
  keyExtractor: item => String(item.value),
191
205
  renderItem: renderOption,
192
206
  contentContainerStyle: styles.optionsList,
193
207
  showsVerticalScrollIndicator: false
194
- })
208
+ })]
195
209
  })]
196
210
  });
197
211
  };
@@ -249,6 +263,10 @@ const styles = _reactNative.StyleSheet.create({
249
263
  marginLeft: _constants.spacing["size-1"],
250
264
  flex: 1
251
265
  },
266
+ searchContainer: {
267
+ paddingHorizontal: _constants.spacing["size-5"],
268
+ paddingBottom: _constants.spacing["size-3"]
269
+ },
252
270
  optionsList: {
253
271
  paddingHorizontal: _constants.spacing["size-5"],
254
272
  paddingBottom: _constants.spacing["size-8"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dropi/react-native-design-system",
3
- "version": "0.3.25",
3
+ "version": "0.3.26",
4
4
  "description": "A React Native package built from scratch",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",