@nexus-cross/design-system 2.0.4 → 2.0.6

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 (41) hide show
  1. package/cursor-rules/nexus-ui-api.mdc +4 -2
  2. package/dist/chunks/chunk-3BMVYJCA.js +15 -0
  3. package/dist/chunks/{chunk-2BINGHGR.js → chunk-EBMOQIY5.js} +17 -3
  4. package/dist/chunks/{chunk-RL5UAEGQ.mjs → chunk-FMUWSORG.mjs} +17 -3
  5. package/dist/chunks/{chunk-JFZLKFFM.mjs → chunk-JBMN6DY3.mjs} +1 -1
  6. package/dist/chunks/chunk-KHCPES3K.mjs +12 -0
  7. package/dist/chunks/{chunk-4ENXP7WH.js → chunk-L7SGGDY3.js} +4 -12
  8. package/dist/chunks/{chunk-WGGBE4ZD.mjs → chunk-QBMDWUQU.mjs} +1 -9
  9. package/dist/chunks/{chunk-7G7U4DP2.js → chunk-YMLPMIWX.js} +1 -1
  10. package/dist/components/NumberInput.d.ts +8 -0
  11. package/dist/components/NumberInput.d.ts.map +1 -1
  12. package/dist/components/PriceInput.d.ts.map +1 -1
  13. package/dist/index.js +8 -7
  14. package/dist/index.mjs +3 -2
  15. package/dist/number-input.js +5 -4
  16. package/dist/number-input.mjs +2 -1
  17. package/dist/price-input.js +4 -3
  18. package/dist/price-input.mjs +2 -1
  19. package/dist/schemas/_all.json +6 -1
  20. package/dist/schemas/number-input.d.ts +3 -0
  21. package/dist/schemas/number-input.d.ts.map +1 -1
  22. package/dist/schemas/numberInput.json +6 -1
  23. package/dist/schemas.js +6 -2
  24. package/dist/schemas.mjs +6 -2
  25. package/dist/styles/.generated/built.d.ts +1 -1
  26. package/dist/styles/.generated/built.d.ts.map +1 -1
  27. package/dist/styles/layer.js +2 -2
  28. package/dist/styles/layer.mjs +1 -1
  29. package/dist/styles.css +8 -8
  30. package/dist/styles.js +2 -2
  31. package/dist/styles.layered.css +8 -8
  32. package/dist/styles.mjs +1 -1
  33. package/dist/tokens/company.css +1 -1
  34. package/dist/tokens/css.css +1 -1
  35. package/dist/tokens-domains/gamehub-vars.css +1 -1
  36. package/dist/tokens-domains/gamehub.css +1 -1
  37. package/dist/tokens-domains/prediction-vars.css +1 -1
  38. package/dist/tokens-domains/prediction.css +1 -1
  39. package/dist/utils/numberFormat.d.ts +15 -0
  40. package/dist/utils/numberFormat.d.ts.map +1 -0
  41. package/package.json +3 -3
@@ -1769,13 +1769,14 @@ Number input with two variants: basic (chevron arrows) and bind (+/- buttons). S
1769
1769
 
1770
1770
  WHEN TO USE:
1771
1771
  • Any numeric field — quantity, score, age, count
1772
- Currency with thousand separators PriceInput instead
1772
+ Need thousand separators? Set separator={true}
1773
+ • Currency UX (prefix $, balance, maxBalance, click-to-fill balance) → PriceInput instead
1773
1774
  • Date / time → DatePicker instead
1774
1775
 
1775
1776
  ANTI-PATTERNS:
1776
1777
  ✗ <TextInput type="number"> → <NumberInput> (loses keyboard ↑↓, step, accelerated long-press, max click)
1777
1778
  ✗ Custom +/- buttons + <input> → variant="bind" (or numberInputBind for external)
1778
- ✗ Manual thousand separators for currencyPriceInput
1779
+ ✗ Manual thousand separator string formattinguse separator={true}
1779
1780
  ✗ Inline unit text inside label/description → use prefixIcon/suffixIcon (e.g. suffixIcon="%")
1780
1781
 
1781
1782
  | Prop | Type | Default | Description |
@@ -1797,6 +1798,7 @@ ANTI-PATTERNS:
1797
1798
  | `disabled` | `boolean` | - | Disabled |
1798
1799
  | `readOnly` | `boolean` | - | Read-only (includes hiding buttons) |
1799
1800
  | `placeholder` | `string` | - | Placeholder (default: "0") |
1801
+ | `separator` | `boolean` | `false` | Display thousand-separator commas (e.g. 1,000). onValueChange still receives raw number without commas. Decimal part is not separated (1,234.567). |
1800
1802
  | `name` | `string` | - | Form field name |
1801
1803
  | `id` | `string` | - | Element ID |
