y-design-ssr 0.2.1 → 0.2.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/libs/button/index.css +579 -1
- package/libs/button/index.mjs +111 -66
- package/libs/button/index.umd.js +203 -2
- package/libs/cell/index.css +1077 -1
- package/libs/cell/index.mjs +167 -104
- package/libs/cell/index.umd.js +300 -2
- package/libs/checkbox/index.css +1053 -1
- package/libs/checkbox/index.mjs +242 -127
- package/libs/checkbox/index.umd.js +369 -2
- package/libs/checkboxGroup/index.css +422 -1
- package/libs/checkboxGroup/index.mjs +173 -87
- package/libs/checkboxGroup/index.umd.js +265 -2
- package/libs/col/index.css +615 -1
- package/libs/col/index.mjs +246 -81
- package/libs/col/index.umd.js +305 -2
- package/libs/countdown/index.css +417 -1
- package/libs/countdown/index.mjs +179 -71
- package/libs/countdown/index.umd.js +231 -2
- package/libs/dialog/index.css +1405 -1
- package/libs/dialog/index.mjs +646 -476
- package/libs/dialog/index.umd.js +1128 -2
- package/libs/empty/index.css +457 -1
- package/libs/empty/index.mjs +91 -44
- package/libs/empty/index.umd.js +139 -2
- package/libs/form/index.css +477 -1
- package/libs/form/index.mjs +226 -126
- package/libs/form/index.umd.js +319 -2
- package/libs/formItem/index.css +477 -1
- package/libs/formItem/index.mjs +276 -126
- package/libs/formItem/index.umd.js +372 -2
- package/libs/icon/index.css +982 -1
- package/libs/icon/index.mjs +107 -58
- package/libs/icon/index.umd.js +186 -2
- package/libs/index.css +2902 -1
- package/libs/index.mjs +3785 -2344
- package/libs/index.umd.js +5509 -2
- package/libs/input/index.css +483 -1
- package/libs/input/index.mjs +183 -92
- package/libs/input/index.umd.js +274 -2
- package/libs/layout/index.css +684 -1
- package/libs/layout/index.mjs +230 -130
- package/libs/layout/index.umd.js +318 -2
- package/libs/list/index.css +440 -1
- package/libs/list/index.mjs +388 -207
- package/libs/list/index.umd.js +571 -2
- package/libs/loading/index.css +548 -1
- package/libs/loading/index.mjs +196 -118
- package/libs/loading/index.umd.js +321 -2
- package/libs/mask/index.css +426 -1
- package/libs/mask/index.mjs +131 -70
- package/libs/mask/index.umd.js +201 -2
- package/libs/popup/index.css +465 -1
- package/libs/popup/index.mjs +210 -134
- package/libs/popup/index.umd.js +358 -2
- package/libs/progress/index.css +488 -1
- package/libs/progress/index.mjs +200 -128
- package/libs/progress/index.umd.js +322 -2
- package/libs/pullrefresh/index.css +441 -1
- package/libs/pullrefresh/index.mjs +241 -111
- package/libs/pullrefresh/index.umd.js +302 -2
- package/libs/row/index.css +485 -1
- package/libs/row/index.mjs +181 -89
- package/libs/row/index.umd.js +237 -2
- package/libs/slider/index.css +558 -1
- package/libs/slider/index.mjs +356 -160
- package/libs/slider/index.umd.js +453 -2
- package/libs/stepper/index.css +489 -1
- package/libs/stepper/index.mjs +181 -101
- package/libs/stepper/index.umd.js +269 -2
- package/libs/swipe/index.css +506 -1
- package/libs/swipe/index.mjs +542 -259
- package/libs/swipe/index.umd.js +703 -2
- package/libs/swipeItem/index.css +424 -1
- package/libs/swipeItem/index.mjs +111 -52
- package/libs/swipeItem/index.umd.js +154 -2
- package/libs/switch/index.css +472 -1
- package/libs/switch/index.mjs +121 -62
- package/libs/switch/index.umd.js +200 -2
- package/libs/tab/index.mjs +131 -68
- package/libs/tab/index.umd.js +190 -1
- package/libs/tabs/index.css +514 -1
- package/libs/tabs/index.mjs +751 -410
- package/libs/tabs/index.umd.js +1020 -2
- package/libs/toast/index.css +1050 -1
- package/libs/toast/index.mjs +183 -114
- package/libs/toast/index.umd.js +306 -2
- package/libs/tooltip/index.css +514 -1
- package/libs/tooltip/index.mjs +293 -155
- package/libs/tooltip/index.umd.js +416 -2
- package/package.json +2 -2
package/libs/stepper/index.mjs
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
|
-
import { ref
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
import { ref, reactive, inject, getCurrentInstance, watch, onUnmounted, defineComponent, computed, createVNode, withDirectives, vModelText } from "vue";
|
|
2
|
+
const getMods = (el, mods) => {
|
|
3
|
+
if (!mods) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
if (typeof mods === "string") {
|
|
7
|
+
return ` ${el}--${mods}`;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(mods)) {
|
|
10
|
+
return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
|
|
11
|
+
}
|
|
12
|
+
return Object.keys(mods).reduce(
|
|
13
|
+
(acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
|
|
14
|
+
""
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
const createBEM = (block) => {
|
|
18
|
+
return (el, mods) => {
|
|
19
|
+
let _el = el;
|
|
20
|
+
let _mods = mods;
|
|
21
|
+
if (_el && typeof _el !== "string") {
|
|
22
|
+
_mods = _el;
|
|
23
|
+
_el = "";
|
|
24
|
+
}
|
|
25
|
+
_el = _el ? `${block}__${_el}` : block;
|
|
26
|
+
return `${_el}${getMods(_el, _mods)}`;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const createGlobalBem = () => {
|
|
30
|
+
return (el, mods) => {
|
|
31
|
+
if (!mods) {
|
|
32
|
+
return `y-${el}`;
|
|
33
|
+
}
|
|
34
|
+
return `${getMods(`y-${el}`, mods)}`;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const defaultLang = {
|
|
9
38
|
"pull-refresh": {
|
|
10
39
|
pulling: "下拉刷新...",
|
|
11
40
|
loosing: "释放刷新...",
|
|
@@ -17,31 +46,50 @@ const b = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t)
|
|
|
17
46
|
validateMessage: "请输入正确内容"
|
|
18
47
|
}
|
|
19
48
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"zh-CN":
|
|
49
|
+
ref("zh-CN");
|
|
50
|
+
reactive({
|
|
51
|
+
"zh-CN": defaultLang
|
|
23
52
|
});
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
return [
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
const createNamespace = (name2) => {
|
|
54
|
+
const prefixedName = `y-${name2}`;
|
|
55
|
+
return [prefixedName, createBEM(prefixedName), createGlobalBem()];
|
|
56
|
+
};
|
|
57
|
+
const parseUnit = (val) => {
|
|
58
|
+
if (isNaN(Number(val)) && typeof val === "string") {
|
|
59
|
+
return val;
|
|
60
|
+
}
|
|
61
|
+
return `${val}px`;
|
|
62
|
+
};
|
|
63
|
+
const FORM_ITEM_PROVIDE = "y-form-item";
|
|
64
|
+
const useFormItem = () => {
|
|
65
|
+
const parent = inject(FORM_ITEM_PROVIDE, null);
|
|
66
|
+
const instance = getCurrentInstance();
|
|
67
|
+
if (parent && (instance == null ? void 0 : instance.proxy)) {
|
|
68
|
+
const { setField } = parent;
|
|
69
|
+
const { resetValidation, change, validateWithTrigger } = parent;
|
|
70
|
+
watch(
|
|
71
|
+
() => instance.proxy.modelValue,
|
|
33
72
|
() => {
|
|
34
|
-
|
|
73
|
+
if (parent.instance && parent.instance.exposed) {
|
|
74
|
+
resetValidation();
|
|
75
|
+
change();
|
|
76
|
+
validateWithTrigger("onChange");
|
|
77
|
+
}
|
|
35
78
|
}
|
|
36
|
-
)
|
|
37
|
-
|
|
79
|
+
);
|
|
80
|
+
setField(instance);
|
|
81
|
+
onUnmounted(() => setField(null));
|
|
82
|
+
return {
|
|
83
|
+
parent
|
|
38
84
|
};
|
|
39
85
|
}
|
|
40
86
|
return {
|
|
41
87
|
parent: null
|
|
42
88
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
89
|
+
};
|
|
90
|
+
const [name, bem, gbem] = createNamespace("stepper");
|
|
91
|
+
const Stepper = /* @__PURE__ */ defineComponent({
|
|
92
|
+
name,
|
|
45
93
|
props: {
|
|
46
94
|
modelValue: {
|
|
47
95
|
type: [Number, String],
|
|
@@ -61,7 +109,7 @@ const O = (e) => {
|
|
|
61
109
|
},
|
|
62
110
|
integer: {
|
|
63
111
|
type: Boolean,
|
|
64
|
-
default:
|
|
112
|
+
default: false
|
|
65
113
|
},
|
|
66
114
|
max: {
|
|
67
115
|
type: Number,
|
|
@@ -69,11 +117,11 @@ const O = (e) => {
|
|
|
69
117
|
},
|
|
70
118
|
disabled: {
|
|
71
119
|
type: Boolean,
|
|
72
|
-
default:
|
|
120
|
+
default: false
|
|
73
121
|
},
|
|
74
122
|
disableInput: {
|
|
75
123
|
type: Boolean,
|
|
76
|
-
default:
|
|
124
|
+
default: false
|
|
77
125
|
},
|
|
78
126
|
inputWidth: {
|
|
79
127
|
type: [Number, String],
|
|
@@ -85,99 +133,131 @@ const O = (e) => {
|
|
|
85
133
|
}
|
|
86
134
|
},
|
|
87
135
|
emits: ["change", "blur", "subtract", "addit", "foucs", "update:modelValue"],
|
|
88
|
-
setup(
|
|
89
|
-
slots
|
|
90
|
-
emit
|
|
136
|
+
setup(props, {
|
|
137
|
+
slots,
|
|
138
|
+
emit
|
|
91
139
|
}) {
|
|
92
140
|
const {
|
|
93
|
-
parent
|
|
94
|
-
} =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
141
|
+
parent
|
|
142
|
+
} = useFormItem();
|
|
143
|
+
const currentValue = ref(props.modelValue);
|
|
144
|
+
const size = computed(() => props.size || (parent == null ? void 0 : parent.getProp("size")));
|
|
145
|
+
const subDisabled = computed(() => props.modelValue <= props.min || props.disabled);
|
|
146
|
+
const addDisabled = computed(() => props.modelValue >= props.max || props.disabled);
|
|
147
|
+
const format = (value) => {
|
|
148
|
+
let bool = props.integer;
|
|
149
|
+
return value.toString().replace(/([^0-9\.\-])/g, "").replace(/\./g, ($1) => {
|
|
150
|
+
if (bool)
|
|
151
|
+
return "";
|
|
152
|
+
bool = true;
|
|
153
|
+
return $1;
|
|
154
|
+
}).replace(/\-/g, (_, i) => i === 0 ? "-" : "");
|
|
100
155
|
};
|
|
101
|
-
|
|
102
|
-
|
|
156
|
+
const changeValue = (number) => {
|
|
157
|
+
const fNumber = format(number);
|
|
158
|
+
currentValue.value = fNumber;
|
|
159
|
+
emit("update:modelValue", fNumber);
|
|
160
|
+
emit("change", fNumber);
|
|
161
|
+
};
|
|
162
|
+
watch(() => props.modelValue, (value) => {
|
|
163
|
+
currentValue.value = value;
|
|
103
164
|
});
|
|
104
|
-
const
|
|
165
|
+
const onFocus = (e) => emit("focus", e);
|
|
166
|
+
const onChange = (e) => {
|
|
105
167
|
const {
|
|
106
|
-
value
|
|
107
|
-
} =
|
|
108
|
-
|
|
109
|
-
}
|
|
168
|
+
value
|
|
169
|
+
} = e.target;
|
|
170
|
+
changeValue(value);
|
|
171
|
+
};
|
|
172
|
+
const onBlurReset = (e) => {
|
|
110
173
|
const {
|
|
111
|
-
value
|
|
112
|
-
} =
|
|
113
|
-
|
|
174
|
+
value
|
|
175
|
+
} = e.target;
|
|
176
|
+
const number = Number(format(value));
|
|
177
|
+
if (number && number < props.min)
|
|
178
|
+
changeValue(props.min);
|
|
179
|
+
else if (number && number > props.max)
|
|
180
|
+
changeValue(props.max);
|
|
181
|
+
else if (number)
|
|
182
|
+
changeValue(number);
|
|
183
|
+
if (parent) {
|
|
114
184
|
const {
|
|
115
|
-
validateWithTrigger
|
|
116
|
-
} =
|
|
117
|
-
|
|
185
|
+
validateWithTrigger
|
|
186
|
+
} = parent;
|
|
187
|
+
validateWithTrigger("onBlur");
|
|
118
188
|
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
189
|
+
emit("blur", e);
|
|
190
|
+
};
|
|
191
|
+
const onSubtract = () => {
|
|
192
|
+
const number = Number(props.modelValue) - props.step;
|
|
193
|
+
changeValue(number);
|
|
194
|
+
emit("subtract", number);
|
|
195
|
+
};
|
|
196
|
+
const onAddit = () => {
|
|
197
|
+
const number = Number(props.modelValue) + props.step;
|
|
198
|
+
changeValue(number);
|
|
199
|
+
emit("addit", number);
|
|
126
200
|
};
|
|
127
201
|
return () => {
|
|
128
202
|
const {
|
|
129
|
-
min
|
|
130
|
-
max
|
|
131
|
-
inputWidth
|
|
132
|
-
placeholder
|
|
133
|
-
disabled
|
|
134
|
-
disableInput
|
|
135
|
-
} =
|
|
136
|
-
return
|
|
137
|
-
class:
|
|
138
|
-
[
|
|
203
|
+
min,
|
|
204
|
+
max,
|
|
205
|
+
inputWidth,
|
|
206
|
+
placeholder,
|
|
207
|
+
disabled,
|
|
208
|
+
disableInput
|
|
209
|
+
} = props;
|
|
210
|
+
return createVNode("div", {
|
|
211
|
+
"class": bem({
|
|
212
|
+
[size.value]: size.value
|
|
139
213
|
})
|
|
140
|
-
}, [
|
|
141
|
-
type: "button",
|
|
142
|
-
disabled:
|
|
143
|
-
class: [
|
|
144
|
-
clickable: !
|
|
214
|
+
}, [slots.subtraction ? slots.subtraction() : createVNode("button", {
|
|
215
|
+
"type": "button",
|
|
216
|
+
"disabled": subDisabled.value,
|
|
217
|
+
"class": [bem("subtraction"), gbem("el", {
|
|
218
|
+
clickable: !subDisabled.value
|
|
145
219
|
})],
|
|
146
|
-
onClick:
|
|
147
|
-
}, null),
|
|
148
|
-
type: "text",
|
|
149
|
-
class:
|
|
150
|
-
"only-disable":
|
|
220
|
+
"onClick": onSubtract
|
|
221
|
+
}, null), withDirectives(createVNode("input", {
|
|
222
|
+
"type": "text",
|
|
223
|
+
"class": bem("input", {
|
|
224
|
+
"only-disable": disableInput
|
|
151
225
|
}),
|
|
152
|
-
style: {
|
|
153
|
-
width:
|
|
226
|
+
"style": {
|
|
227
|
+
width: parseUnit(inputWidth)
|
|
154
228
|
},
|
|
155
|
-
"onUpdate:modelValue": (
|
|
156
|
-
role: "spinbutton",
|
|
157
|
-
inputmode: "decimal",
|
|
158
|
-
"aria-min":
|
|
159
|
-
"aria-max":
|
|
160
|
-
"aria-valuenow":
|
|
161
|
-
onInput:
|
|
162
|
-
onBlur:
|
|
163
|
-
onFocus:
|
|
164
|
-
placeholder:
|
|
165
|
-
disabled:
|
|
166
|
-
}, null), [[
|
|
167
|
-
type: "button",
|
|
168
|
-
disabled:
|
|
169
|
-
class: [
|
|
170
|
-
clickable: !
|
|
229
|
+
"onUpdate:modelValue": ($event) => currentValue.value = $event,
|
|
230
|
+
"role": "spinbutton",
|
|
231
|
+
"inputmode": "decimal",
|
|
232
|
+
"aria-min": min,
|
|
233
|
+
"aria-max": max,
|
|
234
|
+
"aria-valuenow": currentValue.value,
|
|
235
|
+
"onInput": onChange,
|
|
236
|
+
"onBlur": onBlurReset,
|
|
237
|
+
"onFocus": onFocus,
|
|
238
|
+
"placeholder": placeholder,
|
|
239
|
+
"disabled": disabled || disableInput
|
|
240
|
+
}, null), [[vModelText, currentValue.value]]), slots.addition ? slots.addition() : createVNode("button", {
|
|
241
|
+
"type": "button",
|
|
242
|
+
"disabled": addDisabled.value,
|
|
243
|
+
"class": [bem("addition"), gbem("el", {
|
|
244
|
+
clickable: !addDisabled.value
|
|
171
245
|
})],
|
|
172
|
-
onClick:
|
|
246
|
+
"onClick": onAddit
|
|
173
247
|
}, null)]);
|
|
174
248
|
};
|
|
175
249
|
}
|
|
176
250
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
251
|
+
const reset = "";
|
|
252
|
+
const libs = "";
|
|
253
|
+
const font = "";
|
|
254
|
+
const animation = "";
|
|
255
|
+
const theme = "";
|
|
256
|
+
const style = "";
|
|
257
|
+
Stepper.install = (Vue) => {
|
|
258
|
+
const { name: name2 } = Stepper;
|
|
259
|
+
Vue.component(name2, Stepper);
|
|
180
260
|
};
|
|
181
261
|
export {
|
|
182
|
-
|
|
262
|
+
Stepper as default
|
|
183
263
|
};
|