@douyinfe/semi-foundation 2.76.1 → 2.78.0-alpha.2

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 (35) hide show
  1. package/inputNumber/foundation.ts +176 -10
  2. package/lib/cjs/inputNumber/foundation.d.ts +15 -1
  3. package/lib/cjs/inputNumber/foundation.js +169 -8
  4. package/lib/cjs/markdownRender/foundation.d.ts +1 -1
  5. package/lib/cjs/tooltip/foundation.d.ts +5 -0
  6. package/lib/cjs/tooltip/foundation.js +22 -0
  7. package/lib/cjs/userGuide/animation.scss +2 -0
  8. package/lib/cjs/userGuide/constants.d.ts +15 -0
  9. package/lib/cjs/userGuide/constants.js +21 -0
  10. package/lib/cjs/userGuide/foundation.d.ts +24 -0
  11. package/lib/cjs/userGuide/foundation.js +82 -0
  12. package/lib/cjs/userGuide/userGuide.css +109 -0
  13. package/lib/cjs/userGuide/userGuide.scss +143 -0
  14. package/lib/cjs/userGuide/variables.scss +48 -0
  15. package/lib/es/inputNumber/foundation.d.ts +15 -1
  16. package/lib/es/inputNumber/foundation.js +169 -8
  17. package/lib/es/markdownRender/foundation.d.ts +1 -1
  18. package/lib/es/tooltip/foundation.d.ts +5 -0
  19. package/lib/es/tooltip/foundation.js +22 -0
  20. package/lib/es/userGuide/animation.scss +2 -0
  21. package/lib/es/userGuide/constants.d.ts +15 -0
  22. package/lib/es/userGuide/constants.js +16 -0
  23. package/lib/es/userGuide/foundation.d.ts +24 -0
  24. package/lib/es/userGuide/foundation.js +74 -0
  25. package/lib/es/userGuide/userGuide.css +109 -0
  26. package/lib/es/userGuide/userGuide.scss +143 -0
  27. package/lib/es/userGuide/variables.scss +48 -0
  28. package/markdownRender/foundation.ts +2 -1
  29. package/package.json +4 -4
  30. package/tooltip/foundation.ts +26 -2
  31. package/userGuide/animation.scss +2 -0
  32. package/userGuide/constants.ts +35 -0
  33. package/userGuide/foundation.ts +87 -0
  34. package/userGuide/userGuide.scss +143 -0
  35. package/userGuide/variables.scss +48 -0
@@ -23,7 +23,8 @@ export interface InputNumberAdapter extends DefaultAdapter {
23
23
  restoreCursor: (str?: string) => boolean;
24
24
  fixCaret: (start: number, end: number) => void;
25
25
  setClickUpOrDown: (clicked: boolean) => void;
26
- updateStates: (states: BaseInputNumberState, callback?: () => void) => void
26
+ updateStates: (states: BaseInputNumberState, callback?: () => void) => void;
27
+ getInputCharacter: (index: number) => string
27
28
  }
28
29
 
29
30
  export interface BaseInputNumberState {
@@ -38,8 +39,13 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
38
39
  _interval: any;
39
40
  _timerHasRegistered: boolean;
40
41
  _timer: any;
42
+ _decimalPointSymbol: string = undefined;
43
+ _currencySymbol: string = '';
41
44
 
42
45
  init() {
46
+ if (this._isCurrency()) {
47
+ this._setCurrencySymbol();
48
+ }
43
49
  this._setInitValue();
44
50
  }
45
51
 
@@ -53,6 +59,16 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
53
59
  return this._isControlledComponent('value');
54
60
  }
55
61
 
