@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanda-libs/ks-component-ts",
3
- "version": "0.3.57",
3
+ "version": "0.3.58",
4
4
  "description": "Kanda form component library",
5
5
  "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
@@ -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
- [maxInput, step, max]
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 = `${prefix}${formatter(String(max))}${suffix}`;
123
- const minLabel = `${prefix}${formatter(String(min))}${suffix}`;
124
-
125
- const classNames = {
126
- ...CLASS_NAMES,
127
- container: clsx(
128
- CLASS_NAMES.container,
129
- error ? "border-red-200" : "border-neutral-100"
130
- ),
131
- minLowerLabel: clsx(
132
- CLASS_NAMES.lowerLabel,
133
- highlightLabel === "min" && CLASS_NAMES.highlightedLowerLabel
134
- ),
135
- maxLowerLabel: clsx(
136
- CLASS_NAMES.lowerLabel,
137
- highlightLabel === "max" && CLASS_NAMES.highlightedLowerLabel
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,