@thewhileloop/whileui 0.1.1 → 0.2.0
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/README.md +1243 -0
- package/dist/blocks/layout/action-bar.d.ts +8 -0
- package/dist/blocks/layout/action-bar.d.ts.map +1 -0
- package/dist/blocks/layout/action-bar.js +10 -0
- package/dist/blocks/layout/action-bar.js.map +1 -0
- package/dist/blocks/layout/confirm-action-sheet.d.ts +24 -0
- package/dist/blocks/layout/confirm-action-sheet.d.ts.map +1 -0
- package/dist/blocks/layout/confirm-action-sheet.js +41 -0
- package/dist/blocks/layout/confirm-action-sheet.js.map +1 -0
- package/dist/blocks/layout/index.d.ts +2 -0
- package/dist/blocks/layout/index.d.ts.map +1 -1
- package/dist/blocks/layout/index.js +2 -0
- package/dist/blocks/layout/index.js.map +1 -1
- package/dist/blocks/navigation/index.d.ts +1 -0
- package/dist/blocks/navigation/index.d.ts.map +1 -1
- package/dist/blocks/navigation/index.js +1 -0
- package/dist/blocks/navigation/index.js.map +1 -1
- package/dist/blocks/navigation/navigation-sidebar.d.ts +23 -0
- package/dist/blocks/navigation/navigation-sidebar.d.ts.map +1 -0
- package/dist/blocks/navigation/navigation-sidebar.js +11 -0
- package/dist/blocks/navigation/navigation-sidebar.js.map +1 -0
- package/dist/components/card/card.d.ts +81 -2
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +27 -6
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/index.d.ts.map +1 -1
- package/dist/components/card/index.js +1 -1
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/data-row/data-row.d.ts +69 -0
- package/dist/components/data-row/data-row.d.ts.map +1 -0
- package/dist/components/data-row/data-row.js +89 -0
- package/dist/components/data-row/data-row.js.map +1 -0
- package/dist/components/data-row/index.d.ts +2 -0
- package/dist/components/data-row/index.d.ts.map +1 -0
- package/dist/components/data-row/index.js +2 -0
- package/dist/components/data-row/index.js.map +1 -0
- package/dist/components/form-field/form-field.d.ts +124 -0
- package/dist/components/form-field/form-field.d.ts.map +1 -0
- package/dist/components/form-field/form-field.js +68 -0
- package/dist/components/form-field/form-field.js.map +1 -0
- package/dist/components/form-field/index.d.ts +2 -0
- package/dist/components/form-field/index.d.ts.map +1 -0
- package/dist/components/form-field/index.js +2 -0
- package/dist/components/form-field/index.js.map +1 -0
- package/dist/components/labeled-field/index.d.ts +2 -0
- package/dist/components/labeled-field/index.d.ts.map +1 -0
- package/dist/components/labeled-field/index.js +2 -0
- package/dist/components/labeled-field/index.js.map +1 -0
- package/dist/components/labeled-field/labeled-field.d.ts +19 -0
- package/dist/components/labeled-field/labeled-field.d.ts.map +1 -0
- package/dist/components/labeled-field/labeled-field.js +15 -0
- package/dist/components/labeled-field/labeled-field.js.map +1 -0
- package/dist/components/numeric-input/index.d.ts +2 -0
- package/dist/components/numeric-input/index.d.ts.map +1 -0
- package/dist/components/numeric-input/index.js +2 -0
- package/dist/components/numeric-input/index.js.map +1 -0
- package/dist/components/numeric-input/numeric-input.d.ts +119 -0
- package/dist/components/numeric-input/numeric-input.d.ts.map +1 -0
- package/dist/components/numeric-input/numeric-input.js +129 -0
- package/dist/components/numeric-input/numeric-input.js.map +1 -0
- package/dist/components/segmented-control/index.d.ts +2 -0
- package/dist/components/segmented-control/index.d.ts.map +1 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/index.js.map +1 -0
- package/dist/components/segmented-control/segmented-control.d.ts +281 -0
- package/dist/components/segmented-control/segmented-control.d.ts.map +1 -0
- package/dist/components/segmented-control/segmented-control.js +110 -0
- package/dist/components/segmented-control/segmented-control.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/theme-bridge.d.ts +29 -0
- package/dist/lib/theme-bridge.d.ts.map +1 -0
- package/dist/lib/theme-bridge.js +79 -0
- package/dist/lib/theme-bridge.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
import { type VariantProps } from '../../lib/tv';
|
|
4
|
+
declare const formFieldVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
density: {
|
|
6
|
+
default: string;
|
|
7
|
+
compact: string;
|
|
8
|
+
};
|
|
9
|
+
}, undefined, "w-full", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
10
|
+
density: {
|
|
11
|
+
default: string;
|
|
12
|
+
compact: string;
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
density: {
|
|
16
|
+
default: string;
|
|
17
|
+
compact: string;
|
|
18
|
+
};
|
|
19
|
+
}>, {
|
|
20
|
+
density: {
|
|
21
|
+
default: string;
|
|
22
|
+
compact: string;
|
|
23
|
+
};
|
|
24
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
25
|
+
density: {
|
|
26
|
+
default: string;
|
|
27
|
+
compact: string;
|
|
28
|
+
};
|
|
29
|
+
}, undefined, "w-full", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
30
|
+
density: {
|
|
31
|
+
default: string;
|
|
32
|
+
compact: string;
|
|
33
|
+
};
|
|
34
|
+
}, {
|
|
35
|
+
density: {
|
|
36
|
+
default: string;
|
|
37
|
+
compact: string;
|
|
38
|
+
};
|
|
39
|
+
}>, unknown, unknown, undefined>>;
|
|
40
|
+
declare const formControlVariants: import("tailwind-variants").TVReturnType<{
|
|
41
|
+
density: {
|
|
42
|
+
default: string;
|
|
43
|
+
compact: string;
|
|
44
|
+
};
|
|
45
|
+
invalid: {
|
|
46
|
+
true: string;
|
|
47
|
+
false: string;
|
|
48
|
+
};
|
|
49
|
+
}, undefined, "justify-center", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
50
|
+
density: {
|
|
51
|
+
default: string;
|
|
52
|
+
compact: string;
|
|
53
|
+
};
|
|
54
|
+
invalid: {
|
|
55
|
+
true: string;
|
|
56
|
+
false: string;
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
density: {
|
|
60
|
+
default: string;
|
|
61
|
+
compact: string;
|
|
62
|
+
};
|
|
63
|
+
invalid: {
|
|
64
|
+
true: string;
|
|
65
|
+
false: string;
|
|
66
|
+
};
|
|
67
|
+
}>, {
|
|
68
|
+
density: {
|
|
69
|
+
default: string;
|
|
70
|
+
compact: string;
|
|
71
|
+
};
|
|
72
|
+
invalid: {
|
|
73
|
+
true: string;
|
|
74
|
+
false: string;
|
|
75
|
+
};
|
|
76
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
77
|
+
density: {
|
|
78
|
+
default: string;
|
|
79
|
+
compact: string;
|
|
80
|
+
};
|
|
81
|
+
invalid: {
|
|
82
|
+
true: string;
|
|
83
|
+
false: string;
|
|
84
|
+
};
|
|
85
|
+
}, undefined, "justify-center", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
86
|
+
density: {
|
|
87
|
+
default: string;
|
|
88
|
+
compact: string;
|
|
89
|
+
};
|
|
90
|
+
invalid: {
|
|
91
|
+
true: string;
|
|
92
|
+
false: string;
|
|
93
|
+
};
|
|
94
|
+
}, {
|
|
95
|
+
density: {
|
|
96
|
+
default: string;
|
|
97
|
+
compact: string;
|
|
98
|
+
};
|
|
99
|
+
invalid: {
|
|
100
|
+
true: string;
|
|
101
|
+
false: string;
|
|
102
|
+
};
|
|
103
|
+
}>, unknown, unknown, undefined>>;
|
|
104
|
+
export interface FormFieldProps extends ViewProps, VariantProps<typeof formFieldVariants> {
|
|
105
|
+
invalid?: boolean;
|
|
106
|
+
disabled?: boolean;
|
|
107
|
+
required?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface FormLabelProps extends TextProps {
|
|
110
|
+
showRequiredIndicator?: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface FormControlProps extends ViewProps {
|
|
113
|
+
}
|
|
114
|
+
export interface FormHintProps extends TextProps {
|
|
115
|
+
}
|
|
116
|
+
export interface FormMessageProps extends TextProps {
|
|
117
|
+
}
|
|
118
|
+
declare const FormField: React.ForwardRefExoticComponent<FormFieldProps & React.RefAttributes<View>>;
|
|
119
|
+
declare const FormLabel: React.ForwardRefExoticComponent<FormLabelProps & React.RefAttributes<Text>>;
|
|
120
|
+
declare const FormControl: React.ForwardRefExoticComponent<FormControlProps & React.RefAttributes<View>>;
|
|
121
|
+
declare const FormHint: React.ForwardRefExoticComponent<FormHintProps & React.RefAttributes<Text>>;
|
|
122
|
+
declare const FormMessage: React.ForwardRefExoticComponent<FormMessageProps & React.RefAttributes<Text>>;
|
|
123
|
+
export { FormField, FormLabel, FormControl, FormHint, FormMessage, formFieldVariants, formControlVariants, };
|
|
124
|
+
//# sourceMappingURL=form-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field.d.ts","sourceRoot":"","sources":["../../../src/components/form-field/form-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAWrB,CAAC;AAEH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAgBvB,CAAC;AAkBH,MAAM,WAAW,cAAe,SAAQ,SAAS,EAAE,YAAY,CAAC,OAAO,iBAAiB,CAAC;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,gBAAiB,SAAQ,SAAS;CAAG;AAEtD,MAAM,WAAW,aAAc,SAAQ,SAAS;CAAG;AAEnD,MAAM,WAAW,gBAAiB,SAAQ,SAAS;CAAG;AAEtD,QAAA,MAAM,SAAS,6EAsBd,CAAC;AAIF,QAAA,MAAM,SAAS,6EAoBd,CAAC;AAIF,QAAA,MAAM,WAAW,+EAef,CAAC;AAIH,QAAA,MAAM,QAAQ,4EAUZ,CAAC;AAIH,QAAA,MAAM,WAAW,+EAYhB,CAAC;AAIF,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
|
+
import { Text, View } from 'react-native';
|
|
4
|
+
import { cn } from '../../lib/cn';
|
|
5
|
+
import { tv } from '../../lib/tv';
|
|
6
|
+
const formFieldVariants = tv({
|
|
7
|
+
base: 'w-full',
|
|
8
|
+
variants: {
|
|
9
|
+
density: {
|
|
10
|
+
default: 'gap-1.5',
|
|
11
|
+
compact: 'gap-1',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
density: 'default',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const formControlVariants = tv({
|
|
19
|
+
base: 'justify-center',
|
|
20
|
+
variants: {
|
|
21
|
+
density: {
|
|
22
|
+
default: 'min-h-10',
|
|
23
|
+
compact: 'min-h-9',
|
|
24
|
+
},
|
|
25
|
+
invalid: {
|
|
26
|
+
true: '',
|
|
27
|
+
false: '',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
density: 'default',
|
|
32
|
+
invalid: false,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const FormFieldContext = createContext({
|
|
36
|
+
density: 'default',
|
|
37
|
+
invalid: false,
|
|
38
|
+
disabled: false,
|
|
39
|
+
required: false,
|
|
40
|
+
});
|
|
41
|
+
const FormField = React.forwardRef(({ className, density = 'default', invalid = false, disabled = false, required = false, ...props }, ref) => {
|
|
42
|
+
return (_jsx(FormFieldContext.Provider, { value: { density, invalid, disabled, required }, children: _jsx(View, { ref: ref, className: cn(formFieldVariants({ density }), disabled && 'opacity-60', className), ...props }) }));
|
|
43
|
+
});
|
|
44
|
+
FormField.displayName = 'FormField';
|
|
45
|
+
const FormLabel = React.forwardRef(({ className, showRequiredIndicator = true, children, ...props }, ref) => {
|
|
46
|
+
const { invalid, disabled, required } = useContext(FormFieldContext);
|
|
47
|
+
return (_jsxs(Text, { ref: ref, className: cn('text-sm font-medium leading-none text-foreground', invalid && 'text-destructive', disabled && 'text-muted-foreground', className), ...props, children: [children, required && showRequiredIndicator ? _jsx(Text, { className: "text-destructive", children: " *" }) : null] }));
|
|
48
|
+
});
|
|
49
|
+
FormLabel.displayName = 'FormLabel';
|
|
50
|
+
const FormControl = React.forwardRef(({ className, ...props }, ref) => {
|
|
51
|
+
const { density, invalid, disabled } = useContext(FormFieldContext);
|
|
52
|
+
return (_jsx(View, { ref: ref, className: cn(formControlVariants({ density, invalid }), invalid && 'rounded-md ring-1 ring-destructive/60', disabled && 'opacity-60', className), ...props }));
|
|
53
|
+
});
|
|
54
|
+
FormControl.displayName = 'FormControl';
|
|
55
|
+
const FormHint = React.forwardRef(({ className, ...props }, ref) => {
|
|
56
|
+
const { invalid } = useContext(FormFieldContext);
|
|
57
|
+
return (_jsx(Text, { ref: ref, className: cn('text-xs text-muted-foreground', invalid && 'text-destructive/80', className), ...props }));
|
|
58
|
+
});
|
|
59
|
+
FormHint.displayName = 'FormHint';
|
|
60
|
+
const FormMessage = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
61
|
+
if (children === undefined || children === null || children === false) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return (_jsx(Text, { ref: ref, className: cn('text-xs font-medium text-destructive', className), ...props, children: children }));
|
|
65
|
+
});
|
|
66
|
+
FormMessage.displayName = 'FormMessage';
|
|
67
|
+
export { FormField, FormLabel, FormControl, FormHint, FormMessage, formFieldVariants, formControlVariants, };
|
|
68
|
+
//# sourceMappingURL=form-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field.js","sourceRoot":"","sources":["../../../src/components/form-field/form-field.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,EAAE,EAAqB,MAAM,cAAc,CAAC;AAErD,MAAM,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,OAAO;SACjB;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;CACF,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,EAAE,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,SAAS;SACnB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,OAAO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AAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,SAAS,CAAC,KAAM,KAAK,YACxF,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/form-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/form-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GAMpB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/labeled-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/labeled-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,GAGpB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { type FormFieldProps } from '../form-field';
|
|
4
|
+
export interface LabeledFieldProps extends Omit<FormFieldProps, 'children'> {
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
hint?: React.ReactNode;
|
|
7
|
+
error?: React.ReactNode;
|
|
8
|
+
leftSlot?: React.ReactNode;
|
|
9
|
+
rightSlot?: React.ReactNode;
|
|
10
|
+
controlWrapperClassName?: string;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface LabeledFieldControlProps extends ViewProps {
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function LabeledField({ label, hint, error, leftSlot, rightSlot, children, controlWrapperClassName, required, disabled, invalid, ...props }: LabeledFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const LabeledFieldControl: React.ForwardRefExoticComponent<LabeledFieldControlProps & React.RefAttributes<View>>;
|
|
18
|
+
export { LabeledField, LabeledFieldControl };
|
|
19
|
+
//# sourceMappingURL=labeled-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labeled-field.d.ts","sourceRoot":"","sources":["../../../src/components/labeled-field/labeled-field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC;IACzE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAyB,SAAQ,SAAS;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,YAAY,CAAC,EACpB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACT,EAAE,iBAAiB,2CAuBnB;AAED,QAAA,MAAM,mBAAmB,uFAIxB,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { FormControl, FormField, FormHint, FormLabel, FormMessage, } from '../form-field';
|
|
5
|
+
import { cn } from '../../lib/cn';
|
|
6
|
+
function LabeledField({ label, hint, error, leftSlot, rightSlot, children, controlWrapperClassName, required, disabled, invalid, ...props }) {
|
|
7
|
+
const isInvalid = invalid ?? Boolean(error);
|
|
8
|
+
return (_jsxs(FormField, { required: required, disabled: disabled, invalid: isInvalid, ...props, children: [label ? _jsx(FormLabel, { children: label }) : null, _jsx(FormControl, { children: _jsxs(View, { className: cn('flex-row items-center gap-2 rounded-md border border-input bg-background px-3', isInvalid && 'border-destructive', disabled && 'opacity-60', controlWrapperClassName), children: [leftSlot ? _jsx(View, { className: "shrink-0", children: leftSlot }) : null, _jsx(View, { className: "min-h-10 min-w-0 flex-1 justify-center", children: children }), rightSlot ? _jsx(View, { className: "shrink-0", children: rightSlot }) : null] }) }), error ? _jsx(FormMessage, { children: error }) : hint ? _jsx(FormHint, { children: hint }) : null] }));
|
|
9
|
+
}
|
|
10
|
+
const LabeledFieldControl = React.forwardRef(({ className, ...props }, ref) => {
|
|
11
|
+
return _jsx(View, { ref: ref, className: cn('min-w-0 flex-1', className), ...props });
|
|
12
|
+
});
|
|
13
|
+
LabeledFieldControl.displayName = 'LabeledFieldControl';
|
|
14
|
+
export { LabeledField, LabeledFieldControl };
|
|
15
|
+
//# sourceMappingURL=labeled-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labeled-field.js","sourceRoot":"","sources":["../../../src/components/labeled-field/labeled-field.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,GAEZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAgBlC,SAAS,YAAY,CAAC,EACpB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACU;IAClB,MAAM,SAAS,GAAG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAE5C,OAAO,CACL,MAAC,SAAS,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,KAAM,KAAK,aAC7E,KAAK,CAAC,CAAC,CAAC,KAAC,SAAS,cAAE,KAAK,GAAa,CAAC,CAAC,CAAC,IAAI,EAC9C,KAAC,WAAW,cACV,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":"index.js","sourceRoot":"","sources":["../../../src/components/numeric-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInput, type TextInputProps } from 'react-native';
|
|
3
|
+
import { type VariantProps } from '../../lib/tv';
|
|
4
|
+
declare const numericInputVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
variant: {
|
|
6
|
+
default: string;
|
|
7
|
+
error: string;
|
|
8
|
+
};
|
|
9
|
+
size: {
|
|
10
|
+
default: string;
|
|
11
|
+
compact: string;
|
|
12
|
+
};
|
|
13
|
+
}, undefined, "w-full flex-row items-center rounded-md border bg-background", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
14
|
+
variant: {
|
|
15
|
+
default: string;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
size: {
|
|
19
|
+
default: string;
|
|
20
|
+
compact: string;
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
variant: {
|
|
24
|
+
default: string;
|
|
25
|
+
error: string;
|
|
26
|
+
};
|
|
27
|
+
size: {
|
|
28
|
+
default: string;
|
|
29
|
+
compact: string;
|
|
30
|
+
};
|
|
31
|
+
}>, {
|
|
32
|
+
variant: {
|
|
33
|
+
default: string;
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
size: {
|
|
37
|
+
default: string;
|
|
38
|
+
compact: string;
|
|
39
|
+
};
|
|
40
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
41
|
+
variant: {
|
|
42
|
+
default: string;
|
|
43
|
+
error: string;
|
|
44
|
+
};
|
|
45
|
+
size: {
|
|
46
|
+
default: string;
|
|
47
|
+
compact: string;
|
|
48
|
+
};
|
|
49
|
+
}, undefined, "w-full flex-row items-center rounded-md border bg-background", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
50
|
+
variant: {
|
|
51
|
+
default: string;
|
|
52
|
+
error: string;
|
|
53
|
+
};
|
|
54
|
+
size: {
|
|
55
|
+
default: string;
|
|
56
|
+
compact: string;
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
variant: {
|
|
60
|
+
default: string;
|
|
61
|
+
error: string;
|
|
62
|
+
};
|
|
63
|
+
size: {
|
|
64
|
+
default: string;
|
|
65
|
+
compact: string;
|
|
66
|
+
};
|
|
67
|
+
}>, unknown, unknown, undefined>>;
|
|
68
|
+
declare const numericInputTextVariants: import("tailwind-variants").TVReturnType<{
|
|
69
|
+
size: {
|
|
70
|
+
default: string;
|
|
71
|
+
compact: string;
|
|
72
|
+
};
|
|
73
|
+
}, undefined, "flex-1 px-3 py-2 text-foreground", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
74
|
+
size: {
|
|
75
|
+
default: string;
|
|
76
|
+
compact: string;
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
size: {
|
|
80
|
+
default: string;
|
|
81
|
+
compact: string;
|
|
82
|
+
};
|
|
83
|
+
}>, {
|
|
84
|
+
size: {
|
|
85
|
+
default: string;
|
|
86
|
+
compact: string;
|
|
87
|
+
};
|
|
88
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
89
|
+
size: {
|
|
90
|
+
default: string;
|
|
91
|
+
compact: string;
|
|
92
|
+
};
|
|
93
|
+
}, undefined, "flex-1 px-3 py-2 text-foreground", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
94
|
+
size: {
|
|
95
|
+
default: string;
|
|
96
|
+
compact: string;
|
|
97
|
+
};
|
|
98
|
+
}, {
|
|
99
|
+
size: {
|
|
100
|
+
default: string;
|
|
101
|
+
compact: string;
|
|
102
|
+
};
|
|
103
|
+
}>, unknown, unknown, undefined>>;
|
|
104
|
+
export interface NumericInputProps extends Omit<TextInputProps, 'value' | 'defaultValue' | 'onChangeText' | 'keyboardType'>, VariantProps<typeof numericInputVariants> {
|
|
105
|
+
className?: string;
|
|
106
|
+
inputClassName?: string;
|
|
107
|
+
prefix?: React.ReactNode;
|
|
108
|
+
suffix?: React.ReactNode;
|
|
109
|
+
value?: number | null;
|
|
110
|
+
defaultValue?: number;
|
|
111
|
+
onValueChange?: (value: number | null) => void;
|
|
112
|
+
min?: number;
|
|
113
|
+
max?: number;
|
|
114
|
+
step?: number;
|
|
115
|
+
showSteppers?: boolean;
|
|
116
|
+
}
|
|
117
|
+
declare const NumericInput: React.ForwardRefExoticComponent<NumericInputProps & React.RefAttributes<TextInput>>;
|
|
118
|
+
export { NumericInput, numericInputVariants, numericInputTextVariants };
|
|
119
|
+
//# sourceMappingURL=numeric-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-input.d.ts","sourceRoot":"","sources":["../../../src/components/numeric-input/numeric-input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAmB,SAAS,EAAQ,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAgBxB,CAAC;AAEH,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAW5B,CAAC;AAgDH,MAAM,WAAW,iBACf,SACE,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,CAAC,EAChF,YAAY,CAAC,OAAO,oBAAoB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,YAAY,qFA0IjB,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { Pressable, Text, TextInput, View } from 'react-native';
|
|
4
|
+
import { cn } from '../../lib/cn';
|
|
5
|
+
import { tv } from '../../lib/tv';
|
|
6
|
+
const numericInputVariants = tv({
|
|
7
|
+
base: 'w-full flex-row items-center rounded-md border bg-background',
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'border-input',
|
|
11
|
+
error: 'border-destructive',
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
default: 'h-10',
|
|
15
|
+
compact: 'h-9',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
variant: 'default',
|
|
20
|
+
size: 'default',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const numericInputTextVariants = tv({
|
|
24
|
+
base: 'flex-1 px-3 py-2 text-foreground',
|
|
25
|
+
variants: {
|
|
26
|
+
size: {
|
|
27
|
+
default: 'text-sm',
|
|
28
|
+
compact: 'text-xs',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
size: 'default',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const stepperButtonVariants = tv({
|
|
36
|
+
base: 'h-full w-11 items-center justify-center active:opacity-70',
|
|
37
|
+
variants: {
|
|
38
|
+
size: {
|
|
39
|
+
default: 'px-3',
|
|
40
|
+
compact: 'px-2',
|
|
41
|
+
},
|
|
42
|
+
disabled: {
|
|
43
|
+
true: 'opacity-40',
|
|
44
|
+
false: '',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
size: 'default',
|
|
49
|
+
disabled: false,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
function toInputText(value) {
|
|
53
|
+
if (value === null || value === undefined) {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
return Number.isFinite(value) ? String(value) : '';
|
|
57
|
+
}
|
|
58
|
+
function parseNumericText(text) {
|
|
59
|
+
const normalized = text.replace(',', '.').trim();
|
|
60
|
+
if (!normalized || normalized === '-' || normalized === '.' || normalized === '-.') {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const parsed = Number.parseFloat(normalized);
|
|
64
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
65
|
+
}
|
|
66
|
+
function clampValue(value, min, max) {
|
|
67
|
+
let next = value;
|
|
68
|
+
if (min !== undefined && next < min) {
|
|
69
|
+
next = min;
|
|
70
|
+
}
|
|
71
|
+
if (max !== undefined && next > max) {
|
|
72
|
+
next = max;
|
|
73
|
+
}
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
76
|
+
const NumericInput = React.forwardRef(({ className, inputClassName, prefix, suffix, value, defaultValue, onValueChange, min, max, step = 1, showSteppers = false, variant = 'default', size = 'default', editable = true, placeholderTextColor = '#737373', onBlur, ...props }, ref) => {
|
|
77
|
+
const [internalText, setInternalText] = useState(() => toInputText(defaultValue));
|
|
78
|
+
const isControlled = value !== undefined;
|
|
79
|
+
const textValue = isControlled ? toInputText(value) : internalText;
|
|
80
|
+
const currentValue = useMemo(() => parseNumericText(textValue), [textValue]);
|
|
81
|
+
const setTextAndValue = useCallback((nextText) => {
|
|
82
|
+
if (!isControlled) {
|
|
83
|
+
setInternalText(nextText);
|
|
84
|
+
}
|
|
85
|
+
onValueChange?.(parseNumericText(nextText));
|
|
86
|
+
}, [isControlled, onValueChange]);
|
|
87
|
+
const applyNumericValue = useCallback((nextValue) => {
|
|
88
|
+
if (nextValue === null) {
|
|
89
|
+
if (!isControlled) {
|
|
90
|
+
setInternalText('');
|
|
91
|
+
}
|
|
92
|
+
onValueChange?.(null);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const clamped = clampValue(nextValue, min, max);
|
|
96
|
+
if (!isControlled) {
|
|
97
|
+
setInternalText(toInputText(clamped));
|
|
98
|
+
}
|
|
99
|
+
onValueChange?.(clamped);
|
|
100
|
+
}, [isControlled, max, min, onValueChange]);
|
|
101
|
+
const handleTextChange = (nextText) => {
|
|
102
|
+
const isNumericLike = /^-?\d*(?:[.,]\d*)?$/.test(nextText);
|
|
103
|
+
if (!isNumericLike) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setTextAndValue(nextText);
|
|
107
|
+
};
|
|
108
|
+
const handleBlur = (event) => {
|
|
109
|
+
const parsed = parseNumericText(textValue);
|
|
110
|
+
if (parsed !== null) {
|
|
111
|
+
const clamped = clampValue(parsed, min, max);
|
|
112
|
+
if (!isControlled) {
|
|
113
|
+
setInternalText(toInputText(clamped));
|
|
114
|
+
}
|
|
115
|
+
onValueChange?.(clamped);
|
|
116
|
+
}
|
|
117
|
+
onBlur?.(event);
|
|
118
|
+
};
|
|
119
|
+
const canDecrease = editable && (min === undefined || currentValue === null || currentValue > min);
|
|
120
|
+
const canIncrease = editable && (max === undefined || currentValue === null || currentValue < max);
|
|
121
|
+
const nudge = (delta) => {
|
|
122
|
+
const baseline = currentValue ?? min ?? 0;
|
|
123
|
+
applyNumericValue(baseline + delta * step);
|
|
124
|
+
};
|
|
125
|
+
return (_jsxs(View, { className: cn(numericInputVariants({ variant, size }), !editable && 'opacity-50', className), children: [prefix ? _jsx(View, { className: "shrink-0 pl-3", children: prefix }) : null, _jsx(TextInput, { ref: ref, className: cn(numericInputTextVariants({ size }), inputClassName), value: textValue, onChangeText: handleTextChange, onBlur: handleBlur, keyboardType: "decimal-pad", editable: editable, placeholderTextColor: placeholderTextColor, ...props }), suffix ? _jsx(View, { className: "shrink-0 pr-3", children: suffix }) : null, showSteppers ? (_jsxs(View, { className: "ml-1 h-full flex-row border-l border-input", children: [_jsx(Pressable, { className: cn(stepperButtonVariants({ size, disabled: !canDecrease })), onPress: () => nudge(-1), disabled: !canDecrease, hitSlop: 4, accessibilityRole: "button", accessibilityLabel: "Decrease value", children: _jsx(Text, { className: "text-base font-medium text-foreground", children: "-" }) }), _jsx(Pressable, { className: cn(stepperButtonVariants({ size, disabled: !canIncrease })), onPress: () => nudge(1), disabled: !canIncrease, hitSlop: 4, accessibilityRole: "button", accessibilityLabel: "Increase value", children: _jsx(Text, { className: "text-base font-medium text-foreground", children: "+" }) })] })) : null] }));
|
|
126
|
+
});
|
|
127
|
+
NumericInput.displayName = 'NumericInput';
|
|
128
|
+
export { NumericInput, numericInputVariants, numericInputTextVariants };
|
|
129
|
+
//# sourceMappingURL=numeric-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-input.js","sourceRoot":"","sources":["../../../src/components/numeric-input/numeric-input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAuB,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,EAAE,EAAqB,MAAM,cAAc,CAAC;AAErD,MAAM,oBAAoB,GAAG,EAAE,CAAC;IAC9B,IAAI,EAAE,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,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SegmentedControl, SegmentedControlItem, SegmentedControlItemText, segmentedControlVariants, segmentedControlItemVariants, segmentedControlItemTextVariants, type SegmentedControlProps, type SegmentedControlItemProps, type SegmentedControlItemTextProps, } from './segmented-control';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,gCAAgC,EAChC,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,GACnC,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/segmented-control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,gCAAgC,GAIjC,MAAM,qBAAqB,CAAC"}
|