1802
1804
  | `autoFocus` | `boolean` | - | Auto focus |
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // src/utils/numberFormat.ts
4
+ function formatWithComma(value) {
5
+ if (!value) return value;
6
+ const [intPart, decPart] = value.split(".");
7
+ const formatted = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
8
+ return decPart !== void 0 ? `${formatted}.${decPart}` : formatted;
9
+ }
10
+ function stripComma(value) {
11
+ return value.replace(/,/g, "");
12
+ }
13
+
14
+ exports.formatWithComma = formatWithComma;
15
+ exports.stripComma = stripComma;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunk3BMVYJCA_js = require('./chunk-3BMVYJCA.js');
3
4
  var chunkCZC76ZD5_js = require('./chunk-CZC76ZD5.js');
4
5
  var React = require('react');
5
6
  var classVarianceAuthority = require('class-variance-authority');
@@ -128,6 +129,7 @@ var NumberInput = React__namespace.forwardRef(
128
129
  readOnly,
129
130
  onValueChange,
130
131
  placeholder,
132
+ separator = false,
131
133
  ...props
132
134
  }, ref) => {
133
135
  const inputRef = React__namespace.useRef(null);
@@ -160,12 +162,24 @@ var NumberInput = React__namespace.forwardRef(
160
162
  );
161
163
  const handleInputChange = React__namespace.useCallback(
162
164
  (e) => {
163
- const raw = e.target.value;
165
+ const rawInput = e.target.value;
166
+ const raw = separator ? chunk3BMVYJCA_js.stripComma(rawInput) : rawInput;
164
167
  const regex = digit > 0 ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
165
168
  if (!regex.test(raw)) return;
166
169
  setInternalValue(raw);
170
+ if (separator && inputRef.current) {
171
+ const cursorPos = e.target.selectionStart ?? 0;
172
+ const commasBefore = (rawInput.slice(0, cursorPos).match(/,/g) || []).length;
173
+ const formatted = chunk3BMVYJCA_js.formatWithComma(raw);
174
+ const el = inputRef.current;
175
+ requestAnimationFrame(() => {
176
+ const commasAfter = (formatted.slice(0, cursorPos).match(/,/g) || []).length;
177
+ const newPos = cursorPos + (commasAfter - commasBefore);
178
+ el.setSelectionRange(newPos, newPos);
179
+ });
180
+ }
167
181
  },
168
- [digit]
182
+ [digit, separator]
169
183
  );
170
184
  const handleBlur = React__namespace.useCallback(() => {
171
185
  commitValue(internalValue);
@@ -318,7 +332,7 @@ var NumberInput = React__namespace.forwardRef(
318
332
  inputMode: "decimal",
319
333
  role: "spinbutton",
320
334
  className: chunkCZC76ZD5_js.cn("nexus-number-input__field", inputClassName),
321
- value: internalValue,
335
+ value: separator ? chunk3BMVYJCA_js.formatWithComma(internalValue) : internalValue,
322
336
  disabled,
323
337
  readOnly,
324
338
  placeholder: placeholder ?? "0",
@@ -1,3 +1,4 @@
1
+ import { stripComma, formatWithComma } from './chunk-KHCPES3K.mjs';
1
2
  import { cn } from './chunk-MCKOWMLS.mjs';
2
3
  import * as React from 'react';
3
4
  import { cva } from 'class-variance-authority';
@@ -106,6 +107,7 @@ var NumberInput = React.forwardRef(
106
107
  readOnly,
107
108
  onValueChange,
108
109
  placeholder,
110
+ separator = false,
109
111
  ...props
110
112
  }, ref) => {
111
113
  const inputRef = React.useRef(null);
@@ -138,12 +140,24 @@ var NumberInput = React.forwardRef(
138
140
  );
139
141
  const handleInputChange = React.useCallback(
140
142
  (e) => {
141
- const raw = e.target.value;
143
+ const rawInput = e.target.value;
144
+ const raw = separator ? stripComma(rawInput) : rawInput;
142
145
  const regex = digit > 0 ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
143
146
  if (!regex.test(raw)) return;
144
147
  setInternalValue(raw);
148
+ if (separator && inputRef.current) {
149
+ const cursorPos = e.target.selectionStart ?? 0;
150
+ const commasBefore = (rawInput.slice(0, cursorPos).match(/,/g) || []).length;
151
+ const formatted = formatWithComma(raw);
152
+ const el = inputRef.current;
153
+ requestAnimationFrame(() => {
154
+ const commasAfter = (formatted.slice(0, cursorPos).match(/,/g) || []).length;
155
+ const newPos = cursorPos + (commasAfter - commasBefore);
156
+ el.setSelectionRange(newPos, newPos);
157
+ });
158
+ }
145
159
  },
146
- [digit]
160
+ [digit, separator]
147
161
  );
148
162
  const handleBlur = React.useCallback(() => {
149
163
  commitValue(internalValue);
@@ -296,7 +310,7 @@ var NumberInput = React.forwardRef(
296
310
  inputMode: "decimal",
297
311
  role: "spinbutton",
298
312
  className: cn("nexus-number-input__field", inputClassName),
299
- value: internalValue,
313
+ value: separator ? formatWithComma(internalValue) : internalValue,
300
314
  disabled,
301
315
  readOnly,
302
316
  placeholder: placeholder ?? "0",