@skybin-tech/nebula-ui 0.0.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/cjs/components/Button/Button.cjs +37 -0
- package/dist/cjs/components/Button/Button.cjs.map +1 -0
- package/dist/cjs/components/Form/Checkbox.cjs +145 -0
- package/dist/cjs/components/Form/Checkbox.cjs.map +1 -0
- package/dist/cjs/components/Form/Form.cjs +93 -0
- package/dist/cjs/components/Form/Form.cjs.map +1 -0
- package/dist/cjs/components/Form/Radio.cjs +178 -0
- package/dist/cjs/components/Form/Radio.cjs.map +1 -0
- package/dist/cjs/components/Form/Select.cjs +168 -0
- package/dist/cjs/components/Form/Select.cjs.map +1 -0
- package/dist/cjs/components/Form/Switch.cjs +125 -0
- package/dist/cjs/components/Form/Switch.cjs.map +1 -0
- package/dist/cjs/components/Form/TextArea.cjs +168 -0
- package/dist/cjs/components/Form/TextArea.cjs.map +1 -0
- package/dist/cjs/components/Form/TextBox.cjs +211 -0
- package/dist/cjs/components/Form/TextBox.cjs.map +1 -0
- package/dist/cjs/components/Form/context.cjs +131 -0
- package/dist/cjs/components/Form/context.cjs.map +1 -0
- package/dist/cjs/components/Form/hooks.cjs +36 -0
- package/dist/cjs/components/Form/hooks.cjs.map +1 -0
- package/dist/cjs/components/Input/Input.cjs +44 -0
- package/dist/cjs/components/Input/Input.cjs.map +1 -0
- package/dist/cjs/components/ui/checkbox.cjs +45 -0
- package/dist/cjs/components/ui/checkbox.cjs.map +1 -0
- package/dist/cjs/components/ui/input.cjs +41 -0
- package/dist/cjs/components/ui/input.cjs.map +1 -0
- package/dist/cjs/components/ui/label.cjs +38 -0
- package/dist/cjs/components/ui/label.cjs.map +1 -0
- package/dist/cjs/components/ui/radio-group.cjs +53 -0
- package/dist/cjs/components/ui/radio-group.cjs.map +1 -0
- package/dist/cjs/components/ui/select.cjs +144 -0
- package/dist/cjs/components/ui/select.cjs.map +1 -0
- package/dist/cjs/components/ui/switch.cjs +45 -0
- package/dist/cjs/components/ui/switch.cjs.map +1 -0
- package/dist/cjs/components/ui/textarea.cjs +38 -0
- package/dist/cjs/components/ui/textarea.cjs.map +1 -0
- package/dist/cjs/hooks/useDebounce.cjs +17 -0
- package/dist/cjs/hooks/useDebounce.cjs.map +1 -0
- package/dist/cjs/hooks/useToggle.cjs +12 -0
- package/dist/cjs/hooks/useToggle.cjs.map +1 -0
- package/dist/cjs/index.cjs +65 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/nebula-ui.css +212 -0
- package/dist/cjs/utils/cn.cjs +9 -0
- package/dist/cjs/utils/cn.cjs.map +1 -0
- package/dist/components/Button/Button.d.ts +18 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +37 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Form/Checkbox.d.ts +32 -0
- package/dist/components/Form/Checkbox.d.ts.map +1 -0
- package/dist/components/Form/Checkbox.js +145 -0
- package/dist/components/Form/Checkbox.js.map +1 -0
- package/dist/components/Form/Form.d.ts +62 -0
- package/dist/components/Form/Form.d.ts.map +1 -0
- package/dist/components/Form/Form.js +93 -0
- package/dist/components/Form/Form.js.map +1 -0
- package/dist/components/Form/Radio.d.ts +80 -0
- package/dist/components/Form/Radio.d.ts.map +1 -0
- package/dist/components/Form/Radio.js +178 -0
- package/dist/components/Form/Radio.js.map +1 -0
- package/dist/components/Form/Select.d.ts +75 -0
- package/dist/components/Form/Select.d.ts.map +1 -0
- package/dist/components/Form/Select.js +168 -0
- package/dist/components/Form/Select.js.map +1 -0
- package/dist/components/Form/Switch.d.ts +34 -0
- package/dist/components/Form/Switch.d.ts.map +1 -0
- package/dist/components/Form/Switch.js +125 -0
- package/dist/components/Form/Switch.js.map +1 -0
- package/dist/components/Form/TextArea.d.ts +47 -0
- package/dist/components/Form/TextArea.d.ts.map +1 -0
- package/dist/components/Form/TextArea.js +168 -0
- package/dist/components/Form/TextArea.js.map +1 -0
- package/dist/components/Form/TextBox.d.ts +61 -0
- package/dist/components/Form/TextBox.d.ts.map +1 -0
- package/dist/components/Form/TextBox.js +211 -0
- package/dist/components/Form/TextBox.js.map +1 -0
- package/dist/components/Form/context.d.ts +107 -0
- package/dist/components/Form/context.d.ts.map +1 -0
- package/dist/components/Form/context.js +131 -0
- package/dist/components/Form/context.js.map +1 -0
- package/dist/components/Form/hooks.d.ts +21 -0
- package/dist/components/Form/hooks.d.ts.map +1 -0
- package/dist/components/Form/hooks.js +36 -0
- package/dist/components/Form/hooks.js.map +1 -0
- package/dist/components/Form/index.d.ts +18 -0
- package/dist/components/Form/index.d.ts.map +1 -0
- package/dist/components/Input/Input.d.ts +18 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/Input.js +44 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +28 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/index.d.ts +16 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +11 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +24 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +21 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +6 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +36 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +127 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +28 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +11 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +21 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/hooks/useDebounce.d.ts +8 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -0
- package/dist/hooks/useDebounce.js +17 -0
- package/dist/hooks/useDebounce.js.map +1 -0
- package/dist/hooks/useToggle.d.ts +7 -0
- package/dist/hooks/useToggle.d.ts.map +1 -0
- package/dist/hooks/useToggle.js +12 -0
- package/dist/hooks/useToggle.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/nebula-ui.css +212 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +9 -0
- package/dist/utils/cn.js.map +1 -0
- package/package.json +201 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { UseFormReturn, FieldValues } from 'react-hook-form';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Validation rule types that can be applied to form fields
|
|
5
|
+
*/
|
|
6
|
+
export interface FieldValidationRules {
|
|
7
|
+
/** Field is required */
|
|
8
|
+
required?: boolean | string;
|
|
9
|
+
/** Minimum length for strings */
|
|
10
|
+
minLength?: number | {
|
|
11
|
+
value: number;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
/** Maximum length for strings */
|
|
15
|
+
maxLength?: number | {
|
|
16
|
+
value: number;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
/** Minimum value for numbers */
|
|
20
|
+
min?: number | {
|
|
21
|
+
value: number;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
/** Maximum value for numbers */
|
|
25
|
+
max?: number | {
|
|
26
|
+
value: number;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
/** Regex pattern for validation */
|
|
30
|
+
pattern?: RegExp | {
|
|
31
|
+
value: RegExp;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
/** Email validation */
|
|
35
|
+
email?: boolean | string;
|
|
36
|
+
/** URL validation */
|
|
37
|
+
url?: boolean | string;
|
|
38
|
+
/** Custom validation function */
|
|
39
|
+
validate?: (value: unknown) => boolean | string | Promise<boolean | string>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Form configuration options
|
|
43
|
+
*/
|
|
44
|
+
export interface FormConfig {
|
|
45
|
+
/** Show validation errors inline */
|
|
46
|
+
showInlineErrors?: boolean;
|
|
47
|
+
/** Validate on blur */
|
|
48
|
+
validateOnBlur?: boolean;
|
|
49
|
+
/** Validate on change */
|
|
50
|
+
validateOnChange?: boolean;
|
|
51
|
+
/** Size of form controls */
|
|
52
|
+
size?: "sm" | "md" | "lg";
|
|
53
|
+
/** Layout direction */
|
|
54
|
+
layout?: "horizontal" | "vertical" | "inline";
|
|
55
|
+
/** Label width for horizontal layout */
|
|
56
|
+
labelWidth?: string | number;
|
|
57
|
+
/** Whether form is disabled */
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
/** Colon after label */
|
|
60
|
+
colon?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Field registration info
|
|
64
|
+
*/
|
|
65
|
+
export interface FieldRegistration {
|
|
66
|
+
name: string;
|
|
67
|
+
type: "string" | "number" | "boolean" | "date" | "array";
|
|
68
|
+
rules: FieldValidationRules;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Form context value
|
|
72
|
+
*/
|
|
73
|
+
export interface FormContextValue<TFieldValues extends FieldValues = FieldValues> extends FormConfig {
|
|
74
|
+
form: UseFormReturn<TFieldValues>;
|
|
75
|
+
/** Register a field's validation rules */
|
|
76
|
+
registerFieldValidation: (field: FieldRegistration) => void;
|
|
77
|
+
/** Unregister a field's validation rules */
|
|
78
|
+
unregisterFieldValidation: (name: string) => void;
|
|
79
|
+
/** Get current validation schema */
|
|
80
|
+
getValidationSchema: () => z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
81
|
+
/** Trigger validation for a specific field */
|
|
82
|
+
triggerValidation: (name: string) => Promise<boolean>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Default form configuration
|
|
86
|
+
*/
|
|
87
|
+
export declare const defaultFormConfig: FormConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Form context for sharing form state and configuration
|
|
90
|
+
*/
|
|
91
|
+
export declare const FormConfigContext: import('react').Context<FormContextValue<FieldValues> | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Build a Zod schema from validation rules
|
|
94
|
+
*/
|
|
95
|
+
export declare function buildZodSchemaFromRules(type: FieldRegistration["type"], rules: FieldValidationRules): z.ZodTypeAny;
|
|
96
|
+
/**
|
|
97
|
+
* Hook to manage field validations
|
|
98
|
+
*/
|
|
99
|
+
export declare function useFieldValidationRegistry(): {
|
|
100
|
+
registerFieldValidation: (field: FieldRegistration) => void;
|
|
101
|
+
unregisterFieldValidation: (name: string) => void;
|
|
102
|
+
getValidationSchema: () => z.ZodObject<{
|
|
103
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
fieldsRef: import('react').RefObject<Map<string, FieldRegistration>>;
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Form/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,E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I,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAC/B,KAAK,EAAE,oBAAoB,GAC1B,CAAC,CAAC,UAAU,CAuHd;AAED;;GAEG;AACH,wBAAgB,0BAA0B;qCAGY,iBAAiB;sCAIhB,MAAM;;;;;EAoB5D"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { createContext, useRef, useCallback } from "react";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const defaultFormConfig = {
|
|
4
|
+
showInlineErrors: true,
|
|
5
|
+
validateOnBlur: true,
|
|
6
|
+
validateOnChange: false,
|
|
7
|
+
size: "md",
|
|
8
|
+
layout: "vertical",
|
|
9
|
+
disabled: false,
|
|
10
|
+
colon: true
|
|
11
|
+
};
|
|
12
|
+
const FormConfigContext = createContext(null);
|
|
13
|
+
function buildZodSchemaFromRules(type, rules) {
|
|
14
|
+
const getValueAndMessage = (rule, defaultMessage) => {
|
|
15
|
+
if (rule === void 0) return null;
|
|
16
|
+
if (typeof rule === "object" && rule !== null && "value" in rule) {
|
|
17
|
+
return rule;
|
|
18
|
+
}
|
|
19
|
+
return { value: rule, message: defaultMessage };
|
|
20
|
+
};
|
|
21
|
+
if (type === "string") {
|
|
22
|
+
let schema = z.string();
|
|
23
|
+
const minLengthRule = getValueAndMessage(
|
|
24
|
+
rules.minLength,
|
|
25
|
+
`Minimum ${typeof rules.minLength === "number" ? rules.minLength : rules.minLength?.value} characters required`
|
|
26
|
+
);
|
|
27
|
+
if (minLengthRule) {
|
|
28
|
+
schema = schema.min(minLengthRule.value, minLengthRule.message);
|
|
29
|
+
}
|
|
30
|
+
const maxLengthRule = getValueAndMessage(
|
|
31
|
+
rules.maxLength,
|
|
32
|
+
`Maximum ${typeof rules.maxLength === "number" ? rules.maxLength : rules.maxLength?.value} characters allowed`
|
|
33
|
+
);
|
|
34
|
+
if (maxLengthRule) {
|
|
35
|
+
schema = schema.max(maxLengthRule.value, maxLengthRule.message);
|
|
36
|
+
}
|
|
37
|
+
if (rules.pattern !== void 0) {
|
|
38
|
+
const patternRule = rules.pattern instanceof RegExp ? { value: rules.pattern, message: "Invalid format" } : rules.pattern;
|
|
39
|
+
schema = schema.regex(patternRule.value, patternRule.message);
|
|
40
|
+
}
|
|
41
|
+
if (rules.email) {
|
|
42
|
+
const message = typeof rules.email === "string" ? rules.email : "Invalid email address";
|
|
43
|
+
schema = schema.email(message);
|
|
44
|
+
}
|
|
45
|
+
if (rules.url) {
|
|
46
|
+
const message = typeof rules.url === "string" ? rules.url : "Invalid URL";
|
|
47
|
+
schema = schema.url(message);
|
|
48
|
+
}
|
|
49
|
+
if (rules.required) {
|
|
50
|
+
const message = typeof rules.required === "string" ? rules.required : "This field is required";
|
|
51
|
+
schema = schema.min(1, message);
|
|
52
|
+
return schema;
|
|
53
|
+
}
|
|
54
|
+
return schema.optional();
|
|
55
|
+
}
|
|
56
|
+
if (type === "number") {
|
|
57
|
+
let schema = z.coerce.number();
|
|
58
|
+
const minRule = getValueAndMessage(
|
|
59
|
+
rules.min,
|
|
60
|
+
`Minimum value is ${typeof rules.min === "number" ? rules.min : rules.min?.value}`
|
|
61
|
+
);
|
|
62
|
+
if (minRule) {
|
|
63
|
+
schema = schema.min(minRule.value, minRule.message);
|
|
64
|
+
}
|
|
65
|
+
const maxRule = getValueAndMessage(
|
|
66
|
+
rules.max,
|
|
67
|
+
`Maximum value is ${typeof rules.max === "number" ? rules.max : rules.max?.value}`
|
|
68
|
+
);
|
|
69
|
+
if (maxRule) {
|
|
70
|
+
schema = schema.max(maxRule.value, maxRule.message);
|
|
71
|
+
}
|
|
72
|
+
if (!rules.required) {
|
|
73
|
+
return schema.optional();
|
|
74
|
+
}
|
|
75
|
+
return schema;
|
|
76
|
+
}
|
|
77
|
+
if (type === "boolean") {
|
|
78
|
+
const schema = z.boolean();
|
|
79
|
+
if (rules.required) {
|
|
80
|
+
return schema.refine((val) => val === true, {
|
|
81
|
+
message: typeof rules.required === "string" ? rules.required : "This field is required"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return schema.optional();
|
|
85
|
+
}
|
|
86
|
+
if (type === "date") {
|
|
87
|
+
const schema = z.coerce.date();
|
|
88
|
+
if (!rules.required) {
|
|
89
|
+
return schema.optional();
|
|
90
|
+
}
|
|
91
|
+
return schema;
|
|
92
|
+
}
|
|
93
|
+
if (type === "array") {
|
|
94
|
+
let schema = z.array(z.unknown());
|
|
95
|
+
if (rules.required) {
|
|
96
|
+
const message = typeof rules.required === "string" ? rules.required : "This field is required";
|
|
97
|
+
schema = schema.min(1, message);
|
|
98
|
+
}
|
|
99
|
+
return schema;
|
|
100
|
+
}
|
|
101
|
+
return z.unknown();
|
|
102
|
+
}
|
|
103
|
+
function useFieldValidationRegistry() {
|
|
104
|
+
const fieldsRef = useRef(/* @__PURE__ */ new Map());
|
|
105
|
+
const registerFieldValidation = useCallback((field) => {
|
|
106
|
+
fieldsRef.current.set(field.name, field);
|
|
107
|
+
}, []);
|
|
108
|
+
const unregisterFieldValidation = useCallback((name) => {
|
|
109
|
+
fieldsRef.current.delete(name);
|
|
110
|
+
}, []);
|
|
111
|
+
const getValidationSchema = useCallback(() => {
|
|
112
|
+
const shape = {};
|
|
113
|
+
fieldsRef.current.forEach((field) => {
|
|
114
|
+
shape[field.name] = buildZodSchemaFromRules(field.type, field.rules);
|
|
115
|
+
});
|
|
116
|
+
return z.object(shape);
|
|
117
|
+
}, []);
|
|
118
|
+
return {
|
|
119
|
+
registerFieldValidation,
|
|
120
|
+
unregisterFieldValidation,
|
|
121
|
+
getValidationSchema,
|
|
122
|
+
fieldsRef
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
FormConfigContext,
|
|
127
|
+
buildZodSchemaFromRules,
|
|
128
|
+
defaultFormConfig,
|
|
129
|
+
useFieldValidationRegistry
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../src/components/Form/context.ts"],"sourcesContent":["import { createContext, useCallback, useRef } from \"react\";\r\nimport type { UseFormReturn, FieldValues } from \"react-hook-form\";\r\nimport { z } from \"zod\";\r\n\r\n/**\r\n * Validation rule types that can be applied to form fields\r\n */\r\nexport interface FieldValidationRules {\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length for strings */\r\n minLength?: number | { value: number; message: string };\r\n /** Maximum length for strings */\r\n maxLength?: number | { value: number; message: string };\r\n /** Minimum value for numbers */\r\n min?: number | { value: number; message: string };\r\n /** Maximum value for numbers */\r\n max?: number | { value: number; message: string };\r\n /** Regex pattern for validation */\r\n pattern?: RegExp | { value: RegExp; message: string };\r\n /** Email validation */\r\n email?: boolean | string;\r\n /** URL validation */\r\n url?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Form configuration options\r\n */\r\nexport interface FormConfig {\r\n /** Show validation errors inline */\r\n showInlineErrors?: boolean;\r\n /** Validate on blur */\r\n validateOnBlur?: boolean;\r\n /** Validate on change */\r\n validateOnChange?: boolean;\r\n /** Size of form controls */\r\n size?: \"sm\" | \"md\" | \"lg\";\r\n /** Layout direction */\r\n layout?: \"horizontal\" | \"vertical\" | \"inline\";\r\n /** Label width for horizontal layout */\r\n labelWidth?: string | number;\r\n /** Whether form is disabled */\r\n disabled?: boolean;\r\n /** Colon after label */\r\n colon?: boolean;\r\n}\r\n\r\n/**\r\n * Field registration info\r\n */\r\nexport interface FieldRegistration {\r\n name: string;\r\n type: \"string\" | \"number\" | \"boolean\" | \"date\" | \"array\";\r\n rules: FieldValidationRules;\r\n}\r\n\r\n/**\r\n * Form context value\r\n */\r\nexport interface FormContextValue<TFieldValues extends FieldValues = FieldValues>\r\n extends FormConfig {\r\n form: UseFormReturn<TFieldValues>;\r\n /** Register a field's validation rules */\r\n registerFieldValidation: (field: FieldRegistration) => void;\r\n /** Unregister a field's validation rules */\r\n unregisterFieldValidation: (name: string) => void;\r\n /** Get current validation schema */\r\n getValidationSchema: () => z.ZodObject<Record<string, z.ZodTypeAny>>;\r\n /** Trigger validation for a specific field */\r\n triggerValidation: (name: string) => Promise<boolean>;\r\n}\r\n\r\n/**\r\n * Default form configuration\r\n */\r\nexport const defaultFormConfig: FormConfig = {\r\n showInlineErrors: true,\r\n validateOnBlur: true,\r\n validateOnChange: false,\r\n size: \"md\",\r\n layout: \"vertical\",\r\n disabled: false,\r\n colon: true,\r\n};\r\n\r\n/**\r\n * Form context for sharing form state and configuration\r\n */\r\nexport const FormConfigContext = createContext<FormContextValue | null>(null);\r\n\r\n/**\r\n * Build a Zod schema from validation rules\r\n */\r\nexport function buildZodSchemaFromRules(\r\n type: FieldRegistration[\"type\"],\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n // Helper to extract value and message\r\n const getValueAndMessage = <T>(\r\n rule: T | { value: T; message: string } | undefined,\r\n defaultMessage: string\r\n ): { value: T; message: string } | null => {\r\n if (rule === undefined) return null;\r\n if (typeof rule === \"object\" && rule !== null && \"value\" in rule) {\r\n return rule as { value: T; message: string };\r\n }\r\n return { value: rule as T, message: defaultMessage };\r\n };\r\n\r\n // Build string schema\r\n if (type === \"string\") {\r\n let schema = z.string();\r\n\r\n const minLengthRule = getValueAndMessage(\r\n rules.minLength,\r\n `Minimum ${typeof rules.minLength === \"number\" ? rules.minLength : (rules.minLength as { value: number })?.value} characters required`\r\n );\r\n if (minLengthRule) {\r\n schema = schema.min(minLengthRule.value as number, minLengthRule.message);\r\n }\r\n\r\n const maxLengthRule = getValueAndMessage(\r\n rules.maxLength,\r\n `Maximum ${typeof rules.maxLength === \"number\" ? rules.maxLength : (rules.maxLength as { value: number })?.value} characters allowed`\r\n );\r\n if (maxLengthRule) {\r\n schema = schema.max(maxLengthRule.value as number, maxLengthRule.message);\r\n }\r\n\r\n if (rules.pattern !== undefined) {\r\n const patternRule = rules.pattern instanceof RegExp\r\n ? { value: rules.pattern, message: \"Invalid format\" }\r\n : rules.pattern;\r\n schema = schema.regex(patternRule.value, patternRule.message);\r\n }\r\n\r\n if (rules.email) {\r\n const message = typeof rules.email === \"string\" ? rules.email : \"Invalid email address\";\r\n schema = schema.email(message);\r\n }\r\n\r\n if (rules.url) {\r\n const message = typeof rules.url === \"string\" ? rules.url : \"Invalid URL\";\r\n schema = schema.url(message);\r\n }\r\n\r\n // Handle required - for strings, require non-empty\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n schema = schema.min(1, message);\r\n return schema;\r\n }\r\n\r\n return schema.optional();\r\n }\r\n\r\n // Build number schema\r\n if (type === \"number\") {\r\n let schema = z.coerce.number();\r\n\r\n const minRule = getValueAndMessage(\r\n rules.min,\r\n `Minimum value is ${typeof rules.min === \"number\" ? rules.min : (rules.min as { value: number })?.value}`\r\n );\r\n if (minRule) {\r\n schema = schema.min(minRule.value as number, minRule.message);\r\n }\r\n\r\n const maxRule = getValueAndMessage(\r\n rules.max,\r\n `Maximum value is ${typeof rules.max === \"number\" ? rules.max : (rules.max as { value: number })?.value}`\r\n );\r\n if (maxRule) {\r\n schema = schema.max(maxRule.value as number, maxRule.message);\r\n }\r\n\r\n if (!rules.required) {\r\n return schema.optional();\r\n }\r\n return schema;\r\n }\r\n\r\n // Build boolean schema\r\n if (type === \"boolean\") {\r\n const schema = z.boolean();\r\n if (rules.required) {\r\n // For required boolean, must be true (like accepting terms)\r\n return schema.refine((val) => val === true, {\r\n message: typeof rules.required === \"string\" ? rules.required : \"This field is required\",\r\n });\r\n }\r\n return schema.optional();\r\n }\r\n\r\n // Build date schema\r\n if (type === \"date\") {\r\n const schema = z.coerce.date();\r\n if (!rules.required) {\r\n return schema.optional();\r\n }\r\n return schema;\r\n }\r\n\r\n // Build array schema\r\n if (type === \"array\") {\r\n let schema = z.array(z.unknown());\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n schema = schema.min(1, message);\r\n }\r\n return schema;\r\n }\r\n\r\n // Default fallback\r\n return z.unknown();\r\n}\r\n\r\n/**\r\n * Hook to manage field validations\r\n */\r\nexport function useFieldValidationRegistry() {\r\n const fieldsRef = useRef<Map<string, FieldRegistration>>(new Map());\r\n\r\n const registerFieldValidation = useCallback((field: FieldRegistration) => {\r\n fieldsRef.current.set(field.name, field);\r\n }, []);\r\n\r\n const unregisterFieldValidation = useCallback((name: string) => {\r\n fieldsRef.current.delete(name);\r\n }, []);\r\n\r\n const getValidationSchema = useCallback(() => {\r\n const shape: Record<string, z.ZodTypeAny> = {};\r\n \r\n fieldsRef.current.forEach((field) => {\r\n shape[field.name] = buildZodSchemaFromRules(field.type, field.rules);\r\n });\r\n\r\n return z.object(shape);\r\n }, []);\r\n\r\n return {\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n fieldsRef,\r\n };\r\n}\r\n"],"names":[],"mappings":";;AA8EO,MAAM,oBAAgC;AAAA,EAC3C,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AACT;AAKO,MAAM,oBAAoB,cAAuC,IAAI;AAKrE,SAAS,wBACd,MACA,OACc;AAEd,QAAM,qBAAqB,CACzB,MACA,mBACyC;AACzC,QAAI,SAAS,OAAW,QAAO;AAC/B,QAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,MAAM;AAChE,aAAO;AAAA,IACT;AACA,WAAO,EAAE,OAAO,MAAW,SAAS,eAAA;AAAA,EACtC;AAGA,MAAI,SAAS,UAAU;AACrB,QAAI,SAAS,EAAE,OAAA;AAEf,UAAM,gBAAgB;AAAA,MACpB,MAAM;AAAA,MACN,WAAW,OAAO,MAAM,cAAc,WAAW,MAAM,YAAa,MAAM,WAAiC,KAAK;AAAA,IAAA;AAElH,QAAI,eAAe;AACjB,eAAS,OAAO,IAAI,cAAc,OAAiB,cAAc,OAAO;AAAA,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;AAED,WAAO,EAAE,OAAO,KAAK;AAAA,EACvB,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldValues, FieldPath, UseControllerProps, UseControllerReturn } from 'react-hook-form';
|
|
2
|
+
import { FormContextValue, FormConfig } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access form configuration context
|
|
5
|
+
*/
|
|
6
|
+
export declare function useFormConfig<TFieldValues extends FieldValues = FieldValues>(): FormContextValue<TFieldValues>;
|
|
7
|
+
/**
|
|
8
|
+
* Hook to access react-hook-form context directly
|
|
9
|
+
*/
|
|
10
|
+
export declare function useForm<TFieldValues extends FieldValues = FieldValues>(): import('react-hook-form').UseFormReturn<TFieldValues, any, TFieldValues>;
|
|
11
|
+
/**
|
|
12
|
+
* Hook to create a controlled field with form context awareness
|
|
13
|
+
*/
|
|
14
|
+
export declare function useFormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: UseControllerProps<TFieldValues, TName>): UseControllerReturn<TFieldValues, TName> & {
|
|
15
|
+
config: FormConfig;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Hook to get field error
|
|
19
|
+
*/
|
|
20
|
+
export declare function useFieldError<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TName): string | undefined;
|
|
21
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/components/Form/hooks.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqB,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtF;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,KAAK,gBAAgB,CAAC,YAAY,CAAC,CAM9G;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,8EAErE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAE/D,KAAK,EAAE,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,GAC7C,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAWnE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAIjC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { useFormContext, useController } from "react-hook-form";
|
|
3
|
+
import { FormConfigContext } from "./context.js";
|
|
4
|
+
function useFormConfig() {
|
|
5
|
+
const context = useContext(FormConfigContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("useFormConfig must be used within a Form component");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
function useForm() {
|
|
12
|
+
return useFormContext();
|
|
13
|
+
}
|
|
14
|
+
function useFormField(props) {
|
|
15
|
+
const { form, ...config } = useFormConfig();
|
|
16
|
+
const controller = useController({
|
|
17
|
+
...props,
|
|
18
|
+
control: form.control
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
...controller,
|
|
22
|
+
config
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function useFieldError(name) {
|
|
26
|
+
const { form } = useFormConfig();
|
|
27
|
+
const error = form.formState.errors[name];
|
|
28
|
+
return error?.message;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
useFieldError,
|
|
32
|
+
useForm,
|
|
33
|
+
useFormConfig,
|
|
34
|
+
useFormField
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../src/components/Form/hooks.ts"],"sourcesContent":["import { useContext } from \"react\";\r\nimport {\r\n useFormContext as useRHFFormContext,\r\n useController,\r\n type FieldValues,\r\n type FieldPath,\r\n type UseControllerProps,\r\n type UseControllerReturn,\r\n} from \"react-hook-form\";\r\nimport { FormConfigContext, type FormContextValue, type FormConfig } from \"./context\";\r\n\r\n/**\r\n * Hook to access form configuration context\r\n */\r\nexport function useFormConfig<TFieldValues extends FieldValues = FieldValues>(): FormContextValue<TFieldValues> {\r\n const context = useContext(FormConfigContext) as FormContextValue<TFieldValues> | null;\r\n if (!context) {\r\n throw new Error(\"useFormConfig must be used within a Form component\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Hook to access react-hook-form context directly\r\n */\r\nexport function useForm<TFieldValues extends FieldValues = FieldValues>() {\r\n return useRHFFormContext<TFieldValues>();\r\n}\r\n\r\n/**\r\n * Hook to create a controlled field with form context awareness\r\n */\r\nexport function useFormField<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: UseControllerProps<TFieldValues, TName>\r\n): UseControllerReturn<TFieldValues, TName> & { config: FormConfig } {\r\n const { form, ...config } = useFormConfig<TFieldValues>();\r\n const controller = useController<TFieldValues, TName>({\r\n ...props,\r\n control: form.control,\r\n });\r\n\r\n return {\r\n ...controller,\r\n config,\r\n };\r\n}\r\n\r\n/**\r\n * Hook to get field error\r\n */\r\nexport function useFieldError<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(name: TName): string | undefined {\r\n const { form } = useFormConfig<TFieldValues>();\r\n const error = form.formState.errors[name];\r\n return error?.message as string | undefined;\r\n}\r\n"],"names":["useRHFFormContext"],"mappings":";;;AAcO,SAAS,gBAAgG;AAC9G,QAAM,UAAU,WAAW,iBAAiB;AAC5C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;AAKO,SAAS,UAA0D;AACxE,SAAOA,eAAA;AACT;AAKO,SAAS,aAId,OACmE;AACnE,QAAM,EAAE,MAAM,GAAG,OAAA,IAAW,cAAA;AAC5B,QAAM,aAAa,cAAmC;AAAA,IACpD,GAAG;AAAA,IACH,SAAS,KAAK;AAAA,EAAA,CACf;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EAAA;AAEJ;AAKO,SAAS,cAGd,MAAiC;AACjC,QAAM,EAAE,KAAA,IAAS,cAAA;AACjB,QAAM,QAAQ,KAAK,UAAU,OAAO,IAAI;AACxC,SAAO,OAAO;AAChB;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { Form } from './Form';
|
|
2
|
+
export type { FormProps } from './Form';
|
|
3
|
+
export { TextBox } from './TextBox';
|
|
4
|
+
export type { TextBoxProps } from './TextBox';
|
|
5
|
+
export { TextArea } from './TextArea';
|
|
6
|
+
export type { TextAreaProps } from './TextArea';
|
|
7
|
+
export { Select } from './Select';
|
|
8
|
+
export type { SelectProps, SelectOption } from './Select';
|
|
9
|
+
export { Checkbox } from './Checkbox';
|
|
10
|
+
export type { CheckboxProps } from './Checkbox';
|
|
11
|
+
export { RadioGroup, RadioItem } from './Radio';
|
|
12
|
+
export type { RadioGroupProps, RadioItemProps, RadioOption } from './Radio';
|
|
13
|
+
export { Switch } from './Switch';
|
|
14
|
+
export type { SwitchProps } from './Switch';
|
|
15
|
+
export { FormConfigContext, defaultFormConfig, buildZodSchemaFromRules, useFieldValidationRegistry, } from './context';
|
|
16
|
+
export type { FormConfig, FormContextValue, FieldValidationRules, FieldRegistration, } from './context';
|
|
17
|
+
export { useFormConfig, useForm, useFormField, useFieldError } from './hooks';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
/** Label text for the input */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Helper text displayed below the input */
|
|
6
|
+
helperText?: string;
|
|
7
|
+
/** Error message to display */
|
|
8
|
+
error?: string;
|
|
9
|
+
/** The size of the input */
|
|
10
|
+
inputSize?: "sm" | "md" | "lg";
|
|
11
|
+
/** Whether the input should take full width */
|
|
12
|
+
fullWidth?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A customizable input component with label, helper text, and error states
|
|
16
|
+
*/
|
|
17
|
+
export declare const Input: import('react').ForwardRefExoticComponent<InputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
18
|
+
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IACvE,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/B,+CAA+C;IAC/C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,yGAiDjB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
const Input = forwardRef(
|
|
6
|
+
({
|
|
7
|
+
label,
|
|
8
|
+
helperText,
|
|
9
|
+
error,
|
|
10
|
+
inputSize = "md",
|
|
11
|
+
fullWidth = false,
|
|
12
|
+
className,
|
|
13
|
+
id,
|
|
14
|
+
...props
|
|
15
|
+
}, ref) => {
|
|
16
|
+
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("skybin-input-wrapper", fullWidth && "skybin-input-wrapper--full-width"), children: [
|
|
18
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "skybin-input__label", children: label }),
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
"input",
|
|
21
|
+
{
|
|
22
|
+
ref,
|
|
23
|
+
id: inputId,
|
|
24
|
+
className: cn(
|
|
25
|
+
"skybin-input",
|
|
26
|
+
`skybin-input--${inputSize}`,
|
|
27
|
+
error && "skybin-input--error",
|
|
28
|
+
className
|
|
29
|
+
),
|
|
30
|
+
"aria-invalid": !!error,
|
|
31
|
+
"aria-describedby": error ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
|
|
32
|
+
...props
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
error && /* @__PURE__ */ jsx("span", { id: `${inputId}-error`, className: "skybin-input__error", role: "alert", children: error }),
|
|
36
|
+
helperText && !error && /* @__PURE__ */ jsx("span", { id: `${inputId}-helper`, className: "skybin-input__helper", children: helperText })
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
Input.displayName = "Input";
|
|
41
|
+
export {
|
|
42
|
+
Input
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\r\nimport type { InputHTMLAttributes } from \"react\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport \"./Input.css\";\r\n\r\nexport interface InputProps extends InputHTMLAttributes<HTMLInputElement> {\r\n /** Label text for the input */\r\n label?: string;\r\n /** Helper text displayed below the input */\r\n helperText?: string;\r\n /** Error message to display */\r\n error?: string;\r\n /** The size of the input */\r\n inputSize?: \"sm\" | \"md\" | \"lg\";\r\n /** Whether the input should take full width */\r\n fullWidth?: boolean;\r\n}\r\n\r\n/**\r\n * A customizable input component with label, helper text, and error states\r\n */\r\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\r\n (\r\n {\r\n label,\r\n helperText,\r\n error,\r\n inputSize = \"md\",\r\n fullWidth = false,\r\n className,\r\n id,\r\n ...props\r\n },\r\n ref\r\n ) => {\r\n const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;\r\n\r\n return (\r\n <div className={cn(\"skybin-input-wrapper\", fullWidth && \"skybin-input-wrapper--full-width\")}>\r\n {label && (\r\n <label htmlFor={inputId} className=\"skybin-input__label\">\r\n {label}\r\n </label>\r\n )}\r\n <input\r\n ref={ref}\r\n id={inputId}\r\n className={cn(\r\n \"skybin-input\",\r\n `skybin-input--${inputSize}`,\r\n error && \"skybin-input--error\",\r\n className\r\n )}\r\n aria-invalid={!!error}\r\n aria-describedby={error ? `${inputId}-error` : helperText ? `${inputId}-helper` : undefined}\r\n {...props}\r\n />\r\n {error && (\r\n <span id={`${inputId}-error`} className=\"skybin-input__error\" role=\"alert\">\r\n {error}\r\n </span>\r\n )}\r\n {helperText && !error && (\r\n <span id={`${inputId}-helper`} className=\"skybin-input__helper\">\r\n {helperText}\r\n </span>\r\n )}\r\n </div>\r\n );\r\n }\r\n);\r\n\r\nInput.displayName = \"Input\";\r\n"],"names":[],"mappings":";;;;AAqBO,MAAM,QAAQ;AAAA,EACnB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,UAAU,MAAM,SAAS,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,OAAO,GAAG,CAAC,CAAC;AAEtE,gCACG,OAAA,EAAI,WAAW,GAAG,wBAAwB,aAAa,kCAAkC,GACvF,UAAA;AAAA,MAAA,6BACE,SAAA,EAAM,SAAS,SAAS,WAAU,uBAChC,UAAA,OACH;AAAA,MAEF;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,IAAI;AAAA,UACJ,WAAW;AAAA,YACT;AAAA,YACA,iBAAiB,SAAS;AAAA,YAC1B,SAAS;AAAA,YACT;AAAA,UAAA;AAAA,UAEF,gBAAc,CAAC,CAAC;AAAA,UAChB,oBAAkB,QAAQ,GAAG,OAAO,WAAW,aAAa,GAAG,OAAO,YAAY;AAAA,UACjF,GAAG;AAAA,QAAA;AAAA,MAAA;AAAA,MAEL,SACC,oBAAC,QAAA,EAAK,IAAI,GAAG,OAAO,UAAU,WAAU,uBAAsB,MAAK,SAChE,UAAA,MAAA,CACH;AAAA,MAED,cAAc,CAAC,SACd,oBAAC,QAAA,EAAK,IAAI,GAAG,OAAO,WAAW,WAAU,wBACtC,UAAA,WAAA,CACH;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Checkbox };
|
|
5
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/checkbox.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAA;AAK7D,QAAA,MAAM,QAAQ,iKAkBZ,CAAA;AAGF,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Checkbox as Checkbox$1, CheckboxIndicator } from "../../node_modules/@radix-ui/react-checkbox/dist/index.js";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import Check from "../../node_modules/lucide-react/dist/esm/icons/check.js";
|
|
6
|
+
const Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7
|
+
Checkbox$1,
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: cn(
|
|
11
|
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
12
|
+
className
|
|
13
|
+
),
|
|
14
|
+
...props,
|
|
15
|
+
children: /* @__PURE__ */ jsx(
|
|
16
|
+
CheckboxIndicator,
|
|
17
|
+
{
|
|
18
|
+
className: cn("flex items-center justify-center text-current"),
|
|
19
|
+
children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
));
|
|
24
|
+
Checkbox.displayName = Checkbox$1.displayName;
|
|
25
|
+
export {
|
|
26
|
+
Checkbox
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../../src/components/ui/checkbox.tsx"],"sourcesContent":["/**\r\n * shadcn/ui Checkbox component\r\n * @see https://ui.shadcn.com/docs/components/checkbox\r\n * \r\n * DO NOT MODIFY THIS FILE - It is generated from shadcn/ui\r\n * For customizations, create wrapper components instead.\r\n */\r\n\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport * as CheckboxPrimitive from \"@radix-ui/react-checkbox\"\r\nimport { Check } from \"lucide-react\"\r\n\r\nimport { cn } from \"../../utils/cn\"\r\n\r\nconst Checkbox = React.forwardRef<\r\n React.ElementRef<typeof CheckboxPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>\r\n>(({ className, ...props }, ref) => (\r\n <CheckboxPrimitive.Root\r\n ref={ref}\r\n className={cn(\r\n \"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n <CheckboxPrimitive.Indicator\r\n className={cn(\"flex items-center justify-center text-current\")}\r\n >\r\n <Check className=\"h-4 w-4\" />\r\n </CheckboxPrimitive.Indicator>\r\n </CheckboxPrimitive.Root>\r\n))\r\nCheckbox.displayName = CheckboxPrimitive.Root.displayName\r\n\r\nexport { Checkbox }\r\n"],"names":["CheckboxPrimitive.Root","CheckboxPrimitive.Indicator"],"mappings":";;;;;AAeA,MAAM,WAAW,MAAM,WAGrB,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1B;AAAA,EAACA;AAAAA,EAAA;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEJ,UAAA;AAAA,MAACC;AAAAA,MAAA;AAAA,QACC,WAAW,GAAG,+CAA+C;AAAA,QAE7D,UAAA,oBAAC,OAAA,EAAM,WAAU,UAAA,CAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EAC7B;AACF,CACD;AACD,SAAS,cAAcD,WAAuB;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shadcn/ui primitive components
|
|
3
|
+
*
|
|
4
|
+
* DO NOT MODIFY THESE FILES - They are generated from shadcn/ui
|
|
5
|
+
* For customizations, create wrapper components instead.
|
|
6
|
+
*
|
|
7
|
+
* @see https://ui.shadcn.com/docs
|
|
8
|
+
*/
|
|
9
|
+
export { Input } from './input';
|
|
10
|
+
export { Label } from './label';
|
|
11
|
+
export { Checkbox } from './checkbox';
|
|
12
|
+
export { RadioGroup, RadioGroupItem } from './radio-group';
|
|
13
|
+
export { Switch } from './switch';
|
|
14
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, } from './select';
|
|
15
|
+
export { Textarea } from './textarea';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shadcn/ui Input component
|
|
3
|
+
* @see https://ui.shadcn.com/docs/components/input
|
|
4
|
+
*
|
|
5
|
+
* DO NOT MODIFY THIS FILE - It is generated from shadcn/ui
|
|
6
|
+
* For customizations, create wrapper components instead.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare const Input: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
export { Input };
|
|
11
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/components/ui/input.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,QAAA,MAAM,KAAK,8KAcV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
const Input = React.forwardRef(
|
|
5
|
+
({ className, type, ...props }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"input",
|
|
8
|
+
{
|
|
9
|
+
type,
|
|
10
|
+
className: cn(
|
|
11
|
+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
className
|
|
13
|
+
),
|
|
14
|
+
ref,
|
|
15
|
+
...props
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
Input.displayName = "Input";
|
|
21
|
+
export {
|
|
22
|
+
Input
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../src/components/ui/input.tsx"],"sourcesContent":["/**\r\n * shadcn/ui Input component\r\n * @see https://ui.shadcn.com/docs/components/input\r\n * \r\n * DO NOT MODIFY THIS FILE - It is generated from shadcn/ui\r\n * For customizations, create wrapper components instead.\r\n */\r\nimport * as React from \"react\"\r\n\r\nimport { cn } from \"../../utils/cn\"\r\n\r\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<\"input\">>(\r\n ({ className, type, ...props }, ref) => {\r\n return (\r\n <input\r\n type={type}\r\n className={cn(\r\n \"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\r\n className\r\n )}\r\n ref={ref}\r\n {...props}\r\n />\r\n )\r\n }\r\n)\r\nInput.displayName = \"Input\"\r\n\r\nexport { Input }\r\n"],"names":[],"mappings":";;;AAWA,MAAM,QAAQ,MAAM;AAAA,EAClB,CAAC,EAAE,WAAW,MAAM,GAAG,MAAA,GAAS,QAAQ;AACtC,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAEF;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AACA,MAAM,cAAc;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
4
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import('class-variance-authority/types').ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
|
|
5
|
+
export { Label };
|
|
6
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/components/ui/label.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAQjE,QAAA,MAAM,KAAK,4PAUT,CAAA;AAGF,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Root } from "../../node_modules/@radix-ui/react-label/dist/index.js";
|
|
4
|
+
import { cva } from "../../node_modules/class-variance-authority/dist/index.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
const labelVariants = cva(
|
|
7
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
8
|
+
);
|
|
9
|
+
const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
10
|
+
Root,
|
|
11
|
+
{
|
|
12
|
+
ref,
|
|
13
|
+
className: cn(labelVariants(), className),
|
|
14
|
+
...props
|
|
15
|
+
}
|
|
16
|
+
));
|
|
17
|
+
Label.displayName = Root.displayName;
|
|
18
|
+
export {
|
|
19
|
+
Label
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../../src/components/ui/label.tsx"],"sourcesContent":["/**\r\n * shadcn/ui Label component\r\n * @see https://ui.shadcn.com/docs/components/label\r\n * \r\n * DO NOT MODIFY THIS FILE - It is generated from shadcn/ui\r\n * For customizations, create wrapper components instead.\r\n */\r\n\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"../../utils/cn\"\r\n\r\nconst labelVariants = cva(\r\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\r\n)\r\n\r\nconst Label = React.forwardRef<\r\n React.ElementRef<typeof LabelPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\r\n VariantProps<typeof labelVariants>\r\n>(({ className, ...props }, ref) => (\r\n <LabelPrimitive.Root\r\n ref={ref}\r\n className={cn(labelVariants(), className)}\r\n {...props}\r\n />\r\n))\r\nLabel.displayName = LabelPrimitive.Root.displayName\r\n\r\nexport { Label }\r\n"],"names":["LabelPrimitive.Root"],"mappings":";;;;;AAeA,MAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,MAAM,QAAQ,MAAM,WAIlB,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1B;AAAA,EAACA;AAAAA,EAAA;AAAA,IACC;AAAA,IACA,WAAW,GAAG,cAAA,GAAiB,SAAS;AAAA,IACvC,GAAG;AAAA,EAAA;AACN,CACD;AACD,MAAM,cAAcA,KAAoB;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
3
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export { RadioGroup, RadioGroupItem };
|
|
6
|
+
//# sourceMappingURL=radio-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../src/components/ui/radio-group.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAKlE,QAAA,MAAM,UAAU,+JAWd,CAAA;AAGF,QAAA,MAAM,cAAc,yKAkBlB,CAAA;AAGF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAA"}
|