@uzum-tech/ui 2.0.1 → 2.0.3

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 (58) hide show
  1. package/dist/index.js +319 -92
  2. package/dist/index.mjs +319 -92
  3. package/dist/index.prod.js +2 -2
  4. package/dist/index.prod.mjs +2 -2
  5. package/es/chat/src/ChatParts/MainArea.mjs +3 -1
  6. package/es/components.d.ts +51 -0
  7. package/es/input-number/src/InputNumber.d.ts +14 -0
  8. package/es/input-number/src/InputNumber.mjs +121 -48
  9. package/es/input-number/src/constants.d.ts +14 -0
  10. package/es/input-number/src/constants.mjs +15 -0
  11. package/es/input-number/src/interface.d.ts +4 -0
  12. package/es/input-number/src/utils.d.ts +12 -0
  13. package/es/input-number/src/utils.mjs +89 -1
  14. package/es/mapping-card/src/MappingCardList.d.ts +2 -0
  15. package/es/mapping-card/src/MappingCardList.mjs +11 -2
  16. package/es/mapping-card/src/interface.d.ts +3 -0
  17. package/es/mapping-card/src/interface.mjs +2 -1
  18. package/es/mapping-card/src/styles/index.cssr.mjs +8 -1
  19. package/es/modal/src/BodyWrapper.d.ts +39 -0
  20. package/es/modal/src/Modal.d.ts +56 -0
  21. package/es/modal/src/ModalEnvironment.d.ts +39 -0
  22. package/es/modal/src/presetProps.d.ts +18 -1
  23. package/es/modal/src/presetProps.mjs +2 -1
  24. package/es/notification/src/NotificationEnvironment.d.ts +4 -0
  25. package/es/notification/src/NotificationEnvironment.mjs +45 -9
  26. package/es/notification/src/NotificationProvider.d.ts +2 -0
  27. package/es/notification/src/styles/index.cssr.d.ts +1 -2
  28. package/es/notification/src/styles/index.cssr.mjs +13 -23
  29. package/es/version.d.ts +1 -1
  30. package/es/version.mjs +1 -1
  31. package/lib/chat/src/ChatParts/MainArea.js +45 -43
  32. package/lib/components.d.ts +51 -0
  33. package/lib/input-number/src/InputNumber.d.ts +14 -0
  34. package/lib/input-number/src/InputNumber.js +128 -51
  35. package/lib/input-number/src/constants.d.ts +14 -0
  36. package/lib/input-number/src/constants.js +18 -0
  37. package/lib/input-number/src/interface.d.ts +4 -0
  38. package/lib/input-number/src/utils.d.ts +12 -0
  39. package/lib/input-number/src/utils.js +112 -1
  40. package/lib/mapping-card/src/MappingCardList.d.ts +2 -0
  41. package/lib/mapping-card/src/MappingCardList.js +9 -4
  42. package/lib/mapping-card/src/interface.d.ts +3 -0
  43. package/lib/mapping-card/src/interface.js +2 -1
  44. package/lib/mapping-card/src/styles/index.cssr.js +8 -1
  45. package/lib/modal/src/BodyWrapper.d.ts +39 -0
  46. package/lib/modal/src/Modal.d.ts +56 -0
  47. package/lib/modal/src/ModalEnvironment.d.ts +39 -0
  48. package/lib/modal/src/presetProps.d.ts +18 -1
  49. package/lib/modal/src/presetProps.js +2 -1
  50. package/lib/notification/src/NotificationEnvironment.d.ts +4 -0
  51. package/lib/notification/src/NotificationEnvironment.js +46 -9
  52. package/lib/notification/src/NotificationProvider.d.ts +2 -0
  53. package/lib/notification/src/styles/index.cssr.d.ts +1 -2
  54. package/lib/notification/src/styles/index.cssr.js +13 -23
  55. package/lib/version.d.ts +1 -1
  56. package/lib/version.js +1 -1
  57. package/package.json +4 -1
  58. package/web-types.json +8 -1
@@ -68399,6 +68399,10 @@ export declare const UInputNumber: import("vue").DefineComponent<import("vue").E
68399
68399
  type: BooleanConstructor;
68400
68400
  default: boolean;
68401
68401
  };
68402
+ type: {
68403
+ type: import("vue").PropType<"default" | "amount">;
68404
+ default: string;
68405
+ };
68402
68406
  parse: import("vue").PropType<(input: string) => number | null>;
68403
68407
  format: import("vue").PropType<(value: number | null) => string>;
68404
68408
  precision: NumberConstructor;
@@ -69355,6 +69359,7 @@ export declare const UInputNumber: import("vue").DefineComponent<import("vue").E
69355
69359
  displayedValue: import("vue").Ref<string, string>;
69356
69360
  addable: import("vue").ComputedRef<boolean>;
69357
69361
  minusable: import("vue").ComputedRef<boolean>;
69362
+ showButton: import("vue").ComputedRef<boolean>;
69358
69363
  mergedStatus: import("vue").ComputedRef<import("./form/src/interface").FormValidationStatus | undefined>;
69359
69364
  handleFocus: (e: FocusEvent) => void;
