@dmsi/wedgekit-react 0.0.1033 → 0.0.1035

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.
@@ -1287,6 +1287,7 @@ var Stepper = (_a) => {
1287
1287
  ]);
1288
1288
  const userInputRef = (0, import_react8.useRef)(false);
1289
1289
  const [displayValue, setDisplayValue] = (0, import_react8.useState)(String(value));
1290
+ const buttonMin = Math.max(step, min != null ? min : step);
1290
1291
  (0, import_react8.useEffect)(() => {
1291
1292
  if (userInputRef.current) {
1292
1293
  userInputRef.current = false;
@@ -1298,29 +1299,33 @@ var Stepper = (_a) => {
1298
1299
  if (max != null && value >= max) {
1299
1300
  return;
1300
1301
  }
1301
- const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
1302
- const next = Number(
1303
- Math.min(
1304
- Number((value + step).toFixed(prec + 6)),
1305
- max != null ? max : Infinity
1306
- ).toFixed(prec)
1307
- );
1308
- setValue(() => next);
1309
- onIncrease == null ? void 0 : onIncrease();
1302
+ setValue(() => {
1303
+ const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
1304
+ const next = Number(
1305
+ Math.min(
1306
+ Number((value + step).toFixed(prec + 6)),
1307
+ max != null ? max : Infinity
1308
+ ).toFixed(prec)
1309
+ );
1310
+ onIncrease == null ? void 0 : onIncrease(next);
1311
+ return next;
1312
+ });
1310
1313
  }
1311
1314
  function handleDecrease() {
1312
1315
  if (min != null && value <= min) {
1313
1316
  return;
1314
1317
  }
1315
- const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
1316
- const next = Number(
1317
- Math.max(
1318
- Number((value - step).toFixed(prec + 6)),
1319
- min != null ? min : -Infinity
1320
- ).toFixed(prec)
1321
- );
1322
- setValue(() => next);
1323
- onDecrease == null ? void 0 : onDecrease();
1318
+ setValue(() => {
1319
+ const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
1320
+ const next = Number(
1321
+ Math.max(
1322
+ Number((value - step).toFixed(prec + 6)),
1323
+ min != null ? min : -Infinity
1324
+ ).toFixed(prec)
1325
+ );
1326
+ onDecrease == null ? void 0 : onDecrease(next);
1327
+ return next;
1328
+ });
1324
1329
  }
1325
1330
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1326
1331
  "div",
@@ -1353,7 +1358,7 @@ var Stepper = (_a) => {
1353
1358
  }
1354
1359
  ),
1355
1360
  onClick: handleDecrease,
1356
- disabled: disabled || value <= 0 || min != null && value <= min
1361
+ disabled: disabled || value <= buttonMin
1357
1362
  }
1358
1363
  )
1359
1364
  }
@@ -66,6 +66,7 @@ var Stepper = (_a) => {
66
66
  ]);
67
67
  const userInputRef = useRef(false);
68
68
  const [displayValue, setDisplayValue] = useState(String(value));
69
+ const buttonMin = Math.max(step, min != null ? min : step);
69
70
  useEffect(() => {
70
71
  if (userInputRef.current) {
71
72
  userInputRef.current = false;
@@ -77,29 +78,33 @@ var Stepper = (_a) => {
77
78
  if (max != null && value >= max) {
78
79
  return;
79
80
  }
80
- const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
81
- const next = Number(
82
- Math.min(
83
- Number((value + step).toFixed(prec + 6)),
84
- max != null ? max : Infinity
85
- ).toFixed(prec)
86
- );
87
- setValue(() => next);
88
- onIncrease == null ? void 0 : onIncrease();
81
+ setValue(() => {
82
+ const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
83
+ const next = Number(
84
+ Math.min(
85
+ Number((value + step).toFixed(prec + 6)),
86
+ max != null ? max : Infinity
87
+ ).toFixed(prec)
88
+ );
89
+ onIncrease == null ? void 0 : onIncrease(next);
90
+ return next;
91
+ });
89
92
  }
90
93
  function handleDecrease() {
91
94
  if (min != null && value <= min) {
92
95
  return;
93
96
  }
94
- const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
95
- const next = Number(
96
- Math.max(
97
- Number((value - step).toFixed(prec + 6)),
98
- min != null ? min : -Infinity
99
- ).toFixed(prec)
100
- );
101
- setValue(() => next);
102
- onDecrease == null ? void 0 : onDecrease();
97
+ setValue(() => {
98
+ const prec = String(step).includes(".") ? String(step).split(".")[1].length : 0;
99
+ const next = Number(
100
+ Math.max(
101
+ Number((value - step).toFixed(prec + 6)),
102
+ min != null ? min : -Infinity
103
+ ).toFixed(prec)
104
+ );
105
+ onDecrease == null ? void 0 : onDecrease(next);
106
+ return next;
107
+ });
103
108
  }
104
109
  return /* @__PURE__ */ jsxs(
105
110
  "div",
@@ -132,7 +137,7 @@ var Stepper = (_a) => {
132
137
  }
133
138
  ),
134
139
  onClick: handleDecrease,
135
- disabled: disabled || value <= 0 || min != null && value <= min
140
+ disabled: disabled || value <= buttonMin
136
141
  }
137
142
  )
138
143
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.1033",
4
+ "version": "0.0.1035",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",