jaci-ui 0.2.0 → 0.4.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/CHANGELOG.md +12 -0
- package/README.md +95 -0
- package/dist/components/button-group/button-group.cjs +22 -0
- package/dist/components/button-group/button-group.cjs.map +1 -0
- package/dist/components/button-group/button-group.d.cts +12 -0
- package/dist/components/button-group/button-group.d.ts +12 -0
- package/dist/components/button-group/button-group.js +21 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/button-group/index.d.cts +2 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/calendar/calendar.cjs +377 -0
- package/dist/components/calendar/calendar.cjs.map +1 -0
- package/dist/components/calendar/calendar.d.cts +56 -0
- package/dist/components/calendar/calendar.d.ts +56 -0
- package/dist/components/calendar/calendar.js +368 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.cts +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/combobox/combobox.cjs +13 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.d.cts +7 -2
- package/dist/components/combobox/combobox.d.ts +7 -2
- package/dist/components/combobox/combobox.js +13 -2
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/combobox/index.d.cts +2 -2
- package/dist/components/combobox/index.d.ts +2 -2
- package/dist/components/controls/input.cjs +26 -5
- package/dist/components/controls/input.cjs.map +1 -1
- package/dist/components/controls/input.d.cts +5 -2
- package/dist/components/controls/input.d.ts +5 -2
- package/dist/components/controls/input.js +28 -7
- package/dist/components/controls/input.js.map +1 -1
- package/dist/components/controls/textarea.cjs +26 -5
- package/dist/components/controls/textarea.cjs.map +1 -1
- package/dist/components/controls/textarea.d.cts +5 -2
- package/dist/components/controls/textarea.d.ts +5 -2
- package/dist/components/controls/textarea.js +28 -7
- package/dist/components/controls/textarea.js.map +1 -1
- package/dist/components/date-picker/date-picker.cjs +9 -9
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.d.cts +3 -1
- package/dist/components/date-picker/date-picker.d.ts +3 -1
- package/dist/components/date-picker/date-picker.js +9 -9
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +589 -0
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -0
- package/dist/components/date-range-picker/date-range-picker.d.cts +134 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +134 -0
- package/dist/components/date-range-picker/date-range-picker.js +568 -0
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -0
- package/dist/components/date-range-picker/index.d.cts +2 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/empty-state/empty-state.cjs +62 -0
- package/dist/components/empty-state/empty-state.cjs.map +1 -0
- package/dist/components/empty-state/empty-state.d.cts +18 -0
- package/dist/components/empty-state/empty-state.d.ts +18 -0
- package/dist/components/empty-state/empty-state.js +57 -0
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/index.d.cts +2 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/field/field.cjs +106 -11
- package/dist/components/field/field.cjs.map +1 -1
- package/dist/components/field/field.d.cts +22 -4
- package/dist/components/field/field.d.ts +22 -4
- package/dist/components/field/field.js +107 -13
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/index.d.cts +2 -2
- package/dist/components/field/index.d.ts +2 -2
- package/dist/components/icon-button/icon-button.cjs +40 -0
- package/dist/components/icon-button/icon-button.cjs.map +1 -0
- package/dist/components/icon-button/icon-button.d.cts +12 -0
- package/dist/components/icon-button/icon-button.d.ts +12 -0
- package/dist/components/icon-button/icon-button.js +40 -0
- package/dist/components/icon-button/icon-button.js.map +1 -0
- package/dist/components/icon-button/index.d.cts +2 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/input-group/index.d.cts +2 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/input-group.cjs +32 -0
- package/dist/components/input-group/input-group.cjs.map +1 -0
- package/dist/components/input-group/input-group.d.cts +15 -0
- package/dist/components/input-group/input-group.d.ts +15 -0
- package/dist/components/input-group/input-group.js +30 -0
- package/dist/components/input-group/input-group.js.map +1 -0
- package/dist/components/pin-input/index.d.cts +2 -0
- package/dist/components/pin-input/index.d.ts +2 -0
- package/dist/components/pin-input/pin-input.cjs +266 -0
- package/dist/components/pin-input/pin-input.cjs.map +1 -0
- package/dist/components/pin-input/pin-input.d.cts +46 -0
- package/dist/components/pin-input/pin-input.d.ts +46 -0
- package/dist/components/pin-input/pin-input.js +258 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/select/index.d.cts +2 -2
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/select.cjs +80 -3
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.d.cts +18 -3
- package/dist/components/select/select.d.ts +18 -3
- package/dist/components/select/select.js +78 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/tags-input/tags-input.cjs +83 -5
- package/dist/components/tags-input/tags-input.cjs.map +1 -1
- package/dist/components/tags-input/tags-input.d.cts +3 -0
- package/dist/components/tags-input/tags-input.d.ts +3 -0
- package/dist/components/tags-input/tags-input.js +83 -5
- package/dist/components/tags-input/tags-input.js.map +1 -1
- package/dist/components/upload/index.d.cts +2 -2
- package/dist/components/upload/index.d.ts +2 -2
- package/dist/components/upload/upload.cjs +90 -10
- package/dist/components/upload/upload.cjs.map +1 -1
- package/dist/components/upload/upload.d.cts +25 -2
- package/dist/components/upload/upload.d.ts +25 -2
- package/dist/components/upload/upload.js +89 -11
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/index.cjs +70 -0
- package/dist/index.d.cts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +13 -5
- package/dist/styled-system/recipes/button-group.cjs +30 -0
- package/dist/styled-system/recipes/button-group.cjs.map +1 -0
- package/dist/styled-system/recipes/button-group.js +30 -0
- package/dist/styled-system/recipes/button-group.js.map +1 -0
- package/dist/styled-system/recipes/calendar.cjs +43 -0
- package/dist/styled-system/recipes/calendar.cjs.map +1 -0
- package/dist/styled-system/recipes/calendar.js +43 -0
- package/dist/styled-system/recipes/calendar.js.map +1 -0
- package/dist/styled-system/recipes/combobox.cjs +1 -0
- package/dist/styled-system/recipes/combobox.cjs.map +1 -1
- package/dist/styled-system/recipes/combobox.js +1 -0
- package/dist/styled-system/recipes/combobox.js.map +1 -1
- package/dist/styled-system/recipes/date-range-picker.cjs +52 -0
- package/dist/styled-system/recipes/date-range-picker.cjs.map +1 -0
- package/dist/styled-system/recipes/date-range-picker.js +52 -0
- package/dist/styled-system/recipes/date-range-picker.js.map +1 -0
- package/dist/styled-system/recipes/empty-state.cjs +36 -0
- package/dist/styled-system/recipes/empty-state.cjs.map +1 -0
- package/dist/styled-system/recipes/empty-state.js +36 -0
- package/dist/styled-system/recipes/empty-state.js.map +1 -0
- package/dist/styled-system/recipes/icon-button.cjs +40 -0
- package/dist/styled-system/recipes/icon-button.cjs.map +1 -0
- package/dist/styled-system/recipes/icon-button.js +40 -0
- package/dist/styled-system/recipes/icon-button.js.map +1 -0
- package/dist/styled-system/recipes/input-group.cjs +30 -0
- package/dist/styled-system/recipes/input-group.cjs.map +1 -0
- package/dist/styled-system/recipes/input-group.js +30 -0
- package/dist/styled-system/recipes/input-group.js.map +1 -0
- package/dist/styled-system/recipes/pin-input.cjs +39 -0
- package/dist/styled-system/recipes/pin-input.cjs.map +1 -0
- package/dist/styled-system/recipes/pin-input.js +39 -0
- package/dist/styled-system/recipes/pin-input.js.map +1 -0
- package/dist/styled-system/recipes/select.cjs +5 -1
- package/dist/styled-system/recipes/select.cjs.map +1 -1
- package/dist/styled-system/recipes/select.js +5 -1
- package/dist/styled-system/recipes/select.js.map +1 -1
- package/dist/styled-system/recipes/upload.cjs +2 -0
- package/dist/styled-system/recipes/upload.cjs.map +1 -1
- package/dist/styled-system/recipes/upload.js +2 -0
- package/dist/styled-system/recipes/upload.js.map +1 -1
- package/dist/styles/theme.cjs +15 -0
- package/dist/styles/theme.cjs.map +1 -1
- package/dist/styles/theme.js +15 -0
- package/dist/styles/theme.js.map +1 -1
- package/dist/styles.css +901 -46
- package/dist/theme/index.d.cts +2 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/theme-provider.cjs +86 -0
- package/dist/theme/theme-provider.cjs.map +1 -0
- package/dist/theme/theme-provider.d.cts +66 -0
- package/dist/theme/theme-provider.d.ts +66 -0
- package/dist/theme/theme-provider.js +85 -0
- package/dist/theme/theme-provider.js.map +1 -0
- package/package.json +3 -2
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
import { cx } from "../../styled-system/css/cx.js";
|
|
3
3
|
import { field } from "../../styled-system/recipes/field.js";
|
|
4
4
|
import { JaciFormContext } from "../form/form.js";
|
|
5
|
-
import { createContext, forwardRef, useContext } from "react";
|
|
5
|
+
import { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { Field } from "@base-ui/react/field";
|
|
8
8
|
//#region src/components/field/field.tsx
|
|
9
9
|
const FieldContext = createContext({
|
|
10
|
+
controlId: void 0,
|
|
11
|
+
descriptionId: void 0,
|
|
12
|
+
dirty: false,
|
|
13
|
+
errorId: void 0,
|
|
10
14
|
errors: [],
|
|
11
15
|
insideField: false,
|
|
12
16
|
invalid: false,
|
|
13
|
-
|
|
17
|
+
labelId: void 0,
|
|
18
|
+
name: void 0,
|
|
19
|
+
pending: false,
|
|
20
|
+
touched: false,
|
|
21
|
+
valid: null
|
|
14
22
|
});
|
|
15
23
|
function normalizeErrors(errors) {
|
|
16
24
|
if (errors === void 0 || errors === null || errors === false) return [];
|
|
@@ -20,51 +28,127 @@ function renderErrors(errors) {
|
|
|
20
28
|
if (errors.length <= 1) return errors[0];
|
|
21
29
|
return /* @__PURE__ */ jsx("ul", { children: errors.map((error, index) => /* @__PURE__ */ jsx("li", { children: error }, typeof error === "string" ? error : index)) });
|
|
22
30
|
}
|
|
23
|
-
const
|
|
31
|
+
const FieldRoot$1 = forwardRef(function Field$2({ actionsRef, children, className, dirty, disabled = false, errors: directErrors, invalid: invalidProp = false, name, pending: pendingProp = false, touched, validate, validationDebounceTime, validationMode, ...props }, ref) {
|
|
32
|
+
const generatedId = useId();
|
|
33
|
+
const controlId = `${generatedId}-control`;
|
|
34
|
+
const labelId = `${generatedId}-label`;
|
|
35
|
+
const descriptionId = `${generatedId}-description`;
|
|
36
|
+
const errorId = `${generatedId}-error`;
|
|
37
|
+
const [pendingValidation, setPendingValidation] = useState(false);
|
|
38
|
+
const [validationErrors, setValidationErrors] = useState([]);
|
|
39
|
+
const [validationValid, setValidationValid] = useState(null);
|
|
40
|
+
const validationSequence = useRef(0);
|
|
24
41
|
const { errors: formErrors } = useContext(JaciFormContext);
|
|
25
42
|
const formError = name ? formErrors[name] : void 0;
|
|
26
|
-
const
|
|
43
|
+
const externalErrors = directErrors === void 0 ? normalizeErrors(formError) : normalizeErrors(directErrors);
|
|
44
|
+
const errors = directErrors !== void 0 || formError !== void 0 ? externalErrors : validationErrors;
|
|
27
45
|
const invalid = invalidProp || errors.length > 0;
|
|
46
|
+
const pending = pendingProp || pendingValidation;
|
|
47
|
+
const wrappedValidate = useCallback((value, formValues) => {
|
|
48
|
+
const sequence = ++validationSequence.current;
|
|
49
|
+
if (!validate) return null;
|
|
50
|
+
const result = validate(value, formValues);
|
|
51
|
+
if (!result || typeof result !== "object" || !("then" in result)) {
|
|
52
|
+
const resultErrors = normalizeErrors(result);
|
|
53
|
+
setValidationErrors(resultErrors);
|
|
54
|
+
setValidationValid(resultErrors.length === 0);
|
|
55
|
+
setPendingValidation(false);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
setValidationErrors([]);
|
|
59
|
+
setValidationValid(null);
|
|
60
|
+
setPendingValidation(true);
|
|
61
|
+
return Promise.resolve(result).then((validationResult) => {
|
|
62
|
+
if (sequence !== validationSequence.current) return null;
|
|
63
|
+
const resultErrors = normalizeErrors(validationResult);
|
|
64
|
+
setValidationErrors(resultErrors);
|
|
65
|
+
setValidationValid(resultErrors.length === 0);
|
|
66
|
+
return validationResult;
|
|
67
|
+
}).finally(() => {
|
|
68
|
+
if (sequence === validationSequence.current) setPendingValidation(false);
|
|
69
|
+
});
|
|
70
|
+
}, [validate]);
|
|
28
71
|
const styles = field({ invalid });
|
|
29
72
|
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
30
73
|
value: {
|
|
74
|
+
controlId,
|
|
75
|
+
descriptionId,
|
|
76
|
+
dirty: dirty ?? false,
|
|
77
|
+
errorId,
|
|
31
78
|
errors,
|
|
32
79
|
insideField: true,
|
|
33
80
|
invalid,
|
|
34
|
-
|
|
81
|
+
labelId,
|
|
82
|
+
name,
|
|
83
|
+
pending,
|
|
84
|
+
touched: touched ?? false,
|
|
85
|
+
valid: invalid ? false : validationValid
|
|
35
86
|
},
|
|
36
87
|
children: /* @__PURE__ */ jsx(Field.Root, {
|
|
37
88
|
...props,
|
|
38
89
|
ref,
|
|
39
90
|
actionsRef,
|
|
40
91
|
className: cx(styles.root, className),
|
|
92
|
+
"aria-busy": pending || void 0,
|
|
93
|
+
"data-dirty": dirty || void 0,
|
|
41
94
|
"data-invalid": invalid || void 0,
|
|
42
95
|
"data-jaci-component": "field",
|
|
96
|
+
"data-pending": pending || void 0,
|
|
43
97
|
"data-slot": "field",
|
|
98
|
+
"data-touched": touched || void 0,
|
|
44
99
|
disabled,
|
|
45
100
|
dirty,
|
|
46
101
|
invalid,
|
|
47
102
|
name,
|
|
48
103
|
touched,
|
|
49
|
-
validate,
|
|
104
|
+
...validate ? { validate: wrappedValidate } : {},
|
|
50
105
|
validationDebounceTime,
|
|
51
106
|
validationMode,
|
|
52
107
|
children
|
|
53
108
|
})
|
|
54
109
|
});
|
|
55
110
|
});
|
|
111
|
+
const FieldControl = forwardRef(function FieldControl({ "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, className, id, ...props }, ref) {
|
|
112
|
+
const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } = useContext(FieldContext);
|
|
113
|
+
const describedBy = [
|
|
114
|
+
ariaDescribedBy,
|
|
115
|
+
descriptionId,
|
|
116
|
+
invalid ? errorId : void 0
|
|
117
|
+
].filter(Boolean).join(" ") || void 0;
|
|
118
|
+
const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(" ") || void 0;
|
|
119
|
+
const controlProps = {
|
|
120
|
+
...props,
|
|
121
|
+
"aria-busy": pending || void 0,
|
|
122
|
+
"aria-describedby": describedBy,
|
|
123
|
+
"aria-errormessage": ariaErrorMessage ?? (invalid ? errorId : void 0),
|
|
124
|
+
"aria-invalid": ariaInvalid ?? (invalid || void 0),
|
|
125
|
+
"aria-labelledby": labelledBy,
|
|
126
|
+
className,
|
|
127
|
+
"data-pending": pending || void 0,
|
|
128
|
+
id: id ?? controlId
|
|
129
|
+
};
|
|
130
|
+
if (!insideField) return /* @__PURE__ */ jsx(Field.Control, {
|
|
131
|
+
...controlProps,
|
|
132
|
+
ref
|
|
133
|
+
});
|
|
134
|
+
return /* @__PURE__ */ jsx(Field.Control, {
|
|
135
|
+
...controlProps,
|
|
136
|
+
ref
|
|
137
|
+
});
|
|
138
|
+
});
|
|
56
139
|
const FieldLabel = forwardRef(function FieldLabel({ children, className, htmlFor, ...props }, ref) {
|
|
57
|
-
const { insideField, invalid } = useContext(FieldContext);
|
|
140
|
+
const { controlId, insideField, invalid, labelId } = useContext(FieldContext);
|
|
58
141
|
const labelProps = {
|
|
59
142
|
...props,
|
|
60
143
|
className: cx(field({ invalid }).label, className),
|
|
61
144
|
"data-slot": "field-label",
|
|
62
|
-
htmlFor
|
|
145
|
+
htmlFor: htmlFor ?? controlId,
|
|
146
|
+
id: props.id ?? labelId
|
|
63
147
|
};
|
|
64
148
|
if (!insideField) return /* @__PURE__ */ jsx("label", {
|
|
65
149
|
...labelProps,
|
|
66
150
|
ref,
|
|
67
|
-
htmlFor,
|
|
151
|
+
htmlFor: htmlFor ?? controlId,
|
|
68
152
|
children
|
|
69
153
|
});
|
|
70
154
|
return /* @__PURE__ */ jsx(Field.Label, {
|
|
@@ -74,11 +158,12 @@ const FieldLabel = forwardRef(function FieldLabel({ children, className, htmlFor
|
|
|
74
158
|
});
|
|
75
159
|
});
|
|
76
160
|
const FieldDescription = forwardRef(function FieldDescription({ className, ...props }, ref) {
|
|
77
|
-
const { insideField, invalid } = useContext(FieldContext);
|
|
161
|
+
const { descriptionId, insideField, invalid } = useContext(FieldContext);
|
|
78
162
|
const descriptionProps = {
|
|
79
163
|
...props,
|
|
80
164
|
className: cx(field({ invalid }).description, className),
|
|
81
|
-
"data-slot": "field-description"
|
|
165
|
+
"data-slot": "field-description",
|
|
166
|
+
id: props.id ?? descriptionId
|
|
82
167
|
};
|
|
83
168
|
if (!insideField) return /* @__PURE__ */ jsx("p", {
|
|
84
169
|
...descriptionProps,
|
|
@@ -90,7 +175,7 @@ const FieldDescription = forwardRef(function FieldDescription({ className, ...pr
|
|
|
90
175
|
});
|
|
91
176
|
});
|
|
92
177
|
const FieldError = forwardRef(function FieldError({ children, className, match, ...props }, ref) {
|
|
93
|
-
const { errors, insideField, invalid } = useContext(FieldContext);
|
|
178
|
+
const { errorId, errors, insideField, invalid } = useContext(FieldContext);
|
|
94
179
|
const content = children ?? renderErrors(errors);
|
|
95
180
|
if (!insideField) {
|
|
96
181
|
if (content === void 0 || content === null || content === false) return null;
|
|
@@ -99,6 +184,7 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
|
|
|
99
184
|
ref,
|
|
100
185
|
className: cx(field({ invalid }).error, className),
|
|
101
186
|
"data-slot": "field-error",
|
|
187
|
+
id: props.id ?? errorId,
|
|
102
188
|
role: "alert",
|
|
103
189
|
children: content
|
|
104
190
|
});
|
|
@@ -108,6 +194,7 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
|
|
|
108
194
|
ref,
|
|
109
195
|
className: cx(field({ invalid }).error, className),
|
|
110
196
|
"data-slot": "field-error",
|
|
197
|
+
id: props.id ?? errorId,
|
|
111
198
|
match: match ?? (invalid ? true : void 0),
|
|
112
199
|
render: /* @__PURE__ */ jsx("p", {}),
|
|
113
200
|
role: "alert",
|
|
@@ -117,7 +204,14 @@ const FieldError = forwardRef(function FieldError({ children, className, match,
|
|
|
117
204
|
function useFieldState() {
|
|
118
205
|
return useContext(FieldContext);
|
|
119
206
|
}
|
|
207
|
+
const Field$1 = Object.assign(FieldRoot$1, {
|
|
208
|
+
Root: FieldRoot$1,
|
|
209
|
+
Control: FieldControl,
|
|
210
|
+
Label: FieldLabel,
|
|
211
|
+
Description: FieldDescription,
|
|
212
|
+
Error: FieldError
|
|
213
|
+
});
|
|
120
214
|
//#endregion
|
|
121
|
-
export { Field$1 as Field, FieldDescription, FieldError, FieldLabel, useFieldState };
|
|
215
|
+
export { Field$1 as Field, FieldControl, FieldDescription, FieldError, FieldLabel, useFieldState };
|
|
122
216
|
|
|
123
217
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","names":["Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useContext } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n name: string | undefined;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n errors: [],\n insideField: false,\n invalid: false,\n name: undefined,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor: string;\n}\n\nexport const Field = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const errors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const invalid = invalidProp || errors.length > 0;\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider value={{ errors, insideField: true, invalid, name }}>\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-slot=\"field\"\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n validate={validate}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { insideField, invalid } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,eAAe,cAAiC;CACpD,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,MAAM,KAAA;AACR,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,oBAAC,MAAD,EAAA,UAAqD,MAAU,GAAtD,OAAO,UAAU,WAAW,QAAQ,KAAkB,CAChE,EACC,CAAA;AAER;AA6BA,MAAaA,UAAQ,WAAuC,SAASA,QACnE,EACE,YACA,UACA,WACA,OACA,WAAW,OACX,QAAQ,cACR,SAAS,cAAc,OACvB,MACA,SACA,UACA,wBACA,gBACA,GAAG,SAEL,KACA;CACA,MAAM,EAAE,QAAQ,eAAe,WAAW,eAAe;CACzD,MAAM,YAAY,OAAO,WAAW,QAAQ,KAAA;CAC5C,MAAM,SACJ,iBAAiB,KAAA,IAAY,gBAAgB,SAAS,IAAI,gBAAgB,YAAY;CACxF,MAAM,UAAU,eAAe,OAAO,SAAS;CAC/C,MAAM,SAAS,MAAM,EAAE,QAAQ,CAAC;CAEhC,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;GAAE;GAAQ,aAAa;GAAM;GAAS;EAAK;YACvE,oBAACC,MAAU,MAAX;GACE,GAAI;GAC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AAI;GACC;GACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,MAAK;aAEJ;EACA,CAAA;CAEP;CAEA,OACE,oBAACA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC"}
|
|
1
|
+
{"version":3,"file":"field.js","names":["FieldRoot","Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,\n Description: FieldDescription,\n Error: FieldError,\n});\n"],"mappings":";;;;;;;;AA4BA,MAAM,eAAe,cAAiC;CACpD,WAAW,KAAA;CACX,eAAe,KAAA;CACf,OAAO;CACP,SAAS,KAAA;CACT,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,SAAS,KAAA;CACT,MAAM,KAAA;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA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M,EAAE,QAAQ,CAAC,CAAC,CAAC,aAAa,SAAS;EACvD,aAAa;EACb,IAAI,MAAM,MAAM;CAClB;CAEA,IAAI,CAAC,aACH,OAAO,oBAAC,KAAD;EAAG,GAAI;EAAuB;CAAM,CAAA;CAG7C,OAAO,oBAACA,MAAU,aAAX;EAAuB,GAAI;EAAuB;CAAM,CAAA;AACjE,CACF;AAOA,MAAa,aAAa,WAAkD,SAAS,WACnF,EAAE,UAAU,WAAW,OAAO,GAAG,SACjC,KACA;CACA,MAAM,EAAE,SAAS,QAAQ,aAAa,YAAY,WAAW,YAAY;CACzE,MAAM,UAAU,YAAY,aAAa,MAAM;CAE/C,IAAI,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,oBAAC,KAAD;GACE,GAAI;GACC;GACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,IAAI,MAAM,MAAM;GAChB,MAAK;aAEJ;EACA,CAAA;CAEP;CAEA,OACE,oBAACA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC;AAEA,MAAaD,UAAQ,OAAO,OAAOD,aAAW;CAC5C,MAAMA;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.cjs";
|
|
2
|
-
export { Field, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
|
|
1
|
+
import { Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.cjs";
|
|
2
|
+
export { Field, FieldControl, type FieldControlProps, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.js";
|
|
2
|
-
export { Field, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
|
|
1
|
+
import { Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.js";
|
|
2
|
+
export { Field, FieldControl, type FieldControlProps, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
3
|
+
const require_icon_button = require("../../styled-system/recipes/icon-button.cjs");
|
|
4
|
+
const require_index = require("../layout/index.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/components/icon-button/icon-button.tsx
|
|
8
|
+
function hasTextualContent(children) {
|
|
9
|
+
if (typeof children === "string" || typeof children === "number") return String(children).trim().length > 0;
|
|
10
|
+
return react.Children.toArray(children).some((child) => {
|
|
11
|
+
if (!(0, react.isValidElement)(child)) return false;
|
|
12
|
+
return hasTextualContent(child.props.children);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const IconButton = (0, react.forwardRef)(function IconButton({ children, className, disabled, loading = false, size = "md", variant = "outline", ...props }, ref) {
|
|
16
|
+
if (!hasTextualContent(children) && !props["aria-label"] && !props["aria-labelledby"]) throw new Error("IconButton requires an aria-label when it has no textual content.");
|
|
17
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
18
|
+
...props,
|
|
19
|
+
ref,
|
|
20
|
+
"aria-busy": loading || void 0,
|
|
21
|
+
className: require_cx.cx(require_icon_button.iconButton({
|
|
22
|
+
size,
|
|
23
|
+
variant
|
|
24
|
+
}), className),
|
|
25
|
+
"data-jaci-component": "icon-button",
|
|
26
|
+
"data-loading": loading || void 0,
|
|
27
|
+
"data-slot": "icon-button",
|
|
28
|
+
disabled: disabled || loading,
|
|
29
|
+
type: props.type ?? "button",
|
|
30
|
+
children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.Spinner, {
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
label: "",
|
|
33
|
+
size: "sm"
|
|
34
|
+
}) : children
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.IconButton = IconButton;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=icon-button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.cjs","names":["Children","cx","iconButton","Spinner"],"sources":["../../../src/components/icon-button/icon-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { Children, forwardRef, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { iconButton } from \"../../styled-system/recipes\";\nimport { Spinner } from \"../layout\";\n\nexport interface IconButtonProps\n extends Omit<ComponentPropsWithoutRef<\"button\">, \"children\" | \"color\"> {\n children?: ReactNode;\n variant?: \"solid\" | \"outline\" | \"ghost\" | \"danger\";\n size?: \"sm\" | \"md\" | \"lg\";\n loading?: boolean;\n}\n\nfunction hasTextualContent(children: ReactNode): boolean {\n if (typeof children === \"string\" || typeof children === \"number\") {\n return String(children).trim().length > 0;\n }\n\n return Children.toArray(children).some((child) => {\n if (!isValidElement(child)) return false;\n return hasTextualContent((child.props as { children?: ReactNode }).children);\n });\n}\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n { children, className, disabled, loading = false, size = \"md\", variant = \"outline\", ...props },\n ref,\n) {\n if (!hasTextualContent(children) && !props[\"aria-label\"] && !props[\"aria-labelledby\"]) {\n throw new Error(\"IconButton requires an aria-label when it has no textual content.\");\n }\n\n return (\n <button\n {...props}\n ref={ref}\n aria-busy={loading || undefined}\n className={cx(iconButton({ size, variant }), className)}\n data-jaci-component=\"icon-button\"\n data-loading={loading || undefined}\n data-slot=\"icon-button\"\n disabled={disabled || loading}\n type={props.type ?? \"button\"}\n >\n {loading ? <Spinner aria-hidden=\"true\" label=\"\" size=\"sm\" /> : children}\n </button>\n );\n});\n"],"mappings":";;;;;;;AAiBA,SAAS,kBAAkB,UAA8B;CACvD,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,OAAO,OAAO,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS;CAG1C,OAAOA,MAAAA,SAAS,QAAQ,QAAQ,CAAC,CAAC,MAAM,UAAU;EAChD,IAAI,EAAA,GAAA,MAAA,eAAA,CAAgB,KAAK,GAAG,OAAO;EACnC,OAAO,kBAAmB,MAAM,MAAmC,QAAQ;CAC7E,CAAC;AACH;AAEA,MAAa,cAAA,GAAA,MAAA,WAAA,CAA4D,SAAS,WAChF,EAAE,UAAU,WAAW,UAAU,UAAU,OAAO,OAAO,MAAM,UAAU,WAAW,GAAG,SACvF,KACA;CACA,IAAI,CAAC,kBAAkB,QAAQ,KAAK,CAAC,MAAM,iBAAiB,CAAC,MAAM,oBACjE,MAAM,IAAI,MAAM,mEAAmE;CAGrF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;EACE,GAAI;EACC;EACL,aAAW,WAAW,KAAA;EACtB,WAAWC,WAAAA,GAAGC,oBAAAA,WAAW;GAAE;GAAM;EAAQ,CAAC,GAAG,SAAS;EACtD,uBAAoB;EACpB,gBAAc,WAAW,KAAA;EACzB,aAAU;EACV,UAAU,YAAY;EACtB,MAAM,MAAM,QAAQ;YAEnB,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,SAAD;GAAS,eAAY;GAAO,OAAM;GAAG,MAAK;EAAM,CAAA,IAAI;CACzD,CAAA;AAEZ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/icon-button/icon-button.d.ts
|
|
3
|
+
interface IconButtonProps extends Omit<ComponentPropsWithoutRef<"button">, "children" | "color"> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
variant?: "solid" | "outline" | "ghost" | "danger";
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { IconButton, IconButtonProps };
|
|
12
|
+
//# sourceMappingURL=icon-button.d.cts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/icon-button/icon-button.d.ts
|
|
3
|
+
interface IconButtonProps extends Omit<ComponentPropsWithoutRef<"button">, "children" | "color"> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
variant?: "solid" | "outline" | "ghost" | "danger";
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { IconButton, IconButtonProps };
|
|
12
|
+
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../styled-system/css/cx.js";
|
|
3
|
+
import { iconButton } from "../../styled-system/recipes/icon-button.js";
|
|
4
|
+
import { Spinner } from "../layout/index.js";
|
|
5
|
+
import { Children, forwardRef, isValidElement } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/icon-button/icon-button.tsx
|
|
8
|
+
function hasTextualContent(children) {
|
|
9
|
+
if (typeof children === "string" || typeof children === "number") return String(children).trim().length > 0;
|
|
10
|
+
return Children.toArray(children).some((child) => {
|
|
11
|
+
if (!isValidElement(child)) return false;
|
|
12
|
+
return hasTextualContent(child.props.children);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const IconButton = forwardRef(function IconButton({ children, className, disabled, loading = false, size = "md", variant = "outline", ...props }, ref) {
|
|
16
|
+
if (!hasTextualContent(children) && !props["aria-label"] && !props["aria-labelledby"]) throw new Error("IconButton requires an aria-label when it has no textual content.");
|
|
17
|
+
return /* @__PURE__ */ jsx("button", {
|
|
18
|
+
...props,
|
|
19
|
+
ref,
|
|
20
|
+
"aria-busy": loading || void 0,
|
|
21
|
+
className: cx(iconButton({
|
|
22
|
+
size,
|
|
23
|
+
variant
|
|
24
|
+
}), className),
|
|
25
|
+
"data-jaci-component": "icon-button",
|
|
26
|
+
"data-loading": loading || void 0,
|
|
27
|
+
"data-slot": "icon-button",
|
|
28
|
+
disabled: disabled || loading,
|
|
29
|
+
type: props.type ?? "button",
|
|
30
|
+
children: loading ? /* @__PURE__ */ jsx(Spinner, {
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
label: "",
|
|
33
|
+
size: "sm"
|
|
34
|
+
}) : children
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { IconButton };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.js","names":[],"sources":["../../../src/components/icon-button/icon-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { Children, forwardRef, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { iconButton } from \"../../styled-system/recipes\";\nimport { Spinner } from \"../layout\";\n\nexport interface IconButtonProps\n extends Omit<ComponentPropsWithoutRef<\"button\">, \"children\" | \"color\"> {\n children?: ReactNode;\n variant?: \"solid\" | \"outline\" | \"ghost\" | \"danger\";\n size?: \"sm\" | \"md\" | \"lg\";\n loading?: boolean;\n}\n\nfunction hasTextualContent(children: ReactNode): boolean {\n if (typeof children === \"string\" || typeof children === \"number\") {\n return String(children).trim().length > 0;\n }\n\n return Children.toArray(children).some((child) => {\n if (!isValidElement(child)) return false;\n return hasTextualContent((child.props as { children?: ReactNode }).children);\n });\n}\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n { children, className, disabled, loading = false, size = \"md\", variant = \"outline\", ...props },\n ref,\n) {\n if (!hasTextualContent(children) && !props[\"aria-label\"] && !props[\"aria-labelledby\"]) {\n throw new Error(\"IconButton requires an aria-label when it has no textual content.\");\n }\n\n return (\n <button\n {...props}\n ref={ref}\n aria-busy={loading || undefined}\n className={cx(iconButton({ size, variant }), className)}\n data-jaci-component=\"icon-button\"\n data-loading={loading || undefined}\n data-slot=\"icon-button\"\n disabled={disabled || loading}\n type={props.type ?? \"button\"}\n >\n {loading ? <Spinner aria-hidden=\"true\" label=\"\" size=\"sm\" /> : children}\n </button>\n );\n});\n"],"mappings":";;;;;;;AAiBA,SAAS,kBAAkB,UAA8B;CACvD,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,OAAO,OAAO,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS;CAG1C,OAAO,SAAS,QAAQ,QAAQ,CAAC,CAAC,MAAM,UAAU;EAChD,IAAI,CAAC,eAAe,KAAK,GAAG,OAAO;EACnC,OAAO,kBAAmB,MAAM,MAAmC,QAAQ;CAC7E,CAAC;AACH;AAEA,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,UAAU,WAAW,UAAU,UAAU,OAAO,OAAO,MAAM,UAAU,WAAW,GAAG,SACvF,KACA;CACA,IAAI,CAAC,kBAAkB,QAAQ,KAAK,CAAC,MAAM,iBAAiB,CAAC,MAAM,oBACjE,MAAM,IAAI,MAAM,mEAAmE;CAGrF,OACE,oBAAC,UAAD;EACE,GAAI;EACC;EACL,aAAW,WAAW,KAAA;EACtB,WAAW,GAAG,WAAW;GAAE;GAAM;EAAQ,CAAC,GAAG,SAAS;EACtD,uBAAoB;EACpB,gBAAc,WAAW,KAAA;EACzB,aAAU;EACV,UAAU,YAAY;EACtB,MAAM,MAAM,QAAQ;YAEnB,UAAU,oBAAC,SAAD;GAAS,eAAY;GAAO,OAAM;GAAG,MAAK;EAAM,CAAA,IAAI;CACzD,CAAA;AAEZ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
2
|
+
const require_input_group = require("../../styled-system/recipes/input-group.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/components/input-group/input-group.tsx
|
|
6
|
+
const InputGroupRoot = (0, react.forwardRef)(function InputGroupRoot({ className, ...props }, ref) {
|
|
7
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
8
|
+
...props,
|
|
9
|
+
ref,
|
|
10
|
+
className: require_cx.cx(require_input_group.inputGroup().root, className),
|
|
11
|
+
"data-jaci-component": "input-group",
|
|
12
|
+
"data-slot": "input-group"
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const InputGroupAddon = (0, react.forwardRef)(function InputGroupAddon({ className, ...props }, ref) {
|
|
16
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
17
|
+
...props,
|
|
18
|
+
ref,
|
|
19
|
+
className: require_cx.cx(require_input_group.inputGroup().addon, className),
|
|
20
|
+
"data-slot": "input-group-addon"
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
const InputGroup = Object.assign(InputGroupRoot, {
|
|
24
|
+
Root: InputGroupRoot,
|
|
25
|
+
Addon: InputGroupAddon
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.InputGroup = InputGroup;
|
|
29
|
+
exports.InputGroupAddon = InputGroupAddon;
|
|
30
|
+
exports.InputGroupRoot = InputGroupRoot;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=input-group.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-group.cjs","names":["cx","inputGroup"],"sources":["../../../src/components/input-group/input-group.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { inputGroup } from \"../../styled-system/recipes\";\n\nexport interface InputGroupRootProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const InputGroupRoot = forwardRef<HTMLDivElement, InputGroupRootProps>(\n function InputGroupRoot({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(inputGroup().root, className)}\n data-jaci-component=\"input-group\"\n data-slot=\"input-group\"\n />\n );\n },\n);\n\nexport type InputGroupAddonProps = ComponentPropsWithoutRef<\"span\">;\nexport const InputGroupAddon = forwardRef<HTMLSpanElement, InputGroupAddonProps>(\n function InputGroupAddon({ className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(inputGroup().addon, className)}\n data-slot=\"input-group-addon\"\n />\n );\n },\n);\n\nexport const InputGroup = Object.assign(InputGroupRoot, {\n Root: InputGroupRoot,\n Addon: InputGroupAddon,\n});\n"],"mappings":";;;;;AAUA,MAAa,kBAAA,GAAA,MAAA,WAAA,CACX,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,WAAWA,WAAAA,GAAGC,oBAAAA,WAAW,CAAC,CAAC,MAAM,SAAS;EAC1C,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,mBAAA,GAAA,MAAA,WAAA,CACX,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAS,KAAK;CACrD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,GAAI;EACC;EACL,WAAWD,WAAAA,GAAGC,oBAAAA,WAAW,CAAC,CAAC,OAAO,SAAS;EAC3C,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,aAAa,OAAO,OAAO,gBAAgB;CACtD,MAAM;CACN,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/input-group/input-group.d.ts
|
|
3
|
+
interface InputGroupRootProps extends ComponentPropsWithoutRef<"div"> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const InputGroupRoot: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
type InputGroupAddonProps = ComponentPropsWithoutRef<"span">;
|
|
8
|
+
declare const InputGroupAddon: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
declare const InputGroup: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
10
|
+
Root: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
Addon: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InputGroup, InputGroupAddon, InputGroupAddonProps, InputGroupRoot, InputGroupRootProps };
|
|
15
|
+
//# sourceMappingURL=input-group.d.cts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/input-group/input-group.d.ts
|
|
3
|
+
interface InputGroupRootProps extends ComponentPropsWithoutRef<"div"> {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const InputGroupRoot: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
type InputGroupAddonProps = ComponentPropsWithoutRef<"span">;
|
|
8
|
+
declare const InputGroupAddon: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
declare const InputGroup: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
10
|
+
Root: import("react").ForwardRefExoticComponent<InputGroupRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
Addon: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InputGroup, InputGroupAddon, InputGroupAddonProps, InputGroupRoot, InputGroupRootProps };
|
|
15
|
+
//# sourceMappingURL=input-group.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cx } from "../../styled-system/css/cx.js";
|
|
2
|
+
import { inputGroup } from "../../styled-system/recipes/input-group.js";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/input-group/input-group.tsx
|
|
6
|
+
const InputGroupRoot = forwardRef(function InputGroupRoot({ className, ...props }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
...props,
|
|
9
|
+
ref,
|
|
10
|
+
className: cx(inputGroup().root, className),
|
|
11
|
+
"data-jaci-component": "input-group",
|
|
12
|
+
"data-slot": "input-group"
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const InputGroupAddon = forwardRef(function InputGroupAddon({ className, ...props }, ref) {
|
|
16
|
+
return /* @__PURE__ */ jsx("span", {
|
|
17
|
+
...props,
|
|
18
|
+
ref,
|
|
19
|
+
className: cx(inputGroup().addon, className),
|
|
20
|
+
"data-slot": "input-group-addon"
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
const InputGroup = Object.assign(InputGroupRoot, {
|
|
24
|
+
Root: InputGroupRoot,
|
|
25
|
+
Addon: InputGroupAddon
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { InputGroup, InputGroupAddon, InputGroupRoot };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=input-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-group.js","names":[],"sources":["../../../src/components/input-group/input-group.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { inputGroup } from \"../../styled-system/recipes\";\n\nexport interface InputGroupRootProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const InputGroupRoot = forwardRef<HTMLDivElement, InputGroupRootProps>(\n function InputGroupRoot({ className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(inputGroup().root, className)}\n data-jaci-component=\"input-group\"\n data-slot=\"input-group\"\n />\n );\n },\n);\n\nexport type InputGroupAddonProps = ComponentPropsWithoutRef<\"span\">;\nexport const InputGroupAddon = forwardRef<HTMLSpanElement, InputGroupAddonProps>(\n function InputGroupAddon({ className, ...props }, ref) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(inputGroup().addon, className)}\n data-slot=\"input-group-addon\"\n />\n );\n },\n);\n\nexport const InputGroup = Object.assign(InputGroupRoot, {\n Root: InputGroupRoot,\n Addon: InputGroupAddon,\n});\n"],"mappings":";;;;;AAUA,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,WAAW,CAAC,CAAC,MAAM,SAAS;EAC1C,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;AAGA,MAAa,kBAAkB,WAC7B,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAS,KAAK;CACrD,OACE,oBAAC,QAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,WAAW,CAAC,CAAC,OAAO,SAAS;EAC3C,aAAU;CACX,CAAA;AAEL,CACF;AAEA,MAAa,aAAa,OAAO,OAAO,gBAAgB;CACtD,MAAM;CACN,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps } from "./pin-input.cjs";
|
|
2
|
+
export { PinInput, PinInputControl, type PinInputControlProps, PinInputDescription, type PinInputDescriptionProps, PinInputError, type PinInputErrorProps, PinInputHiddenInput, type PinInputHiddenInputProps, PinInputInput, type PinInputInputProps, PinInputInputs, type PinInputInputsProps, PinInputLabel, type PinInputLabelProps, PinInputRoot, type PinInputRootProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps } from "./pin-input.js";
|
|
2
|
+
export { PinInput, PinInputControl, type PinInputControlProps, PinInputDescription, type PinInputDescriptionProps, PinInputError, type PinInputErrorProps, PinInputHiddenInput, type PinInputHiddenInputProps, PinInputInput, type PinInputInputProps, PinInputInputs, type PinInputInputsProps, PinInputLabel, type PinInputLabelProps, PinInputRoot, type PinInputRootProps };
|