sellmate-design-system-react 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/SActionModal/SActionModal.cjs +129 -1
- package/dist/components/SActionModal/SActionModal.cjs.map +1 -1
- package/dist/components/SActionModal/SActionModal.js +129 -1
- package/dist/components/SActionModal/SActionModal.js.map +1 -1
- package/dist/components/SBarcodeInput/SBarcodeInput.cjs +157 -4
- package/dist/components/SBarcodeInput/SBarcodeInput.cjs.map +1 -1
- package/dist/components/SBarcodeInput/SBarcodeInput.js +158 -5
- package/dist/components/SBarcodeInput/SBarcodeInput.js.map +1 -1
- package/dist/components/SButton/SButton.cjs +129 -1
- package/dist/components/SButton/SButton.cjs.map +1 -1
- package/dist/components/SButton/SButton.js +129 -1
- package/dist/components/SButton/SButton.js.map +1 -1
- package/dist/components/SCalendar/SCalendar.cjs +131 -3
- package/dist/components/SCalendar/SCalendar.cjs.map +1 -1
- package/dist/components/SCalendar/SCalendar.d.ts +3 -1
- package/dist/components/SCalendar/SCalendar.js +131 -3
- package/dist/components/SCalendar/SCalendar.js.map +1 -1
- package/dist/components/SCallout/SCallout.cjs +129 -1
- package/dist/components/SCallout/SCallout.cjs.map +1 -1
- package/dist/components/SCallout/SCallout.js +129 -1
- package/dist/components/SCallout/SCallout.js.map +1 -1
- package/dist/components/SCheckbox/SCheckbox.cjs +130 -2
- package/dist/components/SCheckbox/SCheckbox.cjs.map +1 -1
- package/dist/components/SCheckbox/SCheckbox.js +130 -2
- package/dist/components/SCheckbox/SCheckbox.js.map +1 -1
- package/dist/components/SChip/SChip.cjs +130 -3
- package/dist/components/SChip/SChip.cjs.map +1 -1
- package/dist/components/SChip/SChip.js +130 -3
- package/dist/components/SChip/SChip.js.map +1 -1
- package/dist/components/SChipInput/SChipInput.cjs +154 -4
- package/dist/components/SChipInput/SChipInput.cjs.map +1 -1
- package/dist/components/SChipInput/SChipInput.js +154 -4
- package/dist/components/SChipInput/SChipInput.js.map +1 -1
- package/dist/components/SConfirmModal/SConfirmModal.cjs +129 -1
- package/dist/components/SConfirmModal/SConfirmModal.cjs.map +1 -1
- package/dist/components/SConfirmModal/SConfirmModal.js +129 -1
- package/dist/components/SConfirmModal/SConfirmModal.js.map +1 -1
- package/dist/components/SDatePicker/SDatePicker.cjs +159 -6
- package/dist/components/SDatePicker/SDatePicker.cjs.map +1 -1
- package/dist/components/SDatePicker/SDatePicker.js +159 -6
- package/dist/components/SDatePicker/SDatePicker.js.map +1 -1
- package/dist/components/SDateRangePicker/SDateRangePicker.cjs +157 -4
- package/dist/components/SDateRangePicker/SDateRangePicker.cjs.map +1 -1
- package/dist/components/SDateRangePicker/SDateRangePicker.js +157 -4
- package/dist/components/SDateRangePicker/SDateRangePicker.js.map +1 -1
- package/dist/components/SDropdownButton/SDropdownButton.cjs +129 -1
- package/dist/components/SDropdownButton/SDropdownButton.cjs.map +1 -1
- package/dist/components/SDropdownButton/SDropdownButton.js +129 -1
- package/dist/components/SDropdownButton/SDropdownButton.js.map +1 -1
- package/dist/components/SField/SField.cjs +130 -2
- package/dist/components/SField/SField.cjs.map +1 -1
- package/dist/components/SField/SField.js +130 -2
- package/dist/components/SField/SField.js.map +1 -1
- package/dist/components/SFilePicker/SFilePicker.cjs +157 -4
- package/dist/components/SFilePicker/SFilePicker.cjs.map +1 -1
- package/dist/components/SFilePicker/SFilePicker.js +157 -4
- package/dist/components/SFilePicker/SFilePicker.js.map +1 -1
- package/dist/components/SForm/SForm.cjs +91 -0
- package/dist/components/SForm/SForm.cjs.map +1 -0
- package/dist/components/SForm/SForm.d.ts +33 -0
- package/dist/components/SForm/SForm.js +89 -0
- package/dist/components/SForm/SForm.js.map +1 -0
- package/dist/components/SForm/index.d.ts +1 -0
- package/dist/components/SGhostButton/SGhostButton.cjs +129 -1
- package/dist/components/SGhostButton/SGhostButton.cjs.map +1 -1
- package/dist/components/SGhostButton/SGhostButton.js +129 -1
- package/dist/components/SGhostButton/SGhostButton.js.map +1 -1
- package/dist/components/SGuide/SGuide.cjs +129 -1
- package/dist/components/SGuide/SGuide.cjs.map +1 -1
- package/dist/components/SGuide/SGuide.js +129 -1
- package/dist/components/SGuide/SGuide.js.map +1 -1
- package/dist/components/SIcon/SIcon.cjs +129 -1
- package/dist/components/SIcon/SIcon.cjs.map +1 -1
- package/dist/components/SIcon/SIcon.d.ts +3 -2
- package/dist/components/SIcon/SIcon.js +129 -1
- package/dist/components/SIcon/SIcon.js.map +1 -1
- package/dist/components/SInput/SInput.cjs +157 -4
- package/dist/components/SInput/SInput.cjs.map +1 -1
- package/dist/components/SInput/SInput.js +158 -5
- package/dist/components/SInput/SInput.js.map +1 -1
- package/dist/components/SKeyValueTable/SKeyValueTable.cjs +214 -7
- package/dist/components/SKeyValueTable/SKeyValueTable.cjs.map +1 -1
- package/dist/components/SKeyValueTable/SKeyValueTable.js +214 -7
- package/dist/components/SKeyValueTable/SKeyValueTable.js.map +1 -1
- package/dist/components/SLoadingModal/SLoadingModal.cjs +129 -1
- package/dist/components/SLoadingModal/SLoadingModal.cjs.map +1 -1
- package/dist/components/SLoadingModal/SLoadingModal.js +129 -1
- package/dist/components/SLoadingModal/SLoadingModal.js.map +1 -1
- package/dist/components/SModalContainer/SModalContainer.cjs +129 -1
- package/dist/components/SModalContainer/SModalContainer.cjs.map +1 -1
- package/dist/components/SModalContainer/SModalContainer.js +129 -1
- package/dist/components/SModalContainer/SModalContainer.js.map +1 -1
- package/dist/components/SNumberInput/SNumberInput.cjs +157 -4
- package/dist/components/SNumberInput/SNumberInput.cjs.map +1 -1
- package/dist/components/SNumberInput/SNumberInput.js +157 -4
- package/dist/components/SNumberInput/SNumberInput.js.map +1 -1
- package/dist/components/SPagination/SPagination.cjs +129 -1
- package/dist/components/SPagination/SPagination.cjs.map +1 -1
- package/dist/components/SPagination/SPagination.js +129 -1
- package/dist/components/SPagination/SPagination.js.map +1 -1
- package/dist/components/SPopover/SPopover.cjs +129 -1
- package/dist/components/SPopover/SPopover.cjs.map +1 -1
- package/dist/components/SPopover/SPopover.d.ts +3 -1
- package/dist/components/SPopover/SPopover.js +129 -1
- package/dist/components/SPopover/SPopover.js.map +1 -1
- package/dist/components/SPopup/SPopup.cjs +129 -1
- package/dist/components/SPopup/SPopup.cjs.map +1 -1
- package/dist/components/SPopup/SPopup.js +129 -1
- package/dist/components/SPopup/SPopup.js.map +1 -1
- package/dist/components/SSelect/SSelect.cjs +157 -4
- package/dist/components/SSelect/SSelect.cjs.map +1 -1
- package/dist/components/SSelect/SSelect.js +158 -5
- package/dist/components/SSelect/SSelect.js.map +1 -1
- package/dist/components/STable/STable.cjs +161 -6
- package/dist/components/STable/STable.cjs.map +1 -1
- package/dist/components/STable/STable.d.ts +3 -1
- package/dist/components/STable/STable.js +161 -6
- package/dist/components/STable/STable.js.map +1 -1
- package/dist/components/STabs/STabs.cjs +129 -1
- package/dist/components/STabs/STabs.cjs.map +1 -1
- package/dist/components/STabs/STabs.js +129 -1
- package/dist/components/STabs/STabs.js.map +1 -1
- package/dist/components/STag/STag.cjs +129 -1
- package/dist/components/STag/STag.cjs.map +1 -1
- package/dist/components/STag/STag.js +129 -1
- package/dist/components/STag/STag.js.map +1 -1
- package/dist/components/STextLink/STextLink.cjs +129 -1
- package/dist/components/STextLink/STextLink.cjs.map +1 -1
- package/dist/components/STextLink/STextLink.d.ts +3 -2
- package/dist/components/STextLink/STextLink.js +129 -1
- package/dist/components/STextLink/STextLink.js.map +1 -1
- package/dist/components/STextarea/STextarea.cjs +157 -4
- package/dist/components/STextarea/STextarea.cjs.map +1 -1
- package/dist/components/STextarea/STextarea.js +158 -5
- package/dist/components/STextarea/STextarea.js.map +1 -1
- package/dist/components/SToast/SToast.cjs +129 -1
- package/dist/components/SToast/SToast.cjs.map +1 -1
- package/dist/components/SToast/SToast.js +129 -1
- package/dist/components/SToast/SToast.js.map +1 -1
- package/dist/components/SToast/SToastContainer.cjs +129 -1
- package/dist/components/SToast/SToastContainer.cjs.map +1 -1
- package/dist/components/SToast/SToastContainer.js +129 -1
- package/dist/components/SToast/SToastContainer.js.map +1 -1
- package/dist/components/STooltip/STooltip.cjs +130 -2
- package/dist/components/STooltip/STooltip.cjs.map +1 -1
- package/dist/components/STooltip/STooltip.d.ts +3 -1
- package/dist/components/STooltip/STooltip.js +130 -2
- package/dist/components/STooltip/STooltip.js.map +1 -1
- package/dist/index.cjs +311 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +308 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/color.cjs +135 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.d.ts +28 -0
- package/dist/lib/color.js +131 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/form.cjs +23 -0
- package/dist/lib/form.cjs.map +1 -1
- package/dist/lib/form.d.ts +25 -0
- package/dist/lib/form.js +21 -1
- package/dist/lib/form.js.map +1 -1
- package/dist/styles.css +35 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { cn } from './lib/cn';
|
|
2
|
+
export { resolveColor, isColorKey, COLOR_KEYS, type SColor, type SColorKey } from './lib/color';
|
|
2
3
|
export * from './components/SIcon';
|
|
3
4
|
export * from './components/SBadge';
|
|
4
5
|
export * from './components/SCard';
|
|
@@ -28,6 +29,7 @@ export * from './components/SPagination';
|
|
|
28
29
|
export * from './components/STable';
|
|
29
30
|
export * from './components/SKeyValueTable';
|
|
30
31
|
export * from './components/SToast';
|
|
32
|
+
export * from './components/SForm';
|
|
31
33
|
export * from './components/SField';
|
|
32
34
|
export * from './components/SCheckbox';
|
|
33
35
|
export * from './components/SRadio';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,134 @@ import * as Ariakit from '@ariakit/react';
|
|
|
16
16
|
function cn(...inputs) {
|
|
17
17
|
return twMerge(clsx(inputs));
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
// src/lib/color.ts
|
|
21
|
+
var COLOR_KEYS = [
|
|
22
|
+
"white",
|
|
23
|
+
"black",
|
|
24
|
+
"grey_10",
|
|
25
|
+
"grey_20",
|
|
26
|
+
"grey_25",
|
|
27
|
+
"grey_30",
|
|
28
|
+
"grey_35",
|
|
29
|
+
"grey_45",
|
|
30
|
+
"grey_50",
|
|
31
|
+
"grey_55",
|
|
32
|
+
"grey_60",
|
|
33
|
+
"grey_65",
|
|
34
|
+
"grey_70",
|
|
35
|
+
"grey_80",
|
|
36
|
+
"grey_85",
|
|
37
|
+
"grey_90",
|
|
38
|
+
"grey_95",
|
|
39
|
+
"grey_05",
|
|
40
|
+
"red_15",
|
|
41
|
+
"red_20",
|
|
42
|
+
"red_30",
|
|
43
|
+
"red_45",
|
|
44
|
+
"red_60",
|
|
45
|
+
"red_70",
|
|
46
|
+
"red_75",
|
|
47
|
+
"red_80",
|
|
48
|
+
"red_85",
|
|
49
|
+
"red_90",
|
|
50
|
+
"red_95",
|
|
51
|
+
"red_99",
|
|
52
|
+
"orange_10",
|
|
53
|
+
"orange_20",
|
|
54
|
+
"orange_35",
|
|
55
|
+
"orange_45",
|
|
56
|
+
"orange_55",
|
|
57
|
+
"orange_60",
|
|
58
|
+
"orange_65",
|
|
59
|
+
"orange_75",
|
|
60
|
+
"orange_85",
|
|
61
|
+
"orange_90",
|
|
62
|
+
"orange_95",
|
|
63
|
+
"orange_99",
|
|
64
|
+
"yellow_10",
|
|
65
|
+
"yellow_20",
|
|
66
|
+
"yellow_25",
|
|
67
|
+
"yellow_30",
|
|
68
|
+
"yellow_40",
|
|
69
|
+
"yellow_45",
|
|
70
|
+
"yellow_50",
|
|
71
|
+
"yellow_60",
|
|
72
|
+
"yellow_70",
|
|
73
|
+
"yellow_80",
|
|
74
|
+
"yellow_90",
|
|
75
|
+
"yellow_95",
|
|
76
|
+
"olive_10",
|
|
77
|
+
"olive_15",
|
|
78
|
+
"olive_20",
|
|
79
|
+
"olive_30",
|
|
80
|
+
"olive_45",
|
|
81
|
+
"olive_55",
|
|
82
|
+
"olive_65",
|
|
83
|
+
"olive_70",
|
|
84
|
+
"olive_80",
|
|
85
|
+
"olive_90",
|
|
86
|
+
"olive_95",
|
|
87
|
+
"olive_05",
|
|
88
|
+
"green_15",
|
|
89
|
+
"green_25",
|
|
90
|
+
"green_45",
|
|
91
|
+
"green_55",
|
|
92
|
+
"green_65",
|
|
93
|
+
"green_70",
|
|
94
|
+
"green_75",
|
|
95
|
+
"green_80",
|
|
96
|
+
"green_85",
|
|
97
|
+
"green_90",
|
|
98
|
+
"green_95",
|
|
99
|
+
"green_99",
|
|
100
|
+
"steelblue_10",
|
|
101
|
+
"steelblue_25",
|
|
102
|
+
"steelblue_45",
|
|
103
|
+
"steelblue_60",
|
|
104
|
+
"steelblue_65",
|
|
105
|
+
"steelblue_70",
|
|
106
|
+
"steelblue_75",
|
|
107
|
+
"steelblue_80",
|
|
108
|
+
"steelblue_85",
|
|
109
|
+
"steelblue_90",
|
|
110
|
+
"steelblue_95",
|
|
111
|
+
"steelblue_99",
|
|
112
|
+
"oceanblue_15",
|
|
113
|
+
"oceanblue_25",
|
|
114
|
+
"oceanblue_50",
|
|
115
|
+
"oceanblue_60",
|
|
116
|
+
"oceanblue_65",
|
|
117
|
+
"oceanblue_70",
|
|
118
|
+
"oceanblue_75",
|
|
119
|
+
"oceanblue_80",
|
|
120
|
+
"oceanblue_85",
|
|
121
|
+
"oceanblue_90",
|
|
122
|
+
"oceanblue_95",
|
|
123
|
+
"oceanblue_99",
|
|
124
|
+
"brilliantblue_10",
|
|
125
|
+
"brilliantblue_20",
|
|
126
|
+
"brilliantblue_25",
|
|
127
|
+
"brilliantblue_40",
|
|
128
|
+
"brilliantblue_50",
|
|
129
|
+
"brilliantblue_60",
|
|
130
|
+
"brilliantblue_70",
|
|
131
|
+
"brilliantblue_75",
|
|
132
|
+
"brilliantblue_80",
|
|
133
|
+
"brilliantblue_85",
|
|
134
|
+
"brilliantblue_90",
|
|
135
|
+
"brilliantblue_95",
|
|
136
|
+
"brilliantblue_99",
|
|
137
|
+
"brilliantblue_05"
|
|
138
|
+
];
|
|
139
|
+
var KEY_SET = new Set(COLOR_KEYS);
|
|
140
|
+
function isColorKey(input) {
|
|
141
|
+
return KEY_SET.has(input);
|
|
142
|
+
}
|
|
143
|
+
function resolveColor(input, fallback) {
|
|
144
|
+
if (input === null || input === void 0 || input === "") return fallback;
|
|
145
|
+
return isColorKey(input) ? `var(--color-${input.replace(/_/g, "-")})` : input;
|
|
146
|
+
}
|
|
19
147
|
var Icon_add = (p) => {
|
|
20
148
|
const { size = 24, ...rest } = p;
|
|
21
149
|
return /* @__PURE__ */ jsx(
|
|
@@ -2715,7 +2843,7 @@ var SIcon = forwardRef(function SIcon2({ name, size = 24, color, rotate, label,
|
|
|
2715
2843
|
{
|
|
2716
2844
|
ref,
|
|
2717
2845
|
className: cn("inline-flex items-center justify-center", rotateClass, className),
|
|
2718
|
-
style: { color, ...style },
|
|
2846
|
+
style: { color: resolveColor(color), ...style },
|
|
2719
2847
|
role: label ? "img" : void 0,
|
|
2720
2848
|
"aria-label": label,
|
|
2721
2849
|
"aria-hidden": label ? void 0 : true,
|
|
@@ -3760,7 +3888,7 @@ var HIDE_DELAY_MS = 100;
|
|
|
3760
3888
|
function useBody(content, message = []) {
|
|
3761
3889
|
if (content != null) return content;
|
|
3762
3890
|
if (message.length === 0) return null;
|
|
3763
|
-
return /* @__PURE__ */ jsx(
|
|
3891
|
+
return /* @__PURE__ */ jsx(Fragment, { children: message.map((line, i) => /* @__PURE__ */ jsx("div", { children: line }, i)) });
|
|
3764
3892
|
}
|
|
3765
3893
|
var STooltip = forwardRef(function STooltip2({
|
|
3766
3894
|
content,
|
|
@@ -4724,7 +4852,7 @@ function SCheckbox({
|
|
|
4724
4852
|
onValueChange(false);
|
|
4725
4853
|
}
|
|
4726
4854
|
};
|
|
4727
|
-
const boxBg = disabled ? "var(--cmp-checkbox-bg-disabled)" :
|
|
4855
|
+
const boxBg = disabled ? "var(--cmp-checkbox-bg-disabled)" : inverse ? "transparent" : isChecked ? "var(--cmp-checkbox-checked-bg-default)" : "var(--cmp-checkbox-unchecked-bg-default)";
|
|
4728
4856
|
const boxBorder = disabled ? "var(--cmp-checkbox-border-disabled)" : inverse ? "var(--cmp-checkbox-checked-border-inverse)" : isChecked ? "var(--cmp-checkbox-checked-bg-default)" : "var(--cmp-checkbox-unchecked-border-default)";
|
|
4729
4857
|
const iconColor = disabled ? "var(--cmp-checkbox-checked-icon-disabled)" : "var(--cmp-checkbox-checked-icon-default)";
|
|
4730
4858
|
const labelColor = disabled ? "var(--cmp-checkbox-label-disabled)" : inverse ? "var(--cmp-checkbox-label-inverse)" : "var(--cmp-checkbox-label-default)";
|
|
@@ -4769,8 +4897,6 @@ function SCheckbox({
|
|
|
4769
4897
|
}
|
|
4770
4898
|
);
|
|
4771
4899
|
}
|
|
4772
|
-
|
|
4773
|
-
// src/lib/form.ts
|
|
4774
4900
|
function runRules(value, rules) {
|
|
4775
4901
|
if (!rules || rules.length === 0) return "";
|
|
4776
4902
|
for (const rule of rules) {
|
|
@@ -4779,6 +4905,24 @@ function runRules(value, rules) {
|
|
|
4779
4905
|
}
|
|
4780
4906
|
return "";
|
|
4781
4907
|
}
|
|
4908
|
+
var FormContext = createContext(null);
|
|
4909
|
+
function useFormContext() {
|
|
4910
|
+
return useContext(FormContext);
|
|
4911
|
+
}
|
|
4912
|
+
function useFormField(field) {
|
|
4913
|
+
const ctx = useFormContext();
|
|
4914
|
+
const cbRef = useRef(field);
|
|
4915
|
+
cbRef.current = field;
|
|
4916
|
+
const name = field.name ?? "";
|
|
4917
|
+
useEffect(() => {
|
|
4918
|
+
if (!ctx) return;
|
|
4919
|
+
return ctx.register({
|
|
4920
|
+
name,
|
|
4921
|
+
validate: () => cbRef.current.validate(),
|
|
4922
|
+
resetValidation: () => cbRef.current.resetValidation()
|
|
4923
|
+
});
|
|
4924
|
+
}, [ctx, name]);
|
|
4925
|
+
}
|
|
4782
4926
|
var FIELD_SIZE = {
|
|
4783
4927
|
sm: { height: 28, radius: 4, fieldGap: 12, labelGap: 6, fontSize: 12, lineHeight: 20, icon: 12 },
|
|
4784
4928
|
md: { height: 36, radius: 6, fieldGap: 16, labelGap: 8, fontSize: 14, lineHeight: 24, icon: 12 }
|
|
@@ -5071,6 +5215,15 @@ var SSelect = forwardRef(function SSelect2({
|
|
|
5071
5215
|
const arr = Array.isArray(value) ? value : [value];
|
|
5072
5216
|
return arr.map((v) => v != null && typeof v === "object" ? v.value : v).filter((v) => v != null && v !== "").map(String);
|
|
5073
5217
|
}, [value]);
|
|
5218
|
+
useFormField({
|
|
5219
|
+
name,
|
|
5220
|
+
validate: () => {
|
|
5221
|
+
const msg = runRules(multi ? selected : selected[0] ?? "", rules);
|
|
5222
|
+
setRuleError(msg);
|
|
5223
|
+
return msg === "";
|
|
5224
|
+
},
|
|
5225
|
+
resetValidation: () => setRuleError("")
|
|
5226
|
+
});
|
|
5074
5227
|
const emit2 = (next) => {
|
|
5075
5228
|
if (!onValueChange) return;
|
|
5076
5229
|
const mapped = next.map(
|
|
@@ -5745,8 +5898,10 @@ var STable = forwardRef(function STable2({
|
|
|
5745
5898
|
{
|
|
5746
5899
|
className: cn(
|
|
5747
5900
|
// 원본 .td: 컬럼 폭에 맞춰 내용 말줄임(overflow hidden + ellipsis) + 행 구분선(border-b)
|
|
5901
|
+
// 셀 배경은 흰색으로 채워 뒤 배경이 비치지 않게 하고, hover 시 행 배경(grey_05)을 따른다.
|
|
5748
5902
|
"overflow-hidden text-ellipsis whitespace-nowrap border-b border-solid border-[color:var(--cmp-table-border-color)] px-[16px] text-[12px] leading-[20px] text-[color:var(--sys-color-fg-primary)]",
|
|
5749
|
-
|
|
5903
|
+
rowBg,
|
|
5904
|
+
"group-hover:bg-[var(--color-grey-05)]",
|
|
5750
5905
|
stickyShadowClass(i),
|
|
5751
5906
|
col.tdClass
|
|
5752
5907
|
),
|
|
@@ -5845,6 +6000,15 @@ var SInput = forwardRef(function SInput2({
|
|
|
5845
6000
|
const isPassword = type === "password";
|
|
5846
6001
|
const inputType = isPassword ? visible ? "text" : "password" : type;
|
|
5847
6002
|
const hasValue = value !== void 0 && value !== null && String(value) !== "";
|
|
6003
|
+
useFormField({
|
|
6004
|
+
name: rest.name,
|
|
6005
|
+
validate: () => {
|
|
6006
|
+
const msg = runRules(value, rules);
|
|
6007
|
+
setRuleError(msg);
|
|
6008
|
+
return msg === "";
|
|
6009
|
+
},
|
|
6010
|
+
resetValidation: () => setRuleError("")
|
|
6011
|
+
});
|
|
5848
6012
|
const resolvedError = error || ruleError !== "";
|
|
5849
6013
|
const resolvedErrorMessage = ruleError !== "" ? ruleError : errorMessage;
|
|
5850
6014
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
@@ -5975,6 +6139,15 @@ var STextarea = forwardRef(function STextarea2({
|
|
|
5975
6139
|
}, ref) {
|
|
5976
6140
|
const p = PAD;
|
|
5977
6141
|
const [ruleError, setRuleError] = useState("");
|
|
6142
|
+
useFormField({
|
|
6143
|
+
name: rest.name,
|
|
6144
|
+
validate: () => {
|
|
6145
|
+
const msg = runRules(value, rules);
|
|
6146
|
+
setRuleError(msg);
|
|
6147
|
+
return msg === "";
|
|
6148
|
+
},
|
|
6149
|
+
resetValidation: () => setRuleError("")
|
|
6150
|
+
});
|
|
5978
6151
|
const resolvedError = error || ruleError !== "";
|
|
5979
6152
|
const resolvedErrorMessage = ruleError !== "" ? ruleError : errorMessage;
|
|
5980
6153
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
@@ -6108,6 +6281,15 @@ var SNumberInput = forwardRef(function SNumberInput2({
|
|
|
6108
6281
|
useEffect(() => {
|
|
6109
6282
|
setDisplay(formatWithCommas(toNumber(value)));
|
|
6110
6283
|
}, [value]);
|
|
6284
|
+
useFormField({
|
|
6285
|
+
name,
|
|
6286
|
+
validate: () => {
|
|
6287
|
+
const msg = runRules(numValue, rules);
|
|
6288
|
+
setRuleError(msg);
|
|
6289
|
+
return msg === "";
|
|
6290
|
+
},
|
|
6291
|
+
resetValidation: () => setRuleError("")
|
|
6292
|
+
});
|
|
6111
6293
|
const resolvedError = error || ruleError !== "";
|
|
6112
6294
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
6113
6295
|
const emit2 = (n) => {
|
|
@@ -6603,7 +6785,7 @@ function SCalendar({
|
|
|
6603
6785
|
"span",
|
|
6604
6786
|
{
|
|
6605
6787
|
className: "h-[var(--cmp-datepicker-calendar-day-dot-size)] w-[var(--cmp-datepicker-calendar-day-dot-size)] rounded-full",
|
|
6606
|
-
style: { backgroundColor: ev.color }
|
|
6788
|
+
style: { backgroundColor: resolveColor(ev.color) }
|
|
6607
6789
|
},
|
|
6608
6790
|
i
|
|
6609
6791
|
))
|
|
@@ -6631,7 +6813,7 @@ function SCalendar({
|
|
|
6631
6813
|
"span",
|
|
6632
6814
|
{
|
|
6633
6815
|
className: "h-[var(--cmp-datepicker-calendar-day-dot-size)] w-[var(--cmp-datepicker-calendar-day-dot-size)] rounded-full",
|
|
6634
|
-
style: { backgroundColor: item.color },
|
|
6816
|
+
style: { backgroundColor: resolveColor(item.color) },
|
|
6635
6817
|
"aria-hidden": true
|
|
6636
6818
|
}
|
|
6637
6819
|
),
|
|
@@ -6675,6 +6857,15 @@ function SDatePicker({
|
|
|
6675
6857
|
const [focused, setFocused] = useState(false);
|
|
6676
6858
|
const [ruleError, setRuleError] = useState("");
|
|
6677
6859
|
const hasValue = value != null && value !== "";
|
|
6860
|
+
useFormField({
|
|
6861
|
+
name,
|
|
6862
|
+
validate: () => {
|
|
6863
|
+
const msg = runRules(value, rules);
|
|
6864
|
+
setRuleError(msg);
|
|
6865
|
+
return msg === "";
|
|
6866
|
+
},
|
|
6867
|
+
resetValidation: () => setRuleError("")
|
|
6868
|
+
});
|
|
6678
6869
|
const resolvedError = error || ruleError !== "";
|
|
6679
6870
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
6680
6871
|
const dims = size === "md" ? { padX: 16, gap: 12, icon: 20, minW: 104, fontSize: 14, lineHeight: 24, radius: 6 } : { padX: 12, gap: 8, icon: 16, minW: 80, fontSize: 12, lineHeight: 20, radius: 4 };
|
|
@@ -6960,6 +7151,15 @@ function SDateRangePicker({
|
|
|
6960
7151
|
const [ruleError, setRuleError] = useState("");
|
|
6961
7152
|
const hasValue = value != null && value[0] !== "" && value[1] !== "";
|
|
6962
7153
|
const display = hasValue ? `${value[0]} ~ ${value[1]}` : placeholder;
|
|
7154
|
+
useFormField({
|
|
7155
|
+
name,
|
|
7156
|
+
validate: () => {
|
|
7157
|
+
const msg = runRules(value, rules);
|
|
7158
|
+
setRuleError(msg);
|
|
7159
|
+
return msg === "";
|
|
7160
|
+
},
|
|
7161
|
+
resetValidation: () => setRuleError("")
|
|
7162
|
+
});
|
|
6963
7163
|
const resolvedError = error || ruleError !== "";
|
|
6964
7164
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
6965
7165
|
const dims = size === "md" ? { padX: 16, gap: 12, icon: 20, minW: 104, fontSize: 14, lineHeight: 24, radius: 6 } : { padX: 12, gap: 8, icon: 16, minW: 80, fontSize: 12, lineHeight: 20, radius: 4 };
|
|
@@ -7224,6 +7424,15 @@ function SFilePicker({
|
|
|
7224
7424
|
const files = multiple ? Array.isArray(value) ? value : [] : value && !Array.isArray(value) ? value : null;
|
|
7225
7425
|
const hasSingle = !multiple && !!files;
|
|
7226
7426
|
const displayText = hasSingle ? files.name : placeholder;
|
|
7427
|
+
useFormField({
|
|
7428
|
+
name,
|
|
7429
|
+
validate: () => {
|
|
7430
|
+
const msg = runRules(files, rules);
|
|
7431
|
+
setRuleError(msg);
|
|
7432
|
+
return msg === "";
|
|
7433
|
+
},
|
|
7434
|
+
resetValidation: () => setRuleError("")
|
|
7435
|
+
});
|
|
7227
7436
|
const validate = (arr, existing = 0) => {
|
|
7228
7437
|
const mfs = toBytes(maxFileSize), mts = toBytes(maxTotalSize), mf = maxFiles != null ? Number(maxFiles) : void 0;
|
|
7229
7438
|
if (mf != null && existing + arr.length > mf)
|
|
@@ -7820,6 +8029,81 @@ var SToastContainer = forwardRef(
|
|
|
7820
8029
|
);
|
|
7821
8030
|
}
|
|
7822
8031
|
);
|
|
8032
|
+
var SForm = forwardRef(function SForm2({ formClass, onSubmit, onValidationError, children, className, style }, ref) {
|
|
8033
|
+
const formRef = useRef(null);
|
|
8034
|
+
const fieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
8035
|
+
const register = useCallback((entry) => {
|
|
8036
|
+
fieldsRef.current.add(entry);
|
|
8037
|
+
return () => {
|
|
8038
|
+
fieldsRef.current.delete(entry);
|
|
8039
|
+
};
|
|
8040
|
+
}, []);
|
|
8041
|
+
const ctx = useMemo(() => ({ register }), [register]);
|
|
8042
|
+
const orderByDom = useCallback((names) => {
|
|
8043
|
+
const form = formRef.current;
|
|
8044
|
+
if (!form || names.length < 2) return names;
|
|
8045
|
+
const domOrder = /* @__PURE__ */ new Map();
|
|
8046
|
+
form.querySelectorAll("[name],[data-name]").forEach((el, i) => {
|
|
8047
|
+
const n = el.getAttribute("name") || el.getAttribute("data-name");
|
|
8048
|
+
if (n && !domOrder.has(n)) domOrder.set(n, i);
|
|
8049
|
+
});
|
|
8050
|
+
return [...names].sort((a, b) => (domOrder.get(a) ?? Infinity) - (domOrder.get(b) ?? Infinity));
|
|
8051
|
+
}, []);
|
|
8052
|
+
const focusByName = useCallback((name) => {
|
|
8053
|
+
const form = formRef.current;
|
|
8054
|
+
if (!form || !name) return;
|
|
8055
|
+
const host = form.querySelector(`[name="${CSS.escape(name)}"]`) ?? form.querySelector(`[data-name="${CSS.escape(name)}"]`);
|
|
8056
|
+
if (!host) return;
|
|
8057
|
+
const focusable = host.matches("input,textarea,select,button,[tabindex]") ? host : host.querySelector("input,textarea,select,button,[tabindex]");
|
|
8058
|
+
focusable?.focus();
|
|
8059
|
+
(focusable ?? host).scrollIntoView({ block: "nearest" });
|
|
8060
|
+
}, []);
|
|
8061
|
+
const runValidation = useCallback(() => {
|
|
8062
|
+
let valid = true;
|
|
8063
|
+
const invalidNames = [];
|
|
8064
|
+
fieldsRef.current.forEach((f) => {
|
|
8065
|
+
if (!f.validate()) {
|
|
8066
|
+
valid = false;
|
|
8067
|
+
if (f.name) invalidNames.push(f.name);
|
|
8068
|
+
}
|
|
8069
|
+
});
|
|
8070
|
+
return { valid, names: orderByDom(invalidNames) };
|
|
8071
|
+
}, [orderByDom]);
|
|
8072
|
+
useImperativeHandle(
|
|
8073
|
+
ref,
|
|
8074
|
+
() => ({
|
|
8075
|
+
validate: () => runValidation().valid,
|
|
8076
|
+
resetValidation: () => fieldsRef.current.forEach((f) => f.resetValidation()),
|
|
8077
|
+
reset: () => fieldsRef.current.forEach((f) => f.resetValidation()),
|
|
8078
|
+
focusFirstInvalid: () => {
|
|
8079
|
+
const { names } = runValidation();
|
|
8080
|
+
if (names.length > 0) focusByName(names[0]);
|
|
8081
|
+
}
|
|
8082
|
+
}),
|
|
8083
|
+
[runValidation, focusByName]
|
|
8084
|
+
);
|
|
8085
|
+
const handleSubmit = (e) => {
|
|
8086
|
+
e.preventDefault();
|
|
8087
|
+
const { valid, names } = runValidation();
|
|
8088
|
+
if (!valid) {
|
|
8089
|
+
if (names.length > 0) focusByName(names[0]);
|
|
8090
|
+
onValidationError?.({ names });
|
|
8091
|
+
return;
|
|
8092
|
+
}
|
|
8093
|
+
onSubmit?.();
|
|
8094
|
+
};
|
|
8095
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
8096
|
+
"form",
|
|
8097
|
+
{
|
|
8098
|
+
ref: formRef,
|
|
8099
|
+
onSubmit: handleSubmit,
|
|
8100
|
+
className: cn(formClass, className),
|
|
8101
|
+
style,
|
|
8102
|
+
noValidate: true,
|
|
8103
|
+
children
|
|
8104
|
+
}
|
|
8105
|
+
) });
|
|
8106
|
+
});
|
|
7823
8107
|
function SRadioButton({
|
|
7824
8108
|
options = [],
|
|
7825
8109
|
value,
|
|
@@ -7935,6 +8219,12 @@ function SChipInput({
|
|
|
7935
8219
|
const resolvedErrorMessage = duplicateMessage || ruleMessage || errorMessage;
|
|
7936
8220
|
const resolvedError = error || duplicateMessage !== "" || ruleMessage !== "";
|
|
7937
8221
|
const resolvedStatus = status ?? (resolvedError ? "error" : void 0);
|
|
8222
|
+
useFormField({
|
|
8223
|
+
name,
|
|
8224
|
+
validate: () => runRules(values, rules) === "" && duplicateMessage === "",
|
|
8225
|
+
resetValidation: () => {
|
|
8226
|
+
}
|
|
8227
|
+
});
|
|
7938
8228
|
const isMax = maxCount != null && values.length >= maxCount;
|
|
7939
8229
|
const commit = (next) => onValueChange?.(next);
|
|
7940
8230
|
const addChip = (v) => {
|
|
@@ -8207,6 +8497,15 @@ var SBarcodeInput = forwardRef(
|
|
|
8207
8497
|
const f = FONT2[size];
|
|
8208
8498
|
const [ruleError, setRuleError] = useState("");
|
|
8209
8499
|
const hasValue = value !== void 0 && value !== null && String(value) !== "";
|
|
8500
|
+
useFormField({
|
|
8501
|
+
name,
|
|
8502
|
+
validate: () => {
|
|
8503
|
+
const msg = runRules(value, rules);
|
|
8504
|
+
setRuleError(msg);
|
|
8505
|
+
return msg === "";
|
|
8506
|
+
},
|
|
8507
|
+
resetValidation: () => setRuleError("")
|
|
8508
|
+
});
|
|
8210
8509
|
const resolvedError = error || ruleError !== "";
|
|
8211
8510
|
const resolvedStatus = status ?? (rules && rules.length > 0 ? ruleError !== "" ? "error" : void 0 : void 0);
|
|
8212
8511
|
return /* @__PURE__ */ jsx(
|
|
@@ -8293,6 +8592,6 @@ var SBarcodeInput = forwardRef(
|
|
|
8293
8592
|
}
|
|
8294
8593
|
);
|
|
8295
8594
|
|
|
8296
|
-
export { BADGE_COLORS, BUTTON_COLORS, BUTTON_SIZES, ICONS, SActionModal, SBadge, SBarcodeInput, SButton, SCalendar, SCallout, SCard, SCheckbox, SChip, SChipInput, SCircleProgress, SConfirmModal, SDatePicker, SDateRangePicker, SDivider, SDropdownButton, SField, SFilePicker, SGhostButton, SGuide, SIcon, SInput, SKeyValueTable, SLinearProgress, SLoadingContainer, SLoadingModal, SLoadingViewport, SModalContainer, SNumberInput, SPagination, SPopover, SPopup, SPortal, SRadio, SRadioButton, SRadioGroup, SSelect, SSwitch, STable, STabs, STag, STextLink, STextarea, SToast, SToastContainer, SToggle, STooltip, TAG_COLORS, TAG_SHAPES, TAG_SIZES, buttonPreset, cn, loading };
|
|
8595
|
+
export { BADGE_COLORS, BUTTON_COLORS, BUTTON_SIZES, COLOR_KEYS, ICONS, SActionModal, SBadge, SBarcodeInput, SButton, SCalendar, SCallout, SCard, SCheckbox, SChip, SChipInput, SCircleProgress, SConfirmModal, SDatePicker, SDateRangePicker, SDivider, SDropdownButton, SField, SFilePicker, SForm, SGhostButton, SGuide, SIcon, SInput, SKeyValueTable, SLinearProgress, SLoadingContainer, SLoadingModal, SLoadingViewport, SModalContainer, SNumberInput, SPagination, SPopover, SPopup, SPortal, SRadio, SRadioButton, SRadioGroup, SSelect, SSwitch, STable, STabs, STag, STextLink, STextarea, SToast, SToastContainer, SToggle, STooltip, TAG_COLORS, TAG_SHAPES, TAG_SIZES, buttonPreset, cn, isColorKey, loading, resolveColor };
|
|
8297
8596
|
//# sourceMappingURL=index.js.map
|
|
8298
8597
|
//# sourceMappingURL=index.js.map
|