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