@rovula/ui 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.css +630 -467
- package/dist/cjs/bundle.js +1545 -1545
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/AlertDialog/AlertDialog.stories.d.ts +3 -0
- package/dist/cjs/types/components/Dialog/Dialog.d.ts +7 -1
- package/dist/cjs/types/components/Dialog/Dialog.stories.d.ts +3 -0
- package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +2 -0
- package/dist/cjs/types/components/Form/Field.d.ts +26 -0
- package/dist/cjs/types/components/Form/FieldMessage.d.ts +7 -0
- package/dist/cjs/types/components/Form/Form.d.ts +49 -11
- package/dist/cjs/types/components/Form/Form.stories.d.ts +23 -0
- package/dist/cjs/types/components/Form/ValidationHintList.d.ts +17 -0
- package/dist/cjs/types/components/Form/ValidationHintList.stories.d.ts +9 -0
- package/dist/cjs/types/components/Form/index.d.ts +10 -0
- package/dist/cjs/types/components/Form/useOptionBridge.d.ts +17 -0
- package/dist/cjs/types/components/OtpInput/OtpInput.d.ts +17 -0
- package/dist/cjs/types/components/OtpInput/OtpInput.stories.d.ts +15 -0
- package/dist/cjs/types/components/OtpInput/OtpInputGroup.d.ts +25 -0
- package/dist/cjs/types/components/OtpInput/index.d.ts +5 -0
- package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +3 -0
- package/dist/cjs/types/index.d.ts +5 -0
- package/dist/cjs/types/theme/ThemeColorCoverageRuntime.stories.d.ts +10 -0
- package/dist/cjs/types/utils/colors.d.ts +351 -267
- package/dist/components/ActionButton/ActionButton.stories.js +2 -2
- package/dist/components/ActionButton/ActionButton.styles.js +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +6 -6
- package/dist/components/AlertDialog/AlertDialog.stories.js +3 -0
- package/dist/components/Avatar/Avatar.stories.js +1 -1
- package/dist/components/Avatar/Avatar.styles.js +1 -1
- package/dist/components/Avatar/AvatarBase.js +1 -1
- package/dist/components/Avatar/AvatarGroup.stories.js +1 -1
- package/dist/components/Button/Buttons.stories.js +2 -2
- package/dist/components/Calendar/Calendar.js +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Checkbox/Checkbox.stories.js +17 -7
- package/dist/components/Collapsible/Collapsible.styles.js +1 -1
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/Dialog/Dialog.js +12 -7
- package/dist/components/Dialog/Dialog.stories.js +90 -2
- package/dist/components/Dropdown/Dropdown.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenu.js +3 -3
- package/dist/components/FocusedScrollView/FocusedScrollView.stories.js +6 -6
- package/dist/components/Form/Field.js +60 -0
- package/dist/components/Form/FieldMessage.js +24 -0
- package/dist/components/Form/Form.js +73 -41
- package/dist/components/Form/Form.stories.js +221 -0
- package/dist/components/Form/ValidationHintList.js +30 -0
- package/dist/components/Form/ValidationHintList.stories.js +50 -0
- package/dist/components/Form/index.js +5 -0
- package/dist/components/Form/useOptionBridge.js +27 -0
- package/dist/components/InputFilter/InputFilter.js +5 -4
- package/dist/components/InputFilter/InputFilter.stories.js +1 -1
- package/dist/components/InputFilter/InputFilter.styles.js +14 -1
- package/dist/components/Label/Label.styles.js +1 -1
- package/dist/components/Menu/Menu.js +2 -2
- package/dist/components/NumberInput/NumberInput.stories.js +1 -1
- package/dist/components/OtpInput/OtpInput.js +118 -0
- package/dist/components/OtpInput/OtpInput.stories.js +60 -0
- package/dist/components/OtpInput/OtpInputGroup.js +23 -0
- package/dist/components/OtpInput/index.js +3 -0
- package/dist/components/PasswordInput/PasswordInput.stories.js +1 -1
- package/dist/components/Popover/Popover.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.stories.js +2 -2
- package/dist/components/Search/Search.js +13 -1
- package/dist/components/Search/Search.stories.js +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider.stories.js +5 -5
- package/dist/components/Switch/Switch.stories.js +2 -2
- package/dist/components/Switch/Switch.styles.js +1 -1
- package/dist/components/Table/Table.js +5 -5
- package/dist/components/Tabs/Tabs.js +12 -9
- package/dist/components/Tabs/Tabs.stories.js +1 -1
- package/dist/components/Text/Text.js +1 -1
- package/dist/components/Text/Text.stories.js +1 -1
- package/dist/components/TextArea/TextArea.stories.js +1 -1
- package/dist/components/TextArea/TextArea.styles.js +3 -3
- package/dist/components/TextInput/TextInput.js +3 -2
- package/dist/components/TextInput/TextInput.stories.js +3 -3
- package/dist/components/TextInput/TextInput.styles.js +41 -19
- package/dist/components/Toast/Toast.js +4 -2
- package/dist/components/Toast/Toast.stories.js +1 -1
- package/dist/components/Toast/Toast.styles.js +4 -4
- package/dist/components/Toast/Toaster.js +2 -2
- package/dist/components/Tree/Tree.stories.js +1 -1
- package/dist/components/Tree/TreeItem.js +1 -1
- package/dist/esm/bundle.css +630 -467
- package/dist/esm/bundle.js +1545 -1545
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/AlertDialog/AlertDialog.stories.d.ts +3 -0
- package/dist/esm/types/components/Dialog/Dialog.d.ts +7 -1
- package/dist/esm/types/components/Dialog/Dialog.stories.d.ts +3 -0
- package/dist/esm/types/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +2 -0
- package/dist/esm/types/components/Form/Field.d.ts +26 -0
- package/dist/esm/types/components/Form/FieldMessage.d.ts +7 -0
- package/dist/esm/types/components/Form/Form.d.ts +49 -11
- package/dist/esm/types/components/Form/Form.stories.d.ts +23 -0
- package/dist/esm/types/components/Form/ValidationHintList.d.ts +17 -0
- package/dist/esm/types/components/Form/ValidationHintList.stories.d.ts +9 -0
- package/dist/esm/types/components/Form/index.d.ts +10 -0
- package/dist/esm/types/components/Form/useOptionBridge.d.ts +17 -0
- package/dist/esm/types/components/OtpInput/OtpInput.d.ts +17 -0
- package/dist/esm/types/components/OtpInput/OtpInput.stories.d.ts +15 -0
- package/dist/esm/types/components/OtpInput/OtpInputGroup.d.ts +25 -0
- package/dist/esm/types/components/OtpInput/index.d.ts +5 -0
- package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +3 -0
- package/dist/esm/types/index.d.ts +5 -0
- package/dist/esm/types/theme/ThemeColorCoverageRuntime.stories.d.ts +10 -0
- package/dist/esm/types/utils/colors.d.ts +351 -267
- package/dist/index.d.ts +512 -269
- package/dist/index.js +3 -0
- package/dist/src/theme/global.css +2739 -2681
- package/dist/theme/ThemeColorCoverageRuntime.stories.js +91 -0
- package/dist/utils/colors.js +359 -267
- package/package.json +4 -2
- package/src/components/ActionButton/ActionButton.stories.tsx +6 -6
- package/src/components/ActionButton/ActionButton.styles.ts +1 -1
- package/src/components/AlertDialog/AlertDialog.stories.tsx +22 -0
- package/src/components/AlertDialog/AlertDialog.tsx +6 -6
- package/src/components/Avatar/Avatar.stories.tsx +1 -1
- package/src/components/Avatar/Avatar.styles.ts +1 -1
- package/src/components/Avatar/AvatarBase.tsx +1 -1
- package/src/components/Avatar/AvatarGroup.stories.tsx +1 -1
- package/src/components/Button/Buttons.stories.tsx +25 -17
- package/src/components/Calendar/Calendar.tsx +3 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +35 -12
- package/src/components/Checkbox/Checkbox.tsx +7 -5
- package/src/components/Collapsible/Collapsible.styles.ts +1 -1
- package/src/components/DataTable/DataTable.tsx +2 -2
- package/src/components/Dialog/Dialog.stories.tsx +173 -0
- package/src/components/Dialog/Dialog.tsx +32 -15
- package/src/components/Dropdown/Dropdown.styles.ts +1 -1
- package/src/components/Dropdown/Dropdown.tsx +16 -14
- package/src/components/DropdownMenu/DropdownMenu.tsx +3 -3
- package/src/components/FocusedScrollView/FocusedScrollView.stories.tsx +10 -10
- package/src/components/Form/Field.tsx +160 -0
- package/src/components/Form/FieldMessage.tsx +38 -0
- package/src/components/Form/Form.docs.mdx +67 -0
- package/src/components/Form/Form.stories.tsx +490 -0
- package/src/components/Form/Form.tsx +185 -87
- package/src/components/Form/README.md +284 -0
- package/src/components/Form/ValidationHintList.stories.tsx +118 -0
- package/src/components/Form/ValidationHintList.tsx +82 -0
- package/src/components/Form/index.ts +28 -0
- package/src/components/Form/useOptionBridge.ts +55 -0
- package/src/components/InputFilter/InputFilter.stories.tsx +1 -1
- package/src/components/InputFilter/InputFilter.styles.ts +14 -1
- package/src/components/InputFilter/InputFilter.tsx +33 -28
- package/src/components/Label/Label.styles.ts +2 -2
- package/src/components/Label/Label.tsx +1 -1
- package/src/components/Menu/Menu.tsx +12 -12
- package/src/components/NumberInput/NumberInput.stories.tsx +1 -1
- package/src/components/OtpInput/OtpInput.stories.tsx +168 -0
- package/src/components/OtpInput/OtpInput.tsx +210 -0
- package/src/components/OtpInput/OtpInputGroup.tsx +74 -0
- package/src/components/OtpInput/index.ts +5 -0
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/RadioGroup/RadioGroup.stories.tsx +4 -4
- package/src/components/RadioGroup/RadioGroup.tsx +2 -1
- package/src/components/Search/Search.stories.tsx +1 -1
- package/src/components/Search/Search.tsx +6 -2
- package/src/components/Slider/Slider.stories.tsx +7 -7
- package/src/components/Slider/Slider.tsx +1 -1
- package/src/components/Switch/Switch.stories.tsx +4 -4
- package/src/components/Switch/Switch.styles.ts +1 -1
- package/src/components/Table/Table.tsx +5 -5
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +29 -18
- package/src/components/Text/Text.stories.tsx +1 -1
- package/src/components/Text/Text.tsx +1 -1
- package/src/components/TextArea/TextArea.stories.tsx +1 -1
- package/src/components/TextArea/TextArea.styles.ts +3 -3
- package/src/components/TextInput/TextInput.stories.tsx +7 -7
- package/src/components/TextInput/TextInput.styles.ts +42 -19
- package/src/components/TextInput/TextInput.tsx +3 -1
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/Toast/Toast.styles.tsx +7 -7
- package/src/components/Toast/Toast.tsx +5 -4
- package/src/components/Toast/Toaster.tsx +17 -20
- package/src/components/Tree/Tree.stories.tsx +1 -1
- package/src/components/Tree/TreeItem.tsx +1 -1
- package/src/index.ts +5 -0
- package/src/theme/THEME_MAPPING.md +36 -37
- package/src/theme/ThemeColorCoverageRuntime.stories.tsx +236 -0
- package/src/theme/direct-token-migration-plan.md +121 -0
- package/src/theme/figma-mcp-check-report.md +225 -0
- package/src/theme/figma-mcp-component-checklist.json +1250 -0
- package/src/theme/global.css +7 -3
- package/src/theme/presets/colors.js +173 -64
- package/src/theme/themes/skyller/baseline.css +0 -4
- package/src/theme/themes/variable-mapping.css +1064 -0
- package/src/theme/themes/variable.css +248 -230
- package/src/theme/themes/xspector/baseline.css +0 -4
- package/src/theme/themes/xspector/components/dropdown-menu.css +4 -4
- package/src/theme/themes/xspector/components/loading.css +2 -2
- package/src/theme/tokens/baseline.css +0 -3
- package/src/theme/tokens/color.css +36 -65
- package/src/theme/tokens/components/action-button.css +6 -6
- package/src/theme/tokens/components/button.css +189 -189
- package/src/theme/tokens/components/dropdown-menu.css +5 -5
- package/src/theme/tokens/components/footer.css +1 -1
- package/src/theme/tokens/components/loading.css +2 -2
- package/src/theme/tokens/components/switch.css +11 -11
- package/src/theme/tokens/typography.css +28 -28
- package/src/theme/tokens_old/baseline.css +13 -0
- package/src/theme/tokens_old/color.css +78 -0
- package/src/theme/tokens_old/components/action-button.css +127 -0
- package/src/theme/tokens_old/components/button.css +512 -0
- package/src/theme/tokens_old/components/dropdown-menu.css +27 -0
- package/src/theme/tokens_old/components/footer.css +9 -0
- package/src/theme/tokens_old/components/loading.css +11 -0
- package/src/theme/tokens_old/components/navbar.css +9 -0
- package/src/theme/tokens_old/components/progress-bar.css +8 -0
- package/src/theme/tokens_old/components/switch.css +29 -0
- package/src/theme/tokens_old/typography.css +199 -0
- package/src/theme/tokens_old/variables.css +28 -0
- package/src/theme/utils.js +172 -33
- package/src/utils/colors.ts +367 -278
- package/src/theme/themes/skyller/color.css +0 -79
- package/src/theme/themes/skyller/palette.css +0 -143
- package/src/theme/themes/skyller/state.css +0 -94
- package/src/theme/themes/skyller/transparent.css +0 -94
- package/src/theme/themes/xspector/color.css +0 -83
- package/src/theme/themes/xspector/palette.css +0 -142
- package/src/theme/themes/xspector/state.css +0 -94
- package/src/theme/themes/xspector/transparent.css +0 -93
- /package/src/theme/{tokens → tokens_old}/palette.css +0 -0
- /package/src/theme/{tokens → tokens_old}/state.css +0 -0
- /package/src/theme/{tokens → tokens_old}/transparent.css +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useFormContext } from "react-hook-form";
|
|
14
|
+
import { cn } from "@/utils/cn";
|
|
15
|
+
export const FieldMessage = (_a) => {
|
|
16
|
+
var { name, className } = _a, props = __rest(_a, ["name", "className"]);
|
|
17
|
+
const { getFieldState, formState } = useFormContext();
|
|
18
|
+
const { error } = getFieldState(name, formState);
|
|
19
|
+
if (!(error === null || error === void 0 ? void 0 : error.message)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return (_jsx("p", Object.assign({}, props, { className: cn("text-sm text-input-error mt-1", className), role: "alert", children: error.message })));
|
|
23
|
+
};
|
|
24
|
+
export default FieldMessage;
|
|
@@ -1,45 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.string()
|
|
10
|
-
.min(6, "Password must be at least 6 characters")
|
|
11
|
-
.required("Password is required"),
|
|
12
|
-
});
|
|
13
|
-
const Form = ({ onSubmit, className = "" }) => {
|
|
14
|
-
const [values, setValues] = useState({
|
|
15
|
-
name: "",
|
|
16
|
-
email: "",
|
|
17
|
-
password: "",
|
|
18
|
-
});
|
|
19
|
-
const [errors, setErrors] = useState({});
|
|
20
|
-
const handleChange = (e) => {
|
|
21
|
-
const { name, value } = e.target;
|
|
22
|
-
setValues(Object.assign(Object.assign({}, values), { [name]: value }));
|
|
23
|
-
};
|
|
24
|
-
const handleSubmit = async (e) => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
try {
|
|
27
|
-
await schema.validate(values, { abortEarly: false });
|
|
28
|
-
setErrors({});
|
|
29
|
-
onSubmit(values);
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
if (err instanceof yup.ValidationError) {
|
|
33
|
-
const validationErrors = {};
|
|
34
|
-
err.inner.forEach((error) => {
|
|
35
|
-
if (error.path) {
|
|
36
|
-
validationErrors[error.path] = error.message;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
setErrors(validationErrors);
|
|
40
|
-
}
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
41
9
|
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from "react";
|
|
14
|
+
import { FormProvider, useForm, } from "react-hook-form";
|
|
15
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
16
|
+
export const createYupResolver = (schema) => yupResolver(schema);
|
|
17
|
+
export const createControlledForm = ({ methods, defaultValues, controllerRef, }) => {
|
|
18
|
+
const FormRoot = React.forwardRef((_a, ref) => {
|
|
19
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
20
|
+
return (_jsx(Form, Object.assign({}, props, { ref: ref, methods: methods, defaultValues: defaultValues, controllerRef: controllerRef, children: children })));
|
|
21
|
+
});
|
|
22
|
+
FormRoot.displayName = "ControlledFormRoot";
|
|
23
|
+
return {
|
|
24
|
+
methods,
|
|
25
|
+
FormRoot,
|
|
42
26
|
};
|
|
43
|
-
return (_jsxs("form", { className: `form ${className}`, onSubmit: handleSubmit, children: [_jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "name", children: "Name" }), _jsx("input", { id: "name", name: "name", type: "text", value: values.name, onChange: handleChange }), errors.name && _jsx("span", { className: "error", children: errors.name })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "email", children: "Email" }), _jsx("input", { id: "email", name: "email", type: "email", value: values.email, onChange: handleChange }), errors.email && _jsx("span", { className: "error", children: errors.email })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "password", children: "Password" }), _jsx("input", { id: "password", name: "password", type: "password", value: values.password, onChange: handleChange }), errors.password && _jsx("span", { className: "error", children: errors.password })] }), _jsx("button", { type: "submit", children: "Submit" })] }));
|
|
44
27
|
};
|
|
28
|
+
export const useControlledForm = ({ defaultValues, controllerRef, resolver, validationSchema, mode = "onSubmit", reValidateMode = "onChange", }) => {
|
|
29
|
+
const resolvedResolver = resolver !== null && resolver !== void 0 ? resolver : (validationSchema
|
|
30
|
+
? createYupResolver(validationSchema)
|
|
31
|
+
: undefined);
|
|
32
|
+
const methods = useForm({
|
|
33
|
+
defaultValues,
|
|
34
|
+
resolver: resolvedResolver,
|
|
35
|
+
mode,
|
|
36
|
+
reValidateMode,
|
|
37
|
+
});
|
|
38
|
+
return createControlledForm({
|
|
39
|
+
methods,
|
|
40
|
+
defaultValues,
|
|
41
|
+
controllerRef,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const FormInner = (_a, ref) => {
|
|
45
|
+
var { children, defaultValues, methods: externalMethods, controllerRef, onSubmit, onInvalidSubmit, resolver, validationSchema, mode = "onSubmit", reValidateMode = "onChange", noValidate = true } = _a, formProps = __rest(_a, ["children", "defaultValues", "methods", "controllerRef", "onSubmit", "onInvalidSubmit", "resolver", "validationSchema", "mode", "reValidateMode", "noValidate"]);
|
|
46
|
+
const resolvedResolver = resolver !== null && resolver !== void 0 ? resolver : (validationSchema
|
|
47
|
+
? createYupResolver(validationSchema)
|
|
48
|
+
: undefined);
|
|
49
|
+
const internalMethods = useForm({
|
|
50
|
+
defaultValues,
|
|
51
|
+
resolver: resolvedResolver,
|
|
52
|
+
mode,
|
|
53
|
+
reValidateMode,
|
|
54
|
+
});
|
|
55
|
+
const methods = externalMethods !== null && externalMethods !== void 0 ? externalMethods : internalMethods;
|
|
56
|
+
const controller = React.useMemo(() => ({
|
|
57
|
+
submit: async () => {
|
|
58
|
+
await methods.handleSubmit(onSubmit, onInvalidSubmit)();
|
|
59
|
+
},
|
|
60
|
+
getValues: () => methods.getValues(),
|
|
61
|
+
setValue: methods.setValue,
|
|
62
|
+
trigger: methods.trigger,
|
|
63
|
+
reset: methods.reset,
|
|
64
|
+
}), [methods, onSubmit, onInvalidSubmit]);
|
|
65
|
+
React.useImperativeHandle(ref, () => controller, [controller]);
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if (!controllerRef)
|
|
68
|
+
return;
|
|
69
|
+
controllerRef.current = controller;
|
|
70
|
+
return () => {
|
|
71
|
+
controllerRef.current = null;
|
|
72
|
+
};
|
|
73
|
+
}, [controllerRef, controller]);
|
|
74
|
+
return (_jsx(FormProvider, Object.assign({}, methods, { children: _jsx("form", Object.assign({}, formProps, { noValidate: noValidate, onSubmit: methods.handleSubmit(onSubmit, onInvalidSubmit), children: typeof children === "function" ? children(methods) : children })) })));
|
|
75
|
+
};
|
|
76
|
+
export const Form = React.forwardRef(FormInner);
|
|
45
77
|
export default Form;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo, useState } from "react";
|
|
3
|
+
import * as yup from "yup";
|
|
4
|
+
import Button from "@/components/Button/Button";
|
|
5
|
+
import TextInput from "@/components/TextInput/TextInput";
|
|
6
|
+
import Dropdown from "@/components/Dropdown/Dropdown";
|
|
7
|
+
import DatePicker from "@/components/DatePicker/DatePicker";
|
|
8
|
+
import { NumberInput } from "@/components/NumberInput/NumberInput";
|
|
9
|
+
import { Switch } from "@/components/Switch/Switch";
|
|
10
|
+
import { Field } from "./Field";
|
|
11
|
+
import { Form, useControlledForm, } from "./Form";
|
|
12
|
+
const roleOptions = [
|
|
13
|
+
{ value: "dev", label: "Developer" },
|
|
14
|
+
{ value: "pm", label: "Product Manager" },
|
|
15
|
+
{ value: "qa", label: "QA Engineer" },
|
|
16
|
+
];
|
|
17
|
+
const meta = {
|
|
18
|
+
title: "Components/Form",
|
|
19
|
+
tags: ["autodocs"],
|
|
20
|
+
parameters: {
|
|
21
|
+
layout: "centered",
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
(Story) => (_jsx("div", { className: "w-[520px] max-w-full p-5 bg-bg-bg2 rounded-md", children: _jsx(Story, {}) })),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
const loginSchema = yup.object({
|
|
29
|
+
email: yup
|
|
30
|
+
.string()
|
|
31
|
+
.email("Invalid email format")
|
|
32
|
+
.required("Email is required"),
|
|
33
|
+
password: yup
|
|
34
|
+
.string()
|
|
35
|
+
.required("Password is required")
|
|
36
|
+
.min(6, "Password must be at least 6 characters"),
|
|
37
|
+
});
|
|
38
|
+
export const BasicYupLogin = {
|
|
39
|
+
args: {},
|
|
40
|
+
render: () => {
|
|
41
|
+
const [lastEmailChange, setLastEmailChange] = useState("");
|
|
42
|
+
return (_jsxs(Form, { className: "flex flex-col gap-3", defaultValues: {
|
|
43
|
+
email: "",
|
|
44
|
+
password: "",
|
|
45
|
+
}, validationSchema: loginSchema, onSubmit: (values) => {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.log("Submitted form values:", values);
|
|
48
|
+
}, children: [_jsx(Field, { name: "email", component: TextInput, componentProps: {
|
|
49
|
+
label: "Email",
|
|
50
|
+
type: "email",
|
|
51
|
+
helperText: "Use your work email",
|
|
52
|
+
required: true,
|
|
53
|
+
}, onChange: (value) => {
|
|
54
|
+
setLastEmailChange(String(value !== null && value !== void 0 ? value : ""));
|
|
55
|
+
} }), _jsx(Field, { name: "password", component: TextInput, componentProps: {
|
|
56
|
+
label: "Password",
|
|
57
|
+
type: "password",
|
|
58
|
+
required: true,
|
|
59
|
+
} }), _jsxs("div", { className: "text-xs text-text-g-contrast-medium", children: ["Last email change: ", lastEmailChange || "-"] }), _jsx(Button, { type: "submit", children: "Sign in" })] }));
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const MixedUiKitControls = {
|
|
63
|
+
args: {},
|
|
64
|
+
render: () => {
|
|
65
|
+
const selectedRole = useMemo(() => roleOptions.find((item) => item.value === "dev"), []);
|
|
66
|
+
return (_jsxs(Form, { className: "flex flex-col gap-4", defaultValues: {
|
|
67
|
+
fullName: "",
|
|
68
|
+
role: (selectedRole === null || selectedRole === void 0 ? void 0 : selectedRole.value) || "",
|
|
69
|
+
salary: undefined,
|
|
70
|
+
startDate: undefined,
|
|
71
|
+
isActive: true,
|
|
72
|
+
}, validationSchema: yup.object({
|
|
73
|
+
fullName: yup.string().required("Full name is required"),
|
|
74
|
+
role: yup.string().required("Please select a role"),
|
|
75
|
+
}), onSubmit: (values) => {
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
console.log("Submitted employee values:", values);
|
|
78
|
+
}, children: [_jsx(Field, { name: "fullName", component: TextInput, componentProps: {
|
|
79
|
+
label: "Full name",
|
|
80
|
+
required: true,
|
|
81
|
+
} }), _jsx(Field, { name: "role", component: Dropdown, componentProps: {
|
|
82
|
+
label: "Role",
|
|
83
|
+
options: roleOptions,
|
|
84
|
+
required: true,
|
|
85
|
+
helperText: "Choose one role",
|
|
86
|
+
}, valuePropName: "value", changePropName: "onSelect", parseValue: (incoming) => {
|
|
87
|
+
const option = incoming;
|
|
88
|
+
return (option === null || option === void 0 ? void 0 : option.value) || "";
|
|
89
|
+
}, formatValue: (value) => roleOptions.find((option) => option.value === value) }), _jsx(Field, { name: "salary", component: NumberInput, componentProps: {
|
|
90
|
+
label: "Salary",
|
|
91
|
+
min: 0,
|
|
92
|
+
thousandSeparator: ",",
|
|
93
|
+
formatDisplay: true,
|
|
94
|
+
}, parseValue: (incoming) => typeof incoming === "number" ? incoming : undefined }), _jsx(Field, { name: "startDate", component: DatePicker, componentProps: {
|
|
95
|
+
date: undefined,
|
|
96
|
+
onSelect: () => undefined,
|
|
97
|
+
textInputProps: { label: "Start date", required: false },
|
|
98
|
+
}, valuePropName: "date", changePropName: "onSelect", blurPropName: false, refPropName: false, errorMessagePropName: false, invalidPropName: false, parseValue: (incoming) => incoming }), _jsxs("div", { className: "flex items-center justify-between rounded-md border border-bg-stroke1 px-3 py-2", children: [_jsx("span", { className: "text-sm text-text-contrast-max", children: "Active employee" }), _jsx(Field, { name: "isActive", component: Switch, valuePropName: "checked", changePropName: "onCheckedChange", blurPropName: false, errorMessagePropName: false, invalidPropName: false, parseValue: (incoming) => Boolean(incoming) })] }), _jsx(Button, { type: "submit", children: "Create employee" })] }));
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
export const ResolverBasedValidation = {
|
|
102
|
+
args: {},
|
|
103
|
+
render: () => {
|
|
104
|
+
const resolver = async (values) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const errors = {};
|
|
107
|
+
if (!((_a = values.email) === null || _a === void 0 ? void 0 : _a.includes("@"))) {
|
|
108
|
+
errors.email = { type: "validate", message: "Email must include @" };
|
|
109
|
+
}
|
|
110
|
+
if (!values.password || values.password.length < 8) {
|
|
111
|
+
errors.password = {
|
|
112
|
+
type: "validate",
|
|
113
|
+
message: "Password must be at least 8 characters",
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
values: Object.keys(errors).length ? {} : values,
|
|
118
|
+
errors,
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
return (_jsxs(Form, { className: "flex flex-col gap-3", defaultValues: {
|
|
122
|
+
email: "",
|
|
123
|
+
password: "",
|
|
124
|
+
}, resolver: resolver, onSubmit: (values) => {
|
|
125
|
+
// eslint-disable-next-line no-console
|
|
126
|
+
console.log("Resolver submit values:", values);
|
|
127
|
+
}, children: [_jsx(Field, { name: "email", component: TextInput, componentProps: {
|
|
128
|
+
label: "Email",
|
|
129
|
+
type: "email",
|
|
130
|
+
required: true,
|
|
131
|
+
} }), _jsx(Field, { name: "password", component: TextInput, componentProps: {
|
|
132
|
+
label: "Password",
|
|
133
|
+
type: "password",
|
|
134
|
+
helperText: "This story demonstrates custom resolver.",
|
|
135
|
+
required: true,
|
|
136
|
+
} }), _jsx(Button, { type: "submit", children: "Validate" })] }));
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
export const RenderPropsCodeControl = {
|
|
140
|
+
args: {},
|
|
141
|
+
render: () => {
|
|
142
|
+
const codeControlSchema = yup.object({
|
|
143
|
+
title: yup.string().required("Title is required"),
|
|
144
|
+
description: yup
|
|
145
|
+
.string()
|
|
146
|
+
.required("Description is required")
|
|
147
|
+
.min(10, "Description must be at least 10 characters"),
|
|
148
|
+
});
|
|
149
|
+
return (_jsx(Form, { className: "flex flex-col gap-3", defaultValues: {
|
|
150
|
+
title: "",
|
|
151
|
+
description: "",
|
|
152
|
+
}, mode: "onChange", validationSchema: codeControlSchema, onSubmit: (values) => {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
console.log("Submit with code:", values);
|
|
155
|
+
}, children: ({ formState, getValues, handleSubmit }) => (_jsxs(_Fragment, { children: [_jsx(Field, { name: "title", component: TextInput, componentProps: {
|
|
156
|
+
label: "Title",
|
|
157
|
+
required: true,
|
|
158
|
+
} }), _jsx(Field, { name: "description", component: TextInput, componentProps: {
|
|
159
|
+
label: "Description",
|
|
160
|
+
helperText: "Try at least 10 characters",
|
|
161
|
+
required: true,
|
|
162
|
+
} }), _jsx("div", { className: "flex gap-2", children: _jsx(Button, { type: "submit", disabled: !formState.isValid || formState.isSubmitting, isLoading: formState.isSubmitting, children: "Submit with code" }) })] })) }));
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
export const HigherLayerCodeControl = {
|
|
166
|
+
args: {},
|
|
167
|
+
render: () => {
|
|
168
|
+
const [stateSnapshot, setStateSnapshot] = useState("-");
|
|
169
|
+
const [submitCount, setSubmitCount] = useState(0);
|
|
170
|
+
const formRef = React.useRef(null);
|
|
171
|
+
const schema = yup.object({
|
|
172
|
+
title: yup.string().required("Title is required"),
|
|
173
|
+
description: yup
|
|
174
|
+
.string()
|
|
175
|
+
.required("Description is required")
|
|
176
|
+
.min(10, "Description must be at least 10 characters"),
|
|
177
|
+
});
|
|
178
|
+
const { methods, FormRoot } = useControlledForm({
|
|
179
|
+
defaultValues: {
|
|
180
|
+
title: "",
|
|
181
|
+
description: "",
|
|
182
|
+
},
|
|
183
|
+
validationSchema: schema,
|
|
184
|
+
mode: "onChange",
|
|
185
|
+
});
|
|
186
|
+
const onSubmit = (values) => {
|
|
187
|
+
setSubmitCount((prev) => prev + 1);
|
|
188
|
+
// eslint-disable-next-line no-console
|
|
189
|
+
console.log("Higher layer submit with code:", values);
|
|
190
|
+
};
|
|
191
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "rounded-md border border-bg-stroke1 bg-bg-bg2 p-3 text-xs text-text-g-contrast-medium", children: ["Higher layer state: ", methods.formState.isValid ? "valid" : "invalid", " ", "/", methods.formState.isDirty ? " dirty" : " pristine", " / submits:", " ", submitCount] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
192
|
+
const snapshot = JSON.stringify({
|
|
193
|
+
values: methods.getValues(),
|
|
194
|
+
isValid: methods.formState.isValid,
|
|
195
|
+
isDirty: methods.formState.isDirty,
|
|
196
|
+
});
|
|
197
|
+
setStateSnapshot(snapshot);
|
|
198
|
+
}, children: "Get state with code (outside Form)" }), _jsx(Button, { type: "button", disabled: !methods.formState.isValid || methods.formState.isSubmitting, isLoading: methods.formState.isSubmitting, onClick: () => {
|
|
199
|
+
methods.handleSubmit(onSubmit)();
|
|
200
|
+
}, children: "Submit with code (outside Form)" }), _jsx(Button, { type: "button", variant: "outline", onClick: async () => {
|
|
201
|
+
var _a;
|
|
202
|
+
await ((_a = formRef.current) === null || _a === void 0 ? void 0 : _a.submit());
|
|
203
|
+
}, children: "Submit with ref" }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
204
|
+
var _a;
|
|
205
|
+
const valuesFromRef = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getValues();
|
|
206
|
+
if (!valuesFromRef)
|
|
207
|
+
return;
|
|
208
|
+
setStateSnapshot(JSON.stringify({
|
|
209
|
+
values: valuesFromRef,
|
|
210
|
+
via: "controllerRef",
|
|
211
|
+
}));
|
|
212
|
+
}, children: "Get state with ref" })] }), _jsxs("div", { className: "rounded-md border border-bg-stroke1 bg-bg-bg2 p-3 text-xs text-text-g-contrast-medium", children: ["Snapshot: ", stateSnapshot] }), _jsxs(FormRoot, { ref: formRef, className: "flex flex-col gap-3", onSubmit: onSubmit, children: [_jsx(Field, { name: "title", component: TextInput, componentProps: {
|
|
213
|
+
label: "Title",
|
|
214
|
+
required: true,
|
|
215
|
+
} }), _jsx(Field, { name: "description", component: TextInput, componentProps: {
|
|
216
|
+
label: "Description",
|
|
217
|
+
helperText: "Try at least 10 characters",
|
|
218
|
+
required: true,
|
|
219
|
+
} })] })] }));
|
|
220
|
+
},
|
|
221
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircleIcon } from "@heroicons/react/24/outline";
|
|
3
|
+
import { cn } from "@/utils/cn";
|
|
4
|
+
const resolveHintState = (values, rule) => {
|
|
5
|
+
const shouldEvaluate = rule.when ? rule.when(values) : true;
|
|
6
|
+
if (!shouldEvaluate)
|
|
7
|
+
return "pending";
|
|
8
|
+
return rule.validate(values) ? "valid" : "invalid";
|
|
9
|
+
};
|
|
10
|
+
const hintTextStateClass = {
|
|
11
|
+
valid: "text-success",
|
|
12
|
+
invalid: "text-input-error",
|
|
13
|
+
pending: "text-text-g-contrast-medium",
|
|
14
|
+
};
|
|
15
|
+
const hintIconStateClass = {
|
|
16
|
+
valid: "opacity-100",
|
|
17
|
+
invalid: "opacity-100",
|
|
18
|
+
pending: "opacity-40",
|
|
19
|
+
};
|
|
20
|
+
export const ValidationHintList = ({ values, rules, mode = ["pending", "valid", "invalid"], className, itemClassName, }) => {
|
|
21
|
+
const enabledStates = new Set(mode);
|
|
22
|
+
return (_jsx("ul", { className: cn("mt-2 flex flex-col gap-3", className), children: rules.map((rule) => {
|
|
23
|
+
const state = resolveHintState(values, rule);
|
|
24
|
+
const normalizedState = enabledStates.has(state)
|
|
25
|
+
? state
|
|
26
|
+
: "pending";
|
|
27
|
+
return (_jsxs("li", { className: cn("flex items-center gap-2 typography-small2", hintTextStateClass[normalizedState], itemClassName), children: [_jsx(CheckCircleIcon, { className: cn("size-4", hintIconStateClass[normalizedState]) }), _jsx("span", { children: rule.label })] }, rule.id));
|
|
28
|
+
}) }));
|
|
29
|
+
};
|
|
30
|
+
export default ValidationHintList;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import PasswordInput from "@/components/PasswordInput";
|
|
4
|
+
import { ValidationHintList } from "./ValidationHintList";
|
|
5
|
+
const rules = [
|
|
6
|
+
{
|
|
7
|
+
id: "min-length",
|
|
8
|
+
label: "Minimum 12 characters",
|
|
9
|
+
validate: (values) => values.password.length >= 12,
|
|
10
|
+
when: (values) => Boolean(values.password),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "upper-lower",
|
|
14
|
+
label: "At least one upper and lower case",
|
|
15
|
+
validate: (values) => /[a-z]/.test(values.password) && /[A-Z]/.test(values.password),
|
|
16
|
+
when: (values) => Boolean(values.password),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "match",
|
|
20
|
+
label: "Password and confirmation are matching",
|
|
21
|
+
validate: (values) => Boolean(values.password) && values.password === values.confirmPassword,
|
|
22
|
+
when: (values) => Boolean(values.password) && Boolean(values.confirmPassword),
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
const meta = {
|
|
26
|
+
title: "Components/Form/ValidationHintList",
|
|
27
|
+
tags: ["autodocs"],
|
|
28
|
+
parameters: {
|
|
29
|
+
layout: "centered",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export default meta;
|
|
33
|
+
export const ThreeState = {
|
|
34
|
+
render: () => {
|
|
35
|
+
const [values, setValues] = useState({
|
|
36
|
+
password: "",
|
|
37
|
+
confirmPassword: "",
|
|
38
|
+
});
|
|
39
|
+
return (_jsxs("div", { className: "w-[420px] max-w-full rounded-md bg-bg-bg2 p-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(PasswordInput, { label: "Password", value: values.password, onChange: (event) => setValues((prev) => (Object.assign(Object.assign({}, prev), { password: event.target.value }))) }), _jsx(PasswordInput, { label: "Confirm password", value: values.confirmPassword, onChange: (event) => setValues((prev) => (Object.assign(Object.assign({}, prev), { confirmPassword: event.target.value }))) })] }), _jsx(ValidationHintList, { values: values, rules: rules })] }));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const TwoState = {
|
|
43
|
+
render: () => {
|
|
44
|
+
const [values, setValues] = useState({
|
|
45
|
+
password: "",
|
|
46
|
+
confirmPassword: "",
|
|
47
|
+
});
|
|
48
|
+
return (_jsxs("div", { className: "w-[420px] max-w-full rounded-md bg-bg-bg2 p-4", children: [_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(PasswordInput, { label: "Password", value: values.password, onChange: (event) => setValues((prev) => (Object.assign(Object.assign({}, prev), { password: event.target.value }))) }), _jsx(PasswordInput, { label: "Confirm password", value: values.confirmPassword, onChange: (event) => setValues((prev) => (Object.assign(Object.assign({}, prev), { confirmPassword: event.target.value }))) })] }), _jsx(ValidationHintList, { values: values, rules: rules, mode: ["pending", "valid"] })] }));
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Form, createControlledForm, createYupResolver, useControlledForm, } from "./Form";
|
|
2
|
+
export { Field } from "./Field";
|
|
3
|
+
export { FieldMessage } from "./FieldMessage";
|
|
4
|
+
export { ValidationHintList } from "./ValidationHintList";
|
|
5
|
+
export { useOptionBridge } from "./useOptionBridge";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
export const useOptionBridge = ({ options, loading = false, buildFallbackOption, }) => {
|
|
3
|
+
const optionsByValue = useMemo(() => {
|
|
4
|
+
return new Map(options.map((option) => [option.value, option]));
|
|
5
|
+
}, [options]);
|
|
6
|
+
const toOption = (value) => {
|
|
7
|
+
if (value === null || value === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
return optionsByValue.get(value);
|
|
10
|
+
};
|
|
11
|
+
const toValue = (option) => {
|
|
12
|
+
return option === null || option === void 0 ? void 0 : option.value;
|
|
13
|
+
};
|
|
14
|
+
const toOptionWithFallback = (value) => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (value === null || value === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
return (_a = toOption(value)) !== null && _a !== void 0 ? _a : buildFallbackOption === null || buildFallbackOption === void 0 ? void 0 : buildFallbackOption(value, loading);
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
toOption,
|
|
22
|
+
toOptionWithFallback,
|
|
23
|
+
toValue,
|
|
24
|
+
optionsByValue,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default useOptionBridge;
|
|
@@ -77,7 +77,7 @@ const InputFilter = forwardRef((_a, ref) => {
|
|
|
77
77
|
onClick: handleOptionClick,
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
return (_jsxs("ul", { className: cn("absolute mt-1 w-full bg-
|
|
80
|
+
return (_jsxs("ul", { className: cn("absolute text-text-g-contrast-high mt-1 w-full bg-modal-surface border border-modal-surface text-text-contrast-low rounded-md shadow-md z-10 max-h-60 overflow-y-auto", optionContainerClassName), children: [optionsFiltered.map((option) => {
|
|
81
81
|
if (option.renderLabel) {
|
|
82
82
|
return (_jsx(Fragment, { children: option.renderLabel({
|
|
83
83
|
value: option.value,
|
|
@@ -88,8 +88,8 @@ const InputFilter = forwardRef((_a, ref) => {
|
|
|
88
88
|
: ""}`,
|
|
89
89
|
}) }, option.value));
|
|
90
90
|
}
|
|
91
|
-
return (_jsxs("li", { onMouseDown: () => handleOptionClick(option), className: `p-4 typography-subtitle4 hover:bg-primary-hover-bg cursor-pointer flex items-center gap-3 ${selectedOptions.some((selected) => selected.value === option.value)
|
|
92
|
-
? "bg-
|
|
91
|
+
return (_jsxs("li", { onMouseDown: () => handleOptionClick(option), className: `p-4 text-text-g-contrast-high typography-subtitle4 hover:bg-primary-hover-bg cursor-pointer flex items-center gap-3 ${selectedOptions.some((selected) => selected.value === option.value)
|
|
92
|
+
? "bg-modal-highlight"
|
|
93
93
|
: ""}`, children: [_jsx(Checkbox, { checked: selectedOptions.some((selected) => selected.value === option.value) }), option.label] }, option.value));
|
|
94
94
|
}), optionsFiltered.length === 0 && (_jsx("li", { className: "px-4 py-14 text-center text-input-text", children: "Not found" }))] }));
|
|
95
95
|
};
|
|
@@ -119,6 +119,7 @@ const InputFilter = forwardRef((_a, ref) => {
|
|
|
119
119
|
active: !!values.length,
|
|
120
120
|
disabled,
|
|
121
121
|
});
|
|
122
|
-
|
|
122
|
+
const filterIconSizeClassName = size === "lg" ? "size-8" : size === "md" ? "size-[22px]" : "size-[18px]";
|
|
123
|
+
return (_jsxs("div", { ref: containerRef, className: `relative ${fullwidth ? "w-full" : ""}`, children: [_jsx(TextInput, Object.assign({ hasClearIcon: false, endIcon: _jsx(Icon, { type: "heroicons", name: "adjustments-horizontal", variant: "outline", color: "inherit", stroke: "inherit", fill: "transparent", className: filterIconSizeClassName }), classes: { endIconWrapper: filterIconClassName } }, props, { ref: ref, readOnly: !filterMode, value: textValue, onChange: handleOnChangeText, label: label, placeholder: " ", type: "text", rounded: rounded, variant: variant, helperText: helperText, errorMessage: errorMessage, fullwidth: fullwidth, error: error, required: required, id: _id, disabled: disabled, size: size, className: customInputVariant({ size }), onFocus: handleOnFocus, onKeyDown: handleOnKeyDown })), isFocused && renderOptions()] }));
|
|
123
124
|
});
|
|
124
125
|
export { InputFilter };
|
|
@@ -9,7 +9,7 @@ const meta = {
|
|
|
9
9
|
layout: "fullscreen",
|
|
10
10
|
},
|
|
11
11
|
decorators: [
|
|
12
|
-
(Story) => (_jsx("div", { className: "p-5 flex w-full bg-
|
|
12
|
+
(Story) => (_jsx("div", { className: "p-5 flex w-full bg-bg-bg2", children: _jsx(Story, {}) })),
|
|
13
13
|
],
|
|
14
14
|
};
|
|
15
15
|
export default meta;
|
|
@@ -23,7 +23,7 @@ export const filterIconVariant = cva([
|
|
|
23
23
|
},
|
|
24
24
|
rounded: {
|
|
25
25
|
none: "rounded-r-none",
|
|
26
|
-
normal: "
|
|
26
|
+
normal: "",
|
|
27
27
|
full: "rounded-r-full",
|
|
28
28
|
},
|
|
29
29
|
error: {
|
|
@@ -48,12 +48,25 @@ export const filterIconVariant = cva([
|
|
|
48
48
|
},
|
|
49
49
|
disabled: {
|
|
50
50
|
true: [
|
|
51
|
+
"cursor-default pointer-events-none",
|
|
51
52
|
"border-l-input-disable-stroke",
|
|
52
53
|
"fill-input-disable-stroke",
|
|
53
54
|
"stroke-input-disable-stroke",
|
|
54
55
|
],
|
|
55
56
|
},
|
|
56
57
|
},
|
|
58
|
+
compoundVariants: [
|
|
59
|
+
{
|
|
60
|
+
rounded: "normal",
|
|
61
|
+
size: "sm",
|
|
62
|
+
className: "rounded-r-sm",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
rounded: "normal",
|
|
66
|
+
size: ["md", "lg"],
|
|
67
|
+
className: "rounded-r-md",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
57
70
|
defaultVariants: {
|
|
58
71
|
size: "md",
|
|
59
72
|
rounded: "normal",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
export const labelVariant = cva([
|
|
3
|
-
"block cursor-pointer duration-450 transition-all px-[2px] text-
|
|
3
|
+
"block cursor-pointer duration-450 transition-all px-[2px] text-input-default-text peer-focus:text-input-text-active",
|
|
4
4
|
], {
|
|
5
5
|
variants: {
|
|
6
6
|
size: {
|
|
@@ -4,7 +4,7 @@ import { cn } from "@/utils/cn";
|
|
|
4
4
|
import Icon from "../Icon/Icon";
|
|
5
5
|
// ==================== Menu Container ====================
|
|
6
6
|
export const Menu = forwardRef(({ items, selectedValues = [], onSelect, className, style, isAbove = false }, ref) => {
|
|
7
|
-
return (_jsx("div", { ref: ref, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-
|
|
7
|
+
return (_jsx("div", { ref: ref, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-modal-surface text-text-g-contrast-high", "border border-modal-surface", className), style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, style), children: items.map((item, index) => {
|
|
8
8
|
var _a;
|
|
9
9
|
if (item.type === "separator") {
|
|
10
10
|
return _jsx(MenuSeparator, {}, `separator-${index}`);
|
|
@@ -57,7 +57,7 @@ export const MenuSeparator = forwardRef(({ className }, ref) => {
|
|
|
57
57
|
});
|
|
58
58
|
MenuSeparator.displayName = "MenuSeparator";
|
|
59
59
|
export const MenuLabel = forwardRef(({ children, className }, ref) => {
|
|
60
|
-
return (_jsx("div", { ref: ref, className: cn("px-3 py-2 typography-small4 text-text-
|
|
60
|
+
return (_jsx("div", { ref: ref, className: cn("px-3 py-2 typography-small4 text-text-g-contrast-medium", className), children: children }));
|
|
61
61
|
});
|
|
62
62
|
MenuLabel.displayName = "MenuLabel";
|
|
63
63
|
// ==================== Exports ====================
|
|
@@ -8,7 +8,7 @@ const meta = {
|
|
|
8
8
|
},
|
|
9
9
|
tags: ["autodocs"],
|
|
10
10
|
decorators: [
|
|
11
|
-
(Story) => (_jsx("div", { className: "p-5 flex h-screen w-full bg-
|
|
11
|
+
(Story) => (_jsx("div", { className: "p-5 flex h-screen w-full bg-bg-bg2", children: _jsx(Story, {}) })),
|
|
12
12
|
],
|
|
13
13
|
argTypes: {
|
|
14
14
|
size: {
|