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