@rockshin/tao-ui 0.0.57 → 0.0.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.
Files changed (30) hide show
  1. package/dist/components/app/app-notices.js +10 -3
  2. package/dist/components/avatar/avatar.js +1 -1
  3. package/dist/components/badge/badge.js +2 -2
  4. package/dist/components/breadcrumb/breadcrumb.js +5 -1
  5. package/dist/components/calendar/calendar.js +4 -1
  6. package/dist/components/carousel/carousel.js +8 -2
  7. package/dist/components/collapse/collapse-panels.js +68 -67
  8. package/dist/components/date-picker/date-localization.js +12 -14
  9. package/dist/components/divider/divider.js +1 -1
  10. package/dist/components/float-button/float-button.js +7 -5
  11. package/dist/components/image/image.js +135 -143
  12. package/dist/components/input/otp.js +6 -0
  13. package/dist/components/input/search.js +7 -5
  14. package/dist/components/list/list.js +106 -105
  15. package/dist/components/masonry/masonry.js +1 -1
  16. package/dist/components/pagination/pagination.d.ts +2 -0
  17. package/dist/components/pagination/pagination.js +4 -0
  18. package/dist/components/rate/rate.js +83 -72
  19. package/dist/components/scroll-area/scroll-area.css +1 -1
  20. package/dist/components/scroll-area/scroll-area.js +294 -222
  21. package/dist/components/select/use-select-selection.d.ts +1 -1
  22. package/dist/components/select/use-select-selection.js +60 -53
  23. package/dist/components/statistic/statistic.js +84 -78
  24. package/dist/components/steps/steps.js +1 -1
  25. package/dist/components/table/table.js +4 -1
  26. package/dist/components/upload/upload.js +2 -2
  27. package/dist/number-input/cursor.js +20 -8
  28. package/dist/number-input/format.js +12 -4
  29. package/dist/number-input/use-number-input.js +4 -1
  30. package/package.json +1 -1
@@ -10,7 +10,7 @@ export declare function useSelectSelection(props: SelectionProps, disabled: bool
10
10
  select: (next: string) => boolean;
11
11
  addTokens: (input: string) => boolean;
12
12
  remove: (removed: string) => void;
13
- commit: (nextArray: string[]) => void;
13
+ commit: (draft: string[]) => void;
14
14
  clear: () => void;
15
15
  };
16
16
  export {};
@@ -2,7 +2,7 @@ import { c } from "react-compiler-runtime";
2
2
  import { useState } from "react";
3
3
  import { buildSelectIndex } from "./select-model.js";
