@rockshin/tao-ui 0.0.1

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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/components/button/button.css +1055 -0
  4. package/dist/components/button/button.d.ts +15 -0
  5. package/dist/components/button/button.js +93 -0
  6. package/dist/components/checkbox/checkbox.css +1035 -0
  7. package/dist/components/checkbox/checkbox.d.ts +33 -0
  8. package/dist/components/checkbox/checkbox.js +312 -0
  9. package/dist/components/date-picker/calendar/calendar-grid.d.ts +18 -0
  10. package/dist/components/date-picker/calendar/calendar-grid.js +173 -0
  11. package/dist/components/date-picker/calendar/calendar-header.d.ts +10 -0
  12. package/dist/components/date-picker/calendar/calendar-header.js +336 -0
  13. package/dist/components/date-picker/calendar/month-grid.d.ts +9 -0
  14. package/dist/components/date-picker/calendar/month-grid.js +61 -0
  15. package/dist/components/date-picker/calendar/time-panel.d.ts +12 -0
  16. package/dist/components/date-picker/calendar/time-panel.js +233 -0
  17. package/dist/components/date-picker/calendar/use-calendar.d.ts +15 -0
  18. package/dist/components/date-picker/calendar/use-calendar.js +24 -0
  19. package/dist/components/date-picker/calendar/year-grid.d.ts +9 -0
  20. package/dist/components/date-picker/calendar/year-grid.js +60 -0
  21. package/dist/components/date-picker/date-picker.css +1799 -0
  22. package/dist/components/date-picker/date-picker.d.ts +29 -0
  23. package/dist/components/date-picker/date-picker.js +663 -0
  24. package/dist/components/date-picker/presets.d.ts +9 -0
  25. package/dist/components/date-picker/presets.js +36 -0
  26. package/dist/components/date-picker/range-picker.d.ts +30 -0
  27. package/dist/components/date-picker/range-picker.js +432 -0
  28. package/dist/components/date-picker/types.d.ts +39 -0
  29. package/dist/components/date-picker/types.js +7 -0
  30. package/dist/components/drawer/drawer.css +1112 -0
  31. package/dist/components/drawer/drawer.d.ts +17 -0
  32. package/dist/components/drawer/drawer.js +184 -0
  33. package/dist/components/form-actions/form-actions.d.ts +12 -0
  34. package/dist/components/form-actions/form-actions.js +42 -0
  35. package/dist/components/form-field/form-field.d.ts +17 -0
  36. package/dist/components/form-field/form-field.js +101 -0
  37. package/dist/components/form-field/form.css +1036 -0
  38. package/dist/components/form-section/form-section.d.ts +14 -0
  39. package/dist/components/form-section/form-section.js +92 -0
  40. package/dist/components/input/input.css +1185 -0
  41. package/dist/components/input/input.d.ts +15 -0
  42. package/dist/components/input/input.js +143 -0
  43. package/dist/components/pagination/pagination.css +1099 -0
  44. package/dist/components/pagination/pagination.d.ts +22 -0
  45. package/dist/components/pagination/pagination.js +310 -0
  46. package/dist/components/radio/radio.css +1045 -0
  47. package/dist/components/radio/radio.d.ts +34 -0
  48. package/dist/components/radio/radio.js +215 -0
  49. package/dist/components/scroll-area/scroll-area.css +1099 -0
  50. package/dist/components/scroll-area/scroll-area.d.ts +33 -0
  51. package/dist/components/scroll-area/scroll-area.js +375 -0
  52. package/dist/components/select/mobile-select.css +1044 -0
  53. package/dist/components/select/mobile-select.d.ts +19 -0
  54. package/dist/components/select/mobile-select.js +224 -0
  55. package/dist/components/select/select.css +1327 -0
  56. package/dist/components/select/select.d.ts +32 -0
  57. package/dist/components/select/select.js +532 -0
  58. package/dist/components/select/use-is-mobile.d.ts +1 -0
  59. package/dist/components/select/use-is-mobile.js +30 -0
  60. package/dist/components/splitter/splitter.css +1104 -0
  61. package/dist/components/splitter/splitter.d.ts +33 -0
  62. package/dist/components/splitter/splitter.js +451 -0
  63. package/dist/components/switch/switch.css +1170 -0
  64. package/dist/components/switch/switch.d.ts +19 -0
  65. package/dist/components/switch/switch.js +143 -0
  66. package/dist/components/table/table.css +1255 -0
  67. package/dist/components/table/table.d.ts +73 -0
  68. package/dist/components/table/table.js +1022 -0
  69. package/dist/components/tabs/tabs.css +1076 -0
  70. package/dist/components/tabs/tabs.d.ts +24 -0
  71. package/dist/components/tabs/tabs.js +256 -0
  72. package/dist/components/tag/tag.css +1124 -0
  73. package/dist/components/tag/tag.d.ts +33 -0
  74. package/dist/components/tag/tag.js +237 -0
  75. package/dist/index.d.ts +23 -0
  76. package/dist/index.js +23 -0
  77. package/dist/layouts/form-layout/form-layout.d.ts +6 -0
  78. package/dist/layouts/form-layout/form-layout.js +18 -0
  79. package/dist/layouts/stack/layout.css +1003 -0
  80. package/dist/layouts/stack/stack.d.ts +9 -0
  81. package/dist/layouts/stack/stack.js +27 -0
  82. package/dist/number-input/cursor.d.ts +9 -0
  83. package/dist/number-input/cursor.js +44 -0
  84. package/dist/number-input/format.d.ts +5 -0
  85. package/dist/number-input/format.js +50 -0
  86. package/dist/number-input/index.d.ts +5 -0
  87. package/dist/number-input/index.js +2 -0
  88. package/dist/number-input/number-input.d.ts +9 -0
  89. package/dist/number-input/number-input.js +101 -0
  90. package/dist/number-input/percentage.d.ts +3 -0
  91. package/dist/number-input/percentage.js +28 -0
  92. package/dist/number-input/types.d.ts +5 -0
  93. package/dist/number-input/types.js +0 -0
  94. package/dist/number-input/use-number-input.d.ts +30 -0
  95. package/dist/number-input/use-number-input.js +211 -0
  96. package/dist/number-input/validate.d.ts +3 -0
  97. package/dist/number-input/validate.js +17 -0
  98. package/dist/provider/tao-provider.d.ts +42 -0
  99. package/dist/provider/tao-provider.js +67 -0
  100. package/dist/theme/control.css +1061 -0
  101. package/dist/theme/theme.css +957 -0
  102. package/dist/utils/semantic.d.ts +10 -0
  103. package/dist/utils/semantic.js +5 -0
  104. package/llms.txt +67 -0
  105. package/package.json +97 -0
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ import './layout.css';
3
+ export interface StackProps {
4
+ direction?: 'vertical' | 'horizontal';
5
+ gap?: 'sm' | 'md' | 'lg';
6
+ align?: 'start' | 'center' | 'end' | 'stretch';
7
+ children: ReactNode;
8
+ }
9
+ export declare function Stack({ direction, gap, align, children, }: StackProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import "./layout.css";
4
+ function Stack(t0) {
5
+ const $ = c(5);
6
+ const { direction: t1, gap: t2, align: t3, children } = t0;
7
+ const direction = void 0 === t1 ? "vertical" : t1;
8
+ const gap = void 0 === t2 ? "md" : t2;
9
+ const align = void 0 === t3 ? "stretch" : t3;
10
+ let t4;
11
+ if ($[0] !== align || $[1] !== children || $[2] !== direction || $[3] !== gap) {
12
+ t4 = /*#__PURE__*/ jsx("div", {
13
+ "data-tao-stack": "",
14
+ "data-tao-direction": direction,
15
+ "data-tao-gap": gap,
16
+ "data-tao-align": align,
17
+ children: children
18
+ });
19
+ $[0] = align;
20
+ $[1] = children;
21
+ $[2] = direction;
22
+ $[3] = gap;
23
+ $[4] = t4;
24
+ } else t4 = $[4];
25
+ return t4;
26
+ }
27
+ export { Stack };
@@ -0,0 +1,9 @@
1
+ export declare function countAnchored(display: string, upTo: number, thousandsSeparator: string): number;
2
+ export declare function findCursorAt(display: string, anchorCount: number, thousandsSeparator: string): number;
3
+ export declare function reposition(args: {
4
+ before: string;
5
+ beforeCursor: number;
6
+ after: string;
7
+ thousandsSeparator: string;
8
+ }): number;
9
+ export declare function isThousandSepBeforeCursor(display: string, cursor: number, thousandsSeparator: string): boolean;
@@ -0,0 +1,44 @@
1
+ function countAnchored(display, upTo, thousandsSeparator) {
2
+ const limit = Math.min(upTo, display.length);
3
+ if (!thousandsSeparator) return Math.max(0, limit);
4
+ let count = 0;
5
+ for(let i = 0; i < limit; i++)if (display[i] !== thousandsSeparator) count++;
6
+ return count;
7
+ }
8
+ function findCursorAt(display, anchorCount, thousandsSeparator) {
9
+ if (anchorCount <= 0) return 0;
10
+ if (!thousandsSeparator) return Math.min(anchorCount, display.length);
11
+ 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;
15
+ }
16
+ return display.length;
17
+ }
18
+ function countAnchoredFromEnd(display, fromPos, thousandsSeparator) {
19
+ if (fromPos >= display.length) return 0;
20
+ if (!thousandsSeparator) return display.length - Math.max(0, fromPos);
21
+ let count = 0;
22
+ for(let i = Math.max(0, fromPos); i < display.length; i++)if (display[i] !== thousandsSeparator) count++;
23
+ return count;
24
+ }
25
+ function findCursorFromEnd(display, anchoredFromEnd, thousandsSeparator) {
26
+ if (anchoredFromEnd <= 0) return display.length;
27
+ if (!thousandsSeparator) return Math.max(0, display.length - anchoredFromEnd);
28
+ let count = 0;
29
+ for(let i = display.length - 1; i >= 0; i--){
30
+ if (display[i] !== thousandsSeparator) count++;
31
+ if (count === anchoredFromEnd) return i;
32
+ }
33
+ return 0;
34
+ }
35
+ function reposition(args) {
36
+ const { before, beforeCursor, after, thousandsSeparator } = args;
37
+ const fromEnd = countAnchoredFromEnd(before, beforeCursor, thousandsSeparator);
38
+ return findCursorFromEnd(after, fromEnd, thousandsSeparator);
39
+ }
40
+ function isThousandSepBeforeCursor(display, cursor, thousandsSeparator) {
41
+ if (!thousandsSeparator || cursor <= 0) return false;
42
+ return display[cursor - 1] === thousandsSeparator;
43
+ }
44
+ export { countAnchored, findCursorAt, isThousandSepBeforeCursor, reposition };
@@ -0,0 +1,5 @@
1
+ import type { FormatOptions, PadDecimalsOnBlur } from './types';
2
+ export declare function format(canonical: string, opts: FormatOptions): string;
3
+ export declare function parse(display: string, opts: FormatOptions): string;
4
+ export declare function truncateDecimals(canonical: string, decimalPlaces: number): string;
5
+ export declare function padOnBlur(canonical: string, decimalPlaces: number, mode: PadDecimalsOnBlur): string;
@@ -0,0 +1,50 @@
1
+ const THOUSAND_SEP_REGEX = /\B(?=(\d{3})+(?!\d))/g;
2
+ function format(canonical, opts) {
3
+ if ('' === canonical || '-' === canonical) return canonical;
4
+ const negative = canonical.startsWith('-');
5
+ const abs = negative ? canonical.slice(1) : canonical;
6
+ const dotIndex = abs.indexOf('.');
7
+ const intPart = -1 === dotIndex ? abs : abs.slice(0, dotIndex);
8
+ const fracPart = -1 === dotIndex ? '' : abs.slice(dotIndex + 1);
9
+ const groupedInt = opts.thousandsSeparator ? intPart.replace(THOUSAND_SEP_REGEX, opts.thousandsSeparator) : intPart;
10
+ let result = groupedInt;
11
+ if (-1 !== dotIndex) result += opts.decimalSeparator + fracPart;
12
+ return (negative ? '-' : '') + result;
13
+ }
14
+ function parse(display, opts) {
15
+ if (!display) return '';
16
+ const negative = display.startsWith('-');
17
+ const body = negative ? display.slice(1) : display;
18
+ let cleaned = '';
19
+ let seenDecimal = false;
20
+ for (const ch of body)if (ch >= '0' && ch <= '9') cleaned += ch;
21
+ else if (ch === opts.decimalSeparator && !seenDecimal) {
22
+ cleaned += '.';
23
+ seenDecimal = true;
24
+ }
25
+ if (cleaned.startsWith('.')) cleaned = `0${cleaned}`;
26
+ return (negative ? '-' : '') + cleaned;
27
+ }
28
+ function truncateDecimals(canonical, decimalPlaces) {
29
+ const dotIndex = canonical.indexOf('.');
30
+ if (-1 === dotIndex) return canonical;
31
+ if (0 === decimalPlaces) return canonical.slice(0, dotIndex);
32
+ return canonical.slice(0, dotIndex + 1 + decimalPlaces);
33
+ }
34
+ function padOnBlur(canonical, decimalPlaces, mode) {
35
+ if ('never' === mode) return canonical;
36
+ if ('' === canonical || '-' === canonical) return canonical;
37
+ const dotIndex = canonical.indexOf('.');
38
+ const hasDot = -1 !== dotIndex;
39
+ const fracLen = hasDot ? canonical.length - dotIndex - 1 : 0;
40
+ if ('whenHasDecimal' === mode) {
41
+ if (!hasDot || 0 === fracLen) return hasDot ? canonical.slice(0, dotIndex) : canonical;
42
+ if (fracLen >= decimalPlaces) return canonical;
43
+ return canonical + '0'.repeat(decimalPlaces - fracLen);
44
+ }
45
+ if (0 === decimalPlaces) return hasDot ? canonical.slice(0, dotIndex) : canonical;
46
+ if (!hasDot) return `${canonical}.${'0'.repeat(decimalPlaces)}`;
47
+ if (fracLen >= decimalPlaces) return canonical;
48
+ return canonical + '0'.repeat(decimalPlaces - fracLen);
49
+ }
50
+ export { format, padOnBlur, parse, truncateDecimals };
@@ -0,0 +1,5 @@
1
+ export type { NumberInputProps } from './number-input';
2
+ export { NumberInput } from './number-input';
3
+ export type { FormatOptions, PadDecimalsOnBlur } from './types';
4
+ export type { UseNumberInputOptions, UseNumberInputReturn, } from './use-number-input';
5
+ export { useNumberInput } from './use-number-input';
@@ -0,0 +1,2 @@
1
+ export { NumberInput } from "./number-input.js";
2
+ export { useNumberInput } from "./use-number-input.js";
@@ -0,0 +1,9 @@
1
+ import type { InputHTMLAttributes, ReactNode } from 'react';
2
+ import { type UseNumberInputOptions } from './use-number-input';
3
+ export interface NumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'min' | 'max' | 'prefix'>, UseNumberInputOptions {
4
+ prefix?: ReactNode;
5
+ suffix?: ReactNode;
6
+ containerClassName?: string;
7
+ className?: string;
8
+ }
9
+ export declare function NumberInput(props: NumberInputProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,101 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { useNumberInput } from "./use-number-input.js";
4
+ const HOOK_KEYS = [
5
+ 'value',
6
+ 'defaultValue',
7
+ 'onChange',
8
+ 'onBlur',
9
+ 'decimalSeparator',
10
+ 'thousandsSeparator',
11
+ 'decimalPlaces',
12
+ 'padDecimalsOnBlur',
13
+ 'isPercentage',
14
+ 'allowNegative',
15
+ 'min',
16
+ 'max'
17
+ ];
18
+ function NumberInput(props) {
19
+ const $ = c(20);
20
+ let className;
21
+ let containerClassName;
22
+ let hookOpts;
23
+ let nativeAttrs;
24
+ let prefix;
25
+ let suffix;
26
+ if ($[0] !== props) {
27
+ const { prefix: t0, suffix: t1, containerClassName: t2, className: t3, ...rest } = props;
28
+ prefix = t0;
29
+ suffix = t1;
30
+ containerClassName = t2;
31
+ className = t3;
32
+ hookOpts = {};
33
+ nativeAttrs = {};
34
+ for (const [key, val] of Object.entries(rest))if (HOOK_KEYS.includes(key)) hookOpts[key] = val;
35
+ else nativeAttrs[key] = val;
36
+ $[0] = props;
37
+ $[1] = className;
38
+ $[2] = containerClassName;
39
+ $[3] = hookOpts;
40
+ $[4] = nativeAttrs;
41
+ $[5] = prefix;
42
+ $[6] = suffix;
43
+ } else {
44
+ className = $[1];
45
+ containerClassName = $[2];
46
+ hookOpts = $[3];
47
+ nativeAttrs = $[4];
48
+ prefix = $[5];
49
+ suffix = $[6];
50
+ }
51
+ const { inputProps } = useNumberInput(hookOpts);
52
+ let t0;
53
+ if ($[7] !== prefix) {
54
+ t0 = void 0 !== prefix && /*#__PURE__*/ jsx("span", {
55
+ "data-tao-prefix": "",
56
+ children: prefix
57
+ });
58
+ $[7] = prefix;
59
+ $[8] = t0;
60
+ } else t0 = $[8];
61
+ let t1;
62
+ if ($[9] !== className || $[10] !== inputProps || $[11] !== nativeAttrs) {
63
+ t1 = /*#__PURE__*/ jsx("input", {
64
+ ...nativeAttrs,
65
+ ...inputProps,
66
+ className: className
67
+ });
68
+ $[9] = className;
69
+ $[10] = inputProps;
70
+ $[11] = nativeAttrs;
71
+ $[12] = t1;
72
+ } else t1 = $[12];
73
+ let t2;
74
+ if ($[13] !== suffix) {
75
+ t2 = void 0 !== suffix && /*#__PURE__*/ jsx("span", {
76
+ "data-tao-suffix": "",
77
+ children: suffix
78
+ });
79
+ $[13] = suffix;
80
+ $[14] = t2;
81
+ } else t2 = $[14];
82
+ let t3;
83
+ if ($[15] !== containerClassName || $[16] !== t0 || $[17] !== t1 || $[18] !== t2) {
84
+ t3 = /*#__PURE__*/ jsxs("span", {
85
+ className: containerClassName,
86
+ "data-tao-number-input": "",
87
+ children: [
88
+ t0,
89
+ t1,
90
+ t2
91
+ ]
92
+ });
93
+ $[15] = containerClassName;
94
+ $[16] = t0;
95
+ $[17] = t1;
96
+ $[18] = t2;
97
+ $[19] = t3;
98
+ } else t3 = $[19];
99
+ return t3;
100
+ }
101
+ export { NumberInput };
@@ -0,0 +1,3 @@
1
+ export declare function shiftDecimal(value: string, places: number): string;
2
+ export declare function fromPercent(displayValue: string): string;
3
+ export declare function toPercent(actualValue: string): string;
@@ -0,0 +1,28 @@
1
+ function shiftDecimal(value, places) {
2
+ if (0 === places) return value;
3
+ if ('' === value || '-' === value) return value;
4
+ const negative = value.startsWith('-');
5
+ const abs = negative ? value.slice(1) : value;
6
+ const [intPart = '0', fracPart = ''] = abs.split('.');
7
+ const digits = intPart + fracPart;
8
+ const newDecimalPos = intPart.length + places;
9
+ let result;
10
+ result = newDecimalPos <= 0 ? `0.${'0'.repeat(-newDecimalPos)}${digits}` : newDecimalPos >= digits.length ? digits + '0'.repeat(newDecimalPos - digits.length) : `${digits.slice(0, newDecimalPos)}.${digits.slice(newDecimalPos)}`;
11
+ return (negative ? '-' : '') + cleanup(result);
12
+ }
13
+ function fromPercent(displayValue) {
14
+ return shiftDecimal(displayValue, -2);
15
+ }
16
+ function toPercent(actualValue) {
17
+ return shiftDecimal(actualValue, 2);
18
+ }
19
+ function cleanup(s) {
20
+ if (s.includes('.')) {
21
+ s = s.replace(/0+$/, '');
22
+ s = s.replace(/\.$/, '');
23
+ }
24
+ s = s.replace(/^0+(?=\d)/, '');
25
+ if ('' === s) return '0';
26
+ return s;
27
+ }
28
+ export { fromPercent, shiftDecimal, toPercent };
@@ -0,0 +1,5 @@
1
+ export type PadDecimalsOnBlur = 'never' | 'always' | 'whenHasDecimal';
2
+ export interface FormatOptions {
3
+ decimalSeparator: '.' | ',';
4
+ thousandsSeparator: ',' | '.' | "'" | ' ' | '';
5
+ }
File without changes
@@ -0,0 +1,30 @@
1
+ import { type ChangeEvent, type FocusEvent, type KeyboardEvent, type RefObject } from 'react';
2
+ import type { PadDecimalsOnBlur } from './types';
3
+ export interface UseNumberInputOptions {
4
+ value?: string;
5
+ defaultValue?: string;
6
+ onChange?: (value: string) => void;
7
+ onBlur?: (value: string) => void;
8
+ decimalSeparator?: '.' | ',';
9
+ thousandsSeparator?: ',' | '.' | "'" | ' ' | '';
10
+ decimalPlaces?: number;
11
+ padDecimalsOnBlur?: PadDecimalsOnBlur;
12
+ isPercentage?: boolean;
13
+ allowNegative?: boolean;
14
+ min?: number;
15
+ max?: number;
16
+ }
17
+ export interface UseNumberInputReturn {
18
+ inputProps: {
19
+ value: string;
20
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
21
+ onBlur: (e: FocusEvent<HTMLInputElement>) => void;
22
+ onFocus: (e: FocusEvent<HTMLInputElement>) => void;
23
+ onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
24
+ ref: RefObject<HTMLInputElement | null>;
25
+ inputMode: 'decimal' | 'numeric';
26
+ };
27
+ value: string;
28
+ displayValue: string;
29
+ }
30
+ export declare function useNumberInput(opts: UseNumberInputOptions): UseNumberInputReturn;
@@ -0,0 +1,211 @@
1
+ import { c } from "react/compiler-runtime";
2
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { isThousandSepBeforeCursor, reposition } from "./cursor.js";
4
+ import { format, padOnBlur, parse, truncateDecimals } from "./format.js";
5
+ import { fromPercent, toPercent } from "./percentage.js";
6
+ import { clampToRange, isValidCanonical, stripDisallowedSign } from "./validate.js";
7
+ function useNumberInput(opts) {
8
+ const $ = c(53);
9
+ const { value, defaultValue, onChange, onBlur, decimalSeparator: t0, thousandsSeparator: t1, decimalPlaces: t2, padDecimalsOnBlur: t3, isPercentage: t4, allowNegative: t5, min, max } = opts;
10
+ const decimalSeparator = void 0 === t0 ? "." : t0;
11
+ const thousandsSeparator = void 0 === t1 ? "," : t1;
12
+ const decimalPlaces = void 0 === t2 ? 2 : t2;
13
+ const padMode = void 0 === t3 ? "never" : t3;
14
+ const isPercentage = void 0 === t4 ? false : t4;
15
+ const allowNegative = void 0 === t5 ? false : t5;
16
+ let t6;
17
+ if ($[0] !== decimalSeparator || $[1] !== thousandsSeparator) {
18
+ t6 = {
19
+ decimalSeparator,
20
+ thousandsSeparator
21
+ };
22
+ $[0] = decimalSeparator;
23
+ $[1] = thousandsSeparator;
24
+ $[2] = t6;
25
+ } else t6 = $[2];
26
+ const fmtOpts = t6;
27
+ let t7;
28
+ if ($[3] !== fmtOpts || $[4] !== isPercentage) {
29
+ t7 = (actual)=>{
30
+ const canonical = isPercentage ? toPercent(actual) : actual;
31
+ return format(canonical, fmtOpts);
32
+ };
33
+ $[3] = fmtOpts;
34
+ $[4] = isPercentage;
35
+ $[5] = t7;
36
+ } else t7 = $[5];
37
+ const canonicalToDisplay = t7;
38
+ let t8;
39
+ if ($[6] !== canonicalToDisplay || $[7] !== defaultValue || $[8] !== value) {
40
+ t8 = ()=>canonicalToDisplay(value ?? defaultValue ?? "");
41
+ $[6] = canonicalToDisplay;
42
+ $[7] = defaultValue;
43
+ $[8] = value;
44
+ $[9] = t8;
45
+ } else t8 = $[9];
46
+ const [displayBuffer, setDisplayBuffer] = useState(t8);
47
+ const isFocusedRef = useRef(false);
48
+ const inputRef = useRef(null);
49
+ const pendingCursorRef = useRef(null);
50
+ let t9;
51
+ if ($[10] !== canonicalToDisplay || $[11] !== value) {
52
+ t9 = ()=>{
53
+ if (void 0 === value) return;
54
+ if (isFocusedRef.current) return;
55
+ const display = canonicalToDisplay(value);
56
+ setDisplayBuffer((prev)=>prev === display ? prev : display);
57
+ };
58
+ $[10] = canonicalToDisplay;
59
+ $[11] = value;
60
+ $[12] = t9;
61
+ } else t9 = $[12];
62
+ let t10;
63
+ if ($[13] !== value) {
64
+ t10 = [
65
+ value
66
+ ];
67
+ $[13] = value;
68
+ $[14] = t10;
69
+ } else t10 = $[14];
70
+ useEffect(t9, t10);
71
+ let t11;
72
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
73
+ t11 = ()=>{
74
+ if (null === pendingCursorRef.current) return;
75
+ const pos = pendingCursorRef.current;
76
+ inputRef.current?.setSelectionRange(pos, pos);
77
+ pendingCursorRef.current = null;
78
+ };
79
+ $[15] = t11;
80
+ } else t11 = $[15];
81
+ let t12;
82
+ if ($[16] !== displayBuffer) {
83
+ t12 = [
84
+ displayBuffer
85
+ ];
86
+ $[16] = displayBuffer;
87
+ $[17] = t12;
88
+ } else t12 = $[17];
89
+ useLayoutEffect(t11, t12);
90
+ let t13;
91
+ if ($[18] !== allowNegative || $[19] !== decimalPlaces || $[20] !== fmtOpts || $[21] !== isPercentage || $[22] !== onChange || $[23] !== thousandsSeparator) {
92
+ t13 = (e)=>{
93
+ const raw = e.target.value;
94
+ const cursor = e.target.selectionStart ?? raw.length;
95
+ let canonical_0 = parse(raw, fmtOpts);
96
+ canonical_0 = stripDisallowedSign(canonical_0, allowNegative);
97
+ canonical_0 = truncateDecimals(canonical_0, decimalPlaces);
98
+ if (!isValidCanonical(canonical_0)) return;
99
+ const newDisplay = format(canonical_0, fmtOpts);
100
+ pendingCursorRef.current = reposition({
101
+ before: raw,
102
+ beforeCursor: cursor,
103
+ after: newDisplay,
104
+ thousandsSeparator
105
+ });
106
+ setDisplayBuffer(newDisplay);
107
+ const actual_0 = isPercentage ? fromPercent(canonical_0) : canonical_0;
108
+ onChange?.(actual_0);
109
+ };
110
+ $[18] = allowNegative;
111
+ $[19] = decimalPlaces;
112
+ $[20] = fmtOpts;
113
+ $[21] = isPercentage;
114
+ $[22] = onChange;
115
+ $[23] = thousandsSeparator;
116
+ $[24] = t13;
117
+ } else t13 = $[24];
118
+ const handleChange = t13;
119
+ let t14;
120
+ if ($[25] !== decimalPlaces || $[26] !== displayBuffer || $[27] !== fmtOpts || $[28] !== isPercentage || $[29] !== max || $[30] !== min || $[31] !== onBlur || $[32] !== onChange || $[33] !== padMode) {
121
+ t14 = ()=>{
122
+ isFocusedRef.current = false;
123
+ const raw_0 = inputRef.current?.value ?? displayBuffer;
124
+ let canonical_1 = parse(raw_0, fmtOpts);
125
+ canonical_1 = padOnBlur(canonical_1, decimalPlaces, padMode);
126
+ let actual_1 = isPercentage ? fromPercent(canonical_1) : canonical_1;
127
+ actual_1 = clampToRange(actual_1, min, max);
128
+ const canonicalAfter = isPercentage ? toPercent(actual_1) : actual_1;
129
+ const newDisplay_0 = format(canonicalAfter, fmtOpts);
130
+ setDisplayBuffer(newDisplay_0);
131
+ onChange?.(actual_1);
132
+ onBlur?.(actual_1);
133
+ };
134
+ $[25] = decimalPlaces;
135
+ $[26] = displayBuffer;
136
+ $[27] = fmtOpts;
137
+ $[28] = isPercentage;
138
+ $[29] = max;
139
+ $[30] = min;
140
+ $[31] = onBlur;
141
+ $[32] = onChange;
142
+ $[33] = padMode;
143
+ $[34] = t14;
144
+ } else t14 = $[34];
145
+ const handleBlur = t14;
146
+ let t15;
147
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
148
+ t15 = ()=>{
149
+ isFocusedRef.current = true;
150
+ };
151
+ $[35] = t15;
152
+ } else t15 = $[35];
153
+ const handleFocus = t15;
154
+ let t16;
155
+ if ($[36] !== displayBuffer || $[37] !== thousandsSeparator) {
156
+ t16 = (e_0)=>{
157
+ if ("Backspace" !== e_0.key) return;
158
+ const el = inputRef.current;
159
+ if (!el) return;
160
+ const cursor_0 = el.selectionStart ?? 0;
161
+ if (cursor_0 > 0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) el.setSelectionRange(cursor_0 - 1, cursor_0 - 1);
162
+ };
163
+ $[36] = displayBuffer;
164
+ $[37] = thousandsSeparator;
165
+ $[38] = t16;
166
+ } else t16 = $[38];
167
+ const handleKeyDown = t16;
168
+ let t17;
169
+ if ($[39] !== displayBuffer || $[40] !== fmtOpts || $[41] !== isPercentage) {
170
+ const canonical_2 = parse(displayBuffer, fmtOpts);
171
+ t17 = isPercentage ? fromPercent(canonical_2) : canonical_2;
172
+ $[39] = displayBuffer;
173
+ $[40] = fmtOpts;
174
+ $[41] = isPercentage;
175
+ $[42] = t17;
176
+ } else t17 = $[42];
177
+ const derivedActual = t17;
178
+ const t18 = decimalPlaces > 0 ? "decimal" : "numeric";
179
+ let t19;
180
+ if ($[43] !== displayBuffer || $[44] !== handleBlur || $[45] !== handleChange || $[46] !== handleKeyDown || $[47] !== t18) {
181
+ t19 = {
182
+ value: displayBuffer,
183
+ onChange: handleChange,
184
+ onBlur: handleBlur,
185
+ onFocus: handleFocus,
186
+ onKeyDown: handleKeyDown,
187
+ ref: inputRef,
188
+ inputMode: t18
189
+ };
190
+ $[43] = displayBuffer;
191
+ $[44] = handleBlur;
192
+ $[45] = handleChange;
193
+ $[46] = handleKeyDown;
194
+ $[47] = t18;
195
+ $[48] = t19;
196
+ } else t19 = $[48];
197
+ let t20;
198
+ if ($[49] !== derivedActual || $[50] !== displayBuffer || $[51] !== t19) {
199
+ t20 = {
200
+ inputProps: t19,
201
+ value: derivedActual,
202
+ displayValue: displayBuffer
203
+ };
204
+ $[49] = derivedActual;
205
+ $[50] = displayBuffer;
206
+ $[51] = t19;
207
+ $[52] = t20;
208
+ } else t20 = $[52];
209
+ return t20;
210
+ }
211
+ export { useNumberInput };
@@ -0,0 +1,3 @@
1
+ export declare function isValidCanonical(canonical: string): boolean;
2
+ export declare function stripDisallowedSign(canonical: string, allowNegative: boolean): string;
3
+ export declare function clampToRange(canonical: string, min: number | undefined, max: number | undefined): string;
@@ -0,0 +1,17 @@
1
+ const CANONICAL_REGEX = /^-?\d*\.?\d*$/;
2
+ function isValidCanonical(canonical) {
3
+ return CANONICAL_REGEX.test(canonical);
4
+ }
5
+ function stripDisallowedSign(canonical, allowNegative) {
6
+ if (allowNegative) return canonical;
7
+ return canonical.startsWith('-') ? canonical.slice(1) : canonical;
8
+ }
9
+ function clampToRange(canonical, min, max) {
10
+ if ('' === canonical || '-' === canonical) return canonical;
11
+ const n = Number(canonical);
12
+ if (!Number.isFinite(n)) return canonical;
13
+ if (void 0 !== min && n < min) return String(min);
14
+ if (void 0 !== max && n > max) return String(max);
15
+ return canonical;
16
+ }
17
+ export { clampToRange, isValidCanonical, stripDisallowedSign };
@@ -0,0 +1,42 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface TaoSeedToken {
3
+ colorPrimary?: string;
4
+ colorSuccess?: string;
5
+ colorWarning?: string;
6
+ colorError?: string;
7
+ colorBgBase?: string;
8
+ colorTextBase?: string;
9
+ borderRadius?: number;
10
+ fontSize?: number;
11
+ controlHeight?: number;
12
+ sizeUnit?: number;
13
+ sizeStep?: number;
14
+ lineWidth?: number;
15
+ fontFamily?: string;
16
+ fontFamilyCode?: string;
17
+ motionUnit?: number;
18
+ motion?: boolean;
19
+ zIndexBase?: number;
20
+ zIndexPopupBase?: number;
21
+ }
22
+ export interface TaoThemeConfig {
23
+ token?: Partial<TaoSeedToken>;
24
+ inherit?: boolean;
25
+ }
26
+ export type TaoSize = 'small' | 'medium' | 'large';
27
+ export type TaoVariant = 'outlined' | 'filled' | 'borderless';
28
+ interface TaoConfigContextValue {
29
+ size: TaoSize;
30
+ disabled: boolean;
31
+ variant: TaoVariant;
32
+ }
33
+ export declare function useTaoConfig(): TaoConfigContextValue;
34
+ export interface TaoProviderProps {
35
+ children: ReactNode;
36
+ theme?: TaoThemeConfig;
37
+ size?: TaoSize;
38
+ disabled?: boolean;
39
+ variant?: TaoVariant;
40
+ }
41
+ export declare function TaoProvider({ theme, size, disabled, variant, children, }: TaoProviderProps): import("react/jsx-runtime").JSX.Element;
42
+ export {};