62
+ _isCurrency() {
63
+ const { currency } = this.getProps();
64
+ return currency === true || (typeof currency === 'string' && currency.trim() !== '');
65
+ }
66
+
67
+ _getFinalCurrency() {
68
+ const { currency } = this.getProps();
69
+ return currency === true ? this.getProp('defaultCurrency') : currency;
70
+ }
71
+
56
72
  _doInput(v = '', event: any = null, updateCb: any = null) {
57
73
  let notifyVal = v;
58
74
  let number = v;
@@ -122,6 +138,28 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
122
138
  }
123
139
  }
124
140
 
141
+ _setCurrencySymbol() {
142
+ const { localeCode, currencyDisplay } = this.getProps();
143
+ const parts = new Intl.NumberFormat(localeCode, {
144
+ style: 'currency',
145
+ currency: this._getFinalCurrency() || this.getCurrencyByLocaleCode(),
146
+ currencyDisplay
147
+ }).formatToParts(1234.5);
148
+
149
+ for (const part of parts) {
150
+ if (part.type === 'decimal') {
151
+ this._decimalPointSymbol = part.value;
152
+ console.log('this._decimalPointSymbol: ', this._decimalPointSymbol);
153
+ }
154
+ // if (part.type === 'group') {
155
+ // groupSeparator = part.value;
156
+ // }
157
+ if (part.type === 'currency') {
158
+ this._currencySymbol = part.value;
159
+ }
160
+ }
161
+ }
162
+
125
163
  handleInputFocus(e: any) {
126
164
  const value = this.getState('value');
127
165
 
@@ -198,7 +236,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
198
236
  this._adapter.setNumber(num);
199
237
  }
200
238
 
