@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
|
@@ -16,6 +16,7 @@ export declare const ElRate: import("../../utils/types").SFCWithInstall<import("
|
|
|
16
16
|
readonly textColor: import("../../utils/props").BuildPropReturn<StringConstructor, "#1f2d3d", unknown, unknown, unknown>;
|
|
17
17
|
readonly texts: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<string[]>, () => ["Extremely bad", "Disappointed", "Fair", "Satisfied", "Surprise"], unknown, unknown, unknown>;
|
|
18
18
|
readonly scoreTemplate: import("../../utils/props").BuildPropReturn<StringConstructor, "{value}", unknown, unknown, unknown>;
|
|
19
|
+
readonly size: import("../../utils/props").BuildPropReturn<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown, unknown, unknown>;
|
|
19
20
|
}, {
|
|
20
21
|
hoverIndex: import("vue").Ref<number>;
|
|
21
22
|
currentValue: import("vue").Ref<number>;
|
|
@@ -43,6 +44,7 @@ export declare const ElRate: import("../../utils/types").SFCWithInstall<import("
|
|
|
43
44
|
};
|
|
44
45
|
}>;
|
|
45
46
|
iconComponents: import("vue").ComputedRef<any[]>;
|
|
47
|
+
rateKls: import("vue").ComputedRef<string[]>;
|
|
46
48
|
showDecimalIcon: (item: number) => boolean;
|
|
47
49
|
getIconStyle: (item: number) => {
|
|
48
50
|
color: string | {
|
|
@@ -75,6 +77,7 @@ export declare const ElRate: import("../../utils/types").SFCWithInstall<import("
|
|
|
75
77
|
readonly textColor?: unknown;
|
|
76
78
|
readonly texts?: unknown;
|
|
77
79
|
readonly scoreTemplate?: unknown;
|
|
80
|
+
readonly size?: unknown;
|
|
78
81
|
} & {
|
|
79
82
|
disabled: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
80
83
|
modelValue: number;
|
|
@@ -93,10 +96,13 @@ export declare const ElRate: import("../../utils/types").SFCWithInstall<import("
|
|
|
93
96
|
showScore: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
94
97
|
texts: string[];
|
|
95
98
|
scoreTemplate: string;
|
|
96
|
-
} & {
|
|
99
|
+
} & {
|
|
100
|
+
size?: import("../../utils/props").BuildPropType<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown> | undefined;
|
|
101
|
+
}> & {
|
|
97
102
|
onChange?: ((value: number) => any) | undefined;
|
|
98
103
|
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
99
104
|
}, {
|
|
105
|
+
size: import("../../utils/props").BuildPropType<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown>;
|
|
100
106
|
disabled: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
101
107
|
modelValue: number;
|
|
102
108
|
textColor: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ComponentSize } from 'element-plus/es/utils/types';
|
|
1
2
|
import type { Component, ExtractPropTypes } from 'vue';
|
|
2
3
|
export declare const rateProps: {
|
|
3
4
|
readonly modelValue: import("element-plus/es/utils/props").BuildPropReturn<NumberConstructor, 0, unknown, unknown, unknown>;
|
|
@@ -17,6 +18,7 @@ export declare const rateProps: {
|
|
|
17
18
|
readonly textColor: import("element-plus/es/utils/props").BuildPropReturn<StringConstructor, "#1f2d3d", unknown, unknown, unknown>;
|
|
18
19
|
readonly texts: import("element-plus/es/utils/props").BuildPropReturn<import("element-plus/es/utils/props").PropWrapper<string[]>, () => ["Extremely bad", "Disappointed", "Fair", "Satisfied", "Surprise"], unknown, unknown, unknown>;
|
|
19
20
|
readonly scoreTemplate: import("element-plus/es/utils/props").BuildPropReturn<StringConstructor, "{value}", unknown, unknown, unknown>;
|
|
21
|
+
readonly size: import("element-plus/es/utils/props").BuildPropReturn<(new (...args: any[]) => ComponentSize & {}) | (() => ComponentSize) | ((new (...args: any[]) => ComponentSize & {}) | (() => ComponentSize))[], unknown, unknown, unknown, unknown>;
|
|
20
22
|
};
|
|
21
23
|
export declare type RateProps = ExtractPropTypes<typeof rateProps>;
|
|
22
24
|
export declare const rateEmits: {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var iconsVue = require('@element-plus/icons-vue');
|
|
6
6
|
var constants = require('../../../utils/constants.js');
|
|
7
7
|
var props = require('../../../utils/props.js');
|
|
8
|
+
var validators = require('../../../utils/validators.js');
|
|
8
9
|
|
|
9
10
|
const rateProps = props.buildProps({
|
|
10
11
|
modelValue: {
|
|
@@ -80,6 +81,10 @@ const rateProps = props.buildProps({
|
|
|
80
81
|
scoreTemplate: {
|
|
81
82
|
type: String,
|
|
82
83
|
default: "{value}"
|
|
84
|
+
},
|
|
85
|
+
size: {
|
|
86
|
+
type: String,
|
|
87
|
+
validator: validators.isValidComponentSize
|
|
83
88
|
}
|
|
84
89
|
});
|
|
85
90
|
const rateEmits = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate.js","sources":["../../../../../../packages/components/rate/src/rate.ts"],"sourcesContent":["import { Star, StarFilled } from '@element-plus/icons-vue'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { buildProps, definePropType, mutable } from '@element-plus/utils/props'\nimport type { Component, ExtractPropTypes } from 'vue'\n\nexport const rateProps = buildProps({\n modelValue: {\n type: Number,\n default: 0,\n },\n lowThreshold: {\n type: Number,\n default: 2,\n },\n highThreshold: {\n type: Number,\n default: 4,\n },\n max: {\n type: Number,\n default: 5,\n },\n colors: {\n type: definePropType<string[] | Record<number, string>>([Array, Object]),\n default: () => mutable(['#F7BA2A', '#F7BA2A', '#F7BA2A'] as const),\n },\n voidColor: {\n type: String,\n default: '#C6D1DE',\n },\n disabledVoidColor: {\n type: String,\n default: '#EFF2F7',\n },\n icons: {\n type: definePropType<\n Array<string | Component> | Record<number, string | Component>\n >([Array, Object]),\n default: () => [StarFilled, StarFilled, StarFilled],\n },\n voidIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: () => Star,\n },\n disabledvoidIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: () => StarFilled,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n allowHalf: {\n type: Boolean,\n default: false,\n },\n showText: {\n type: Boolean,\n default: false,\n },\n showScore: {\n type: Boolean,\n default: false,\n },\n textColor: {\n type: String,\n default: '#1f2d3d',\n },\n texts: {\n type: definePropType<string[]>([Array]),\n default: () =>\n mutable([\n 'Extremely bad',\n 'Disappointed',\n 'Fair',\n 'Satisfied',\n 'Surprise',\n ] as const),\n },\n scoreTemplate: {\n type: String,\n default: '{value}',\n },\n} as const)\n\nexport type RateProps = ExtractPropTypes<typeof rateProps>\n\nexport const rateEmits = {\n change: (value: number) => typeof value === 'number',\n [UPDATE_MODEL_EVENT]: (value: number) => typeof value === 'number',\n}\nexport type RateEmits = typeof rateEmits\n"],"names":["buildProps","definePropType","mutable","StarFilled","Star","UPDATE_MODEL_EVENT"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rate.js","sources":["../../../../../../packages/components/rate/src/rate.ts"],"sourcesContent":["import { Star, StarFilled } from '@element-plus/icons-vue'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { buildProps, definePropType, mutable } from '@element-plus/utils/props'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type { Component, ExtractPropTypes, PropType } from 'vue'\n\nexport const rateProps = buildProps({\n modelValue: {\n type: Number,\n default: 0,\n },\n lowThreshold: {\n type: Number,\n default: 2,\n },\n highThreshold: {\n type: Number,\n default: 4,\n },\n max: {\n type: Number,\n default: 5,\n },\n colors: {\n type: definePropType<string[] | Record<number, string>>([Array, Object]),\n default: () => mutable(['#F7BA2A', '#F7BA2A', '#F7BA2A'] as const),\n },\n voidColor: {\n type: String,\n default: '#C6D1DE',\n },\n disabledVoidColor: {\n type: String,\n default: '#EFF2F7',\n },\n icons: {\n type: definePropType<\n Array<string | Component> | Record<number, string | Component>\n >([Array, Object]),\n default: () => [StarFilled, StarFilled, StarFilled],\n },\n voidIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: () => Star,\n },\n disabledvoidIcon: {\n type: definePropType<string | Component>([String, Object]),\n default: () => StarFilled,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n allowHalf: {\n type: Boolean,\n default: false,\n },\n showText: {\n type: Boolean,\n default: false,\n },\n showScore: {\n type: Boolean,\n default: false,\n },\n textColor: {\n type: String,\n default: '#1f2d3d',\n },\n texts: {\n type: definePropType<string[]>([Array]),\n default: () =>\n mutable([\n 'Extremely bad',\n 'Disappointed',\n 'Fair',\n 'Satisfied',\n 'Surprise',\n ] as const),\n },\n scoreTemplate: {\n type: String,\n default: '{value}',\n },\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n} as const)\n\nexport type RateProps = ExtractPropTypes<typeof rateProps>\n\nexport const rateEmits = {\n change: (value: number) => typeof value === 'number',\n [UPDATE_MODEL_EVENT]: (value: number) => typeof value === 'number',\n}\nexport type RateEmits = typeof rateEmits\n"],"names":["buildProps","definePropType","mutable","StarFilled","Star","isValidComponentSize","UPDATE_MODEL_EVENT"],"mappings":";;;;;;;;;AAIY,MAAC,SAAS,G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ils/props").BuildPropReturn<StringConstructor, "#1f2d3d", unknown, unknown, unknown>;
|
|
17
17
|
readonly texts: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<string[]>, () => ["Extremely bad", "Disappointed", "Fair", "Satisfied", "Surprise"], unknown, unknown, unknown>;
|
|
18
18
|
readonly scoreTemplate: import("../../../utils/props").BuildPropReturn<StringConstructor, "{value}", unknown, unknown, unknown>;
|
|
19
|
+
readonly size: import("../../../utils/props").BuildPropReturn<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown, unknown, unknown>;
|
|
19
20
|
}, {
|
|
20
21
|
hoverIndex: import("vue").Ref<number>;
|
|
21
22
|
currentValue: import("vue").Ref<number>;
|
|
@@ -43,6 +44,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
43
44
|
};
|
|
44
45
|
}>;
|
|
45
46
|
iconComponents: import("vue").ComputedRef<any[]>;
|
|
47
|
+
rateKls: import("vue").ComputedRef<string[]>;
|
|
46
48
|
showDecimalIcon: (item: number) => boolean;
|
|
47
49
|
getIconStyle: (item: number) => {
|
|
48
50
|
color: string | {
|
|
@@ -75,6 +77,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
75
77
|
readonly textColor?: unknown;
|
|
76
78
|
readonly texts?: unknown;
|
|
77
79
|
readonly scoreTemplate?: unknown;
|
|
80
|
+
readonly size?: unknown;
|
|
78
81
|
} & {
|
|
79
82
|
disabled: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
80
83
|
modelValue: number;
|
|
@@ -93,10 +96,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
93
96
|
showScore: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
94
97
|
texts: string[];
|
|
95
98
|
scoreTemplate: string;
|
|
96
|
-
} & {
|
|
99
|
+
} & {
|
|
100
|
+
size?: import("../../../utils/props").BuildPropType<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown> | undefined;
|
|
101
|
+
}> & {
|
|
97
102
|
onChange?: ((value: number) => any) | undefined;
|
|
98
103
|
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
99
104
|
}, {
|
|
105
|
+
size: import("../../../utils/props").BuildPropType<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown>;
|
|
100
106
|
disabled: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
|
|
101
107
|
modelValue: number;
|
|
102
108
|
textColor: string;
|
|
@@ -10,8 +10,10 @@ var aria = require('../../../utils/aria.js');
|
|
|
10
10
|
var constants = require('../../../utils/constants.js');
|
|
11
11
|
var index = require('../../icon/index.js');
|
|
12
12
|
var iconsVue = require('@element-plus/icons-vue');
|
|
13
|
+
require('../../../hooks/index.js');
|
|
13
14
|
var rate = require('./rate.js');
|
|
14
15
|
var form = require('../../../tokens/form.js');
|
|
16
|
+
var index$1 = require('../../../hooks/use-common-props/index.js');
|
|
15
17
|
|
|
16
18
|
function getValueFromMap(value, map) {
|
|
17
19
|
const isExcludedObject = (val) => shared.isObject(val);
|
|
@@ -34,9 +36,12 @@ var script = vue.defineComponent({
|
|
|
34
36
|
emits: rate.rateEmits,
|
|
35
37
|
setup(props, { emit }) {
|
|
36
38
|
const elForm = vue.inject(form.elFormKey, {});
|
|
39
|
+
const rateSize = index$1.useSize();
|
|
37
40
|
const currentValue = vue.ref(props.modelValue);
|
|
38
41
|
const hoverIndex = vue.ref(-1);
|
|
39
42
|
const pointerAtLeftHalf = vue.ref(true);
|
|
43
|
+
const prefix = "el-rate";
|
|
44
|
+
const rateKls = vue.computed(() => [prefix, `${prefix}--${rateSize.value}`]);
|
|
40
45
|
const rateDisabled = vue.computed(() => props.disabled || elForm.disabled);
|
|
41
46
|
const text = vue.computed(() => {
|
|
42
47
|
let result = "";
|
|
@@ -184,6 +189,7 @@ var script = vue.defineComponent({
|
|
|
184
189
|
decimalStyle,
|
|
185
190
|
decimalIconComponent,
|
|
186
191
|
iconComponents,
|
|
192
|
+
rateKls,
|
|
187
193
|
showDecimalIcon,
|
|
188
194
|
getIconStyle,
|
|
189
195
|
selectValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/rate/src/rate.vue"],"sourcesContent":["<template>\n <div\n class=\"el-rate\"\n role=\"slider\"\n :aria-valuenow=\"currentValue\"\n :aria-valuetext=\"text\"\n aria-valuemin=\"0\"\n :aria-valuemax=\"max\"\n tabindex=\"0\"\n @keydown=\"handleKey\"\n >\n <span\n v-for=\"(item, key) in max\"\n :key=\"key\"\n class=\"el-rate__item\"\n :style=\"{ cursor: rateDisabled ? 'auto' : 'pointer' }\"\n @mousemove=\"setCurrentValue(item, $event)\"\n @mouseleave=\"resetCurrentValue\"\n @click=\"selectValue(item)\"\n >\n <el-icon\n :class=\"[{ hover: hoverIndex === item }]\"\n class=\"el-rate__icon\"\n :style=\"getIconStyle(item)\"\n >\n <component :is=\"iconComponents[item - 1]\" />\n <el-icon\n v-if=\"showDecimalIcon(item)\"\n :style=\"decimalStyle\"\n class=\"el-rate__icon el-rate__decimal\"\n >\n <component :is=\"decimalIconComponent\" />\n </el-icon>\n </el-icon>\n </span>\n <span\n v-if=\"showText || showScore\"\n class=\"el-rate__text\"\n :style=\"{ color: textColor }\"\n >\n {{ text }}\n </span>\n </div>\n</template>\n<script lang=\"ts\">\nimport { defineComponent, inject, computed, ref, watch } from 'vue'\nimport { isObject, isArray } from '@vue/shared'\nimport { elFormKey } from '@element-plus/tokens'\nimport { hasClass } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\n\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { StarFilled, Star } from '@element-plus/icons-vue'\nimport { rateProps, rateEmits } from './rate'\nimport type { ElFormContext } from '@element-plus/tokens'\n\nfunction getValueFromMap<T>(\n value: number,\n map: Record<string, T | { excluded?: boolean; value: T }>\n) {\n const isExcludedObject = (\n val: unknown\n ): val is { excluded?: boolean } & Record<any, unknown> => isObject(val)\n\n const matchedKeys = Object.keys(map)\n .map((key) => +key)\n .filter((key) => {\n const val = map[key]\n const excluded = isExcludedObject(val) ? val.excluded : false\n return excluded ? value < key : value <= key\n })\n .sort((a, b) => a - b)\n const matchedValue = map[matchedKeys[0]]\n return (isExcludedObject(matchedValue) && matchedValue.value) || matchedValue\n}\n\nexport default defineComponent({\n name: 'ElRate',\n components: {\n ElIcon,\n StarFilled,\n Star,\n },\n props: rateProps,\n emits: rateEmits,\n\n setup(props, { emit }) {\n const elForm = inject(elFormKey, {} as ElFormContext)\n\n const currentValue = ref(props.modelValue)\n const hoverIndex = ref(-1)\n const pointerAtLeftHalf = ref(true)\n\n const rateDisabled = computed(() => props.disabled || elForm.disabled)\n const text = computed(() => {\n let result = ''\n if (props.showScore) {\n result = props.scoreTemplate.replace(\n /\\{\\s*value\\s*\\}/,\n rateDisabled.value ? `${props.modelValue}` : `${currentValue.value}`\n )\n } else if (props.showText) {\n result = props.texts[Math.ceil(currentValue.value) - 1]\n }\n return result\n })\n const valueDecimal = computed(\n () => props.modelValue * 100 - Math.floor(props.modelValue) * 100\n )\n const colorMap = computed(() =>\n isArray(props.colors)\n ? {\n [props.lowThreshold]: props.colors[0],\n [props.highThreshold]: { value: props.colors[1], excluded: true },\n [props.max]: props.colors[2],\n }\n : props.colors\n )\n const activeColor = computed(() =>\n getValueFromMap(currentValue.value, colorMap.value)\n )\n const decimalStyle = computed(() => {\n let width = ''\n if (rateDisabled.value) {\n width = `${valueDecimal.value}%`\n } else if (props.allowHalf) {\n width = '50%'\n }\n return {\n color: activeColor.value,\n width,\n }\n })\n const componentMap = computed(() =>\n isArray(props.icons)\n ? {\n [props.lowThreshold]: props.icons[0],\n [props.highThreshold]: {\n value: props.icons[1],\n excluded: true,\n },\n [props.max]: props.icons[2],\n }\n : props.icons\n )\n const decimalIconComponent = computed(() =>\n getValueFromMap(props.modelValue, componentMap.value)\n )\n const voidComponent = computed(() =>\n rateDisabled.value ? props.disabledvoidIcon : props.voidIcon\n )\n const activeComponent = computed(() =>\n getValueFromMap(currentValue.value, componentMap.value)\n )\n const iconComponents = computed(() => {\n const result = Array(props.max)\n const threshold = currentValue.value\n result.fill(activeComponent.value, 0, threshold)\n result.fill(voidComponent.value, threshold, props.max)\n return result\n })\n\n function showDecimalIcon(item: number) {\n const showWhenDisabled =\n rateDisabled.value &&\n valueDecimal.value > 0 &&\n item - 1 < props.modelValue &&\n item > props.modelValue\n const showWhenAllowHalf =\n props.allowHalf &&\n pointerAtLeftHalf.value &&\n item - 0.5 <= currentValue.value &&\n item > currentValue.value\n return showWhenDisabled || showWhenAllowHalf\n }\n\n function getIconStyle(item: number) {\n const voidColor = rateDisabled.value\n ? props.disabledVoidColor\n : props.voidColor\n return {\n color: item <= currentValue.value ? activeColor.value : voidColor,\n }\n }\n\n function selectValue(value: number) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf && pointerAtLeftHalf.value) {\n emit(UPDATE_MODEL_EVENT, currentValue.value)\n if (props.modelValue !== currentValue.value) {\n emit('change', currentValue.value)\n }\n } else {\n emit(UPDATE_MODEL_EVENT, value)\n if (props.modelValue !== value) {\n emit('change', value)\n }\n }\n }\n\n function handleKey(e: KeyboardEvent) {\n if (rateDisabled.value) {\n return\n }\n let _currentValue = currentValue.value\n const code = e.code\n if (code === EVENT_CODE.up || code === EVENT_CODE.right) {\n if (props.allowHalf) {\n _currentValue += 0.5\n } else {\n _currentValue += 1\n }\n e.stopPropagation()\n e.preventDefault()\n } else if (code === EVENT_CODE.left || code === EVENT_CODE.down) {\n if (props.allowHalf) {\n _currentValue -= 0.5\n } else {\n _currentValue -= 1\n }\n e.stopPropagation()\n e.preventDefault()\n }\n _currentValue = _currentValue < 0 ? 0 : _currentValue\n _currentValue = _currentValue > props.max ? props.max : _currentValue\n emit(UPDATE_MODEL_EVENT, _currentValue)\n emit('change', _currentValue)\n return _currentValue\n }\n\n function setCurrentValue(value: number, event: MouseEvent) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n let target = event.target as HTMLElement\n if (hasClass(target, 'el-rate__item')) {\n target = target.querySelector('.el-rate__icon')!\n }\n if (target.clientWidth === 0 || hasClass(target, 'el-rate__decimal')) {\n target = target.parentNode as HTMLElement\n }\n pointerAtLeftHalf.value = event.offsetX * 2 <= target.clientWidth\n currentValue.value = pointerAtLeftHalf.value ? value - 0.5 : value\n } else {\n currentValue.value = value\n }\n hoverIndex.value = value\n }\n\n function resetCurrentValue() {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n currentValue.value = props.modelValue\n hoverIndex.value = -1\n }\n\n watch(\n () => props.modelValue,\n (val) => {\n currentValue.value = val\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n )\n\n if (!props.modelValue) {\n emit(UPDATE_MODEL_EVENT, 0)\n }\n\n return {\n hoverIndex,\n currentValue,\n rateDisabled,\n text,\n decimalStyle,\n decimalIconComponent,\n iconComponents,\n\n showDecimalIcon,\n getIconStyle,\n selectValue,\n handleKey,\n setCurrentValue,\n resetCurrentValue,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ElIcon","StarFilled","rateProps","inject","elFormKey","ref","computed","EVENT_CODE"],"mappings":";;;;;;;;;;;;;;;AAqDA,SAAS,eAAe,MAAM,KAAK,EAAE;AACrC,EAAE,sBAAsB,GA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P,IAAI;QACF,OAAO;;;;QAIP,gBAAY,CAAC,MAAM,EAAE;UACnB,MAAM,GAAG,MAAM,CAAC;SACjB;;UAEC,MAAM,GAAG,OAAO,UAAU,CAAC;SAC5B;QACD,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC;oBAC/B,CAAC,KAAK,GAAG;;QAErB;;gBAEQ,CAAC,KAAK,GAAG,KAAK,CAAC;;;MAGzB;;;MAGA,IAAI,KAAK,CAAC,WAAW;yBACF,CAAC;;MAEpB;MACA,UAAU,CAAC,KAAK,IAAI,CAAC,CAAC;;aAEnB,CAAC,MAAM,KAAK,CAAC,YAAY,IAAI,KAAK;kBACzB,CAAC,KAAK,GAAG;wBACH,KAAK;;cAEf,CAAC,UAAU,EAAE;;;WAGhB;MACL,UAAU;kBACE;kBACA;UACR;kBACQ;;oBAEE;qBACC;MACf;MACA,WAAW;MACX,SAAS;MACT,eAAe;MACf,iBAAiB;MACjB;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rate.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/rate/src/rate.vue"],"sourcesContent":["<template>\n <div\n :class=\"rateKls\"\n role=\"slider\"\n :aria-valuenow=\"currentValue\"\n :aria-valuetext=\"text\"\n aria-valuemin=\"0\"\n :aria-valuemax=\"max\"\n tabindex=\"0\"\n @keydown=\"handleKey\"\n >\n <span\n v-for=\"(item, key) in max\"\n :key=\"key\"\n class=\"el-rate__item\"\n :style=\"{ cursor: rateDisabled ? 'auto' : 'pointer' }\"\n @mousemove=\"setCurrentValue(item, $event)\"\n @mouseleave=\"resetCurrentValue\"\n @click=\"selectValue(item)\"\n >\n <el-icon\n :class=\"[{ hover: hoverIndex === item }]\"\n class=\"el-rate__icon\"\n :style=\"getIconStyle(item)\"\n >\n <component :is=\"iconComponents[item - 1]\" />\n <el-icon\n v-if=\"showDecimalIcon(item)\"\n :style=\"decimalStyle\"\n class=\"el-rate__icon el-rate__decimal\"\n >\n <component :is=\"decimalIconComponent\" />\n </el-icon>\n </el-icon>\n </span>\n <span\n v-if=\"showText || showScore\"\n class=\"el-rate__text\"\n :style=\"{ color: textColor }\"\n >\n {{ text }}\n </span>\n </div>\n</template>\n<script lang=\"ts\">\nimport { defineComponent, inject, computed, ref, watch } from 'vue'\nimport { isObject, isArray } from '@vue/shared'\nimport { elFormKey } from '@element-plus/tokens'\nimport { hasClass } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\n\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { StarFilled, Star } from '@element-plus/icons-vue'\nimport { useSize } from '@element-plus/hooks'\nimport { rateProps, rateEmits } from './rate'\nimport type { ElFormContext } from '@element-plus/tokens'\n\nfunction getValueFromMap<T>(\n value: number,\n map: Record<string, T | { excluded?: boolean; value: T }>\n) {\n const isExcludedObject = (\n val: unknown\n ): val is { excluded?: boolean } & Record<any, unknown> => isObject(val)\n\n const matchedKeys = Object.keys(map)\n .map((key) => +key)\n .filter((key) => {\n const val = map[key]\n const excluded = isExcludedObject(val) ? val.excluded : false\n return excluded ? value < key : value <= key\n })\n .sort((a, b) => a - b)\n const matchedValue = map[matchedKeys[0]]\n return (isExcludedObject(matchedValue) && matchedValue.value) || matchedValue\n}\n\nexport default defineComponent({\n name: 'ElRate',\n components: {\n ElIcon,\n StarFilled,\n Star,\n },\n props: rateProps,\n emits: rateEmits,\n\n setup(props, { emit }) {\n const elForm = inject(elFormKey, {} as ElFormContext)\n\n const rateSize = useSize()\n const currentValue = ref(props.modelValue)\n const hoverIndex = ref(-1)\n const pointerAtLeftHalf = ref(true)\n\n const prefix = 'el-rate'\n const rateKls = computed(() => [prefix, `${prefix}--${rateSize.value}`])\n\n const rateDisabled = computed(() => props.disabled || elForm.disabled)\n const text = computed(() => {\n let result = ''\n if (props.showScore) {\n result = props.scoreTemplate.replace(\n /\\{\\s*value\\s*\\}/,\n rateDisabled.value ? `${props.modelValue}` : `${currentValue.value}`\n )\n } else if (props.showText) {\n result = props.texts[Math.ceil(currentValue.value) - 1]\n }\n return result\n })\n const valueDecimal = computed(\n () => props.modelValue * 100 - Math.floor(props.modelValue) * 100\n )\n const colorMap = computed(() =>\n isArray(props.colors)\n ? {\n [props.lowThreshold]: props.colors[0],\n [props.highThreshold]: { value: props.colors[1], excluded: true },\n [props.max]: props.colors[2],\n }\n : props.colors\n )\n const activeColor = computed(() =>\n getValueFromMap(currentValue.value, colorMap.value)\n )\n const decimalStyle = computed(() => {\n let width = ''\n if (rateDisabled.value) {\n width = `${valueDecimal.value}%`\n } else if (props.allowHalf) {\n width = '50%'\n }\n return {\n color: activeColor.value,\n width,\n }\n })\n const componentMap = computed(() =>\n isArray(props.icons)\n ? {\n [props.lowThreshold]: props.icons[0],\n [props.highThreshold]: {\n value: props.icons[1],\n excluded: true,\n },\n [props.max]: props.icons[2],\n }\n : props.icons\n )\n const decimalIconComponent = computed(() =>\n getValueFromMap(props.modelValue, componentMap.value)\n )\n const voidComponent = computed(() =>\n rateDisabled.value ? props.disabledvoidIcon : props.voidIcon\n )\n const activeComponent = computed(() =>\n getValueFromMap(currentValue.value, componentMap.value)\n )\n const iconComponents = computed(() => {\n const result = Array(props.max)\n const threshold = currentValue.value\n result.fill(activeComponent.value, 0, threshold)\n result.fill(voidComponent.value, threshold, props.max)\n return result\n })\n\n function showDecimalIcon(item: number) {\n const showWhenDisabled =\n rateDisabled.value &&\n valueDecimal.value > 0 &&\n item - 1 < props.modelValue &&\n item > props.modelValue\n const showWhenAllowHalf =\n props.allowHalf &&\n pointerAtLeftHalf.value &&\n item - 0.5 <= currentValue.value &&\n item > currentValue.value\n return showWhenDisabled || showWhenAllowHalf\n }\n\n function getIconStyle(item: number) {\n const voidColor = rateDisabled.value\n ? props.disabledVoidColor\n : props.voidColor\n return {\n color: item <= currentValue.value ? activeColor.value : voidColor,\n }\n }\n\n function selectValue(value: number) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf && pointerAtLeftHalf.value) {\n emit(UPDATE_MODEL_EVENT, currentValue.value)\n if (props.modelValue !== currentValue.value) {\n emit('change', currentValue.value)\n }\n } else {\n emit(UPDATE_MODEL_EVENT, value)\n if (props.modelValue !== value) {\n emit('change', value)\n }\n }\n }\n\n function handleKey(e: KeyboardEvent) {\n if (rateDisabled.value) {\n return\n }\n let _currentValue = currentValue.value\n const code = e.code\n if (code === EVENT_CODE.up || code === EVENT_CODE.right) {\n if (props.allowHalf) {\n _currentValue += 0.5\n } else {\n _currentValue += 1\n }\n e.stopPropagation()\n e.preventDefault()\n } else if (code === EVENT_CODE.left || code === EVENT_CODE.down) {\n if (props.allowHalf) {\n _currentValue -= 0.5\n } else {\n _currentValue -= 1\n }\n e.stopPropagation()\n e.preventDefault()\n }\n _currentValue = _currentValue < 0 ? 0 : _currentValue\n _currentValue = _currentValue > props.max ? props.max : _currentValue\n emit(UPDATE_MODEL_EVENT, _currentValue)\n emit('change', _currentValue)\n return _currentValue\n }\n\n function setCurrentValue(value: number, event: MouseEvent) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n let target = event.target as HTMLElement\n if (hasClass(target, 'el-rate__item')) {\n target = target.querySelector('.el-rate__icon')!\n }\n if (target.clientWidth === 0 || hasClass(target, 'el-rate__decimal')) {\n target = target.parentNode as HTMLElement\n }\n pointerAtLeftHalf.value = event.offsetX * 2 <= target.clientWidth\n currentValue.value = pointerAtLeftHalf.value ? value - 0.5 : value\n } else {\n currentValue.value = value\n }\n hoverIndex.value = value\n }\n\n function resetCurrentValue() {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n currentValue.value = props.modelValue\n hoverIndex.value = -1\n }\n\n watch(\n () => props.modelValue,\n (val) => {\n currentValue.value = val\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n )\n\n if (!props.modelValue) {\n emit(UPDATE_MODEL_EVENT, 0)\n }\n\n return {\n hoverIndex,\n currentValue,\n rateDisabled,\n text,\n decimalStyle,\n decimalIconComponent,\n iconComponents,\n rateKls,\n\n showDecimalIcon,\n getIconStyle,\n selectValue,\n handleKey,\n setCurrentValue,\n resetCurrentValue,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ElIcon","StarFilled","rateProps","inject","elFormKey","useSize","ref","computed","isArray","UPDATE_MODEL_EVENT","EVENT_CODE"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,SAAS,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE;AACrC,EAAE,sBAAsB,GAAG,CAAC,uBAAgB;AAC5C,EAAE,MAAM,WAAW,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG;;AAExD,IAAI,MAAM,QAAQ,GAAG;IACjB,OAAO;GACR,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE;AAC1B,EAAE;EACA,OAAO,gBAAgB;;aAEVA,mBAAe,CAAC;;EAE7B,UAAU,EAAE;YACVC,YAAM;gBACNC,mBAAU;uBACN;;OAED,EAAEC,cAAS;;OAEX,CAAC,OAAO,EAAE,QAAQ;IACrB,MAAM,MAAM,GAAGC,UAAM,CAACC,cAAS,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAGC,eAAO,EAAE,CAAC;AAC/B;;AAEA,IAAI,MAAM,iBAAiB,GAAGC;IAC1B,MAAM,MAAM;IACZ,MAAM;IACN,MAAM;IACN,MAAM,IAAI;MACR;;cAEQ,GAAG;OACV,MAAM,IAAI;;OAEV;MACD,OAAO,MAAM,CAAC;;IAEhB,MAAM,YAAY,GAAGC;IACrB,MAAM,QAAQ,GAAGA,YAAQ,CAAC,MAAMC,cAAO,CAAC;MACtC,CAAC,KAAK,CAAC,YAAY,GAAG;MACtB,CAAC,KAAK,CAAC,aAAa,KAAK,KAAK,EAAE;;KAEjC,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L;;;QAGF,CAAC,CAAC,cAAc,EAAE,CAAC;OACpB,MAAM,IAAI,IAAI,KAAKA;QAClB,IAAI,KAAK,CAAC,SAAS;UACjB,aAAa,IAAI,IAAI;SACtB,MAAM;UACL,aAAa,IAAI,CAAC,CAAC;SACpB;QACD,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,cAAc,EAAE,CAAC;;mBAER,GAAG;MAChB,aAAa,GAAG,aAAa,GAAG,KAAK,CAAC,GAAG;;;MAGzC,OAAO,aAAa,CAAC;;aAEd,eAAe,CAAC;UACnB,YAAY,CAAC;QACf;;MAEF;;;UAGI,MAAM,GAAG,MAAM,CAAC,cAAc;SAC/B;QACD,IAAI;;SAEH;QACD,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC;QAC3C,YAAY,CAAC,KAAK,GAAG,iBAAiB,CAAC;aAClC;QACL;;gBAEQ,CAAC,KAAK,GAAG,KAAK,CAAC;;aAElB,iBAAiB;;;;;QAKtB,kBAAkB,KAAK,GAAG,KAAK;OAChC;;MAED;;aAEG,CAAC,WAAW,CAAC;MAChB,aAAa,KAAK,GAAG,GAAG,CAAC;uBACR,CAAC,KAAK;;QAErB,OAAO;UACL,CAACD;;WAEA;gBACK;MACV,YAAY;kBACA;UACR;;;;aAIG;qBACQ;MACf;MACA,WAAW;MACX,SAAS;MACT,eAAe;MACf,iBAAiB;MACjB;;;;;;"}
|
|
@@ -9,7 +9,7 @@ const _hoisted_2 = ["onMousemove", "onClick"];
|
|
|
9
9
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
10
10
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
11
11
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
12
|
-
class:
|
|
12
|
+
class: vue.normalizeClass(_ctx.rateKls),
|
|
13
13
|
role: "slider",
|
|
14
14
|
"aria-valuenow": _ctx.currentValue,
|
|
15
15
|
"aria-valuetext": _ctx.text,
|
|
@@ -53,7 +53,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
53
53
|
class: "el-rate__text",
|
|
54
54
|
style: vue.normalizeStyle({ color: _ctx.textColor })
|
|
55
55
|
}, vue.toDisplayString(_ctx.text), 5)) : vue.createCommentVNode("v-if", true)
|
|
56
|
-
],
|
|
56
|
+
], 42, _hoisted_1);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
exports.render = render;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate.vue_vue_type_template_id_38c42df6_lang.js","sources":["../../../../../../packages/components/rate/src/rate.vue?vue&type=template&id=38c42df6&lang.js"],"sourcesContent":["<template>\n <div\n class=\"
|
|
1
|
+
{"version":3,"file":"rate.vue_vue_type_template_id_38c42df6_lang.js","sources":["../../../../../../packages/components/rate/src/rate.vue?vue&type=template&id=38c42df6&lang.js"],"sourcesContent":["<template>\n <div\n :class=\"rateKls\"\n role=\"slider\"\n :aria-valuenow=\"currentValue\"\n :aria-valuetext=\"text\"\n aria-valuemin=\"0\"\n :aria-valuemax=\"max\"\n tabindex=\"0\"\n @keydown=\"handleKey\"\n >\n <span\n v-for=\"(item, key) in max\"\n :key=\"key\"\n class=\"el-rate__item\"\n :style=\"{ cursor: rateDisabled ? 'auto' : 'pointer' }\"\n @mousemove=\"setCurrentValue(item, $event)\"\n @mouseleave=\"resetCurrentValue\"\n @click=\"selectValue(item)\"\n >\n <el-icon\n :class=\"[{ hover: hoverIndex === item }]\"\n class=\"el-rate__icon\"\n :style=\"getIconStyle(item)\"\n >\n <component :is=\"iconComponents[item - 1]\" />\n <el-icon\n v-if=\"showDecimalIcon(item)\"\n :style=\"decimalStyle\"\n class=\"el-rate__icon el-rate__decimal\"\n >\n <component :is=\"decimalIconComponent\" />\n </el-icon>\n </el-icon>\n </span>\n <span\n v-if=\"showText || showScore\"\n class=\"el-rate__text\"\n :style=\"{ color: textColor }\"\n >\n {{ text }}\n </span>\n </div>\n</template>\n<script lang=\"ts\">\nimport { defineComponent, inject, computed, ref, watch } from 'vue'\nimport { isObject, isArray } from '@vue/shared'\nimport { elFormKey } from '@element-plus/tokens'\nimport { hasClass } from '@element-plus/utils/dom'\nimport { EVENT_CODE } from '@element-plus/utils/aria'\n\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { StarFilled, Star } from '@element-plus/icons-vue'\nimport { useSize } from '@element-plus/hooks'\nimport { rateProps, rateEmits } from './rate'\nimport type { ElFormContext } from '@element-plus/tokens'\n\nfunction getValueFromMap<T>(\n value: number,\n map: Record<string, T | { excluded?: boolean; value: T }>\n) {\n const isExcludedObject = (\n val: unknown\n ): val is { excluded?: boolean } & Record<any, unknown> => isObject(val)\n\n const matchedKeys = Object.keys(map)\n .map((key) => +key)\n .filter((key) => {\n const val = map[key]\n const excluded = isExcludedObject(val) ? val.excluded : false\n return excluded ? value < key : value <= key\n })\n .sort((a, b) => a - b)\n const matchedValue = map[matchedKeys[0]]\n return (isExcludedObject(matchedValue) && matchedValue.value) || matchedValue\n}\n\nexport default defineComponent({\n name: 'ElRate',\n components: {\n ElIcon,\n StarFilled,\n Star,\n },\n props: rateProps,\n emits: rateEmits,\n\n setup(props, { emit }) {\n const elForm = inject(elFormKey, {} as ElFormContext)\n\n const rateSize = useSize()\n const currentValue = ref(props.modelValue)\n const hoverIndex = ref(-1)\n const pointerAtLeftHalf = ref(true)\n\n const prefix = 'el-rate'\n const rateKls = computed(() => [prefix, `${prefix}--${rateSize.value}`])\n\n const rateDisabled = computed(() => props.disabled || elForm.disabled)\n const text = computed(() => {\n let result = ''\n if (props.showScore) {\n result = props.scoreTemplate.replace(\n /\\{\\s*value\\s*\\}/,\n rateDisabled.value ? `${props.modelValue}` : `${currentValue.value}`\n )\n } else if (props.showText) {\n result = props.texts[Math.ceil(currentValue.value) - 1]\n }\n return result\n })\n const valueDecimal = computed(\n () => props.modelValue * 100 - Math.floor(props.modelValue) * 100\n )\n const colorMap = computed(() =>\n isArray(props.colors)\n ? {\n [props.lowThreshold]: props.colors[0],\n [props.highThreshold]: { value: props.colors[1], excluded: true },\n [props.max]: props.colors[2],\n }\n : props.colors\n )\n const activeColor = computed(() =>\n getValueFromMap(currentValue.value, colorMap.value)\n )\n const decimalStyle = computed(() => {\n let width = ''\n if (rateDisabled.value) {\n width = `${valueDecimal.value}%`\n } else if (props.allowHalf) {\n width = '50%'\n }\n return {\n color: activeColor.value,\n width,\n }\n })\n const componentMap = computed(() =>\n isArray(props.icons)\n ? {\n [props.lowThreshold]: props.icons[0],\n [props.highThreshold]: {\n value: props.icons[1],\n excluded: true,\n },\n [props.max]: props.icons[2],\n }\n : props.icons\n )\n const decimalIconComponent = computed(() =>\n getValueFromMap(props.modelValue, componentMap.value)\n )\n const voidComponent = computed(() =>\n rateDisabled.value ? props.disabledvoidIcon : props.voidIcon\n )\n const activeComponent = computed(() =>\n getValueFromMap(currentValue.value, componentMap.value)\n )\n const iconComponents = computed(() => {\n const result = Array(props.max)\n const threshold = currentValue.value\n result.fill(activeComponent.value, 0, threshold)\n result.fill(voidComponent.value, threshold, props.max)\n return result\n })\n\n function showDecimalIcon(item: number) {\n const showWhenDisabled =\n rateDisabled.value &&\n valueDecimal.value > 0 &&\n item - 1 < props.modelValue &&\n item > props.modelValue\n const showWhenAllowHalf =\n props.allowHalf &&\n pointerAtLeftHalf.value &&\n item - 0.5 <= currentValue.value &&\n item > currentValue.value\n return showWhenDisabled || showWhenAllowHalf\n }\n\n function getIconStyle(item: number) {\n const voidColor = rateDisabled.value\n ? props.disabledVoidColor\n : props.voidColor\n return {\n color: item <= currentValue.value ? activeColor.value : voidColor,\n }\n }\n\n function selectValue(value: number) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf && pointerAtLeftHalf.value) {\n emit(UPDATE_MODEL_EVENT, currentValue.value)\n if (props.modelValue !== currentValue.value) {\n emit('change', currentValue.value)\n }\n } else {\n emit(UPDATE_MODEL_EVENT, value)\n if (props.modelValue !== value) {\n emit('change', value)\n }\n }\n }\n\n function handleKey(e: KeyboardEvent) {\n if (rateDisabled.value) {\n return\n }\n let _currentValue = currentValue.value\n const code = e.code\n if (code === EVENT_CODE.up || code === EVENT_CODE.right) {\n if (props.allowHalf) {\n _currentValue += 0.5\n } else {\n _currentValue += 1\n }\n e.stopPropagation()\n e.preventDefault()\n } else if (code === EVENT_CODE.left || code === EVENT_CODE.down) {\n if (props.allowHalf) {\n _currentValue -= 0.5\n } else {\n _currentValue -= 1\n }\n e.stopPropagation()\n e.preventDefault()\n }\n _currentValue = _currentValue < 0 ? 0 : _currentValue\n _currentValue = _currentValue > props.max ? props.max : _currentValue\n emit(UPDATE_MODEL_EVENT, _currentValue)\n emit('change', _currentValue)\n return _currentValue\n }\n\n function setCurrentValue(value: number, event: MouseEvent) {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n let target = event.target as HTMLElement\n if (hasClass(target, 'el-rate__item')) {\n target = target.querySelector('.el-rate__icon')!\n }\n if (target.clientWidth === 0 || hasClass(target, 'el-rate__decimal')) {\n target = target.parentNode as HTMLElement\n }\n pointerAtLeftHalf.value = event.offsetX * 2 <= target.clientWidth\n currentValue.value = pointerAtLeftHalf.value ? value - 0.5 : value\n } else {\n currentValue.value = value\n }\n hoverIndex.value = value\n }\n\n function resetCurrentValue() {\n if (rateDisabled.value) {\n return\n }\n if (props.allowHalf) {\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n currentValue.value = props.modelValue\n hoverIndex.value = -1\n }\n\n watch(\n () => props.modelValue,\n (val) => {\n currentValue.value = val\n pointerAtLeftHalf.value =\n props.modelValue !== Math.floor(props.modelValue)\n }\n )\n\n if (!props.modelValue) {\n emit(UPDATE_MODEL_EVENT, 0)\n }\n\n return {\n hoverIndex,\n currentValue,\n rateDisabled,\n text,\n decimalStyle,\n decimalIconComponent,\n iconComponents,\n rateKls,\n\n showDecimalIcon,\n getIconStyle,\n selectValue,\n handleKey,\n setCurrentValue,\n resetCurrentValue,\n }\n },\n})\n</script>\n"],"names":["_openBlock","_createVNode"],"mappings":";;;;;;;;;;;;;;IAEK,uBAAO;IACR;IACC,eAAa,EAAE;IACf;IACD,iBAAc;;;aAGNA,gDAAE;;;;QAIP;QACD;QACC;;QAEAC,eAAU;eACL,gCAAa,KAAK;;;UAGrB;;;;;;;;;;;;;;;;;;;;;;KAeG;;;;;"}
|
|
@@ -24,9 +24,13 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
24
24
|
type: BooleanConstructor;
|
|
25
25
|
default: boolean;
|
|
26
26
|
};
|
|
27
|
+
size: {
|
|
28
|
+
type: import("vue").PropType<import("element-plus/es/utils/types").ComponentSize>;
|
|
29
|
+
validator: (val: string) => boolean;
|
|
30
|
+
};
|
|
27
31
|
inputSize: {
|
|
28
32
|
type: import("vue").PropType<import("element-plus/es/utils/types").ComponentSize>;
|
|
29
|
-
|
|
33
|
+
validator: (val: string) => boolean;
|
|
30
34
|
};
|
|
31
35
|
showStops: {
|
|
32
36
|
type: BooleanConstructor;
|
|
@@ -89,6 +93,9 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
89
93
|
stops: import("vue").ComputedRef<number[]>;
|
|
90
94
|
markList: import("vue").ComputedRef<import("./src/slider.type").Mark[]>;
|
|
91
95
|
sliderWrapper: import("vue").Ref<import("element-plus/es/utils/types").Nullable<HTMLElement>>;
|
|
96
|
+
sliderWrapperSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
|
|
97
|
+
sliderInputSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
|
|
98
|
+
sliderKls: import("vue").ComputedRef<string[]>;
|
|
92
99
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "update:modelValue" | "change")[], "input" | "update:modelValue" | "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
93
100
|
modelValue?: unknown;
|
|
94
101
|
min?: unknown;
|
|
@@ -96,6 +103,7 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
96
103
|
step?: unknown;
|
|
97
104
|
showInput?: unknown;
|
|
98
105
|
showInputControls?: unknown;
|
|
106
|
+
size?: unknown;
|
|
99
107
|
inputSize?: unknown;
|
|
100
108
|
showStops?: unknown;
|
|
101
109
|
showTooltip?: unknown;
|
|
@@ -114,7 +122,6 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
114
122
|
height: string;
|
|
115
123
|
vertical: boolean;
|
|
116
124
|
range: boolean;
|
|
117
|
-
inputSize: import("element-plus/es/utils/types").ComponentSize;
|
|
118
125
|
debounce: number;
|
|
119
126
|
max: number;
|
|
120
127
|
min: number;
|
|
@@ -124,7 +131,9 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
124
131
|
showInputControls: boolean;
|
|
125
132
|
showStops: boolean;
|
|
126
133
|
} & {
|
|
134
|
+
size?: import("element-plus/es/utils/types").ComponentSize | undefined;
|
|
127
135
|
label?: string | undefined;
|
|
136
|
+
inputSize?: import("element-plus/es/utils/types").ComponentSize | undefined;
|
|
128
137
|
tooltipClass?: string | undefined;
|
|
129
138
|
formatTooltip?: ((val: number) => string | number) | undefined;
|
|
130
139
|
marks?: Record<string, any> | undefined;
|
|
@@ -139,7 +148,6 @@ declare const _Slider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
139
148
|
height: string;
|
|
140
149
|
vertical: boolean;
|
|
141
150
|
range: boolean;
|
|
142
|
-
inputSize: import("element-plus/es/utils/types").ComponentSize;
|
|
143
151
|
debounce: number;
|
|
144
152
|
max: number;
|
|
145
153
|
min: number;
|
|
@@ -177,9 +185,13 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
177
185
|
type: BooleanConstructor;
|
|
178
186
|
default: boolean;
|
|
179
187
|
};
|
|
188
|
+
size: {
|
|
189
|
+
type: import("vue").PropType<import("element-plus/es/utils/types").ComponentSize>;
|
|
190
|
+
validator: (val: string) => boolean;
|
|
191
|
+
};
|
|
180
192
|
inputSize: {
|
|
181
193
|
type: import("vue").PropType<import("element-plus/es/utils/types").ComponentSize>;
|
|
182
|
-
|
|
194
|
+
validator: (val: string) => boolean;
|
|
183
195
|
};
|
|
184
196
|
showStops: {
|
|
185
197
|
type: BooleanConstructor;
|
|
@@ -242,6 +254,9 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
242
254
|
stops: import("vue").ComputedRef<number[]>;
|
|
243
255
|
markList: import("vue").ComputedRef<import("./src/slider.type").Mark[]>;
|
|
244
256
|
sliderWrapper: import("vue").Ref<import("element-plus/es/utils/types").Nullable<HTMLElement>>;
|
|
257
|
+
sliderWrapperSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
|
|
258
|
+
sliderInputSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
|
|
259
|
+
sliderKls: import("vue").ComputedRef<string[]>;
|
|
245
260
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "update:modelValue" | "change")[], "input" | "update:modelValue" | "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
246
261
|
modelValue?: unknown;
|
|
247
262
|
min?: unknown;
|
|
@@ -249,6 +264,7 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
249
264
|
step?: unknown;
|
|
250
265
|
showInput?: unknown;
|
|
251
266
|
showInputControls?: unknown;
|
|
267
|
+
size?: unknown;
|
|
252
268
|
inputSize?: unknown;
|
|
253
269
|
showStops?: unknown;
|
|
254
270
|
showTooltip?: unknown;
|
|
@@ -267,7 +283,6 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
267
283
|
height: string;
|
|
268
284
|
vertical: boolean;
|
|
269
285
|
range: boolean;
|
|
270
|
-
inputSize: import("element-plus/es/utils/types").ComponentSize;
|
|
271
286
|
debounce: number;
|
|
272
287
|
max: number;
|
|
273
288
|
min: number;
|
|
@@ -277,7 +292,9 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
277
292
|
showInputControls: boolean;
|
|
278
293
|
showStops: boolean;
|
|
279
294
|
} & {
|
|
295
|
+
size?: import("element-plus/es/utils/types").ComponentSize | undefined;
|
|
280
296
|
label?: string | undefined;
|
|
297
|
+
inputSize?: import("element-plus/es/utils/types").ComponentSize | undefined;
|
|
281
298
|
tooltipClass?: string | undefined;
|
|
282
299
|
formatTooltip?: ((val: number) => string | number) | undefined;
|
|
283
300
|
marks?: Record<string, any> | undefined;
|
|
@@ -292,7 +309,6 @@ export declare const ElSlider: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
292
309
|
height: string;
|
|
293
310
|
vertical: boolean;
|
|
294
311
|
range: boolean;
|
|
295
|
-
inputSize: import("element-plus/es/utils/types").ComponentSize;
|
|
296
312
|
debounce: number;
|
|
297
313
|
max: number;
|
|
298
314
|
min: number;
|
|
@@ -25,9 +25,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
25
25
|
type: BooleanConstructor;
|
|
26
26
|
default: boolean;
|
|
27
27
|
};
|
|
28
|
+
size: {
|
|
29
|
+
type: PropType<ComponentSize>;
|
|
30
|
+
validator: (val: string) => boolean;
|
|
31
|
+
};
|
|
28
32
|
inputSize: {
|
|
29
33
|
type: PropType<ComponentSize>;
|
|
30
|
-
|
|
34
|
+
validator: (val: string) => boolean;
|
|
31
35
|
};
|
|
32
36
|
showStops: {
|
|
33
37
|
type: BooleanConstructor;
|
|
@@ -90,6 +94,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
90
94
|
stops: import("vue").ComputedRef<number[]>;
|
|
91
95
|
markList: import("vue").ComputedRef<import("./slider.type").Mark[]>;
|
|
92
96
|
sliderWrapper: Ref<Nullable<HTMLElement>>;
|
|
97
|
+
sliderWrapperSize: import("vue").ComputedRef<ComponentSize>;
|
|
98
|
+
sliderInputSize: import("vue").ComputedRef<ComponentSize>;
|
|
99
|
+
sliderKls: import("vue").ComputedRef<string[]>;
|
|
93
100
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "update:modelValue" | "change")[], "input" | "update:modelValue" | "change", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
94
101
|
modelValue?: unknown;
|
|
95
102
|
min?: unknown;
|
|
@@ -97,6 +104,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
104
|
step?: unknown;
|
|
98
105
|
showInput?: unknown;
|
|
99
106
|
showInputControls?: unknown;
|
|
107
|
+
size?: unknown;
|
|
100
108
|
inputSize?: unknown;
|
|
101
109
|
showStops?: unknown;
|
|
102
110
|
showTooltip?: unknown;
|
|
@@ -115,7 +123,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
115
123
|
height: string;
|
|
116
124
|
vertical: boolean;
|
|
117
125
|
range: boolean;
|
|
118
|
-
inputSize: ComponentSize;
|
|
119
126
|
debounce: number;
|
|
120
127
|
max: number;
|
|
121
128
|
min: number;
|
|
@@ -125,7 +132,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
125
132
|
showInputControls: boolean;
|
|
126
133
|
showStops: boolean;
|
|
127
134
|
} & {
|
|
135
|
+
size?: ComponentSize | undefined;
|
|
128
136
|
label?: string | undefined;
|
|
137
|
+
inputSize?: ComponentSize | undefined;
|
|
129
138
|
tooltipClass?: string | undefined;
|
|
130
139
|
formatTooltip?: ((val: number) => number | string) | undefined;
|
|
131
140
|
marks?: Record<string, any> | undefined;
|
|
@@ -140,7 +149,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
140
149
|
height: string;
|
|
141
150
|
vertical: boolean;
|
|
142
151
|
range: boolean;
|
|
143
|
-
inputSize: ComponentSize;
|
|
144
152
|
debounce: number;
|
|
145
153
|
max: number;
|
|
146
154
|
min: number;
|
|
@@ -7,6 +7,8 @@ var index = require('../../input-number/index.js');
|
|
|
7
7
|
var constants = require('../../../utils/constants.js');
|
|
8
8
|
var dom = require('../../../utils/dom.js');
|
|
9
9
|
var error = require('../../../utils/error.js');
|
|
10
|
+
var validators = require('../../../utils/validators.js');
|
|
11
|
+
require('../../../hooks/index.js');
|
|
10
12
|
require('./button.js');
|
|
11
13
|
require('./marker.js');
|
|
12
14
|
var useMarks = require('./useMarks.js');
|
|
@@ -14,6 +16,7 @@ var useSlide = require('./useSlide.js');
|
|
|
14
16
|
var useStops = require('./useStops.js');
|
|
15
17
|
var button_vue_vue_type_script_lang = require('./button.vue_vue_type_script_lang.js');
|
|
16
18
|
var marker_vue_vue_type_script_lang = require('./marker.vue_vue_type_script_lang.js');
|
|
19
|
+
var index$1 = require('../../../hooks/use-common-props/index.js');
|
|
17
20
|
|
|
18
21
|
var script = vue.defineComponent({
|
|
19
22
|
name: "ElSlider",
|
|
@@ -47,9 +50,13 @@ var script = vue.defineComponent({
|
|
|
47
50
|
type: Boolean,
|
|
48
51
|
default: true
|
|
49
52
|
},
|
|
53
|
+
size: {
|
|
54
|
+
type: String,
|
|
55
|
+
validator: validators.isValidComponentSize
|
|
56
|
+
},
|
|
50
57
|
inputSize: {
|
|
51
58
|
type: String,
|
|
52
|
-
|
|
59
|
+
validator: validators.isValidComponentSize
|
|
53
60
|
},
|
|
54
61
|
showStops: {
|
|
55
62
|
type: Boolean,
|
|
@@ -119,6 +126,15 @@ var script = vue.defineComponent({
|
|
|
119
126
|
setSecondValue
|
|
120
127
|
} = useSlide.useSlide(props, initData, emit);
|
|
121
128
|
const { stops, getStopStyle } = useStops.useStops(props, initData, minValue, maxValue);
|
|
129
|
+
const sliderWrapperSize = index$1.useSize();
|
|
130
|
+
const sliderInputSize = vue.computed(() => props.inputSize || sliderWrapperSize.value);
|
|
131
|
+
const prefix = "el-slider";
|
|
132
|
+
const sliderKls = vue.computed(() => [
|
|
133
|
+
prefix,
|
|
134
|
+
`${prefix}--${sliderWrapperSize.value}`,
|
|
135
|
+
props.vertical ? "is-vertical" : "",
|
|
136
|
+
props.showInput ? "el-slider--with-input" : ""
|
|
137
|
+
]);
|
|
122
138
|
const markList = useMarks.useMarks(props);
|
|
123
139
|
useWatch(props, initData, minValue, maxValue, emit, elFormItem);
|
|
124
140
|
const precision = vue.computed(() => {
|
|
@@ -161,7 +177,10 @@ var script = vue.defineComponent({
|
|
|
161
177
|
setSecondValue,
|
|
162
178
|
stops,
|
|
163
179
|
markList,
|
|
164
|
-
sliderWrapper
|
|
180
|
+
sliderWrapper,
|
|
181
|
+
sliderWrapperSize,
|
|
182
|
+
sliderInputSize,
|
|
183
|
+
sliderKls
|
|
165
184
|
};
|
|
166
185
|
}
|
|
167
186
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/slider/src/index.vue"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n class=\"el-slider\"\n :class=\"{ 'is-vertical': vertical, 'el-slider--with-input': showInput }\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"inputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n default: 'small',\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["defineComponent","ElInputNumber","SliderMarker","useSlide","UPDATE_MODEL_EVENT","INPUT_EVENT","throwError","on","off"],"mappings":";;;;;;;;;;;;;;;;;AAwGA,aAAeA,mBAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,mBAAIC,mBAAa;;AAEjB,kBAAIC,0CAAY;GACb;;IAEC,UAAU;MACR,IAAI,EAAE,CAAC;MACP,OAAO,EAAE,CAAC;KACX;;;MAGC;KACD;OACE,EAAE;MACH,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE;;KAEP;;MAEC,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,OAAO;;KAEd;eACU,EAAE;MACX,IAAI,EAAE,OAAO;;KAEd;iBACY,EAAE;MACb,IAAI,EAAE,QAAQ;;KAEf;YACO,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Q,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,YAAY,EAAE;UAChB,CAAC,EAAE,GAAG;;;;KAIX,MAAM,IAAI,CAAC,KAAK;MACf,IAAI,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE;;QAEjB;OACD,MAAM;;;;UAIH,QAAQ;SACT;OACF;;IAEH;WACO,GAAG;WACP,CAAC,MAAM,SAAS,QAAQ,EAAE,CAAC,GAAG;SAC5B,GAAG,EAAE;eACC,EAAE,CAAC;;;YAGV,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QACzB,QAAQ,CAAC,YAAY;MACvB,OAAO;;aAEA;;YAEL,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;aACvB,EAAE,CAAC;;;;;eAKL,CAAC,YAAY;iBACP,CAAC;QACV,KAAK,CAAC,KAAK,EAAE;MACf,IAAI,MAAM,OAAO,CAAC,KAAK,CAAC;QACtB,QAAQ,CAAC;QACT;aACK;QACL,QAAQ,CAAC;gBACD,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG;;;MAGlC;;;;OAIC;;OAEA;cACO,CAAC,QAAQ,GAAG;MACpB;;iBAEW,CAAC;;IAEdC;;;GAGD,CAAC,CAAC;qBACY,CAAC,MAAM;IACpBC,OAAG,CAAC,MAAM,EAAE;;SAEP;iBACQ;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.vue_vue_type_script_lang.js","sources":["../../../../../../packages/components/slider/src/index.vue"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n :class=\"sliderKls\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"sliderInputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { useSize } from '@element-plus/hooks'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const sliderWrapperSize = useSize()\n const sliderInputSize = computed(\n () => props.inputSize || sliderWrapperSize.value\n )\n\n const prefix = 'el-slider'\n const sliderKls = computed(() => [\n prefix,\n `${prefix}--${sliderWrapperSize.value}`,\n props.vertical ? 'is-vertical' : '',\n props.showInput ? 'el-slider--with-input' : '',\n ])\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n sliderWrapperSize,\n sliderInputSize,\n sliderKls,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["defineComponent","ElInputNumber","SliderMarker","useSlide","provide","toRefs","INPUT_EVENT","throwError","ref","on","nextTick"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyGA,aAAeA,mBAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,mBAAIC,mBAAa;;AAEjB,kBAAIC,0CAAY;GACb;;IAEC,UAAU;MACR,IAAI,EAAE,CAAC;MACP,OAAO,EAAE,CAAC;KACX;;;MAGC;KACD;OACE,EAAE;MACH,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE;;KAEP;;MAEC,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,OAAO;;KAEd;eACU,EAAE;MACX,IAAI,EAAE,OAAO;;KAEd;iBACY,EAAE;MACb,IAAI,EAAE,QAAQ;;KAEf;YACO,EAAE;MACR,IAAI,EAAE,OAAO;;KAEd;SACI;MACH,IAAI,EAAE,OAAO;;KAEd;YACO,EAAE;MACR,IAAI,EAAE,OAAO;;KAEd;UACK,EAAE;MACN,IAAI,EAAE,MAAM;;KAEb;YACO,EAAE;MACR,IAAI,EAAE,MAAM;;KAEb;SACI;MACH,IAAI,EAAE;;KAEP;gBACW,EAAE;MACZ,IAAI,EAAE,MAAM;;KAEb;SACI,QAAQ;;;OAGV,CAAC,KAAK,EAAE;UACL,QAAQ;MACZ,UAAU,EAAE,CAAC;;MAEb,QAAQ,EAAE,CAAC;;;KAGZ,CAAC,CAAC;;MAED;MACA,MAAM;MACN;MACA;MACA;MACA,QAAQ;MACR,QAAQ;;;MAGR;MACA,UAAU;MACV;MACA;MACA;QACEC,iBAAQ,CAA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