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

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.
@@ -8,7 +8,7 @@ type ButtonConfig = {
8
8
  borderColor: string;
9
9
  };
10
10
  interface Props extends TouchableOpacityProps {
11
- label: string;
11
+ label?: string;
12
12
  variant: Variant;
13
13
  size: Size;
14
14
  preIcon?: IconName;
@@ -27,9 +27,9 @@ const DefaultButton = ({
27
27
  return "m";
28
28
  };
29
29
  const getIconSize = () => {
30
- if (size === "small") return 12;
31
- if (size === "large") return 16;
32
- return 14;
30
+ if (size === "small") return _constants.sizes.s;
31
+ if (size === "large") return _constants.sizes.l;
32
+ return _constants.sizes.m;
33
33
  };
34
34
  const getTabletIconSize = () => {
35
35
  if (size === "small") return 20;
@@ -99,20 +99,21 @@ const DefaultButton = ({
99
99
  style: {
100
100
  backgroundColor: currentButtonConfig.backgroundColor,
101
101
  paddingVertical: getPaddingVertical(),
102
- paddingHorizontal: _constants.spacing["size-4"],
102
+ paddingHorizontal: !label ? getPaddingVertical() : _constants.spacing["size-4"],
103
103
  borderRadius: _constants.radius["border-2"],
104
104
  alignItems: "center",
105
105
  justifyContent: "center",
106
106
  opacity: disabled ? 0.5 : 1,
107
107
  borderWidth: 1,
108
108
  borderColor: currentButtonConfig.borderColor,
109
- flexDirection: "row"
109
+ flexDirection: "row",
110
+ alignSelf: !label ? 'flex-start' : 'stretch'
110
111
  },
111
112
  disabled: disabled || isMakingRequest,
112
113
  ...rest,
113
114
  children: [preIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
114
115
  style: {
115
- marginRight: _constants.spacing["size-2"]
116
+ marginRight: label || postIcon ? _constants.spacing["size-2"] : 0
116
117
  },
117
118
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Icon, {
118
119
  name: preIcon,
@@ -121,7 +122,7 @@ const DefaultButton = ({
121
122
  })
122
123
  }), isMakingRequest ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
123
124
  color: currentButtonConfig.labelColor
124
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Label, {
125
+ }) : !!label && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Label, {
125
126
  type: textVariant,
126
127
  style: {
127
128
  color: currentButtonConfig.labelColor
@@ -129,7 +130,7 @@ const DefaultButton = ({
129
130
  children: label
130
131
  }), postIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
131
132
  style: {
132
- marginLeft: _constants.spacing["size-2"]
133
+ marginLeft: label || preIcon ? _constants.spacing["size-2"] : 0
133
134
  },
134
135
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Icon, {
135
136
  name: postIcon,
@@ -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.27",
4
4
  "description": "A React Native package built from scratch",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",