@vellira-ui/react-native 2.22.0 → 2.22.1

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 (2) hide show
  1. package/dist/index.js +94 -60
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1884,23 +1884,26 @@ var createStyles21 = (theme) => StyleSheet21.create({
1884
1884
  });
1885
1885
 
1886
1886
  // src/primitives/Button/Button.tsx
1887
- import { jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
1887
+ import { Fragment, jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
1888
1888
  var sizeMap = {
1889
1889
  sm: {
1890
1890
  px: 12,
1891
1891
  py: 8,
1892
+ height: 36,
1892
1893
  fontSize: 12,
1893
1894
  iconSize: 16
1894
1895
  },
1895
1896
  md: {
1896
1897
  px: 16,
1897
1898
  py: 12,
1899
+ height: 44,
1898
1900
  fontSize: 14,
1899
1901
  iconSize: 20
1900
1902
  },
1901
1903
  lg: {
1902
1904
  px: 20,
1903
1905
  py: 16,
1906
+ height: 52,
1904
1907
  fontSize: 16,
1905
1908
  iconSize: 24
1906
1909
  }
@@ -1913,6 +1916,10 @@ function Button({
1913
1916
  loading = false,
1914
1917
  loadingText,
1915
1918
  onPress,
1919
+ onFocus,
1920
+ onBlur,
1921
+ onHoverIn,
1922
+ onHoverOut,
1916
1923
  size = "md",
1917
1924
  leftIcon,
1918
1925
  rightIcon,
@@ -1922,13 +1929,13 @@ function Button({
1922
1929
  textStyle,
1923
1930
  accessibilityLabel,
1924
1931
  iconSize,
1925
- testID
1932
+ testID,
1933
+ ...props
1926
1934
  }) {
1927
1935
  const { theme } = useTheme();
1928
1936
  const styles = useThemeStyles(createStyles21);
1929
1937
  const config = sizeMap[size];
1930
1938
  const variantTheme = theme.components.button[color][variant];
1931
- const [isPressed, setIsPressed] = useState7(false);
1932
1939
  const [isHovered, setIsHovered] = useState7(false);
1933
1940
  const [isFocused, setIsFocused] = useState7(false);
1934
1941
  const isDisabled = disabled || loading;
@@ -1938,66 +1945,84 @@ function Button({
1938
1945
  !iconOnly || Boolean(accessibilityLabel),
1939
1946
  "Button: icon-only buttons must provide an accessibilityLabel."
1940
1947
  );
1941
- const stateTheme = isDisabled ? theme.components.button.disabled : isPressed ? variantTheme.pressed : isHovered ? variantTheme.hover : variantTheme.default;
1942
- const contentColor = stateTheme.fg;
1943
1948
  const resolvedIconSize = iconSize ?? config.iconSize;
1944
- const renderIcon = (icon, iconColor) => {
1945
- return cloneElement4(icon, {
1946
- color: iconColor,
1947
- size: resolvedIconSize
1948
- });
1949
+ const handleFocus = (event) => {
1950
+ setIsFocused(true);
1951
+ onFocus?.(event);
1952
+ };
1953
+ const handleBlur = (event) => {
1954
+ setIsFocused(false);
1955
+ onBlur?.(event);
1956
+ };
1957
+ const handleHoverIn = (event) => {
1958
+ setIsHovered(true);
1959
+ onHoverIn?.(event);
1949
1960
  };
1950
- return /* @__PURE__ */ jsxs13(
1961
+ const handleHoverOut = (event) => {
1962
+ setIsHovered(false);
1963
+ onHoverOut?.(event);
1964
+ };
1965
+ const renderIcon = (icon, iconColor) => cloneElement4(icon, {
1966
+ color: iconColor,
1967
+ size: resolvedIconSize
1968
+ });
1969
+ const getInteractionTheme = (pressed) => isDisabled ? theme.components.button.disabled : pressed ? variantTheme.pressed : isHovered ? variantTheme.hover : variantTheme.default;
1970
+ return /* @__PURE__ */ jsx23(
1951
1971
  Pressable11,
1952
1972
  {
1973
+ ...props,
1953
1974
  testID,
1954
1975
  disabled: isDisabled,
1955
1976
  onPress: isDisabled ? void 0 : onPress,
1956
1977
  accessibilityRole: "button",
1957
1978
  accessibilityState: { disabled: isDisabled, busy: loading },
1958
1979
  accessibilityLabel: accessibilityLabel ?? (typeof content === "string" ? content : void 0),
1959
- onBlur: () => setIsFocused(false),
1960
- onFocus: () => setIsFocused(true),
1961
- onHoverIn: () => setIsHovered(true),
1962
- onHoverOut: () => setIsHovered(false),
1963
- onPressIn: () => setIsPressed(true),
1964
- onPressOut: () => setIsPressed(false),
1980
+ onBlur: handleBlur,
1981
+ onFocus: handleFocus,
1982
+ onHoverIn: handleHoverIn,
1983
+ onHoverOut: handleHoverOut,
1965
1984
  style: ({ pressed }) => {
1966
- const pressedTheme = !isDisabled && pressed ? variantTheme.pressed : !isDisabled && isHovered ? variantTheme.hover : stateTheme;
1985
+ const interactionTheme = getInteractionTheme(pressed);
1967
1986
  return [
1968
1987
  styles.button,
1969
1988
  {
1970
- backgroundColor: pressedTheme.bg,
1971
- borderColor: pressedTheme.border,
1972
- paddingHorizontal: iconOnly ? config.py : config.px,
1973
- paddingVertical: config.py
1989
+ backgroundColor: interactionTheme.bg,
1990
+ borderColor: interactionTheme.border,
1991
+ paddingHorizontal: iconOnly ? 0 : config.px,
1992
+ paddingVertical: iconOnly ? 0 : config.py,
1993
+ width: iconOnly ? config.height : void 0,
1994
+ height: iconOnly ? config.height : void 0
1974
1995
  },
1975
- fullWidth && styles.fullWidth,
1996
+ fullWidth && !iconOnly && styles.fullWidth,
1976
1997
  isDisabled && styles.disabled,
1977
1998
  pressed && !isDisabled && styles.pressed,
1978
1999
  isFocused && !isDisabled && styles.focused,
1979
2000
  style
1980
2001
  ];
1981
2002
  },
1982
- children: [
1983
- loading && /* @__PURE__ */ jsx23(ActivityIndicator, { size: "small", color: contentColor }),
1984
- !loading && leftIcon && renderIcon(leftIcon, contentColor),
1985
- content && !iconOnly && /* @__PURE__ */ jsx23(
1986
- Text12,
1987
- {
1988
- style: [
1989
- styles.text,
1990
- {
1991
- fontSize: config.fontSize,
1992
- color: contentColor
1993
- },
1994
- textStyle
1995
- ],
1996
- children: content
1997
- }
1998
- ),
1999
- !loading && rightIcon && renderIcon(rightIcon, contentColor)
2000
- ]
2003
+ children: ({ pressed }) => {
2004
+ const interactionTheme = getInteractionTheme(pressed);
2005
+ const contentColor = interactionTheme.fg;
2006
+ return /* @__PURE__ */ jsxs13(Fragment, { children: [
2007
+ loading && /* @__PURE__ */ jsx23(ActivityIndicator, { size: "small", color: contentColor }),
2008
+ !loading && leftIcon && renderIcon(leftIcon, contentColor),
2009
+ content && !iconOnly && /* @__PURE__ */ jsx23(
2010
+ Text12,
2011
+ {
2012
+ style: [
2013
+ styles.text,
2014
+ {
2015
+ fontSize: config.fontSize,
2016
+ color: contentColor
2017
+ },
2018
+ textStyle
2019
+ ],
2020
+ children: content
2021
+ }
2022
+ ),
2023
+ !loading && rightIcon && renderIcon(rightIcon, contentColor)
2024
+ ] });
2025
+ }
2001
2026
  }
2002
2027
  );
2003
2028
  }
@@ -2157,7 +2182,7 @@ var createStyles23 = (theme) => StyleSheet23.create({
2157
2182
  inputWithRightAdornment: {
2158
2183
  paddingRight: theme.tokens.spacing[5] + 20
2159
2184
  },
2160
- rightAdornment: {
2185
+ rightIcon: {
2161
2186
  position: "absolute",
2162
2187
  right: theme.tokens.spacing[4],
2163
2188
  top: "50%",
@@ -2168,7 +2193,7 @@ var createStyles23 = (theme) => StyleSheet23.create({
2168
2193
  alignItems: "center",
2169
2194
  justifyContent: "center"
2170
2195
  },
2171
- leftAdornment: {
2196
+ leftIcon: {
2172
2197
  position: "absolute",
2173
2198
  left: theme.tokens.spacing[4],
2174
2199
  top: "50%",
@@ -2270,6 +2295,7 @@ var autoCorrectByInputType = {
2270
2295
  var Input = forwardRef2(
2271
2296
  ({
2272
2297
  label,
2298
+ description,
2273
2299
  value,
2274
2300
  defaultValue,
2275
2301
  onChange,
@@ -2280,11 +2306,12 @@ var Input = forwardRef2(
2280
2306
  required = false,
2281
2307
  readOnly = false,
2282
2308
  type = "text",
2283
- leftAdornment,
2284
- rightAdornment,
2285
- leftAdornmentTone = "default",
2286
- rightAdornmentTone = "default",
2309
+ leftIcon,
2310
+ rightIcon,
2311
+ leftIconTone = "default",
2312
+ rightIconTone = "default",
2287
2313
  clearIcon,
2314
+ clearIconTone = "danger",
2288
2315
  iconSize,
2289
2316
  containerStyle,
2290
2317
  inputStyle,
@@ -2337,27 +2364,28 @@ var Input = forwardRef2(
2337
2364
  onClear?.();
2338
2365
  };
2339
2366
  const showClearButton = clearable && hasValue && !disabled && !readOnly;
2340
- const showRightIcon = !showClearButton && Boolean(rightAdornment);
2341
- const leftIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon[leftAdornmentTone];
2342
- const rightIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon[rightAdornmentTone];
2343
- const clearIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon.danger;
2367
+ const showRightIcon = !showClearButton && Boolean(rightIcon);
2368
+ const leftIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon[leftIconTone];
2369
+ const rightIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon[rightIconTone];
2370
+ const clearIconColor = disabled ? theme.components.input.disabled.icon : theme.components.input.icon[clearIconTone];
2344
2371
  return /* @__PURE__ */ jsx25(
2345
2372
  FormField,
2346
2373
  {
2347
2374
  label,
2375
+ description,
2348
2376
  error,
2349
2377
  required,
2350
2378
  disabled,
2351
2379
  style: containerStyle,
2352
2380
  children: /* @__PURE__ */ jsxs15(View20, { style: styles.inputWrapper, children: [
2353
- leftAdornment && /* @__PURE__ */ jsx25(
2381
+ leftIcon && /* @__PURE__ */ jsx25(
2354
2382
  View20,
2355
2383
  {
2356
2384
  pointerEvents: "none",
2357
- style: styles.leftAdornment,
2385
+ style: styles.leftIcon,
2358
2386
  accessibilityElementsHidden: true,
2359
2387
  importantForAccessibility: "no",
2360
- children: cloneElement5(leftAdornment, {
2388
+ children: cloneElement5(leftIcon, {
2361
2389
  color: leftIconColor,
2362
2390
  size: resolvedIconSize
2363
2391
  })
@@ -2389,7 +2417,7 @@ var Input = forwardRef2(
2389
2417
  styles.input,
2390
2418
  styles[size],
2391
2419
  inputStyle,
2392
- leftAdornment && styles.inputWithLeftAdornment,
2420
+ leftIcon && styles.inputWithLeftAdornment,
2393
2421
  (showRightIcon || showClearButton) && styles.inputWithRightAdornment,
2394
2422
  isFocused && !disabled && !readOnly && styles.focused,
2395
2423
  error && styles.error,
@@ -2410,16 +2438,22 @@ var Input = forwardRef2(
2410
2438
  children: clearIcon ? cloneElement5(clearIcon, {
2411
2439
  color: clearIconColor,
2412
2440
  size: resolvedIconSize
2413
- }) : /* @__PURE__ */ jsx25(Text14, { style: styles.clearButtonText, children: "\xD7" })
2441
+ }) : /* @__PURE__ */ jsx25(
2442
+ Text14,
2443
+ {
2444
+ style: [styles.clearButtonText, { color: clearIconColor }],
2445
+ children: "\xD7"
2446
+ }
2447
+ )
2414
2448
  }
2415
- ) : showRightIcon && rightAdornment && /* @__PURE__ */ jsx25(
2449
+ ) : showRightIcon && rightIcon && /* @__PURE__ */ jsx25(
2416
2450
  View20,
2417
2451
  {
2418
2452
  pointerEvents: "none",
2419
- style: styles.rightAdornment,
2453
+ style: styles.rightIcon,
2420
2454
  accessibilityElementsHidden: true,
2421
2455
  importantForAccessibility: "no",
2422
- children: cloneElement5(rightAdornment, {
2456
+ children: cloneElement5(rightIcon, {
2423
2457
  color: rightIconColor,
2424
2458
  size: resolvedIconSize
2425
2459
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellira-ui/react-native",
3
- "version": "2.22.0",
3
+ "version": "2.22.1",
4
4
  "description": "React Native components for Vellira Design System",
5
5
  "author": "Roman Bakurov",
6
6
  "license": "MIT",
@@ -35,10 +35,10 @@
35
35
  "react-native": ">=0.81"
36
36
  },
37
37
  "dependencies": {
38
- "@vellira-ui/core": "2.22.0",
39
- "@vellira-ui/icons": "2.22.0",
40
- "@vellira-ui/types": "2.22.0",
41
- "@vellira-ui/tokens": "2.22.0"
38
+ "@vellira-ui/icons": "2.22.1",
39
+ "@vellira-ui/core": "2.22.1",
40
+ "@vellira-ui/types": "2.22.1",
41
+ "@vellira-ui/tokens": "2.22.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react": "^19.2.3",