69360
69365
  handleBlur: (e: FocusEvent) => void;
@@ -69733,6 +69738,10 @@ export declare const UInputNumber: import("vue").DefineComponent<import("vue").E
69733
69738
  type: BooleanConstructor;
69734
69739
  default: boolean;
69735
69740
  };
69741
+ type: {
69742
+ type: import("vue").PropType<"default" | "amount">;
69743
+ default: string;
69744
+ };
69736
69745
  parse: import("vue").PropType<(input: string) => number | null>;
69737
69746
  format: import("vue").PropType<(value: number | null) => string>;
69738
69747
  precision: NumberConstructor;
@@ -70628,6 +70637,7 @@ export declare const UInputNumber: import("vue").DefineComponent<import("vue").E
70628
70637
  }>> & Readonly<{}>, {
70629
70638
  bordered: boolean | undefined;
70630
70639
  disabled: boolean | undefined;
70640
+ type: "default" | "amount";
70631
70641
  loading: boolean;
70632
70642
  clearable: boolean;
70633
70643
  defaultValue: number | null;
@@ -79156,6 +79166,7 @@ export declare const UMappingCardList: import("vue").DefineComponent<import("vue
79156
79166
  readonly type: NumberConstructor;
79157
79167
  readonly default: 16;
79158
79168
  };
79169
+ readonly emptyProps: import("vue").PropType<Partial<import("./empty").EmptyProps>>;
79159
79170
  }>, {
79160
79171
  mergedClsPrefix: import("vue").Ref<string, string>;
79161
79172
  mergedPagination: import("vue").ComputedRef<import("./pagination").PaginationProps | null>;
@@ -79172,6 +79183,7 @@ export declare const UMappingCardList: import("vue").DefineComponent<import("vue
79172
79183
  readonly type: NumberConstructor;
79173
79184
  readonly default: 16;
79174
79185
  };
79186
+ readonly emptyProps: import("vue").PropType<Partial<import("./empty").EmptyProps>>;
79175
79187
  }>> & Readonly<{}>, {
79176
79188
  readonly gap: number;
79177
79189
  readonly items: import("./mapping-card").MappingCardProps[];
@@ -82082,6 +82094,23 @@ export declare const UModal: import("vue").DefineComponent<import("vue").Extract
82082
82094
  loading: BooleanConstructor;
82083
82095
  bordered: BooleanConstructor;
82084
82096
  iconPlacement: import("vue").PropType<import("./dialog/src/interface").IconPlacement>;
82097
+ contentClass: StringConstructor;
82098
+ contentScrollable: BooleanConstructor;
82099
+ contentStyle: import("vue").PropType<import("vue").CSSProperties | string>;
82100
+ headerStyle: import("vue").PropType<import("vue").CSSProperties | string>;
82101
+ headerExtraStyle: import("vue").PropType<import("vue").CSSProperties | string>;
82102
+ footerStyle: import("vue").PropType<import("vue").CSSProperties | string>;
82103
+ embedded: BooleanConstructor;
82104
+ segmented: {
82105
+ readonly type: import("vue").PropType<boolean | import("./card").CardSegmented>;
82106
+ readonly default: false;
82107
+ };
82108
+ hoverable: BooleanConstructor;
82109
+ role: StringConstructor;
82110
+ tag: {
82111
+ readonly type: import("vue").PropType<keyof HTMLElementTagNameMap>;
82112
+ readonly default: "div";
82113
+ };
82085
82114
  show: BooleanConstructor;
82086
82115
  unstableShowMask: {
82087
82116
  type: BooleanConstructor;
@@ -83144,6 +83173,23 @@ export declare const UModal: import("vue").DefineComponent<import("vue").Extract
83144
83173
  loading: BooleanConstructor;
83145
83174
  bordered: BooleanConstructor;
83146
83175
  iconPlacement: import("vue").PropType<import("./dialog/src/interface").IconPlacement>;
83176
+ contentClass: StringConstructor;
83177
+ contentScrollable: BooleanConstructor;
83178
+ contentStyle: import("vue").PropType<import("vue").CSSProperties | string>;
83179
+ headerStyle: import("vue").PropType<import("vue").CSSProperties | string>;
83180
+ headerExtraStyle: import("vue").PropType<import("vue").CSSProperties | string>;
83181
+ footerStyle: import("vue").PropType<import("vue").CSSProperties | string>;
83182
+ embedded: BooleanConstructor;
83183
+ segmented: {
83184
+ readonly type: import("vue").PropType<boolean | import("./card").CardSegmented>;
83185
+ readonly default: false;
83186
+ };
83187
+ hoverable: BooleanConstructor;
83188
+ role: StringConstructor;
83189
+ tag: {
83190
+ readonly type: import("vue").PropType<keyof HTMLElementTagNameMap>;
83191
+ readonly default: "div";
83192
+ };
83147
83193
  show: BooleanConstructor;
83148
83194
  unstableShowMask: {
83149
83195
  type: BooleanConstructor;
@@ -84140,9 +84186,14 @@ export declare const UModal: import("vue").DefineComponent<import("vue").Extract
84140
84186
  type: "default" | "error" | "warning" | "success" | "info";
84141
84187
  size: "small" | "medium" | "large";
84142
84188
  loading: boolean;
84189
+ tag: keyof HTMLElementTagNameMap;
84143
84190
  showIcon: boolean;
84144
84191
  closable: boolean;
84145
84192
  show: boolean;
84193
+ contentScrollable: boolean;
84194
+ embedded: boolean;
84195
+ segmented: boolean | import("./card").CardSegmented;
84196
+ hoverable: boolean;
84146
84197
  displayDirective: "show" | "if";
84147
84198
  maskClosable: boolean;
84148
84199
  trapFocus: boolean;
@@ -52,6 +52,10 @@ export declare const inputNumberProps: {
52
52
  type: BooleanConstructor;
53
53
  default: boolean;
54
54
  };
55
+ type: {
56
+ type: PropType<"default" | "amount">;
57
+ default: string;
58
+ };
55
59
  parse: PropType<(input: string) => number | null>;
56
60
  format: PropType<(value: number | null) => string>;
57
61
  precision: NumberConstructor;
@@ -1001,6 +1005,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1001
1005
  type: BooleanConstructor;
1002
1006
  default: boolean;
1003
1007
  };
1008
+ type: {
1009
+ type: PropType<"default" | "amount">;
1010
+ default: string;
1011
+ };
1004
1012
  parse: PropType<(input: string) => number | null>;
1005
1013
  format: PropType<(value: number | null) => string>;
1006
1014
  precision: NumberConstructor;
@@ -1957,6 +1965,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1957
1965
  displayedValue: import("vue").Ref<string, string>;
1958
1966
  addable: import("vue").ComputedRef<boolean>;
1959
1967
  minusable: import("vue").ComputedRef<boolean>;
1968
+ showButton: import("vue").ComputedRef<boolean>;
1960
1969
  mergedStatus: import("vue").ComputedRef<FormValidationStatus | undefined>;
1961
1970
  handleFocus: (e: FocusEvent) => void;
1962
1971
  handleBlur: (e: FocusEvent) => void;
@@ -2335,6 +2344,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2335
2344
  type: BooleanConstructor;
2336
2345
  default: boolean;
2337
2346
  };
2347
+ type: {
2348
+ type: PropType<"default" | "amount">;
2349
+ default: string;
2350
+ };
2338
2351
  parse: PropType<(input: string) => number | null>;
2339
2352
  format: PropType<(value: number | null) => string>;
2340
2353
  precision: NumberConstructor;
@@ -3230,6 +3243,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
3230
3243
  }>> & Readonly<{}>, {
3231
3244
  bordered: boolean | undefined;
3232
3245
  disabled: boolean | undefined;
3246
+ type: "default" | "amount";
3233
3247
  loading: boolean;
3234
3248
  clearable: boolean;
3235
3249
  defaultValue: number | null;
@@ -15,8 +15,9 @@ const _utils_1 = require("../../_utils");
15
15
  const button_1 = require("../../button");
16
16
  const input_1 = require("../../input");
17
17
  const styles_1 = require("../styles");
18
- const input_number_cssr_1 = __importDefault(require("./styles/input-number.cssr"));
18
+ const constants_1 = require("./constants");
19
19
  const utils_1 = require("./utils");
20
+ const input_number_cssr_1 = __importDefault(require("./styles/input-number.cssr"));
20
21
  const HOLDING_CHANGE_THRESHOLD = 800;
21
22
  const HOLDING_CHANGE_INTERVAL = 100;
22
23
  exports.inputNumberProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), { autofocus: Boolean, loading: {
@@ -46,6 +47,9 @@ exports.inputNumberProps = Object.assign(Object.assign({}, _mixins_1.useTheme.pr
46
47
  }, updateValueOnInput: {
47
48
  type: Boolean,
48
49
  default: true
50
+ }, type: {
51
+ type: String,
52
+ default: 'default'
49
53
  }, parse: Function, format: Function, precision: Number, status: String, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], onClear: [Function, Array],
50
54
  // deprecated
51
55
  onChange: [Function, Array] });