201
- this._adapter.setValue(this.isControlled() ? formattedNum : this.doFormat(valueAfterParser as unknown as number, false), () => {
239
+ this._adapter.setValue(this.isControlled() && !this._isCurrency() ? formattedNum : this.doFormat(valueAfterParser as unknown as number, false), () => {
202
240
  this._adapter.restoreCursor();
203
241
  });
204
242
 
@@ -242,7 +280,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
242
280
  numHasChanged = true;
243
281
  }
244
282
 
245
- const currentFormattedNum = this.doFormat(currentNumber, true);
283
+ const currentFormattedNum = this.doFormat(currentNumber, true, true);
246
284
 
247
285
  if (currentFormattedNum !== currentValue) {
248
286
  willSetVal = currentFormattedNum;
@@ -366,14 +404,15 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
366
404
  const { defaultValue, value } = this.getProps();
367
405
 
368
406
  const propsValue = this._isControlledComponent('value') ? value : defaultValue;
369
- const tmpNumber = this.doParse(toString(propsValue), false, true, true);
407
+
408
+ const tmpNumber = this.doParse(this._isCurrency() ? propsValue : toString(propsValue), false, true, true);
370
409
 
371
410
  let number = null;
372
411
  if (typeof tmpNumber === 'number' && !isNaN(tmpNumber)) {
373
412
  number = tmpNumber;
374
413
  }
375
414
 
376
- const formattedValue = typeof number === 'number' ? this.doFormat(number, true) : '';
415
+ const formattedValue = typeof number === 'number' ? this.doFormat(number, true, true) : '';
377
416
 
378
417
  this._adapter.setNumber(number);
379
418
  this._adapter.setValue(formattedValue);
@@ -417,7 +456,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
417
456
 
418
457
  // console.log('scale: ', scale, 'curNum: ', curNum);
419
458
 
420
- return this.doFormat(curNum, true);
459
+ return this.doFormat(curNum, true, true);
421
460
  }
422
461
 
423
462
  minus(step?: number, event?: any): string {
@@ -448,19 +487,43 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
448
487
  return toString(num);
449
488
  }
450
489
 
490
+ formatCurrency(value: number | string) {
491
+ const { localeCode, minimumFractionDigits, precision, maximumFractionDigits, currencyDisplay, showCurrencySymbol } = this.getProps();
492
+
493
+ let formattedValue = value;
494
+ if (typeof value === 'string' && Number.isNaN(Number(value))) {
495
+ formattedValue = this.parseInternationalCurrency(value);
496
+ }
497
+
498
+ const formatter = new Intl.NumberFormat(localeCode, {
499
+ style: 'currency',
500
+ currency: this._getFinalCurrency() || this.getCurrencyByLocaleCode(),
501
+ currencyDisplay: currencyDisplay,
502
+ minimumFractionDigits: minimumFractionDigits || precision || undefined,
503
+ maximumFractionDigits: maximumFractionDigits || precision || undefined,
504
+ });
505
+
506
+ const formatted = formatter.format(Number(formattedValue));
507
+ return showCurrencySymbol ? formatted : formatted.replace(this._currencySymbol, '').trim();
508
+ }
509
+
451
510
  /**
452
511
  * format number to string
453
512
  * @param {string|number} value
454
513
  * @param {boolean} needAdjustPrec
455
514
  * @returns {string}
456
515
  */
457
- doFormat(value: string | number = 0, needAdjustPrec = true): string {
516
+ doFormat(value: string | number = 0, needAdjustPrec = true, needAdjustCurrency = false): string {
458
517
  // if (typeof value === 'string') {
459
518
  // return value;
460
519
  // }
520
+ const { formatter } = this.getProps();
461
521
  let str;
462
- const formatter = this.getProp('formatter');
463
- if (needAdjustPrec) {
522
+
523
+ // AdjustCurrency conversion is done only in blur situation, otherwise it is just converted to normal string
524
+ if (this._isCurrency() && needAdjustCurrency) {
525
+ str = this.formatCurrency(value);
526
+ } else if (needAdjustPrec) {
464
527
  str = this._adjustPrec(value);
465
528
  } else {
466
529
  str = toString(value);
@@ -487,6 +550,22 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
487
550
  return current;
488
551
  }
489
552
 
553
+ // 将货币模式的货币转化为纯数字
554
+ // Convert currency in currency mode to pure numbers
555
+ // eg:¥123456.78 to 123456.78
556
+ // eg:123456.78 to 123456.78
557
+ parseInternationalCurrency(currencyString: string) {
558
+ let cleaned = currencyString
559
+ .replace(this._currencySymbol, '')
560
+ .replace(new RegExp(`[^\\d${this._decimalPointSymbol}\\-]`, 'g'), '');
561
+
562
+ // Convert the localized decimal point to the standard decimal point
563
+ if (this._decimalPointSymbol && this._decimalPointSymbol !== '.') {
564
+ cleaned = cleaned.replace(this._decimalPointSymbol, '.');
565
+ }
566
+ return parseFloat(cleaned);
567
+ }
568
+
490
569
  /**
491
570
  * parse to number
492
571
  * @param {string|number} value
@@ -496,6 +575,11 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
496
575
  * @returns {number}
497
576
  */
498
577
  doParse(value: string | number, needCheckPrec = true, needAdjustPrec = false, needAdjustMaxMin = false) {
578
+
579
+ if (this._isCurrency() && typeof value === 'string') {
580
+ value = this.parseInternationalCurrency(value);
581
+ }
582
+
499
583
  if (typeof value === 'number') {
500
584
  if (needAdjustMaxMin) {
501
585
  value = this.fetchMinOrMax(value);
@@ -557,7 +641,11 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
557
641
  return value;
558
642
  }
559
643
  if (typeof value === 'string') {
560
- const parser = this.getProp('parser');
644
+ const { parser } = this.getProps();
645
+
646
+ if (this._isCurrency()) {
647
+ value = this.parseInternationalCurrency(value);
648
+ }
561
649
 
562
650
  if (typeof parser === 'function') {
563
651
  value = parser(value);
@@ -630,6 +718,84 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
630
718
  updateStates(states: BaseInputNumberState, callback?: () => void) {
631
719
  this._adapter.updateStates(states, callback);
632
720
  }
721
+
722
+ /**
723
+ * Get currency by locale code
724
+ * @param {string} localeCode
725
+ * @returns {string}
726
+ */
727
+ getCurrencyByLocaleCode() {
728
+ const { localeCode } = this.getProps();
729
+
730
+ // Mapping table of region codes to currency codes
731
+ const localeToCurrency: Record<string, string> = {
732
+ // Asia
733
+ 'zh-CN': 'CNY', // China
734
+ 'zh-HK': 'HKD', // Hong Kong
735
+ 'zh-TW': 'TWD', // Taiwan
736
+ 'ja-JP': 'JPY', // Japan
737
+ 'ko-KR': 'KRW', // Korea
738
+ 'th-TH': 'THB', // Thailand
739
+ 'vi-VN': 'VND', // Vietnam
740
+ 'ms-MY': 'MYR', // Malaysia
741
+ 'id-ID': 'IDR', // Indonesia
742
+ 'hi-IN': 'INR', // India
743
+ 'ar-SA': 'SAR', // Saudi Arabia
744
+
745
+ // Europe
746
+ 'en-GB': 'GBP', // United Kingdom
747
+ 'de-DE': 'EUR', // Germany
748
+ 'fr-FR': 'EUR', // France
749
+ 'it-IT': 'EUR', // Italy
750
+ 'es-ES': 'EUR', // Spain
751
+ 'pt-PT': 'EUR', // Portugal
752
+ 'ru-RU': 'RUB', // 俄罗斯
753
+
754
+ // North America
755
+ 'en-US': 'USD', // United States
756
+ 'en-CA': 'CAD', // Canada
757
+ 'es-MX': 'MXN', // Mexico
758
+
759
+ // South America
760
+ 'pt-BR': 'BRL', // Brazil
761
+ 'es-AR': 'ARS', // Argentina
762
+
763
+ // Oceania
764
+ 'en-AU': 'AUD', // Australia
765
+ 'en-NZ': 'NZD', // New Zealand
766
+
767
+ // Africa
768
+ 'en-ZA': 'ZAR', // South Africa
769
+ 'ar-EG': 'EGP', // Egypt
770
+ };
771
+
772
+ // Try to match the full region code directly
773
+ if (localeToCurrency[localeCode]) {
774
+ return localeToCurrency[localeCode];
775
+ }
776
+
777
+ // If no direct match, try to match the language part (the first two characters)
778
+ const languageCode = localeCode.split('-')[0];
779
+ const fallbackMap: Record<string, string> = {
780
+ 'en': 'USD', // English defaults to USD
781
+ 'zh': 'CNY', // Chinese defaults to CNY
782
+ 'es': 'EUR', // Spanish defaults to EUR
783
+ 'fr': 'EUR', // French defaults to EUR
784
+ 'de': 'EUR', // German defaults to EUR
785
+ 'it': 'EUR', // Italian defaults to EUR
786
+ 'ja': 'JPY', // Japanese defaults to JPY
787
+ 'ko': 'KRW', // Korean defaults to KRW
788
+ 'ru': 'RUB', // Russian defaults to RUB
789
+ 'ar': 'SAR', // Arabic defaults to SAR
790
+ };
791
+
792
+ if (fallbackMap[languageCode]) {
793
+ return fallbackMap[languageCode];
794
+ }
795
+
796
+ // If no match, return USD as the default value
797
+ return 'USD';
798
+ }
633
799
  }
634
800
 
635
801
  export default InputNumberFoundation;
@@ -19,6 +19,7 @@ export interface InputNumberAdapter extends DefaultAdapter {
19
19
  fixCaret: (start: number, end: number) => void;
20
20
  setClickUpOrDown: (clicked: boolean) => void;
21
21
  updateStates: (states: BaseInputNumberState, callback?: () => void) => void;
22
+ getInputCharacter: (index: number) => string;
22
23
  }
23
24
  export interface BaseInputNumberState {
24
25
  value?: number | string;
@@ -31,14 +32,19 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
31
32
  _interval: any;
32
33
  _timerHasRegistered: boolean;
33
34
  _timer: any;
35
+ _decimalPointSymbol: string;
36
+ _currencySymbol: string;
34
37
  init(): void;
35
38
  destroy(): void;
36
39
  isControlled(): boolean;
40
+ _isCurrency(): boolean;
41
+ _getFinalCurrency(): any;
37
42
  _doInput(v?: string, event?: any, updateCb?: any): void;
38
43
  _registerInterval(cb?: (...args: any) => void): void;
39
44
  _unregisterInterval(): void;
40
45
  _registerTimer(cb: (...args: any[]) => void): void;
41
46
  _unregisterTimer(): void;
47
+ _setCurrencySymbol(): void;
42
48
  handleInputFocus(e: any): void;
43
49
  /**
44
50
  * Input box content update processing
@@ -73,19 +79,21 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
73
79
  */
74
80
  _getPrecLen(num: string | number): number;
75
81
  _adjustPrec(num: string | number): string;
82
+ formatCurrency(value: number | string): string;
76
83
  /**
77
84
  * format number to string
78
85
  * @param {string|number} value
79
86
  * @param {boolean} needAdjustPrec
80
87
  * @returns {string}
81
88
  */
82
- doFormat(value?: string | number, needAdjustPrec?: boolean): string;
89
+ doFormat(value?: string | number, needAdjustPrec?: boolean, needAdjustCurrency?: boolean): string;
83
90
  /**
84
91
  *
85
92
  * @param {number} current
86
93
  * @returns {number}
87
94
  */
88
95
  fetchMinOrMax(current: number): any;
96
+ parseInternationalCurrency(currencyString: string): number;
89
97
  /**
90
98
  * parse to number
91
99
  * @param {string|number} value
@@ -116,5 +124,11 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
116
124
  notifyChange(value: string, e: any): void;
117
125
  notifyNumberChange(value: number, e: any): void;
118
126
  updateStates(states: BaseInputNumberState, callback?: () => void): void;
127
+ /**
128
+ * Get currency by locale code
129
+ * @param {string} localeCode
130
+ * @returns {string}
131
+ */
132
+ getCurrencyByLocaleCode(): string;
119
133
  }
120
134
  export default InputNumberFoundation;
@@ -14,7 +14,15 @@ var _constants = require("./constants");
14
14
  var _number = require("../utils/number");
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  class InputNumberFoundation extends _foundation.default {
17
+ constructor() {
18
+ super(...arguments);
19
+ this._decimalPointSymbol = undefined;
20
+ this._currencySymbol = '';
21
+ }
17
22
  init() {
23
+ if (this._isCurrency()) {
24
+ this._setCurrencySymbol();
25
+ }
18
26
  this._setInitValue();
19
27
  }
20
28
  destroy() {
@@ -25,6 +33,18 @@ class InputNumberFoundation extends _foundation.default {
25
33
  isControlled() {
26
34
  return this._isControlledComponent('value');
27
35
  }
36
+ _isCurrency() {
37
+ const {
38
+ currency
39
+ } = this.getProps();
40
+ return currency === true || typeof currency === 'string' && currency.trim() !== '';
41
+ }
42
+ _getFinalCurrency() {
43
+ const {
44
+ currency
45
+ } = this.getProps();
46
+ return currency === true ? this.getProp('defaultCurrency') : currency;
47
+ }
28
48
  _doInput() {
29
49
  let v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
30
50
  let event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -86,6 +106,29 @@ class InputNumberFoundation extends _foundation.default {
86
106
  this._timer = null;
87
107
  }
88
108
  }
109
+ _setCurrencySymbol() {
110
+ const {
111
+ localeCode,
112
+ currencyDisplay
113
+ } = this.getProps();
114
+ const parts = new Intl.NumberFormat(localeCode, {
115
+ style: 'currency',
116
+ currency: this._getFinalCurrency() || this.getCurrencyByLocaleCode(),
117
+ currencyDisplay
118
+ }).formatToParts(1234.5);
119
+ for (const part of parts) {
120
+ if (part.type === 'decimal') {
121
+ this._decimalPointSymbol = part.value;
122
+ console.log('this._decimalPointSymbol: ', this._decimalPointSymbol);
123
+ }
124
+ // if (part.type === 'group') {
125
+ // groupSeparator = part.value;
126
+ // }
127
+ if (part.type === 'currency') {
128
+ this._currencySymbol = part.value;
129
+ }
130
+ }
131
+ }
89
132
  handleInputFocus(e) {
90
133
  const value = this.getState('value');
91
134
  if (value !== '') {
@@ -156,7 +199,7 @@ class InputNumberFoundation extends _foundation.default {
156
199
  if (!this.isControlled() && (num === null || typeof num === 'number' && !isNaN(num))) {
157
200
  this._adapter.setNumber(num);
158
201
  }
159
- this._adapter.setValue(this.isControlled() ? formattedNum : this.doFormat(valueAfterParser, false), () => {
202
+ this._adapter.setValue(this.isControlled() && !this._isCurrency() ? formattedNum : this.doFormat(valueAfterParser, false), () => {
160
203
  this._adapter.restoreCursor();
161
204
  });
162
205
  this.notifyChange(notifyVal, event);
@@ -189,7 +232,7 @@ class InputNumberFoundation extends _foundation.default {
189
232
  }
190
233
  numHasChanged = true;
191
234
  }
192
- const currentFormattedNum = this.doFormat(currentNumber, true);
235
+ const currentFormattedNum = this.doFormat(currentNumber, true, true);
193
236
  if (currentFormattedNum !== currentValue) {
194
237
  willSetVal = currentFormattedNum;
195
238
  strHasChanged = true;
@@ -303,12 +346,12 @@ class InputNumberFoundation extends _foundation.default {
303
346
  value
304
347
  } = this.getProps();
305
348
  const propsValue = this._isControlledComponent('value') ? value : defaultValue;
306
- const tmpNumber = this.doParse((0, _toString2.default)(propsValue), false, true, true);
349
+ const tmpNumber = this.doParse(this._isCurrency() ? propsValue : (0, _toString2.default)(propsValue), false, true, true);
307
350
  let number = null;
308
351
  if (typeof tmpNumber === 'number' && !isNaN(tmpNumber)) {
309
352
  number = tmpNumber;
310
353
  }
311
- const formattedValue = typeof number === 'number' ? this.doFormat(number, true) : '';
354
+ const formattedValue = typeof number === 'number' ? this.doFormat(number, true, true) : '';
312
355
  this._adapter.setNumber(number);
313
356
  this._adapter.setValue(formattedValue);
314
357
  if ((0, _isString2.default)(formattedValue) && formattedValue !== String(propsValue !== null && propsValue !== void 0 ? propsValue : '')) {
@@ -346,7 +389,7 @@ class InputNumberFoundation extends _foundation.default {
346
389
  curNum = max;
347
390
  }
348
391
  // console.log('scale: ', scale, 'curNum: ', curNum);
349
- return this.doFormat(curNum, true);
392
+ return this.doFormat(curNum, true, true);
350
393
  }
351
394
  minus(step, event) {
352
395
  const pressShift = event && event.shiftKey;
@@ -373,6 +416,29 @@ class InputNumberFoundation extends _foundation.default {
373
416
  }
374
417
  return (0, _toString2.default)(num);
375
418
  }
419
+ formatCurrency(value) {
420
+ const {
421
+ localeCode,
422
+ minimumFractionDigits,
423
+ precision,
424
+ maximumFractionDigits,
425
+ currencyDisplay,
426
+ showCurrencySymbol
427
+ } = this.getProps();
428
+ let formattedValue = value;
429
+ if (typeof value === 'string' && Number.isNaN(Number(value))) {
430
+ formattedValue = this.parseInternationalCurrency(value);
431
+ }
432
+ const formatter = new Intl.NumberFormat(localeCode, {
433
+ style: 'currency',
434
+ currency: this._getFinalCurrency() || this.getCurrencyByLocaleCode(),
435
+ currencyDisplay: currencyDisplay,
436
+ minimumFractionDigits: minimumFractionDigits || precision || undefined,
437
+ maximumFractionDigits: maximumFractionDigits || precision || undefined
438
+ });
439
+ const formatted = formatter.format(Number(formattedValue));
440
+ return showCurrencySymbol ? formatted : formatted.replace(this._currencySymbol, '').trim();
441
+ }
376
442
  /**
377
443
  * format number to string
378
444
  * @param {string|number} value
@@ -382,12 +448,18 @@ class InputNumberFoundation extends _foundation.default {
382
448
  doFormat() {
383
449
  let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
384
450
  let needAdjustPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
451
+ let needAdjustCurrency = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
385
452
  // if (typeof value === 'string') {
386
453
  // return value;
387
454
  // }
455
+ const {
456
+ formatter
457
+ } = this.getProps();
388
458
  let str;
389
- const formatter = this.getProp('formatter');
390
- if (needAdjustPrec) {
459
+ // AdjustCurrency conversion is done only in blur situation, otherwise it is just converted to normal string
460
+ if (this._isCurrency() && needAdjustCurrency) {
461
+ str = this.formatCurrency(value);
462
+ } else if (needAdjustPrec) {
391
463
  str = this._adjustPrec(value);
392
464
  } else {
393
465
  str = (0, _toString2.default)(value);
@@ -414,6 +486,18 @@ class InputNumberFoundation extends _foundation.default {
414
486
  }
415
487
  return current;
416
488
  }
489
+ // 将货币模式的货币转化为纯数字
490
+ // Convert currency in currency mode to pure numbers
491
+ // eg:¥123456.78 to 123456.78
492
+ // eg:123456.78 to 123456.78
493
+ parseInternationalCurrency(currencyString) {
494
+ let cleaned = currencyString.replace(this._currencySymbol, '').replace(new RegExp(`[^\\d${this._decimalPointSymbol}\\-]`, 'g'), '');
495
+ // Convert the localized decimal point to the standard decimal point
496
+ if (this._decimalPointSymbol && this._decimalPointSymbol !== '.') {
497
+ cleaned = cleaned.replace(this._decimalPointSymbol, '.');
498
+ }
499
+ return parseFloat(cleaned);
500
+ }
417
501
  /**
418
502
  * parse to number
419
503
  * @param {string|number} value
@@ -426,6 +510,9 @@ class InputNumberFoundation extends _foundation.default {
426
510
  let needCheckPrec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
427
511
  let needAdjustPrec = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
428
512
  let needAdjustMaxMin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
513
+ if (this._isCurrency() && typeof value === 'string') {
514
+ value = this.parseInternationalCurrency(value);
515
+ }
429
516
  if (typeof value === 'number') {
430
517
  if (needAdjustMaxMin) {
431
518
  value = this.fetchMinOrMax(value);
@@ -474,7 +561,12 @@ class InputNumberFoundation extends _foundation.default {
474
561
  return value;
475
562
  }
476
563
  if (typeof value === 'string') {
477
- const parser = this.getProp('parser');
564
+ const {
565
+ parser
566
+ } = this.getProps();
567
+ if (this._isCurrency()) {
568
+ value = this.parseInternationalCurrency(value);
569
+ }
478
570
  if (typeof parser === 'function') {
479
571
  value = parser(value);
480
572
  }
@@ -542,5 +634,74 @@ class InputNumberFoundation extends _foundation.default {
542
634
  updateStates(states, callback) {
543
635
  this._adapter.updateStates(states, callback);
544
636
  }
637
+ /**
638
+ * Get currency by locale code
639
+ * @param {string} localeCode
640
+ * @returns {string}
641
+ */
642
+ getCurrencyByLocaleCode() {
643
+ const {
644
+ localeCode
645
+ } = this.getProps();
646
+ // Mapping table of region codes to currency codes
647
+ const localeToCurrency = {
648
+ // Asia
649
+ 'zh-CN': 'CNY',
650
+ 'zh-HK': 'HKD',
651
+ 'zh-TW': 'TWD',
652
+ 'ja-JP': 'JPY',
653
+ 'ko-KR': 'KRW',
654
+ 'th-TH': 'THB',
655
+ 'vi-VN': 'VND',
656
+ 'ms-MY': 'MYR',
657
+ 'id-ID': 'IDR',
658
+ 'hi-IN': 'INR',
659
+ 'ar-SA': 'SAR',
660
+ // Europe
661
+ 'en-GB': 'GBP',
662
+ 'de-DE': 'EUR',
663
+ 'fr-FR': 'EUR',
664
+ 'it-IT': 'EUR',
665
+ 'es-ES': 'EUR',
666
+ 'pt-PT': 'EUR',
667
+ 'ru-RU': 'RUB',
668
+ // North America
669
+ 'en-US': 'USD',
670
+ 'en-CA': 'CAD',
671
+ 'es-MX': 'MXN',
672
+ // South America
673
+ 'pt-BR': 'BRL',
674
+ 'es-AR': 'ARS',
675
+ // Oceania
676
+ 'en-AU': 'AUD',
677
+ 'en-NZ': 'NZD',
678
+ // Africa
679
+ 'en-ZA': 'ZAR',
680
+ 'ar-EG': 'EGP' // Egypt
681
+ };
682
+ // Try to match the full region code directly
683
+ if (localeToCurrency[localeCode]) {
684
+ return localeToCurrency[localeCode];
685
+ }
686
+ // If no direct match, try to match the language part (the first two characters)
687
+ const languageCode = localeCode.split('-')[0];
688
+ const fallbackMap = {
689
+ 'en': 'USD',
690
+ 'zh': 'CNY',
691
+ 'es': 'EUR',
692
+ 'fr': 'EUR',
693
+ 'de': 'EUR',
694
+ 'it': 'EUR',
695
+ 'ja': 'JPY',
696
+ 'ko': 'KRW',
697
+ 'ru': 'RUB',
698
+ 'ar': 'SAR' // Arabic defaults to SAR
699
+ };
700
+ if (fallbackMap[languageCode]) {
701
+ return fallbackMap[languageCode];
702
+ }
703
+ // If no match, return USD as the default value
704
+ return 'USD';
705
+ }
545
706
  }
546
707
  var _default = exports.default = InputNumberFoundation;
@@ -1,6 +1,6 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { MDXProps } from 'mdx/types';
3
- import { type PluggableList } from "@mdx-js/mdx/lib/core";
3
+ import type { PluggableList } from 'unified';
4
4
  export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
5
5
  getRuntime: () => any;
6
6
  }
@@ -59,6 +59,7 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
59
59
  export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
60
60
  _timer: ReturnType<typeof setTimeout>;
61
61
  _mounted: boolean;
62
+ anchorName: string;
62
63
  constructor(adapter: TooltipAdapter<P, S>);
63
64
  init(): void;
64
65
  destroy(): void;
@@ -76,6 +77,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
76
77
  _reducePos(position?: string): string;
77
78
  clearDelayTimer(): void;
78
79
  updateStateIfCursorOnTrigger: (trigger: HTMLElement) => void;
80
+ getNativeAnchorStyle: () => {
81
+ positionAnchor: string;
82
+ position: string;
83
+ };
79
84
  _generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
80
85
  triggerEventSet: {
81
86
  [x: string]: (event: any) => void;