@rehagro/ui 1.0.17 → 1.0.18

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.
package/dist/native.mjs CHANGED
@@ -7,11 +7,8 @@ import { Pressable, ActivityIndicator, View, Text, TextInput as TextInput$1, Ima
7
7
  // src/provider/theme.native.ts
8
8
  var DEFAULT_NATIVE_THEME = {
9
9
  primary: "#16a34a",
10
- primaryHover: "#15803d",
11
10
  secondary: "#6b7280",
12
- secondaryHover: "#4b5563",
13
11
  danger: "#dc2626",
14
- dangerHover: "#b91c1c",
15
12
  warning: "#d97706",
16
13
  success: "#16a34a",
17
14
  info: "#0284c7",
@@ -64,6 +61,7 @@ function RehagroNativeProvider({ theme, children }) {
64
61
  return /* @__PURE__ */ jsx(RehagroNativeContext.Provider, { value: resolvedTheme, children });
65
62
  }
66
63
  function darkenColor(hex, factor = 0.2) {
64
+ if (!hex.startsWith("#")) return hex;
67
65
  const clean = hex.replace("#", "");
68
66
  const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
69
67
  const num = parseInt(full, 16);
@@ -101,20 +99,20 @@ var Button = forwardRef(function Button2({
101
99
  const isDisabled = disabled || loading;
102
100
  const preset = isPresetColor(color);
103
101
  const presetBase = {
104
- primary: theme.primary,
105
- secondary: theme.secondary,
106
- danger: theme.danger,
107
- warning: theme.warning,
108
- success: theme.success,
109
- info: theme.info
102
+ primary: theme.primary ?? "#15607A",
103
+ secondary: theme.secondary ?? "#718D44",
104
+ danger: theme.danger ?? "#dc2626",
105
+ warning: theme.warning ?? "#d97706",
106
+ success: theme.success ?? "#16a34a",
107
+ info: theme.info ?? "#0284c7"
110
108
  };
111
109
  const presetHover = {
112
- primary: theme.primaryHover,
113
- secondary: theme.secondaryHover,
114
- danger: theme.dangerHover,
115
- warning: theme.warning,
116
- success: theme.success,
117
- info: theme.infoHover
110
+ primary: theme.primaryHover ?? darkenColor(presetBase.primary),
111
+ secondary: theme.secondaryHover ?? darkenColor(presetBase.secondary),
112
+ danger: theme.dangerHover ?? darkenColor(presetBase.danger),
113
+ warning: theme.warning ?? darkenColor(presetBase.warning),
114
+ success: theme.success ?? darkenColor(presetBase.success),
115
+ info: theme.infoHover ?? darkenColor(presetBase.info)
118
116
  };
119
117
  const colorBase = preset ? presetBase[color] : color;
120
118
  const colorHover = preset ? presetHover[color] : darkenColor(color);
@@ -164,8 +162,8 @@ var Button = forwardRef(function Button2({
164
162
  return { borderColor: "transparent", backgroundColor: "transparent" };
165
163
  };
166
164
  const textColor = (pressed) => {
167
- if (variant === "solid") return theme.surface;
168
- if (variant === "outline") return pressed ? theme.surface : colorBase;
165
+ if (variant === "solid") return theme.surface ?? "#ffffff";
166
+ if (variant === "outline") return pressed ? theme.surface ?? "#ffffff" : colorBase;
169
167
  return colorBase;
170
168
  };
171
169
  return /* @__PURE__ */ jsx(
@@ -176,6 +174,7 @@ var Button = forwardRef(function Button2({
176
174
  accessibilityRole: "button",
177
175
  accessibilityState: { disabled: !!isDisabled, busy: loading },
178
176
  accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : void 0),
177
+ android_ripple: { color: pressedColor ?? colorHover, borderless: false },
179
178
  style: ({ pressed }) => [baseStyle, variantStyle(pressed), style],
180
179
  ...rest,
181
180
  children: ({ pressed }) => /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -183,7 +182,7 @@ var Button = forwardRef(function Button2({
183
182
  ActivityIndicator,
184
183
  {
185
184
  size: "small",
186
- color: variant === "solid" ? theme.surface : colorBase
185
+ color: variant === "solid" ? theme.surface ?? "#ffffff" : colorBase
187
186
  }
188
187
  ),
189
188
  !loading && leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: leftIcon }),
@@ -199,6 +198,16 @@ var Button = forwardRef(function Button2({
199
198
  }
200
199
  );
201
200
  });
201
+ function darkenColor2(hex, factor = 0.2) {
202
+ if (!hex.startsWith("#")) return hex;
203
+ const clean = hex.replace("#", "");
204
+ const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
205
+ const num = parseInt(full, 16);
206
+ const r = Math.max(0, Math.round((num >> 16 & 255) * (1 - factor)));
207
+ const g = Math.max(0, Math.round((num >> 8 & 255) * (1 - factor)));
208
+ const b = Math.max(0, Math.round((num & 255) * (1 - factor)));
209
+ return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
210
+ }
202
211
  var PRESET_COLORS2 = /* @__PURE__ */ new Set([
203
212
  "primary",
204
213
  "secondary",
@@ -238,16 +247,16 @@ var IconButton = forwardRef(function IconButton2({
238
247
  full: 9999
239
248
  };
240
249
  const presetTokens = {
241
- primary: { main: theme.primary, hover: theme.primaryHover },
242
- secondary: { main: theme.secondary, hover: theme.secondaryHover },
243
- danger: { main: theme.danger, hover: theme.dangerHover },
244
- warning: { main: theme.warning, hover: theme.warning },
245
- success: { main: theme.success, hover: theme.success },
246
- info: { main: theme.info, hover: theme.infoHover }
250
+ primary: { main: theme.primary ?? "#15607A", hover: theme.primaryHover ?? darkenColor2(theme.primary ?? "#15607A") },
251
+ secondary: { main: theme.secondary ?? "#718D44", hover: theme.secondaryHover ?? darkenColor2(theme.secondary ?? "#718D44") },
252
+ danger: { main: theme.danger ?? "#dc2626", hover: theme.dangerHover ?? darkenColor2(theme.danger ?? "#dc2626") },
253
+ warning: { main: theme.warning ?? "#d97706", hover: darkenColor2(theme.warning ?? "#d97706") },
254
+ success: { main: theme.success ?? "#16a34a", hover: darkenColor2(theme.success ?? "#16a34a") },
255
+ info: { main: theme.info ?? "#0284c7", hover: theme.infoHover ?? darkenColor2(theme.info ?? "#0284c7") }
247
256
  };
248
257
  const preset = isPresetColor2(color);
249
258
  const main = preset ? presetTokens[color].main : color;
250
- const hover = preset ? presetTokens[color].hover : color;
259
+ const hover = preset ? presetTokens[color].hover : darkenColor2(color);
251
260
  const boxSize = sizePxMap[size];
252
261
  const baseStyle = {
253
262
  width: boxSize,
@@ -268,8 +277,8 @@ var IconButton = forwardRef(function IconButton2({
268
277
  return { borderColor: "transparent", backgroundColor: pressed ? `${main}1a` : "transparent" };
269
278
  };
270
279
  const iconColor = (pressed) => {
271
- if (variant === "solid") return theme.surface;
272
- if (variant === "outline") return pressed ? theme.surface : main;
280
+ if (variant === "solid") return theme.surface ?? "#ffffff";
281
+ if (variant === "outline") return pressed ? theme.surface ?? "#ffffff" : main;
273
282
  return main;
274
283
  };
275
284
  return /* @__PURE__ */ jsx(
@@ -280,6 +289,7 @@ var IconButton = forwardRef(function IconButton2({
280
289
  accessibilityRole: "button",
281
290
  accessibilityState: { disabled: !!isDisabled, busy: loading },
282
291
  accessibilityLabel,
292
+ android_ripple: { color: hover, borderless: false },
283
293
  style: ({ pressed }) => [baseStyle, variantStyle(pressed), style],
284
294
  ...rest,
285
295
  children: ({ pressed }) => loading ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: variant === "solid" ? theme.surface : main }) : /* @__PURE__ */ jsx(View, { style: { tintColor: iconColor(pressed) }, children })
@@ -305,9 +315,9 @@ var TextInput = forwardRef(function TextInput2({
305
315
  const [focused, setFocused] = useState(false);
306
316
  const isDisabled = editable === false;
307
317
  const heightMap = {
308
- sm: theme.inputHeightSm,
309
- md: theme.inputHeightMd,
310
- lg: theme.inputHeightLg
318
+ sm: theme.inputHeightSm ?? 36,
319
+ md: theme.inputHeightMd ?? 44,
320
+ lg: theme.inputHeightLg ?? 52
311
321
  };
312
322
  const paddingMap2 = {
313
323
  sm: 12,
@@ -321,12 +331,12 @@ var TextInput = forwardRef(function TextInput2({
321
331
  };
322
332
  const radiusMap2 = {
323
333
  none: 0,
324
- xxs: theme.radiusXxs,
325
- xs: theme.radiusXs,
326
- sm: theme.radiusSm,
327
- md: theme.radiusMd,
328
- lg: theme.radiusLg,
329
- xl: theme.radiusXl,
334
+ xxs: theme.radiusXxs ?? 4,
335
+ xs: theme.radiusXs ?? 8,
336
+ sm: theme.radiusSm ?? 12,
337
+ md: theme.radiusMd ?? 16,
338
+ lg: theme.radiusLg ?? 24,
339
+ xl: theme.radiusXl ?? 32,
330
340
  full: 9999
331
341
  };
332
342
  const hasError = status === "error" || !!helperText;
@@ -350,7 +360,7 @@ var TextInput = forwardRef(function TextInput2({
350
360
  subtitle && /* @__PURE__ */ jsx(Text, { style: { fontSize: 14, color: theme.textMuted }, children: subtitle })
351
361
  ] }),
352
362
  /* @__PURE__ */ jsxs(View, { style: [containerStyle, style], children: [
353
- leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, style: { width: fontSizeMap[size], height: fontSizeMap[size] }, children: leftIcon }),
363
+ leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: leftIcon }),
354
364
  /* @__PURE__ */ jsx(
355
365
  TextInput$1,
356
366
  {
@@ -376,7 +386,7 @@ var TextInput = forwardRef(function TextInput2({
376
386
  ...rest
377
387
  }
378
388
  ),
379
- rightIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, style: { width: fontSizeMap[size], height: fontSizeMap[size] }, children: rightIcon })
389
+ rightIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: rightIcon })
380
390
  ] }),
381
391
  helperText && /* @__PURE__ */ jsx(
382
392
  Text,
@@ -490,7 +500,7 @@ var Checkbox = forwardRef(function Checkbox2({
490
500
  ],
491
501
  ...rest,
492
502
  children: [
493
- /* @__PURE__ */ jsx(View, { style: boxStyle, children: indeterminate ? /* @__PURE__ */ jsx(MinusIcon, { size: iconSize, color: theme.surface }) : isChecked ? /* @__PURE__ */ jsx(CheckIcon, { size: iconSize, color: theme.surface }) : null }),
503
+ /* @__PURE__ */ jsx(View, { style: boxStyle, children: indeterminate ? /* @__PURE__ */ jsx(MinusIcon, { size: iconSize, color: theme.surface ?? "#ffffff" }) : isChecked ? /* @__PURE__ */ jsx(CheckIcon, { size: iconSize, color: theme.surface ?? "#ffffff" }) : null }),
494
504
  label && /* @__PURE__ */ jsx(
495
505
  Text,
496
506
  {
@@ -650,32 +660,32 @@ var sizeWeights = {
650
660
  var Text5 = forwardRef(function Text6({ size = "sm", color = "default", bold = false, style, children, ...rest }, ref) {
651
661
  const theme = useRehagroTheme();
652
662
  const colorMap = {
653
- default: theme.text,
654
- muted: theme.textMuted,
655
- primary: theme.primary,
656
- danger: theme.danger,
657
- success: theme.success,
658
- warning: theme.warning
663
+ default: theme.text ?? "#111827",
664
+ muted: theme.textMuted ?? "#6b7280",
665
+ primary: theme.primary ?? "#16a34a",
666
+ danger: theme.danger ?? "#dc2626",
667
+ success: theme.success ?? "#16a34a",
668
+ warning: theme.warning ?? "#d97706"
659
669
  };
660
670
  const isDisplaySize = size === "lg" || size === "xl" || size === "xxl" || size === "xxl2";
661
671
  const fontFamily = isDisplaySize ? theme.fontFamilyDisplay : theme.fontFamilyBody;
662
672
  const fontSizeMap = {
663
- xs: theme.fontSizeXs,
664
- sm: theme.fontSizeSm,
665
- md: theme.fontSizeMd,
666
- lg: theme.fontSizeLg,
667
- xl: theme.fontSizeXl,
668
- xxl: theme.fontSizeXxl,
669
- xxl2: theme.fontSizeXxl2
673
+ xs: theme.fontSizeXs ?? 12,
674
+ sm: theme.fontSizeSm ?? 14,
675
+ md: theme.fontSizeMd ?? 16,
676
+ lg: theme.fontSizeLg ?? 18,
677
+ xl: theme.fontSizeXl ?? 20,
678
+ xxl: theme.fontSizeXxl ?? 24,
679
+ xxl2: theme.fontSizeXxl2 ?? 32
670
680
  };
671
681
  const lineHeightMap = {
672
- xs: theme.lineHeightXs,
673
- sm: theme.lineHeightSm,
674
- md: theme.lineHeightMd,
675
- lg: theme.lineHeightLg,
676
- xl: theme.lineHeightXl,
677
- xxl: theme.lineHeightXxl,
678
- xxl2: theme.lineHeightXxl2
682
+ xs: theme.lineHeightXs ?? 16,
683
+ sm: theme.lineHeightSm ?? 20,
684
+ md: theme.lineHeightMd ?? 24,
685
+ lg: theme.lineHeightLg ?? 26,
686
+ xl: theme.lineHeightXl ?? 28,
687
+ xxl: theme.lineHeightXxl ?? 32,
688
+ xxl2: theme.lineHeightXxl2 ?? 40
679
689
  };
680
690
  const resolvedStyle = {
681
691
  fontSize: fontSizeMap[size],
@@ -714,12 +724,12 @@ var Tag = forwardRef(function Tag2({
714
724
  const theme = useRehagroTheme();
715
725
  const clickable = !!rest.onPress && !disabled;
716
726
  const presetTokens = {
717
- primary: { main: theme.primary, hover: theme.primaryHover },
718
- secondary: { main: theme.secondary, hover: theme.secondaryHover },
719
- danger: { main: theme.danger, hover: theme.dangerHover },
720
- warning: { main: theme.warning, hover: theme.warning },
721
- success: { main: theme.success, hover: theme.success },
722
- info: { main: theme.info, hover: theme.infoHover }
727
+ primary: { main: theme.primary ?? "#16a34a", hover: theme.primaryHover ?? "#15803d" },
728
+ secondary: { main: theme.secondary ?? "#6b7280", hover: theme.secondaryHover ?? "#4b5563" },
729
+ danger: { main: theme.danger ?? "#dc2626", hover: theme.dangerHover ?? "#b91c1c" },
730
+ warning: { main: theme.warning ?? "#d97706", hover: theme.warning ?? "#d97706" },
731
+ success: { main: theme.success ?? "#16a34a", hover: theme.success ?? "#16a34a" },
732
+ info: { main: theme.info ?? "#0284c7", hover: theme.infoHover ?? "#0369a1" }
723
733
  };
724
734
  const preset = isPresetColor3(color);
725
735
  const mainColor = preset ? presetTokens[color].main : color;
@@ -756,7 +766,7 @@ var Tag = forwardRef(function Tag2({
756
766
  return { backgroundColor: bg, borderColor: border };
757
767
  }
758
768
  function resolvedTextColor(pressed) {
759
- if (active) return theme.surface;
769
+ if (active) return theme.surface ?? "#ffffff";
760
770
  return pressed && clickable ? hoverColor : mainColor;
761
771
  }
762
772
  const textStyle = (pressed) => ({