4
4
  function useSelectSelection(props, disabled) {
5
- const $ = c(75);
5
+ const $ = c(76);
6
6
  const { options, value: valueProp, defaultValue, mode, maxCount, tokenSeparators, onChange, onSelect, onDeselect, onClear } = props;
7
7
  const multiple = "multiple" === mode || "tags" === mode;
8
8
  const controlled = "value" in props;
@@ -162,67 +162,74 @@ function useSelectSelection(props, disabled) {
162
162
  } else t7 = $[41];
163
163
  const remove = t7;
164
164
  let t8;
165
- if ($[42] !== disabled || $[43] !== maxCount || $[44] !== onDeselect || $[45] !== onSelect || $[46] !== optionByValue || $[47] !== publish || $[48] !== selectedValueSet || $[49] !== valueArray) {
166
- t8 = (nextArray_1)=>{
167
- if (disabled || null != maxCount && nextArray_1.length > maxCount) return;
165
+ if ($[42] !== disabled || $[43] !== maxCount || $[44] !== mode || $[45] !== onDeselect || $[46] !== onSelect || $[47] !== optionByValue || $[48] !== publish || $[49] !== selectedValueSet || $[50] !== valueArray) {
166
+ t8 = (draft)=>{
167
+ if (disabled) return;
168
+ const nextArray_1 = draft.filter((item_2)=>{
169
+ if (selectedValueSet.has(item_2)) return true;
170
+ const option_4 = optionByValue.get(item_2);
171
+ return option_4 ? !option_4.disabled : "tags" === mode;
172
+ });
173
+ if (null != maxCount && nextArray_1.length > maxCount) return;
168
174
  publish(nextArray_1);
169
175
  const nextSet = new Set(nextArray_1);
170
176
  for (const next_3 of nextArray_1)if (!selectedValueSet.has(next_3)) {
171
- const option_4 = optionByValue.get(next_3);
172
- if (option_4) onSelect?.(next_3, option_4);
177
+ const option_5 = optionByValue.get(next_3);
178
+ if (option_5) onSelect?.(next_3, option_5);
173
179
  }
174
180
  for (const previous of valueArray)if (!nextSet.has(previous)) {
175
- const option_5 = optionByValue.get(previous);
176
- if (option_5) onDeselect?.(previous, option_5);
181
+ const option_6 = optionByValue.get(previous);
182
+ if (option_6) onDeselect?.(previous, option_6);
177
183
  }
178
184
  };
179
185
  $[42] = disabled;
180
186
  $[43] = maxCount;
181
- $[44] = onDeselect;
182
- $[45] = onSelect;
183
- $[46] = optionByValue;
184
- $[47] = publish;
185
- $[48] = selectedValueSet;
186
- $[49] = valueArray;
187
- $[50] = t8;
188
- } else t8 = $[50];
187
+ $[44] = mode;
188
+ $[45] = onDeselect;
189
+ $[46] = onSelect;
190
+ $[47] = optionByValue;
191
+ $[48] = publish;
192
+ $[49] = selectedValueSet;
193
+ $[50] = valueArray;
194
+ $[51] = t8;
195
+ } else t8 = $[51];
189
196
  const commit = t8;
190
197
  let t9;
191
- if ($[51] !== multiple || $[52] !== onClear || $[53] !== publish) {
198
+ if ($[52] !== multiple || $[53] !== onClear || $[54] !== publish) {
192
199
  t9 = ()=>{
193
200
  publish(multiple ? [] : void 0, true);
194
201
  onClear?.();
195
202
  };
196
- $[51] = multiple;
197
- $[52] = onClear;
198
- $[53] = publish;
199
- $[54] = t9;
200
- } else t9 = $[54];
203
+ $[52] = multiple;
204
+ $[53] = onClear;
205
+ $[54] = publish;
206
+ $[55] = t9;
207
+ } else t9 = $[55];
201
208
  const clear_0 = t9;
202
209
  let t10;
203
- if ($[55] !== multiple || $[56] !== optionByValue || $[57] !== value) {
210
+ if ($[56] !== multiple || $[57] !== optionByValue || $[58] !== value) {
204
211
  t10 = !multiple && value ? optionByValue.get(value) : void 0;
205
- $[55] = multiple;
206
- $[56] = optionByValue;
207
- $[57] = value;
208
- $[58] = t10;
209
- } else t10 = $[58];
212
+ $[56] = multiple;
213
+ $[57] = optionByValue;
214
+ $[58] = value;
215
+ $[59] = t10;
216
+ } else t10 = $[59];
210
217
  const selectedOption = t10;
211
218
  let t11;
212
- if ($[59] !== mode || $[60] !== multiple || $[61] !== optionByValue || $[62] !== valueArray) {
213
- t11 = multiple ? valueArray.map((item_2)=>optionByValue.get(item_2) ?? ("tags" === mode ? {
214
- label: item_2,
215
- value: item_2
219
+ if ($[60] !== mode || $[61] !== multiple || $[62] !== optionByValue || $[63] !== valueArray) {
220
+ t11 = multiple ? valueArray.map((item_3)=>optionByValue.get(item_3) ?? ("tags" === mode ? {
221
+ label: item_3,
222
+ value: item_3
216
223
  } : void 0)).filter(_temp4) : [];
217
- $[59] = mode;
218
- $[60] = multiple;
219
- $[61] = optionByValue;
220
- $[62] = valueArray;
221
- $[63] = t11;
222
- } else t11 = $[63];
224
+ $[60] = mode;
225
+ $[61] = multiple;
226
+ $[62] = optionByValue;
227
+ $[63] = valueArray;
228
+ $[64] = t11;
229
+ } else t11 = $[64];
223
230
  const selectedOptions = t11;
224
231
  let t12;
225
- if ($[64] !== addTokens || $[65] !== clear_0 || $[66] !== commit || $[67] !== remove || $[68] !== select || $[69] !== selectedOption || $[70] !== selectedOptions || $[71] !== selectedValueSet || $[72] !== value || $[73] !== valueArray) {
232
+ if ($[65] !== addTokens || $[66] !== clear_0 || $[67] !== commit || $[68] !== remove || $[69] !== select || $[70] !== selectedOption || $[71] !== selectedOptions || $[72] !== selectedValueSet || $[73] !== value || $[74] !== valueArray) {
226
233
  t12 = {
227
234
  value,
228
235
  valueArray,
@@ -235,22 +242,22 @@ function useSelectSelection(props, disabled) {
235
242
  commit,
236
243
  clear: clear_0
237
244
  };
238
- $[64] = addTokens;
239
- $[65] = clear_0;
240
- $[66] = commit;
241
- $[67] = remove;
242
- $[68] = select;
243
- $[69] = selectedOption;
244
- $[70] = selectedOptions;
245
- $[71] = selectedValueSet;
246
- $[72] = value;
247
- $[73] = valueArray;
248
- $[74] = t12;
249
- } else t12 = $[74];
245
+ $[65] = addTokens;
246
+ $[66] = clear_0;
247
+ $[67] = commit;
248
+ $[68] = remove;
249
+ $[69] = select;
250
+ $[70] = selectedOption;
251
+ $[71] = selectedOptions;
252
+ $[72] = selectedValueSet;
253
+ $[73] = value;
254
+ $[74] = valueArray;
255
+ $[75] = t12;
256
+ } else t12 = $[75];
250
257
  return t12;
251
258
  }
252
- function _temp4(option_6) {
253
- return void 0 !== option_6;
259
+ function _temp4(option_7) {
260
+ return void 0 !== option_7;
254
261
  }
255
262
  function _temp3(token) {
256
263
  return token.trim();
@@ -13,7 +13,7 @@ const plainNumber = new Intl.NumberFormat('en-US', {
13
13
  function formattedNumber(value, precision, options) {
14
14
  const text = 'number' == typeof value && String(value).includes('e') ? plainNumber.format(value) : String(value);
15
15
  const match = /^(-?)(\d*)(?:\.(\d+))?$/.exec(text);
16
- if (!match || '-' === text) return text;
16
+ if (!match || '' === text || '-' === text) return text;
17
17
  const integer = localizeDigits(groupInteger(match[2] || '0', options), options);
18
18
  const fraction = void 0 === precision ? match[3] ?? '' : (match[3] ?? '').padEnd(precision, '0').slice(0, Math.max(0, precision));
19
19
  return /*#__PURE__*/ jsxs(Fragment, {
@@ -37,7 +37,7 @@ function formattedNumber(value, precision, options) {
37
37
  }
38
38
  const hasContent = (node)=>null != node && 'boolean' != typeof node;
39
39
  const StatisticRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
40
- const $ = c(86);
40
+ const $ = c(87);
41
41
  let className;
42
42
  let classNames;
43
43
  let decimalSeparator;
@@ -158,51 +158,57 @@ const StatisticRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
158
158
  const t5 = classes?.value;
159
159
  const t6 = slots?.value;
160
160
  let t7;
161
- if ($[34] !== formatter || $[35] !== numberFormat || $[36] !== precision || $[37] !== value) {
162
- t7 = "function" == typeof formatter ? formatter(value) : false === formatter ? value : formattedNumber(value, precision, numberFormat);
161
+ if ($[34] !== formatter || $[35] !== locale || $[36] !== numberFormat || $[37] !== precision || $[38] !== value) {
162
+ t7 = "function" == typeof formatter ? formatter(value, {
163
+ locale,
164
+ precision,
165
+ decimalSeparator: numberFormat.decimalSeparator,
166
+ groupSeparator: numberFormat.thousandsSeparator
167
+ }) : false === formatter ? value : formattedNumber(value, precision, numberFormat);
163
168
  $[34] = formatter;
164
- $[35] = numberFormat;
165
- $[36] = precision;
166
- $[37] = value;
167
- $[38] = t7;
168
- } else t7 = $[38];
169
+ $[35] = locale;
170
+ $[36] = numberFormat;
171
+ $[37] = precision;
172
+ $[38] = value;
173
+ $[39] = t7;
174
+ } else t7 = $[39];
169
175
  let t8;
170
- if ($[39] !== t5 || $[40] !== t6 || $[41] !== t7) {
176
+ if ($[40] !== t5 || $[41] !== t6 || $[42] !== t7) {
171
177
  t8 = /*#__PURE__*/ jsx("span", {
172
178
  "data-tao-statistic-value": "",
173
179
  className: t5,
174
180
  style: t6,
175
181
  children: t7
176
182
  });
177
- $[39] = t5;
178
- $[40] = t6;
179
- $[41] = t7;
180
- $[42] = t8;
181
- } else t8 = $[42];
183
+ $[40] = t5;
184
+ $[41] = t6;
185
+ $[42] = t7;
186
+ $[43] = t8;
187
+ } else t8 = $[43];
182
188
  const formatted = t8;
183
189
  const t9 = classes?.root;
184
190
  let t10;
185
- if ($[43] !== className || $[44] !== prefixCls || $[45] !== rootClassName || $[46] !== t9) {
191
+ if ($[44] !== className || $[45] !== prefixCls || $[46] !== rootClassName || $[47] !== t9) {
186
192
  t10 = cx(prefixCls, t9, className, rootClassName);
187
- $[43] = className;
188
- $[44] = prefixCls;
189
- $[45] = rootClassName;
190
- $[46] = t9;
191
- $[47] = t10;
192
- } else t10 = $[47];
193
+ $[44] = className;
194
+ $[45] = prefixCls;
195
+ $[46] = rootClassName;
196
+ $[47] = t9;
197
+ $[48] = t10;
198
+ } else t10 = $[48];
193
199
  const t11 = slots?.root;
194
200
  let t12;
195
- if ($[48] !== style || $[49] !== t11) {
201
+ if ($[49] !== style || $[50] !== t11) {
196
202
  t12 = {
197
203
  ...t11,
198
204
  ...style
199
205
  };
200
- $[48] = style;
201
- $[49] = t11;
202
- $[50] = t12;
203
- } else t12 = $[50];
206
+ $[49] = style;
207
+ $[50] = t11;
208
+ $[51] = t12;
209
+ } else t12 = $[51];
204
210
  let t13;
205
- if ($[51] !== classes?.header || $[52] !== classes?.title || $[53] !== slots?.header || $[54] !== slots?.title || $[55] !== title) {
211
+ if ($[52] !== classes?.header || $[53] !== classes?.title || $[54] !== slots?.header || $[55] !== slots?.title || $[56] !== title) {
206
212
  t13 = hasContent(title) && /*#__PURE__*/ jsx("div", {
207
213
  "data-tao-statistic-header": "",
208
214
  className: classes?.header,
@@ -214,60 +220,60 @@ const StatisticRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
214
220
  children: title
215
221
  })
216
222
  });
217
- $[51] = classes?.header;
218
- $[52] = classes?.title;
219
- $[53] = slots?.header;
220
- $[54] = slots?.title;
221
- $[55] = title;
222
- $[56] = t13;
223
- } else t13 = $[56];
223
+ $[52] = classes?.header;
224
+ $[53] = classes?.title;
225
+ $[54] = slots?.header;
226
+ $[55] = slots?.title;
227
+ $[56] = title;
228
+ $[57] = t13;
229
+ } else t13 = $[57];
224
230
  const t14 = classes?.content;
225
231
  const t15 = slots?.content;
226
232
  let t16;
227
- if ($[57] !== t15 || $[58] !== valueStyle) {
233
+ if ($[58] !== t15 || $[59] !== valueStyle) {
228
234
  t16 = {
229
235
  ...valueStyle,
230
236
  ...t15
231
237
  };
232
- $[57] = t15;
233
- $[58] = valueStyle;
234
- $[59] = t16;
235
- } else t16 = $[59];
238
+ $[58] = t15;
239
+ $[59] = valueStyle;
240
+ $[60] = t16;
241
+ } else t16 = $[60];
236
242
  let t17;
237
- if ($[60] !== classes?.prefix || $[61] !== prefix || $[62] !== slots?.prefix) {
243
+ if ($[61] !== classes?.prefix || $[62] !== prefix || $[63] !== slots?.prefix) {
238
244
  t17 = hasContent(prefix) && /*#__PURE__*/ jsx("span", {
239
245
  "data-tao-statistic-prefix": "",
240
246
  className: classes?.prefix,
241
247
  style: slots?.prefix,
242
248
  children: prefix
243
249
  });
244
- $[60] = classes?.prefix;
245
- $[61] = prefix;
246
- $[62] = slots?.prefix;
247
- $[63] = t17;
248
- } else t17 = $[63];
250
+ $[61] = classes?.prefix;
251
+ $[62] = prefix;
252
+ $[63] = slots?.prefix;
253
+ $[64] = t17;
254
+ } else t17 = $[64];
249
255
  let t18;
250
- if ($[64] !== formatted || $[65] !== valueRender) {
256
+ if ($[65] !== formatted || $[66] !== valueRender) {
251
257
  t18 = valueRender ? valueRender(formatted) : formatted;
252
- $[64] = formatted;
253
- $[65] = valueRender;
254
- $[66] = t18;
255
- } else t18 = $[66];
258
+ $[65] = formatted;
259
+ $[66] = valueRender;
260
+ $[67] = t18;
261
+ } else t18 = $[67];
256
262
  let t19;
257
- if ($[67] !== classes?.suffix || $[68] !== slots?.suffix || $[69] !== suffix) {
263
+ if ($[68] !== classes?.suffix || $[69] !== slots?.suffix || $[70] !== suffix) {
258
264
  t19 = hasContent(suffix) && /*#__PURE__*/ jsx("span", {
259
265
  "data-tao-statistic-suffix": "",
260
266
  className: classes?.suffix,
261
267
  style: slots?.suffix,
262
268
  children: suffix
263
269
  });
264
- $[67] = classes?.suffix;
265
- $[68] = slots?.suffix;
266
- $[69] = suffix;
267
- $[70] = t19;
268
- } else t19 = $[70];
270
+ $[68] = classes?.suffix;
271
+ $[69] = slots?.suffix;
272
+ $[70] = suffix;
273
+ $[71] = t19;
274
+ } else t19 = $[71];
269
275
  let t20;
270
- if ($[71] !== t14 || $[72] !== t16 || $[73] !== t17 || $[74] !== t18 || $[75] !== t19) {
276
+ if ($[72] !== t14 || $[73] !== t16 || $[74] !== t17 || $[75] !== t18 || $[76] !== t19) {
271
277
  t20 = /*#__PURE__*/ jsxs("div", {
272
278
  "data-tao-statistic-content": "",
273
279
  className: t14,
@@ -278,27 +284,27 @@ const StatisticRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
278
284
  t19
279
285
  ]
280
286
  });
281
- $[71] = t14;
282
- $[72] = t16;
283
- $[73] = t17;
284
- $[74] = t18;
285
- $[75] = t19;
286
- $[76] = t20;
287
- } else t20 = $[76];
287
+ $[72] = t14;
288
+ $[73] = t16;
289
+ $[74] = t17;
290
+ $[75] = t18;
291
+ $[76] = t19;
292
+ $[77] = t20;
293
+ } else t20 = $[77];
288
294
  let t21;
289
- if ($[77] !== loading || $[78] !== t20) {
295
+ if ($[78] !== loading || $[79] !== t20) {
290
296
  t21 = /*#__PURE__*/ jsx(Skeleton, {
291
297
  loading: loading,
292
298
  paragraph: false,
293
299
  active: true,
294
300
  children: t20
295
301
  });
296
- $[77] = loading;
297
- $[78] = t20;
298
- $[79] = t21;
299
- } else t21 = $[79];
302
+ $[78] = loading;
303
+ $[79] = t20;
304
+ $[80] = t21;
305
+ } else t21 = $[80];
300
306
  let t22;
301
- if ($[80] !== rest || $[81] !== t10 || $[82] !== t12 || $[83] !== t13 || $[84] !== t21) {
307
+ if ($[81] !== rest || $[82] !== t10 || $[83] !== t12 || $[84] !== t13 || $[85] !== t21) {
302
308
  t22 = /*#__PURE__*/ jsxs("div", {
303
309
  ...rest,
304
310
  ref: node,
@@ -310,13 +316,13 @@ const StatisticRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
310
316
  t21
311
317
  ]
312
318
  });
313
- $[80] = rest;
314
- $[81] = t10;
315
- $[82] = t12;
316
- $[83] = t13;
317
- $[84] = t21;
318
- $[85] = t22;
319
- } else t22 = $[85];
319
+ $[81] = rest;
320
+ $[82] = t10;
321
+ $[83] = t12;
322
+ $[84] = t13;
323
+ $[85] = t21;
324
+ $[86] = t22;
325
+ } else t22 = $[86];
320
326
  return t22;
321
327
  });
322
328
  StatisticRoot.displayName = 'Statistic';
@@ -148,7 +148,7 @@ function Steps(t0) {
148
148
  const isPanel = "panel" === mergedType;
149
149
  const mergedOrientation = isPanel ? "horizontal" : "vertical" === orientation || responsive && true === screens.xs ? "vertical" : "horizontal";
150
150
  const mergedTitlePlacement = isDot || "vertical" === mergedOrientation ? "vertical" === mergedOrientation ? "horizontal" : "vertical" : "navigation" === mergedType ? "horizontal" : titlePlacement ?? "horizontal";
151
- const mergedPercent = isInline ? void 0 : percent;
151
+ const mergedPercent = isInline || void 0 === percent ? void 0 : Math.min(100, Math.max(0, percent || 0));
152
152
  const { canApplyMaxCount, displaySteps, displayCurrent } = useDisplaySteps(mergedItems, current, initial, maxCount);
153
153
  let t10;
154
154
  if ($[4] !== displayCurrent || $[5] !== displaySteps || $[6] !== status) {
@@ -143,7 +143,9 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
143
143
  ] : expandedKeys.filter((k_0)=>k_0 !== key_1);
144
144
  if (!isExpansionControlled) setInternalExpandedKeys(nextKeys_1);
145
145
  expandable?.onExpand?.(expanded, record_2);
146
- expandable?.onExpandedRowsChange?.(nextKeys_1);
146
+ expandable?.onExpandedRowsChange?.([
147
+ ...nextKeys_1
148
+ ]);
147
149
  };
148
150
  const scrollRef = useRef(null);
149
151
  const headerRowRef = useRef(null);
@@ -416,6 +418,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
416
418
  "data-tao-table-row": "",
417
419
  "data-tao-selected": isSelected || void 0,
418
420
  onClick: (event)=>{
421
+ if (!event.currentTarget.contains(event.target)) return;
419
422
  const selectionCell = event.target.closest('[data-tao-table-selection-cell]');
420
423
  if (selectionCell && event.target !== selectionCell) return void event.stopPropagation();
421
424
  rowProps.onClick?.(event);
@@ -572,8 +572,8 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
572
572
  showInfo: false,
573
573
  ...props.progress,
574
574
  percent: file_15.percent ?? 0,
575
- "aria-label": file_15['aria-label'] ?? file_15.name,
576
- "aria-labelledby": file_15['aria-labelledby']
575
+ "aria-label": file_15['aria-label'] ?? props.progress?.['aria-label'] ?? file_15.name,
576
+ "aria-labelledby": file_15['aria-labelledby'] ?? props.progress?.['aria-labelledby']
577
577
  }),
578
578
  null != listConfig.extra && /*#__PURE__*/ jsx("span", {
579
579
  "data-tao-upload-extra": "",
@@ -2,16 +2,22 @@ function countAnchored(display, upTo, thousandsSeparator) {
2
2
  const limit = Math.min(upTo, display.length);
3
3
  if (!thousandsSeparator) return Math.max(0, limit);
4
4
  let count = 0;
5
- for(let i = 0; i < limit; i++)if (display[i] !== thousandsSeparator) count++;
5
+ for(let i = 0; i < limit;)if (display.startsWith(thousandsSeparator, i)) i += thousandsSeparator.length;
6
+ else {
7
+ count++;
8
+ i++;
9
+ }
6
10
  return count;
7
11
  }
8
12
  function findCursorAt(display, anchorCount, thousandsSeparator) {
9
13
  if (anchorCount <= 0) return 0;
10
14
  if (!thousandsSeparator) return Math.min(anchorCount, display.length);
11
15
  let count = 0;
12
- for(let i = 0; i < display.length; i++){
13
- if (display[i] !== thousandsSeparator) count++;
14
- if (count === anchorCount) return i + 1;
16
+ for(let i = 0; i < display.length;)if (display.startsWith(thousandsSeparator, i)) i += thousandsSeparator.length;
17
+ else {
18
+ count++;
19
+ i++;
20
+ if (count === anchorCount) return i;
15
21
  }
16
22
  return display.length;
17
23
  }
@@ -19,15 +25,21 @@ function countAnchoredFromEnd(display, fromPos, thousandsSeparator) {
19
25
  if (fromPos >= display.length) return 0;
20
26
  if (!thousandsSeparator) return display.length - Math.max(0, fromPos);
21
27
  let count = 0;
22
- for(let i = Math.max(0, fromPos); i < display.length; i++)if (display[i] !== thousandsSeparator) count++;
28
+ for(let i = display.length; i > Math.max(0, fromPos);)if (display.endsWith(thousandsSeparator, i)) i -= thousandsSeparator.length;
29
+ else {
30
+ count++;
31
+ i--;
32
+ }
23
33
  return count;
24
34
  }
25
35
  function findCursorFromEnd(display, anchoredFromEnd, thousandsSeparator) {
26
36
  if (anchoredFromEnd <= 0) return display.length;
27
37
  if (!thousandsSeparator) return Math.max(0, display.length - anchoredFromEnd);
28
38
  let count = 0;
29
- for(let i = display.length - 1; i >= 0; i--){
30
- if (display[i] !== thousandsSeparator) count++;
39
+ for(let i = display.length; i > 0;)if (display.endsWith(thousandsSeparator, i)) i -= thousandsSeparator.length;
40
+ else {
41
+ count++;
42
+ i--;
31
43
  if (count === anchoredFromEnd) return i;
32
44
  }
33
45
  return 0;
@@ -39,6 +51,6 @@ function reposition(args) {
39
51
  }
40
52
  function isThousandSepBeforeCursor(display, cursor, thousandsSeparator) {
41
53
  if (!thousandsSeparator || cursor <= 0) return false;
42
- return display[cursor - 1] === thousandsSeparator;
54
+ return display.endsWith(thousandsSeparator, cursor);
43
55
  }
44
56
  export { countAnchored, findCursorAt, isThousandSepBeforeCursor, reposition };
@@ -19,10 +19,18 @@ function parse(display, opts) {
19
19
  const body = negative ? text.slice(1) : text;
20
20
  let cleaned = '';
21
21
  let seenDecimal = false;
22
- for (const ch of body)if (ch >= '0' && ch <= '9') cleaned += ch;
23
- else if (!seenDecimal && (ch === opts.decimalSeparator || opts.allowAsciiDecimal && '.' === ch && '.' !== opts.thousandsSeparator)) {
24
- cleaned += '.';
25
- seenDecimal = true;
22
+ const { decimalSeparator } = opts;
23
+ for(let index = 0; index < body.length; index++){
24
+ const ch = body[index];
25
+ if (decimalSeparator && body.startsWith(decimalSeparator, index)) {
26
+ if (!seenDecimal) cleaned += '.';
27
+ seenDecimal = true;
28
+ index += decimalSeparator.length - 1;
29
+ } else if (ch >= '0' && ch <= '9') cleaned += ch;
30
+ else if (!seenDecimal && opts.allowAsciiDecimal && '.' === ch && '.' !== opts.thousandsSeparator) {
31
+ cleaned += '.';
32
+ seenDecimal = true;
33
+ }
26
34
  }
27
35
  if (cleaned.startsWith('.')) cleaned = `0${cleaned}`;
28
36
  return (negative ? '-' : '') + cleaned;
@@ -294,7 +294,10 @@ function useNumberInput(opts) {
294
294
  const el = inputRef.current;
295
295
  if (!el) return;
296
296
  const cursor_0 = el.selectionStart ?? 0;
297
- if (cursor_0 > 0 && el.selectionEnd === cursor_0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) el.setSelectionRange(cursor_0 - 1, cursor_0 - 1);
297
+ if (cursor_0 > 0 && el.selectionEnd === cursor_0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) {
298
+ const beforeSeparator = cursor_0 - thousandsSeparator.length;
299
+ el.setSelectionRange(beforeSeparator, beforeSeparator);
300
+ }
298
301
  };
299
302
  $[74] = displayBuffer;
300
303
  $[75] = thousandsSeparator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [