@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
|
@@ -246,6 +246,8 @@ export default defineComponent({
|
|
|
246
246
|
const keyId = toKeyString(chat === null || chat === void 0 ? void 0 : chat.id);
|
|
247
247
|
const keyTitle = toKeyString(chat === null || chat === void 0 ? void 0 : chat.title);
|
|
248
248
|
return h("div", {
|
|
249
|
+
class: `${mergedClsPrefixRef.value}-chat-main__header`
|
|
250
|
+
}, h("div", {
|
|
249
251
|
class: `${mergedClsPrefixRef.value}-chat-main__header-inner`
|
|
250
252
|
}, h("div", {
|
|
251
253
|
class: `${mergedClsPrefixRef.value}-chat-main__header-title-wrap`
|
|
@@ -344,7 +346,7 @@ export default defineComponent({
|
|
|
344
346
|
}));
|
|
345
347
|
return buttons;
|
|
346
348
|
})
|
|
347
|
-
}));
|
|
349
|
+
})));
|
|
348
350
|
};
|
|
349
351
|
const renderMessages = () => {
|
|
350
352
|
var _a;
|
package/es/components.d.ts
CHANGED
|
@@ -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(".").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;
|
|
@@ -9,8 +9,9 @@ import { call, resolveSlot, resolveWrappedSlot, warnOnce } from "../../_utils/in
|
|
|
9
9
|
import { UxButton } from "../../button/index.mjs";
|
|
10
10
|
import { UInput } from "../../input/index.mjs";
|
|
11
11
|
import { inputNumberLight } from "../styles/index.mjs";
|
|
12
|
+
import { MAX_AMOUNT_INPUT_DIGITS } from "./constants.mjs";
|
|
13
|
+
import { parse, validator, format, parseNumber, isWipValue, getPrecision, parseAmount, formatAmount, isValidAmountInput, isAmountInputWithinDigitLimit, isRawWipValue, mapSelectionAfterFormat, getRejectedSelectionRange } from "./utils.mjs";
|
|
12
14
|
import style from "./styles/input-number.cssr.mjs";
|
|
13
|
-
import { format, isWipValue, parse, parseNumber, validator } from "./utils.mjs";
|
|
14
15
|
const HOLDING_CHANGE_THRESHOLD = 800;
|
|
15
16
|
const HOLDING_CHANGE_INTERVAL = 100;
|
|
16
17
|
export const inputNumberProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
@@ -59,6 +60,10 @@ export const inputNumberProps = Object.assign(Object.assign({}, useTheme.props),
|
|
|
59
60
|
type: Boolean,
|
|
60
61
|
default: true
|
|
61
62
|
},
|
|
63
|
+
type: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: 'default'
|
|
66
|
+
},
|
|
62
67
|
parse: Function,
|
|
63
68
|
format: Function,
|
|
64
69
|
precision: Number,
|
|
@@ -107,10 +112,6 @@ export default defineComponent({
|
|
|
107
112
|
const controlledValueRef = toRef(props, 'value');
|
|
108
113
|
const mergedValueRef = useMergedState(controlledValueRef, uncontrolledValueRef);
|
|
109
114
|
const displayedValueRef = ref('');
|
|
110
|
-
const getPrecision = value => {
|
|
111
|
-
const fraction = String(value).split('.')[1];
|
|
112
|
-
return fraction ? fraction.length : 0;
|
|
113
|
-
};
|
|
114
115
|
const getMaxPrecision = currentValue => {
|
|
115
116
|
const precisions = [props.min, props.max, props.step, currentValue].map(value => {
|
|
116
117
|
if (value === undefined) return 0;
|
|
@@ -140,6 +141,44 @@ export default defineComponent({
|
|
|
140
141
|
const parsedNumber = parseNumber(props.max);
|
|
141
142
|
if (parsedNumber !== null) return parsedNumber;else return null;
|
|
142
143
|
});
|
|
144
|
+
const isAmountTypeRef = useMemo(() => props.type === 'amount');
|
|
145
|
+
const showButtonRef = useMemo(() => {
|
|
146
|
+
return isAmountTypeRef.value ? false : props.showButton;
|
|
147
|
+
});
|
|
148
|
+
const effectiveParse = input => {
|
|
149
|
+
if (props.parse) return props.parse(input);
|
|
150
|
+
if (isAmountTypeRef.value) return parseAmount(input);
|
|
151
|
+
return parse(input);
|
|
152
|
+
};
|
|
153
|
+
const effectiveFormat = (value, precision) => {
|
|
154
|
+
if (props.format && value !== undefined) return props.format(value);
|
|
155
|
+
if (isAmountTypeRef.value) return formatAmount(value, precision);
|
|
156
|
+
return format(value, precision);
|
|
157
|
+
};
|
|
158
|
+
const doUpdateValue = value => {
|
|
159
|
+
const {
|
|
160
|
+
value: mergedValue
|
|
161
|
+
} = mergedValueRef;
|
|
162
|
+
if (value === mergedValue) {
|
|
163
|
+
deriveDisplayedValueFromValue();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const {
|
|
167
|
+
'onUpdate:value': _onUpdateValue,
|
|
168
|
+
onUpdateValue,
|
|
169
|
+
onChange
|
|
170
|
+
} = props;
|
|
171
|
+
const {
|
|
172
|
+
triggerFormInput,
|
|
173
|
+
triggerFormChange
|
|
174
|
+
} = formItem;
|
|
175
|
+
if (onChange) call(onChange, value);
|
|
176
|
+
if (onUpdateValue) call(onUpdateValue, value);
|
|
177
|
+
if (_onUpdateValue) call(_onUpdateValue, value);
|
|
178
|
+
uncontrolledValueRef.value = value;
|
|
179
|
+
triggerFormInput();
|
|
180
|
+
triggerFormChange();
|
|
181
|
+
};
|
|
143
182
|
const deriveValueFromDisplayedValue = ({
|
|
144
183
|
offset,
|
|
145
184
|
doUpdateIfValid,
|
|
@@ -152,7 +191,7 @@ export default defineComponent({
|
|
|
152
191
|
if (isInputing && isWipValue(displayedValue)) {
|
|
153
192
|
return false;
|
|
154
193
|
}
|
|
155
|
-
const parsedValue = (
|
|
194
|
+
const parsedValue = effectiveParse(displayedValue);
|
|
156
195
|
if (parsedValue === null) {
|
|
157
196
|
if (doUpdateIfValid) doUpdateValue(null);
|
|
158
197
|
return null;
|
|
@@ -196,51 +235,69 @@ export default defineComponent({
|
|
|
196
235
|
} = mergedValueRef;
|
|
197
236
|
if (validator(mergedValue)) {
|
|
198
237
|
const {
|
|
199
|
-
format: formatProp,
|
|
200
238
|
precision
|
|
201
239
|
} = props;
|
|
202
|
-
|
|
203
|
-
displayedValueRef.value = formatProp(mergedValue);
|
|
204
|
-
} else {
|
|
205
|
-
if (mergedValue === null || precision === undefined
|
|
206
|
-
// precision overflow
|
|
207
|
-
|| getPrecision(mergedValue) > precision) {
|
|
208
|
-
displayedValueRef.value = format(mergedValue, undefined);
|
|
209
|
-
} else {
|
|
210
|
-
displayedValueRef.value = format(mergedValue, precision);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
240
|
+
displayedValueRef.value = effectiveFormat(mergedValue, mergedValue === null ? undefined : precision);
|
|
213
241
|
} else {
|
|
214
242
|
// null can pass the validator check
|
|
215
243
|
// so mergedValue is a number
|
|
216
244
|
displayedValueRef.value = String(mergedValue);
|
|
217
245
|
}
|
|
218
246
|
};
|
|
219
|
-
|
|
220
|
-
|
|
247
|
+
const computeValueToFormat = (prev, derived) => {
|
|
248
|
+
if (derived !== false && derived !== null) return derived;
|
|
249
|
+
if (!isAmountTypeRef.value) return null;
|
|
250
|
+
const parsed = effectiveParse(prev);
|
|
251
|
+
if (parsed === null || Number.isNaN(parsed)) return null;
|
|
252
|
+
return parsed;
|
|
253
|
+
};
|
|
254
|
+
const setInputValueSelection = (value, selectionStart, selectionEnd) => {
|
|
255
|
+
var _a;
|
|
256
|
+
const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
|
|
257
|
+
if (!inputElement) return;
|
|
258
|
+
inputElement.value = value;
|
|
259
|
+
inputElement.setSelectionRange(selectionStart, selectionEnd);
|
|
260
|
+
};
|
|
261
|
+
const applyFormatted = (prev, valueNumber) => {
|
|
262
|
+
var _a, _b, _c;
|
|
263
|
+
const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
|
|
264
|
+
const selectionStart = (_b = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionStart) !== null && _b !== void 0 ? _b : prev.length;
|
|
265
|
+
const selectionEnd = (_c = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionEnd) !== null && _c !== void 0 ? _c : selectionStart;
|
|
266
|
+
const newFormatted = effectiveFormat(valueNumber, props.precision);
|
|
267
|
+
displayedValueRef.value = newFormatted;
|
|
268
|
+
void nextTick(() => {
|
|
269
|
+
const {
|
|
270
|
+
start,
|
|
271
|
+
end
|
|
272
|
+
} = mapSelectionAfterFormat(prev, newFormatted, selectionStart, selectionEnd);
|
|
273
|
+
inputElement === null || inputElement === void 0 ? void 0 : inputElement.setSelectionRange(start, end);
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
const restoreRejectedAmountInput = (prevDisplayedValue, attemptedDisplayedValue) => {
|
|
277
|
+
var _a, _b, _c;
|
|
278
|
+
const inputElement = (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.inputElRef;
|
|
279
|
+
const selectionStart = (_b = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionStart) !== null && _b !== void 0 ? _b : attemptedDisplayedValue.length;
|
|
280
|
+
const selectionEnd = (_c = inputElement === null || inputElement === void 0 ? void 0 : inputElement.selectionEnd) !== null && _c !== void 0 ? _c : selectionStart;
|
|
221
281
|
const {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
282
|
+
start,
|
|
283
|
+
end
|
|
284
|
+
} = getRejectedSelectionRange(prevDisplayedValue, attemptedDisplayedValue, selectionStart, selectionEnd);
|
|
285
|
+
displayedValueRef.value = prevDisplayedValue;
|
|
286
|
+
setInputValueSelection(prevDisplayedValue, start, end);
|
|
287
|
+
void nextTick(() => {
|
|
288
|
+
setInputValueSelection(prevDisplayedValue, start, end);
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
const shouldRejectAmountInput = value => {
|
|
292
|
+
if (!isValidAmountInput(value)) return true;
|
|
293
|
+
if (!isAmountInputWithinDigitLimit(value, MAX_AMOUNT_INPUT_DIGITS)) {
|
|
294
|
+
return true;
|
|
227
295
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const {
|
|
234
|
-
triggerFormInput,
|
|
235
|
-
triggerFormChange
|
|
236
|
-
} = formItem;
|
|
237
|
-
if (onChange) call(onChange, value);
|
|
238
|
-
if (onUpdateValue) call(onUpdateValue, value);
|
|
239
|
-
if (_onUpdateValue) call(_onUpdateValue, value);
|
|
240
|
-
uncontrolledValueRef.value = value;
|
|
241
|
-
triggerFormInput();
|
|
242
|
-
triggerFormChange();
|
|
243
|
-
}
|
|
296
|
+
if (props.precision === undefined) return false;
|
|
297
|
+
const parsedValue = effectiveParse(value);
|
|
298
|
+
return parsedValue !== null && !Number.isNaN(parsedValue) && getPrecision(parsedValue) > props.precision;
|
|
299
|
+
};
|
|
300
|
+
deriveDisplayedValueFromValue();
|
|
244
301
|
const displayedValueInvalidRef = useMemo(() => {
|
|
245
302
|
const derivedValue = deriveValueFromDisplayedValue({
|
|
246
303
|
offset: 0,
|
|
@@ -532,15 +589,30 @@ export default defineComponent({
|
|
|
532
589
|
}
|
|
533
590
|
}
|
|
534
591
|
}
|
|
592
|
+
const shouldTryFormat = () => props.updateValueOnInput && !props.format && !props.parse && (props.precision === undefined || isAmountTypeRef.value);
|
|
535
593
|
function handleUpdateDisplayedValue(value) {
|
|
594
|
+
const prevDisplayedValue = displayedValueRef.value;
|
|
595
|
+
const prevFormatted = value;
|
|
596
|
+
if (isAmountTypeRef.value) {
|
|
597
|
+
if (shouldRejectAmountInput(value)) {
|
|
598
|
+
restoreRejectedAmountInput(prevDisplayedValue, value);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
536
602
|
displayedValueRef.value = value;
|
|
537
|
-
if (
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
603
|
+
if (!shouldTryFormat()) return;
|
|
604
|
+
if (isAmountTypeRef.value) {
|
|
605
|
+
if (isRawWipValue(prevFormatted)) return;
|
|
606
|
+
}
|
|
607
|
+
const derived = deriveValueFromDisplayedValue({
|
|
608
|
+
offset: 0,
|
|
609
|
+
doUpdateIfValid: true,
|
|
610
|
+
isInputing: true,
|
|
611
|
+
fixPrecision: false
|
|
612
|
+
});
|
|
613
|
+
const valueToFormat = computeValueToFormat(prevFormatted, derived);
|
|
614
|
+
if (valueToFormat !== null && isAmountTypeRef.value) {
|
|
615
|
+
applyFormatted(prevFormatted, valueToFormat);
|
|
544
616
|
}
|
|
545
617
|
}
|
|
546
618
|
watch(mergedValueRef, () => {
|
|
@@ -577,6 +649,7 @@ export default defineComponent({
|
|
|
577
649
|
displayedValue: displayedValueRef,
|
|
578
650
|
addable: addableRef,
|
|
579
651
|
minusable: minusableRef,
|
|
652
|
+
showButton: showButtonRef,
|
|
580
653
|
mergedStatus: mergedStatusRef,
|
|
581
654
|
handleFocus,
|
|
582
655
|
handleBlur,
|
|
@@ -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,15 @@
|
|
|
1
|
+
export const MAX_AMOUNT_INPUT_DIGITS = 16;
|
|
2
|
+
export var InputNumberRegex;
|
|
3
|
+
(function (InputNumberRegex) {
|
|
4
|
+
InputNumberRegex["INPUT_WIP_VALUE"] = "^(-)?\\d+.*(\\.|0)$";
|
|
5
|
+
InputNumberRegex["INPUT_LEADING_DOT_WIP_VALUE"] = "^\\.\\d+$";
|
|
6
|
+
InputNumberRegex["AMOUNT_INPUT"] = "^-?[\\d\\s]*\\.?\\d*$";
|
|
7
|
+
InputNumberRegex["AMOUNT_VALUE"] = "^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$";
|
|
8
|
+
InputNumberRegex["AMOUNT_RAW_LEADING_DOT"] = "^-?\\.\\d*$";
|
|
9
|
+
InputNumberRegex["WHITESPACE"] = "\\s";
|
|
10
|
+
InputNumberRegex["NON_DIGIT"] = "\\D";
|
|
11
|
+
InputNumberRegex["LEADING_ZEROS"] = "^0+(?=\\d)";
|
|
12
|
+
InputNumberRegex["NON_ZERO_DIGIT"] = "[1-9]";
|
|
13
|
+
InputNumberRegex["TRAILING_ZERO_FRACTION"] = "\\.?0+$";
|
|
14
|
+
InputNumberRegex["THOUSANDS_SEPARATOR"] = "\\B(?=(\\d{3})+(?!\\d))";
|
|
15
|
+
})(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;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InputNumberRegex, MAX_AMOUNT_INPUT_DIGITS } from "./constants.mjs";
|
|
2
|
+
const MAX_SAFE_INTEGER_LIMIT = String(Number.MAX_SAFE_INTEGER);
|
|
1
3
|
// string => string (expected, not implemented)
|
|
2
4
|
// string => number (legacy)
|
|
3
5
|
export function parse(value) {
|
|
@@ -9,7 +11,7 @@ export function parse(value) {
|
|
|
9
11
|
// can be parsed to number but shouldn't be applied when inputing
|
|
10
12
|
// when value includes `.`, ending with 0 and`.`, doesn't update, if 0 parse func will remove 0
|
|
11
13
|
export function isWipValue(value) {
|
|
12
|
-
return value.includes('.') && (
|
|
14
|
+
return value.includes('.') && (new RegExp(InputNumberRegex.INPUT_WIP_VALUE).test(value) || new RegExp(InputNumberRegex.INPUT_LEADING_DOT_WIP_VALUE).test(value));
|
|
13
15
|
}
|
|
14
16
|
// string => boolean (expected, not implemented)
|
|
15
17
|
// number => boolean (legacy)
|
|
@@ -36,4 +38,90 @@ export function parseNumber(number) {
|
|
|
36
38
|
return parsedNumber;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
}
|
|
42
|
+
export function getPrecision(value) {
|
|
43
|
+
const fraction = String(value).split('.')[1];
|
|
44
|
+
return fraction ? fraction.length : 0;
|
|
45
|
+
}
|
|
46
|
+
export function stripAmountFormatting(value) {
|
|
47
|
+
return String(value).replace(new RegExp(InputNumberRegex.WHITESPACE, 'g'), '').trim();
|
|
48
|
+
}
|
|
49
|
+
export function isValidAmountInput(value) {
|
|
50
|
+
return value === '' || new RegExp(InputNumberRegex.AMOUNT_INPUT).test(value);
|
|
51
|
+
}
|
|
52
|
+
export function isAmountInputWithinDigitLimit(value, maxDigits = MAX_AMOUNT_INPUT_DIGITS) {
|
|
53
|
+
return value.replace(new RegExp(InputNumberRegex.NON_DIGIT, 'g'), '').length <= maxDigits;
|
|
54
|
+
}
|
|
55
|
+
export function getRejectedSelectionRange(prevDisplayedValue, attemptedDisplayedValue, selectionStart, selectionEnd) {
|
|
56
|
+
const removedLength = Math.max(0, attemptedDisplayedValue.length - prevDisplayedValue.length);
|
|
57
|
+
return {
|
|
58
|
+
start: Math.min(prevDisplayedValue.length, Math.max(0, selectionStart - removedLength)),
|
|
59
|
+
end: Math.min(prevDisplayedValue.length, Math.max(0, selectionEnd - removedLength))
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function exceedsMaxSafeAmountValue(numberString) {
|
|
63
|
+
const normalized = numberString.startsWith('-') ? numberString.slice(1) : numberString;
|
|
64
|
+
const [integerPart = '0', fractionPart = ''] = normalized.split('.');
|
|
65
|
+
const normalizedIntegerPart = integerPart.replace(new RegExp(InputNumberRegex.LEADING_ZEROS), '');
|
|
66
|
+
return normalizedIntegerPart.length > MAX_SAFE_INTEGER_LIMIT.length || normalizedIntegerPart.length === MAX_SAFE_INTEGER_LIMIT.length && (normalizedIntegerPart > MAX_SAFE_INTEGER_LIMIT || normalizedIntegerPart === MAX_SAFE_INTEGER_LIMIT && new RegExp(InputNumberRegex.NON_ZERO_DIGIT).test(fractionPart));
|
|
67
|
+
}
|
|
68
|
+
export function parseAmount(input) {
|
|
69
|
+
if (input === undefined || input === null) return null;
|
|
70
|
+
const numberString = stripAmountFormatting(input);
|
|
71
|
+
if (new RegExp(InputNumberRegex.AMOUNT_VALUE).test(numberString)) {
|
|
72
|
+
if (exceedsMaxSafeAmountValue(numberString)) return Number.NaN;
|
|
73
|
+
return Number(numberString);
|
|
74
|
+
}
|
|
75
|
+
return numberString === '' ? null : Number.NaN;
|
|
76
|
+
}
|
|
77
|
+
export function formatAmount(value, precision) {
|
|
78
|
+
if (value === undefined || value === null) return '';
|
|
79
|
+
let stringValue = String(value);
|
|
80
|
+
if (precision !== undefined) {
|
|
81
|
+
stringValue = value.toFixed(precision).replace(new RegExp(InputNumberRegex.TRAILING_ZERO_FRACTION), '');
|
|
82
|
+
}
|
|
83
|
+
const negative = stringValue.startsWith('-');
|
|
84
|
+
if (negative) stringValue = stringValue.slice(1);
|
|
85
|
+
const [integerPart, fractionPart] = stringValue.split('.');
|
|
86
|
+
const integerWithSeparator = integerPart.replace(new RegExp(InputNumberRegex.THOUSANDS_SEPARATOR, 'g'), ' ');
|
|
87
|
+
return `${negative ? '-' : ''}${integerWithSeparator}${fractionPart ? `.${fractionPart}` : ''}`;
|
|
88
|
+
}
|
|
89
|
+
export function formattedToRawIndex(formatted, caret) {
|
|
90
|
+
let raw = 0;
|
|
91
|
+
for (let i = 0; i < Math.min(caret, formatted.length); i++) {
|
|
92
|
+
if (formatted[i] !== ' ') raw++;
|
|
93
|
+
}
|
|
94
|
+
return raw;
|
|
95
|
+
}
|
|
96
|
+
export function rawIndexToCaret(formatted, rawIndex) {
|
|
97
|
+
if (rawIndex <= 0) return 0;
|
|
98
|
+
let raw = 0;
|
|
99
|
+
for (let i = 0; i < formatted.length; i++) {
|
|
100
|
+
if (formatted[i] !== ' ') raw++;
|
|
101
|
+
if (raw === rawIndex) return i + 1;
|
|
102
|
+
}
|
|
103
|
+
return formatted.length;
|
|
104
|
+
}
|
|
105
|
+
export function isRawWipValue(formatted) {
|
|
106
|
+
return isWipValue(stripAmountFormatting(formatted));
|
|
107
|
+
}
|
|
108
|
+
export function mapSelectionAfterFormat(formatted, newFormatted, selectionStart, selectionEnd) {
|
|
109
|
+
const rawStart = formattedToRawIndex(formatted, selectionStart);
|
|
110
|
+
const rawEnd = formattedToRawIndex(formatted, selectionEnd);
|
|
111
|
+
const rawInput = stripAmountFormatting(formatted);
|
|
112
|
+
if (new RegExp(InputNumberRegex.AMOUNT_RAW_LEADING_DOT).test(rawInput)) {
|
|
113
|
+
const {
|
|
114
|
+
length
|
|
115
|
+
} = newFormatted;
|
|
116
|
+
return {
|
|
117
|
+
start: length,
|
|
118
|
+
end: length
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const newStart = rawIndexToCaret(newFormatted, rawStart);
|
|
122
|
+
const newEnd = rawIndexToCaret(newFormatted, rawEnd);
|
|
123
|
+
return {
|
|
124
|
+
start: newStart,
|
|
125
|
+
end: newEnd
|
|
126
|
+
};
|
|
39
127
|
}
|
|
@@ -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("../..").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("../..").EmptyProps>>;
|
|
31
33
|
}>> & Readonly<{}>, {
|
|
32
34
|
readonly gap: number;
|
|
33
35
|
readonly items: import("./interface").MappingCardProps[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { computed, defineComponent, h } from 'vue';
|
|
2
2
|
import { useConfig } from "../../_mixins/index.mjs";
|
|
3
|
+
import { resolveSlot } from "../../_utils/index.mjs";
|
|
4
|
+
import { UEmpty } from "../../empty/index.mjs";
|
|
3
5
|
import { UFlex } from "../../flex/index.mjs";
|
|
4
6
|
import { UPagination } from "../../pagination/index.mjs";
|
|
5
7
|
import { mappingCardListProps } from "./interface.mjs";
|
|
@@ -28,11 +30,18 @@ export default defineComponent({
|
|
|
28
30
|
mergedClsPrefix,
|
|
29
31
|
mergedPagination,
|
|
30
32
|
gap,
|
|
31
|
-
items
|
|
33
|
+
items,
|
|
34
|
+
emptyProps,
|
|
35
|
+
$slots
|
|
32
36
|
} = this;
|
|
37
|
+
const isEmpty = !items.length;
|
|
33
38
|
return h("div", {
|
|
34
39
|
class: `${mergedClsPrefix}-mapping-card-list`
|
|
35
|
-
}, h(
|
|
40
|
+
}, isEmpty ? h("div", {
|
|
41
|
+
class: `${mergedClsPrefix}-mapping-card-list__empty`
|
|
42
|
+
}, resolveSlot($slots.empty, () => [h(UEmpty, Object.assign({
|
|
43
|
+
size: "large"
|
|
44
|
+
}, emptyProps))])) : h(UFlex, {
|
|
36
45
|
vertical: true,
|
|
37
46
|
size: gap,
|
|
38
47
|
class: `${mergedClsPrefix}-mapping-card-list__items`
|
|
@@ -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>;
|