vue-devui 1.0.0-pre.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -187
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.es.js +67 -82
- package/auto-complete/index.umd.js +3 -1
- package/auto-complete/style.css +1 -1
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +39 -40
- package/button/index.umd.js +1 -1
- package/countdown/index.es.js +2 -1
- package/editable-select/index.es.js +122 -163
- package/editable-select/index.umd.js +1 -1
- package/fullscreen/index.es.js +13 -16
- package/fullscreen/index.umd.js +1 -1
- package/icon/index.es.js +39 -57
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +2 -1
- package/modal/index.es.js +81 -76
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +38 -40
- package/notification/index.umd.js +1 -1
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/overlay/index.es.js +44 -37
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -43
- package/pagination/index.es.js +10 -12
- package/pagination/index.umd.js +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +46 -39
- package/popover/index.umd.js +6 -6
- package/popover/style.css +1 -1
- package/progress/index.es.js +1 -1
- package/progress/index.umd.js +1 -1
- package/progress/style.css +1 -1
- package/radio/index.es.js +11 -11
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +6 -3
- package/result/index.es.js +38 -53
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +47 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +2 -5
- package/search/index.umd.js +4 -4
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +60 -59
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +215 -160
- package/splitter/index.umd.js +11 -11
- package/splitter/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/tag/index.es.js +15 -18
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +4 -2
- package/{accordion → timeline}/index.d.ts +0 -0
- package/{time-axis → timeline}/index.es.js +65 -78
- package/timeline/index.umd.js +1 -0
- package/{anchor → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/upload/index.es.js +38 -40
- package/upload/index.umd.js +1 -1
- package/vue-devui.es.js +1478 -1196
- package/vue-devui.umd.js +19 -17
- package/accordion/index.es.js +0 -720
- package/accordion/index.umd.js +0 -1
- package/accordion/package.json +0 -7
- package/accordion/style.css +0 -1
- package/anchor/index.d.ts +0 -7
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -128
- package/back-top/index.umd.js +0 -1
- package/back-top/package.json +0 -7
- package/back-top/style.css +0 -1
- package/breadcrumb/index.d.ts +0 -7
- package/breadcrumb/index.es.js +0 -127
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/package.json +0 -7
- package/breadcrumb/style.css +0 -1
- package/carousel/index.d.ts +0 -7
- package/carousel/index.es.js +0 -329
- package/carousel/index.umd.js +0 -1
- package/carousel/package.json +0 -7
- package/carousel/style.css +0 -1
- package/cascader/index.d.ts +0 -7
- package/cascader/index.es.js +0 -5963
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.d.ts +0 -7
- package/color-picker/index.es.js +0 -8187
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/date-picker/index.d.ts +0 -7
- package/date-picker/index.es.js +0 -1171
- package/date-picker/index.umd.js +0 -1
- package/date-picker/package.json +0 -7
- package/date-picker/style.css +0 -1
- package/dragdrop/index.d.ts +0 -7
- package/dragdrop/index.es.js +0 -157
- package/dragdrop/index.umd.js +0 -1
- package/dragdrop/package.json +0 -7
- package/drawer/index.d.ts +0 -7
- package/drawer/index.es.js +0 -234
- package/drawer/index.umd.js +0 -1
- package/drawer/package.json +0 -7
- package/drawer/style.css +0 -1
- package/dropdown/index.d.ts +0 -7
- package/dropdown/index.es.js +0 -638
- package/dropdown/index.umd.js +0 -1
- package/dropdown/package.json +0 -7
- package/dropdown/style.css +0 -1
- package/form/index.d.ts +0 -7
- package/form/index.es.js +0 -7865
- package/form/index.umd.js +0 -27
- package/form/package.json +0 -7
- package/form/style.css +0 -1
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/package.json +0 -7
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -331
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/input-number/index.d.ts +0 -7
- package/input-number/index.es.js +0 -240
- package/input-number/index.umd.js +0 -1
- package/input-number/package.json +0 -7
- package/input-number/style.css +0 -1
- package/list/index.d.ts +0 -7
- package/list/index.es.js +0 -39
- package/list/index.umd.js +0 -1
- package/list/package.json +0 -7
- package/list/style.css +0 -1
- package/nav-sprite/index.d.ts +0 -7
- package/nav-sprite/index.es.js +0 -68
- package/nav-sprite/index.umd.js +0 -1
- package/nav-sprite/package.json +0 -7
- package/nuxt/components/Accordion.js +0 -3
- package/nuxt/components/Anchor.js +0 -3
- package/nuxt/components/BackTop.js +0 -3
- package/nuxt/components/Breadcrumb.js +0 -3
- package/nuxt/components/Carousel.js +0 -3
- package/nuxt/components/CarouselItem.js +0 -3
- package/nuxt/components/Cascader.js +0 -3
- package/nuxt/components/ColorPicker.js +0 -3
- package/nuxt/components/Column.js +0 -3
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/Drawer.js +0 -3
- package/nuxt/components/DrawerService.js +0 -3
- package/nuxt/components/Dropdown.js +0 -3
- package/nuxt/components/DropdownMenu.js +0 -3
- package/nuxt/components/Form.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormItem.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/FormOperation.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/InputNumber.js +0 -3
- package/nuxt/components/List.js +0 -3
- package/nuxt/components/ListItem.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/Select.js +0 -3
- package/nuxt/components/StepsGuide.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/Sticky.js +0 -2
- package/nuxt/components/Table.js +0 -3
- package/nuxt/components/Tabs.js +0 -3
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/TimePicker.js +0 -3
- package/nuxt/components/Tooltip.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/Tree.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/nuxt/components/dropdownMenuProps.js +0 -3
- package/nuxt/components/tooltipProps.js +0 -3
- package/quadrant-diagram/index.d.ts +0 -7
- package/quadrant-diagram/index.es.js +0 -5728
- package/quadrant-diagram/index.umd.js +0 -27
- package/quadrant-diagram/package.json +0 -7
- package/quadrant-diagram/style.css +0 -1
- package/select/index.d.ts +0 -7
- package/select/index.es.js +0 -706
- package/select/index.umd.js +0 -1
- package/select/package.json +0 -7
- package/select/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -239
- package/steps-guide/index.umd.js +0 -1
- package/steps-guide/package.json +0 -7
- package/steps-guide/style.css +0 -1
- package/sticky/index.d.ts +0 -7
- package/sticky/index.es.js +0 -197
- package/sticky/index.umd.js +0 -1
- package/sticky/package.json +0 -7
- package/table/index.d.ts +0 -7
- package/table/index.es.js +0 -1969
- package/table/index.umd.js +0 -1
- package/table/package.json +0 -7
- package/table/style.css +0 -1
- package/tabs/index.d.ts +0 -7
- package/tabs/index.es.js +0 -194
- package/tabs/index.umd.js +0 -1
- package/tabs/package.json +0 -7
- package/tabs/style.css +0 -1
- package/time-axis/index.d.ts +0 -7
- package/time-axis/index.umd.js +0 -1
- package/time-axis/package.json +0 -7
- package/time-axis/style.css +0 -1
- package/time-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1237
- package/time-picker/index.umd.js +0 -1
- package/time-picker/package.json +0 -7
- package/time-picker/style.css +0 -1
- package/tooltip/index.d.ts +0 -7
- package/tooltip/index.es.js +0 -5828
- package/tooltip/index.umd.js +0 -27
- package/tooltip/package.json +0 -7
- package/tooltip/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.es.js +0 -7608
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree/index.d.ts +0 -7
- package/tree/index.es.js +0 -6490
- package/tree/index.umd.js +0 -27
- package/tree/package.json +0 -7
- package/tree/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -623
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
package/tag/index.es.js
CHANGED
|
@@ -24,17 +24,17 @@ const tagProps = {
|
|
|
24
24
|
function useClass(props) {
|
|
25
25
|
return computed(() => {
|
|
26
26
|
const { type, color, deletable } = props;
|
|
27
|
-
return `devui-tag devui-tag-${type || (color ? "colorful" : "") || "default"}
|
|
27
|
+
return `devui-tag-item devui-tag-${type || (color ? "colorful" : "") || "default"}${deletable ? " devui-tag-deletable" : ""}`;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
function useColor(props) {
|
|
31
31
|
return computed(() => {
|
|
32
32
|
const { color, type } = props;
|
|
33
33
|
const typeMap = {
|
|
34
|
-
primary: "#5e7ce0",
|
|
35
|
-
success: "#50d4ab",
|
|
36
|
-
warning: "#fac20a",
|
|
37
|
-
danger: "#f66f6a"
|
|
34
|
+
primary: "var(--devui-primary, #5e7ce0)",
|
|
35
|
+
success: "var(--devui-success, #50d4ab)",
|
|
36
|
+
warning: "var(--devui-warning, #fac20a)",
|
|
37
|
+
danger: "var(--devui-danger, #f66f6a)"
|
|
38
38
|
};
|
|
39
39
|
const colorMap = {
|
|
40
40
|
"blue-w98": "#3383ff",
|
|
@@ -47,8 +47,9 @@ function useColor(props) {
|
|
|
47
47
|
"pink-w98": "#f3689a",
|
|
48
48
|
"purple-w98": "#a97af8"
|
|
49
49
|
};
|
|
50
|
-
if (!color && type)
|
|
50
|
+
if (!color && type) {
|
|
51
51
|
return typeMap[type];
|
|
52
|
+
}
|
|
52
53
|
const themeColor = colorMap[color] || color;
|
|
53
54
|
return themeColor;
|
|
54
55
|
});
|
|
@@ -74,12 +75,12 @@ var Tag = defineComponent({
|
|
|
74
75
|
const tagTitle = titleContent.value || "";
|
|
75
76
|
const isDefaultTag = () => !type.value && !color.value;
|
|
76
77
|
const isShow = ref(true);
|
|
77
|
-
const handleClick = () => {
|
|
78
|
-
emit("click");
|
|
78
|
+
const handleClick = (e) => {
|
|
79
|
+
emit("click", e);
|
|
79
80
|
};
|
|
80
|
-
const handleDelete = () => {
|
|
81
|
+
const handleDelete = (e) => {
|
|
81
82
|
isShow.value = false;
|
|
82
|
-
emit("tagDelete");
|
|
83
|
+
emit("tagDelete", e);
|
|
83
84
|
};
|
|
84
85
|
const closeIconEl = () => {
|
|
85
86
|
return deletable.value ? createVNode("a", {
|
|
@@ -96,7 +97,6 @@ var Tag = defineComponent({
|
|
|
96
97
|
}, null)]) : null;
|
|
97
98
|
};
|
|
98
99
|
const unWatch = watch(checked, (newVal) => {
|
|
99
|
-
console.log("checkedChange");
|
|
100
100
|
emit("checkedChange", newVal);
|
|
101
101
|
});
|
|
102
102
|
onUnmounted(() => unWatch());
|
|
@@ -110,22 +110,19 @@ var Tag = defineComponent({
|
|
|
110
110
|
"style": {
|
|
111
111
|
display: "block",
|
|
112
112
|
color: checked.value ? "#fff" : themeColor.value,
|
|
113
|
-
backgroundColor: checked.value ? themeColor.value : !color.value ? "" : "#
|
|
113
|
+
backgroundColor: checked.value ? themeColor.value : !color.value ? "" : "var(--devui-base-bg, #ffffff)"
|
|
114
114
|
},
|
|
115
115
|
"title": tagTitle
|
|
116
116
|
}, [(_a = slots.default) == null ? void 0 : _a.call(slots), closeIconEl()])]), [[vShow, isShow.value]]);
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
-
Tag.install = function(app) {
|
|
121
|
-
app.component(Tag.name, Tag);
|
|
122
|
-
};
|
|
123
120
|
var index = {
|
|
124
121
|
title: "Tag \u6807\u7B7E",
|
|
125
122
|
category: "\u6570\u636E\u5C55\u793A",
|
|
126
|
-
status: "
|
|
123
|
+
status: "100%",
|
|
127
124
|
install(app) {
|
|
128
|
-
app.
|
|
125
|
+
app.component(Tag.name, Tag);
|
|
129
126
|
}
|
|
130
127
|
};
|
|
131
|
-
export { Tag, index as default };
|
|
128
|
+
export { Tag, index as default, tagProps };
|
package/tag/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.index={},t.Vue))})(this,function(t,e){"use strict";const f={type:{type:String,default:""},color:{type:String,default:""},titleContent:{type:String,default:""},checked:{type:Boolean,default:!1},deletable:{type:Boolean,default:!1}};function p(a){return e.computed(()=>{const{type:o,color:n,deletable:c}=a;return`devui-tag-item devui-tag-${o||(n?"colorful":"")||"default"}${c?" devui-tag-deletable":""}`})}function g(a){return e.computed(()=>{const{color:o,type:n}=a,c={primary:"var(--devui-primary, #5e7ce0)",success:"var(--devui-success, #50d4ab)",warning:"var(--devui-warning, #fac20a)",danger:"var(--devui-danger, #f66f6a)"},r={"blue-w98":"#3383ff","aqua-w98":"#39afcc","olivine-w98":"#2fa898","green-w98":"#4eb15e","yellow-w98":"#b08d1a","orange-w98":"#d47f35","red-w98":"#f66f6a","pink-w98":"#f3689a","purple-w98":"#a97af8"};return!o&&n?c[n]:r[o]||o})}var D="",d=e.defineComponent({name:"DTag",props:f,emits:["click","tagDelete","checkedChange"],setup(a,{slots:o,emit:n}){const{type:c,color:r,checked:u,titleContent:m,deletable:y}=e.toRefs(a),h=p(a),i=g(a),C=m.value||"",b=()=>!c.value&&!r.value,s=e.ref(!0),w=l=>{n("click",l)},k=l=>{s.value=!1,n("tagDelete",l)},T=()=>y.value?e.createVNode("a",{class:"remove-button",onClick:k},[b()?e.createVNode(e.resolveComponent("d-icon"),{size:"12px",name:"error-o",color:"#adb0b8"},null):e.createVNode(e.resolveComponent("d-icon"),{size:"12px",name:"close",color:i.value},null)]):null,S=e.watch(u,l=>{n("checkedChange",l)});return e.onUnmounted(()=>S()),()=>{var l;return s.value&&e.withDirectives(e.createVNode("div",{class:"devui-tag",onClick:w},[e.createVNode("span",{class:h.value,style:{display:"block",color:u.value?"#fff":i.value,backgroundColor:u.value?i.value:r.value?"var(--devui-base-bg, #ffffff)":""},title:C},[(l=o.default)==null?void 0:l.call(o),T()])]),[[e.vShow,s.value]])}}}),v={title:"Tag \u6807\u7B7E",category:"\u6570\u636E\u5C55\u793A",status:"100%",install(a){a.component(d.name,d)}};t.Tag=d,t.default=v,t.tagProps=f,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"});
|
package/tag/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";.devui-tag{display:inline-block;margin:4px}.devui-tag .devui-tag{padding:0 8px;min-height:20px;
|
|
1
|
+
@charset "UTF-8";.devui-tag{display:inline-block;margin:4px}.devui-tag .devui-tag-item{display:block;position:relative;padding:0 8px;min-height:20px;border:1px solid;border-radius:var(--devui-border-radius, 2px);font-size:var(--devui-font-size, 12px);line-height:20px;cursor:default}.devui-tag .devui-tag-item.devui-tag-default{border:0;color:var(--devui-text, #252b3a);background-color:var(--devui-default-bg, #f3f6f8)}.devui-tag .devui-tag-item.devui-tag-primary{color:var(--devui-primary, #5e7ce0);background-color:var(--devui-primary-bg, #f2f5fc)}.devui-tag .devui-tag-item.devui-tag-success{color:var(--devui-success, #50d4ab);background-color:var(--devui-success-bg, #edfff9)}.devui-tag .devui-tag-item.devui-tag-warning{color:var(--devui-warning, #fac20a);background-color:var(--devui-warning-bg, #fff3e8)}.devui-tag .devui-tag-item.devui-tag-danger{color:var(--devui-danger, #f66f6a);background-color:var(--devui-danger-bg, #ffeeed)}.devui-tag .devui-tag-item.devui-tag-colorful{background-color:#fff}.devui-tag .devui-tag-item.devui-tag-deletable{padding-right:32px}.devui-tag .remove-button{display:inline-block;margin-left:12px;font-size:var(--devui-font-size-icon, 16px);cursor:pointer;width:12px;height:12px;line-height:12px;border-radius:50%;text-align:center;position:absolute;top:50%;transform:translateY(-50%)}.devui-tag .remove-button i{vertical-align:0}
|
package/tag-input/index.es.js
CHANGED
|
@@ -152,8 +152,9 @@ var TagInput = defineComponent({
|
|
|
152
152
|
let res = {
|
|
153
153
|
[props.displayProperty]: tagInputVal.value
|
|
154
154
|
};
|
|
155
|
-
if (tagInputVal.value === "" && mergedSuggestions.value.length === 0)
|
|
155
|
+
if (tagInputVal.value === "" && mergedSuggestions.value.length === 0) {
|
|
156
156
|
return false;
|
|
157
|
+
}
|
|
157
158
|
if (props.tags.findIndex((item) => item[props.displayProperty] === tagInputVal.value) > -1) {
|
|
158
159
|
tagInputVal.value = "";
|
|
159
160
|
return false;
|
|
@@ -177,8 +178,9 @@ var TagInput = defineComponent({
|
|
|
177
178
|
case KEYS_MAP.tab:
|
|
178
179
|
case KEYS_MAP.enter:
|
|
179
180
|
case KEYS_MAP.space:
|
|
180
|
-
if (!props.isAddBySpace && KEYS_MAP.space)
|
|
181
|
+
if (!props.isAddBySpace && KEYS_MAP.space) {
|
|
181
182
|
return;
|
|
183
|
+
}
|
|
182
184
|
handleEnter();
|
|
183
185
|
break;
|
|
184
186
|
case KEYS_MAP.down:
|
|
File without changes
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import { defineComponent, createVNode, inject, createTextVNode, provide, ref, reactive, onMounted, watch, toRef, nextTick, Fragment } from "vue";
|
|
1
|
+
import { defineComponent, toRefs, createVNode, inject, createTextVNode, provide, ref, reactive, onMounted, watch, toRef, nextTick, Fragment } from "vue";
|
|
18
2
|
const timeAxisProps = {
|
|
19
3
|
direction: {
|
|
20
4
|
type: String,
|
|
@@ -33,50 +17,51 @@ const timeAxisProps = {
|
|
|
33
17
|
default: "left"
|
|
34
18
|
}
|
|
35
19
|
};
|
|
20
|
+
const iconProps = {
|
|
21
|
+
name: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "",
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "inherit"
|
|
29
|
+
},
|
|
30
|
+
color: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "inherit"
|
|
33
|
+
},
|
|
34
|
+
classPrefix: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "icon"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
36
39
|
var DIcon = defineComponent({
|
|
37
40
|
name: "DIcon",
|
|
38
|
-
props:
|
|
39
|
-
name: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: true
|
|
42
|
-
},
|
|
43
|
-
size: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: "inherit"
|
|
46
|
-
},
|
|
47
|
-
color: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: "inherit"
|
|
50
|
-
},
|
|
51
|
-
classPrefix: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: "icon"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
41
|
+
props: iconProps,
|
|
56
42
|
setup(props) {
|
|
57
|
-
return __spreadValues({}, props);
|
|
58
|
-
},
|
|
59
|
-
render() {
|
|
60
43
|
const {
|
|
61
44
|
name,
|
|
62
45
|
size,
|
|
63
46
|
color,
|
|
64
47
|
classPrefix
|
|
65
|
-
} =
|
|
66
|
-
return
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
48
|
+
} = toRefs(props);
|
|
49
|
+
return () => {
|
|
50
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
51
|
+
"src": name.value,
|
|
52
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
53
|
+
"style": {
|
|
54
|
+
width: size.value,
|
|
55
|
+
verticalAlign: "text-bottom"
|
|
56
|
+
}
|
|
57
|
+
}, null) : createVNode("i", {
|
|
58
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
59
|
+
"style": {
|
|
60
|
+
fontSize: size.value,
|
|
61
|
+
color: color.value
|
|
62
|
+
}
|
|
63
|
+
}, null);
|
|
64
|
+
};
|
|
80
65
|
}
|
|
81
66
|
});
|
|
82
67
|
const timeAxisItemProps = {
|
|
@@ -105,16 +90,16 @@ const timeAxisItemProps = {
|
|
|
105
90
|
default: "primary"
|
|
106
91
|
}
|
|
107
92
|
};
|
|
108
|
-
var
|
|
109
|
-
name: "
|
|
93
|
+
var TimelineItem = defineComponent({
|
|
94
|
+
name: "DTimelineItem",
|
|
110
95
|
components: {
|
|
111
96
|
DIcon
|
|
112
97
|
},
|
|
113
98
|
props: timeAxisItemProps,
|
|
114
99
|
emits: [],
|
|
115
100
|
setup(props, ctx) {
|
|
116
|
-
const
|
|
117
|
-
const itemClass = "devui-
|
|
101
|
+
const timeAxis = inject("timeAxis");
|
|
102
|
+
const itemClass = "devui-timeline-item";
|
|
118
103
|
const renderTime = () => {
|
|
119
104
|
var _a, _b;
|
|
120
105
|
return createVNode("div", {
|
|
@@ -131,7 +116,7 @@ var TimeAxisItem = defineComponent({
|
|
|
131
116
|
if (types.includes(props.position)) {
|
|
132
117
|
return renderContent();
|
|
133
118
|
} else {
|
|
134
|
-
if (
|
|
119
|
+
if (timeAxis.props.direction === "horizontal") {
|
|
135
120
|
return renderTime();
|
|
136
121
|
} else {
|
|
137
122
|
return props.timePosition === "left" ? renderTime() : "";
|
|
@@ -171,7 +156,7 @@ var TimeAxisItem = defineComponent({
|
|
|
171
156
|
"class": `${itemClass}-data-left ${itemClass}-data-top`
|
|
172
157
|
}, [renderPosition(["top", "left"])]), createVNode("div", {
|
|
173
158
|
"class": `${itemClass}-axis`
|
|
174
|
-
}, [renderDot(),
|
|
159
|
+
}, [renderDot(), timeAxis.props.direction === "vertical" && props.timePosition === "bottom" ? renderTime() : "", createVNode("div", {
|
|
175
160
|
"class": `${itemClass}-line ${itemClass}-line-style-${props.lineStyle}`,
|
|
176
161
|
"style": {
|
|
177
162
|
borderColor: props.lineColor
|
|
@@ -184,11 +169,11 @@ var TimeAxisItem = defineComponent({
|
|
|
184
169
|
};
|
|
185
170
|
}
|
|
186
171
|
});
|
|
187
|
-
var
|
|
188
|
-
var
|
|
189
|
-
name: "
|
|
172
|
+
var timeline = "";
|
|
173
|
+
var Timeline = defineComponent({
|
|
174
|
+
name: "DTimeline",
|
|
190
175
|
components: {
|
|
191
|
-
|
|
176
|
+
TimelineItem
|
|
192
177
|
},
|
|
193
178
|
props: timeAxisProps,
|
|
194
179
|
emits: [],
|
|
@@ -197,7 +182,7 @@ var TimeAxis = defineComponent({
|
|
|
197
182
|
ctx,
|
|
198
183
|
props
|
|
199
184
|
});
|
|
200
|
-
const
|
|
185
|
+
const timeAxis = ref();
|
|
201
186
|
const style = reactive({
|
|
202
187
|
marginLeft: "0px",
|
|
203
188
|
height: "auto"
|
|
@@ -208,11 +193,11 @@ var TimeAxis = defineComponent({
|
|
|
208
193
|
if (props.direction === "horizontal") {
|
|
209
194
|
nextTick(() => {
|
|
210
195
|
var _a;
|
|
211
|
-
const el =
|
|
196
|
+
const el = timeAxis.value;
|
|
212
197
|
if (props.center) {
|
|
213
198
|
style.marginLeft = (((_a = el == null ? void 0 : el.firstElementChild) == null ? void 0 : _a.clientWidth) || 0) / 2 + "px";
|
|
214
199
|
}
|
|
215
|
-
style.height = Math.max(...Array.from(el == null ? void 0 : el.querySelectorAll(".devui-
|
|
200
|
+
style.height = Math.max(...Array.from(el == null ? void 0 : el.querySelectorAll(".devui-timeline-item-data-top")).map((el2) => el2.clientHeight), ...Array.from(el == null ? void 0 : el.querySelectorAll(".devui-timeline-item-data-bottom")).map((el2) => el2.clientHeight)) * 2 + Math.max(...Array.from(el == null ? void 0 : el.querySelectorAll(".devui-timeline-item-axis")).map((el2) => el2.clientHeight)) + "px";
|
|
216
201
|
});
|
|
217
202
|
}
|
|
218
203
|
};
|
|
@@ -252,16 +237,18 @@ var TimeAxis = defineComponent({
|
|
|
252
237
|
}, null);
|
|
253
238
|
}
|
|
254
239
|
if (props.direction === "horizontal") {
|
|
255
|
-
if (((_e = item.props) == null ? void 0 : _e.position) === "top" || ((_f = item.props) == null ? void 0 : _f.position) === "bottom")
|
|
240
|
+
if (((_e = item.props) == null ? void 0 : _e.position) === "top" || ((_f = item.props) == null ? void 0 : _f.position) === "bottom") {
|
|
256
241
|
return item;
|
|
242
|
+
}
|
|
257
243
|
if (props.mode === "alternative") {
|
|
258
244
|
return renderItemPosition(item, index2 % 2 == 0 ? "bottom" : "top");
|
|
259
245
|
} else {
|
|
260
246
|
return renderItemPosition(item, "bottom");
|
|
261
247
|
}
|
|
262
248
|
} else {
|
|
263
|
-
if (((_g = item.props) == null ? void 0 : _g.position) === "left" || ((_h = item.props) == null ? void 0 : _h.position) === "right")
|
|
249
|
+
if (((_g = item.props) == null ? void 0 : _g.position) === "left" || ((_h = item.props) == null ? void 0 : _h.position) === "right") {
|
|
264
250
|
return item;
|
|
251
|
+
}
|
|
265
252
|
if (props.mode === "alternative") {
|
|
266
253
|
return renderItemPosition(item, index2 % 2 == 0 ? "left" : "right");
|
|
267
254
|
} else {
|
|
@@ -274,26 +261,26 @@ var TimeAxis = defineComponent({
|
|
|
274
261
|
return props.direction === "horizontal" ? "horizontal" : "vertical";
|
|
275
262
|
};
|
|
276
263
|
return createVNode("div", {
|
|
277
|
-
"class": `devui-
|
|
278
|
-
"ref":
|
|
264
|
+
"class": `devui-timeline devui-timeline-${getDirection()} ${props.center ? "devui-timeline-" + getDirection() + "-center" : ""} `,
|
|
265
|
+
"ref": timeAxis,
|
|
279
266
|
"style": style
|
|
280
267
|
}, [renderItem()]);
|
|
281
268
|
};
|
|
282
269
|
}
|
|
283
270
|
});
|
|
284
|
-
|
|
285
|
-
app.component(
|
|
271
|
+
Timeline.install = function(app) {
|
|
272
|
+
app.component(Timeline.name, Timeline);
|
|
286
273
|
};
|
|
287
|
-
|
|
288
|
-
app.component(
|
|
274
|
+
TimelineItem.install = function(app) {
|
|
275
|
+
app.component(TimelineItem.name, TimelineItem);
|
|
289
276
|
};
|
|
290
277
|
var index = {
|
|
291
|
-
title: "
|
|
278
|
+
title: "Timeline \u65F6\u95F4\u8F74",
|
|
292
279
|
category: "\u6570\u636E\u5C55\u793A",
|
|
293
280
|
status: "100%",
|
|
294
281
|
install(app) {
|
|
295
|
-
app.use(
|
|
296
|
-
app.use(
|
|
282
|
+
app.use(Timeline);
|
|
283
|
+
app.use(TimelineItem);
|
|
297
284
|
}
|
|
298
285
|
};
|
|
299
|
-
export {
|
|
286
|
+
export { Timeline, TimelineItem, index as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a.index={},a.Vue))})(this,function(a,e){"use strict";const T={direction:{type:String,default:"vertical"},center:{type:Boolean,default:!1},mode:{type:String,default:"normal"},timePosition:{type:String,default:"left"}},b={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var I=e.defineComponent({name:"DIcon",props:b,setup(t){const{name:l,size:u,color:i,classPrefix:c}=e.toRefs(t);return()=>/^((https?):)?\/\//.test(l.value)?e.createVNode("img",{src:l.value,alt:l.value.split("/")[l.value.split("/").length-1],style:{width:u.value,verticalAlign:"text-bottom"}},null):e.createVNode("i",{class:`${c.value} ${c.value}-${l.value}`,style:{fontSize:u.value,color:i.value}},null)}});const z={time:{type:String},dotColor:{type:String},lineStyle:{type:String,default:"solid"},lineColor:{type:String},position:{type:String},timePosition:{type:String,default:"left"},type:{type:String,default:"primary"}};var p=e.defineComponent({name:"DTimelineItem",components:{DIcon:I},props:z,emits:[],setup(t,l){const u=e.inject("timeAxis"),i="devui-timeline-item",c=()=>{var n,s;return e.createVNode("div",{class:`${i}-time`},[l.slots.time?(s=(n=l.slots).time)==null?void 0:s.call(n):t.time])},o=()=>{var n,s;return e.createVNode("div",{class:`${i}-content`},[(s=(n=l.slots).default)==null?void 0:s.call(n,t)])},f=n=>n.includes(t.position)?o():u.props.direction==="horizontal"||t.timePosition==="left"?c():"",d=n=>n==="primary"?"":e.createVNode("i",{class:`icon-${n==="success"?"right":n}-o`},null),m=()=>{var n,s;return l.slots.dot?e.createVNode("div",{style:{color:t.dotColor},class:`${i}-dot`},[e.createTextVNode(" "),(s=(n=l.slots).dot)==null?void 0:s.call(n)]):e.createVNode("div",{class:`${i}-dot ${i}-type-${t.type}`,style:{borderColor:t.dotColor}},[d(t.type)])};return()=>e.createVNode("div",{class:i},[e.createVNode("div",{class:`${i}-data-left ${i}-data-top`},[f(["top","left"])]),e.createVNode("div",{class:`${i}-axis`},[m(),u.props.direction==="vertical"&&t.timePosition==="bottom"?c():"",e.createVNode("div",{class:`${i}-line ${i}-line-style-${t.lineStyle}`,style:{borderColor:t.lineColor}},[l.slots.extra?e.createVNode("div",{class:`${i}-line-extra`},[l.slots.extra()]):""])]),e.createVNode("div",{class:`${i}-data-right ${i}-data-bottom`},[f(["right","bottom"])])])}}),q="",y=e.defineComponent({name:"DTimeline",components:{TimelineItem:p},props:T,emits:[],setup(t,l){e.provide("timeAxis",{ctx:l,props:t});const u=e.ref(),i=e.reactive({marginLeft:"0px",height:"auto"}),c=()=>{i.height="auto",i.marginLeft="0px",t.direction==="horizontal"&&e.nextTick(()=>{var f;const o=u.value;t.center&&(i.marginLeft=(((f=o==null?void 0:o.firstElementChild)==null?void 0:f.clientWidth)||0)/2+"px"),i.height=Math.max(...Array.from(o==null?void 0:o.querySelectorAll(".devui-timeline-item-data-top")).map(d=>d.clientHeight),...Array.from(o==null?void 0:o.querySelectorAll(".devui-timeline-item-data-bottom")).map(d=>d.clientHeight))*2+Math.max(...Array.from(o==null?void 0:o.querySelectorAll(".devui-timeline-item-axis")).map(d=>d.clientHeight))+"px"})};return e.onMounted(()=>{c()}),e.watch(e.toRef(t,"direction"),()=>{c()}),()=>{const o=(m,n)=>n?e.createVNode(m,{position:n},null):e.createVNode(m,null,null),f=()=>{var s,h,S;const m=(S=(h=(s=l.slots).default)==null?void 0:h.call(s))!=null?S:[];let n;return m.length===1&&m[0].type===e.Fragment?n=m[0].children||[]:n=m,n.map((r,g)=>{var $,V,N,P,v,x,A,C;return g+1===n.length&&!(($=r.props)==null?void 0:$.lineStyle)&&!((V=r.props)==null?void 0:V["line-style"])&&(r=e.createVNode(r,{"line-style":"none"},null)),!((N=r.props)==null?void 0:N.timePosition)&&!((P=r.props)==null?void 0:P["time-position"])&&(r=e.createVNode(r,{"time-position":t.timePosition?t.timePosition:"left"},null)),t.direction==="horizontal"?((v=r.props)==null?void 0:v.position)==="top"||((x=r.props)==null?void 0:x.position)==="bottom"?r:t.mode==="alternative"?o(r,g%2==0?"bottom":"top"):o(r,"bottom"):((A=r.props)==null?void 0:A.position)==="left"||((C=r.props)==null?void 0:C.position)==="right"?r:t.mode==="alternative"?o(r,g%2==0?"left":"right"):o(r,"right")})},d=()=>t.direction==="horizontal"?"horizontal":"vertical";return e.createVNode("div",{class:`devui-timeline devui-timeline-${d()} ${t.center?"devui-timeline-"+d()+"-center":""} `,ref:u,style:i},[f()])}}});y.install=function(t){t.component(y.name,y)},p.install=function(t){t.component(p.name,p)};var D={title:"Timeline \u65F6\u95F4\u8F74",category:"\u6570\u636E\u5C55\u793A",status:"100%",install(t){t.use(y),t.use(p)}};a.Timeline=y,a.TimelineItem=p,a.default=D,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.devui-timeline-vertical{display:flex;flex-direction:column;align-items:center;position:relative}.devui-timeline-vertical .devui-timeline-item{display:flex;flex-direction:row;width:100%}.devui-timeline-vertical .devui-timeline-item-axis{display:flex;flex-direction:column;align-items:center;padding:0 12px}.devui-timeline-vertical .devui-timeline-item-line{position:relative;height:calc(100% - 18px);min-height:20px;border-left-width:2px;border-left-color:var(--devui-dividing-line, #dfe1e6)}.devui-timeline-vertical .devui-timeline-item-line-extra{position:absolute;top:50%;transform:translate(-50%,-50%)}.devui-timeline-vertical .devui-timeline-item-line:first-child{display:none}.devui-timeline-vertical .devui-timeline-item-data-left{text-align:end}.devui-timeline-vertical .devui-timeline-item-data-left,.devui-timeline-vertical .devui-timeline-item-data-right{margin-bottom:24px;margin-top:-2px;flex:1}.devui-timeline-vertical .devui-timeline-item-line-style-dashed{border-left-style:dashed}.devui-timeline-vertical .devui-timeline-item-line-style-solid{border-left-style:solid}.devui-timeline-vertical .devui-timeline-item-line-style-dotted{border-left-style:dotted}.devui-timeline-vertical .devui-timeline-item-line-style-none{border-left-style:none}.devui-timeline-vertical .devui-timeline-item .devui-timeline-middle-zone{position:absolute;top:50%;transform:translate(-50%,-50%)}.devui-timeline-horizontal{display:flex;flex-direction:row;align-items:center;position:relative}.devui-timeline-horizontal-center .devui-timeline-item-data-top,.devui-timeline-horizontal-center .devui-timeline-item-data-bottom{text-align:center;padding:0 6px}.devui-timeline-horizontal-center .devui-timeline-item-data-top>div,.devui-timeline-horizontal-center .devui-timeline-item-data-bottom>div{transform:translate(-50%)}.devui-timeline-horizontal .devui-timeline-item{display:flex;flex-direction:column;height:100%}.devui-timeline-horizontal .devui-timeline-item-axis{display:flex;flex-direction:row;align-items:center;padding:12px 0}.devui-timeline-horizontal .devui-timeline-item-line{position:relative;min-width:60px;width:calc(100% - 18px);border-bottom-width:2px;border-bottom-color:var(--devui-dividing-line, #dfe1e6)}.devui-timeline-horizontal .devui-timeline-item-line-extra{position:absolute;left:50%;transform:translate(-50%,-50%)}.devui-timeline-horizontal .devui-timeline-item:first-child .devui-timeline-item-line:first-child{opacity:0}.devui-timeline-horizontal .devui-timeline-item-data-top,.devui-timeline-horizontal .devui-timeline-item-data-bottom{padding-right:12px;flex:1}.devui-timeline-horizontal .devui-timeline-item-line-style-dashed{border-bottom-style:dashed}.devui-timeline-horizontal .devui-timeline-item-line-style-solid{border-bottom-style:solid}.devui-timeline-horizontal .devui-timeline-item-line-style-dotted{border-bottom-style:dotted}.devui-timeline-horizontal .devui-timeline-item-line-style-none{border-bottom-style:none}.devui-timeline-horizontal .devui-timeline-item .devui-timeline-middle-zone{position:absolute;left:50%;transform:translate(-50%,-50%)}.devui-timeline-item-dot,.devui-timeline-item-dot>svg{width:18px;height:18px;flex-shrink:0}.devui-timeline-item-dot>i{font-size:18px;vertical-align:0}.devui-timeline-item-type-primary{border:2px solid var(--devui-placeholder, #8a8e99);border-radius:50%}.devui-timeline-item-type-success i{color:var(--devui-success, #50d4ab)}.devui-timeline-item-type-error i{color:var(--devui-danger, #f66f6a)}.devui-timeline-item-type-warning i{color:var(--devui-warning, #fac20a)}.devui-timeline-item-type-running{line-height:16px;text-align:center;animation:devui-timeline-running 1.5s linear infinite;border:2px solid var(--devui-success, #50d4ab);border-radius:50%}@keyframes devui-timeline-running{0%{transform:rotate(0);color:var(--devui-success, #50d4ab);border-color:var(--devui-success, #50d4ab)}50%{transform:rotate(180deg);color:var(--devui-success, #50d4ab);border-color:var(--devui-success, #50d4ab)}to{transform:rotate(360deg);color:var(--devui-success, #50d4ab);border-color:var(--devui-success, #50d4ab)}}
|
package/upload/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { defineComponent,
|
|
24
|
+
import { defineComponent, toRefs, createVNode, computed, watch, Transition, reactive, createApp, onUnmounted, mergeProps, isVNode, ref, withDirectives, resolveComponent, resolveDirective } from "vue";
|
|
25
25
|
const notificationProps = {
|
|
26
26
|
modelValue: {
|
|
27
27
|
type: Boolean,
|
|
@@ -43,55 +43,53 @@ const notificationProps = {
|
|
|
43
43
|
type: Function
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
+
const iconProps = {
|
|
47
|
+
name: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "",
|
|
50
|
+
required: true
|
|
51
|
+
},
|
|
52
|
+
size: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "inherit"
|
|
55
|
+
},
|
|
56
|
+
color: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "inherit"
|
|
59
|
+
},
|
|
60
|
+
classPrefix: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "icon"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
46
65
|
var Icon = defineComponent({
|
|
47
66
|
name: "DIcon",
|
|
48
|
-
props:
|
|
49
|
-
name: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true
|
|
52
|
-
},
|
|
53
|
-
size: {
|
|
54
|
-
type: String,
|
|
55
|
-
default: "inherit"
|
|
56
|
-
},
|
|
57
|
-
color: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: "inherit"
|
|
60
|
-
},
|
|
61
|
-
classPrefix: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: "icon"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
67
|
+
props: iconProps,
|
|
66
68
|
setup(props) {
|
|
67
|
-
return __spreadValues({}, props);
|
|
68
|
-
},
|
|
69
|
-
render() {
|
|
70
69
|
const {
|
|
71
70
|
name,
|
|
72
71
|
size,
|
|
73
72
|
color,
|
|
74
73
|
classPrefix
|
|
75
|
-
} =
|
|
76
|
-
return
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
} = toRefs(props);
|
|
75
|
+
return () => {
|
|
76
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
77
|
+
"src": name.value,
|
|
78
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
79
|
+
"style": {
|
|
80
|
+
width: size.value,
|
|
81
|
+
verticalAlign: "text-bottom"
|
|
82
|
+
}
|
|
83
|
+
}, null) : createVNode("i", {
|
|
84
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
85
|
+
"style": {
|
|
86
|
+
fontSize: size.value,
|
|
87
|
+
color: color.value
|
|
88
|
+
}
|
|
89
|
+
}, null);
|
|
90
|
+
};
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
|
-
Icon.install = function(app) {
|
|
93
|
-
app.component(Icon.name, Icon);
|
|
94
|
-
};
|
|
95
93
|
var Close = defineComponent({
|
|
96
94
|
emits: ["click"],
|
|
97
95
|
setup(props, {
|
package/upload/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ae=Object.defineProperty,xe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable;var P=(f,t,E)=>t in f?Ae(f,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):f[t]=E,x=(f,t)=>{for(var E in t||(t={}))Me.call(t,E)&&P(f,E,t[E]);if(G)for(var E of G(t))Be.call(t,E)&&P(f,E,t[E]);return f},Y=(f,t)=>xe(f,Oe(t));var g=(f,t,E)=>(P(f,typeof t!="symbol"?t+"":t,E),E);(function(f,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(f=typeof globalThis!="undefined"?globalThis:f||self,t(f.index={},f.Vue))})(this,function(f,t){"use strict";const E={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}};var D=t.defineComponent({name:"DIcon",props:{name:{type:String,required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}},setup(e){return x({},e)},render(){const{name:e,size:o,color:n,classPrefix:l}=this;return/^((https?):)?\/\//.test(e)?t.createVNode("img",{src:e,alt:e.split("/")[e.split("/").length-1],style:{width:o,verticalAlign:"text-bottom"}},null):t.createVNode("i",{class:`${l} ${l}-${e}`,style:{fontSize:o,color:n}},null)}});D.install=function(e){e.component(D.name,D)};var Z=t.defineComponent({emits:["click"],setup(e,{emit:o}){return()=>t.createVNode("div",{class:"devui-notification-icon-close",onClick:n=>o("click",n)},[t.createVNode(D,{name:"close",size:"14px"},null)])}}),J=t.defineComponent({props:{type:{type:String,default:"normal"}},setup(e){const{type:o}=t.toRefs(e),n=t.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${o.value}`]:!0})),l={info:"info-o",success:"right-o",warning:"warning-o",error:"error-o"};return()=>t.createVNode("span",{class:n.value},[o.value!=="normal"&&t.createVNode(D,{name:l[o.value],size:"16px"},null)])}});function K(e){return{classes:t.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${e.type}`]:!0}))}}function Q(e,o){let n=null,l;const s=()=>{var N;clearTimeout(n),n=null,(N=e.onClose)==null||N.call(e),o("update:modelValue",!1)},m=()=>{n&&(clearTimeout(n),n=null)},y=()=>{if(!e.modelValue){const N=e.duration-(Date.now()-l);n=setTimeout(s,N)}},C=()=>{o("destroy")};return t.watch(()=>e.modelValue,N=>{N&&(l=Date.now(),e.duration&&(n=setTimeout(s,e.duration)))}),{interrupt:m,removeReset:y,close:s,handleDestroy:C}}var Le="",ee=t.defineComponent({name:"DNotification",props:E,emits:["update:modelValue","destroy"],setup(e,{emit:o,slots:n}){const{modelValue:l,title:s,type:m}=t.toRefs(e),{classes:y}=K(e),{interrupt:C,removeReset:N,close:u,handleDestroy:r}=Q(e,o);return()=>t.createVNode(t.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var v;return[l.value&&t.createVNode("div",{class:"devui-notification"},[t.createVNode("div",{class:y.value,onMouseenter:C,onMouseleave:N},[t.createVNode("div",{class:"devui-notification-item"},[t.createVNode(Z,{onClick:u},null),s.value&&t.createVNode(J,{type:m.value},null),t.createVNode("div",{class:"devui-notification-message"},[t.createVNode("span",{class:"devui-notification-title"},[s.value]),t.createVNode("span",{class:"devui-notification-content"},[(v=n.default)==null?void 0:v.call(n)])])])])])]}})}});function te(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const oe={modelValue:!1,duration:3e3,type:"normal"};function ne(e,o){const n=document.createElement("div"),l=t.createApp({setup(){return t.onUnmounted(()=>{document.body.removeChild(n)}),()=>t.createVNode(ee,t.mergeProps(e,{onDestroy:l.unmount}),te(o)?o:{default:()=>[o]})}});return document.body.appendChild(n),l.mount(n),l}function ie(e,o){e.modelValue=!1,o==null||o()}class le{static open(o){const n=o.onClose||null,l=o.content;let s;delete o.content;const m=t.reactive(Y(x(x({},oe),o),{onClose:()=>{ie(m,n)}}));ne(m,l),m.modelValue=!0,clearTimeout(s),o.duration&&(s=setTimeout(m.onClose,o.duration))}}class ae{constructor(){g(this,"uri");g(this,"method");g(this,"maximumSize");g(this,"headers");g(this,"authToken");g(this,"authTokenHeader");g(this,"additionalParameter");g(this,"fileFieldName");g(this,"checkSameName");g(this,"withCredentials");g(this,"responseType")}}class se{constructor(){g(this,"accept");g(this,"multiple");g(this,"webkitdirectory")}}var F=(e=>(e[e.preLoad=0]="preLoad",e[e.uploading=1]="uploading",e[e.uploaded=2]="uploaded",e[e.failed=3]="failed",e))(F||{});const z={accept:{type:String},webkitdirectory:{type:Boolean,default:!1},uploadOptions:{type:Object},multiple:{type:Boolean,default:!1},autoUpload:{type:Boolean,default:!0},placeholder:{type:String,default:"\u9009\u62E9\u6587\u4EF6"},modelValue:{type:Array,default:()=>[]},droppable:{type:Boolean,default:!1},beforeUpload:{type:Function},dynamicUploadOptionsFn:{type:Function},disabled:{type:Boolean,default:!1},onChange:{type:Function},fileDrop:{type:Function,default:void 0},fileOver:{type:Function,default:void 0},fileSelect:{type:Function,default:void 0},deleteUploadedFile:{type:Function,default:void 0},"on-error":{type:Function,default:void 0},"on-success":{type:Function,default:void 0},oneTimeUpload:{type:Boolean,default:!1}},re=e=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${e}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ue=(e,o)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${o}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ce=(e,o)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${o}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,de=e=>`\u60A8\u4E0A\u4F20\u7684 "${e}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,pe=()=>{const e=t.ref(""),o=u=>{const r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,0,null),u.dispatchEvent(r)},n=({multiple:u,accept:r,webkitdirectory:v})=>new Promise(b=>{const a=document.getElementById("d-upload-temp");a&&document.body.removeChild(a);const i=document.createElement("input");i.style.position="fixed",i.style.left="-2000px",i.style.top="-2000px",i.setAttribute("id","d-upload-temp"),i.setAttribute("type","file"),u&&i.setAttribute("multiple",""),r&&i.setAttribute("accept",r),v&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{b(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),o(i)}),l=(u,r)=>{if(u){const v=u.split(","),b=r.type.replace(/\/.*$/,"");return v.some(a=>{const i=a.trim();return i.startsWith(".")?r.name.toLowerCase().indexOf(i.toLowerCase(),r.name.toLowerCase().length-i.toLowerCase().length)>-1:/\/\*$/.test(i)?b===i.replace(/\/.*$/,""):r.type===i})}return!0},s=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:v,webkitdirectory:b}=u;return n({multiple:r,accept:v,webkitdirectory:b})},_validateFiles:(u,r,v)=>l(r,u)?v&&s(u.size,v.maximumSize)?{checkError:!0,errorMsg:ue(u.name,v.maximumSize)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:ce(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(s(u,r))return e.value=re(r),{checkError:!0,errorMsg:e.value}}}};class _{constructor(o,n){g(this,"xhr");g(this,"status");g(this,"response");g(this,"percentage",0);this.file=o,this.uploadOptions=n,this.file=o,this.uploadOptions=n,this.status=F.preLoad}send(o){return new Promise((n,l)=>{const{uri:s,method:m,headers:y,authToken:C,authTokenHeader:N,additionalParameter:u,fileFieldName:r,withCredentials:v,responseType:b}=this.uploadOptions,a=N||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(m||"POST",s),v&&(this.xhr.withCredentials=v),b&&(this.xhr.responseType=b),C&&this.xhr.setRequestHeader(a,C),y&&Object.keys(y).forEach(S=>{this.xhr.setRequestHeader(S,y[S])}),this.xhr.upload.onprogress=S=>{this.percentage=Math.round(S.loaded*100/S.total)};const h=o&&o.length?this.oneTimeUploadFiles(i,u,o):this.parallelUploadFiles(i,u);this.xhr.send(h),this.status=F.uploading,this.xhr.onabort=()=>{this.status=F.preLoad,this.xhr=null},this.xhr.onerror=()=>{this.response=this.xhr.response,this.status=F.failed,l({file:this.file,response:this.xhr.response})},this.xhr.onload=()=>{this.xhr.readyState===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,n({file:this.file,response:this.xhr.response})):(this.response=this.xhr.response,this.status=F.failed,l({file:this.file,response:this.xhr.response}))}})}parallelUploadFiles(o,n){const l=new FormData;return l.append(o,this.file,this.file.name),n&&Object.keys(n).forEach(s=>{l.append(s,n[s])}),l}oneTimeUploadFiles(o,n,l){const s=new FormData;return l.forEach(m=>{s.append(o,m.file,m.file.name),n&&Object.keys(n).forEach(y=>{s.append(y,n[y])})}),s}cancel(){this.xhr&&this.xhr.abort()}}const fe=()=>{const e=t.ref([]),o=t.ref([]),n=a=>{let i=!0;for(let h=0;h<e.value.length;h++)if(a===e.value[h].file.name){i=!1,o.value.indexOf(a)===-1&&o.value.push(a);break}return i},l=(a,i)=>{i&&i.checkSameName?n(a.name)&&e.value.push(new _(a,i)):e.value.push(new _(a,i))},s=()=>e.value.map(a=>a.file),m=()=>e.value.map(a=>a),y=async a=>{if(!a||!a.length)return Promise.reject("no files");let i=[];return await a[0].send(a).finally(()=>i=a.map(h=>(h.status=a[0].status,h.percentage=a[0].percentage,{file:h.file,response:a[0].response}))),i};return{fileUploaders:e,getFiles:s,addFile:l,getFullFiles:m,deleteFile:a=>{e.value.find(h=>h.file===a).cancel(),e.value=e.value.filter(h=>a!==h.file)},upload:async a=>{let i=[];if(a){a.percentage=0;const h=await a.send();i.push(h)}else{const h=e.value.filter(k=>k.status===F.preLoad),S=e.value.filter(k=>k.status===F.failed),w=h.length>0?h:S;i=await Promise.all(w.map(async k=>(k.percentage=0,await k.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{e.value=[],o.value=[]},getSameNameFiles:()=>o.value.join(),resetSameNameFiles:()=>{o.value=[]},_oneTimeUpload:()=>{const a=e.value.filter(i=>i.status!==F.uploaded);return y(a)}}};var $e="",O=t.defineComponent({name:"DUpload",props:z,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(e,o){const{uploadOptions:n,placeholder:l,autoUpload:s,disabled:m,beforeUpload:y,droppable:C,oneTimeUpload:N,modelValue:u,multiple:r,accept:v,webkitdirectory:b}=t.toRefs(e),{triggerSelectFiles:a,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:S}=pe(),{fileUploaders:w,addFile:k,getFullFiles:R,deleteFile:j,upload:Ee,resetSameNameFiles:Ne,removeFiles:B,_oneTimeUpload:Ve,getSameNameFiles:be}=fe(),L=t.ref(!1);t.ref("");const A=d=>{le.open({type:"warning",content:d})},Ce=()=>{let d=0;if(w.value.forEach(p=>{d+=p.file.size;const V=i(p.file,v.value,p.uploadOptions);if(V&&V.checkError){j(p.file),A(V.errorMsg);return}}),N.value){const p=S(d,n.value.maximumSize);p&&p.checkError&&(B(),A(p.errorMsg))}},H=d=>{Ne(),d.then(p=>{p.forEach(c=>{r.value||B(),k(c,n.value)}),Ce();const V=be();n.value&&n.value.checkSameName&&V.length&&A(de(V));const T=w.value.filter(c=>c.status===F.preLoad).map(c=>c.file);o.emit("fileSelect",T),s.value&&W()}).catch(p=>{A(p.message)})},q=()=>{m.value||H(a({accept:v.value,multiple:r.value,webkitdirectory:b.value}))},Se=d=>{L.value=!1,H(h(d)),o.emit("fileDrop",d)},ke=d=>{L.value=d,o.emit("fileOver",d)},U=d=>{const p=u.value.filter(V=>V.name!==d.name);o.emit("deleteUploadedFile",d),o.emit("update:modelValue",p)},we=(d,p,V)=>{d.stopPropagation(),V===F.uploaded&&U(p),j(p)},De=()=>{let d=Promise.resolve(!0);if(y.value){const p=y.value(R());typeof p!="undefined"&&(p.then?d=p:d=Promise.resolve(p))}return d},W=(d,p)=>{d&&d.stopPropagation(),De().then(V=>{if(!V){B();return}(N.value?Ve():Ee(p)).then(c=>{e["on-success"]&&e["on-success"](c);const $=[...c.map(Te=>Te.file),...u.value];o.emit("update:modelValue",$)}).catch(c=>{e["on-error"]&&e["on-error"](c)})})};return()=>{var d,p,V,T;return t.createVNode("div",null,[t.withDirectives(t.createVNode("div",{class:"devui-upload",style:`border: ${L.value?"1px solid #15bf15":"0"}`},[((p=(d=o.slots).default)==null?void 0:p.call(d))?t.createVNode("div",{onClick:q},[o.slots.default()]):t.createVNode("div",{class:`devui-input-group ${m.value?"disabled":""}`,onClick:q},[w.value.length===0&&t.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[l.value]),w.value.length>0&&t.createVNode("ul",{class:"devui-form-control devui-files-list"},[w.value.map((c,X)=>t.createVNode("li",{key:X,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[t.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),t.createVNode(t.resolveComponent("d-icon"),{name:"close",class:`${(c==null?void 0:c.status)===F.failed?"devui-upload-delete-file-button":""} ${(c==null?void 0:c.status)===F.uploading||(c==null?void 0:c.status)===F.uploaded?"devui-uploading-delete":""}`,onClick:$=>we($,c.file,c.status)},null),c.status===F.uploading&&t.createVNode("div",{class:"icon devui-upload-progress"},[t.createVNode(t.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&t.createVNode(t.resolveComponent("d-icon"),{name:"running",onClick:W},null),c.status===F.uploaded&&t.createVNode(t.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),t.createVNode("span",{class:"devui-input-group-addon"},[t.createVNode(t.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[t.resolveDirective("file-drop"),{droppable:C,isSingle:!r,onFileDrop:Se,onFileOver:ke}]]),t.createVNode("div",null,[(T=(V=o.slots)["uploaded-files"])==null?void 0:T.call(V,{uploadedFiles:u.value,deleteFile:U})])])}}});const I=e=>{var o;return e.dataTransfer?e.dataTransfer:(o=e.originalEvent)==null?void 0:o.dataTransfer},me=e=>e?e.indexOf?e.indexOf("Files")!==-1:e.contains?e.contains("Files"):!1:!1,M=e=>{e.preventDefault(),e.stopPropagation()},he=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragover",l=>{const s=I(l);!me(s.types)||(M(l),n&&n(!0))})},Fe=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragleave",l=>{l.currentTarget!==e&&(M(l),n&&n(!0))})},ve=(e,o)=>{const{onFileDrop:n,isSingle:l}=o.value;e.addEventListener("drop",s=>{const m=I(s);!m||(M(s),l?n&&n([m.files[0]]):n&&n(Array.from(m.files)))})},ge={mounted:(e,o)=>{const{droppable:n}=o.value;!n||(he(e,o),Fe(e,o),ve(e,o))}};var ye={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.directive("file-drop",ge),e.component(O.name,O)}};f.IFileOptions=se,f.IUploadOptions=ae,f.Upload=O,f.UploadStatus=F,f.default=ye,f.uploadProps=z,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|
|
1
|
+
var xe=Object.defineProperty,Oe=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var L=(f,t,E)=>t in f?xe(f,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):f[t]=E,P=(f,t)=>{for(var E in t||(t={}))Be.call(t,E)&&L(f,E,t[E]);if(G)for(var E of G(t))Le.call(t,E)&&L(f,E,t[E]);return f},Y=(f,t)=>Oe(f,Me(t));var g=(f,t,E)=>(L(f,typeof t!="symbol"?t+"":t,E),E);(function(f,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(f=typeof globalThis!="undefined"?globalThis:f||self,t(f.index={},f.Vue))})(this,function(f,t){"use strict";const E={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},Z={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var $=t.defineComponent({name:"DIcon",props:Z,setup(e){const{name:o,size:n,color:a,classPrefix:s}=t.toRefs(e);return()=>/^((https?):)?\/\//.test(o.value)?t.createVNode("img",{src:o.value,alt:o.value.split("/")[o.value.split("/").length-1],style:{width:n.value,verticalAlign:"text-bottom"}},null):t.createVNode("i",{class:`${s.value} ${s.value}-${o.value}`,style:{fontSize:n.value,color:a.value}},null)}}),J=t.defineComponent({emits:["click"],setup(e,{emit:o}){return()=>t.createVNode("div",{class:"devui-notification-icon-close",onClick:n=>o("click",n)},[t.createVNode($,{name:"close",size:"14px"},null)])}}),K=t.defineComponent({props:{type:{type:String,default:"normal"}},setup(e){const{type:o}=t.toRefs(e),n=t.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${o.value}`]:!0})),a={info:"info-o",success:"right-o",warning:"warning-o",error:"error-o"};return()=>t.createVNode("span",{class:n.value},[o.value!=="normal"&&t.createVNode($,{name:a[o.value],size:"16px"},null)])}});function Q(e){return{classes:t.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${e.type}`]:!0}))}}function ee(e,o){let n=null,a;const s=()=>{var N;clearTimeout(n),n=null,(N=e.onClose)==null||N.call(e),o("update:modelValue",!1)},m=()=>{n&&(clearTimeout(n),n=null)},y=()=>{if(!e.modelValue){const N=e.duration-(Date.now()-a);n=setTimeout(s,N)}},C=()=>{o("destroy")};return t.watch(()=>e.modelValue,N=>{N&&(a=Date.now(),e.duration&&(n=setTimeout(s,e.duration)))}),{interrupt:m,removeReset:y,close:s,handleDestroy:C}}var Pe="",te=t.defineComponent({name:"DNotification",props:E,emits:["update:modelValue","destroy"],setup(e,{emit:o,slots:n}){const{modelValue:a,title:s,type:m}=t.toRefs(e),{classes:y}=Q(e),{interrupt:C,removeReset:N,close:u,handleDestroy:r}=ee(e,o);return()=>t.createVNode(t.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var v;return[a.value&&t.createVNode("div",{class:"devui-notification"},[t.createVNode("div",{class:y.value,onMouseenter:C,onMouseleave:N},[t.createVNode("div",{class:"devui-notification-item"},[t.createVNode(J,{onClick:u},null),s.value&&t.createVNode(K,{type:m.value},null),t.createVNode("div",{class:"devui-notification-message"},[t.createVNode("span",{class:"devui-notification-title"},[s.value]),t.createVNode("span",{class:"devui-notification-content"},[(v=n.default)==null?void 0:v.call(n)])])])])])]}})}});function oe(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const ne={modelValue:!1,duration:3e3,type:"normal"};function ie(e,o){const n=document.createElement("div"),a=t.createApp({setup(){return t.onUnmounted(()=>{document.body.removeChild(n)}),()=>t.createVNode(te,t.mergeProps(e,{onDestroy:a.unmount}),oe(o)?o:{default:()=>[o]})}});return document.body.appendChild(n),a.mount(n),a}function le(e,o){e.modelValue=!1,o==null||o()}class ae{static open(o){const n=o.onClose||null,a=o.content;let s;delete o.content;const m=t.reactive(Y(P(P({},ne),o),{onClose:()=>{le(m,n)}}));ie(m,a),m.modelValue=!0,clearTimeout(s),o.duration&&(s=setTimeout(m.onClose,o.duration))}}class se{constructor(){g(this,"uri");g(this,"method");g(this,"maximumSize");g(this,"headers");g(this,"authToken");g(this,"authTokenHeader");g(this,"additionalParameter");g(this,"fileFieldName");g(this,"checkSameName");g(this,"withCredentials");g(this,"responseType")}}class re{constructor(){g(this,"accept");g(this,"multiple");g(this,"webkitdirectory")}}var F=(e=>(e[e.preLoad=0]="preLoad",e[e.uploading=1]="uploading",e[e.uploaded=2]="uploaded",e[e.failed=3]="failed",e))(F||{});const z={accept:{type:String},webkitdirectory:{type:Boolean,default:!1},uploadOptions:{type:Object},multiple:{type:Boolean,default:!1},autoUpload:{type:Boolean,default:!0},placeholder:{type:String,default:"\u9009\u62E9\u6587\u4EF6"},modelValue:{type:Array,default:()=>[]},droppable:{type:Boolean,default:!1},beforeUpload:{type:Function},dynamicUploadOptionsFn:{type:Function},disabled:{type:Boolean,default:!1},onChange:{type:Function},fileDrop:{type:Function,default:void 0},fileOver:{type:Function,default:void 0},fileSelect:{type:Function,default:void 0},deleteUploadedFile:{type:Function,default:void 0},"on-error":{type:Function,default:void 0},"on-success":{type:Function,default:void 0},oneTimeUpload:{type:Boolean,default:!1}},ue=e=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${e}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ce=(e,o)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${o}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,de=(e,o)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${o}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,pe=e=>`\u60A8\u4E0A\u4F20\u7684 "${e}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,fe=()=>{const e=t.ref(""),o=u=>{const r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,0,null),u.dispatchEvent(r)},n=({multiple:u,accept:r,webkitdirectory:v})=>new Promise(b=>{const l=document.getElementById("d-upload-temp");l&&document.body.removeChild(l);const i=document.createElement("input");i.style.position="fixed",i.style.left="-2000px",i.style.top="-2000px",i.setAttribute("id","d-upload-temp"),i.setAttribute("type","file"),u&&i.setAttribute("multiple",""),r&&i.setAttribute("accept",r),v&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{b(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),o(i)}),a=(u,r)=>{if(u){const v=u.split(","),b=r.type.replace(/\/.*$/,"");return v.some(l=>{const i=l.trim();return i.startsWith(".")?r.name.toLowerCase().indexOf(i.toLowerCase(),r.name.toLowerCase().length-i.toLowerCase().length)>-1:/\/\*$/.test(i)?b===i.replace(/\/.*$/,""):r.type===i})}return!0},s=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:v,webkitdirectory:b}=u;return n({multiple:r,accept:v,webkitdirectory:b})},_validateFiles:(u,r,v)=>a(r,u)?v&&s(u.size,v.maximumSize)?{checkError:!0,errorMsg:ce(u.name,v.maximumSize)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:de(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(s(u,r))return e.value=ue(r),{checkError:!0,errorMsg:e.value}}}};class _{constructor(o,n){g(this,"xhr");g(this,"status");g(this,"response");g(this,"percentage",0);this.file=o,this.uploadOptions=n,this.file=o,this.uploadOptions=n,this.status=F.preLoad}send(o){return new Promise((n,a)=>{const{uri:s,method:m,headers:y,authToken:C,authTokenHeader:N,additionalParameter:u,fileFieldName:r,withCredentials:v,responseType:b}=this.uploadOptions,l=N||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(m||"POST",s),v&&(this.xhr.withCredentials=v),b&&(this.xhr.responseType=b),C&&this.xhr.setRequestHeader(l,C),y&&Object.keys(y).forEach(S=>{this.xhr.setRequestHeader(S,y[S])}),this.xhr.upload.onprogress=S=>{this.percentage=Math.round(S.loaded*100/S.total)};const h=o&&o.length?this.oneTimeUploadFiles(i,u,o):this.parallelUploadFiles(i,u);this.xhr.send(h),this.status=F.uploading,this.xhr.onabort=()=>{this.status=F.preLoad,this.xhr=null},this.xhr.onerror=()=>{this.response=this.xhr.response,this.status=F.failed,a({file:this.file,response:this.xhr.response})},this.xhr.onload=()=>{this.xhr.readyState===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,n({file:this.file,response:this.xhr.response})):(this.response=this.xhr.response,this.status=F.failed,a({file:this.file,response:this.xhr.response}))}})}parallelUploadFiles(o,n){const a=new FormData;return a.append(o,this.file,this.file.name),n&&Object.keys(n).forEach(s=>{a.append(s,n[s])}),a}oneTimeUploadFiles(o,n,a){const s=new FormData;return a.forEach(m=>{s.append(o,m.file,m.file.name),n&&Object.keys(n).forEach(y=>{s.append(y,n[y])})}),s}cancel(){this.xhr&&this.xhr.abort()}}const me=()=>{const e=t.ref([]),o=t.ref([]),n=l=>{let i=!0;for(let h=0;h<e.value.length;h++)if(l===e.value[h].file.name){i=!1,o.value.indexOf(l)===-1&&o.value.push(l);break}return i},a=(l,i)=>{i&&i.checkSameName?n(l.name)&&e.value.push(new _(l,i)):e.value.push(new _(l,i))},s=()=>e.value.map(l=>l.file),m=()=>e.value.map(l=>l),y=async l=>{if(!l||!l.length)return Promise.reject("no files");let i=[];return await l[0].send(l).finally(()=>i=l.map(h=>(h.status=l[0].status,h.percentage=l[0].percentage,{file:h.file,response:l[0].response}))),i};return{fileUploaders:e,getFiles:s,addFile:a,getFullFiles:m,deleteFile:l=>{e.value.find(h=>h.file===l).cancel(),e.value=e.value.filter(h=>l!==h.file)},upload:async l=>{let i=[];if(l){l.percentage=0;const h=await l.send();i.push(h)}else{const h=e.value.filter(k=>k.status===F.preLoad),S=e.value.filter(k=>k.status===F.failed),w=h.length>0?h:S;i=await Promise.all(w.map(async k=>(k.percentage=0,await k.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{e.value=[],o.value=[]},getSameNameFiles:()=>o.value.join(),resetSameNameFiles:()=>{o.value=[]},_oneTimeUpload:()=>{const l=e.value.filter(i=>i.status!==F.uploaded);return y(l)}}};var $e="",A=t.defineComponent({name:"DUpload",props:z,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(e,o){const{uploadOptions:n,placeholder:a,autoUpload:s,disabled:m,beforeUpload:y,droppable:C,oneTimeUpload:N,modelValue:u,multiple:r,accept:v,webkitdirectory:b}=t.toRefs(e),{triggerSelectFiles:l,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:S}=fe(),{fileUploaders:w,addFile:k,getFullFiles:R,deleteFile:j,upload:Ne,resetSameNameFiles:Ve,removeFiles:O,_oneTimeUpload:be,getSameNameFiles:Ce}=me(),M=t.ref(!1);t.ref("");const T=d=>{ae.open({type:"warning",content:d})},Se=()=>{let d=0;if(w.value.forEach(p=>{d+=p.file.size;const V=i(p.file,v.value,p.uploadOptions);if(V&&V.checkError){j(p.file),T(V.errorMsg);return}}),N.value){const p=S(d,n.value.maximumSize);p&&p.checkError&&(O(),T(p.errorMsg))}},H=d=>{Ve(),d.then(p=>{p.forEach(c=>{r.value||O(),k(c,n.value)}),Se();const V=Ce();n.value&&n.value.checkSameName&&V.length&&T(pe(V));const D=w.value.filter(c=>c.status===F.preLoad).map(c=>c.file);o.emit("fileSelect",D),s.value&&W()}).catch(p=>{T(p.message)})},q=()=>{m.value||H(l({accept:v.value,multiple:r.value,webkitdirectory:b.value}))},ke=d=>{M.value=!1,H(h(d)),o.emit("fileDrop",d)},we=d=>{M.value=d,o.emit("fileOver",d)},U=d=>{const p=u.value.filter(V=>V.name!==d.name);o.emit("deleteUploadedFile",d),o.emit("update:modelValue",p)},De=(d,p,V)=>{d.stopPropagation(),V===F.uploaded&&U(p),j(p)},Te=()=>{let d=Promise.resolve(!0);if(y.value){const p=y.value(R());typeof p!="undefined"&&(p.then?d=p:d=Promise.resolve(p))}return d},W=(d,p)=>{d&&d.stopPropagation(),Te().then(V=>{if(!V){O();return}(N.value?be():Ne(p)).then(c=>{e["on-success"]&&e["on-success"](c);const B=[...c.map(Ae=>Ae.file),...u.value];o.emit("update:modelValue",B)}).catch(c=>{e["on-error"]&&e["on-error"](c)})})};return()=>{var d,p,V,D;return t.createVNode("div",null,[t.withDirectives(t.createVNode("div",{class:"devui-upload",style:`border: ${M.value?"1px solid #15bf15":"0"}`},[((p=(d=o.slots).default)==null?void 0:p.call(d))?t.createVNode("div",{onClick:q},[o.slots.default()]):t.createVNode("div",{class:`devui-input-group ${m.value?"disabled":""}`,onClick:q},[w.value.length===0&&t.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[a.value]),w.value.length>0&&t.createVNode("ul",{class:"devui-form-control devui-files-list"},[w.value.map((c,X)=>t.createVNode("li",{key:X,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[t.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),t.createVNode(t.resolveComponent("d-icon"),{name:"close",class:`${(c==null?void 0:c.status)===F.failed?"devui-upload-delete-file-button":""} ${(c==null?void 0:c.status)===F.uploading||(c==null?void 0:c.status)===F.uploaded?"devui-uploading-delete":""}`,onClick:B=>De(B,c.file,c.status)},null),c.status===F.uploading&&t.createVNode("div",{class:"icon devui-upload-progress"},[t.createVNode(t.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&t.createVNode(t.resolveComponent("d-icon"),{name:"running",onClick:W},null),c.status===F.uploaded&&t.createVNode(t.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),t.createVNode("span",{class:"devui-input-group-addon"},[t.createVNode(t.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[t.resolveDirective("file-drop"),{droppable:C,isSingle:!r,onFileDrop:ke,onFileOver:we}]]),t.createVNode("div",null,[(D=(V=o.slots)["uploaded-files"])==null?void 0:D.call(V,{uploadedFiles:u.value,deleteFile:U})])])}}});const I=e=>{var o;return e.dataTransfer?e.dataTransfer:(o=e.originalEvent)==null?void 0:o.dataTransfer},he=e=>e?e.indexOf?e.indexOf("Files")!==-1:e.contains?e.contains("Files"):!1:!1,x=e=>{e.preventDefault(),e.stopPropagation()},Fe=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragover",a=>{const s=I(a);!he(s.types)||(x(a),n&&n(!0))})},ve=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragleave",a=>{a.currentTarget!==e&&(x(a),n&&n(!0))})},ge=(e,o)=>{const{onFileDrop:n,isSingle:a}=o.value;e.addEventListener("drop",s=>{const m=I(s);!m||(x(s),a?n&&n([m.files[0]]):n&&n(Array.from(m.files)))})},ye={mounted:(e,o)=>{const{droppable:n}=o.value;!n||(Fe(e,o),ve(e,o),ge(e,o))}};var Ee={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.directive("file-drop",ye),e.component(A.name,A)}};f.IFileOptions=re,f.IUploadOptions=se,f.Upload=A,f.UploadStatus=F,f.default=Ee,f.uploadProps=z,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|