@element-plus/nightly 0.0.20220106 → 0.0.20220107
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/attributes.json +1 -1
- package/dist/index.css +1 -1
- package/dist/index.full.js +92 -37
- package/dist/index.full.min.js +7 -7
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +7 -7
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +92 -37
- package/es/components/input-number/index.d.ts +2 -0
- package/es/components/input-number/src/input-number.vue.d.ts +2 -0
- package/es/components/input-number/src/input-number.vue_vue_type_script_lang.mjs +15 -1
- package/es/components/input-number/src/input-number.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs +5 -4
- package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs.map +1 -1
- package/es/components/message-box/src/index.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.mjs +1 -0
- package/es/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.mjs.map +1 -1
- package/es/components/rate/index.d.ts +7 -1
- package/es/components/rate/src/rate.d.ts +2 -0
- package/es/components/rate/src/rate.mjs +5 -0
- package/es/components/rate/src/rate.mjs.map +1 -1
- package/es/components/rate/src/rate.vue.d.ts +7 -1
- package/es/components/rate/src/rate.vue_vue_type_script_lang.mjs +6 -0
- package/es/components/rate/src/rate.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.mjs +3 -3
- package/es/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.mjs.map +1 -1
- package/es/components/slider/index.d.ts +22 -6
- package/es/components/slider/src/index.vue.d.ts +11 -3
- package/es/components/slider/src/index.vue_vue_type_script_lang.mjs +21 -2
- package/es/components/slider/src/index.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.mjs +19 -19
- package/es/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.mjs.map +1 -1
- package/es/components/switch/index.d.ts +5 -0
- package/es/components/switch/src/switch.d.ts +2 -0
- package/es/components/switch/src/switch.mjs +5 -0
- package/es/components/switch/src/switch.mjs.map +1 -1
- package/es/components/switch/src/switch.vue.d.ts +5 -0
- package/es/components/switch/src/switch.vue_vue_type_script_lang.mjs +10 -1
- package/es/components/switch/src/switch.vue_vue_type_script_lang.mjs.map +1 -1
- package/es/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.mjs +1 -1
- package/es/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.mjs.map +1 -1
- package/es/components/table/src/table-layout.mjs +1 -2
- package/es/components/table/src/table-layout.mjs.map +1 -1
- package/es/components/table/src/util.d.ts +2 -2
- package/es/components/table/src/util.mjs +9 -5
- package/es/components/table/src/util.mjs.map +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/input-number/index.d.ts +2 -0
- package/lib/components/input-number/src/input-number.vue.d.ts +2 -0
- package/lib/components/input-number/src/input-number.vue_vue_type_script_lang.js +18 -4
- package/lib/components/input-number/src/input-number.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.js +5 -4
- package/lib/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.js.map +1 -1
- package/lib/components/message-box/src/index.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.js +1 -0
- package/lib/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.js.map +1 -1
- package/lib/components/rate/index.d.ts +7 -1
- package/lib/components/rate/src/rate.d.ts +2 -0
- package/lib/components/rate/src/rate.js +5 -0
- package/lib/components/rate/src/rate.js.map +1 -1
- package/lib/components/rate/src/rate.vue.d.ts +7 -1
- package/lib/components/rate/src/rate.vue_vue_type_script_lang.js +6 -0
- package/lib/components/rate/src/rate.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.js +2 -2
- package/lib/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.js.map +1 -1
- package/lib/components/slider/index.d.ts +22 -6
- package/lib/components/slider/src/index.vue.d.ts +11 -3
- package/lib/components/slider/src/index.vue_vue_type_script_lang.js +21 -2
- package/lib/components/slider/src/index.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.js +18 -18
- package/lib/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.js.map +1 -1
- package/lib/components/switch/index.d.ts +5 -0
- package/lib/components/switch/src/switch.d.ts +2 -0
- package/lib/components/switch/src/switch.js +5 -0
- package/lib/components/switch/src/switch.js.map +1 -1
- package/lib/components/switch/src/switch.vue.d.ts +5 -0
- package/lib/components/switch/src/switch.vue_vue_type_script_lang.js +9 -0
- package/lib/components/switch/src/switch.vue_vue_type_script_lang.js.map +1 -1
- package/lib/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.js +1 -1
- package/lib/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.js.map +1 -1
- package/lib/components/table/src/table-layout.js +1 -2
- package/lib/components/table/src/table-layout.js.map +1 -1
- package/lib/components/table/src/util.d.ts +2 -2
- package/lib/components/table/src/util.js +9 -5
- package/lib/components/table/src/util.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/tags.json +1 -1
- package/theme-chalk/el-checkbox.css +1 -1
- package/theme-chalk/el-date-picker.css +1 -1
- package/theme-chalk/el-radio.css +1 -1
- package/theme-chalk/el-rate.css +1 -1
- package/theme-chalk/el-slider.css +1 -1
- package/theme-chalk/el-switch.css +1 -1
- package/theme-chalk/el-time-picker.css +1 -1
- package/theme-chalk/el-time-select.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/checkbox.scss +40 -6
- package/theme-chalk/src/common/var.scss +0 -2
- package/theme-chalk/src/date-picker/picker-panel.scss +1 -1
- package/theme-chalk/src/radio.scss +21 -0
- package/theme-chalk/src/rate.scss +19 -2
- package/theme-chalk/src/slider.scss +28 -77
- package/theme-chalk/src/switch.scss +43 -4
- package/web-types.json +1 -1
package/dist/index.full.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Element Plus v0.0.
|
|
1
|
+
/*! Element Plus v0.0.20220107 */
|
|
2
2
|
|
|
3
3
|
import { getCurrentInstance, computed, warn, readonly, getCurrentScope, onScopeDispose, shallowRef, watchSyncEffect, ref, unref, watch, inject, provide, isRef, onMounted, onUnmounted, h as h$1, Teleport, onBeforeUnmount, onBeforeMount, nextTick, defineComponent, reactive, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, renderSlot, mergeProps, resolveComponent, createBlock, Transition, withCtx, withDirectives, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, Fragment, createVNode, vShow, onUpdated, withModifiers, toRef, cloneVNode, Text, Comment, resolveDirective, renderList, withKeys, createSlots, normalizeProps, guardReactiveProps, toRefs, vModelCheckbox, vModelRadio, onBeforeUpdate, vModelText, toHandlers, watchEffect, isVNode, camelize as camelize$1, effectScope, markRaw, toRaw, triggerRef, TransitionGroup, createApp, render as render$26 } from 'vue';
|
|
4
4
|
|
|
@@ -4525,7 +4525,7 @@ if (isClient) {
|
|
|
4525
4525
|
});
|
|
4526
4526
|
}
|
|
4527
4527
|
|
|
4528
|
-
const version$1 = "0.0.
|
|
4528
|
+
const version$1 = "0.0.20220107";
|
|
4529
4529
|
|
|
4530
4530
|
const INSTALLED_KEY = Symbol("INSTALLED_KEY");
|
|
4531
4531
|
const makeInstaller = (components = []) => {
|
|
@@ -26938,6 +26938,7 @@ var script$T = defineComponent({
|
|
|
26938
26938
|
currentValue: props.modelValue,
|
|
26939
26939
|
userInput: null
|
|
26940
26940
|
});
|
|
26941
|
+
const { formItem } = useFormItem();
|
|
26941
26942
|
const minDisabled = computed(() => _decrease(props.modelValue) < props.min);
|
|
26942
26943
|
const maxDisabled = computed(() => _increase(props.modelValue) > props.max);
|
|
26943
26944
|
const numPrecision = computed(() => {
|
|
@@ -27013,6 +27014,7 @@ var script$T = defineComponent({
|
|
|
27013
27014
|
setCurrentValue(newVal);
|
|
27014
27015
|
};
|
|
27015
27016
|
const setCurrentValue = (newVal) => {
|
|
27017
|
+
var _a;
|
|
27016
27018
|
const oldVal = data.currentValue;
|
|
27017
27019
|
if (typeof newVal === "number" && props.precision !== void 0) {
|
|
27018
27020
|
newVal = toPrecision(newVal, props.precision);
|
|
@@ -27030,6 +27032,7 @@ var script$T = defineComponent({
|
|
|
27030
27032
|
emit("update:modelValue", newVal);
|
|
27031
27033
|
emit("input", newVal);
|
|
27032
27034
|
emit("change", newVal, oldVal);
|
|
27035
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
|
|
27033
27036
|
data.currentValue = newVal;
|
|
27034
27037
|
};
|
|
27035
27038
|
const handleInput = (value) => {
|
|
@@ -27050,6 +27053,14 @@ var script$T = defineComponent({
|
|
|
27050
27053
|
var _a, _b;
|
|
27051
27054
|
(_b = (_a = input.value) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
|
|
27052
27055
|
};
|
|
27056
|
+
const handleFocus = (event) => {
|
|
27057
|
+
emit("focus", event);
|
|
27058
|
+
};
|
|
27059
|
+
const handleBlur = (event) => {
|
|
27060
|
+
var _a;
|
|
27061
|
+
emit("blur", event);
|
|
27062
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
|
|
27063
|
+
};
|
|
27053
27064
|
watch(() => props.modelValue, (value) => {
|
|
27054
27065
|
let newVal = Number(value);
|
|
27055
27066
|
if (!isNaN(newVal)) {
|
|
@@ -27103,7 +27114,9 @@ var script$T = defineComponent({
|
|
|
27103
27114
|
maxDisabled,
|
|
27104
27115
|
minDisabled,
|
|
27105
27116
|
focus,
|
|
27106
|
-
blur
|
|
27117
|
+
blur,
|
|
27118
|
+
handleFocus,
|
|
27119
|
+
handleBlur
|
|
27107
27120
|
};
|
|
27108
27121
|
}
|
|
27109
27122
|
});
|
|
@@ -27124,7 +27137,7 @@ function render$O(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
27124
27137
|
{ "is-without-controls": !_ctx.controls },
|
|
27125
27138
|
{ "is-controls-right": _ctx.controlsAtRight }
|
|
27126
27139
|
]),
|
|
27127
|
-
onDragstart: _cache[
|
|
27140
|
+
onDragstart: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
27128
27141
|
}, ["prevent"]))
|
|
27129
27142
|
}, [
|
|
27130
27143
|
_ctx.controls ? withDirectives((openBlock(), createElementBlock("span", {
|
|
@@ -27169,15 +27182,16 @@ function render$O(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
27169
27182
|
min: _ctx.min,
|
|
27170
27183
|
name: _ctx.name,
|
|
27171
27184
|
label: _ctx.label,
|
|
27185
|
+
"validate-event": false,
|
|
27172
27186
|
onKeydown: [
|
|
27173
27187
|
withKeys(withModifiers(_ctx.increase, ["prevent"]), ["up"]),
|
|
27174
27188
|
withKeys(withModifiers(_ctx.decrease, ["prevent"]), ["down"])
|
|
27175
27189
|
],
|
|
27176
|
-
onBlur:
|
|
27177
|
-
onFocus:
|
|
27190
|
+
onBlur: _ctx.handleBlur,
|
|
27191
|
+
onFocus: _ctx.handleFocus,
|
|
27178
27192
|
onInput: _ctx.handleInput,
|
|
27179
27193
|
onChange: _ctx.handleInputChange
|
|
27180
|
-
}, null, 8, ["step", "model-value", "placeholder", "disabled", "size", "max", "min", "name", "label", "onKeydown", "onInput", "onChange"])
|
|
27194
|
+
}, null, 8, ["step", "model-value", "placeholder", "disabled", "size", "max", "min", "name", "label", "onKeydown", "onBlur", "onFocus", "onInput", "onChange"])
|
|
27181
27195
|
], 34);
|
|
27182
27196
|
}
|
|
27183
27197
|
|
|
@@ -31135,6 +31149,10 @@ const rateProps = buildProps({
|
|
|
31135
31149
|
scoreTemplate: {
|
|
31136
31150
|
type: String,
|
|
31137
31151
|
default: "{value}"
|
|
31152
|
+
},
|
|
31153
|
+
size: {
|
|
31154
|
+
type: String,
|
|
31155
|
+
validator: isValidComponentSize
|
|
31138
31156
|
}
|
|
31139
31157
|
});
|
|
31140
31158
|
const rateEmits = {
|
|
@@ -31163,9 +31181,12 @@ var script$A = defineComponent({
|
|
|
31163
31181
|
emits: rateEmits,
|
|
31164
31182
|
setup(props, { emit }) {
|
|
31165
31183
|
const elForm = inject(elFormKey, {});
|
|
31184
|
+
const rateSize = useSize();
|
|
31166
31185
|
const currentValue = ref(props.modelValue);
|
|
31167
31186
|
const hoverIndex = ref(-1);
|
|
31168
31187
|
const pointerAtLeftHalf = ref(true);
|
|
31188
|
+
const prefix = "el-rate";
|
|
31189
|
+
const rateKls = computed(() => [prefix, `${prefix}--${rateSize.value}`]);
|
|
31169
31190
|
const rateDisabled = computed(() => props.disabled || elForm.disabled);
|
|
31170
31191
|
const text = computed(() => {
|
|
31171
31192
|
let result = "";
|
|
@@ -31313,6 +31334,7 @@ var script$A = defineComponent({
|
|
|
31313
31334
|
decimalStyle,
|
|
31314
31335
|
decimalIconComponent,
|
|
31315
31336
|
iconComponents,
|
|
31337
|
+
rateKls,
|
|
31316
31338
|
showDecimalIcon,
|
|
31317
31339
|
getIconStyle,
|
|
31318
31340
|
selectValue,
|
|
@@ -31328,7 +31350,7 @@ const _hoisted_2$i = ["onMousemove", "onClick"];
|
|
|
31328
31350
|
function render$v(_ctx, _cache, $props, $setup, $data, $options) {
|
|
31329
31351
|
const _component_el_icon = resolveComponent("el-icon");
|
|
31330
31352
|
return openBlock(), createElementBlock("div", {
|
|
31331
|
-
class:
|
|
31353
|
+
class: normalizeClass(_ctx.rateKls),
|
|
31332
31354
|
role: "slider",
|
|
31333
31355
|
"aria-valuenow": _ctx.currentValue,
|
|
31334
31356
|
"aria-valuetext": _ctx.text,
|
|
@@ -31372,7 +31394,7 @@ function render$v(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
31372
31394
|
class: "el-rate__text",
|
|
31373
31395
|
style: normalizeStyle({ color: _ctx.textColor })
|
|
31374
31396
|
}, toDisplayString(_ctx.text), 5)) : createCommentVNode("v-if", true)
|
|
31375
|
-
],
|
|
31397
|
+
], 42, _hoisted_1$m);
|
|
31376
31398
|
}
|
|
31377
31399
|
|
|
31378
31400
|
script$A.render = render$v;
|
|
@@ -35264,9 +35286,13 @@ var script$p = defineComponent({
|
|
|
35264
35286
|
type: Boolean,
|
|
35265
35287
|
default: true
|
|
35266
35288
|
},
|
|
35289
|
+
size: {
|
|
35290
|
+
type: String,
|
|
35291
|
+
validator: isValidComponentSize
|
|
35292
|
+
},
|
|
35267
35293
|
inputSize: {
|
|
35268
35294
|
type: String,
|
|
35269
|
-
|
|
35295
|
+
validator: isValidComponentSize
|
|
35270
35296
|
},
|
|
35271
35297
|
showStops: {
|
|
35272
35298
|
type: Boolean,
|
|
@@ -35336,6 +35362,15 @@ var script$p = defineComponent({
|
|
|
35336
35362
|
setSecondValue
|
|
35337
35363
|
} = useSlide(props, initData, emit);
|
|
35338
35364
|
const { stops, getStopStyle } = useStops(props, initData, minValue, maxValue);
|
|
35365
|
+
const sliderWrapperSize = useSize();
|
|
35366
|
+
const sliderInputSize = computed(() => props.inputSize || sliderWrapperSize.value);
|
|
35367
|
+
const prefix = "el-slider";
|
|
35368
|
+
const sliderKls = computed(() => [
|
|
35369
|
+
prefix,
|
|
35370
|
+
`${prefix}--${sliderWrapperSize.value}`,
|
|
35371
|
+
props.vertical ? "is-vertical" : "",
|
|
35372
|
+
props.showInput ? "el-slider--with-input" : ""
|
|
35373
|
+
]);
|
|
35339
35374
|
const markList = useMarks(props);
|
|
35340
35375
|
useWatch(props, initData, minValue, maxValue, emit, elFormItem);
|
|
35341
35376
|
const precision = computed(() => {
|
|
@@ -35378,7 +35413,10 @@ var script$p = defineComponent({
|
|
|
35378
35413
|
setSecondValue,
|
|
35379
35414
|
stops,
|
|
35380
35415
|
markList,
|
|
35381
|
-
sliderWrapper
|
|
35416
|
+
sliderWrapper,
|
|
35417
|
+
sliderWrapperSize,
|
|
35418
|
+
sliderInputSize,
|
|
35419
|
+
sliderKls
|
|
35382
35420
|
};
|
|
35383
35421
|
}
|
|
35384
35422
|
});
|
|
@@ -35489,33 +35527,18 @@ const _hoisted_1$h = ["aria-valuemin", "aria-valuemax", "aria-orientation", "ari
|
|
|
35489
35527
|
const _hoisted_2$e = { key: 1 };
|
|
35490
35528
|
const _hoisted_3$c = { class: "el-slider__marks" };
|
|
35491
35529
|
function render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
35492
|
-
const _component_el_input_number = resolveComponent("el-input-number");
|
|
35493
35530
|
const _component_slider_button = resolveComponent("slider-button");
|
|
35494
35531
|
const _component_slider_marker = resolveComponent("slider-marker");
|
|
35532
|
+
const _component_el_input_number = resolveComponent("el-input-number");
|
|
35495
35533
|
return openBlock(), createElementBlock("div", {
|
|
35496
35534
|
ref: "sliderWrapper",
|
|
35497
|
-
class: normalizeClass(
|
|
35535
|
+
class: normalizeClass(_ctx.sliderKls),
|
|
35498
35536
|
role: "slider",
|
|
35499
35537
|
"aria-valuemin": _ctx.min,
|
|
35500
35538
|
"aria-valuemax": _ctx.max,
|
|
35501
35539
|
"aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
|
|
35502
35540
|
"aria-disabled": _ctx.sliderDisabled
|
|
35503
35541
|
}, [
|
|
35504
|
-
_ctx.showInput && !_ctx.range ? (openBlock(), createBlock(_component_el_input_number, {
|
|
35505
|
-
key: 0,
|
|
35506
|
-
ref: "input",
|
|
35507
|
-
"model-value": _ctx.firstValue,
|
|
35508
|
-
class: "el-slider__input",
|
|
35509
|
-
step: _ctx.step,
|
|
35510
|
-
disabled: _ctx.sliderDisabled,
|
|
35511
|
-
controls: _ctx.showInputControls,
|
|
35512
|
-
min: _ctx.min,
|
|
35513
|
-
max: _ctx.max,
|
|
35514
|
-
debounce: _ctx.debounce,
|
|
35515
|
-
size: _ctx.inputSize,
|
|
35516
|
-
"onUpdate:modelValue": _ctx.setFirstValue,
|
|
35517
|
-
onChange: _ctx.emitChange
|
|
35518
|
-
}, null, 8, ["model-value", "step", "disabled", "controls", "min", "max", "debounce", "size", "onUpdate:modelValue", "onChange"])) : createCommentVNode("v-if", true),
|
|
35519
35542
|
createElementVNode("div", {
|
|
35520
35543
|
ref: "slider",
|
|
35521
35544
|
class: normalizeClass(["el-slider__runway", { "show-input": _ctx.showInput && !_ctx.range, disabled: _ctx.sliderDisabled }]),
|
|
@@ -35570,7 +35593,22 @@ function render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
35570
35593
|
}), 128))
|
|
35571
35594
|
])
|
|
35572
35595
|
], 64)) : createCommentVNode("v-if", true)
|
|
35573
|
-
], 6)
|
|
35596
|
+
], 6),
|
|
35597
|
+
_ctx.showInput && !_ctx.range ? (openBlock(), createBlock(_component_el_input_number, {
|
|
35598
|
+
key: 0,
|
|
35599
|
+
ref: "input",
|
|
35600
|
+
"model-value": _ctx.firstValue,
|
|
35601
|
+
class: "el-slider__input",
|
|
35602
|
+
step: _ctx.step,
|
|
35603
|
+
disabled: _ctx.sliderDisabled,
|
|
35604
|
+
controls: _ctx.showInputControls,
|
|
35605
|
+
min: _ctx.min,
|
|
35606
|
+
max: _ctx.max,
|
|
35607
|
+
debounce: _ctx.debounce,
|
|
35608
|
+
size: _ctx.sliderInputSize,
|
|
35609
|
+
"onUpdate:modelValue": _ctx.setFirstValue,
|
|
35610
|
+
onChange: _ctx.emitChange
|
|
35611
|
+
}, null, 8, ["model-value", "step", "disabled", "controls", "min", "max", "debounce", "size", "onUpdate:modelValue", "onChange"])) : createCommentVNode("v-if", true)
|
|
35574
35612
|
], 10, _hoisted_1$h);
|
|
35575
35613
|
}
|
|
35576
35614
|
|
|
@@ -36151,6 +36189,10 @@ const switchProps = buildProps({
|
|
|
36151
36189
|
},
|
|
36152
36190
|
beforeChange: {
|
|
36153
36191
|
type: definePropType(Function)
|
|
36192
|
+
},
|
|
36193
|
+
size: {
|
|
36194
|
+
type: String,
|
|
36195
|
+
validator: isValidComponentSize
|
|
36154
36196
|
}
|
|
36155
36197
|
});
|
|
36156
36198
|
const switchEmits = {
|
|
@@ -36168,9 +36210,17 @@ var script$l = defineComponent({
|
|
|
36168
36210
|
setup(props, { emit }) {
|
|
36169
36211
|
const { formItem } = useFormItem();
|
|
36170
36212
|
const switchDisabled = useDisabled$1(computed(() => props.loading));
|
|
36213
|
+
const switchSize = useSize();
|
|
36171
36214
|
const isModelValue = ref(props.modelValue !== false);
|
|
36172
36215
|
const input = ref();
|
|
36173
36216
|
const core = ref();
|
|
36217
|
+
const prefix = "el-switch";
|
|
36218
|
+
const switchKls = computed(() => [
|
|
36219
|
+
prefix,
|
|
36220
|
+
`${prefix}--${switchSize.value}`,
|
|
36221
|
+
switchDisabled.value ? "is-disabled" : "",
|
|
36222
|
+
checked.value ? "is-checked" : ""
|
|
36223
|
+
]);
|
|
36174
36224
|
watch(() => props.modelValue, () => {
|
|
36175
36225
|
isModelValue.value = true;
|
|
36176
36226
|
});
|
|
@@ -36254,6 +36304,7 @@ var script$l = defineComponent({
|
|
|
36254
36304
|
core,
|
|
36255
36305
|
switchDisabled,
|
|
36256
36306
|
checked,
|
|
36307
|
+
switchKls,
|
|
36257
36308
|
handleChange,
|
|
36258
36309
|
switchValue,
|
|
36259
36310
|
focus
|
|
@@ -36276,7 +36327,7 @@ function render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
36276
36327
|
const _component_el_icon = resolveComponent("el-icon");
|
|
36277
36328
|
const _component_loading = resolveComponent("loading");
|
|
36278
36329
|
return openBlock(), createElementBlock("div", {
|
|
36279
|
-
class: normalizeClass(
|
|
36330
|
+
class: normalizeClass(_ctx.switchKls),
|
|
36280
36331
|
role: "switch",
|
|
36281
36332
|
"aria-checked": _ctx.checked,
|
|
36282
36333
|
"aria-disabled": _ctx.switchDisabled,
|
|
@@ -36527,18 +36578,22 @@ function mergeOptions(defaults, config) {
|
|
|
36527
36578
|
return options;
|
|
36528
36579
|
}
|
|
36529
36580
|
function parseWidth(width) {
|
|
36581
|
+
if (width === "")
|
|
36582
|
+
return width;
|
|
36530
36583
|
if (width !== void 0) {
|
|
36531
36584
|
width = parseInt(width, 10);
|
|
36532
|
-
if (isNaN(width)) {
|
|
36533
|
-
width =
|
|
36585
|
+
if (Number.isNaN(width)) {
|
|
36586
|
+
width = "";
|
|
36534
36587
|
}
|
|
36535
36588
|
}
|
|
36536
|
-
return
|
|
36589
|
+
return width;
|
|
36537
36590
|
}
|
|
36538
36591
|
function parseMinWidth(minWidth) {
|
|
36539
|
-
if (
|
|
36592
|
+
if (minWidth === "")
|
|
36593
|
+
return minWidth;
|
|
36594
|
+
if (minWidth !== void 0) {
|
|
36540
36595
|
minWidth = parseWidth(minWidth);
|
|
36541
|
-
if (isNaN(minWidth)) {
|
|
36596
|
+
if (Number.isNaN(minWidth)) {
|
|
36542
36597
|
minWidth = 80;
|
|
36543
36598
|
}
|
|
36544
36599
|
}
|
|
@@ -37769,8 +37824,7 @@ class TableLayout {
|
|
|
37769
37824
|
if (this.bodyHeight.value === null) {
|
|
37770
37825
|
scrollY = false;
|
|
37771
37826
|
} else {
|
|
37772
|
-
|
|
37773
|
-
scrollY = body.offsetHeight > this.bodyHeight.value;
|
|
37827
|
+
scrollY = bodyWrapper.scrollHeight > this.bodyHeight.value;
|
|
37774
37828
|
}
|
|
37775
37829
|
this.scrollY.value = scrollY;
|
|
37776
37830
|
return prevScrollY !== scrollY;
|
|
@@ -47555,6 +47609,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
47555
47609
|
default: withCtx(() => [
|
|
47556
47610
|
withDirectives((openBlock(), createElementBlock("div", {
|
|
47557
47611
|
ref: "root",
|
|
47612
|
+
role: "dialog",
|
|
47558
47613
|
"aria-label": _ctx.title || "dialog",
|
|
47559
47614
|
"aria-modal": "true",
|
|
47560
47615
|
class: normalizeClass([
|
|
@@ -328,6 +328,8 @@ export declare const ElInputNumber: import("../../utils/types").SFCWithInstall<i
|
|
|
328
328
|
minDisabled: import("vue").ComputedRef<boolean>;
|
|
329
329
|
focus: () => void;
|
|
330
330
|
blur: () => void;
|
|
331
|
+
handleFocus: (event: MouseEvent) => void;
|
|
332
|
+
handleBlur: (event: MouseEvent) => void;
|
|
331
333
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
332
334
|
change: (prev: number, cur: number) => boolean;
|
|
333
335
|
blur: (e: FocusEvent) => boolean;
|
|
@@ -329,6 +329,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
329
329
|
minDisabled: import("vue").ComputedRef<boolean>;
|
|
330
330
|
focus: () => void;
|
|
331
331
|
blur: () => void;
|
|
332
|
+
handleFocus: (event: MouseEvent) => void;
|
|
333
|
+
handleBlur: (event: MouseEvent) => void;
|
|
332
334
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
333
335
|
change: (prev: number, cur: number) => boolean;
|
|
334
336
|
blur: (e: FocusEvent) => boolean;
|
|
@@ -8,6 +8,7 @@ import { debugWarn } from '../../../utils/error.mjs';
|
|
|
8
8
|
import { ArrowUp, ArrowDown, Plus, Minus } from '@element-plus/icons-vue';
|
|
9
9
|
import { inputNumberProps, inputNumberEmits } from './input-number.mjs';
|
|
10
10
|
import RepeatClick from '../../../directives/repeat-click/index.mjs';
|
|
11
|
+
import { useFormItem } from '../../../hooks/use-form-item/index.mjs';
|
|
11
12
|
import { useSize, useDisabled } from '../../../hooks/use-common-props/index.mjs';
|
|
12
13
|
|
|
13
14
|
var script = defineComponent({
|
|
@@ -31,6 +32,7 @@ var script = defineComponent({
|
|
|
31
32
|
currentValue: props.modelValue,
|
|
32
33
|
userInput: null
|
|
33
34
|
});
|
|
35
|
+
const { formItem } = useFormItem();
|
|
34
36
|
const minDisabled = computed(() => _decrease(props.modelValue) < props.min);
|
|
35
37
|
const maxDisabled = computed(() => _increase(props.modelValue) > props.max);
|
|
36
38
|
const numPrecision = computed(() => {
|
|
@@ -108,6 +110,7 @@ var script = defineComponent({
|
|
|
108
110
|
setCurrentValue(newVal);
|
|
109
111
|
};
|
|
110
112
|
const setCurrentValue = (newVal) => {
|
|
113
|
+
var _a;
|
|
111
114
|
const oldVal = data.currentValue;
|
|
112
115
|
if (typeof newVal === "number" && props.precision !== void 0) {
|
|
113
116
|
newVal = toPrecision(newVal, props.precision);
|
|
@@ -125,6 +128,7 @@ var script = defineComponent({
|
|
|
125
128
|
emit("update:modelValue", newVal);
|
|
126
129
|
emit("input", newVal);
|
|
127
130
|
emit("change", newVal, oldVal);
|
|
131
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
|
|
128
132
|
data.currentValue = newVal;
|
|
129
133
|
};
|
|
130
134
|
const handleInput = (value) => {
|
|
@@ -145,6 +149,14 @@ var script = defineComponent({
|
|
|
145
149
|
var _a, _b;
|
|
146
150
|
(_b = (_a = input.value) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
|
|
147
151
|
};
|
|
152
|
+
const handleFocus = (event) => {
|
|
153
|
+
emit("focus", event);
|
|
154
|
+
};
|
|
155
|
+
const handleBlur = (event) => {
|
|
156
|
+
var _a;
|
|
157
|
+
emit("blur", event);
|
|
158
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
|
|
159
|
+
};
|
|
148
160
|
watch(() => props.modelValue, (value) => {
|
|
149
161
|
let newVal = Number(value);
|
|
150
162
|
if (!isNaN(newVal)) {
|
|
@@ -198,7 +210,9 @@ var script = defineComponent({
|
|
|
198
210
|
maxDisabled,
|
|
199
211
|
minDisabled,
|
|
200
212
|
focus,
|
|
201
|
-
blur
|
|
213
|
+
blur,
|
|
214
|
+
handleFocus,
|
|
215
|
+
handleBlur
|
|
202
216
|
};
|
|
203
217
|
}
|
|
204
218
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-number.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/input-number/src/input-number.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'el-input-number',\n inputNumberSize ? 'el-input-number--' + inputNumberSize : '',\n { 'is-disabled': inputNumberDisabled },\n { 'is-without-controls': !controls },\n { 'is-controls-right': controlsAtRight },\n ]\"\n @dragstart.prevent\n >\n <span\n v-if=\"controls\"\n v-repeat-click=\"decrease\"\n class=\"el-input-number__decrease\"\n role=\"button\"\n :class=\"{ 'is-disabled': minDisabled }\"\n @keydown.enter=\"decrease\"\n >\n <el-icon>\n <arrow-down v-if=\"controlsAtRight\" />\n <minus v-else />\n </el-icon>\n </span>\n <span\n v-if=\"controls\"\n v-repeat-click=\"increase\"\n class=\"el-input-number__increase\"\n role=\"button\"\n :class=\"{ 'is-disabled': maxDisabled }\"\n @keydown.enter=\"increase\"\n >\n <el-icon>\n <arrow-up v-if=\"controlsAtRight\" />\n <plus v-else />\n </el-icon>\n </span>\n <el-input\n ref=\"input\"\n type=\"number\"\n :step=\"step\"\n :model-value=\"displayValue\"\n :placeholder=\"placeholder\"\n :disabled=\"inputNumberDisabled\"\n :size=\"inputNumberSize\"\n :max=\"max\"\n :min=\"min\"\n :name=\"name\"\n :label=\"label\"\n @keydown.up.prevent=\"increase\"\n @keydown.down.prevent=\"decrease\"\n @blur=\"(event) => $emit('blur', event)\"\n @focus=\"(event) => $emit('focus', event)\"\n @input=\"handleInput\"\n @change=\"handleInputChange\"\n />\n </div>\n</template>\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n reactive,\n ref,\n watch,\n onMounted,\n onUpdated,\n} from 'vue'\n\nimport { ElIcon } from '@element-plus/components/icon'\nimport { RepeatClick } from '@element-plus/directives'\nimport { useDisabled, useSize } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { isNumber } from '@element-plus/utils/util'\nimport { debugWarn } from '@element-plus/utils/error'\nimport { ArrowUp, ArrowDown, Plus, Minus } from '@element-plus/icons-vue'\nimport { inputNumberProps, inputNumberEmits } from './input-number'\n\nimport type { ComponentPublicInstance } from 'vue'\n\ninterface IData {\n currentValue: number | undefined\n userInput: null | number | string\n}\n\nexport default defineComponent({\n name: 'ElInputNumber',\n components: {\n ElInput,\n ElIcon,\n ArrowUp,\n ArrowDown,\n Plus,\n Minus,\n },\n directives: {\n RepeatClick,\n },\n props: inputNumberProps,\n emits: inputNumberEmits,\n setup(props, { emit }) {\n const input = ref<ComponentPublicInstance<typeof ElInput>>()\n const data = reactive<IData>({\n currentValue: props.modelValue,\n userInput: null,\n })\n\n const minDisabled = computed(() => _decrease(props.modelValue) < props.min)\n const maxDisabled = computed(() => _increase(props.modelValue) > props.max)\n\n const numPrecision = computed(() => {\n const stepPrecision = getPrecision(props.step)\n if (props.precision !== undefined) {\n if (stepPrecision > props.precision) {\n debugWarn(\n 'InputNumber',\n 'precision should not be less than the decimal places of step'\n )\n }\n return props.precision\n } else {\n return Math.max(getPrecision(props.modelValue), stepPrecision)\n }\n })\n const controlsAtRight = computed(() => {\n return props.controls && props.controlsPosition === 'right'\n })\n\n const inputNumberSize = useSize()\n const inputNumberDisabled = useDisabled()\n\n const displayValue = computed(() => {\n if (data.userInput !== null) {\n return data.userInput\n }\n let currentValue: number | string | undefined = data.currentValue\n if (isNumber(currentValue)) {\n if (Number.isNaN(currentValue)) return ''\n if (props.precision !== undefined) {\n currentValue = currentValue.toFixed(props.precision)\n }\n }\n return currentValue\n })\n const toPrecision = (num: number, pre?: number) => {\n if (pre === undefined) pre = numPrecision.value\n return parseFloat(\n `${Math.round(num * Math.pow(10, pre)) / Math.pow(10, pre)}`\n )\n }\n const getPrecision = (value: number | undefined) => {\n if (value === undefined) return 0\n const valueString = value.toString()\n const dotPosition = valueString.indexOf('.')\n let precision = 0\n if (dotPosition !== -1) {\n precision = valueString.length - dotPosition - 1\n }\n return precision\n }\n const _increase = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val + precisionFactor * props.step) / precisionFactor\n )\n }\n const _decrease = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val - precisionFactor * props.step) / precisionFactor\n )\n }\n const increase = () => {\n if (inputNumberDisabled.value || maxDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _increase(value)\n setCurrentValue(newVal)\n }\n const decrease = () => {\n if (inputNumberDisabled.value || minDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _decrease(value)\n setCurrentValue(newVal)\n }\n const setCurrentValue = (newVal: number) => {\n const oldVal = data.currentValue\n if (typeof newVal === 'number' && props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n if (newVal !== undefined && newVal >= props.max) newVal = props.max\n if (newVal !== undefined && newVal <= props.min) newVal = props.min\n if (oldVal === newVal) return\n if (!isNumber(newVal)) {\n newVal = NaN\n }\n data.userInput = null\n emit('update:modelValue', newVal)\n emit('input', newVal)\n emit('change', newVal, oldVal)\n data.currentValue = newVal\n }\n const handleInput = (value: string) => {\n return (data.userInput = value)\n }\n const handleInputChange = (value: string) => {\n const newVal = Number(value)\n if ((isNumber(newVal) && !Number.isNaN(newVal)) || value === '') {\n setCurrentValue(newVal)\n }\n data.userInput = null\n }\n\n const focus = () => {\n input.value?.focus?.()\n }\n\n const blur = () => {\n input.value?.blur?.()\n }\n\n watch(\n () => props.modelValue,\n (value) => {\n let newVal = Number(value)\n if (!isNaN(newVal)) {\n if (props.stepStrictly) {\n const stepPrecision = getPrecision(props.step)\n const precisionFactor = Math.pow(10, stepPrecision)\n newVal =\n (Math.round(newVal / props.step) * precisionFactor * props.step) /\n precisionFactor\n }\n if (props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n\n if (newVal > props.max) {\n newVal = props.max\n emit('update:modelValue', newVal)\n }\n if (newVal < props.min) {\n newVal = props.min\n emit('update:modelValue', newVal)\n }\n }\n data.currentValue = newVal\n data.userInput = null\n },\n { immediate: true }\n )\n onMounted(() => {\n const innerInput = input.value?.input as HTMLInputElement\n innerInput.setAttribute('role', 'spinbutton')\n innerInput.setAttribute('aria-valuemax', String(props.max))\n innerInput.setAttribute('aria-valuemin', String(props.min))\n innerInput.setAttribute('aria-valuenow', String(data.currentValue))\n innerInput.setAttribute(\n 'aria-disabled',\n String(inputNumberDisabled.value)\n )\n if (!isNumber(props.modelValue)) {\n emit('update:modelValue', Number(props.modelValue))\n }\n })\n onUpdated(() => {\n const innerInput = input.value?.input\n innerInput.setAttribute('aria-valuenow', data.currentValue)\n })\n return {\n input,\n displayValue,\n handleInput,\n handleInputChange,\n controlsAtRight,\n decrease,\n increase,\n inputNumberSize,\n inputNumberDisabled,\n maxDisabled,\n minDisabled,\n focus,\n blur,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;AA2EA,aAAe,eAAe,CAAC;AAC/B,EAAE,qBAAqB;;AAEvB,IAAI;;AAEJ,IAAI,OAAO;IACP,SAAS;IACT,IAAI;AACR;;AAEA,EAAE,UAAU;IACR,WAAW;GACZ;OACI,EAAE;OACF,EAAE;OACF,CAAC;IACJ,MAAM;IACN;MACE;;KAED,CAAC,CAAC;IACH,MAAM;;IAEN,MAAM,YAAY,GAAG;MACnB,MAAM,aAAa;MACnB,IAAI,KAAK,UAAU;QACjB,IAAI,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE;UACnC,SAAS,CAAC,aAAa;SACxB;QACD,OAAO,KAAK,CAA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MAAM,CAAC,EAAE;QAClB,IAAI,KAAK,CAAC,YAAY;;UAEpB,MAAM;;;QAGR,IAAI,MAAM;UACR,MAAM,GAAG;;;UAGT;UACA,IAAI,CAAC;;;;UAIL,IAAI,CAAC;SACN;;WAEE,YAAY,GAAG;UAChB,CAAC,SAAS,GAAG,IAAI,CAAC;kBACV,EAAE,IAAI,EAAE,CAAC,CAAC;aACf,CAAC,MAAM;YACR,CAAC;sBACS,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC;gBACxD,CAAC;;gBAED,CAAC,aAAa,eAAe;gBAC7B,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC;;;aAGzC,mBAAmB,EAAE;;;;UAIxB,GAAG;YACD,UAAU,GAAG,CAAC,EAAE;gBACZ,CAAC,YAAY,CAAC;;;WAGnB;kBACO;MACZ;MACA;;MAEA,QAAQ;MACR,QAAQ;MACR,eAAe;MACf,mBAAmB;MACnB,WAAW;MACX,WAAW;MACX,KAAK;UACD;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"input-number.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/input-number/src/input-number.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'el-input-number',\n inputNumberSize ? 'el-input-number--' + inputNumberSize : '',\n { 'is-disabled': inputNumberDisabled },\n { 'is-without-controls': !controls },\n { 'is-controls-right': controlsAtRight },\n ]\"\n @dragstart.prevent\n >\n <span\n v-if=\"controls\"\n v-repeat-click=\"decrease\"\n class=\"el-input-number__decrease\"\n role=\"button\"\n :class=\"{ 'is-disabled': minDisabled }\"\n @keydown.enter=\"decrease\"\n >\n <el-icon>\n <arrow-down v-if=\"controlsAtRight\" />\n <minus v-else />\n </el-icon>\n </span>\n <span\n v-if=\"controls\"\n v-repeat-click=\"increase\"\n class=\"el-input-number__increase\"\n role=\"button\"\n :class=\"{ 'is-disabled': maxDisabled }\"\n @keydown.enter=\"increase\"\n >\n <el-icon>\n <arrow-up v-if=\"controlsAtRight\" />\n <plus v-else />\n </el-icon>\n </span>\n <el-input\n ref=\"input\"\n type=\"number\"\n :step=\"step\"\n :model-value=\"displayValue\"\n :placeholder=\"placeholder\"\n :disabled=\"inputNumberDisabled\"\n :size=\"inputNumberSize\"\n :max=\"max\"\n :min=\"min\"\n :name=\"name\"\n :label=\"label\"\n :validate-event=\"false\"\n @keydown.up.prevent=\"increase\"\n @keydown.down.prevent=\"decrease\"\n @blur=\"handleBlur\"\n @focus=\"handleFocus\"\n @input=\"handleInput\"\n @change=\"handleInputChange\"\n />\n </div>\n</template>\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n reactive,\n ref,\n watch,\n onMounted,\n onUpdated,\n} from 'vue'\n\nimport { ElIcon } from '@element-plus/components/icon'\nimport { RepeatClick } from '@element-plus/directives'\nimport { useDisabled, useFormItem, useSize } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { isNumber } from '@element-plus/utils/util'\nimport { debugWarn } from '@element-plus/utils/error'\nimport { ArrowUp, ArrowDown, Plus, Minus } from '@element-plus/icons-vue'\nimport { inputNumberProps, inputNumberEmits } from './input-number'\n\nimport type { ComponentPublicInstance } from 'vue'\n\ninterface IData {\n currentValue: number | undefined\n userInput: null | number | string\n}\n\nexport default defineComponent({\n name: 'ElInputNumber',\n components: {\n ElInput,\n ElIcon,\n ArrowUp,\n ArrowDown,\n Plus,\n Minus,\n },\n directives: {\n RepeatClick,\n },\n props: inputNumberProps,\n emits: inputNumberEmits,\n setup(props, { emit }) {\n const input = ref<ComponentPublicInstance<typeof ElInput>>()\n const data = reactive<IData>({\n currentValue: props.modelValue,\n userInput: null,\n })\n const { formItem } = useFormItem()\n\n const minDisabled = computed(() => _decrease(props.modelValue) < props.min)\n const maxDisabled = computed(() => _increase(props.modelValue) > props.max)\n\n const numPrecision = computed(() => {\n const stepPrecision = getPrecision(props.step)\n if (props.precision !== undefined) {\n if (stepPrecision > props.precision) {\n debugWarn(\n 'InputNumber',\n 'precision should not be less than the decimal places of step'\n )\n }\n return props.precision\n } else {\n return Math.max(getPrecision(props.modelValue), stepPrecision)\n }\n })\n const controlsAtRight = computed(() => {\n return props.controls && props.controlsPosition === 'right'\n })\n\n const inputNumberSize = useSize()\n const inputNumberDisabled = useDisabled()\n\n const displayValue = computed(() => {\n if (data.userInput !== null) {\n return data.userInput\n }\n let currentValue: number | string | undefined = data.currentValue\n if (isNumber(currentValue)) {\n if (Number.isNaN(currentValue)) return ''\n if (props.precision !== undefined) {\n currentValue = currentValue.toFixed(props.precision)\n }\n }\n return currentValue\n })\n const toPrecision = (num: number, pre?: number) => {\n if (pre === undefined) pre = numPrecision.value\n return parseFloat(\n `${Math.round(num * Math.pow(10, pre)) / Math.pow(10, pre)}`\n )\n }\n const getPrecision = (value: number | undefined) => {\n if (value === undefined) return 0\n const valueString = value.toString()\n const dotPosition = valueString.indexOf('.')\n let precision = 0\n if (dotPosition !== -1) {\n precision = valueString.length - dotPosition - 1\n }\n return precision\n }\n const _increase = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val + precisionFactor * props.step) / precisionFactor\n )\n }\n const _decrease = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val - precisionFactor * props.step) / precisionFactor\n )\n }\n const increase = () => {\n if (inputNumberDisabled.value || maxDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _increase(value)\n setCurrentValue(newVal)\n }\n const decrease = () => {\n if (inputNumberDisabled.value || minDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _decrease(value)\n setCurrentValue(newVal)\n }\n const setCurrentValue = (newVal: number) => {\n const oldVal = data.currentValue\n if (typeof newVal === 'number' && props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n if (newVal !== undefined && newVal >= props.max) newVal = props.max\n if (newVal !== undefined && newVal <= props.min) newVal = props.min\n if (oldVal === newVal) return\n if (!isNumber(newVal)) {\n newVal = NaN\n }\n data.userInput = null\n emit('update:modelValue', newVal)\n emit('input', newVal)\n emit('change', newVal, oldVal)\n formItem?.validate?.('change')\n data.currentValue = newVal\n }\n const handleInput = (value: string) => {\n return (data.userInput = value)\n }\n const handleInputChange = (value: string) => {\n const newVal = Number(value)\n if ((isNumber(newVal) && !Number.isNaN(newVal)) || value === '') {\n setCurrentValue(newVal)\n }\n data.userInput = null\n }\n\n const focus = () => {\n input.value?.focus?.()\n }\n\n const blur = () => {\n input.value?.blur?.()\n }\n\n const handleFocus = (event: MouseEvent) => {\n emit('focus', event)\n }\n\n const handleBlur = (event: MouseEvent) => {\n emit('blur', event)\n formItem?.validate?.('blur')\n }\n\n watch(\n () => props.modelValue,\n (value) => {\n let newVal = Number(value)\n if (!isNaN(newVal)) {\n if (props.stepStrictly) {\n const stepPrecision = getPrecision(props.step)\n const precisionFactor = Math.pow(10, stepPrecision)\n newVal =\n (Math.round(newVal / props.step) * precisionFactor * props.step) /\n precisionFactor\n }\n if (props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n\n if (newVal > props.max) {\n newVal = props.max\n emit('update:modelValue', newVal)\n }\n if (newVal < props.min) {\n newVal = props.min\n emit('update:modelValue', newVal)\n }\n }\n data.currentValue = newVal\n data.userInput = null\n },\n { immediate: true }\n )\n onMounted(() => {\n const innerInput = input.value?.input as HTMLInputElement\n innerInput.setAttribute('role', 'spinbutton')\n innerInput.setAttribute('aria-valuemax', String(props.max))\n innerInput.setAttribute('aria-valuemin', String(props.min))\n innerInput.setAttribute('aria-valuenow', String(data.currentValue))\n innerInput.setAttribute(\n 'aria-disabled',\n String(inputNumberDisabled.value)\n )\n if (!isNumber(props.modelValue)) {\n emit('update:modelValue', Number(props.modelValue))\n }\n })\n onUpdated(() => {\n const innerInput = input.value?.input\n innerInput.setAttribute('aria-valuenow', data.currentValue)\n })\n return {\n input,\n displayValue,\n handleInput,\n handleInputChange,\n controlsAtRight,\n decrease,\n increase,\n inputNumberSize,\n inputNumberDisabled,\n maxDisabled,\n minDisabled,\n focus,\n blur,\n handleFocus,\n handleBlur,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;AA4EA,aAAe,eAAe,CAAC;AAC/B,EAAE,qBAAqB;;AAEvB,IAAI;;AAEJ,IAAI,OAAO;IACP,SAAS;IACT,IAAI;AACR;;AAEA,EAAE,UAAU;IACR,WAAW;GACZ;OACI,EAAE;OACF,EAAE;OACF,CAAC;IACJ,MAAM;IACN;MACE;;KAED,CAAC,CAAC;IACH,MAAM,EAAE;;IAER,MAAM,WAAW,GAAG;IACpB,MAAM,YAAY,GAAG;MACnB,MAAM,aAAa;MACnB,IAAI,MAAM,SAAS,KAAK,KAAK,CAAC,EAAE;QAC9B,IAAI,aAAa,GAAG,KAAK;UACvB,UAAU,aAAa,EAAE;SAC1B;;OAEF,MAAM;;OAEN;KACF,CAAC,CAAC;;MAED,OAAO,KAAK,CAAC,QAAQ,IAAI,MAAM;MAC/B,CAAC;UACG,kBAAkB,OAAO,EAAE,CAAC;6BACT,GAAG,WAAW,EAAE;UACnC;cACI,CAAC,SAAS;eACT,IAAI,CAAC,UAAU;;;UAGpB,QAAQ,CAAC;QACX;UACE,OAAO,EAAE,CAAC;;;;OAIb;;;IAGH,MAAM,WAAW,GAAG,IAAI,EAAE,GAAG;MAC3B,IAAI,GAAG,KAAK,KAAK,CAAC;;MAElB,OAAO,UAAU,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC;MAChC;UACI,YAAY,GAAG,CAAC;MACpB;QACE,OAAO,CAAC,CAAC;MACX,MAAM,WAAW,GAAG,KAAK,CAAC;YACpB,WAAW,GAAG,WAAW,CAA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AG,CAAC,EAAE;gBACZ,CAAC,YAAY,CAAC;;;WAGnB;kBACO;MACZ;MACA;;MAEA,QAAQ;MACR,QAAQ;MACR,eAAe;MACf,mBAAmB;MACnB,WAAW;MACX,WAAW;MACX,KAAK;UACD;iBACO;MACX;MACA;;;;;;"}
|
package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs
CHANGED
|
@@ -16,7 +16,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
16
16
|
{ "is-without-controls": !_ctx.controls },
|
|
17
17
|
{ "is-controls-right": _ctx.controlsAtRight }
|
|
18
18
|
]),
|
|
19
|
-
onDragstart: _cache[
|
|
19
|
+
onDragstart: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
20
20
|
}, ["prevent"]))
|
|
21
21
|
}, [
|
|
22
22
|
_ctx.controls ? withDirectives((openBlock(), createElementBlock("span", {
|
|
@@ -61,15 +61,16 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
61
61
|
min: _ctx.min,
|
|
62
62
|
name: _ctx.name,
|
|
63
63
|
label: _ctx.label,
|
|
64
|
+
"validate-event": false,
|
|
64
65
|
onKeydown: [
|
|
65
66
|
withKeys(withModifiers(_ctx.increase, ["prevent"]), ["up"]),
|
|
66
67
|
withKeys(withModifiers(_ctx.decrease, ["prevent"]), ["down"])
|
|
67
68
|
],
|
|
68
|
-
onBlur:
|
|
69
|
-
onFocus:
|
|
69
|
+
onBlur: _ctx.handleBlur,
|
|
70
|
+
onFocus: _ctx.handleFocus,
|
|
70
71
|
onInput: _ctx.handleInput,
|
|
71
72
|
onChange: _ctx.handleInputChange
|
|
72
|
-
}, null, 8, ["step", "model-value", "placeholder", "disabled", "size", "max", "min", "name", "label", "onKeydown", "onInput", "onChange"])
|
|
73
|
+
}, null, 8, ["step", "model-value", "placeholder", "disabled", "size", "max", "min", "name", "label", "onKeydown", "onBlur", "onFocus", "onInput", "onChange"])
|
|
73
74
|
], 34);
|
|
74
75
|
}
|
|
75
76
|
|
package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-number.vue_vue_type_template_id_dec60af6_lang.mjs","sources":["../../../../../../packages/components/input-number/src/input-number.vue?vue&type=template&id=dec60af6&lang.js"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'el-input-number',\n inputNumberSize ? 'el-input-number--' + inputNumberSize : '',\n { 'is-disabled': inputNumberDisabled },\n { 'is-without-controls': !controls },\n { 'is-controls-right': controlsAtRight },\n ]\"\n @dragstart.prevent\n >\n <span\n v-if=\"controls\"\n v-repeat-click=\"decrease\"\n class=\"el-input-number__decrease\"\n role=\"button\"\n :class=\"{ 'is-disabled': minDisabled }\"\n @keydown.enter=\"decrease\"\n >\n <el-icon>\n <arrow-down v-if=\"controlsAtRight\" />\n <minus v-else />\n </el-icon>\n </span>\n <span\n v-if=\"controls\"\n v-repeat-click=\"increase\"\n class=\"el-input-number__increase\"\n role=\"button\"\n :class=\"{ 'is-disabled': maxDisabled }\"\n @keydown.enter=\"increase\"\n >\n <el-icon>\n <arrow-up v-if=\"controlsAtRight\" />\n <plus v-else />\n </el-icon>\n </span>\n <el-input\n ref=\"input\"\n type=\"number\"\n :step=\"step\"\n :model-value=\"displayValue\"\n :placeholder=\"placeholder\"\n :disabled=\"inputNumberDisabled\"\n :size=\"inputNumberSize\"\n :max=\"max\"\n :min=\"min\"\n :name=\"name\"\n :label=\"label\"\n @keydown.up.prevent=\"increase\"\n @keydown.down.prevent=\"decrease\"\n @blur=\"
|
|
1
|
+
{"version":3,"file":"input-number.vue_vue_type_template_id_dec60af6_lang.mjs","sources":["../../../../../../packages/components/input-number/src/input-number.vue?vue&type=template&id=dec60af6&lang.js"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'el-input-number',\n inputNumberSize ? 'el-input-number--' + inputNumberSize : '',\n { 'is-disabled': inputNumberDisabled },\n { 'is-without-controls': !controls },\n { 'is-controls-right': controlsAtRight },\n ]\"\n @dragstart.prevent\n >\n <span\n v-if=\"controls\"\n v-repeat-click=\"decrease\"\n class=\"el-input-number__decrease\"\n role=\"button\"\n :class=\"{ 'is-disabled': minDisabled }\"\n @keydown.enter=\"decrease\"\n >\n <el-icon>\n <arrow-down v-if=\"controlsAtRight\" />\n <minus v-else />\n </el-icon>\n </span>\n <span\n v-if=\"controls\"\n v-repeat-click=\"increase\"\n class=\"el-input-number__increase\"\n role=\"button\"\n :class=\"{ 'is-disabled': maxDisabled }\"\n @keydown.enter=\"increase\"\n >\n <el-icon>\n <arrow-up v-if=\"controlsAtRight\" />\n <plus v-else />\n </el-icon>\n </span>\n <el-input\n ref=\"input\"\n type=\"number\"\n :step=\"step\"\n :model-value=\"displayValue\"\n :placeholder=\"placeholder\"\n :disabled=\"inputNumberDisabled\"\n :size=\"inputNumberSize\"\n :max=\"max\"\n :min=\"min\"\n :name=\"name\"\n :label=\"label\"\n :validate-event=\"false\"\n @keydown.up.prevent=\"increase\"\n @keydown.down.prevent=\"decrease\"\n @blur=\"handleBlur\"\n @focus=\"handleFocus\"\n @input=\"handleInput\"\n @change=\"handleInputChange\"\n />\n </div>\n</template>\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n reactive,\n ref,\n watch,\n onMounted,\n onUpdated,\n} from 'vue'\n\nimport { ElIcon } from '@element-plus/components/icon'\nimport { RepeatClick } from '@element-plus/directives'\nimport { useDisabled, useFormItem, useSize } from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { isNumber } from '@element-plus/utils/util'\nimport { debugWarn } from '@element-plus/utils/error'\nimport { ArrowUp, ArrowDown, Plus, Minus } from '@element-plus/icons-vue'\nimport { inputNumberProps, inputNumberEmits } from './input-number'\n\nimport type { ComponentPublicInstance } from 'vue'\n\ninterface IData {\n currentValue: number | undefined\n userInput: null | number | string\n}\n\nexport default defineComponent({\n name: 'ElInputNumber',\n components: {\n ElInput,\n ElIcon,\n ArrowUp,\n ArrowDown,\n Plus,\n Minus,\n },\n directives: {\n RepeatClick,\n },\n props: inputNumberProps,\n emits: inputNumberEmits,\n setup(props, { emit }) {\n const input = ref<ComponentPublicInstance<typeof ElInput>>()\n const data = reactive<IData>({\n currentValue: props.modelValue,\n userInput: null,\n })\n const { formItem } = useFormItem()\n\n const minDisabled = computed(() => _decrease(props.modelValue) < props.min)\n const maxDisabled = computed(() => _increase(props.modelValue) > props.max)\n\n const numPrecision = computed(() => {\n const stepPrecision = getPrecision(props.step)\n if (props.precision !== undefined) {\n if (stepPrecision > props.precision) {\n debugWarn(\n 'InputNumber',\n 'precision should not be less than the decimal places of step'\n )\n }\n return props.precision\n } else {\n return Math.max(getPrecision(props.modelValue), stepPrecision)\n }\n })\n const controlsAtRight = computed(() => {\n return props.controls && props.controlsPosition === 'right'\n })\n\n const inputNumberSize = useSize()\n const inputNumberDisabled = useDisabled()\n\n const displayValue = computed(() => {\n if (data.userInput !== null) {\n return data.userInput\n }\n let currentValue: number | string | undefined = data.currentValue\n if (isNumber(currentValue)) {\n if (Number.isNaN(currentValue)) return ''\n if (props.precision !== undefined) {\n currentValue = currentValue.toFixed(props.precision)\n }\n }\n return currentValue\n })\n const toPrecision = (num: number, pre?: number) => {\n if (pre === undefined) pre = numPrecision.value\n return parseFloat(\n `${Math.round(num * Math.pow(10, pre)) / Math.pow(10, pre)}`\n )\n }\n const getPrecision = (value: number | undefined) => {\n if (value === undefined) return 0\n const valueString = value.toString()\n const dotPosition = valueString.indexOf('.')\n let precision = 0\n if (dotPosition !== -1) {\n precision = valueString.length - dotPosition - 1\n }\n return precision\n }\n const _increase = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val + precisionFactor * props.step) / precisionFactor\n )\n }\n const _decrease = (val: number) => {\n if (!isNumber(val)) return data.currentValue\n const precisionFactor = Math.pow(10, numPrecision.value)\n // Solve the accuracy problem of JS decimal calculation by converting the value to integer.\n val = isNumber(val) ? val : NaN\n return toPrecision(\n (precisionFactor * val - precisionFactor * props.step) / precisionFactor\n )\n }\n const increase = () => {\n if (inputNumberDisabled.value || maxDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _increase(value)\n setCurrentValue(newVal)\n }\n const decrease = () => {\n if (inputNumberDisabled.value || minDisabled.value) return\n const value = props.modelValue || 0\n const newVal = _decrease(value)\n setCurrentValue(newVal)\n }\n const setCurrentValue = (newVal: number) => {\n const oldVal = data.currentValue\n if (typeof newVal === 'number' && props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n if (newVal !== undefined && newVal >= props.max) newVal = props.max\n if (newVal !== undefined && newVal <= props.min) newVal = props.min\n if (oldVal === newVal) return\n if (!isNumber(newVal)) {\n newVal = NaN\n }\n data.userInput = null\n emit('update:modelValue', newVal)\n emit('input', newVal)\n emit('change', newVal, oldVal)\n formItem?.validate?.('change')\n data.currentValue = newVal\n }\n const handleInput = (value: string) => {\n return (data.userInput = value)\n }\n const handleInputChange = (value: string) => {\n const newVal = Number(value)\n if ((isNumber(newVal) && !Number.isNaN(newVal)) || value === '') {\n setCurrentValue(newVal)\n }\n data.userInput = null\n }\n\n const focus = () => {\n input.value?.focus?.()\n }\n\n const blur = () => {\n input.value?.blur?.()\n }\n\n const handleFocus = (event: MouseEvent) => {\n emit('focus', event)\n }\n\n const handleBlur = (event: MouseEvent) => {\n emit('blur', event)\n formItem?.validate?.('blur')\n }\n\n watch(\n () => props.modelValue,\n (value) => {\n let newVal = Number(value)\n if (!isNaN(newVal)) {\n if (props.stepStrictly) {\n const stepPrecision = getPrecision(props.step)\n const precisionFactor = Math.pow(10, stepPrecision)\n newVal =\n (Math.round(newVal / props.step) * precisionFactor * props.step) /\n precisionFactor\n }\n if (props.precision !== undefined) {\n newVal = toPrecision(newVal, props.precision)\n }\n\n if (newVal > props.max) {\n newVal = props.max\n emit('update:modelValue', newVal)\n }\n if (newVal < props.min) {\n newVal = props.min\n emit('update:modelValue', newVal)\n }\n }\n data.currentValue = newVal\n data.userInput = null\n },\n { immediate: true }\n )\n onMounted(() => {\n const innerInput = input.value?.input as HTMLInputElement\n innerInput.setAttribute('role', 'spinbutton')\n innerInput.setAttribute('aria-valuemax', String(props.max))\n innerInput.setAttribute('aria-valuemin', String(props.min))\n innerInput.setAttribute('aria-valuenow', String(data.currentValue))\n innerInput.setAttribute(\n 'aria-disabled',\n String(inputNumberDisabled.value)\n )\n if (!isNumber(props.modelValue)) {\n emit('update:modelValue', Number(props.modelValue))\n }\n })\n onUpdated(() => {\n const innerInput = input.value?.input\n innerInput.setAttribute('aria-valuenow', data.currentValue)\n })\n return {\n input,\n displayValue,\n handleInput,\n handleInputChange,\n controlsAtRight,\n decrease,\n increase,\n inputNumberSize,\n inputNumberDisabled,\n maxDisabled,\n minDisabled,\n focus,\n blur,\n handleFocus,\n handleBlur,\n }\n },\n})\n</script>\n"],"names":["_openBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;eAcW;;kBAGG;;UAER;;;;;;;;;;;;KAMM;sCADR;;UAGE,KAAK,mBAACA,4CAEmB;UADzB;;;UAIA;8BACE;kCAA+B;;;;;;;;;;;MAKjC;MACA;MACC;MACA;gBACW;;;MAGX,aAAQ;MACR,aAAQ;MACR;MACA;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/message-box/src/index.vue"],"sourcesContent":["<template>\n <transition name=\"fade-in-linear\" @after-leave=\"$emit('vanish')\">\n <el-overlay\n v-show=\"visible\"\n :z-index=\"zIndex\"\n :overlay-class=\"['is-message-box', modalClass]\"\n :mask=\"modal\"\n @click.self=\"handleWrapperClick\"\n >\n <div\n ref=\"root\"\n v-trap-focus\n :aria-label=\"title || 'dialog'\"\n aria-modal=\"true\"\n :class=\"[\n 'el-message-box',\n customClass,\n { 'el-message-box--center': center },\n ]\"\n :style=\"customStyle\"\n >\n <div\n v-if=\"title !== null && title !== undefined\"\n class=\"el-message-box__header\"\n >\n <div class=\"el-message-box__title\">\n <el-icon\n v-if=\"iconComponent && center\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <span>{{ title }}</span>\n </div>\n <button\n v-if=\"showClose\"\n type=\"button\"\n class=\"el-message-box__headerbtn\"\n aria-label=\"Close\"\n @click=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n @keydown.prevent.enter=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n >\n <el-icon class=\"el-message-box__close\"><close /></el-icon>\n </button>\n </div>\n <div class=\"el-message-box__content\">\n <div class=\"el-message-box__container\">\n <el-icon\n v-if=\"iconComponent && !center && hasMessage\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div v-if=\"hasMessage\" class=\"el-message-box__message\">\n <slot>\n <p v-if=\"!dangerouslyUseHTMLString\">{{ message }}</p>\n <p v-else v-html=\"message\"></p>\n </slot>\n </div>\n </div>\n <div v-show=\"showInput\" class=\"el-message-box__input\">\n <el-input\n ref=\"inputRef\"\n v-model=\"inputValue\"\n :type=\"inputType\"\n :placeholder=\"inputPlaceholder\"\n :class=\"{ invalid: validateError }\"\n @keydown.prevent.enter=\"handleInputEnter\"\n />\n <div\n class=\"el-message-box__errormsg\"\n :style=\"{\n visibility: !!editorErrorMessage ? 'visible' : 'hidden',\n }\"\n >\n {{ editorErrorMessage }}\n </div>\n </div>\n </div>\n <div class=\"el-message-box__btns\">\n <el-button\n v-if=\"showCancelButton\"\n :loading=\"cancelButtonLoading\"\n :class=\"[cancelButtonClass]\"\n :round=\"roundButton\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('cancel')\"\n @keydown.prevent.enter=\"handleAction('cancel')\"\n >\n {{ cancelButtonText || t('el.messagebox.cancel') }}\n </el-button>\n <el-button\n v-show=\"showConfirmButton\"\n ref=\"confirmRef\"\n type=\"primary\"\n :loading=\"confirmButtonLoading\"\n :class=\"[confirmButtonClasses]\"\n :round=\"roundButton\"\n :disabled=\"confirmButtonDisabled\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('confirm')\"\n @keydown.prevent.enter=\"handleAction('confirm')\"\n >\n {{ confirmButtonText || t('el.messagebox.confirm') }}\n </el-button>\n </div>\n </div>\n </el-overlay>\n </transition>\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onMounted,\n onBeforeUnmount,\n computed,\n watch,\n reactive,\n ref,\n toRefs,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport { TrapFocus } from '@element-plus/directives'\nimport {\n useModal,\n useLockscreen,\n useLocale,\n useRestoreActive,\n usePreventGlobal,\n} from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { ElOverlay } from '@element-plus/components/overlay'\nimport { PopupManager } from '@element-plus/utils/popup-manager'\nimport { on, off } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils/icon'\n\nimport type { ComponentPublicInstance, PropType } from 'vue'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type {\n Action,\n MessageBoxState,\n MessageBoxType,\n} from './message-box.type'\n\nexport default defineComponent({\n name: 'ElMessageBox',\n directives: {\n TrapFocus,\n },\n components: {\n ElButton,\n ElInput,\n ElOverlay,\n ElIcon,\n ...TypeComponents,\n },\n inheritAttrs: false,\n props: {\n buttonSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n modal: {\n type: Boolean,\n default: true,\n },\n lockScroll: {\n type: Boolean,\n default: true,\n },\n showClose: {\n type: Boolean,\n default: true,\n },\n closeOnClickModal: {\n type: Boolean,\n default: true,\n },\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n closeOnHashChange: {\n type: Boolean,\n default: true,\n },\n center: Boolean,\n roundButton: {\n default: false,\n type: Boolean,\n },\n container: {\n type: String, // default append to body\n default: 'body',\n },\n boxType: {\n type: String as PropType<MessageBoxType>,\n default: '',\n },\n },\n emits: ['vanish', 'action'],\n setup(props, { emit }) {\n // const popup = usePopup(props, doClose)\n const { t } = useLocale()\n const visible = ref(false)\n // s represents state\n const state = reactive<MessageBoxState>({\n beforeClose: null,\n callback: null,\n cancelButtonText: '',\n cancelButtonClass: '',\n confirmButtonText: '',\n confirmButtonClass: '',\n customClass: '',\n customStyle: {},\n dangerouslyUseHTMLString: false,\n distinguishCancelAndClose: false,\n icon: '',\n inputPattern: null,\n inputPlaceholder: '',\n inputType: 'text',\n inputValue: null,\n inputValidator: null,\n inputErrorMessage: '',\n message: null,\n modalFade: true,\n modalClass: '',\n showCancelButton: false,\n showConfirmButton: true,\n type: '',\n title: undefined,\n showInput: false,\n action: '' as Action,\n confirmButtonLoading: false,\n cancelButtonLoading: false,\n confirmButtonDisabled: false,\n editorErrorMessage: '',\n // refer to: https://github.com/ElemeFE/element/commit/2999279ae34ef10c373ca795c87b020ed6753eed\n // seemed ok for now without this state.\n // isOnComposition: false, // temporary remove\n validateError: false,\n zIndex: PopupManager.nextZIndex(),\n })\n\n const typeClass = computed(() => {\n const type = state.type\n return type && TypeComponentsMap[type]\n ? `el-message-box-icon--${type}`\n : ''\n })\n\n const iconComponent = computed(\n () => state.icon || TypeComponentsMap[state.type] || ''\n )\n const hasMessage = computed(() => !!state.message)\n const inputRef = ref<ComponentPublicInstance>(null)\n const confirmRef = ref<ComponentPublicInstance>(null)\n\n const confirmButtonClasses = computed(() => state.confirmButtonClass)\n\n watch(\n () => state.inputValue,\n async (val) => {\n await nextTick()\n if (props.boxType === 'prompt' && val !== null) {\n validate()\n }\n },\n { immediate: true }\n )\n\n watch(\n () => visible.value,\n (val) => {\n if (val) {\n if (props.boxType === 'alert' || props.boxType === 'confirm') {\n nextTick().then(() => {\n confirmRef.value?.$el?.focus?.()\n })\n }\n state.zIndex = PopupManager.nextZIndex()\n }\n if (props.boxType !== 'prompt') return\n if (val) {\n nextTick().then(() => {\n if (inputRef.value && inputRef.value.$el) {\n getInputElement().focus()\n }\n })\n } else {\n state.editorErrorMessage = ''\n state.validateError = false\n }\n }\n )\n\n onMounted(async () => {\n await nextTick()\n if (props.closeOnHashChange) {\n on(window, 'hashchange', doClose)\n }\n })\n\n onBeforeUnmount(() => {\n if (props.closeOnHashChange) {\n off(window, 'hashchange', doClose)\n }\n })\n\n function doClose() {\n if (!visible.value) return\n visible.value = false\n nextTick(() => {\n if (state.action) emit('action', state.action)\n })\n }\n\n const handleWrapperClick = () => {\n if (props.closeOnClickModal) {\n handleAction(state.distinguishCancelAndClose ? 'close' : 'cancel')\n }\n }\n\n const handleInputEnter = () => {\n if (state.inputType !== 'textarea') {\n return handleAction('confirm')\n }\n }\n\n const handleAction = (action: Action) => {\n if (props.boxType === 'prompt' && action === 'confirm' && !validate()) {\n return\n }\n\n state.action = action\n\n if (state.beforeClose) {\n state.beforeClose?.(action, state, doClose)\n } else {\n doClose()\n }\n }\n\n const validate = () => {\n if (props.boxType === 'prompt') {\n const inputPattern = state.inputPattern\n if (inputPattern && !inputPattern.test(state.inputValue || '')) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n const inputValidator = state.inputValidator\n if (typeof inputValidator === 'function') {\n const validateResult = inputValidator(state.inputValue)\n if (validateResult === false) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n if (typeof validateResult === 'string') {\n state.editorErrorMessage = validateResult\n state.validateError = true\n return false\n }\n }\n }\n state.editorErrorMessage = ''\n state.validateError = false\n return true\n }\n\n const getInputElement = () => {\n const inputRefs = inputRef.value.$refs\n return (inputRefs.input || inputRefs.textarea) as HTMLElement\n }\n\n const handleClose = () => {\n handleAction('close')\n }\n\n // when close on press escape is disabled, pressing esc should not callout\n // any other message box and close any other dialog-ish elements\n // e.g. Dialog has a close on press esc feature, and when it closes, it calls\n // props.beforeClose method to make a intermediate state by callout a message box\n // for some verification or alerting. then if we allow global event liek this\n // to dispatch, it could callout another message box.\n if (props.closeOnPressEscape) {\n useModal(\n {\n handleClose,\n },\n visible\n )\n } else {\n usePreventGlobal(\n visible,\n 'keydown',\n (e: KeyboardEvent) => e.code === EVENT_CODE.esc\n )\n }\n\n // locks the screen to prevent scroll\n if (props.lockScroll) {\n useLockscreen(visible)\n }\n\n // restore to prev active element.\n useRestoreActive(visible)\n\n return {\n ...toRefs(state),\n visible,\n hasMessage,\n typeClass,\n iconComponent,\n confirmButtonClasses,\n inputRef,\n confirmRef,\n doClose, // for outside usage\n handleClose, // for out side usage\n handleWrapperClick,\n handleInputEnter,\n handleAction,\n t,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAgJA,aAAe,eAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI;AACJ,GAAG;EACD;IACE,QAAQ;IACR,OAAO;AACX,IAAI,SAAS;;AAEb,IAAI,GAAG,cAAc;GAClB;EACD,YAAY;OACP,EAAE;;MAEH,IAAI,EAAE;MACN;KACD;IACD,KAAK,EAAE;MACL,IAAI;MACJ,OAAO,EAAE,IAAI;;IAEf,UAAU,EAAE;MACV;MACA,OAAO;;aAEA,EAAE;;MAET;;;;MAIA,OAAO;;;;MAIP,OAAO,EAAE;;;;MAIT,OAAO,EAAE,IAAI;;UAET,EAAE,OAAO;IACf;MACE,OAAO,EAAE,KAAK;MACd,IAAI,EAAE,OAAO;;IAEf;MACE,IAAI,EAAE,MAAM;MACZ,OAAO,EAAE;;IAEX;MACE,IAAI,EAAE,MAAM;MACZ,OAAO,EAAE,EAAE;;;;OAIV,CAAC,KAAK,EAAE;UACL,EAAE,CAAC,EAAE,GAAG,SA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AM,EAAE,CAAC;;SAE7B;OACF,MAAM;QACL,KAAK,CAAC;QACN,MAAM;;;;MAIR;MACA,IAAI,KAAK,CAAC;;;KAGX,CAAC,CAAC;mBACY,CAAC;MACd,IAAI,KAAK;QACP,GAAG,CAAC;;;oBAGQ,GAAG;;;aAGV,CAAC,KAAK,QAAQ,CAAC;;QAEpB,IAAI,KAAK,CAAC,MAAM;cACV,CAAC;;;4BAGa,GAAG,MAAM;;;;;UAK3B,gBAAgB,SAAS;;;;;IAK/B,MAAM,gBAAgB;MACpB,IAAI,EAAE,CAAC;MACP,IAAI,KAAK,CAAC,OAAO,KAAK;QACpB,OAAO;;;;QAIP,CAAC,EAAE,GAAG,KAAK,CAAC;OACb,MAAM;QACL,OAAO,EAAE,CAAC;;KAEb;;MAEC,IAAI,KAAK,CAAC,OAAO;cACT,YAAY,GAAG;QACrB,IAAI,YAAY;UACd,KAAK,CAAC;eACD,CAAC,aAAa,GAAG,IAAI,CAAC;;;;QAI7B,IAAI,OAAO;UACT,MAAM,cAAc,GAAG;UACvB,IAAI,cAAc,KAAK,KAAK,EAAE;;;;WAI7B;UACD,IAAI,OAAO,cAAc,KAAK;YAC5B,KAAK,CAAC,kBAAkB;;;;;OAK7B;WACI,CAAC;MACN;;MAEA;;MAEA,MAAM,SAAS,GAAG;aACX,SAAS,CAAC,KAAK,IAAI,SAAS,SAAS;MAC5C;UACI;MACJ;;;MAGA,QAAQ,CAAC;mBACI;SACV,OAAO,CAAC,CAAC;WACP;sBACW,CAAC,OAAO,EAAE;;aAEnB,CAAC,UAAU,EAAE;mBACP,CAAC;;oBAEA,CAAC,QAAQ;WAClB;gBACK,KAAK,CAAC;aACT;gBACG;eACD;mBACI;;;gBAGH;aACH;iBACI;;;;MAIX;MACA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/message-box/src/index.vue"],"sourcesContent":["<template>\n <transition name=\"fade-in-linear\" @after-leave=\"$emit('vanish')\">\n <el-overlay\n v-show=\"visible\"\n :z-index=\"zIndex\"\n :overlay-class=\"['is-message-box', modalClass]\"\n :mask=\"modal\"\n @click.self=\"handleWrapperClick\"\n >\n <div\n ref=\"root\"\n v-trap-focus\n role=\"dialog\"\n :aria-label=\"title || 'dialog'\"\n aria-modal=\"true\"\n :class=\"[\n 'el-message-box',\n customClass,\n { 'el-message-box--center': center },\n ]\"\n :style=\"customStyle\"\n >\n <div\n v-if=\"title !== null && title !== undefined\"\n class=\"el-message-box__header\"\n >\n <div class=\"el-message-box__title\">\n <el-icon\n v-if=\"iconComponent && center\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <span>{{ title }}</span>\n </div>\n <button\n v-if=\"showClose\"\n type=\"button\"\n class=\"el-message-box__headerbtn\"\n aria-label=\"Close\"\n @click=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n @keydown.prevent.enter=\"\n handleAction(distinguishCancelAndClose ? 'close' : 'cancel')\n \"\n >\n <el-icon class=\"el-message-box__close\"><close /></el-icon>\n </button>\n </div>\n <div class=\"el-message-box__content\">\n <div class=\"el-message-box__container\">\n <el-icon\n v-if=\"iconComponent && !center && hasMessage\"\n class=\"el-message-box__status\"\n :class=\"typeClass\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div v-if=\"hasMessage\" class=\"el-message-box__message\">\n <slot>\n <p v-if=\"!dangerouslyUseHTMLString\">{{ message }}</p>\n <p v-else v-html=\"message\"></p>\n </slot>\n </div>\n </div>\n <div v-show=\"showInput\" class=\"el-message-box__input\">\n <el-input\n ref=\"inputRef\"\n v-model=\"inputValue\"\n :type=\"inputType\"\n :placeholder=\"inputPlaceholder\"\n :class=\"{ invalid: validateError }\"\n @keydown.prevent.enter=\"handleInputEnter\"\n />\n <div\n class=\"el-message-box__errormsg\"\n :style=\"{\n visibility: !!editorErrorMessage ? 'visible' : 'hidden',\n }\"\n >\n {{ editorErrorMessage }}\n </div>\n </div>\n </div>\n <div class=\"el-message-box__btns\">\n <el-button\n v-if=\"showCancelButton\"\n :loading=\"cancelButtonLoading\"\n :class=\"[cancelButtonClass]\"\n :round=\"roundButton\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('cancel')\"\n @keydown.prevent.enter=\"handleAction('cancel')\"\n >\n {{ cancelButtonText || t('el.messagebox.cancel') }}\n </el-button>\n <el-button\n v-show=\"showConfirmButton\"\n ref=\"confirmRef\"\n type=\"primary\"\n :loading=\"confirmButtonLoading\"\n :class=\"[confirmButtonClasses]\"\n :round=\"roundButton\"\n :disabled=\"confirmButtonDisabled\"\n :size=\"buttonSize || ''\"\n @click=\"handleAction('confirm')\"\n @keydown.prevent.enter=\"handleAction('confirm')\"\n >\n {{ confirmButtonText || t('el.messagebox.confirm') }}\n </el-button>\n </div>\n </div>\n </el-overlay>\n </transition>\n</template>\n<script lang=\"ts\">\nimport {\n defineComponent,\n nextTick,\n onMounted,\n onBeforeUnmount,\n computed,\n watch,\n reactive,\n ref,\n toRefs,\n} from 'vue'\nimport ElButton from '@element-plus/components/button'\nimport { TrapFocus } from '@element-plus/directives'\nimport {\n useModal,\n useLockscreen,\n useLocale,\n useRestoreActive,\n usePreventGlobal,\n} from '@element-plus/hooks'\nimport ElInput from '@element-plus/components/input'\nimport { ElOverlay } from '@element-plus/components/overlay'\nimport { PopupManager } from '@element-plus/utils/popup-manager'\nimport { on, off } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils/icon'\n\nimport type { ComponentPublicInstance, PropType } from 'vue'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type {\n Action,\n MessageBoxState,\n MessageBoxType,\n} from './message-box.type'\n\nexport default defineComponent({\n name: 'ElMessageBox',\n directives: {\n TrapFocus,\n },\n components: {\n ElButton,\n ElInput,\n ElOverlay,\n ElIcon,\n ...TypeComponents,\n },\n inheritAttrs: false,\n props: {\n buttonSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n modal: {\n type: Boolean,\n default: true,\n },\n lockScroll: {\n type: Boolean,\n default: true,\n },\n showClose: {\n type: Boolean,\n default: true,\n },\n closeOnClickModal: {\n type: Boolean,\n default: true,\n },\n closeOnPressEscape: {\n type: Boolean,\n default: true,\n },\n closeOnHashChange: {\n type: Boolean,\n default: true,\n },\n center: Boolean,\n roundButton: {\n default: false,\n type: Boolean,\n },\n container: {\n type: String, // default append to body\n default: 'body',\n },\n boxType: {\n type: String as PropType<MessageBoxType>,\n default: '',\n },\n },\n emits: ['vanish', 'action'],\n setup(props, { emit }) {\n // const popup = usePopup(props, doClose)\n const { t } = useLocale()\n const visible = ref(false)\n // s represents state\n const state = reactive<MessageBoxState>({\n beforeClose: null,\n callback: null,\n cancelButtonText: '',\n cancelButtonClass: '',\n confirmButtonText: '',\n confirmButtonClass: '',\n customClass: '',\n customStyle: {},\n dangerouslyUseHTMLString: false,\n distinguishCancelAndClose: false,\n icon: '',\n inputPattern: null,\n inputPlaceholder: '',\n inputType: 'text',\n inputValue: null,\n inputValidator: null,\n inputErrorMessage: '',\n message: null,\n modalFade: true,\n modalClass: '',\n showCancelButton: false,\n showConfirmButton: true,\n type: '',\n title: undefined,\n showInput: false,\n action: '' as Action,\n confirmButtonLoading: false,\n cancelButtonLoading: false,\n confirmButtonDisabled: false,\n editorErrorMessage: '',\n // refer to: https://github.com/ElemeFE/element/commit/2999279ae34ef10c373ca795c87b020ed6753eed\n // seemed ok for now without this state.\n // isOnComposition: false, // temporary remove\n validateError: false,\n zIndex: PopupManager.nextZIndex(),\n })\n\n const typeClass = computed(() => {\n const type = state.type\n return type && TypeComponentsMap[type]\n ? `el-message-box-icon--${type}`\n : ''\n })\n\n const iconComponent = computed(\n () => state.icon || TypeComponentsMap[state.type] || ''\n )\n const hasMessage = computed(() => !!state.message)\n const inputRef = ref<ComponentPublicInstance>(null)\n const confirmRef = ref<ComponentPublicInstance>(null)\n\n const confirmButtonClasses = computed(() => state.confirmButtonClass)\n\n watch(\n () => state.inputValue,\n async (val) => {\n await nextTick()\n if (props.boxType === 'prompt' && val !== null) {\n validate()\n }\n },\n { immediate: true }\n )\n\n watch(\n () => visible.value,\n (val) => {\n if (val) {\n if (props.boxType === 'alert' || props.boxType === 'confirm') {\n nextTick().then(() => {\n confirmRef.value?.$el?.focus?.()\n })\n }\n state.zIndex = PopupManager.nextZIndex()\n }\n if (props.boxType !== 'prompt') return\n if (val) {\n nextTick().then(() => {\n if (inputRef.value && inputRef.value.$el) {\n getInputElement().focus()\n }\n })\n } else {\n state.editorErrorMessage = ''\n state.validateError = false\n }\n }\n )\n\n onMounted(async () => {\n await nextTick()\n if (props.closeOnHashChange) {\n on(window, 'hashchange', doClose)\n }\n })\n\n onBeforeUnmount(() => {\n if (props.closeOnHashChange) {\n off(window, 'hashchange', doClose)\n }\n })\n\n function doClose() {\n if (!visible.value) return\n visible.value = false\n nextTick(() => {\n if (state.action) emit('action', state.action)\n })\n }\n\n const handleWrapperClick = () => {\n if (props.closeOnClickModal) {\n handleAction(state.distinguishCancelAndClose ? 'close' : 'cancel')\n }\n }\n\n const handleInputEnter = () => {\n if (state.inputType !== 'textarea') {\n return handleAction('confirm')\n }\n }\n\n const handleAction = (action: Action) => {\n if (props.boxType === 'prompt' && action === 'confirm' && !validate()) {\n return\n }\n\n state.action = action\n\n if (state.beforeClose) {\n state.beforeClose?.(action, state, doClose)\n } else {\n doClose()\n }\n }\n\n const validate = () => {\n if (props.boxType === 'prompt') {\n const inputPattern = state.inputPattern\n if (inputPattern && !inputPattern.test(state.inputValue || '')) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n const inputValidator = state.inputValidator\n if (typeof inputValidator === 'function') {\n const validateResult = inputValidator(state.inputValue)\n if (validateResult === false) {\n state.editorErrorMessage =\n state.inputErrorMessage || t('el.messagebox.error')\n state.validateError = true\n return false\n }\n if (typeof validateResult === 'string') {\n state.editorErrorMessage = validateResult\n state.validateError = true\n return false\n }\n }\n }\n state.editorErrorMessage = ''\n state.validateError = false\n return true\n }\n\n const getInputElement = () => {\n const inputRefs = inputRef.value.$refs\n return (inputRefs.input || inputRefs.textarea) as HTMLElement\n }\n\n const handleClose = () => {\n handleAction('close')\n }\n\n // when close on press escape is disabled, pressing esc should not callout\n // any other message box and close any other dialog-ish elements\n // e.g. Dialog has a close on press esc feature, and when it closes, it calls\n // props.beforeClose method to make a intermediate state by callout a message box\n // for some verification or alerting. then if we allow global event liek this\n // to dispatch, it could callout another message box.\n if (props.closeOnPressEscape) {\n useModal(\n {\n handleClose,\n },\n visible\n )\n } else {\n usePreventGlobal(\n visible,\n 'keydown',\n (e: KeyboardEvent) => e.code === EVENT_CODE.esc\n )\n }\n\n // locks the screen to prevent scroll\n if (props.lockScroll) {\n useLockscreen(visible)\n }\n\n // restore to prev active element.\n useRestoreActive(visible)\n\n return {\n ...toRefs(state),\n visible,\n hasMessage,\n typeClass,\n iconComponent,\n confirmButtonClasses,\n inputRef,\n confirmRef,\n doClose, // for outside usage\n handleClose, // for out side usage\n handleWrapperClick,\n handleInputEnter,\n handleAction,\n t,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiJA,aAAe,eAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI;AACJ,GAAG;EACD;IACE,QAAQ;IACR,OAAO;AACX,IAAI,SAAS;;AAEb,IAAI,GAAG,cAAc;GAClB;EACD,YAAY;OACP,EAAE;;MAEH,IAAI,EAAE;MACN;KACD;IACD,KAAK,EAAE;MACL,IAAI;MACJ,OAAO,EAAE,IAAI;;IAEf,UAAU,EAAE;MACV;MACA,OAAO;;aAEA,EAAE;;MAET;;;;MAIA,OAAO;;;;MAIP,OAAO,EAAE;;;;MAIT,OAAO,EAAE,IAAI;;UAET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