@particle-network/ui-native 0.0.21 → 0.0.23

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.
@@ -7,7 +7,7 @@ import { UXPressable } from "../UXPressable/index.js";
7
7
  import { UXSpinner } from "../UXSpinner/index.js";
8
8
  import { useStyles } from "./button.styles.js";
9
9
  const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
10
- const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth, width, w, h, isIconOnly, children, ...restProps } = props;
10
+ const { style, size, radius, color, variant, onPress, isDisabled, isLoading, startContent, endContent, fullWidth, width, w, h, ph, isIconOnly, children, ...restProps } = props;
11
11
  const handlePress = (e)=>{
12
12
  Keyboard.dismiss();
13
13
  triggerHapticFeedback();
@@ -24,7 +24,8 @@ const UXButton = /*#__PURE__*/ forwardRef((props, ref)=>{
24
24
  isIconOnly,
25
25
  width,
26
26
  w,
27
- h
27
+ h,
28
+ ph
28
29
  });
29
30
  const content = useMemo(()=>{
30
31
  if ('string' == typeof children || 'number' == typeof children) return /*#__PURE__*/ jsx(Text, {
@@ -10,7 +10,7 @@ export declare const useStyles: (props: UXButtonProps) => {
10
10
  paddingVertical: number;
11
11
  height: number | undefined;
12
12
  width: number | "100%" | undefined;
13
- paddingHorizontal: number;
13
+ paddingHorizontal: number | undefined;
14
14
  backgroundColor: string | undefined;
15
15
  borderRadius: number | undefined;
16
16
  borderWidth: number;
@@ -4,7 +4,7 @@ import { useColors, useComponentConfig, useMs, useRadius, useSpacing } from "../
4
4
  import { disabledOpacity } from "../../theme/index.js";
5
5
  const useStyles = (props)=>{
6
6
  const { button: buttonConfig } = useComponentConfig();
7
- const { size = 'md', radius = buttonConfig.defaultProps?.radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, w, h, fullWidth, isIconOnly } = props;
7
+ const { size = 'md', radius = buttonConfig.defaultProps?.radius, color = 'default', variant = 'solid', isDisabled, isLoading, width, w, h, ph, fullWidth, isIconOnly } = props;
8
8
  const { getColor } = useColors();
9
9
  const { getRadius } = useRadius();
10
10
  const { getSpacing } = useSpacing();
@@ -77,12 +77,15 @@ const useStyles = (props)=>{
77
77
  ]);
78
78
  const paddingHorizontal = useMemo(()=>{
79
79
  if (isIconOnly || 'auto' === size || 'text' === variant) return 0;
80
+ if (void 0 !== ph) return getSpacing(ph);
80
81
  return paddingMap[size];
81
82
  }, [
82
83
  size,
83
84
  isIconOnly,
84
85
  variant,
85
- paddingMap
86
+ paddingMap,
87
+ ph,
88
+ getSpacing
86
89
  ]);
87
90
  const textColor = useMemo(()=>{
88
91
  const customColorConfig = buttonConfig?.color?.[color];
@@ -110,7 +113,7 @@ const useStyles = (props)=>{
110
113
  'default',
111
114
  'secondary'
112
115
  ].includes(color)) return getColor(color);
113
- return getColor('bg-300');
116
+ return getColor('bg-200');
114
117
  }
115
118
  if ('flat' === variant) {
116
119
  if (customColorConfig) return `${getColor(customColorConfig.background)}40`;
@@ -118,7 +121,7 @@ const useStyles = (props)=>{
118
121
  if ([
119
122
  'default',
120
123
  'secondary'
121
- ].includes(color)) return `${getColor('bg-300')}40`;
124
+ ].includes(color)) return `${getColor('bg-200')}40`;
122
125
  return `${getColor(color)}20`;
123
126
  }
124
127
  return 'transparent';
@@ -5,6 +5,7 @@ const toast = {
5
5
  UXToast.show({
6
6
  type: 'success',
7
7
  text1: message,
8
+ topOffset: 60,
8
9
  ...options
9
10
  });
10
11
  },
@@ -12,16 +13,18 @@ const toast = {
12
13
  UXToast.show({
13
14
  type: 'error',
14
15
  text1: message,
16
+ topOffset: 60,
15
17
  ...options
16
18
  });
17
19
  },
18
20
  loading: (message, options)=>{
19
- const { visibilityTime = 0, autoHide = !!visibilityTime, ...restOptions } = options ?? {};
21
+ const { visibilityTime = 0, autoHide = !!visibilityTime, topOffset = 60, ...restOptions } = options ?? {};
20
22
  UXToast.show({
21
23
  type: 'loading',
22
24
  text1: message,
23
25
  visibilityTime,
24
26
  autoHide,
27
+ topOffset,
25
28
  ...restOptions
26
29
  });
27
30
  }
@@ -139,13 +139,14 @@ const UXInput = /*#__PURE__*/ forwardRef((props, ref)=>{
139
139
  onFocus: handleFocus,
140
140
  ...restProps
141
141
  }),
142
- renderContent(endContent),
143
- !isClearable || !internalValue || isDisabled || isReadOnly ? null : /*#__PURE__*/ jsx(UXPressable, {
142
+ isClearable && !!internalValue && !isDisabled && !isReadOnly && /*#__PURE__*/ jsx(UXPressable, {
143
+ p: 4,
144
144
  onPress: handleClear,
145
145
  children: /*#__PURE__*/ jsx(CloseIcon, {
146
- size: 16
146
+ style: styles.clearButton
147
147
  })
148
- })
148
+ }),
149
+ renderContent(endContent)
149
150
  ]
150
151
  }),
151
152
  !!renderError && /*#__PURE__*/ jsx(Text, {
@@ -2,12 +2,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
3
3
  import { Platform, TextInput } from "react-native";
4
4
  import { useColors } from "../../hooks/index.js";
5
+ import CloseIcon from "../../icons/CloseIcon.js";
5
6
  import { HStack } from "../layout/HStack.js";
6
7
  import { VStack } from "../layout/VStack.js";
7
8
  import { Text } from "../Text/index.js";
9
+ import { UXPressable } from "../UXPressable/index.js";
8
10
  import { useStyles } from "./styles.js";
9
11
  const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
10
- const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, minValue, maxValue, formatOptions, startContent, endContent, isRequired, isReadOnly, isDisabled, isInvalid: isInvalidProp, autoErrorMessage, allowNegative, label, onChangeText, onValueChange, onFocus, onBlur, ...restProps } = props;
12
+ const { containerStyle, wrapperStyle, inputStyle, value: controlledValue, defaultValue, errorMessage, minValue, maxValue, formatOptions, startContent, endContent, isRequired, isReadOnly, isDisabled, isClearable, isInvalid: isInvalidProp, autoErrorMessage, allowNegative, label, onChangeText, onValueChange, onFocus, onBlur, ...restProps } = props;
11
13
  const { getColor } = useColors();
12
14
  const inputRef = useRef(null);
13
15
  const [internalValue, setInternalValue] = useState(defaultValue ?? NaN);
@@ -139,6 +141,18 @@ const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
139
141
  adjustValueToFractionDigits,
140
142
  onBlur
141
143
  ]);
144
+ const handleClear = useCallback(()=>{
145
+ if (isDisabled || isReadOnly) return;
146
+ setDisplayText('');
147
+ setInternalValue(NaN);
148
+ onChangeText?.('');
149
+ onValueChange?.(NaN);
150
+ }, [
151
+ isDisabled,
152
+ isReadOnly,
153
+ onChangeText,
154
+ onValueChange
155
+ ]);
142
156
  const displayValue = useMemo(()=>{
143
157
  if (isFocused) return displayText;
144
158
  if (isNaN(internalValue)) return '';
@@ -219,6 +233,14 @@ const UXNumberInput = /*#__PURE__*/ forwardRef((props, ref)=>{
219
233
  onFocus: handleFocus,
220
234
  ...restProps
221
235
  }),
236
+ isClearable && !isNaN(internalValue) && !isDisabled && !isReadOnly && /*#__PURE__*/ jsx(UXPressable, {
237
+ p: 4,
238
+ onPress: handleClear,
239
+ children: /*#__PURE__*/ jsx(CloseIcon, {
240
+ style: styles.clearButton,
241
+ color: "secondary"
242
+ })
243
+ }),
222
244
  renderContent(endContent)
223
245
  ]
224
246
  }),
@@ -27,7 +27,8 @@ export declare const useStyles: (props: UseStylesProps) => {
27
27
  textAlign: "right" | "left" | "center";
28
28
  };
29
29
  clearButton: {
30
- padding: number;
30
+ width: number;
31
+ height: number;
31
32
  };
32
33
  };
33
34
  export {};
@@ -102,7 +102,8 @@ const useStyles = (props)=>{
102
102
  textAlign
103
103
  },
104
104
  clearButton: {
105
- padding: ms(4)
105
+ width: fontSize + ms(6),
106
+ height: fontSize + ms(6)
106
107
  }
107
108
  }), [
108
109
  width,
@@ -13,11 +13,11 @@ const defaultComponentConfig = {
13
13
  },
14
14
  color: {
15
15
  default: {
16
- background: 'bg-300',
16
+ background: 'bg-200',
17
17
  text: 'default'
18
18
  },
19
19
  secondary: {
20
- background: 'bg-300',
20
+ background: 'bg-200',
21
21
  text: 'secondary'
22
22
  }
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-native",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "license": "MIT",
5
5
  "main": "./entry.js",
6
6
  "react-native": "./dist/index.js",