@uzum-tech/ui 2.0.1 → 2.0.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.
- package/dist/index.js +260 -62
- package/dist/index.mjs +260 -62
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +2 -2
- package/es/chat/src/ChatParts/MainArea.mjs +3 -1
- package/es/components.d.ts +51 -0
- package/es/input-number/src/InputNumber.d.ts +14 -0
- package/es/input-number/src/InputNumber.mjs +121 -48
- package/es/input-number/src/constants.d.ts +14 -0
- package/es/input-number/src/constants.mjs +15 -0
- package/es/input-number/src/interface.d.ts +4 -0
- package/es/input-number/src/utils.d.ts +12 -0
- package/es/input-number/src/utils.mjs +89 -1
- package/es/mapping-card/src/MappingCardList.d.ts +2 -0
- package/es/mapping-card/src/MappingCardList.mjs +11 -2
- package/es/mapping-card/src/interface.d.ts +3 -0
- package/es/mapping-card/src/interface.mjs +2 -1
- package/es/mapping-card/src/styles/index.cssr.mjs +8 -1
- package/es/modal/src/BodyWrapper.d.ts +39 -0
- package/es/modal/src/Modal.d.ts +56 -0
- package/es/modal/src/ModalEnvironment.d.ts +39 -0
- package/es/modal/src/presetProps.d.ts +18 -1
- package/es/modal/src/presetProps.mjs +2 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/chat/src/ChatParts/MainArea.js +45 -43
- package/lib/components.d.ts +51 -0
- package/lib/input-number/src/InputNumber.d.ts +14 -0
- package/lib/input-number/src/InputNumber.js +128 -51
- package/lib/input-number/src/constants.d.ts +14 -0
- package/lib/input-number/src/constants.js +18 -0
- package/lib/input-number/src/interface.d.ts +4 -0
- package/lib/input-number/src/utils.d.ts +12 -0
- package/lib/input-number/src/utils.js +112 -1
- package/lib/mapping-card/src/MappingCardList.d.ts +2 -0
- package/lib/mapping-card/src/MappingCardList.js +9 -4
- package/lib/mapping-card/src/interface.d.ts +3 -0
- package/lib/mapping-card/src/interface.js +2 -1
- package/lib/mapping-card/src/styles/index.cssr.js +8 -1
- package/lib/modal/src/BodyWrapper.d.ts +39 -0
- package/lib/modal/src/Modal.d.ts +56 -0
- package/lib/modal/src/ModalEnvironment.d.ts +39 -0
- package/lib/modal/src/presetProps.d.ts +18 -1
- package/lib/modal/src/presetProps.js +2 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/web-types.json +8 -1
|
@@ -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
|
|
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 = (
|
|
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 {
|
|
165
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (value
|
|
190
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
(0,
|
|
199
|
-
|
|
200
|
-
|
|
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 (
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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 = {}));
|
|
@@ -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
|
-
&& (
|
|
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)(
|
|
32
|
-
|
|
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));
|
|
@@ -2,6 +2,7 @@ import type { PropType, VNodeChild } from 'vue';
|
|
|
2
2
|
import type { BuiltinType, BuiltinTypeMap, ComponentConfig } from '../../_internal/component-renderer';
|
|
3
3
|
import type { ExtractPublicPropTypes } from '../../_utils';
|
|
4
4
|
import type { ButtonProps } from '../../button';
|
|
5
|
+
import type { EmptyProps } from '../../empty';
|
|
5
6
|
import type { IconProps } from '../../icon';
|
|
6
7
|
import type { PaginationProps } from '../../pagination';
|
|
7
8
|
import type { SwitchProps } from '../../switch';
|
|
@@ -55,6 +56,7 @@ export interface MappingCardListInterface {
|
|
|
55
56
|
items?: MappingCardProps[];
|
|
56
57
|
pagination?: PaginationProps | false;
|
|
57
58
|
gap?: number;
|
|
59
|
+
emptyProps?: Partial<EmptyProps>;
|
|
58
60
|
}
|
|
59
61
|
export declare const mappingCardProps: {
|
|
60
62
|
readonly title: PropType<MappingCardInterface["title"]>;
|
|
@@ -104,6 +106,7 @@ export declare const mappingCardListProps: {
|
|
|
104
106
|
readonly type: NumberConstructor;
|
|
105
107
|
readonly default: 16;
|
|
106
108
|
};
|
|
109
|
+
readonly emptyProps: PropType<Partial<EmptyProps>>;
|
|
107
110
|
};
|
|
108
111
|
export type MappingCardProps = ExtractPublicPropTypes<typeof mappingCardProps>;
|
|
109
112
|
export type MappingCardListProps = ExtractPublicPropTypes<typeof mappingCardListProps>;
|
|
@@ -92,6 +92,13 @@ exports.default = (0, cssr_1.c)([(0, cssr_1.cB)('mapping-card', `
|
|
|
92
92
|
color: var(--u-arrow-color);
|
|
93
93
|
font-size: 16px;
|
|
94
94
|
flex-shrink: 0;
|
|
95
|
-
`)]), (0, cssr_1.cB)('mapping-card-list',
|
|
95
|
+
`)]), (0, cssr_1.cB)('mapping-card-list', `
|
|
96
|
+
display: flex;
|
|
97
|
+
justify-content: space-between;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
height: 100%;
|
|
100
|
+
`, [(0, cssr_1.cE)('pagination', `
|
|
96
101
|
margin-top: 16px;
|
|
102
|
+
`), (0, cssr_1.cE)('empty', `
|
|
103
|
+
margin: auto;
|
|
97
104
|
`)])]);
|
|
@@ -55,6 +55,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
55
55
|
loading: BooleanConstructor;
|
|
56
56
|
bordered: BooleanConstructor;
|
|
57
57
|
iconPlacement: PropType<import("../../dialog/src/interface").IconPlacement>;
|
|
58
|
+
contentClass: StringConstructor;
|
|
59
|
+
contentScrollable: BooleanConstructor;
|
|
60
|
+
contentStyle: PropType<import("vue").CSSProperties | string>;
|
|
61
|
+
headerStyle: PropType<import("vue").CSSProperties | string>;
|
|
62
|
+
headerExtraStyle: PropType<import("vue").CSSProperties | string>;
|
|
63
|
+
footerStyle: PropType<import("vue").CSSProperties | string>;
|
|
64
|
+
embedded: BooleanConstructor;
|
|
65
|
+
segmented: {
|
|
66
|
+
readonly type: PropType<boolean | import("../../card").CardSegmented>;
|
|
67
|
+
readonly default: false;
|
|
68
|
+
};
|
|
69
|
+
hoverable: BooleanConstructor;
|
|
70
|
+
role: StringConstructor;
|
|
71
|
+
tag: {
|
|
72
|
+
readonly type: PropType<keyof HTMLElementTagNameMap>;
|
|
73
|
+
readonly default: "div";
|
|
74
|
+
};
|
|
58
75
|
show: {
|
|
59
76
|
type: BooleanConstructor;
|
|
60
77
|
required: true;
|
|
@@ -1283,6 +1300,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
1283
1300
|
loading: BooleanConstructor;
|
|
1284
1301
|
bordered: BooleanConstructor;
|
|
1285
1302
|
iconPlacement: PropType<import("../../dialog/src/interface").IconPlacement>;
|
|
1303
|
+
contentClass: StringConstructor;
|
|
1304
|
+
contentScrollable: BooleanConstructor;
|
|
1305
|
+
contentStyle: PropType<import("vue").CSSProperties | string>;
|
|
1306
|
+
headerStyle: PropType<import("vue").CSSProperties | string>;
|
|
1307
|
+
headerExtraStyle: PropType<import("vue").CSSProperties | string>;
|
|
1308
|
+
footerStyle: PropType<import("vue").CSSProperties | string>;
|
|
1309
|
+
embedded: BooleanConstructor;
|
|
1310
|
+
segmented: {
|
|
1311
|
+
readonly type: PropType<boolean | import("../../card").CardSegmented>;
|
|
1312
|
+
readonly default: false;
|
|
1313
|
+
};
|
|
1314
|
+
hoverable: BooleanConstructor;
|
|
1315
|
+
role: StringConstructor;
|
|
1316
|
+
tag: {
|
|
1317
|
+
readonly type: PropType<keyof HTMLElementTagNameMap>;
|
|
1318
|
+
readonly default: "div";
|
|
1319
|
+
};
|
|
1286
1320
|
show: {
|
|
1287
1321
|
type: BooleanConstructor;
|
|
1288
1322
|
required: true;
|
|
@@ -1310,8 +1344,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
1310
1344
|
type: "default" | "error" | "warning" | "success" | "info";
|
|
1311
1345
|
size: "small" | "medium" | "large";
|
|
1312
1346
|
loading: boolean;
|
|
1347
|
+
tag: keyof HTMLElementTagNameMap;
|
|
1313
1348
|
showIcon: boolean;
|
|
1314
1349
|
closable: boolean;
|
|
1350
|
+
contentScrollable: boolean;
|
|
1351
|
+
embedded: boolean;
|
|
1352
|
+
segmented: boolean | import("../../card").CardSegmented;
|
|
1353
|
+
hoverable: boolean;
|
|
1315
1354
|
draggable: boolean | ModalDraggableOptions;
|
|
1316
1355
|
trapFocus: boolean;
|
|
1317
1356
|
autoFocus: boolean;
|