@kanda-libs/ks-component-ts 0.3.57 → 0.3.58
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/app/src/App.tsx +12 -49
- package/dist/index.d.ts +12738 -12738
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +3 -3
- package/package.json +1 -1
- package/src/field/components/RangeInput/useRangeInputProps.ts +32 -23
- package/src/generated/widget/index.tsx +62160 -62160
package/package.json
CHANGED
|
@@ -78,7 +78,7 @@ export default function useRangeInputProps(
|
|
|
78
78
|
|
|
79
79
|
const step = useMemo(
|
|
80
80
|
() => Math.ceil((parseInt(max, 10) - parseInt(min, 10)) / numSteps),
|
|
81
|
-
[]
|
|
81
|
+
[max, min, numSteps]
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
const maxInput = useMemo(() => {
|
|
@@ -111,32 +111,41 @@ export default function useRangeInputProps(
|
|
|
111
111
|
const increment = rawDiff * step;
|
|
112
112
|
return String(Math.min(parseInt(min, 10) + increment, parseInt(max, 10)));
|
|
113
113
|
},
|
|
114
|
-
[
|
|
114
|
+
[step, max, min]
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
const currentLabel = useMemo(() => {
|
|
118
118
|
if (!value) return undefined;
|
|
119
119
|
return `${prefix}${formatter(value)}${suffix}`;
|
|
120
|
-
}, [value]);
|
|
121
|
-
|
|
122
|
-
const maxLabel =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
120
|
+
}, [formatter, value, prefix, suffix]);
|
|
121
|
+
|
|
122
|
+
const maxLabel = useMemo(
|
|
123
|
+
() => `${prefix}${formatter(String(max))}${suffix}`,
|
|
124
|
+
[prefix, formatter, max, suffix]
|
|
125
|
+
);
|
|
126
|
+
const minLabel = useMemo(
|
|
127
|
+
() => `${prefix}${formatter(String(min))}${suffix}`,
|
|
128
|
+
[prefix, formatter, min, suffix]
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const classNames = useMemo(
|
|
132
|
+
() => ({
|
|
133
|
+
...CLASS_NAMES,
|
|
134
|
+
container: clsx(
|
|
135
|
+
CLASS_NAMES.container,
|
|
136
|
+
error ? "border-red-200" : "border-neutral-100"
|
|
137
|
+
),
|
|
138
|
+
minLowerLabel: clsx(
|
|
139
|
+
CLASS_NAMES.lowerLabel,
|
|
140
|
+
highlightLabel === "min" && CLASS_NAMES.highlightedLowerLabel
|
|
141
|
+
),
|
|
142
|
+
maxLowerLabel: clsx(
|
|
143
|
+
CLASS_NAMES.lowerLabel,
|
|
144
|
+
highlightLabel === "max" && CLASS_NAMES.highlightedLowerLabel
|
|
145
|
+
),
|
|
146
|
+
}),
|
|
147
|
+
[error, highlightLabel]
|
|
148
|
+
);
|
|
140
149
|
|
|
141
150
|
const onSliderChange = useCallback(
|
|
142
151
|
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -197,7 +206,7 @@ export default function useRangeInputProps(
|
|
|
197
206
|
if (!initRef.current) return;
|
|
198
207
|
const newValue = tieStepsTo === "max" ? tieMax(rawValue) : tieMin(rawValue);
|
|
199
208
|
setValue(name, newValue);
|
|
200
|
-
}, [rawValue, tieStepsTo, setValue]);
|
|
209
|
+
}, [rawValue, tieStepsTo, setValue, tieMax, tieMin, name]);
|
|
201
210
|
|
|
202
211
|
return {
|
|
203
212
|
ref,
|