@@ -75,15 +79,11 @@ exports.default = (0, vue_1.defineComponent)({
75
79
  const controlledValueRef = (0, vue_1.toRef)(props, 'value');
76
80
  const mergedValueRef = (0, vooks_1.useMergedState)(controlledValueRef, uncontrolledValueRef);
77
81
  const displayedValueRef = (0, vue_1.ref)('');
78
- const getPrecision = (value) => {
79
- const fraction = String(value).split('.')[1];
80
- return fraction ? fraction.length : 0;
81
- };
82
82
  const getMaxPrecision = (currentValue) => {
83
83
  const precisions = [props.min, props.max, props.step, currentValue].map((value) => {
84
84
  if (value === undefined)
85
85
  return 0;
86
- return getPrecision(value);
86
+ return (0, utils_1.getPrecision)(value);
87
87
  });
88
88
  return Math.max(...precisions);
89
89
  };
@@ -114,19 +114,55 @@ exports.default = (0, vue_1.defineComponent)({
114
114
  else
115
115
  return null;
116
116
  });
117
+ const isAmountTypeRef = (0, vooks_1.useMemo)(() => props.type === 'amount');
118
+ const showButtonRef = (0, vooks_1.useMemo)(() => {
119
+ return isAmountTypeRef.value ? false : props.showButton;
120
+ });
121
+ const effectiveParse = (input) => {
122
+ if (props.parse)
123
+ return props.parse(input);
124
+ if (isAmountTypeRef.value)
125
+ return (0, utils_1.parseAmount)(input);
126
+ return (0, utils_1.parse)(input);
127
+ };
128
+ const effectiveFormat = (value, precision) => {
129
+ if (props.format && value !== undefined)
130
+ return props.format(value);
131
+ if (isAmountTypeRef.value)
132
+ return (0, utils_1.formatAmount)(value, precision);
133
+ return (0, utils_1.format)(value, precision);
134
+ };
135
+ const doUpdateValue = (value) => {
136
+ const { value: mergedValue } = mergedValueRef;
137
+ if (value === mergedValue) {
138
+ deriveDisplayedValueFromValue();
139
+ return;
140
+ }
141
+ const { 'onUpdate:value': _onUpdateValue, onUpdateValue, onChange } = props;
142
+ const { triggerFormInput, triggerFormChange } = formItem;
143
+ if (onChange)
144
+ (0, _utils_1.call)(onChange, value);
145
+ if (onUpdateValue)
146
+ (0, _utils_1.call)(onUpdateValue, value);
147
+ if (_onUpdateValue)
148
+ (0, _utils_1.call)(_onUpdateValue, value);
149
+ uncontrolledValueRef.value = value;
150
+ triggerFormInput();
151
+ triggerFormChange();
152
+ };
117
153
  const deriveValueFromDisplayedValue = ({ offset, doUpdateIfValid, fixPrecision, isInputing }) => {
118
154
  const { value: displayedValue } = displayedValueRef;
119
155
  if (isInputing && (0, utils_1.isWipValue)(displayedValue)) {
120
156
  return false;
121
157
  }
122
- const parsedValue = (props.parse || utils_1.parse)(displayedValue);
158
+ const parsedValue = effectiveParse(displayedValue);
123
159
  if (parsedValue === null) {
124
160
  if (doUpdateIfValid)
125
161
  doUpdateValue(null);
126
162
  return null;
127
163
  }
128
164
  if ((0, utils_1.validator)(parsedValue)) {
129
- const currentPrecision = getPrecision(parsedValue);
165
+ const currentPrecision = (0, utils_1.getPrecision)(parsedValue);
130
166
  const { precision } = props;
131
167
  if (precision !== undefined
132
168
  && precision < currentPrecision
@@ -161,21 +197,8 @@ exports.default = (0, vue_1.defineComponent)({
161
197
  const deriveDisplayedValueFromValue = () => {
162
198
  const { value: mergedValue } = mergedValueRef;
163
199
  if ((0, utils_1.validator)(mergedValue)) {
164
- const { format: formatProp, precision } = props;
165
- if (formatProp) {
166
- displayedValueRef.value = formatProp(mergedValue);
167
- }
168
- else {
169
- if (mergedValue === null
170
- || precision === undefined
171
- // precision overflow
172
- || getPrecision(mergedValue) > precision) {
173
- displayedValueRef.value = (0, utils_1.format)(mergedValue, undefined);
174
- }
175
- else {
176
- displayedValueRef.value = (0, utils_1.format)(mergedValue, precision);
177
- }
178
- }
200
+ const { precision } = props;
201
+ displayedValueRef.value = effectiveFormat(mergedValue, mergedValue === null ? undefined : precision);
179
202
  }
180
203
  else {
181
204
  // null can pass the validator check
@@ -183,25 +206,62 @@ exports.default = (0, vue_1.defineComponent)({
183
206
  displayedValueRef.value = String(mergedValue);
184
207
  }
185
208
  };
186
- deriveDisplayedValueFromValue();
187
- function doUpdateValue(value) {
188
- const { value: mergedValue } = mergedValueRef;
189
- if (value === mergedValue) {
190
- deriveDisplayedValueFromValue();
209
+ const computeValueToFormat = (prev, derived) => {
210
+ if (derived !== false && derived !== null)
211
+ return derived;
212
+ if (!isAmountTypeRef.value)
213
+ return null;
214
+ const parsed = effectiveParse(prev);
215
+ if (parsed === null || Number.isNaN(parsed))
216
+ return null;
217
+ return parsed;
218
+ };
219
+ const setInputValueSelection = (value, selectionStart, selectionEnd) => {
220
+ var _a;
221
+ const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
222
+ if (!inputElement)
191
223
  return;
224
+ inputElement.value = value;
225
+ inputElement.setSelectionRange(selectionStart, selectionEnd);
226
+ };
227
+ const applyFormatted = (prev, valueNumber) => {
228
+ var _a, _b, _c;
229
+ const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
230
+ const selectionStart = (_b = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionStart) !== null && _b !== void 0 ? _b : prev.length;
231
+ const selectionEnd = (_c = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionEnd) !== null && _c !== void 0 ? _c : selectionStart;
232
+ const newFormatted = effectiveFormat(valueNumber, props.precision);
233
+ displayedValueRef.value = newFormatted;
234
+ void (0, vue_1.nextTick)(() => {
235
+ const { start, end } = (0, utils_1.mapSelectionAfterFormat)(prev, newFormatted, selectionStart, selectionEnd);
236
+ inputElement === null || inputElement === void 0 ? void 0 : inputElement.setSelectionRange(start, end);
237
+ });
238
+ };
239
+ const restoreRejectedAmountInput = (prevDisplayedValue, attemptedDisplayedValue) => {
240
+ var _a, _b, _c;
241
+ const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
242
+ const selectionStart = (_b = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionStart) !== null && _b !== void 0 ? _b : attemptedDisplayedValue.length;
243
+ const selectionEnd = (_c = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionEnd) !== null && _c !== void 0 ? _c : selectionStart;
244
+ const { start, end } = (0, utils_1.getRejectedSelectionRange)(prevDisplayedValue, attemptedDisplayedValue, selectionStart, selectionEnd);
245
+ displayedValueRef.value = prevDisplayedValue;
246
+ setInputValueSelection(prevDisplayedValue, start, end);
247
+ void (0, vue_1.nextTick)(() => {
248
+ setInputValueSelection(prevDisplayedValue, start, end);
249
+ });
250
+ };
251
+ const shouldRejectAmountInput = (value) => {
252
+ if (!(0, utils_1.isValidAmountInput)(value))
253
+ return true;
254
+ if (!(0, utils_1.isAmountInputWithinDigitLimit)(value, constants_1.MAX_AMOUNT_INPUT_DIGITS)) {
255
+ return true;
192
256
  }
193
- const { 'onUpdate:value': _onUpdateValue, onUpdateValue, onChange } = props;
194
- const { triggerFormInput, triggerFormChange } = formItem;
195
- if (onChange)
196
- (0, _utils_1.call)(onChange, value);
197
- if (onUpdateValue)
198
- (0, _utils_1.call)(onUpdateValue, value);
199
- if (_onUpdateValue)
200
- (0, _utils_1.call)(_onUpdateValue, value);
201
- uncontrolledValueRef.value = value;
202
- triggerFormInput();
203
- triggerFormChange();
204
- }
257
+ if (props.precision === undefined)
258
+ return false;
259
+ const parsedValue = effectiveParse(value);
260
+ return (parsedValue !== null &&
261
+ !Number.isNaN(parsedValue) &&
262
+ (0, utils_1.getPrecision)(parsedValue) > props.precision);
263
+ };
264
+ deriveDisplayedValueFromValue();
205
265
  const displayedValueInvalidRef = (0, vooks_1.useMemo)(() => {
206
266
  const derivedValue = deriveValueFromDisplayedValue({
207
267
  offset: 0,
@@ -476,18 +536,35 @@ exports.default = (0, vue_1.defineComponent)({
476
536
  }
477
537
  }
478
538
  }
539
+ const shouldTryFormat = () => props.updateValueOnInput &&
540
+ !props.format &&
541
+ !props.parse &&
542
+ (props.precision === undefined || isAmountTypeRef.value);
479
543
  function handleUpdateDisplayedValue(value) {
544
+ const prevDisplayedValue = displayedValueRef.value;
545
+ const prevFormatted = value;
546
+ if (isAmountTypeRef.value) {
547
+ if (shouldRejectAmountInput(value)) {
548
+ restoreRejectedAmountInput(prevDisplayedValue, value);
549
+ return;
550
+ }
551
+ }
480
552
  displayedValueRef.value = value;
481
- if (props.updateValueOnInput
482
- && !props.format
483
- && !props.parse
484
- && props.precision === undefined) {
485
- deriveValueFromDisplayedValue({
486
- offset: 0,
487
- doUpdateIfValid: true,
488
- isInputing: true,
489
- fixPrecision: false
490
- });
553
+ if (!shouldTryFormat())
554
+ return;
555
+ if (isAmountTypeRef.value) {
556
+ if ((0, utils_1.isRawWipValue)(prevFormatted))
557
+ return;
558
+ }
559
+ const derived = deriveValueFromDisplayedValue({
560
+ offset: 0,
561
+ doUpdateIfValid: true,
562
+ isInputing: true,
563
+ fixPrecision: false
564
+ });
565
+ const valueToFormat = computeValueToFormat(prevFormatted, derived);
566
+ if (valueToFormat !== null && isAmountTypeRef.value) {
567
+ applyFormatted(prevFormatted, valueToFormat);
491
568
  }
492
569
  }
493
570
  (0, vue_1.watch)(mergedValueRef, () => {
@@ -501,7 +578,7 @@ exports.default = (0, vue_1.defineComponent)({
501
578
  const rtlEnabledRef = (0, use_rtl_1.useRtl)('InputNumber', mergedRtlRef, mergedClsPrefixRef);
502
579
  return Object.assign(Object.assign({}, exposedMethods), { rtlEnabled: rtlEnabledRef, inputInstRef,
503
580
  minusButtonInstRef,
504
- addButtonInstRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, uncontrolledValue: uncontrolledValueRef, mergedValue: mergedValueRef, mergedPlaceholder: mergedPlaceholderRef, displayedValueInvalid: displayedValueInvalidRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, displayedValue: displayedValueRef, addable: addableRef, minusable: minusableRef, mergedStatus: mergedStatusRef, handleFocus,
581
+ addButtonInstRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, uncontrolledValue: uncontrolledValueRef, mergedValue: mergedValueRef, mergedPlaceholder: mergedPlaceholderRef, displayedValueInvalid: displayedValueInvalidRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, displayedValue: displayedValueRef, addable: addableRef, minusable: minusableRef, showButton: showButtonRef, mergedStatus: mergedStatusRef, handleFocus,
505
582
  handleBlur,
506
583
  handleClear,
507
584
  handleMouseDown,
@@ -0,0 +1,14 @@
1
+ export declare const MAX_AMOUNT_INPUT_DIGITS = 16;
2
+ export declare enum InputNumberRegex {
3
+ INPUT_WIP_VALUE = "^(-)?\\d+.*(\\.|0)$",
4
+ INPUT_LEADING_DOT_WIP_VALUE = "^\\.\\d+$",
5
+ AMOUNT_INPUT = "^-?[\\d\\s]*\\.?\\d*$",
6
+ AMOUNT_VALUE = "^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$",
7
+ AMOUNT_RAW_LEADING_DOT = "^-?\\.\\d*$",
8
+ WHITESPACE = "\\s",
9
+ NON_DIGIT = "\\D",
10
+ LEADING_ZEROS = "^0+(?=\\d)",
11
+ NON_ZERO_DIGIT = "[1-9]",
12
+ TRAILING_ZERO_FRACTION = "\\.?0+$",
13
+ THOUSANDS_SEPARATOR = "\\B(?=(\\d{3})+(?!\\d))"
14
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputNumberRegex = exports.MAX_AMOUNT_INPUT_DIGITS = void 0;
4
+ exports.MAX_AMOUNT_INPUT_DIGITS = 16;
5
+ var InputNumberRegex;
6
+ (function (InputNumberRegex) {
7
+ InputNumberRegex["INPUT_WIP_VALUE"] = "^(-)?\\d+.*(\\.|0)$";
8
+ InputNumberRegex["INPUT_LEADING_DOT_WIP_VALUE"] = "^\\.\\d+$";
9
+ InputNumberRegex["AMOUNT_INPUT"] = "^-?[\\d\\s]*\\.?\\d*$";
10
+ InputNumberRegex["AMOUNT_VALUE"] = "^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$";
11
+ InputNumberRegex["AMOUNT_RAW_LEADING_DOT"] = "^-?\\.\\d*$";
12
+ InputNumberRegex["WHITESPACE"] = "\\s";
13
+ InputNumberRegex["NON_DIGIT"] = "\\D";
14
+ InputNumberRegex["LEADING_ZEROS"] = "^0+(?=\\d)";
15
+ InputNumberRegex["NON_ZERO_DIGIT"] = "[1-9]";
16
+ InputNumberRegex["TRAILING_ZERO_FRACTION"] = "\\.?0+$";
17
+ InputNumberRegex["THOUSANDS_SEPARATOR"] = "\\B(?=(\\d{3})+(?!\\d))";
18
+ })(InputNumberRegex || (exports.InputNumberRegex = InputNumberRegex = {}));
@@ -4,3 +4,7 @@ export interface InputNumberInst {
4
4
  blur: () => void;
5
5
  select: () => void;
6
6
  }
7
+ export interface InputSelectionRange {
8
+ start: number;
9
+ end: number;
10
+ }
@@ -1,5 +1,17 @@
1
+ import type { InputSelectionRange } from './interface';
1
2
  export declare function parse(value: string): number | null;
2
3
  export declare function isWipValue(value: string): boolean;
3
4
  export declare function validator(value: number | null): boolean;
4
5
  export declare function format(value: number | undefined | null, precision: number | undefined): string;
5
6
  export declare function parseNumber(number: number | null | undefined | string): number | null;
7
+ export declare function getPrecision(value: string | number): number;
8
+ export declare function stripAmountFormatting(value: string): string;
9
+ export declare function isValidAmountInput(value: string): boolean;
10
+ export declare function isAmountInputWithinDigitLimit(value: string, maxDigits?: number): boolean;
11
+ export declare function getRejectedSelectionRange(prevDisplayedValue: string, attemptedDisplayedValue: string, selectionStart: number, selectionEnd: number): InputSelectionRange;
12
+ export declare function parseAmount(input: string): number | null;
13
+ export declare function formatAmount(value: number | undefined | null, precision: number | undefined): string;
14
+ export declare function formattedToRawIndex(formatted: string, caret: number): number;
15
+ export declare function rawIndexToCaret(formatted: string, rawIndex: number): number;
16
+ export declare function isRawWipValue(formatted: string): boolean;
17
+ export declare function mapSelectionAfterFormat(formatted: string, newFormatted: string, selectionStart: number, selectionEnd: number): InputSelectionRange;
@@ -5,6 +5,19 @@ exports.isWipValue = isWipValue;
5
5
  exports.validator = validator;
6
6
  exports.format = format;
7
7
  exports.parseNumber = parseNumber;
8
+ exports.getPrecision = getPrecision;
9
+ exports.stripAmountFormatting = stripAmountFormatting;
10
+ exports.isValidAmountInput = isValidAmountInput;
11
+ exports.isAmountInputWithinDigitLimit = isAmountInputWithinDigitLimit;
12
+ exports.getRejectedSelectionRange = getRejectedSelectionRange;
13
+ exports.parseAmount = parseAmount;
14
+ exports.formatAmount = formatAmount;
15
+ exports.formattedToRawIndex = formattedToRawIndex;
16
+ exports.rawIndexToCaret = rawIndexToCaret;
17
+ exports.isRawWipValue = isRawWipValue;
18
+ exports.mapSelectionAfterFormat = mapSelectionAfterFormat;
19
+ const constants_1 = require("./constants");
20
+ const MAX_SAFE_INTEGER_LIMIT = String(Number.MAX_SAFE_INTEGER);
8
21
  // string => string (expected, not implemented)
9
22
  // string => number (legacy)
10
23
  function parse(value) {
@@ -19,7 +32,8 @@ function parse(value) {
19
32
  // when value includes `.`, ending with 0 and`.`, doesn't update, if 0 parse func will remove 0
20
33
  function isWipValue(value) {
21
34
  return (value.includes('.')
22
- && (/^(-)?\d+.*(\.|0)$/.test(value) || /^\.\d+$/.test(value)));
35
+ && (new RegExp(constants_1.InputNumberRegex.INPUT_WIP_VALUE).test(value)
36
+ || new RegExp(constants_1.InputNumberRegex.INPUT_LEADING_DOT_WIP_VALUE).test(value)));
23
37
  }
24
38
  // string => boolean (expected, not implemented)
25
39
  // number => boolean (legacy)
@@ -53,3 +67,100 @@ function parseNumber(number) {
53
67
  }
54
68
  }
55
69
  }
70
+ function getPrecision(value) {
71
+ const fraction = String(value).split('.')[1];
72
+ return fraction ? fraction.length : 0;
73
+ }
74
+ function stripAmountFormatting(value) {
75
+ return String(value)
76
+ .replace(new RegExp(constants_1.InputNumberRegex.WHITESPACE, 'g'), '')
77
+ .trim();
78
+ }
79
+ function isValidAmountInput(value) {
80
+ return value === '' || new RegExp(constants_1.InputNumberRegex.AMOUNT_INPUT).test(value);
81
+ }
82
+ function isAmountInputWithinDigitLimit(value, maxDigits = constants_1.MAX_AMOUNT_INPUT_DIGITS) {
83
+ return (value.replace(new RegExp(constants_1.InputNumberRegex.NON_DIGIT, 'g'), '').length
84
+ <= maxDigits);
85
+ }
86
+ function getRejectedSelectionRange(prevDisplayedValue, attemptedDisplayedValue, selectionStart, selectionEnd) {
87
+ const removedLength = Math.max(0, attemptedDisplayedValue.length - prevDisplayedValue.length);
88
+ return {
89
+ start: Math.min(prevDisplayedValue.length, Math.max(0, selectionStart - removedLength)),
90
+ end: Math.min(prevDisplayedValue.length, Math.max(0, selectionEnd - removedLength))
91
+ };
92
+ }
93
+ function exceedsMaxSafeAmountValue(numberString) {
94
+ const normalized = numberString.startsWith('-')
95
+ ? numberString.slice(1)
96
+ : numberString;
97
+ const [integerPart = '0', fractionPart = ''] = normalized.split('.');
98
+ const normalizedIntegerPart = integerPart.replace(new RegExp(constants_1.InputNumberRegex.LEADING_ZEROS), '');
99
+ return (normalizedIntegerPart.length > MAX_SAFE_INTEGER_LIMIT.length
100
+ || (normalizedIntegerPart.length === MAX_SAFE_INTEGER_LIMIT.length
101
+ && (normalizedIntegerPart > MAX_SAFE_INTEGER_LIMIT
102
+ || (normalizedIntegerPart === MAX_SAFE_INTEGER_LIMIT
103
+ && new RegExp(constants_1.InputNumberRegex.NON_ZERO_DIGIT).test(fractionPart)))));
104
+ }
105
+ function parseAmount(input) {
106
+ if (input === undefined || input === null)
107
+ return null;
108
+ const numberString = stripAmountFormatting(input);
109
+ if (new RegExp(constants_1.InputNumberRegex.AMOUNT_VALUE).test(numberString)) {
110
+ if (exceedsMaxSafeAmountValue(numberString))
111
+ return Number.NaN;
112
+ return Number(numberString);
113
+ }
114
+ return numberString === '' ? null : Number.NaN;
115
+ }
116
+ function formatAmount(value, precision) {
117
+ if (value === undefined || value === null)
118
+ return '';
119
+ let stringValue = String(value);
120
+ if (precision !== undefined) {
121
+ stringValue = value
122
+ .toFixed(precision)
123
+ .replace(new RegExp(constants_1.InputNumberRegex.TRAILING_ZERO_FRACTION), '');
124
+ }
125
+ const negative = stringValue.startsWith('-');
126
+ if (negative)
127
+ stringValue = stringValue.slice(1);
128
+ const [integerPart, fractionPart] = stringValue.split('.');
129
+ const integerWithSeparator = integerPart.replace(new RegExp(constants_1.InputNumberRegex.THOUSANDS_SEPARATOR, 'g'), ' ');
130
+ return `${negative ? '-' : ''}${integerWithSeparator}${fractionPart ? `.${fractionPart}` : ''}`;
131
+ }
132
+ function formattedToRawIndex(formatted, caret) {
133
+ let raw = 0;
134
+ for (let i = 0; i < Math.min(caret, formatted.length); i++) {
135
+ if (formatted[i] !== ' ')
136
+ raw++;
137
+ }
138
+ return raw;
139
+ }
140
+ function rawIndexToCaret(formatted, rawIndex) {
141
+ if (rawIndex <= 0)
142
+ return 0;
143
+ let raw = 0;
144
+ for (let i = 0; i < formatted.length; i++) {
145
+ if (formatted[i] !== ' ')
146
+ raw++;
147
+ if (raw === rawIndex)
148
+ return i + 1;
149
+ }
150
+ return formatted.length;
151
+ }
152
+ function isRawWipValue(formatted) {
153
+ return isWipValue(stripAmountFormatting(formatted));
154
+ }
155
+ function mapSelectionAfterFormat(formatted, newFormatted, selectionStart, selectionEnd) {
156
+ const rawStart = formattedToRawIndex(formatted, selectionStart);
157
+ const rawEnd = formattedToRawIndex(formatted, selectionEnd);
158
+ const rawInput = stripAmountFormatting(formatted);
159
+ if (new RegExp(constants_1.InputNumberRegex.AMOUNT_RAW_LEADING_DOT).test(rawInput)) {
160
+ const { length } = newFormatted;
161
+ return { start: length, end: length };
162
+ }
163
+ const newStart = rawIndexToCaret(newFormatted, rawStart);
164
+ const newEnd = rawIndexToCaret(newFormatted, rawEnd);
165
+ return { start: newStart, end: newEnd };
166
+ }
@@ -12,6 +12,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
12
12
  readonly type: NumberConstructor;
13
13
  readonly default: 16;
14
14
  };
15
+ readonly emptyProps: import("vue").PropType<Partial<import("../../empty").EmptyProps>>;
15
16
  }>, {
16
17
  mergedClsPrefix: import("vue").Ref<string, string>;
17
18
  mergedPagination: import("vue").ComputedRef<PaginationProps | null>;
@@ -28,6 +29,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
28
29
  readonly type: NumberConstructor;
29
30
  readonly default: 16;
30
31
  };
32
+ readonly emptyProps: import("vue").PropType<Partial<import("../../empty").EmptyProps>>;
31
33
  }>> & Readonly<{}>, {
32
34
  readonly gap: number;
33
35
  readonly items: import("./interface").MappingCardProps[];
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const vue_1 = require("vue");
7
7
  const _mixins_1 = require("../../_mixins");
8
+ const _utils_1 = require("../../_utils");
9
+ const empty_1 = require("../../empty");
8
10
  const flex_1 = require("../../flex");
9
11
  const pagination_1 = require("../../pagination");
10
12
  const interface_1 = require("./interface");
@@ -26,11 +28,14 @@ exports.default = (0, vue_1.defineComponent)({
26
28
  };
27
29
  },
28
30
  render() {
29
- const { mergedClsPrefix, mergedPagination, gap, items } = this;
31
+ const { mergedClsPrefix, mergedPagination, gap, items, emptyProps, $slots } = this;
32
+ const isEmpty = !items.length;
30
33
  return ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-mapping-card-list` },
31
- (0, vue_1.h)(flex_1.UFlex, { vertical: true, size: gap, class: `${mergedClsPrefix}-mapping-card-list__items` }, {
32
- default: () => items.map((item, index) => (0, vue_1.h)(MappingCard_1.default, Object.assign({ key: index }, item)))
33
- }),
34
+ isEmpty ? ((0, vue_1.h)("div", { class: `${mergedClsPrefix}-mapping-card-list__empty` }, (0, _utils_1.resolveSlot)($slots.empty, () => [
35
+ (0, vue_1.h)(empty_1.UEmpty, Object.assign({ size: "large" }, emptyProps))
36
+ ]))) : ((0, vue_1.h)(flex_1.UFlex, { vertical: true, size: gap, class: `${mergedClsPrefix}-mapping-card-list__items` }, {
37
+ default: () => items.map((item, index) => ((0, vue_1.h)(MappingCard_1.default, Object.assign({ key: index }, item))))
38
+ })),
34
39
  mergedPagination ? ((0, vue_1.h)(flex_1.UFlex, { justify: "flex-end", class: `${mergedClsPrefix}-mapping-card-list__pagination` }, {
35
40
  default: () => (0, vue_1.h)(pagination_1.UPagination, Object.assign({}, mergedPagination))
36
41
  })) : null));