element-plus 1.3.0-beta.8 → 1.3.0-beta.9
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 +211 -206
- 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 +211 -206
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/components/carousel/index.d.ts +11 -0
- package/es/components/carousel/src/item.mjs +17 -13
- package/es/components/carousel/src/item.mjs.map +1 -1
- package/es/components/carousel/src/main.mjs +25 -23
- package/es/components/carousel/src/main.mjs.map +1 -1
- package/es/components/carousel/src/main.vue.d.ts +11 -0
- package/es/components/checkbox/index.d.ts +3 -3
- package/es/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
- package/es/components/checkbox/src/checkbox.vue.d.ts +1 -1
- package/es/components/checkbox/src/useCheckbox.d.ts +1 -1
- package/es/components/checkbox/src/useCheckbox.mjs +2 -2
- package/es/components/checkbox/src/useCheckbox.mjs.map +1 -1
- package/es/components/message-box/src/index.mjs +5 -2
- package/es/components/message-box/src/index.mjs.map +1 -1
- package/es/components/message-box/src/index.vue.d.ts +1 -0
- package/es/components/popover/index.d.ts +0 -6
- package/es/components/popover/src/index.vue.d.ts +0 -3
- package/es/components/popover/src/popover.d.ts +0 -1
- package/es/components/popover/src/popover.mjs +0 -4
- package/es/components/popover/src/popover.mjs.map +1 -1
- package/es/components/transfer/index.d.ts +492 -0
- package/es/components/transfer/src/index.mjs +11 -6
- package/es/components/transfer/src/index.mjs.map +1 -1
- package/es/components/transfer/src/index.vue.d.ts +246 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/carousel/index.d.ts +11 -0
- package/lib/components/carousel/src/item.js +17 -13
- package/lib/components/carousel/src/item.js.map +1 -1
- package/lib/components/carousel/src/main.js +25 -23
- package/lib/components/carousel/src/main.js.map +1 -1
- package/lib/components/carousel/src/main.vue.d.ts +11 -0
- package/lib/components/checkbox/index.d.ts +3 -3
- package/lib/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
- package/lib/components/checkbox/src/checkbox.vue.d.ts +1 -1
- package/lib/components/checkbox/src/useCheckbox.d.ts +1 -1
- package/lib/components/checkbox/src/useCheckbox.js +2 -2
- package/lib/components/checkbox/src/useCheckbox.js.map +1 -1
- package/lib/components/message-box/src/index.js +13 -10
- package/lib/components/message-box/src/index.js.map +1 -1
- package/lib/components/message-box/src/index.vue.d.ts +1 -0
- package/lib/components/popover/index.d.ts +0 -6
- package/lib/components/popover/src/index.vue.d.ts +0 -3
- package/lib/components/popover/src/popover.d.ts +0 -1
- package/lib/components/popover/src/popover.js +0 -4
- package/lib/components/popover/src/popover.js.map +1 -1
- package/lib/components/transfer/index.d.ts +492 -0
- package/lib/components/transfer/src/index.js +11 -6
- package/lib/components/transfer/src/index.js.map +1 -1
- package/lib/components/transfer/src/index.vue.d.ts +246 -0
- 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-popper.css +1 -1
- package/theme-chalk/el-tooltip.css +0 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/common/var.scss +0 -15
- package/theme-chalk/src/popper.scss +20 -2
- package/theme-chalk/src/tooltip.scss +0 -95
- package/web-types.json +1 -1
|
@@ -37,7 +37,7 @@ export declare const ElCheckbox: import("../../utils/types").SFCWithInstall<impo
|
|
|
37
37
|
tabindex: (StringConstructor | NumberConstructor)[];
|
|
38
38
|
}, {
|
|
39
39
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
40
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
40
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
41
41
|
checkboxSize: import("vue").ComputedRef<import("../../utils/types").ComponentSize>;
|
|
42
42
|
model: import("vue").WritableComputedRef<any>;
|
|
43
43
|
handleChange: (e: InputEvent) => void;
|
|
@@ -134,7 +134,7 @@ export declare const ElCheckbox: import("../../utils/types").SFCWithInstall<impo
|
|
|
134
134
|
}, {
|
|
135
135
|
focus: import("vue").Ref<boolean>;
|
|
136
136
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
137
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
137
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
138
138
|
model: import("vue").WritableComputedRef<any>;
|
|
139
139
|
handleChange: (e: InputEvent) => void;
|
|
140
140
|
activeStyle: import("vue").ComputedRef<{
|
|
@@ -296,7 +296,7 @@ export declare const ElCheckboxButton: import("../../utils/types").SFCWithInstal
|
|
|
296
296
|
}, {
|
|
297
297
|
focus: import("vue").Ref<boolean>;
|
|
298
298
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
299
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
299
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
300
300
|
model: import("vue").WritableComputedRef<any>;
|
|
301
301
|
handleChange: (e: InputEvent) => void;
|
|
302
302
|
activeStyle: import("vue").ComputedRef<{
|
|
@@ -26,7 +26,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
26
26
|
}, {
|
|
27
27
|
focus: import("vue").Ref<boolean>;
|
|
28
28
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
29
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
29
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
30
30
|
model: import("vue").WritableComputedRef<any>;
|
|
31
31
|
handleChange: (e: InputEvent) => void;
|
|
32
32
|
activeStyle: import("vue").ComputedRef<{
|
|
@@ -39,7 +39,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
39
39
|
tabindex: (StringConstructor | NumberConstructor)[];
|
|
40
40
|
}, {
|
|
41
41
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
42
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
42
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
43
43
|
checkboxSize: import("vue").ComputedRef<ComponentSize>;
|
|
44
44
|
model: import("vue").WritableComputedRef<any>;
|
|
45
45
|
handleChange: (e: InputEvent) => void;
|
|
@@ -37,7 +37,7 @@ export declare const useCheckboxGroup: () => {
|
|
|
37
37
|
};
|
|
38
38
|
export declare const useCheckbox: (props: IUseCheckboxProps) => {
|
|
39
39
|
isChecked: import("vue").ComputedRef<boolean>;
|
|
40
|
-
isDisabled: import("vue").ComputedRef<boolean
|
|
40
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
41
41
|
checkboxSize: import("vue").ComputedRef<import("element-plus/es/utils/types").ComponentSize>;
|
|
42
42
|
model: import("vue").WritableComputedRef<any>;
|
|
43
43
|
handleChange: (e: InputEvent) => void;
|
|
@@ -117,9 +117,9 @@ const useDisabled = (props, {
|
|
|
117
117
|
return !!(max || min) && model.value.length >= max && !isChecked.value || model.value.length <= min && isChecked.value;
|
|
118
118
|
});
|
|
119
119
|
const isDisabled = vue.computed(() => {
|
|
120
|
-
var _a;
|
|
120
|
+
var _a, _b;
|
|
121
121
|
const disabled = props.disabled || elForm.disabled;
|
|
122
|
-
return isGroup.value ? ((_a = checkboxGroup.disabled) == null ? void 0 : _a.value) || disabled || isLimitDisabled.value : props.disabled || elForm.disabled;
|
|
122
|
+
return (_b = isGroup.value ? ((_a = checkboxGroup.disabled) == null ? void 0 : _a.value) || disabled || isLimitDisabled.value : props.disabled || elForm.disabled) != null ? _b : false;
|
|
123
123
|
});
|
|
124
124
|
return {
|
|
125
125
|
isDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckbox.js","sources":["../../../../../../packages/components/checkbox/src/useCheckbox.ts"],"sourcesContent":["import { ref, computed, inject, getCurrentInstance, watch } from 'vue'\nimport { toTypeString } from '@vue/shared'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { elFormKey, elFormItemKey } from '@element-plus/tokens'\n\nimport { useSize } from '@element-plus/hooks'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ElFormContext, ElFormItemContext } from '@element-plus/tokens'\nimport type { PartialReturnType } from '@element-plus/utils/types'\nimport type { ICheckboxGroupInstance } from './checkbox.type'\n\nexport const useCheckboxProps = {\n modelValue: {\n type: [Boolean, Number, String],\n default: () => undefined,\n },\n label: {\n type: [String, Boolean, Number, Object],\n },\n indeterminate: Boolean,\n disabled: Boolean,\n checked: Boolean,\n name: {\n type: String,\n default: undefined,\n },\n trueLabel: {\n type: [String, Number],\n default: undefined,\n },\n falseLabel: {\n type: [String, Number],\n default: undefined,\n },\n tabindex: [String, Number],\n size: String,\n}\n\nexport type IUseCheckboxProps = ExtractPropTypes<typeof useCheckboxProps>\n\nexport const useCheckboxGroup = () => {\n const elForm = inject(elFormKey, {} as ElFormContext)\n const elFormItem = inject(elFormItemKey, {} as ElFormItemContext)\n const checkboxGroup = inject<ICheckboxGroupInstance>('CheckboxGroup', {})\n const isGroup = computed(\n () => checkboxGroup && checkboxGroup?.name === 'ElCheckboxGroup'\n )\n const elFormItemSize = computed(() => {\n return elFormItem.size\n })\n return {\n isGroup,\n checkboxGroup,\n elForm,\n elFormItemSize,\n elFormItem,\n }\n}\n\nconst useModel = (props: IUseCheckboxProps) => {\n const selfModel = ref(false)\n const { emit } = getCurrentInstance()\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitExceeded = ref(false)\n const model = computed({\n get() {\n return isGroup.value\n ? checkboxGroup.modelValue?.value\n : props.modelValue ?? selfModel.value\n },\n\n set(val: unknown) {\n if (isGroup.value && Array.isArray(val)) {\n isLimitExceeded.value =\n checkboxGroup.max !== undefined &&\n val.length > checkboxGroup.max.value\n isLimitExceeded.value === false && checkboxGroup?.changeEvent?.(val)\n } else {\n emit(UPDATE_MODEL_EVENT, val)\n selfModel.value = val as boolean\n }\n },\n })\n\n return {\n model,\n isLimitExceeded,\n }\n}\n\nconst useCheckboxStatus = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const focus = ref(false)\n const size = useSize(checkboxGroup?.checkboxGroupSize, { prop: true })\n const isChecked = computed<boolean>(() => {\n const value = model.value\n if (toTypeString(value) === '[object Boolean]') {\n return value\n } else if (Array.isArray(value)) {\n return value.includes(props.label)\n } else if (value !== null && value !== undefined) {\n return value === props.trueLabel\n } else {\n return !!value\n }\n })\n\n const checkboxSize = useSize(\n computed(() =>\n isGroup.value ? checkboxGroup?.checkboxGroupSize?.value : undefined\n )\n )\n\n return {\n isChecked,\n focus,\n size,\n checkboxSize,\n }\n}\n\nconst useDisabled = (\n props: IUseCheckboxProps,\n {\n model,\n isChecked,\n }: PartialReturnType<typeof useModel> &\n PartialReturnType<typeof useCheckboxStatus>\n) => {\n const { elForm, isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitDisabled = computed(() => {\n const max = checkboxGroup.max?.value\n const min = checkboxGroup.min?.value\n return (\n (!!(max || min) && model.value.length >= max && !isChecked.value) ||\n (model.value.length <= min && isChecked.value)\n )\n })\n const isDisabled = computed(() => {\n const disabled = props.disabled || elForm.disabled\n return isGroup.value\n ? checkboxGroup.disabled?.value || disabled || isLimitDisabled.value\n : props.disabled || elForm.disabled\n })\n\n return {\n isDisabled,\n isLimitDisabled,\n }\n}\n\nconst setStoreValue = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n function addToStore() {\n if (Array.isArray(model.value) && !model.value.includes(props.label)) {\n model.value.push(props.label)\n } else {\n model.value = props.trueLabel || true\n }\n }\n props.checked && addToStore()\n}\n\nconst useEvent = (\n props: IUseCheckboxProps,\n { isLimitExceeded }: PartialReturnType<typeof useModel>\n) => {\n const { elFormItem } = useCheckboxGroup()\n const { emit } = getCurrentInstance()\n function handleChange(e: InputEvent) {\n if (isLimitExceeded.value) return\n const target = e.target as HTMLInputElement\n const value = target.checked\n ? props.trueLabel ?? true\n : props.falseLabel ?? false\n\n emit('change', value, e)\n }\n\n watch(\n () => props.modelValue,\n () => {\n elFormItem.validate?.('change')\n }\n )\n\n return {\n handleChange,\n }\n}\n\nexport const useCheckbox = (props: IUseCheckboxProps) => {\n const { model, isLimitExceeded } = useModel(props)\n const { focus, size, isChecked, checkboxSize } = useCheckboxStatus(props, {\n model,\n })\n const { isDisabled } = useDisabled(props, { model, isChecked })\n const { handleChange } = useEvent(props, { isLimitExceeded })\n\n setStoreValue(props, { model })\n\n return {\n isChecked,\n isDisabled,\n checkboxSize,\n model,\n handleChange,\n focus,\n size,\n }\n}\n"],"names":["inject","elFormKey","elFormItemKey","computed","ref","getCurrentInstance","UPDATE_MODEL_EVENT","useSize","toTypeString","watch"],"mappings":";;;;;;;;;;;;AAKY,MAAC,gBAAgB,GAAG;AAChC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,MAAM,KAAK,CAA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AAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAClC,EAAE,OAAO;AACT,IAAI,SAAS;AACb,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,IAAI;AACR,GAAG,CAAC;AACJ;;;;;;"}
|
|
1
|
+
{"version":3,"file":"useCheckbox.js","sources":["../../../../../../packages/components/checkbox/src/useCheckbox.ts"],"sourcesContent":["import { ref, computed, inject, getCurrentInstance, watch } from 'vue'\nimport { toTypeString } from '@vue/shared'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants'\nimport { elFormKey, elFormItemKey } from '@element-plus/tokens'\n\nimport { useSize } from '@element-plus/hooks'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ElFormContext, ElFormItemContext } from '@element-plus/tokens'\nimport type { PartialReturnType } from '@element-plus/utils/types'\nimport type { ICheckboxGroupInstance } from './checkbox.type'\n\nexport const useCheckboxProps = {\n modelValue: {\n type: [Boolean, Number, String],\n default: () => undefined,\n },\n label: {\n type: [String, Boolean, Number, Object],\n },\n indeterminate: Boolean,\n disabled: Boolean,\n checked: Boolean,\n name: {\n type: String,\n default: undefined,\n },\n trueLabel: {\n type: [String, Number],\n default: undefined,\n },\n falseLabel: {\n type: [String, Number],\n default: undefined,\n },\n tabindex: [String, Number],\n size: String,\n}\n\nexport type IUseCheckboxProps = ExtractPropTypes<typeof useCheckboxProps>\n\nexport const useCheckboxGroup = () => {\n const elForm = inject(elFormKey, {} as ElFormContext)\n const elFormItem = inject(elFormItemKey, {} as ElFormItemContext)\n const checkboxGroup = inject<ICheckboxGroupInstance>('CheckboxGroup', {})\n const isGroup = computed(\n () => checkboxGroup && checkboxGroup?.name === 'ElCheckboxGroup'\n )\n const elFormItemSize = computed(() => {\n return elFormItem.size\n })\n return {\n isGroup,\n checkboxGroup,\n elForm,\n elFormItemSize,\n elFormItem,\n }\n}\n\nconst useModel = (props: IUseCheckboxProps) => {\n const selfModel = ref(false)\n const { emit } = getCurrentInstance()\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitExceeded = ref(false)\n const model = computed({\n get() {\n return isGroup.value\n ? checkboxGroup.modelValue?.value\n : props.modelValue ?? selfModel.value\n },\n\n set(val: unknown) {\n if (isGroup.value && Array.isArray(val)) {\n isLimitExceeded.value =\n checkboxGroup.max !== undefined &&\n val.length > checkboxGroup.max.value\n isLimitExceeded.value === false && checkboxGroup?.changeEvent?.(val)\n } else {\n emit(UPDATE_MODEL_EVENT, val)\n selfModel.value = val as boolean\n }\n },\n })\n\n return {\n model,\n isLimitExceeded,\n }\n}\n\nconst useCheckboxStatus = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n const { isGroup, checkboxGroup } = useCheckboxGroup()\n const focus = ref(false)\n const size = useSize(checkboxGroup?.checkboxGroupSize, { prop: true })\n const isChecked = computed<boolean>(() => {\n const value = model.value\n if (toTypeString(value) === '[object Boolean]') {\n return value\n } else if (Array.isArray(value)) {\n return value.includes(props.label)\n } else if (value !== null && value !== undefined) {\n return value === props.trueLabel\n } else {\n return !!value\n }\n })\n\n const checkboxSize = useSize(\n computed(() =>\n isGroup.value ? checkboxGroup?.checkboxGroupSize?.value : undefined\n )\n )\n\n return {\n isChecked,\n focus,\n size,\n checkboxSize,\n }\n}\n\nconst useDisabled = (\n props: IUseCheckboxProps,\n {\n model,\n isChecked,\n }: PartialReturnType<typeof useModel> &\n PartialReturnType<typeof useCheckboxStatus>\n) => {\n const { elForm, isGroup, checkboxGroup } = useCheckboxGroup()\n const isLimitDisabled = computed(() => {\n const max = checkboxGroup.max?.value\n const min = checkboxGroup.min?.value\n return (\n (!!(max || min) && model.value.length >= max && !isChecked.value) ||\n (model.value.length <= min && isChecked.value)\n )\n })\n const isDisabled = computed(() => {\n const disabled = props.disabled || elForm.disabled\n return (\n (isGroup.value\n ? checkboxGroup.disabled?.value || disabled || isLimitDisabled.value\n : props.disabled || elForm.disabled) ?? false\n )\n })\n\n return {\n isDisabled,\n isLimitDisabled,\n }\n}\n\nconst setStoreValue = (\n props: IUseCheckboxProps,\n { model }: PartialReturnType<typeof useModel>\n) => {\n function addToStore() {\n if (Array.isArray(model.value) && !model.value.includes(props.label)) {\n model.value.push(props.label)\n } else {\n model.value = props.trueLabel || true\n }\n }\n props.checked && addToStore()\n}\n\nconst useEvent = (\n props: IUseCheckboxProps,\n { isLimitExceeded }: PartialReturnType<typeof useModel>\n) => {\n const { elFormItem } = useCheckboxGroup()\n const { emit } = getCurrentInstance()\n function handleChange(e: InputEvent) {\n if (isLimitExceeded.value) return\n const target = e.target as HTMLInputElement\n const value = target.checked\n ? props.trueLabel ?? true\n : props.falseLabel ?? false\n\n emit('change', value, e)\n }\n\n watch(\n () => props.modelValue,\n () => {\n elFormItem.validate?.('change')\n }\n )\n\n return {\n handleChange,\n }\n}\n\nexport const useCheckbox = (props: IUseCheckboxProps) => {\n const { model, isLimitExceeded } = useModel(props)\n const { focus, size, isChecked, checkboxSize } = useCheckboxStatus(props, {\n model,\n })\n const { isDisabled } = useDisabled(props, { model, isChecked })\n const { handleChange } = useEvent(props, { isLimitExceeded })\n\n setStoreValue(props, { model })\n\n return {\n isChecked,\n isDisabled,\n checkboxSize,\n model,\n handleChange,\n focus,\n size,\n }\n}\n"],"names":["inject","elFormKey","elFormItemKey","computed","ref","getCurrentInstance","UPDATE_MODEL_EVENT","useSize","toTypeString","watch"],"mappings":";;;;;;;;;;;;AAKY,MAAC,gBAAgB,GAAG;AAChC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC;AACzB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AAC3C,GAAG;AACH,EAAE,aAAa,EAAE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AACb,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,IAAI;AACR,GAAG,CAAC;AACJ;;;;;;"}
|
|
@@ -17,10 +17,11 @@ var icon = require('../../../utils/icon.js');
|
|
|
17
17
|
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
|
|
18
18
|
var index = require('../../../directives/trap-focus/index.js');
|
|
19
19
|
var index$5 = require('../../../hooks/use-locale/index.js');
|
|
20
|
-
var index$6 = require('../../../hooks/use-
|
|
21
|
-
var index$7 = require('../../../hooks/use-
|
|
22
|
-
var index$8 = require('../../../hooks/use-
|
|
23
|
-
var index$9 = require('../../../hooks/use-
|
|
20
|
+
var index$6 = require('../../../hooks/use-common-props/index.js');
|
|
21
|
+
var index$7 = require('../../../hooks/use-modal/index.js');
|
|
22
|
+
var index$8 = require('../../../hooks/use-prevent-global/index.js');
|
|
23
|
+
var index$9 = require('../../../hooks/use-lockscreen/index.js');
|
|
24
|
+
var index$a = require('../../../hooks/use-restore-active/index.js');
|
|
24
25
|
|
|
25
26
|
const _sfc_main = vue.defineComponent({
|
|
26
27
|
name: "ElMessageBox",
|
|
@@ -120,6 +121,7 @@ const _sfc_main = vue.defineComponent({
|
|
|
120
121
|
const type = state.type;
|
|
121
122
|
return type && icon.TypeComponentsMap[type] ? `el-message-box-icon--${type}` : "";
|
|
122
123
|
});
|
|
124
|
+
const btnSize = index$6.useSize(vue.computed(() => props.buttonSize), { prop: true, form: true, formItem: true });
|
|
123
125
|
const iconComponent = vue.computed(() => state.icon || icon.TypeComponentsMap[state.type] || "");
|
|
124
126
|
const hasMessage = vue.computed(() => !!state.message);
|
|
125
127
|
const inputRef = vue.ref(null);
|
|
@@ -231,21 +233,22 @@ const _sfc_main = vue.defineComponent({
|
|
|
231
233
|
handleAction("close");
|
|
232
234
|
};
|
|
233
235
|
if (props.closeOnPressEscape) {
|
|
234
|
-
index$
|
|
236
|
+
index$7.useModal({
|
|
235
237
|
handleClose
|
|
236
238
|
}, visible);
|
|
237
239
|
} else {
|
|
238
|
-
index$
|
|
240
|
+
index$8.usePreventGlobal(visible, "keydown", (e) => e.code === aria.EVENT_CODE.esc);
|
|
239
241
|
}
|
|
240
242
|
if (props.lockScroll) {
|
|
241
|
-
index$
|
|
243
|
+
index$9.useLockscreen(visible);
|
|
242
244
|
}
|
|
243
|
-
index$
|
|
245
|
+
index$a.useRestoreActive(visible);
|
|
244
246
|
return {
|
|
245
247
|
...vue.toRefs(state),
|
|
246
248
|
visible,
|
|
247
249
|
hasMessage,
|
|
248
250
|
typeClass,
|
|
251
|
+
btnSize,
|
|
249
252
|
iconComponent,
|
|
250
253
|
confirmButtonClasses,
|
|
251
254
|
inputRef,
|
|
@@ -381,7 +384,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
381
384
|
loading: _ctx.cancelButtonLoading,
|
|
382
385
|
class: vue.normalizeClass([_ctx.cancelButtonClass]),
|
|
383
386
|
round: _ctx.roundButton,
|
|
384
|
-
size: _ctx.
|
|
387
|
+
size: _ctx.btnSize,
|
|
385
388
|
onClick: _cache[3] || (_cache[3] = ($event) => _ctx.handleAction("cancel")),
|
|
386
389
|
onKeydown: _cache[4] || (_cache[4] = vue.withKeys(vue.withModifiers(($event) => _ctx.handleAction("cancel"), ["prevent"]), ["enter"]))
|
|
387
390
|
}, {
|
|
@@ -397,7 +400,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
397
400
|
class: vue.normalizeClass([_ctx.confirmButtonClasses]),
|
|
398
401
|
round: _ctx.roundButton,
|
|
399
402
|
disabled: _ctx.confirmButtonDisabled,
|
|
400
|
-
size: _ctx.
|
|
403
|
+
size: _ctx.btnSize,
|
|
401
404
|
onClick: _cache[5] || (_cache[5] = ($event) => _ctx.handleAction("confirm")),
|
|
402
405
|
onKeydown: _cache[6] || (_cache[6] = vue.withKeys(vue.withModifiers(($event) => _ctx.handleAction("confirm"), ["prevent"]), ["enter"]))
|
|
403
406
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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":["defineComponent","TrapFocus","ElButton","ElInput","ElOverlay","ElIcon","TypeComponents","isValidComponentSize","useLocale","ref","reactive","PopupManager","computed","TypeComponentsMap","nextTick","_withCtx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2JA,MAAK,YAAaA,oBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,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BACL;AAAO;;;;;;;AATiB;;;;;;;;;AAhGhB;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","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=\"btnSize\"\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=\"btnSize\"\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 useSize,\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 btnSize = useSize(\n computed(() => props.buttonSize),\n { prop: true, form: true, formItem: true }\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 btnSize,\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":["defineComponent","TrapFocus","ElButton","ElInput","ElOverlay","ElIcon","TypeComponents","isValidComponentSize","useLocale","ref","reactive","PopupManager","computed","TypeComponentsMap","useSize","nextTick","_withCtx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4JA,MA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AAAkB,gBAClB,OAAM;AAAA,gBACN;AAAK,gBACL;AAAO;;;;;;;AAiBE;AAXM,qBACZ;AAAA;AACH,gBACA;AAAK,gBACL;AAAkB,gBAClB;AAAU,gBACV;AAAM,gBACN,WAAK;AAAA,gBACL;AAAO;;;;;;;AATiB;;;;;;;;;AAhGhB;;;;;;;;;;;;"}
|
|
@@ -47,6 +47,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
47
47
|
visible: import("vue").Ref<boolean>;
|
|
48
48
|
hasMessage: import("vue").ComputedRef<boolean>;
|
|
49
49
|
typeClass: import("vue").ComputedRef<string>;
|
|
50
|
+
btnSize: import("vue").ComputedRef<ComponentSize>;
|
|
50
51
|
iconComponent: import("vue").ComputedRef<any>;
|
|
51
52
|
confirmButtonClasses: import("vue").ComputedRef<string>;
|
|
52
53
|
inputRef: import("vue").Ref<ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>>;
|
|
@@ -2,7 +2,6 @@ import type { SFCWithInstall } from 'element-plus/es/utils/types';
|
|
|
2
2
|
declare const _PopoverDirective: SFCWithInstall<import("vue").ObjectDirective<any, any>>;
|
|
3
3
|
declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
|
|
4
4
|
title: StringConstructor;
|
|
5
|
-
hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
6
5
|
width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
7
6
|
content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
8
7
|
popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -842,7 +841,6 @@ declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
842
841
|
hide: () => void;
|
|
843
842
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
844
843
|
title: StringConstructor;
|
|
845
|
-
hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
846
844
|
width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
847
845
|
content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
848
846
|
popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -942,14 +940,12 @@ declare const _Popover: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
942
940
|
} | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
943
941
|
popperStyle: import("vue").StyleValue;
|
|
944
942
|
content: string;
|
|
945
|
-
hideAfter: number;
|
|
946
943
|
}>> & {
|
|
947
944
|
directive: typeof _PopoverDirective;
|
|
948
945
|
};
|
|
949
946
|
export default _Popover;
|
|
950
947
|
export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
|
|
951
948
|
title: StringConstructor;
|
|
952
|
-
hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
953
949
|
width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
954
950
|
content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
955
951
|
popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -1789,7 +1785,6 @@ export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
1789
1785
|
hide: () => void;
|
|
1790
1786
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
1791
1787
|
title: StringConstructor;
|
|
1792
|
-
hideAfter: import("../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
1793
1788
|
width: import("../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
1794
1789
|
content: import("../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
1795
1790
|
popperStyle: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -1889,7 +1884,6 @@ export declare const ElPopover: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
1889
1884
|
} | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
1890
1885
|
popperStyle: import("vue").StyleValue;
|
|
1891
1886
|
content: string;
|
|
1892
|
-
hideAfter: number;
|
|
1893
1887
|
}>> & {
|
|
1894
1888
|
directive: typeof _PopoverDirective;
|
|
1895
1889
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { StyleValue } from 'vue';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<{
|
|
3
3
|
title: StringConstructor;
|
|
4
|
-
hideAfter: import("../../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
5
4
|
width: import("../../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
6
5
|
content: import("../../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
7
6
|
popperStyle: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -841,7 +840,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
841
840
|
hide: () => void;
|
|
842
841
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
843
842
|
title: StringConstructor;
|
|
844
|
-
hideAfter: import("../../../utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
845
843
|
width: import("../../../utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
846
844
|
content: import("../../../utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
847
845
|
popperStyle: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -941,6 +939,5 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
941
939
|
} | any)[])[])[])[])[])[])[])[])[])[])[];
|
|
942
940
|
popperStyle: StyleValue;
|
|
943
941
|
content: string;
|
|
944
|
-
hideAfter: number;
|
|
945
942
|
}>;
|
|
946
943
|
export default _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const usePopoverProps: {
|
|
2
2
|
title: StringConstructor;
|
|
3
|
-
hideAfter: import("element-plus/es/utils/props").BuildPropReturn<NumberConstructor, number, unknown, unknown, unknown>;
|
|
4
3
|
width: import("element-plus/es/utils/props").BuildPropReturn<(StringConstructor | NumberConstructor)[], number, unknown, unknown, unknown>;
|
|
5
4
|
content: import("element-plus/es/utils/props").BuildPropReturn<StringConstructor, string | (() => string) | undefined, unknown, unknown, unknown>;
|
|
6
5
|
popperStyle: import("element-plus/es/utils/props").BuildPropReturn<import("element-plus/es/utils/props").PropWrapper<import("vue").StyleValue>, string | import("vue").CSSProperties | (() => string) | (() => import("vue").CSSProperties) | (() => import("vue").StyleValue[]) | undefined, unknown, unknown, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../../../../../packages/components/popover/src/popover.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils/props'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\n\nexport const usePopoverProps = {\n content: useTooltipContentProps.content,\n popperStyle: useTooltipContentProps.popperStyle,\n popperClass: useTooltipContentProps.popperClass,\n enterable: {\n ...useTooltipContentProps.enterable,\n default: true,\n },\n effect: {\n ...useTooltipContentProps.effect,\n default: 'light',\n },\n ...buildProps({\n title: String,\n\n
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../../../../packages/components/popover/src/popover.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils/props'\nimport { useTooltipContentProps } from '@element-plus/components/tooltip'\n\nexport const usePopoverProps = {\n content: useTooltipContentProps.content,\n popperStyle: useTooltipContentProps.popperStyle,\n popperClass: useTooltipContentProps.popperClass,\n enterable: {\n ...useTooltipContentProps.enterable,\n default: true,\n },\n effect: {\n ...useTooltipContentProps.effect,\n default: 'light',\n },\n ...buildProps({\n title: String,\n\n width: {\n type: [String, Number],\n default: 150,\n },\n }),\n}\n"],"names":["useTooltipContentProps","buildProps"],"mappings":";;;;;;;;AAEY,MAAC,eAAe,GAAG;AAC/B,EAAE,OAAO,EAAEA,8BAAsB,CAAC,OAAO;AACzC,EAAE,WAAW,EAAEA,8BAAsB,CAAC,WAAW;AACjD,EAAE,WAAW,EAAEA,8BAAsB,CAAC,WAAW;AACjD,EAAE,SAAS,EAAE;AACb,IAAI,GAAGA,8BAAsB,CAAC,SAAS;AACvC,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,GAAGA,8BAAsB,CAAC,MAAM;AACpC,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,EAAE,GAAGC,gBAAU,CAAC;AAChB,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,KAAK,EAAE;AACX,MAAM,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC5B,MAAM,OAAO,EAAE,GAAG;AAClB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
|