@rehagro/ui 1.0.17 → 1.0.19
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/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/native.d.mts +1 -1
- package/dist/native.d.ts +1 -1
- package/dist/native.js +81 -72
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +81 -72
- package/dist/native.mjs.map +1 -1
- package/dist/styles.css +3 -3
- package/package.json +1 -1
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);
|
|
@@ -150,22 +148,21 @@ var Button = forwardRef(function Button2({
|
|
|
150
148
|
};
|
|
151
149
|
const variantStyle = (pressed) => {
|
|
152
150
|
if (variant === "solid") {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
borderColor: pressed ? colorHover : colorBase
|
|
156
|
-
};
|
|
151
|
+
const bg = isDisabled ? colorBase : pressed ? colorHover : colorBase;
|
|
152
|
+
return { backgroundColor: bg, borderColor: bg };
|
|
157
153
|
}
|
|
158
154
|
if (variant === "outline") {
|
|
155
|
+
const bg = pressed ? colorBase : "transparent";
|
|
159
156
|
return {
|
|
160
|
-
borderColor: colorBase,
|
|
161
|
-
backgroundColor:
|
|
157
|
+
borderColor: isDisabled ? bg : colorBase,
|
|
158
|
+
backgroundColor: bg
|
|
162
159
|
};
|
|
163
160
|
}
|
|
164
161
|
return { borderColor: "transparent", backgroundColor: "transparent" };
|
|
165
162
|
};
|
|
166
163
|
const textColor = (pressed) => {
|
|
167
|
-
if (variant === "solid") return theme.surface;
|
|
168
|
-
if (variant === "outline") return pressed ? theme.surface : colorBase;
|
|
164
|
+
if (variant === "solid") return theme.surface ?? "#ffffff";
|
|
165
|
+
if (variant === "outline") return pressed ? theme.surface ?? "#ffffff" : colorBase;
|
|
169
166
|
return colorBase;
|
|
170
167
|
};
|
|
171
168
|
return /* @__PURE__ */ jsx(
|
|
@@ -176,6 +173,7 @@ var Button = forwardRef(function Button2({
|
|
|
176
173
|
accessibilityRole: "button",
|
|
177
174
|
accessibilityState: { disabled: !!isDisabled, busy: loading },
|
|
178
175
|
accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : void 0),
|
|
176
|
+
android_ripple: { color: pressedColor ?? colorHover, borderless: false },
|
|
179
177
|
style: ({ pressed }) => [baseStyle, variantStyle(pressed), style],
|
|
180
178
|
...rest,
|
|
181
179
|
children: ({ pressed }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -183,7 +181,7 @@ var Button = forwardRef(function Button2({
|
|
|
183
181
|
ActivityIndicator,
|
|
184
182
|
{
|
|
185
183
|
size: "small",
|
|
186
|
-
color: variant === "solid" ? theme.surface : colorBase
|
|
184
|
+
color: variant === "solid" ? theme.surface ?? "#ffffff" : colorBase
|
|
187
185
|
}
|
|
188
186
|
),
|
|
189
187
|
!loading && leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: leftIcon }),
|
|
@@ -199,6 +197,16 @@ var Button = forwardRef(function Button2({
|
|
|
199
197
|
}
|
|
200
198
|
);
|
|
201
199
|
});
|
|
200
|
+
function darkenColor2(hex, factor = 0.2) {
|
|
201
|
+
if (!hex.startsWith("#")) return hex;
|
|
202
|
+
const clean = hex.replace("#", "");
|
|
203
|
+
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
204
|
+
const num = parseInt(full, 16);
|
|
205
|
+
const r = Math.max(0, Math.round((num >> 16 & 255) * (1 - factor)));
|
|
206
|
+
const g = Math.max(0, Math.round((num >> 8 & 255) * (1 - factor)));
|
|
207
|
+
const b = Math.max(0, Math.round((num & 255) * (1 - factor)));
|
|
208
|
+
return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
209
|
+
}
|
|
202
210
|
var PRESET_COLORS2 = /* @__PURE__ */ new Set([
|
|
203
211
|
"primary",
|
|
204
212
|
"secondary",
|
|
@@ -238,16 +246,16 @@ var IconButton = forwardRef(function IconButton2({
|
|
|
238
246
|
full: 9999
|
|
239
247
|
};
|
|
240
248
|
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 }
|
|
249
|
+
primary: { main: theme.primary ?? "#15607A", hover: theme.primaryHover ?? darkenColor2(theme.primary ?? "#15607A") },
|
|
250
|
+
secondary: { main: theme.secondary ?? "#718D44", hover: theme.secondaryHover ?? darkenColor2(theme.secondary ?? "#718D44") },
|
|
251
|
+
danger: { main: theme.danger ?? "#dc2626", hover: theme.dangerHover ?? darkenColor2(theme.danger ?? "#dc2626") },
|
|
252
|
+
warning: { main: theme.warning ?? "#d97706", hover: darkenColor2(theme.warning ?? "#d97706") },
|
|
253
|
+
success: { main: theme.success ?? "#16a34a", hover: darkenColor2(theme.success ?? "#16a34a") },
|
|
254
|
+
info: { main: theme.info ?? "#0284c7", hover: theme.infoHover ?? darkenColor2(theme.info ?? "#0284c7") }
|
|
247
255
|
};
|
|
248
256
|
const preset = isPresetColor2(color);
|
|
249
257
|
const main = preset ? presetTokens[color].main : color;
|
|
250
|
-
const hover = preset ? presetTokens[color].hover : color;
|
|
258
|
+
const hover = preset ? presetTokens[color].hover : darkenColor2(color);
|
|
251
259
|
const boxSize = sizePxMap[size];
|
|
252
260
|
const baseStyle = {
|
|
253
261
|
width: boxSize,
|
|
@@ -268,8 +276,8 @@ var IconButton = forwardRef(function IconButton2({
|
|
|
268
276
|
return { borderColor: "transparent", backgroundColor: pressed ? `${main}1a` : "transparent" };
|
|
269
277
|
};
|
|
270
278
|
const iconColor = (pressed) => {
|
|
271
|
-
if (variant === "solid") return theme.surface;
|
|
272
|
-
if (variant === "outline") return pressed ? theme.surface : main;
|
|
279
|
+
if (variant === "solid") return theme.surface ?? "#ffffff";
|
|
280
|
+
if (variant === "outline") return pressed ? theme.surface ?? "#ffffff" : main;
|
|
273
281
|
return main;
|
|
274
282
|
};
|
|
275
283
|
return /* @__PURE__ */ jsx(
|
|
@@ -280,6 +288,7 @@ var IconButton = forwardRef(function IconButton2({
|
|
|
280
288
|
accessibilityRole: "button",
|
|
281
289
|
accessibilityState: { disabled: !!isDisabled, busy: loading },
|
|
282
290
|
accessibilityLabel,
|
|
291
|
+
android_ripple: { color: hover, borderless: false },
|
|
283
292
|
style: ({ pressed }) => [baseStyle, variantStyle(pressed), style],
|
|
284
293
|
...rest,
|
|
285
294
|
children: ({ pressed }) => loading ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: variant === "solid" ? theme.surface : main }) : /* @__PURE__ */ jsx(View, { style: { tintColor: iconColor(pressed) }, children })
|
|
@@ -305,9 +314,9 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
305
314
|
const [focused, setFocused] = useState(false);
|
|
306
315
|
const isDisabled = editable === false;
|
|
307
316
|
const heightMap = {
|
|
308
|
-
sm: theme.inputHeightSm,
|
|
309
|
-
md: theme.inputHeightMd,
|
|
310
|
-
lg: theme.inputHeightLg
|
|
317
|
+
sm: theme.inputHeightSm ?? 36,
|
|
318
|
+
md: theme.inputHeightMd ?? 44,
|
|
319
|
+
lg: theme.inputHeightLg ?? 52
|
|
311
320
|
};
|
|
312
321
|
const paddingMap2 = {
|
|
313
322
|
sm: 12,
|
|
@@ -321,12 +330,12 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
321
330
|
};
|
|
322
331
|
const radiusMap2 = {
|
|
323
332
|
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,
|
|
333
|
+
xxs: theme.radiusXxs ?? 4,
|
|
334
|
+
xs: theme.radiusXs ?? 8,
|
|
335
|
+
sm: theme.radiusSm ?? 12,
|
|
336
|
+
md: theme.radiusMd ?? 16,
|
|
337
|
+
lg: theme.radiusLg ?? 24,
|
|
338
|
+
xl: theme.radiusXl ?? 32,
|
|
330
339
|
full: 9999
|
|
331
340
|
};
|
|
332
341
|
const hasError = status === "error" || !!helperText;
|
|
@@ -350,7 +359,7 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
350
359
|
subtitle && /* @__PURE__ */ jsx(Text, { style: { fontSize: 14, color: theme.textMuted }, children: subtitle })
|
|
351
360
|
] }),
|
|
352
361
|
/* @__PURE__ */ jsxs(View, { style: [containerStyle, style], children: [
|
|
353
|
-
leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true,
|
|
362
|
+
leftIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: leftIcon }),
|
|
354
363
|
/* @__PURE__ */ jsx(
|
|
355
364
|
TextInput$1,
|
|
356
365
|
{
|
|
@@ -376,7 +385,7 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
376
385
|
...rest
|
|
377
386
|
}
|
|
378
387
|
),
|
|
379
|
-
rightIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true,
|
|
388
|
+
rightIcon && /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: rightIcon })
|
|
380
389
|
] }),
|
|
381
390
|
helperText && /* @__PURE__ */ jsx(
|
|
382
391
|
Text,
|
|
@@ -490,7 +499,7 @@ var Checkbox = forwardRef(function Checkbox2({
|
|
|
490
499
|
],
|
|
491
500
|
...rest,
|
|
492
501
|
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 }),
|
|
502
|
+
/* @__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
503
|
label && /* @__PURE__ */ jsx(
|
|
495
504
|
Text,
|
|
496
505
|
{
|
|
@@ -650,32 +659,32 @@ var sizeWeights = {
|
|
|
650
659
|
var Text5 = forwardRef(function Text6({ size = "sm", color = "default", bold = false, style, children, ...rest }, ref) {
|
|
651
660
|
const theme = useRehagroTheme();
|
|
652
661
|
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
|
|
662
|
+
default: theme.text ?? "#111827",
|
|
663
|
+
muted: theme.textMuted ?? "#6b7280",
|
|
664
|
+
primary: theme.primary ?? "#16a34a",
|
|
665
|
+
danger: theme.danger ?? "#dc2626",
|
|
666
|
+
success: theme.success ?? "#16a34a",
|
|
667
|
+
warning: theme.warning ?? "#d97706"
|
|
659
668
|
};
|
|
660
669
|
const isDisplaySize = size === "lg" || size === "xl" || size === "xxl" || size === "xxl2";
|
|
661
670
|
const fontFamily = isDisplaySize ? theme.fontFamilyDisplay : theme.fontFamilyBody;
|
|
662
671
|
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
|
|
672
|
+
xs: theme.fontSizeXs ?? 12,
|
|
673
|
+
sm: theme.fontSizeSm ?? 14,
|
|
674
|
+
md: theme.fontSizeMd ?? 16,
|
|
675
|
+
lg: theme.fontSizeLg ?? 18,
|
|
676
|
+
xl: theme.fontSizeXl ?? 20,
|
|
677
|
+
xxl: theme.fontSizeXxl ?? 24,
|
|
678
|
+
xxl2: theme.fontSizeXxl2 ?? 32
|
|
670
679
|
};
|
|
671
680
|
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
|
|
681
|
+
xs: theme.lineHeightXs ?? 16,
|
|
682
|
+
sm: theme.lineHeightSm ?? 20,
|
|
683
|
+
md: theme.lineHeightMd ?? 24,
|
|
684
|
+
lg: theme.lineHeightLg ?? 26,
|
|
685
|
+
xl: theme.lineHeightXl ?? 28,
|
|
686
|
+
xxl: theme.lineHeightXxl ?? 32,
|
|
687
|
+
xxl2: theme.lineHeightXxl2 ?? 40
|
|
679
688
|
};
|
|
680
689
|
const resolvedStyle = {
|
|
681
690
|
fontSize: fontSizeMap[size],
|
|
@@ -714,12 +723,12 @@ var Tag = forwardRef(function Tag2({
|
|
|
714
723
|
const theme = useRehagroTheme();
|
|
715
724
|
const clickable = !!rest.onPress && !disabled;
|
|
716
725
|
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 }
|
|
726
|
+
primary: { main: theme.primary ?? "#16a34a", hover: theme.primaryHover ?? "#15803d" },
|
|
727
|
+
secondary: { main: theme.secondary ?? "#6b7280", hover: theme.secondaryHover ?? "#4b5563" },
|
|
728
|
+
danger: { main: theme.danger ?? "#dc2626", hover: theme.dangerHover ?? "#b91c1c" },
|
|
729
|
+
warning: { main: theme.warning ?? "#d97706", hover: theme.warning ?? "#d97706" },
|
|
730
|
+
success: { main: theme.success ?? "#16a34a", hover: theme.success ?? "#16a34a" },
|
|
731
|
+
info: { main: theme.info ?? "#0284c7", hover: theme.infoHover ?? "#0369a1" }
|
|
723
732
|
};
|
|
724
733
|
const preset = isPresetColor3(color);
|
|
725
734
|
const mainColor = preset ? presetTokens[color].main : color;
|
|
@@ -756,7 +765,7 @@ var Tag = forwardRef(function Tag2({
|
|
|
756
765
|
return { backgroundColor: bg, borderColor: border };
|
|
757
766
|
}
|
|
758
767
|
function resolvedTextColor(pressed) {
|
|
759
|
-
if (active) return theme.surface;
|
|
768
|
+
if (active) return theme.surface ?? "#ffffff";
|
|
760
769
|
return pressed && clickable ? hoverColor : mainColor;
|
|
761
770
|
}
|
|
762
771
|
const textStyle = (pressed) => ({
|