@korsolutions/ui 0.0.19 → 0.0.21
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/components/index.d.mts +73 -4
- package/dist/components/index.mjs +156 -8
- package/dist/hooks/index.d.mts +32 -2
- package/dist/hooks/index.mjs +79 -2
- package/dist/{index-BLsiF42Z.d.mts → index-pCM7YTs1.d.mts} +165 -9
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -2
- package/dist/primitives/index.d.mts +3 -2
- package/dist/primitives/index.mjs +3 -2
- package/dist/{primitives-CyDqzNcp.mjs → primitives-DNeYBN-3.mjs} +330 -12
- package/dist/{toast-manager-BOORCQn8.mjs → toast-manager-BfoJ-_dB.mjs} +1 -1
- package/dist/use-numeric-mask-B9WZG25o.d.mts +33 -0
- package/dist/use-numeric-mask-BQlz1Pus.mjs +113 -0
- package/dist/use-relative-position-BTKEyT1F.mjs +106 -0
- package/dist/use-relative-position-DBzhrBU7.d.mts +61 -0
- package/package.json +1 -1
- package/src/components/button/button.tsx +7 -4
- package/src/components/dropdown-menu/dropdown-menu.tsx +49 -0
- package/src/components/dropdown-menu/variants/default.tsx +40 -0
- package/src/components/dropdown-menu/variants/index.ts +5 -0
- package/src/components/index.ts +3 -1
- package/src/components/input/index.ts +2 -0
- package/src/components/input/numeric-input.tsx +73 -0
- package/src/components/popover/popover.tsx +51 -0
- package/src/components/popover/variants/default.tsx +26 -0
- package/src/components/popover/variants/index.ts +5 -0
- package/src/hooks/index.ts +4 -1
- package/src/hooks/use-currency-mask.ts +141 -0
- package/src/hooks/use-numeric-mask.ts +202 -0
- package/src/hooks/use-relative-position.ts +188 -0
- package/src/primitives/button/button-root.tsx +2 -4
- package/src/primitives/dropdown-menu/context.ts +25 -0
- package/src/primitives/dropdown-menu/dropdown-menu-button.tsx +47 -0
- package/src/primitives/dropdown-menu/dropdown-menu-content.tsx +39 -0
- package/src/primitives/dropdown-menu/dropdown-menu-divider.tsx +18 -0
- package/src/primitives/dropdown-menu/dropdown-menu-overlay.tsx +29 -0
- package/src/primitives/dropdown-menu/dropdown-menu-portal.tsx +21 -0
- package/src/primitives/dropdown-menu/dropdown-menu-root.tsx +35 -0
- package/src/primitives/dropdown-menu/dropdown-menu-trigger.tsx +47 -0
- package/src/primitives/dropdown-menu/index.ts +26 -0
- package/src/primitives/dropdown-menu/types.ts +13 -0
- package/src/primitives/index.ts +2 -0
- package/src/primitives/popover/context.ts +25 -0
- package/src/primitives/popover/index.ts +24 -0
- package/src/primitives/popover/popover-close.tsx +29 -0
- package/src/primitives/popover/popover-content.tsx +39 -0
- package/src/primitives/popover/popover-overlay.tsx +37 -0
- package/src/primitives/popover/popover-portal.tsx +21 -0
- package/src/primitives/popover/popover-root.tsx +35 -0
- package/src/primitives/popover/popover-trigger.tsx +47 -0
- package/src/primitives/popover/types.ts +7 -0
- package/src/utils/get-ref-layout.ts +16 -0
- /package/src/hooks/{useScreenSize.ts → use-screen-size.ts} +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as BadgeStyles, I as AvatarStyles, S as TextareaPrimitiveBaseProps, V as EmptyStyles, d as PopoverTriggerRef, dt as ButtonStyles, et as SelectRootBaseProps, gt as InputStyles, h as DropdownMenuStyles, j as ToastStyles, lt as ButtonPrimitiveRootProps, mt as InputPrimitiveBaseProps, nt as SelectStyles, q as CardStyles, s as PopoverStyles, w as TextareaStyles, yt as FieldStyles } from "../index-pCM7YTs1.mjs";
|
|
2
|
+
import "../use-relative-position-DBzhrBU7.mjs";
|
|
3
|
+
import { t as NumericMaskFormat } from "../use-numeric-mask-B9WZG25o.mjs";
|
|
2
4
|
import React from "react";
|
|
3
|
-
import { ImageSource, TextProps, TextStyle } from "react-native";
|
|
5
|
+
import { ImageSource, PressableProps, TextProps, TextStyle } from "react-native";
|
|
4
6
|
|
|
5
7
|
//#region src/components/button/variants/index.d.ts
|
|
6
8
|
declare const ButtonVariants: {
|
|
@@ -10,8 +12,9 @@ declare const ButtonVariants: {
|
|
|
10
12
|
//#endregion
|
|
11
13
|
//#region src/components/button/button.d.ts
|
|
12
14
|
interface ButtonProps {
|
|
13
|
-
onPress?: () => void;
|
|
14
15
|
children?: string;
|
|
16
|
+
onPress?: ButtonPrimitiveRootProps["onPress"];
|
|
17
|
+
onLayout?: ButtonPrimitiveRootProps["onLayout"];
|
|
15
18
|
isDisabled?: boolean;
|
|
16
19
|
isLoading?: boolean;
|
|
17
20
|
variant?: keyof typeof ButtonVariants;
|
|
@@ -48,6 +51,35 @@ interface InputProps extends InputPrimitiveBaseProps {
|
|
|
48
51
|
}
|
|
49
52
|
declare function Input(props: InputProps): React.JSX.Element;
|
|
50
53
|
//#endregion
|
|
54
|
+
//#region src/components/input/numeric-input.d.ts
|
|
55
|
+
interface NumericInputProps extends Omit<InputPrimitiveBaseProps, "value" | "onChange" | "keyboardType"> {
|
|
56
|
+
variant?: "default";
|
|
57
|
+
value?: number | null;
|
|
58
|
+
onChange?: (value: number | null) => void;
|
|
59
|
+
format?: NumericMaskFormat;
|
|
60
|
+
locale?: string;
|
|
61
|
+
currency?: string;
|
|
62
|
+
precision?: number;
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
allowNegative?: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare function NumericInput({
|
|
68
|
+
value,
|
|
69
|
+
onChange,
|
|
70
|
+
format,
|
|
71
|
+
locale,
|
|
72
|
+
currency,
|
|
73
|
+
precision,
|
|
74
|
+
min,
|
|
75
|
+
max,
|
|
76
|
+
allowNegative,
|
|
77
|
+
variant,
|
|
78
|
+
onBlur,
|
|
79
|
+
onFocus,
|
|
80
|
+
...props
|
|
81
|
+
}: NumericInputProps): React.JSX.Element;
|
|
82
|
+
//#endregion
|
|
51
83
|
//#region src/components/field/variants/index.d.ts
|
|
52
84
|
declare const FieldVariants: {
|
|
53
85
|
default: () => FieldStyles;
|
|
@@ -224,4 +256,41 @@ interface TextareaProps extends TextareaPrimitiveBaseProps {
|
|
|
224
256
|
}
|
|
225
257
|
declare function Textarea(props: TextareaProps): React.JSX.Element;
|
|
226
258
|
//#endregion
|
|
227
|
-
|
|
259
|
+
//#region src/components/dropdown-menu/variants/index.d.ts
|
|
260
|
+
declare const DropdownMenuVariants: {
|
|
261
|
+
default: () => DropdownMenuStyles;
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/components/dropdown-menu/dropdown-menu.d.ts
|
|
265
|
+
type DropdownMenuOption = {
|
|
266
|
+
type: "button";
|
|
267
|
+
label: string;
|
|
268
|
+
onPress: () => void;
|
|
269
|
+
} | {
|
|
270
|
+
type: "divider";
|
|
271
|
+
};
|
|
272
|
+
interface DropdownMenuProps {
|
|
273
|
+
trigger: React.ReactElement<PressableProps>;
|
|
274
|
+
options: DropdownMenuOption[];
|
|
275
|
+
variant?: keyof typeof DropdownMenuVariants;
|
|
276
|
+
}
|
|
277
|
+
declare function DropdownMenu(props: DropdownMenuProps): React.JSX.Element;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/components/popover/variants/index.d.ts
|
|
280
|
+
declare const PopoverVariants: {
|
|
281
|
+
default: () => PopoverStyles;
|
|
282
|
+
};
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/components/popover/popover.d.ts
|
|
285
|
+
interface PopoverChildrenProps {
|
|
286
|
+
close: () => void;
|
|
287
|
+
}
|
|
288
|
+
interface PopoverProps {
|
|
289
|
+
children: ((props: PopoverChildrenProps) => React.ReactNode) | React.ReactNode;
|
|
290
|
+
trigger: React.ReactElement<PressableProps>;
|
|
291
|
+
closeOnOverlayPress?: boolean;
|
|
292
|
+
variant?: keyof typeof PopoverVariants;
|
|
293
|
+
}
|
|
294
|
+
declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<PopoverTriggerRef>>;
|
|
295
|
+
//#endregion
|
|
296
|
+
export { Avatar, AvatarProps, Badge, Button, Card, DropdownMenu, Empty, EmptyProps, Field, FieldProps, Input, Link, LinkProps, NumericInput, NumericInputProps, Popover, PopoverProps, Select, SelectOption, SelectProps, Textarea, Toast, Typography, TypographyProps };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { i as useThemedStyles, r as ToastComponent, t as ToastAPI } from "../toast-manager-
|
|
2
|
-
import { a as
|
|
3
|
-
import
|
|
1
|
+
import { i as useThemedStyles, r as ToastComponent, t as ToastAPI } from "../toast-manager-BfoJ-_dB.mjs";
|
|
2
|
+
import { a as BadgePrimitive, c as EmptyPrimitive, d as ButtonPrimitive, f as InputPrimitive, i as TextareaPrimitive, l as CardPrimitive, n as usePopover, p as FieldPrimitive, r as DropdownMenuPrimitive, s as AvatarPrimitive, t as PopoverPrimitive, u as SelectPrimitive } from "../primitives-DNeYBN-3.mjs";
|
|
3
|
+
import "../use-relative-position-BTKEyT1F.mjs";
|
|
4
|
+
import { t as useNumericMask } from "../use-numeric-mask-BQlz1Pus.mjs";
|
|
5
|
+
import React, { forwardRef, useEffect, useState } from "react";
|
|
4
6
|
import { Linking, Text } from "react-native";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
|
|
@@ -110,11 +112,11 @@ const ButtonVariants = {
|
|
|
110
112
|
//#endregion
|
|
111
113
|
//#region src/components/button/button.tsx
|
|
112
114
|
function Button(props) {
|
|
113
|
-
const
|
|
115
|
+
const { children, variant = "default", ...rootProps } = props;
|
|
116
|
+
const useVariantStyles = ButtonVariants[variant];
|
|
117
|
+
const variantStyles = useVariantStyles();
|
|
114
118
|
return /* @__PURE__ */ jsxs(ButtonPrimitive.Root, {
|
|
115
|
-
|
|
116
|
-
isDisabled: props.isDisabled,
|
|
117
|
-
isLoading: props.isLoading,
|
|
119
|
+
...rootProps,
|
|
118
120
|
styles: variantStyles,
|
|
119
121
|
children: [props.isLoading && /* @__PURE__ */ jsx(ButtonPrimitive.Spinner, {}), /* @__PURE__ */ jsx(ButtonPrimitive.Label, { children: props.children })]
|
|
120
122
|
});
|
|
@@ -205,6 +207,41 @@ function Input(props) {
|
|
|
205
207
|
});
|
|
206
208
|
}
|
|
207
209
|
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/components/input/numeric-input.tsx
|
|
212
|
+
function NumericInput({ value, onChange, format = "decimal", locale = "en-US", currency = "USD", precision = 2, min, max, allowNegative = true, variant = "default", onBlur, onFocus, ...props }) {
|
|
213
|
+
const numericMask = useNumericMask({
|
|
214
|
+
format,
|
|
215
|
+
locale,
|
|
216
|
+
currency,
|
|
217
|
+
precision,
|
|
218
|
+
min,
|
|
219
|
+
max,
|
|
220
|
+
allowNegative,
|
|
221
|
+
onChange
|
|
222
|
+
});
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (value !== numericMask.numericValue) numericMask.setValue(value ?? null);
|
|
225
|
+
}, [value]);
|
|
226
|
+
const handleBlur = (e) => {
|
|
227
|
+
numericMask.onBlur();
|
|
228
|
+
onBlur?.(e);
|
|
229
|
+
};
|
|
230
|
+
const handleFocus = (e) => {
|
|
231
|
+
numericMask.onFocus();
|
|
232
|
+
onFocus?.(e);
|
|
233
|
+
};
|
|
234
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
235
|
+
...props,
|
|
236
|
+
variant,
|
|
237
|
+
value: numericMask.value,
|
|
238
|
+
onChange: numericMask.onChangeText,
|
|
239
|
+
onBlur: handleBlur,
|
|
240
|
+
onFocus: handleFocus,
|
|
241
|
+
keyboardType: numericMask.keyboardType
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
208
245
|
//#endregion
|
|
209
246
|
//#region src/components/field/variants/default.tsx
|
|
210
247
|
const useFieldVariantDefault = () => {
|
|
@@ -679,4 +716,115 @@ function Textarea(props) {
|
|
|
679
716
|
}
|
|
680
717
|
|
|
681
718
|
//#endregion
|
|
682
|
-
|
|
719
|
+
//#region src/components/dropdown-menu/variants/default.tsx
|
|
720
|
+
const useDropdownMenuVariantDefault = () => {
|
|
721
|
+
return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
|
|
722
|
+
overlay: { backgroundColor: "rgba(0, 0, 0, 0.5)" },
|
|
723
|
+
content: {
|
|
724
|
+
overflow: "hidden",
|
|
725
|
+
backgroundColor: colors.surface,
|
|
726
|
+
borderRadius: radius,
|
|
727
|
+
borderWidth: 1,
|
|
728
|
+
borderColor: colors.border,
|
|
729
|
+
shadowColor: "#000",
|
|
730
|
+
shadowOffset: {
|
|
731
|
+
width: 0,
|
|
732
|
+
height: 4
|
|
733
|
+
},
|
|
734
|
+
shadowOpacity: .15,
|
|
735
|
+
shadowRadius: 12,
|
|
736
|
+
elevation: 8
|
|
737
|
+
},
|
|
738
|
+
button: {
|
|
739
|
+
default: {
|
|
740
|
+
paddingVertical: 12,
|
|
741
|
+
paddingHorizontal: 16,
|
|
742
|
+
fontFamily,
|
|
743
|
+
fontSize,
|
|
744
|
+
color: colors.foreground
|
|
745
|
+
},
|
|
746
|
+
hovered: { backgroundColor: colors.muted }
|
|
747
|
+
},
|
|
748
|
+
divider: {
|
|
749
|
+
height: 1,
|
|
750
|
+
backgroundColor: colors.border
|
|
751
|
+
}
|
|
752
|
+
}));
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/components/dropdown-menu/variants/index.ts
|
|
757
|
+
const DropdownMenuVariants = { default: useDropdownMenuVariantDefault };
|
|
758
|
+
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/components/dropdown-menu/dropdown-menu.tsx
|
|
761
|
+
function DropdownMenu(props) {
|
|
762
|
+
const useVariantStyles = DropdownMenuVariants[props.variant || "default"];
|
|
763
|
+
const styles = useVariantStyles();
|
|
764
|
+
return /* @__PURE__ */ jsxs(DropdownMenuPrimitive.Root, {
|
|
765
|
+
styles,
|
|
766
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuPrimitive.Trigger, { children: props.trigger }), /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Overlay, { children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Content, { children: props.options.map((option) => {
|
|
767
|
+
if (option.type === "button") return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Button, {
|
|
768
|
+
onPress: option.onPress,
|
|
769
|
+
children: option.label
|
|
770
|
+
}, option.label);
|
|
771
|
+
else if (option.type === "divider") return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Divider, {}, Math.random().toString());
|
|
772
|
+
}) }) }) })]
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
//#endregion
|
|
777
|
+
//#region src/components/popover/variants/default.tsx
|
|
778
|
+
const usePopoverVariantDefault = () => {
|
|
779
|
+
return useThemedStyles(({ colors, radius }) => ({
|
|
780
|
+
overlay: { backgroundColor: "rgba(0, 0, 0, 0.5)" },
|
|
781
|
+
content: {
|
|
782
|
+
backgroundColor: colors.surface,
|
|
783
|
+
borderRadius: radius,
|
|
784
|
+
borderWidth: 1,
|
|
785
|
+
borderColor: colors.border,
|
|
786
|
+
padding: 16,
|
|
787
|
+
minWidth: 280,
|
|
788
|
+
maxWidth: 320,
|
|
789
|
+
shadowColor: "#000",
|
|
790
|
+
shadowOffset: {
|
|
791
|
+
width: 0,
|
|
792
|
+
height: 4
|
|
793
|
+
},
|
|
794
|
+
shadowOpacity: .15,
|
|
795
|
+
shadowRadius: 12,
|
|
796
|
+
elevation: 8
|
|
797
|
+
}
|
|
798
|
+
}));
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/components/popover/variants/index.ts
|
|
803
|
+
const PopoverVariants = { default: usePopoverVariantDefault };
|
|
804
|
+
|
|
805
|
+
//#endregion
|
|
806
|
+
//#region src/components/popover/popover.tsx
|
|
807
|
+
const PopoverContentComponent = (props) => {
|
|
808
|
+
const popover = usePopover();
|
|
809
|
+
if (typeof props.children === "function") return /* @__PURE__ */ jsx(PopoverPrimitive.Content, { children: props.children({ close: () => popover.setIsOpen(false) }) });
|
|
810
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Content, { children: props.children });
|
|
811
|
+
};
|
|
812
|
+
const PopoverComponent = forwardRef((props, ref) => {
|
|
813
|
+
const useVariantStyles = PopoverVariants[props.variant || "default"];
|
|
814
|
+
const styles = useVariantStyles();
|
|
815
|
+
return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, {
|
|
816
|
+
styles,
|
|
817
|
+
children: [/* @__PURE__ */ jsx(PopoverPrimitive.Trigger, {
|
|
818
|
+
ref,
|
|
819
|
+
children: props.trigger
|
|
820
|
+
}), /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(PopoverPrimitive.Overlay, {
|
|
821
|
+
closeOnPress: props.closeOnOverlayPress,
|
|
822
|
+
children: /* @__PURE__ */ jsx(PopoverContentComponent, { children: props.children })
|
|
823
|
+
}) })]
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
PopoverComponent.displayName = "Popover";
|
|
827
|
+
const Popover = PopoverComponent;
|
|
828
|
+
|
|
829
|
+
//#endregion
|
|
830
|
+
export { Avatar, Badge, Button, Card, DropdownMenu, Empty, Field, Input, Link, NumericInput, Popover, Select, Textarea, Toast, Typography };
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { i as useRelativePosition, n as DEFAULT_POSITION, r as LayoutPosition, t as DEFAULT_LAYOUT } from "../use-relative-position-DBzhrBU7.mjs";
|
|
2
|
+
import { i as useNumericMask, n as UseNumericMaskOptions, r as UseNumericMaskReturn, t as NumericMaskFormat } from "../use-numeric-mask-B9WZG25o.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/use-screen-size.d.ts
|
|
2
5
|
type ScreenSize = "mobile" | "tablet" | "desktop";
|
|
3
6
|
interface Response {
|
|
4
7
|
readonly size: ScreenSize;
|
|
@@ -14,4 +17,31 @@ interface Response {
|
|
|
14
17
|
}
|
|
15
18
|
declare function useScreenSize(): Response;
|
|
16
19
|
//#endregion
|
|
17
|
-
|
|
20
|
+
//#region src/hooks/use-currency-mask.d.ts
|
|
21
|
+
interface UseCurrencyMaskOptions {
|
|
22
|
+
locale?: string;
|
|
23
|
+
currency?: string;
|
|
24
|
+
precision?: number;
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
onValueChange?: (value: number | null) => void;
|
|
28
|
+
}
|
|
29
|
+
interface UseCurrencyMaskReturn {
|
|
30
|
+
value: string;
|
|
31
|
+
numericValue: number | null;
|
|
32
|
+
onChangeText: (text: string) => void;
|
|
33
|
+
onBlur: () => void;
|
|
34
|
+
onFocus: () => void;
|
|
35
|
+
keyboardType: "decimal-pad";
|
|
36
|
+
setValue: (value: number | null) => void;
|
|
37
|
+
}
|
|
38
|
+
declare function useCurrencyMask({
|
|
39
|
+
locale,
|
|
40
|
+
currency,
|
|
41
|
+
precision,
|
|
42
|
+
min,
|
|
43
|
+
max,
|
|
44
|
+
onValueChange
|
|
45
|
+
}?: UseCurrencyMaskOptions): UseCurrencyMaskReturn;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { DEFAULT_LAYOUT, DEFAULT_POSITION, LayoutPosition, NumericMaskFormat, ScreenSize, UseCurrencyMaskOptions, UseCurrencyMaskReturn, UseNumericMaskOptions, UseNumericMaskReturn, useCurrencyMask, useNumericMask, useRelativePosition, useScreenSize };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { n as DEFAULT_POSITION, r as useRelativePosition, t as DEFAULT_LAYOUT } from "../use-relative-position-BTKEyT1F.mjs";
|
|
2
|
+
import { t as useNumericMask } from "../use-numeric-mask-BQlz1Pus.mjs";
|
|
3
|
+
import { useCallback, useState } from "react";
|
|
1
4
|
import { useWindowDimensions } from "react-native";
|
|
2
5
|
|
|
3
|
-
//#region src/hooks/
|
|
6
|
+
//#region src/hooks/use-screen-size.ts
|
|
4
7
|
function useScreenSize() {
|
|
5
8
|
const windowDimensions = useWindowDimensions();
|
|
6
9
|
const size = windowDimensions.width < 768 ? "mobile" : windowDimensions.width < 1024 ? "tablet" : "desktop";
|
|
@@ -23,4 +26,78 @@ function useScreenSize() {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
//#endregion
|
|
26
|
-
|
|
29
|
+
//#region src/hooks/use-currency-mask.ts
|
|
30
|
+
function useCurrencyMask({ locale = "en-US", currency = "USD", precision = 2, min, max, onValueChange } = {}) {
|
|
31
|
+
const [numericValue, setNumericValue] = useState(null);
|
|
32
|
+
const [displayValue, setDisplayValue] = useState("");
|
|
33
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
34
|
+
const formatCurrency = useCallback((num) => {
|
|
35
|
+
if (num === null || isNaN(num)) return "";
|
|
36
|
+
return new Intl.NumberFormat(locale, {
|
|
37
|
+
style: "currency",
|
|
38
|
+
currency,
|
|
39
|
+
minimumFractionDigits: precision,
|
|
40
|
+
maximumFractionDigits: precision
|
|
41
|
+
}).format(num);
|
|
42
|
+
}, [
|
|
43
|
+
locale,
|
|
44
|
+
currency,
|
|
45
|
+
precision
|
|
46
|
+
]);
|
|
47
|
+
const parseCurrency = useCallback((text) => {
|
|
48
|
+
const cleaned = text.replace(/[^\d.-]/g, "");
|
|
49
|
+
const parsed = parseFloat(cleaned);
|
|
50
|
+
if (isNaN(parsed) || cleaned === "") return null;
|
|
51
|
+
let constrained = parsed;
|
|
52
|
+
if (min !== void 0 && constrained < min) constrained = min;
|
|
53
|
+
if (max !== void 0 && constrained > max) constrained = max;
|
|
54
|
+
return constrained;
|
|
55
|
+
}, [min, max]);
|
|
56
|
+
return {
|
|
57
|
+
value: displayValue,
|
|
58
|
+
numericValue,
|
|
59
|
+
onChangeText: useCallback((text) => {
|
|
60
|
+
if (isFocused) {
|
|
61
|
+
const cleaned = text.replace(/[^\d.-]/g, "");
|
|
62
|
+
const decimalIndex = cleaned.indexOf(".");
|
|
63
|
+
if (decimalIndex !== -1) {
|
|
64
|
+
if (cleaned.substring(decimalIndex + 1).length > precision) return;
|
|
65
|
+
}
|
|
66
|
+
if ((cleaned.match(/\./g) || []).length > 1) return;
|
|
67
|
+
}
|
|
68
|
+
setDisplayValue(text);
|
|
69
|
+
const value = parseCurrency(text);
|
|
70
|
+
setNumericValue(value);
|
|
71
|
+
onValueChange?.(value);
|
|
72
|
+
}, [
|
|
73
|
+
parseCurrency,
|
|
74
|
+
onValueChange,
|
|
75
|
+
isFocused,
|
|
76
|
+
precision
|
|
77
|
+
]),
|
|
78
|
+
onBlur: useCallback(() => {
|
|
79
|
+
setIsFocused(false);
|
|
80
|
+
if (numericValue !== null) setDisplayValue(formatCurrency(numericValue));
|
|
81
|
+
else setDisplayValue("");
|
|
82
|
+
}, [numericValue, formatCurrency]),
|
|
83
|
+
onFocus: useCallback(() => {
|
|
84
|
+
setIsFocused(true);
|
|
85
|
+
if (numericValue !== null) setDisplayValue(numericValue.toString());
|
|
86
|
+
}, [numericValue]),
|
|
87
|
+
keyboardType: "decimal-pad",
|
|
88
|
+
setValue: useCallback((value) => {
|
|
89
|
+
setNumericValue(value);
|
|
90
|
+
if (value !== null) if (isFocused) setDisplayValue(value.toString());
|
|
91
|
+
else setDisplayValue(formatCurrency(value));
|
|
92
|
+
else setDisplayValue("");
|
|
93
|
+
onValueChange?.(value);
|
|
94
|
+
}, [
|
|
95
|
+
isFocused,
|
|
96
|
+
formatCurrency,
|
|
97
|
+
onValueChange
|
|
98
|
+
])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { DEFAULT_LAYOUT, DEFAULT_POSITION, useCurrencyMask, useNumericMask, useRelativePosition, useScreenSize };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { r as LayoutPosition } from "./use-relative-position-DBzhrBU7.mjs";
|
|
2
|
+
import * as react7 from "react";
|
|
3
|
+
import React$1, { Dispatch, RefAttributes } from "react";
|
|
4
|
+
import { ImageSource, ImageStyle, LayoutRectangle, PressableProps, StyleProp, TextInputProps, TextProps, TextStyle, View, ViewStyle } from "react-native";
|
|
4
5
|
|
|
5
6
|
//#region src/primitives/field/field-label.d.ts
|
|
6
7
|
interface FieldLabelProps {
|
|
@@ -65,7 +66,7 @@ interface InputPrimitiveProps extends InputPrimitiveBaseProps {
|
|
|
65
66
|
render?: (props: InputPrimitiveProps) => React.ReactNode;
|
|
66
67
|
styles?: InputStyles;
|
|
67
68
|
}
|
|
68
|
-
declare function InputPrimitive(props: InputPrimitiveProps):
|
|
69
|
+
declare function InputPrimitive(props: InputPrimitiveProps): react7.JSX.Element;
|
|
69
70
|
//#endregion
|
|
70
71
|
//#region src/primitives/button/button-label.d.ts
|
|
71
72
|
interface ButtonPrimitiveLabelProps {
|
|
@@ -84,9 +85,8 @@ interface ButtonStyles {
|
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
87
|
//#region src/primitives/button/button-root.d.ts
|
|
87
|
-
interface ButtonPrimitiveRootProps {
|
|
88
|
+
interface ButtonPrimitiveRootProps extends PressableProps {
|
|
88
89
|
children?: React$1.ReactNode;
|
|
89
|
-
onPress?: () => void;
|
|
90
90
|
isDisabled?: boolean;
|
|
91
91
|
isLoading?: boolean;
|
|
92
92
|
style?: StyleProp<ViewStyle>;
|
|
@@ -152,7 +152,7 @@ interface SelectOptionProps {
|
|
|
152
152
|
render?: (props: SelectOptionProps) => React.ReactElement;
|
|
153
153
|
style?: StyleProp<TextStyle>;
|
|
154
154
|
}
|
|
155
|
-
declare function SelectOption(props: SelectOptionProps):
|
|
155
|
+
declare function SelectOption(props: SelectOptionProps): react7.JSX.Element;
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/primitives/select/types.d.ts
|
|
158
158
|
type SelectState = "default" | "disabled";
|
|
@@ -433,6 +433,162 @@ interface TextareaPrimitiveProps extends TextareaPrimitiveBaseProps {
|
|
|
433
433
|
render?: (props: TextareaPrimitiveProps) => React.ReactNode;
|
|
434
434
|
styles?: TextareaStyles;
|
|
435
435
|
}
|
|
436
|
-
declare function TextareaPrimitive(props: TextareaPrimitiveProps):
|
|
436
|
+
declare function TextareaPrimitive(props: TextareaPrimitiveProps): react7.JSX.Element;
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-trigger.d.ts
|
|
439
|
+
interface DropdownMenuTriggerProps extends PressableProps {
|
|
440
|
+
children: React$1.ReactElement<RefAttributes<View> & PressableProps>;
|
|
441
|
+
}
|
|
442
|
+
interface DropdownMenuTriggerRef {
|
|
443
|
+
open: () => void;
|
|
444
|
+
close: () => void;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-content.d.ts
|
|
448
|
+
interface DropdownMenuContentProps {
|
|
449
|
+
children?: React$1.ReactNode;
|
|
450
|
+
render?: (props: DropdownMenuContentProps) => React$1.ReactNode;
|
|
451
|
+
style?: StyleProp<ViewStyle>;
|
|
452
|
+
}
|
|
453
|
+
declare function DropdownMenuContent(props: DropdownMenuContentProps): React$1.JSX.Element;
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-button.d.ts
|
|
456
|
+
interface DropdownMenuButtonProps {
|
|
457
|
+
children?: string;
|
|
458
|
+
onPress?: () => void;
|
|
459
|
+
onMouseEnter?: () => void;
|
|
460
|
+
onMouseLeave?: () => void;
|
|
461
|
+
render?: (props: DropdownMenuButtonProps) => React$1.ReactElement;
|
|
462
|
+
style?: StyleProp<TextStyle>;
|
|
463
|
+
}
|
|
464
|
+
declare function DropdownMenuButton(props: DropdownMenuButtonProps): React$1.JSX.Element;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-divider.d.ts
|
|
467
|
+
interface DropdownMenuDividerProps {
|
|
468
|
+
render?: (props: DropdownMenuDividerProps) => React$1.ReactNode;
|
|
469
|
+
style?: StyleProp<ViewStyle>;
|
|
470
|
+
}
|
|
471
|
+
declare function DropdownMenuDivider(props: DropdownMenuDividerProps): React$1.JSX.Element;
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-overlay.d.ts
|
|
474
|
+
interface DropdownMenuOverlayProps {
|
|
475
|
+
children?: React$1.ReactNode;
|
|
476
|
+
render?: (props: DropdownMenuOverlayProps) => React$1.ReactElement;
|
|
477
|
+
style?: StyleProp<ViewStyle>;
|
|
478
|
+
}
|
|
479
|
+
declare function DropdownMenuOverlay(props: DropdownMenuOverlayProps): React$1.JSX.Element;
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/primitives/dropdown-menu/types.d.ts
|
|
482
|
+
type DropdownMenuButtonState = "default" | "hovered";
|
|
483
|
+
interface DropdownMenuStyles {
|
|
484
|
+
content?: DropdownMenuContentProps["style"];
|
|
485
|
+
button?: Partial<Record<DropdownMenuButtonState, DropdownMenuButtonProps["style"]>>;
|
|
486
|
+
divider?: DropdownMenuDividerProps["style"];
|
|
487
|
+
overlay?: DropdownMenuOverlayProps["style"];
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-root.d.ts
|
|
491
|
+
interface DropdownMenuRootProps {
|
|
492
|
+
children?: React$1.ReactNode;
|
|
493
|
+
render?: (props: DropdownMenuRootProps) => React$1.ReactNode;
|
|
494
|
+
styles?: DropdownMenuStyles;
|
|
495
|
+
}
|
|
496
|
+
declare function DropdownMenuRoot(props: DropdownMenuRootProps): React$1.JSX.Element;
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/primitives/dropdown-menu/dropdown-menu-portal.d.ts
|
|
499
|
+
interface DropdownMenuPortalProps {
|
|
500
|
+
children?: React$1.ReactNode;
|
|
501
|
+
}
|
|
502
|
+
declare function DropdownMenuPortal(props: DropdownMenuPortalProps): React$1.JSX.Element | null;
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/primitives/dropdown-menu/index.d.ts
|
|
505
|
+
declare const DropdownMenuPrimitive: {
|
|
506
|
+
Root: typeof DropdownMenuRoot;
|
|
507
|
+
Trigger: react7.ForwardRefExoticComponent<DropdownMenuTriggerProps & react7.RefAttributes<DropdownMenuTriggerRef>>;
|
|
508
|
+
Portal: typeof DropdownMenuPortal;
|
|
509
|
+
Overlay: typeof DropdownMenuOverlay;
|
|
510
|
+
Content: typeof DropdownMenuContent;
|
|
511
|
+
Button: typeof DropdownMenuButton;
|
|
512
|
+
Divider: typeof DropdownMenuDivider;
|
|
513
|
+
};
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/primitives/popover/popover-trigger.d.ts
|
|
516
|
+
interface PopoverTriggerProps extends PressableProps {
|
|
517
|
+
children: React$1.ReactElement<RefAttributes<View> & PressableProps>;
|
|
518
|
+
}
|
|
519
|
+
interface PopoverTriggerRef {
|
|
520
|
+
open: () => void;
|
|
521
|
+
close: () => void;
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/primitives/popover/popover-content.d.ts
|
|
525
|
+
interface PopoverContentProps {
|
|
526
|
+
children?: React$1.ReactNode;
|
|
527
|
+
render?: (props: PopoverContentProps) => React$1.ReactNode;
|
|
528
|
+
style?: StyleProp<ViewStyle>;
|
|
529
|
+
}
|
|
530
|
+
declare function PopoverContent(props: PopoverContentProps): React$1.JSX.Element;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/primitives/popover/popover-overlay.d.ts
|
|
533
|
+
interface PopoverOverlayProps extends Omit<PressableProps, "onPress"> {
|
|
534
|
+
children?: React$1.ReactNode;
|
|
535
|
+
onPress?: () => void;
|
|
536
|
+
closeOnPress?: boolean;
|
|
537
|
+
render?: (props: PopoverOverlayProps) => React$1.ReactElement;
|
|
538
|
+
style?: StyleProp<ViewStyle>;
|
|
539
|
+
}
|
|
540
|
+
declare function PopoverOverlay(props: PopoverOverlayProps): React$1.JSX.Element;
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/primitives/popover/types.d.ts
|
|
543
|
+
interface PopoverStyles {
|
|
544
|
+
overlay?: PopoverOverlayProps["style"];
|
|
545
|
+
content?: PopoverContentProps["style"];
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/primitives/popover/popover-root.d.ts
|
|
549
|
+
interface PopoverRootProps {
|
|
550
|
+
children?: React$1.ReactNode;
|
|
551
|
+
render?: (props: PopoverRootProps) => React$1.ReactNode;
|
|
552
|
+
styles?: PopoverStyles;
|
|
553
|
+
}
|
|
554
|
+
declare function PopoverRoot(props: PopoverRootProps): React$1.JSX.Element;
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/primitives/popover/popover-portal.d.ts
|
|
557
|
+
interface PopoverPortalProps {
|
|
558
|
+
children?: React$1.ReactNode;
|
|
559
|
+
}
|
|
560
|
+
declare function PopoverPortal(props: PopoverPortalProps): React$1.JSX.Element | null;
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/primitives/popover/popover-close.d.ts
|
|
563
|
+
interface PopoverCloseProps extends Omit<PressableProps, "onPress"> {
|
|
564
|
+
children?: React$1.ReactNode;
|
|
565
|
+
onPress?: () => void;
|
|
566
|
+
render?: (props: PopoverCloseProps) => React$1.ReactNode;
|
|
567
|
+
style?: StyleProp<ViewStyle>;
|
|
568
|
+
}
|
|
569
|
+
declare function PopoverClose(props: PopoverCloseProps): React$1.JSX.Element;
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/primitives/popover/context.d.ts
|
|
572
|
+
interface PopoverContext {
|
|
573
|
+
isOpen: boolean;
|
|
574
|
+
setIsOpen: Dispatch<React.SetStateAction<boolean>>;
|
|
575
|
+
contentLayout: LayoutRectangle;
|
|
576
|
+
setContentLayout: Dispatch<React.SetStateAction<LayoutRectangle>>;
|
|
577
|
+
triggerPosition: LayoutPosition;
|
|
578
|
+
setTriggerPosition: Dispatch<React.SetStateAction<LayoutPosition>>;
|
|
579
|
+
styles?: PopoverStyles;
|
|
580
|
+
}
|
|
581
|
+
declare const PopoverContext: react7.Context<PopoverContext | undefined>;
|
|
582
|
+
declare const usePopover: () => PopoverContext;
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/primitives/popover/index.d.ts
|
|
585
|
+
declare const PopoverPrimitive: {
|
|
586
|
+
Root: typeof PopoverRoot;
|
|
587
|
+
Trigger: react7.ForwardRefExoticComponent<PopoverTriggerProps & react7.RefAttributes<PopoverTriggerRef>>;
|
|
588
|
+
Portal: typeof PopoverPortal;
|
|
589
|
+
Overlay: typeof PopoverOverlay;
|
|
590
|
+
Content: typeof PopoverContent;
|
|
591
|
+
Close: typeof PopoverClose;
|
|
592
|
+
};
|
|
437
593
|
//#endregion
|
|
438
|
-
export {
|
|
594
|
+
export { SelectPortalProps as $, ToastRootProps as A, EmptyRootProps as B, TextareaPrimitiveProps as C, BadgeStyles as D, BadgeRootProps as E, AvatarRootProps as F, CardPrimitive as G, EmptyTitleProps as H, AvatarStyles as I, CardFooterProps as J, CardRootProps as K, AvatarImageProps as L, ToastDescriptionProps as M, ToastTitleProps as N, BadgeLabelProps as O, AvatarPrimitive as P, SelectPrimitive as Q, AvatarFallbackProps as R, TextareaPrimitiveBaseProps as S, FieldLabelProps as St, BadgePrimitive as T, EmptyMediaProps as U, EmptyStyles as V, EmptyDescriptionProps as W, CardTitleProps as X, CardBodyProps as Y, CardHeaderProps as Z, DropdownMenuDividerProps as _, FieldPrimitive as _t, PopoverPortalProps as a, SelectOverlayProps as at, DropdownMenuTriggerProps as b, FieldErrorProps as bt, PopoverOverlayProps as c, ButtonPrimitive as ct, PopoverTriggerRef as d, ButtonStyles as dt, SelectRootBaseProps as et, DropdownMenuPrimitive as f, ButtonPrimitiveLabelProps as ft, DropdownMenuOverlayProps as g, InputStyles as gt, DropdownMenuStyles as h, InputPrimitiveProps as ht, PopoverCloseProps as i, SelectContentProps as it, ToastStyles as j, ToastPrimitive as k, PopoverContentProps as l, ButtonPrimitiveRootProps as lt, DropdownMenuRootProps as m, InputPrimitiveBaseProps as mt, PopoverContext as n, SelectStyles as nt, PopoverRootProps as o, SelectValueProps as ot, DropdownMenuPortalProps as p, InputPrimitive as pt, CardStyles as q, usePopover as r, SelectOptionProps as rt, PopoverStyles as s, SelectTriggerProps as st, PopoverPrimitive as t, SelectRootProps as tt, PopoverTriggerProps as u, ButtonState as ut, DropdownMenuButtonProps as v, FieldPrimitiveRootProps as vt, TextareaStyles as w, TextareaPrimitive as x, FieldDescriptionProps as xt, DropdownMenuContentProps as y, FieldStyles as yt, EmptyPrimitive as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/themes/types.d.ts
|
|
4
4
|
type ThemeName = "default";
|
|
@@ -37,7 +37,7 @@ interface ThemeContext {
|
|
|
37
37
|
setTheme: (themeName: ThemeName) => void;
|
|
38
38
|
themeName: ThemeName;
|
|
39
39
|
}
|
|
40
|
-
declare const ThemeContext:
|
|
40
|
+
declare const ThemeContext: react4.Context<ThemeContext | null>;
|
|
41
41
|
declare const useTheme: () => ThemeContext;
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/index.d.ts
|
|
@@ -45,6 +45,6 @@ declare const UniversalUIProvider: ({
|
|
|
45
45
|
children
|
|
46
46
|
}: {
|
|
47
47
|
children: React.ReactNode;
|
|
48
|
-
}) =>
|
|
48
|
+
}) => react4.JSX.Element;
|
|
49
49
|
//#endregion
|
|
50
50
|
export { UniversalUIProvider, useTheme };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as ThemeProvider, n as ToastContainer, o as useTheme } from "./toast-manager-
|
|
2
|
-
import {
|
|
1
|
+
import { a as ThemeProvider, n as ToastContainer, o as useTheme } from "./toast-manager-BfoJ-_dB.mjs";
|
|
2
|
+
import { m as PortalHost } from "./primitives-DNeYBN-3.mjs";
|
|
3
|
+
import "./use-relative-position-BTKEyT1F.mjs";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
|
|
5
6
|
//#region src/index.tsx
|