vue-devui 1.0.0-rc.7 → 1.0.0
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 +163 -146
- package/alert/index.es.js +46 -15
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8230 -231
- package/auto-complete/index.umd.js +29 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +81 -70
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +34 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5706 -98
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +38 -13
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +8066 -245
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{date-picker → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +213 -0
- package/collapse/index.umd.js +1 -0
- package/{date-picker → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +56 -13
- package/countdown/index.umd.js +1 -1
- package/date-picker-pro/index.d.ts +7 -0
- package/date-picker-pro/index.es.js +12020 -0
- package/date-picker-pro/index.umd.js +27 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.es.js +29 -4
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +178 -142
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +742 -107
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +544 -316
- package/form/index.umd.js +17 -17
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +28 -4
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +71 -50
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +184 -23
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +34 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8250 -131
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +275 -203
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +34 -6
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +34 -10
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/mention/index.d.ts +7 -0
- package/mention/index.es.js +8310 -0
- package/mention/index.umd.js +36 -0
- package/mention/package.json +7 -0
- package/mention/style.css +1 -0
- package/menu/index.d.ts +7 -0
- package/menu/index.es.js +934 -0
- package/menu/index.umd.js +1 -0
- package/menu/package.json +7 -0
- package/menu/style.css +1 -0
- package/message/index.d.ts +7 -0
- package/message/index.es.js +538 -0
- package/message/index.umd.js +1 -0
- package/message/package.json +7 -0
- package/message/style.css +1 -0
- package/modal/index.es.js +359 -170
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +236 -65
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Mention.js +3 -0
- package/nuxt/components/Menu.js +3 -0
- package/nuxt/components/MenuItem.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/SubMenu.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/iconProps.js +1 -0
- package/nuxt/components/mentionProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/treeNodeProps.js +3 -0
- package/overlay/index.es.js +84 -125
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +7 -3
- package/pagination/index.es.js +234 -39
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +274 -220
- package/popover/index.umd.js +13 -13
- package/popover/style.css +1 -1
- package/progress/index.es.js +31 -9
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +7969 -152
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +46 -14
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +169 -22
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +3823 -1090
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +9186 -478
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +110 -259
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +143 -146
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +433 -207
- package/splitter/index.umd.js +17 -17
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +34 -16
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +26 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps/index.d.ts +7 -0
- package/steps/index.es.js +386 -0
- package/steps/index.umd.js +1 -0
- package/steps/package.json +7 -0
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.es.js +7802 -59
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +9769 -919
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +309 -96
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +35 -7
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +7922 -78
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +9549 -0
- package/time-picker/index.umd.js +27 -0
- package/time-picker/package.json +7 -0
- package/time-picker/style.css +1 -0
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9585 -0
- package/time-select/index.umd.js +27 -0
- package/time-select/package.json +7 -0
- package/time-select/style.css +1 -0
- package/timeline/index.es.js +169 -22
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +265 -212
- package/tooltip/index.umd.js +15 -15
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +11343 -795
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +494 -106
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +22849 -13614
- package/vue-devui.umd.js +30 -23
- package/date-picker/index.es.js +0 -1145
- package/date-picker/index.umd.js +0 -1
- package/date-picker/style.css +0 -1
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/formControlProps.js +0 -3
- package/nuxt/components/overlayEmits.js +0 -3
- package/nuxt/components/overlayProps.js +0 -3
package/input-number/index.es.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
+
target[prop] = source[prop];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
import { createVNode, computed, ref, toRefs, reactive, watch, defineComponent, mergeProps } from "vue";
|
|
2
17
|
const inputNumberProps = {
|
|
3
18
|
placeholder: {
|
|
4
|
-
type: String
|
|
5
|
-
default: void 0
|
|
19
|
+
type: String
|
|
6
20
|
},
|
|
7
21
|
disabled: {
|
|
8
22
|
type: Boolean,
|
|
@@ -10,7 +24,7 @@ const inputNumberProps = {
|
|
|
10
24
|
},
|
|
11
25
|
step: {
|
|
12
26
|
type: Number,
|
|
13
|
-
default:
|
|
27
|
+
default: 1
|
|
14
28
|
},
|
|
15
29
|
max: {
|
|
16
30
|
type: Number,
|
|
@@ -25,227 +39,285 @@ const inputNumberProps = {
|
|
|
25
39
|
default: ""
|
|
26
40
|
},
|
|
27
41
|
modelValue: {
|
|
28
|
-
type: Number
|
|
29
|
-
default: 0
|
|
30
|
-
},
|
|
31
|
-
"onUpdate:modelValue": {
|
|
32
|
-
type: Function,
|
|
33
|
-
default: void 0
|
|
42
|
+
type: Number
|
|
34
43
|
},
|
|
35
|
-
|
|
36
|
-
type:
|
|
37
|
-
default: void 0
|
|
38
|
-
},
|
|
39
|
-
"onKeydown": {
|
|
40
|
-
type: Function,
|
|
41
|
-
default: void 0
|
|
42
|
-
},
|
|
43
|
-
"onFocus": {
|
|
44
|
-
type: Function,
|
|
45
|
-
default: void 0
|
|
46
|
-
},
|
|
47
|
-
"onBlur": {
|
|
48
|
-
type: Function,
|
|
49
|
-
default: void 0
|
|
44
|
+
precision: {
|
|
45
|
+
type: Number
|
|
50
46
|
}
|
|
51
47
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
default: "",
|
|
57
|
-
required: true
|
|
58
|
-
},
|
|
59
|
-
size: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: "inherit"
|
|
62
|
-
},
|
|
63
|
-
color: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: "inherit"
|
|
66
|
-
},
|
|
67
|
-
classPrefix: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: "icon"
|
|
48
|
+
function createBem(namespace, element, modifier) {
|
|
49
|
+
let cls = namespace;
|
|
50
|
+
if (element) {
|
|
51
|
+
cls += `__${element}`;
|
|
70
52
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
name: "DIcon",
|
|
74
|
-
props: iconProps,
|
|
75
|
-
setup(props) {
|
|
76
|
-
const {
|
|
77
|
-
name,
|
|
78
|
-
size,
|
|
79
|
-
color,
|
|
80
|
-
classPrefix
|
|
81
|
-
} = toRefs(props);
|
|
82
|
-
return () => {
|
|
83
|
-
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
84
|
-
"src": name.value,
|
|
85
|
-
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
86
|
-
"style": {
|
|
87
|
-
width: size.value,
|
|
88
|
-
verticalAlign: "text-bottom"
|
|
89
|
-
}
|
|
90
|
-
}, null) : createVNode("i", {
|
|
91
|
-
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
92
|
-
"style": {
|
|
93
|
-
fontSize: size.value,
|
|
94
|
-
color: color.value
|
|
95
|
-
}
|
|
96
|
-
}, null);
|
|
97
|
-
};
|
|
53
|
+
if (modifier) {
|
|
54
|
+
cls += `--${modifier}`;
|
|
98
55
|
}
|
|
99
|
-
|
|
56
|
+
return cls;
|
|
57
|
+
}
|
|
58
|
+
function useNamespace(block, needDot = false) {
|
|
59
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
60
|
+
const b = () => createBem(namespace);
|
|
61
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
62
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
63
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
64
|
+
return {
|
|
65
|
+
b,
|
|
66
|
+
e,
|
|
67
|
+
m,
|
|
68
|
+
em
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const ns$1 = useNamespace("input-number");
|
|
72
|
+
function IncIcon() {
|
|
73
|
+
return createVNode("svg", {
|
|
74
|
+
"class": ns$1.e("icon-arrow"),
|
|
75
|
+
"width": "1em",
|
|
76
|
+
"height": "1em",
|
|
77
|
+
"viewBox": "0 0 16 16",
|
|
78
|
+
"version": "1.1",
|
|
79
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
80
|
+
}, [createVNode("g", {
|
|
81
|
+
"stroke": "none",
|
|
82
|
+
"stroke-width": "1",
|
|
83
|
+
"fill": "none",
|
|
84
|
+
"fill-rule": "evenodd"
|
|
85
|
+
}, [createVNode("path", {
|
|
86
|
+
"d": "M12.1464466,6.85355339 L8.35355339,10.6464466 C8.15829124,10.8417088 7.84170876,10.8417088 7.64644661,10.6464466 L3.85355339,6.85355339 C3.65829124,6.65829124 3.65829124,6.34170876 3.85355339,6.14644661 C3.94732158,6.05267842 4.07449854,6 4.20710678,6 L11.7928932,6 C12.0690356,6 12.2928932,6.22385763 12.2928932,6.5 C12.2928932,6.63260824 12.2402148,6.7597852 12.1464466,6.85355339 Z",
|
|
87
|
+
"fill-rule": "nonzero"
|
|
88
|
+
}, null)])]);
|
|
89
|
+
}
|
|
90
|
+
function DecIcon() {
|
|
91
|
+
return createVNode("svg", {
|
|
92
|
+
"class": ns$1.e("icon-arrow"),
|
|
93
|
+
"width": "1em",
|
|
94
|
+
"height": "1em",
|
|
95
|
+
"viewBox": "0 0 16 16",
|
|
96
|
+
"version": "1.1",
|
|
97
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
98
|
+
}, [createVNode("g", {
|
|
99
|
+
"stroke": "none",
|
|
100
|
+
"stroke-width": "1",
|
|
101
|
+
"fill": "none",
|
|
102
|
+
"fill-rule": "evenodd"
|
|
103
|
+
}, [createVNode("path", {
|
|
104
|
+
"d": "M12.1464466,6.85355339 L8.35355339,10.6464466 C8.15829124,10.8417088 7.84170876,10.8417088 7.64644661,10.6464466 L3.85355339,6.85355339 C3.65829124,6.65829124 3.65829124,6.34170876 3.85355339,6.14644661 C3.94732158,6.05267842 4.07449854,6 4.20710678,6 L11.7928932,6 C12.0690356,6 12.2928932,6.22385763 12.2928932,6.5 C12.2928932,6.63260824 12.2402148,6.7597852 12.1464466,6.85355339 Z",
|
|
105
|
+
"fill-rule": "nonzero"
|
|
106
|
+
}, null)])]);
|
|
107
|
+
}
|
|
108
|
+
const isNumber = (value) => typeof value === "number";
|
|
109
|
+
const isUndefined = (value) => value === void 0;
|
|
110
|
+
const isNull = (value) => value === null;
|
|
111
|
+
const ns = useNamespace("input-number");
|
|
112
|
+
function useRender(props, ctx) {
|
|
113
|
+
const _a = ctx.attrs, { style, class: customClass } = _a, otherAttrs = __objRest(_a, ["style", "class"]);
|
|
114
|
+
const customStyle = { style };
|
|
115
|
+
const wrapClass = computed(() => [
|
|
116
|
+
{
|
|
117
|
+
[ns.b()]: true
|
|
118
|
+
},
|
|
119
|
+
customClass
|
|
120
|
+
]);
|
|
121
|
+
const controlButtonsClass = computed(() => ({
|
|
122
|
+
[ns.e("control-buttons")]: true,
|
|
123
|
+
disabled: props.disabled,
|
|
124
|
+
[ns.m(props.size)]: true
|
|
125
|
+
}));
|
|
126
|
+
const inputWrapClass = computed(() => ({
|
|
127
|
+
[ns.e("input-wrap")]: true,
|
|
128
|
+
[ns.m(props.size)]: true
|
|
129
|
+
}));
|
|
130
|
+
const inputInnerClass = computed(() => ({
|
|
131
|
+
[ns.e("input-box")]: true,
|
|
132
|
+
disabled: props.disabled
|
|
133
|
+
}));
|
|
134
|
+
return { wrapClass, customStyle, otherAttrs, controlButtonsClass, inputWrapClass, inputInnerClass };
|
|
135
|
+
}
|
|
136
|
+
function useExpose(ctx) {
|
|
137
|
+
const inputRef = ref();
|
|
138
|
+
const focus = () => {
|
|
139
|
+
inputRef.value.focus();
|
|
140
|
+
};
|
|
141
|
+
const blur = () => {
|
|
142
|
+
inputRef.value.blur();
|
|
143
|
+
};
|
|
144
|
+
const select = () => {
|
|
145
|
+
inputRef.value.select();
|
|
146
|
+
};
|
|
147
|
+
ctx.expose({ focus, blur, select });
|
|
148
|
+
return { inputRef };
|
|
149
|
+
}
|
|
150
|
+
function getPrecision(pre) {
|
|
151
|
+
let precision = 0;
|
|
152
|
+
if (isUndefined(pre)) {
|
|
153
|
+
return precision;
|
|
154
|
+
}
|
|
155
|
+
const preString = pre.toString();
|
|
156
|
+
const dotIndex = preString.indexOf(".");
|
|
157
|
+
if (dotIndex !== -1) {
|
|
158
|
+
precision = preString.length - dotIndex - 1;
|
|
159
|
+
}
|
|
160
|
+
return precision;
|
|
161
|
+
}
|
|
162
|
+
function useEvent(props, ctx, inputRef) {
|
|
163
|
+
const { min, max, step, disabled } = toRefs(props);
|
|
164
|
+
const state = reactive({
|
|
165
|
+
currentValue: props.modelValue || "",
|
|
166
|
+
userInputValue: void 0
|
|
167
|
+
});
|
|
168
|
+
const numPrecision = computed(() => {
|
|
169
|
+
if (!isUndefined(props.precision)) {
|
|
170
|
+
return props.precision;
|
|
171
|
+
} else {
|
|
172
|
+
return Math.max(getPrecision(props.modelValue), getPrecision(step.value));
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const inputVal = computed(() => {
|
|
176
|
+
if (!isUndefined(state.userInputValue)) {
|
|
177
|
+
return state.userInputValue;
|
|
178
|
+
}
|
|
179
|
+
let currentValue = state.currentValue;
|
|
180
|
+
if (currentValue === "" || isUndefined(currentValue) || Number.isNaN(currentValue)) {
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
if (isNumber(currentValue)) {
|
|
184
|
+
currentValue = currentValue.toFixed(numPrecision.value);
|
|
185
|
+
}
|
|
186
|
+
return currentValue;
|
|
187
|
+
});
|
|
188
|
+
const toPrecision = (num) => {
|
|
189
|
+
return Number.parseFloat(num.toFixed(numPrecision.value));
|
|
190
|
+
};
|
|
191
|
+
const computeByStep = (val, addOrNot = 1) => {
|
|
192
|
+
if (!isNumber(val)) {
|
|
193
|
+
return state.currentValue;
|
|
194
|
+
}
|
|
195
|
+
return toPrecision(val + step.value * addOrNot);
|
|
196
|
+
};
|
|
197
|
+
const correctValue = (value, shouldUpdate) => {
|
|
198
|
+
if (value === "" || isUndefined(value) || isNull(value) || Number.isNaN(value)) {
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
201
|
+
let newVal = Number(value);
|
|
202
|
+
newVal = toPrecision(newVal);
|
|
203
|
+
if (newVal > max.value || newVal < min.value) {
|
|
204
|
+
newVal = newVal > max.value ? max.value : min.value;
|
|
205
|
+
shouldUpdate && ctx.emit("update:modelValue", newVal);
|
|
206
|
+
}
|
|
207
|
+
return newVal;
|
|
208
|
+
};
|
|
209
|
+
const setCurrentValue = (value) => {
|
|
210
|
+
const oldVal = state.currentValue;
|
|
211
|
+
const newVal = correctValue(value);
|
|
212
|
+
if (oldVal === newVal) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
state.userInputValue = void 0;
|
|
216
|
+
ctx.emit("update:modelValue", newVal);
|
|
217
|
+
ctx.emit("input", newVal);
|
|
218
|
+
ctx.emit("change", newVal, oldVal);
|
|
219
|
+
state.currentValue = newVal;
|
|
220
|
+
};
|
|
221
|
+
const minDisabled = computed(() => isNumber(state.currentValue) && computeByStep(state.currentValue, -1) < props.min);
|
|
222
|
+
const maxDisabled = computed(() => isNumber(state.currentValue) && computeByStep(state.currentValue) > props.max);
|
|
223
|
+
const onAdd = () => {
|
|
224
|
+
if (disabled.value || maxDisabled.value) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
inputRef.value.focus();
|
|
228
|
+
const newVal = computeByStep(state.currentValue || 0);
|
|
229
|
+
setCurrentValue(newVal);
|
|
230
|
+
};
|
|
231
|
+
const onSubtract = () => {
|
|
232
|
+
if (disabled.value || minDisabled.value) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
inputRef.value.focus();
|
|
236
|
+
const newVal = computeByStep(state.currentValue || 0, -1);
|
|
237
|
+
setCurrentValue(newVal);
|
|
238
|
+
};
|
|
239
|
+
watch(() => props.modelValue, (val) => {
|
|
240
|
+
state.currentValue = correctValue(val, true);
|
|
241
|
+
state.userInputValue = void 0;
|
|
242
|
+
}, { immediate: true });
|
|
243
|
+
const onInput = (event) => {
|
|
244
|
+
const value = event.target.value;
|
|
245
|
+
state.userInputValue = value;
|
|
246
|
+
};
|
|
247
|
+
const onChange = (event) => {
|
|
248
|
+
const value = event.target.value;
|
|
249
|
+
const newVal = value !== "" ? Number(value) : "";
|
|
250
|
+
if (isNumber(newVal) && !Number.isNaN(newVal) || value === "") {
|
|
251
|
+
setCurrentValue(newVal);
|
|
252
|
+
}
|
|
253
|
+
state.userInputValue = void 0;
|
|
254
|
+
};
|
|
255
|
+
return { inputVal, minDisabled, maxDisabled, onAdd, onSubtract, onInput, onChange };
|
|
256
|
+
}
|
|
257
|
+
var inputNumber = "";
|
|
100
258
|
var InputNumber = defineComponent({
|
|
101
259
|
name: "DInputNumber",
|
|
102
260
|
props: inputNumberProps,
|
|
103
|
-
emits: ["update:modelValue", "change", "input"
|
|
261
|
+
emits: ["update:modelValue", "change", "input"],
|
|
104
262
|
setup(props, ctx) {
|
|
105
|
-
const inputVal = ref(props.modelValue < props.min ? props.min : props.modelValue);
|
|
106
|
-
const focusVal = ref("");
|
|
107
|
-
const isSize = computed(() => {
|
|
108
|
-
return `devui-input-number-${props.size}`;
|
|
109
|
-
});
|
|
110
|
-
const isDisabled = computed(() => {
|
|
111
|
-
return props.disabled;
|
|
112
|
-
});
|
|
113
|
-
const add = () => {
|
|
114
|
-
if (props.disabled) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (inputVal.value >= props.max) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (props.step !== 0) {
|
|
121
|
-
const maxSpaceVal = props.max - inputVal.value;
|
|
122
|
-
if (inputVal.value < props.max && maxSpaceVal < props.step) {
|
|
123
|
-
inputVal.value += maxSpaceVal;
|
|
124
|
-
} else if (inputVal.value < props.max && maxSpaceVal > props.step) {
|
|
125
|
-
inputVal.value += props.step;
|
|
126
|
-
} else {
|
|
127
|
-
inputVal.value += props.step;
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
inputVal.value += 1;
|
|
131
|
-
}
|
|
132
|
-
focusVal.value = "active";
|
|
133
|
-
ctx.emit("change", inputVal.value);
|
|
134
|
-
ctx.emit("update:modelValue", inputVal.value);
|
|
135
|
-
};
|
|
136
|
-
const subtract = () => {
|
|
137
|
-
if (props.disabled) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (inputVal.value <= props.min) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (props.step !== 0) {
|
|
144
|
-
const minSpaceVal = inputVal.value - props.min;
|
|
145
|
-
if (inputVal.value > props.min && minSpaceVal > props.step) {
|
|
146
|
-
inputVal.value -= props.step;
|
|
147
|
-
} else if (inputVal.value > props.min && minSpaceVal < props.step) {
|
|
148
|
-
inputVal.value -= minSpaceVal;
|
|
149
|
-
} else {
|
|
150
|
-
inputVal.value -= props.step;
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
inputVal.value -= 1;
|
|
154
|
-
}
|
|
155
|
-
focusVal.value = "active";
|
|
156
|
-
ctx.emit("change", inputVal.value);
|
|
157
|
-
ctx.emit("update:modelValue", inputVal.value);
|
|
158
|
-
};
|
|
159
|
-
const onInput = (val) => {
|
|
160
|
-
inputVal.value = parseInt(val.data);
|
|
161
|
-
ctx.emit("input", inputVal.value);
|
|
162
|
-
ctx.emit("update:modelValue", inputVal.value);
|
|
163
|
-
};
|
|
164
|
-
const onFocus = ($event) => {
|
|
165
|
-
focusVal.value = "active";
|
|
166
|
-
ctx.emit("focus", $event);
|
|
167
|
-
};
|
|
168
|
-
const onBlur = ($event) => {
|
|
169
|
-
focusVal.value = "";
|
|
170
|
-
ctx.emit("blur", $event);
|
|
171
|
-
};
|
|
172
|
-
const onChange = ($event) => {
|
|
173
|
-
ctx.emit("change", $event.target.value);
|
|
174
|
-
};
|
|
175
|
-
const onKeydown = ($event) => {
|
|
176
|
-
ctx.emit("keydown", $event);
|
|
177
|
-
};
|
|
178
|
-
return {
|
|
179
|
-
inputVal,
|
|
180
|
-
focusVal,
|
|
181
|
-
isDisabled,
|
|
182
|
-
isSize,
|
|
183
|
-
add,
|
|
184
|
-
subtract,
|
|
185
|
-
onInput,
|
|
186
|
-
onChange,
|
|
187
|
-
onKeydown,
|
|
188
|
-
onBlur,
|
|
189
|
-
onFocus
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
render() {
|
|
193
263
|
const {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
264
|
+
disabled
|
|
265
|
+
} = toRefs(props);
|
|
266
|
+
const {
|
|
267
|
+
wrapClass,
|
|
268
|
+
customStyle,
|
|
269
|
+
otherAttrs,
|
|
270
|
+
controlButtonsClass,
|
|
271
|
+
inputWrapClass,
|
|
272
|
+
inputInnerClass
|
|
273
|
+
} = useRender(props, ctx);
|
|
274
|
+
const {
|
|
275
|
+
inputRef
|
|
276
|
+
} = useExpose(ctx);
|
|
277
|
+
const {
|
|
197
278
|
inputVal,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
279
|
+
minDisabled,
|
|
280
|
+
maxDisabled,
|
|
281
|
+
onAdd,
|
|
282
|
+
onSubtract,
|
|
201
283
|
onInput,
|
|
202
|
-
onChange
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return createVNode("div", {
|
|
209
|
-
"class": dInputNum
|
|
210
|
-
}, [createVNode("div", {
|
|
211
|
-
"onBlur": onBlur,
|
|
212
|
-
"tabindex": "1",
|
|
213
|
-
"class": ["devui-control-buttons", focusVal.value]
|
|
284
|
+
onChange
|
|
285
|
+
} = useEvent(props, ctx, inputRef);
|
|
286
|
+
return () => createVNode("div", mergeProps({
|
|
287
|
+
"class": wrapClass.value
|
|
288
|
+
}, customStyle), [createVNode("div", {
|
|
289
|
+
"class": controlButtonsClass.value
|
|
214
290
|
}, [createVNode("span", {
|
|
215
|
-
"
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"
|
|
219
|
-
}, null)]), createVNode("span", {
|
|
220
|
-
"
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
}, null)])]), createVNode("div", {
|
|
225
|
-
"class":
|
|
226
|
-
}, [createVNode("input", {
|
|
291
|
+
"class": ["control-button control-inc", {
|
|
292
|
+
disabled: maxDisabled.value
|
|
293
|
+
}],
|
|
294
|
+
"onClick": onAdd
|
|
295
|
+
}, [createVNode(IncIcon, null, null)]), createVNode("span", {
|
|
296
|
+
"class": ["control-button control-dec", {
|
|
297
|
+
disabled: minDisabled.value
|
|
298
|
+
}],
|
|
299
|
+
"onClick": onSubtract
|
|
300
|
+
}, [createVNode(DecIcon, null, null)])]), createVNode("div", {
|
|
301
|
+
"class": inputWrapClass.value
|
|
302
|
+
}, [createVNode("input", mergeProps({
|
|
227
303
|
"type": "number",
|
|
228
|
-
"
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
304
|
+
"ref": inputRef,
|
|
305
|
+
"value": inputVal.value,
|
|
306
|
+
"placeholder": props.placeholder,
|
|
307
|
+
"disabled": disabled.value,
|
|
308
|
+
"class": inputInnerClass.value
|
|
309
|
+
}, otherAttrs, {
|
|
232
310
|
"onInput": onInput,
|
|
233
|
-
"onChange": onChange
|
|
234
|
-
|
|
235
|
-
"onBlur": onBlur,
|
|
236
|
-
"onKeydown": onKeydown
|
|
237
|
-
}, null)])]);
|
|
311
|
+
"onChange": onChange
|
|
312
|
+
}), null)])]);
|
|
238
313
|
}
|
|
239
314
|
});
|
|
240
|
-
InputNumber.install = function(app) {
|
|
241
|
-
app.component(InputNumber.name, InputNumber);
|
|
242
|
-
};
|
|
243
315
|
var index = {
|
|
244
316
|
title: "InputNumber \u6570\u5B57\u8F93\u5165\u6846",
|
|
245
317
|
category: "\u6570\u636E\u5F55\u5165",
|
|
246
318
|
status: "50%",
|
|
247
319
|
install(app) {
|
|
248
|
-
app.
|
|
320
|
+
app.component(InputNumber.name, InputNumber);
|
|
249
321
|
}
|
|
250
322
|
};
|
|
251
323
|
export { InputNumber, index as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
var k=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var z=(a,e)=>{var g={};for(var c in a)j.call(a,c)&&e.indexOf(c)<0&&(g[c]=a[c]);if(a!=null&&k)for(var c of k(a))e.indexOf(c)<0&&O.call(a,c)&&(g[c]=a[c]);return g};(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 g={placeholder:{type:String},disabled:{type:Boolean,default:!1},step:{type:Number,default:1},max:{type:Number,default:1/0},min:{type:Number,default:-1/0},size:{type:String,default:""},modelValue:{type:Number},precision:{type:Number}};function c(t,o,r){let s=t;return o&&(s+=`__${o}`),r&&(s+=`--${r}`),s}function P(t,o=!1){const r=o?`.devui-${t}`:`devui-${t}`;return{b:()=>c(r),e:n=>n?c(r,n):"",m:n=>n?c(r,"",n):"",em:(n,m)=>n&&m?c(r,n,m):""}}const D=P("input-number");function F(){return e.createVNode("svg",{class:D.e("icon-arrow"),width:"1em",height:"1em",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{d:"M12.1464466,6.85355339 L8.35355339,10.6464466 C8.15829124,10.8417088 7.84170876,10.8417088 7.64644661,10.6464466 L3.85355339,6.85355339 C3.65829124,6.65829124 3.65829124,6.34170876 3.85355339,6.14644661 C3.94732158,6.05267842 4.07449854,6 4.20710678,6 L11.7928932,6 C12.0690356,6 12.2928932,6.22385763 12.2928932,6.5 C12.2928932,6.63260824 12.2402148,6.7597852 12.1464466,6.85355339 Z","fill-rule":"nonzero"},null)])])}function M(){return e.createVNode("svg",{class:D.e("icon-arrow"),width:"1em",height:"1em",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{d:"M12.1464466,6.85355339 L8.35355339,10.6464466 C8.15829124,10.8417088 7.84170876,10.8417088 7.64644661,10.6464466 L3.85355339,6.85355339 C3.65829124,6.65829124 3.65829124,6.34170876 3.85355339,6.14644661 C3.94732158,6.05267842 4.07449854,6 4.20710678,6 L11.7928932,6 C12.0690356,6 12.2928932,6.22385763 12.2928932,6.5 C12.2928932,6.63260824 12.2402148,6.7597852 12.1464466,6.85355339 Z","fill-rule":"nonzero"},null)])])}const C=t=>typeof t=="number",v=t=>t===void 0,$=t=>t===null,b=P("input-number");function A(t,o){const V=o.attrs,{style:r,class:s}=V,d=z(V,["style","class"]),p={style:r},f=e.computed(()=>[{[b.b()]:!0},s]),n=e.computed(()=>({[b.e("control-buttons")]:!0,disabled:t.disabled,[b.m(t.size)]:!0})),m=e.computed(()=>({[b.e("input-wrap")]:!0,[b.m(t.size)]:!0})),N=e.computed(()=>({[b.e("input-box")]:!0,disabled:t.disabled}));return{wrapClass:f,customStyle:p,otherAttrs:d,controlButtonsClass:n,inputWrapClass:m,inputInnerClass:N}}function R(t){const o=e.ref(),r=()=>{o.value.focus()},s=()=>{o.value.blur()},d=()=>{o.value.select()};return t.expose({focus:r,blur:s,select:d}),{inputRef:o}}function L(t){let o=0;if(v(t))return o;const r=t.toString(),s=r.indexOf(".");return s!==-1&&(o=r.length-s-1),o}function _(t,o,r){const{min:s,max:d,step:p,disabled:f}=e.toRefs(t),n=e.reactive({currentValue:t.modelValue||"",userInputValue:void 0}),m=e.computed(()=>v(t.precision)?Math.max(L(t.modelValue),L(p.value)):t.precision),N=e.computed(()=>{if(!v(n.userInputValue))return n.userInputValue;let u=n.currentValue;return u===""||v(u)||Number.isNaN(u)?"":(C(u)&&(u=u.toFixed(m.value)),u)}),V=u=>Number.parseFloat(u.toFixed(m.value)),h=(u,i=1)=>C(u)?V(u+p.value*i):n.currentValue,I=(u,i)=>{if(u===""||v(u)||$(u)||Number.isNaN(u))return;let l=Number(u);return l=V(l),(l>d.value||l<s.value)&&(l=l>d.value?d.value:s.value,i&&o.emit("update:modelValue",l)),l},w=u=>{const i=n.currentValue,l=I(u);i!==l&&(n.userInputValue=void 0,o.emit("update:modelValue",l),o.emit("input",l),o.emit("change",l,i),n.currentValue=l)},y=e.computed(()=>C(n.currentValue)&&h(n.currentValue,-1)<t.min),x=e.computed(()=>C(n.currentValue)&&h(n.currentValue)>t.max),B=()=>{if(f.value||x.value)return;r.value.focus();const u=h(n.currentValue||0);w(u)},T=()=>{if(f.value||y.value)return;r.value.focus();const u=h(n.currentValue||0,-1);w(u)};return e.watch(()=>t.modelValue,u=>{n.currentValue=I(u,!0),n.userInputValue=void 0},{immediate:!0}),{inputVal:N,minDisabled:y,maxDisabled:x,onAdd:B,onSubtract:T,onInput:u=>{const i=u.target.value;n.userInputValue=i},onChange:u=>{const i=u.target.value,l=i!==""?Number(i):"";(C(l)&&!Number.isNaN(l)||i==="")&&w(l),n.userInputValue=void 0}}}var W="",S=e.defineComponent({name:"DInputNumber",props:g,emits:["update:modelValue","change","input"],setup(t,o){const{disabled:r}=e.toRefs(t),{wrapClass:s,customStyle:d,otherAttrs:p,controlButtonsClass:f,inputWrapClass:n,inputInnerClass:m}=A(t,o),{inputRef:N}=R(o),{inputVal:V,minDisabled:h,maxDisabled:I,onAdd:w,onSubtract:y,onInput:x,onChange:B}=_(t,o,N);return()=>e.createVNode("div",e.mergeProps({class:s.value},d),[e.createVNode("div",{class:f.value},[e.createVNode("span",{class:["control-button control-inc",{disabled:I.value}],onClick:w},[e.createVNode(F,null,null)]),e.createVNode("span",{class:["control-button control-dec",{disabled:h.value}],onClick:y},[e.createVNode(M,null,null)])]),e.createVNode("div",{class:n.value},[e.createVNode("input",e.mergeProps({type:"number",ref:N,value:V.value,placeholder:t.placeholder,disabled:r.value,class:m.value},p,{onInput:x,onChange:B}),null)])])}}),E={title:"InputNumber \u6570\u5B57\u8F93\u5165\u6846",category:"\u6570\u636E\u5F55\u5165",status:"50%",install(t){t.component(S.name,S)}};a.InputNumber=S,a.default=E,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
|
package/input-number/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.devui-input-number{position:relative;display:inline-block;width:80px
|
|
1
|
+
.devui-input-number{position:relative;display:inline-block;width:80px}.devui-input-number:hover .devui-input-number__input-box:not(.disabled){border:1px solid var(--devui-form-control-line-hover, #575d6c);padding-right:24px}.devui-input-number:hover .devui-input-number__control-buttons:not(.disabled){display:flex;border-color:var(--devui-form-control-line-hover, #575d6c)}.devui-input-number:focus-within .devui-input-number__input-box:not(.disabled){border:1px solid var(--devui-form-control-line-active, #5e7ce0);padding-right:24px}.devui-input-number:focus-within .devui-input-number__control-buttons:not(.disabled){display:flex;border-color:var(--devui-form-control-line-active, #5e7ce0)}.devui-input-number.devui-input-number--md{width:80px}.devui-input-number.devui-input-number--md .devui-input-number__input-box{height:32px;line-height:32px}.devui-input-number .devui-input-number__input-box{box-sizing:border-box;padding:4px 8px;font-size:var(--devui-font-size, 14px);border-radius:var(--devui-border-radius, 4px);border:1px solid var(--devui-form-control-line, #d7d8da);outline:none;width:100%;line-height:20px;height:28px;display:block;cursor:text;-moz-appearance:textfield;transition:border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-input-number .devui-input-number__input-box:not(.disabled){background-color:var(--devui-base-bg, #ffffff);border-color:var(--devui-line, #d7d8da);color:var(--devui-text, #252b3a)}.devui-input-number .devui-input-number__input-box::-webkit-inner-spin-button,.devui-input-number .devui-input-number__input-box::-webkit-outer-spin-button{-webkit-appearance:none}.devui-input-number .devui-input-number__control-buttons{display:none;position:absolute;right:0;width:22px;height:100%;flex-direction:column;justify-content:center;align-items:center;border:1px solid transparent;border-left-color:var(--devui-line, #d7d8da);box-sizing:border-box;line-height:100%;border-radius:0 var(--devui-border-radius, 4px) var(--devui-border-radius, 4px) 0}.devui-input-number .devui-input-number__control-buttons.disabled{border-left-color:var(--devui-disabled-line, #dfe1e6)}.devui-input-number .devui-input-number__control-buttons .control-button{user-select:none;box-sizing:border-box;height:50%;line-height:50%;border-width:0 1px;transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1));display:flex;justify-content:center;align-items:center;background-color:var(--devui-base-bg, #ffffff)}.devui-input-number .devui-input-number__control-buttons .control-button.control-inc svg{position:relative;top:2px;transform:rotate(180deg)}.devui-input-number .devui-input-number__control-buttons .control-button.control-dec svg{position:relative;bottom:2px}.devui-input-number .devui-input-number__control-buttons .control-button svg path{fill:var(--devui-text-weak, #575d6c)}.devui-input-number .devui-input-number__control-buttons .control-button:not(.disabled){cursor:pointer}.devui-input-number .devui-input-number__control-buttons .control-button:not(.disabled):hover>svg path{fill:var(--devui-icon-fill-active-hover, #252b3a)}.devui-input-number .devui-input-number__control-buttons .control-button.disabled>svg path{fill:var(--devui-disabled-text, #adb0b8)}.devui-input-number .devui-input-number--lg>.devui-input-number__input-box{font-size:var(--devui-font-size-lg, 14px);line-height:24px;height:46px}.devui-input-number .devui-input-number--lg.devui-input-number__control-buttons .control-button .devui-input-number__icon-arrow{width:16px;height:16px}.devui-input-number .devui-input-number--md>.devui-input-number__input-box{font-size:var(--devui-font-size, 14px);line-height:20px;height:28px}.devui-input-number .devui-input-number--sm>.devui-input-number__input-box{font-size:var(--devui-font-size-sm, 12px);line-height:18px;height:26px}.devui-input-number .devui-input-number--sm.devui-input-number__control-buttons .control-button:first-child .devui-input-number__icon-arrow{width:14px;height:14px}.devui-input-number .devui-input-number--sm.devui-input-number__control-buttons .control-button:last-child .devui-input-number__icon-arrow{width:14px;height:14px}.devui-input-number .devui-input-number__input-wrap{line-height:100%}.devui-input-number .disabled{cursor:not-allowed}
|
package/layout/index.es.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from "vue";
|
|
2
|
+
function createBem(namespace, element, modifier) {
|
|
3
|
+
let cls = namespace;
|
|
4
|
+
if (element) {
|
|
5
|
+
cls += `__${element}`;
|
|
6
|
+
}
|
|
7
|
+
if (modifier) {
|
|
8
|
+
cls += `--${modifier}`;
|
|
9
|
+
}
|
|
10
|
+
return cls;
|
|
11
|
+
}
|
|
12
|
+
function useNamespace(block, needDot = false) {
|
|
13
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
14
|
+
const b = () => createBem(namespace);
|
|
15
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
16
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
17
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
18
|
+
return {
|
|
19
|
+
b,
|
|
20
|
+
e,
|
|
21
|
+
m,
|
|
22
|
+
em
|
|
23
|
+
};
|
|
24
|
+
}
|
|
2
25
|
var layout = "";
|
|
3
26
|
var Layout = defineComponent({
|
|
4
27
|
name: "DLayout",
|
|
@@ -6,11 +29,12 @@ var Layout = defineComponent({
|
|
|
6
29
|
setup(props, {
|
|
7
30
|
slots
|
|
8
31
|
}) {
|
|
32
|
+
const ns = useNamespace("layout");
|
|
9
33
|
return () => {
|
|
10
34
|
var _a;
|
|
11
35
|
const slotDefault = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
|
12
|
-
const isAside = slotDefault.some((item) => item.name === "DAside");
|
|
13
|
-
const classNames = `${isAside ? "
|
|
36
|
+
const isAside = slotDefault.some((item) => item.type.name === "DAside");
|
|
37
|
+
const classNames = `${isAside ? ns.e("aside") : ""} ${ns.b()}`;
|
|
14
38
|
return createVNode("div", {
|
|
15
39
|
"class": classNames
|
|
16
40
|
}, [slotDefault]);
|
|
@@ -23,10 +47,11 @@ var Content = defineComponent({
|
|
|
23
47
|
setup(props, {
|
|
24
48
|
slots
|
|
25
49
|
}) {
|
|
50
|
+
const ns = useNamespace("layout");
|
|
26
51
|
return () => {
|
|
27
52
|
var _a;
|
|
28
53
|
return createVNode("div", {
|
|
29
|
-
"class": "
|
|
54
|
+
"class": ns.e("content")
|
|
30
55
|
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
31
56
|
};
|
|
32
57
|
}
|
|
@@ -37,10 +62,11 @@ var Header = defineComponent({
|
|
|
37
62
|
setup(props, {
|
|
38
63
|
slots
|
|
39
64
|
}) {
|
|
65
|
+
const ns = useNamespace("layout");
|
|
40
66
|
return () => {
|
|
41
67
|
var _a;
|
|
42
68
|
return createVNode("div", {
|
|
43
|
-
"class": "
|
|
69
|
+
"class": ns.e("header")
|
|
44
70
|
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
45
71
|
};
|
|
46
72
|
}
|
|
@@ -51,10 +77,11 @@ var Footer = defineComponent({
|
|
|
51
77
|
setup(props, {
|
|
52
78
|
slots
|
|
53
79
|
}) {
|
|
80
|
+
const ns = useNamespace("layout");
|
|
54
81
|
return () => {
|
|
55
82
|
var _a;
|
|
56
83
|
return createVNode("div", {
|
|
57
|
-
"class": "
|
|
84
|
+
"class": ns.e("footer")
|
|
58
85
|
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
59
86
|
};
|
|
60
87
|
}
|
|
@@ -64,10 +91,11 @@ var Aside = defineComponent({
|
|
|
64
91
|
setup(props, {
|
|
65
92
|
slots
|
|
66
93
|
}) {
|
|
94
|
+
const ns = useNamespace("layout");
|
|
67
95
|
return () => {
|
|
68
96
|
var _a;
|
|
69
97
|
return createVNode("div", {
|
|
70
|
-
"class": "
|
|
98
|
+
"class": ns.em("aside", "inner")
|
|
71
99
|
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
72
100
|
};
|
|
73
101
|
}
|