@vellira-ui/react-native 2.19.6 → 2.20.0

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 (3) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +53 -35
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -47,7 +47,9 @@ export function Example() {
47
47
  <View style={{ gap: 16 }}>
48
48
  <Input label='Email' value={email} onChange={setEmail} />
49
49
  <Checkbox label='Accept terms' />
50
- <Button variant='primary'>Continue</Button>
50
+ <Button color='primary' variant='solid'>
51
+ Continue
52
+ </Button>
51
53
  </View>
52
54
  );
53
55
  }
package/dist/index.js CHANGED
@@ -1829,7 +1829,7 @@ Tooltip.displayName = "Tooltip";
1829
1829
 
1830
1830
  // src/primitives/Button/Button.tsx
1831
1831
  import { cloneElement as cloneElement4, useState as useState7 } from "react";
1832
- import { Pressable as Pressable11, Text as Text12 } from "react-native";
1832
+ import { ActivityIndicator, Pressable as Pressable11, Text as Text12 } from "react-native";
1833
1833
 
1834
1834
  // src/primitives/Button/Button.styles.ts
1835
1835
  import { StyleSheet as StyleSheet21 } from "react-native";
@@ -1841,7 +1841,7 @@ var createStyles21 = (theme) => StyleSheet21.create({
1841
1841
  justifyContent: "center",
1842
1842
  gap: 8,
1843
1843
  borderRadius: theme.tokens.radius.md,
1844
- borderWidth: 0
1844
+ borderWidth: 1
1845
1845
  },
1846
1846
  fullWidth: {
1847
1847
  alignSelf: "stretch",
@@ -1851,13 +1851,15 @@ var createStyles21 = (theme) => StyleSheet21.create({
1851
1851
  fontFamily: theme.tokens.typography.family.regular,
1852
1852
  fontWeight: fontWeight3(theme.tokens.typography.weight.regular),
1853
1853
  lineHeight: theme.tokens.typography.lineHeight.md,
1854
- // Кнопка сама задает цвет текста через props,
1855
- // поэтому это значение используется как fallback.
1856
- color: theme.components.button.primary.default.fg
1854
+ // Fallback color.
1855
+ color: theme.components.button.primary.solid.default.fg
1856
+ },
1857
+ spinner: {
1858
+ fontSize: 12,
1859
+ lineHeight: theme.tokens.typography.lineHeight.md
1857
1860
  },
1858
1861
  disabled: {
1859
- borderColor: theme.components.button.disabled.border,
1860
- borderWidth: 1
1862
+ borderColor: theme.components.button.disabled.border
1861
1863
  },
1862
1864
  pressed: {
1863
1865
  transform: [{ scale: 0.98 }]
@@ -1888,61 +1890,76 @@ var sizeMap = {
1888
1890
  };
1889
1891
  function Button({
1890
1892
  children,
1893
+ color = "primary",
1894
+ variant = "solid",
1891
1895
  disabled = false,
1896
+ loading = false,
1897
+ loadingText,
1892
1898
  onPress,
1893
- variant = "primary",
1894
1899
  size = "md",
1895
1900
  leftIcon,
1896
1901
  rightIcon,
1897
1902
  fullWidth = false,
1903
+ iconOnly: iconOnlyProp = false,
1898
1904
  style,
1905
+ textStyle,
1899
1906
  accessibilityLabel,
1900
- iconSize
1907
+ iconSize,
1908
+ testID
1901
1909
  }) {
1902
1910
  const { theme } = useTheme();
1903
1911
  const styles = useThemeStyles(createStyles21);
1904
1912
  const config = sizeMap[size];
1905
- const variantTheme = theme.components.button[variant];
1913
+ const variantTheme = theme.components.button[color][variant];
1906
1914
  const [isPressed, setIsPressed] = useState7(false);
1907
- const iconOnly = !children && Boolean(leftIcon || rightIcon);
1915
+ const isDisabled = disabled || loading;
1916
+ const iconOnly = iconOnlyProp || !children && Boolean(leftIcon || rightIcon);
1917
+ const content = loading && loadingText ? loadingText : children;
1908
1918
  if (iconOnly && !accessibilityLabel) {
1909
1919
  console.warn(
1910
1920
  "Vellira Button: icon-only buttons must provide an accessibilityLabel."
1911
1921
  );
1912
1922
  }
1913
- const contentColor = disabled ? theme.components.button.disabled.fg : isPressed ? variantTheme.pressed.fg : variantTheme.default.fg;
1923
+ const stateTheme = isDisabled ? theme.components.button.disabled : isPressed ? variantTheme.pressed : variantTheme.default;
1924
+ const contentColor = stateTheme.fg;
1914
1925
  const resolvedIconSize = iconSize ?? config.iconSize;
1915
- const renderIcon = (icon, color) => {
1926
+ const renderIcon = (icon, iconColor) => {
1916
1927
  return cloneElement4(icon, {
1917
- color,
1928
+ color: iconColor,
1918
1929
  size: resolvedIconSize
1919
1930
  });
1920
1931
  };
1921
1932
  return /* @__PURE__ */ jsxs13(
1922
1933
  Pressable11,
1923
1934
  {
1924
- disabled,
1925
- onPress,
1935
+ testID,
1936
+ disabled: isDisabled,
1937
+ onPress: isDisabled ? void 0 : onPress,
1926
1938
  accessibilityRole: "button",
1927
- accessibilityState: { disabled },
1928
- accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : void 0),
1939
+ accessibilityState: { disabled: isDisabled, busy: loading },
1940
+ accessibilityLabel: accessibilityLabel ?? (typeof content === "string" ? content : void 0),
1929
1941
  onPressIn: () => setIsPressed(true),
1930
1942
  onPressOut: () => setIsPressed(false),
1931
- style: ({ pressed }) => [
1932
- styles.button,
1933
- {
1934
- backgroundColor: disabled ? theme.components.button.disabled.bg : pressed ? variantTheme.pressed.bg : variantTheme.default.bg,
1935
- paddingHorizontal: iconOnly ? config.py : config.px,
1936
- paddingVertical: config.py
1937
- },
1938
- fullWidth && styles.fullWidth,
1939
- disabled && styles.disabled,
1940
- pressed && !disabled && styles.pressed,
1941
- style
1942
- ],
1943
+ style: ({ pressed }) => {
1944
+ const pressedTheme = !isDisabled && pressed ? variantTheme.pressed : stateTheme;
1945
+ return [
1946
+ styles.button,
1947
+ {
1948
+ backgroundColor: pressedTheme.bg,
1949
+ borderColor: pressedTheme.border,
1950
+ paddingHorizontal: iconOnly ? config.py : config.px,
1951
+ paddingVertical: config.py
1952
+ },
1953
+ fullWidth && styles.fullWidth,
1954
+ isDisabled && styles.disabled,
1955
+ pressed && !isDisabled && styles.pressed,
1956
+ style
1957
+ ];
1958
+ },
1943
1959
  children: [
1944
- leftIcon && renderIcon(leftIcon, contentColor),
1945
- children && /* @__PURE__ */ jsx23(
1960
+ loading && /* @__PURE__ */ jsx23(ActivityIndicator, { size: "small", color: contentColor }),
1961
+ !loading && leftIcon && renderIcon(leftIcon, contentColor),
1962
+ content && !iconOnly && /* @__PURE__ */ jsx23(
1946
1963
  Text12,
1947
1964
  {
1948
1965
  style: [
@@ -1950,12 +1967,13 @@ function Button({
1950
1967
  {
1951
1968
  fontSize: config.fontSize,
1952
1969
  color: contentColor
1953
- }
1970
+ },
1971
+ textStyle
1954
1972
  ],
1955
- children
1973
+ children: content
1956
1974
  }
1957
1975
  ),
1958
- rightIcon && renderIcon(rightIcon, contentColor)
1976
+ !loading && rightIcon && renderIcon(rightIcon, contentColor)
1959
1977
  ]
1960
1978
  }
1961
1979
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellira-ui/react-native",
3
- "version": "2.19.6",
3
+ "version": "2.20.0",
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.19.6",
39
- "@vellira-ui/tokens": "2.19.6",
40
- "@vellira-ui/icons": "2.19.6",
41
- "@vellira-ui/types": "2.19.6"
38
+ "@vellira-ui/core": "2.20.0",
39
+ "@vellira-ui/icons": "2.20.0",
40
+ "@vellira-ui/types": "2.20.0",
41
+ "@vellira-ui/tokens": "2.20.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react": "^19.2.3",