hoci 0.2.0 → 0.3.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/dist/index.cjs +6 -725
- package/dist/index.d.cts +2 -798
- package/dist/index.d.mts +2 -798
- package/dist/index.d.ts +2 -798
- package/dist/index.mjs +2 -0
- package/package.json +13 -9
- package/dist/index.esm.js +0 -713
package/dist/index.cjs
CHANGED
|
@@ -1,732 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const core = require('@
|
|
4
|
-
const
|
|
3
|
+
const core = require('@hoci/core');
|
|
4
|
+
const components = require('@hoci/components');
|
|
5
5
|
|
|
6
|
-
function defineHookProps(props) {
|
|
7
|
-
return props;
|
|
8
|
-
}
|
|
9
|
-
function defineHookEmits(emits) {
|
|
10
|
-
return emits;
|
|
11
|
-
}
|
|
12
|
-
function defineHookComponent(options) {
|
|
13
|
-
return (props, context) => {
|
|
14
|
-
const p = withDefaults(
|
|
15
|
-
isFunction(props) ? core.reactiveComputed(() => props()) : props,
|
|
16
|
-
options.props
|
|
17
|
-
);
|
|
18
|
-
return options.setup(p, context);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function isFunction(value) {
|
|
22
|
-
return typeof value === "function";
|
|
23
|
-
}
|
|
24
|
-
function isConstructor(value) {
|
|
25
|
-
return isFunction(value) && value.prototype !== void 0;
|
|
26
|
-
}
|
|
27
|
-
function withDefaults(props, propsOptions) {
|
|
28
|
-
if (Array.isArray(propsOptions)) {
|
|
29
|
-
return props;
|
|
30
|
-
}
|
|
31
|
-
const newProps = props;
|
|
32
|
-
const options = propsOptions;
|
|
33
|
-
for (const key in options) {
|
|
34
|
-
const k = key;
|
|
35
|
-
const opt = options[k];
|
|
36
|
-
if (newProps[k] !== void 0) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (opt === null) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (isConstructor(opt)) {
|
|
43
|
-
if (isExtends(opt, Boolean)) {
|
|
44
|
-
newProps[key] = false;
|
|
45
|
-
}
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(opt)) {
|
|
49
|
-
if (opt.some((e) => isExtends(e, Boolean))) {
|
|
50
|
-
newProps[key] = false;
|
|
51
|
-
}
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (isFunction(opt.default)) {
|
|
55
|
-
newProps[key] = opt.default(props);
|
|
56
|
-
} else if (opt.default !== void 0) {
|
|
57
|
-
newProps[key] = opt.default;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return newProps;
|
|
61
|
-
}
|
|
62
|
-
function isExtends(types, value) {
|
|
63
|
-
if (Array.isArray(types)) {
|
|
64
|
-
return types.some((e) => isExtends(e, value));
|
|
65
|
-
}
|
|
66
|
-
return value === types;
|
|
67
|
-
}
|
|
68
6
|
|
|
69
|
-
function isIterable(obj) {
|
|
70
|
-
return obj && typeof obj[Symbol.iterator] === "function";
|
|
71
|
-
}
|
|
72
|
-
function isObject(obj) {
|
|
73
|
-
return typeof obj === "object" && obj !== null;
|
|
74
|
-
}
|
|
75
|
-
function isString(obj) {
|
|
76
|
-
return typeof obj === "string";
|
|
77
|
-
}
|
|
78
|
-
function isNumber(obj) {
|
|
79
|
-
return typeof obj === "number";
|
|
80
|
-
}
|
|
81
7
|
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
if (cur) {
|
|
85
|
-
if (isString(cur) || isNumber(cur)) {
|
|
86
|
-
prev = prev && `${prev} `;
|
|
87
|
-
prev = prev.concat(String(cur));
|
|
88
|
-
} else if (isIterable(cur)) {
|
|
89
|
-
prev = prev && `${prev} `;
|
|
90
|
-
prev = prev.concat(classnames(...cur));
|
|
91
|
-
} else if (isObject(cur)) {
|
|
92
|
-
for (const key in cur) {
|
|
93
|
-
if (cur[key]) {
|
|
94
|
-
prev = prev && `${prev} `;
|
|
95
|
-
prev = prev.concat(key);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return prev;
|
|
101
|
-
}, "");
|
|
102
|
-
}
|
|
103
|
-
const cls = classnames;
|
|
104
|
-
|
|
105
|
-
const valuePropType = [
|
|
106
|
-
String,
|
|
107
|
-
Number,
|
|
108
|
-
Object,
|
|
109
|
-
Boolean,
|
|
110
|
-
null
|
|
111
|
-
];
|
|
112
|
-
const classPropType = [String, Array, Object];
|
|
113
|
-
const labelPropType = [String, Function];
|
|
114
|
-
|
|
115
|
-
const InitSymbol = Symbol("[hi-selection]init");
|
|
116
|
-
const ActiveClassSymbol = Symbol("[hi-selection]active-class");
|
|
117
|
-
const ItemClassSymbol = Symbol("[hi-selection]item-class");
|
|
118
|
-
const UnactiveSymbol = Symbol("[hi-selection]unactive-class");
|
|
119
|
-
const DisabledClassSymbol = Symbol("[hi-selection]disabled-class");
|
|
120
|
-
const ItemLabelSymbol = Symbol("[hi-selection]label");
|
|
121
|
-
const ActivateEventSymbol = Symbol("[hi-selection]activate-event");
|
|
122
|
-
const ChangeActiveSymbol = Symbol("[hi-selection]change-active");
|
|
123
|
-
const IsActiveSymbol = Symbol("[hi-selection]is-active");
|
|
124
|
-
|
|
125
|
-
var __defProp$3 = Object.defineProperty;
|
|
126
|
-
var __defProps$3 = Object.defineProperties;
|
|
127
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
128
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
129
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
130
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
131
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
132
|
-
var __spreadValues$3 = (a, b) => {
|
|
133
|
-
for (var prop in b || (b = {}))
|
|
134
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
135
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
136
|
-
if (__getOwnPropSymbols$3)
|
|
137
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
138
|
-
if (__propIsEnum$3.call(b, prop))
|
|
139
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
140
|
-
}
|
|
141
|
-
return a;
|
|
142
|
-
};
|
|
143
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
144
|
-
const selectionItemProps = defineHookProps({
|
|
145
|
-
value: {
|
|
146
|
-
type: valuePropType,
|
|
147
|
-
default() {
|
|
148
|
-
return Math.random().toString(16).slice(2);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
label: {
|
|
152
|
-
type: [Function, String]
|
|
153
|
-
},
|
|
154
|
-
keepAlive: {
|
|
155
|
-
type: Boolean,
|
|
156
|
-
default: () => true
|
|
157
|
-
},
|
|
158
|
-
key: {
|
|
159
|
-
type: [String, Number, Symbol]
|
|
160
|
-
},
|
|
161
|
-
activateEvent: {
|
|
162
|
-
type: String
|
|
163
|
-
},
|
|
164
|
-
disabled: {
|
|
165
|
-
type: Boolean,
|
|
166
|
-
default: false
|
|
167
|
-
}
|
|
8
|
+
Object.keys(core).forEach(function (k) {
|
|
9
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = core[k];
|
|
168
10
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
setup(props, { slots }) {
|
|
172
|
-
const isActiveFn = vue.inject(IsActiveSymbol, () => false);
|
|
173
|
-
const changeActive = vue.inject(ChangeActiveSymbol, () => {
|
|
174
|
-
});
|
|
175
|
-
const parentLabel = core.toRef(vue.inject(ItemLabelSymbol));
|
|
176
|
-
const activate = () => {
|
|
177
|
-
if (props.disabled) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
changeActive(props.value);
|
|
181
|
-
};
|
|
182
|
-
function render() {
|
|
183
|
-
return vue.renderSlot(slots, "default", {
|
|
184
|
-
active: isActiveFn(props.value),
|
|
185
|
-
activate
|
|
186
|
-
}, () => {
|
|
187
|
-
var _a;
|
|
188
|
-
let label = (_a = props.label) != null ? _a : parentLabel.value;
|
|
189
|
-
if (label && typeof label == "function") {
|
|
190
|
-
label = label(props.value);
|
|
191
|
-
}
|
|
192
|
-
return Array.isArray(label) ? label : [label];
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
let remove = () => {
|
|
196
|
-
};
|
|
197
|
-
const init = vue.inject(InitSymbol);
|
|
198
|
-
if (init) {
|
|
199
|
-
vue.watch(
|
|
200
|
-
() => props.value,
|
|
201
|
-
(value) => {
|
|
202
|
-
remove();
|
|
203
|
-
remove = init({
|
|
204
|
-
id: Math.random().toString(16).slice(2),
|
|
205
|
-
label: typeof props.label == "string" ? props.label : void 0,
|
|
206
|
-
value,
|
|
207
|
-
render
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
{ immediate: true }
|
|
211
|
-
);
|
|
212
|
-
vue.onDeactivated(() => remove());
|
|
213
|
-
}
|
|
214
|
-
const isActive = vue.computed(() => isActiveFn(props.value));
|
|
215
|
-
const isDisabled = vue.computed(() => props.disabled);
|
|
216
|
-
const activeClass = vue.computed(
|
|
217
|
-
() => {
|
|
218
|
-
var _a, _b;
|
|
219
|
-
return (_b = (_a = vue.inject(ActiveClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "active";
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
const unactiveClass = vue.computed(
|
|
223
|
-
() => {
|
|
224
|
-
var _a, _b;
|
|
225
|
-
return (_b = (_a = vue.inject(UnactiveSymbol)) == null ? void 0 : _a.value) != null ? _b : "unactive";
|
|
226
|
-
}
|
|
227
|
-
);
|
|
228
|
-
const disabledClass = vue.computed(() => {
|
|
229
|
-
var _a, _b;
|
|
230
|
-
return (_b = (_a = vue.inject(DisabledClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "disabled";
|
|
231
|
-
});
|
|
232
|
-
const itemClass = vue.computed(() => {
|
|
233
|
-
var _a, _b;
|
|
234
|
-
return (_b = (_a = vue.inject(ItemClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "";
|
|
235
|
-
});
|
|
236
|
-
const className = vue.computed(() => {
|
|
237
|
-
const array = [itemClass.value];
|
|
238
|
-
if (!isDisabled.value) {
|
|
239
|
-
array.push(isActiveFn(props.value) ? activeClass.value : unactiveClass.value);
|
|
240
|
-
} else {
|
|
241
|
-
array.push(disabledClass.value);
|
|
242
|
-
}
|
|
243
|
-
return cls(array);
|
|
244
|
-
});
|
|
245
|
-
const activateEvent = core.toRef(() => {
|
|
246
|
-
var _a, _b;
|
|
247
|
-
const event = vue.inject(ActivateEventSymbol);
|
|
248
|
-
return (_b = (_a = props.activateEvent) != null ? _a : event == null ? void 0 : event.value) != null ? _b : "click";
|
|
249
|
-
});
|
|
250
|
-
return {
|
|
251
|
-
activate,
|
|
252
|
-
render,
|
|
253
|
-
isActive,
|
|
254
|
-
isDisabled,
|
|
255
|
-
activeClass,
|
|
256
|
-
unactiveClass,
|
|
257
|
-
disabledClass,
|
|
258
|
-
itemClass,
|
|
259
|
-
className,
|
|
260
|
-
activateEvent
|
|
261
|
-
};
|
|
262
|
-
}
|
|
11
|
+
Object.keys(components).forEach(function (k) {
|
|
12
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = components[k];
|
|
263
13
|
});
|
|
264
|
-
const HiItem = vue.defineComponent({
|
|
265
|
-
name: "HiItem",
|
|
266
|
-
props: __spreadProps$3(__spreadValues$3({}, selectionItemProps), {
|
|
267
|
-
tag: {
|
|
268
|
-
type: String,
|
|
269
|
-
default: "div"
|
|
270
|
-
}
|
|
271
|
-
}),
|
|
272
|
-
setup(props, context) {
|
|
273
|
-
const { render, activate, className, isDisabled, activateEvent } = useSelectionItem(
|
|
274
|
-
props,
|
|
275
|
-
context
|
|
276
|
-
);
|
|
277
|
-
return () => vue.h(
|
|
278
|
-
props.tag,
|
|
279
|
-
{
|
|
280
|
-
class: className.value,
|
|
281
|
-
[`on${vue.capitalize(activateEvent.value)}`]: activate,
|
|
282
|
-
disabled: isDisabled.value
|
|
283
|
-
},
|
|
284
|
-
render()
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
var __defProp$2 = Object.defineProperty;
|
|
290
|
-
var __defProps$2 = Object.defineProperties;
|
|
291
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
292
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
293
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
294
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
295
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
296
|
-
var __spreadValues$2 = (a, b) => {
|
|
297
|
-
for (var prop in b || (b = {}))
|
|
298
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
299
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
300
|
-
if (__getOwnPropSymbols$2)
|
|
301
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
302
|
-
if (__propIsEnum$2.call(b, prop))
|
|
303
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
304
|
-
}
|
|
305
|
-
return a;
|
|
306
|
-
};
|
|
307
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
308
|
-
const selectionListProps = defineHookProps({
|
|
309
|
-
modelValue: {
|
|
310
|
-
type: valuePropType,
|
|
311
|
-
default: () => null
|
|
312
|
-
},
|
|
313
|
-
/**
|
|
314
|
-
* 选中时的 class
|
|
315
|
-
*/
|
|
316
|
-
activeClass: {
|
|
317
|
-
type: classPropType,
|
|
318
|
-
default: "active"
|
|
319
|
-
},
|
|
320
|
-
/**
|
|
321
|
-
* 每个选项的 class
|
|
322
|
-
*/
|
|
323
|
-
itemClass: {
|
|
324
|
-
type: classPropType,
|
|
325
|
-
default: ""
|
|
326
|
-
},
|
|
327
|
-
disabledClass: {
|
|
328
|
-
type: classPropType,
|
|
329
|
-
default: "disabled"
|
|
330
|
-
},
|
|
331
|
-
unactiveClass: {
|
|
332
|
-
type: classPropType,
|
|
333
|
-
default: ""
|
|
334
|
-
},
|
|
335
|
-
label: {
|
|
336
|
-
type: labelPropType
|
|
337
|
-
},
|
|
338
|
-
/**
|
|
339
|
-
* 多选模式
|
|
340
|
-
*/
|
|
341
|
-
multiple: {
|
|
342
|
-
type: [Boolean, Number],
|
|
343
|
-
default: () => false
|
|
344
|
-
},
|
|
345
|
-
/**
|
|
346
|
-
* 可清除
|
|
347
|
-
*/
|
|
348
|
-
clearable: {
|
|
349
|
-
type: Boolean
|
|
350
|
-
},
|
|
351
|
-
defaultValue: {
|
|
352
|
-
type: valuePropType,
|
|
353
|
-
default: () => null
|
|
354
|
-
},
|
|
355
|
-
activateEvent: {
|
|
356
|
-
type: String,
|
|
357
|
-
default: () => "click"
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
const selectionListEmits = defineHookEmits([
|
|
361
|
-
"update:modelValue",
|
|
362
|
-
"change",
|
|
363
|
-
"load",
|
|
364
|
-
"unload"
|
|
365
|
-
]);
|
|
366
|
-
const useSelectionList = defineHookComponent({
|
|
367
|
-
props: selectionListProps,
|
|
368
|
-
emits: selectionListEmits,
|
|
369
|
-
setup(props, { emit }) {
|
|
370
|
-
var _a;
|
|
371
|
-
const options = vue.reactive([]);
|
|
372
|
-
function toArray(value) {
|
|
373
|
-
if (!core.isDefined(value)) {
|
|
374
|
-
return [];
|
|
375
|
-
}
|
|
376
|
-
if (props.multiple && Array.isArray(value)) {
|
|
377
|
-
return value.filter((v) => v != null || v !== void 0);
|
|
378
|
-
}
|
|
379
|
-
return [value];
|
|
380
|
-
}
|
|
381
|
-
const actives = vue.reactive([
|
|
382
|
-
...toArray((_a = props.modelValue) != null ? _a : props.defaultValue)
|
|
383
|
-
]);
|
|
384
|
-
const currentValue = vue.computed({
|
|
385
|
-
get() {
|
|
386
|
-
return props.multiple ? actives : actives[0];
|
|
387
|
-
},
|
|
388
|
-
set(val) {
|
|
389
|
-
actives.splice(0, actives.length, ...toArray(val));
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
const modelValue = vue.computed({
|
|
393
|
-
get() {
|
|
394
|
-
var _a2;
|
|
395
|
-
return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
|
|
396
|
-
},
|
|
397
|
-
set(val) {
|
|
398
|
-
emit("update:modelValue", val);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
core.syncRef(currentValue, modelValue, { immediate: true, deep: true });
|
|
402
|
-
vue.provide(
|
|
403
|
-
ActiveClassSymbol,
|
|
404
|
-
vue.computed(() => cls(props.activeClass))
|
|
405
|
-
);
|
|
406
|
-
vue.provide(
|
|
407
|
-
UnactiveSymbol,
|
|
408
|
-
vue.computed(() => cls(props.unactiveClass))
|
|
409
|
-
);
|
|
410
|
-
vue.provide(
|
|
411
|
-
DisabledClassSymbol,
|
|
412
|
-
vue.computed(() => cls(props.disabledClass))
|
|
413
|
-
);
|
|
414
|
-
vue.provide(
|
|
415
|
-
ItemClassSymbol,
|
|
416
|
-
vue.computed(() => cls(props.itemClass))
|
|
417
|
-
);
|
|
418
|
-
vue.provide(
|
|
419
|
-
ItemLabelSymbol,
|
|
420
|
-
vue.computed(() => props.label)
|
|
421
|
-
);
|
|
422
|
-
vue.provide(
|
|
423
|
-
ActivateEventSymbol,
|
|
424
|
-
vue.computed(() => props.activateEvent)
|
|
425
|
-
);
|
|
426
|
-
const emitChange = () => emit("change", currentValue.value);
|
|
427
|
-
function isActive(value) {
|
|
428
|
-
return actives.includes(value);
|
|
429
|
-
}
|
|
430
|
-
function changeActive(value) {
|
|
431
|
-
if (isActive(value)) {
|
|
432
|
-
if (props.multiple || props.clearable) {
|
|
433
|
-
actives.splice(actives.indexOf(value), 1);
|
|
434
|
-
emitChange();
|
|
435
|
-
}
|
|
436
|
-
} else {
|
|
437
|
-
if (props.multiple) {
|
|
438
|
-
const limit = typeof props.multiple === "number" ? props.multiple : Number.POSITIVE_INFINITY;
|
|
439
|
-
if (actives.length < limit) {
|
|
440
|
-
actives.push(value);
|
|
441
|
-
emitChange();
|
|
442
|
-
}
|
|
443
|
-
} else {
|
|
444
|
-
actives.splice(0, actives.length, value);
|
|
445
|
-
emitChange();
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
vue.provide(IsActiveSymbol, isActive);
|
|
450
|
-
vue.provide(ChangeActiveSymbol, changeActive);
|
|
451
|
-
vue.provide(InitSymbol, (option) => {
|
|
452
|
-
function remove() {
|
|
453
|
-
const index = options.findIndex((e) => e.id === option.id);
|
|
454
|
-
if (index > -1) {
|
|
455
|
-
options.splice(index, 1);
|
|
456
|
-
emit("unload", option);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
for (let i = 0; i < options.length; i++) {
|
|
460
|
-
if (options[i].value === option.value) {
|
|
461
|
-
options.splice(i, 1);
|
|
462
|
-
i--;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
options.push(option);
|
|
466
|
-
emit("load", option);
|
|
467
|
-
return remove;
|
|
468
|
-
});
|
|
469
|
-
function renderItem() {
|
|
470
|
-
const children = options.filter((e) => actives.includes(e.value)).map((e) => e.render());
|
|
471
|
-
return props.multiple ? children : children[0];
|
|
472
|
-
}
|
|
473
|
-
return {
|
|
474
|
-
options,
|
|
475
|
-
actives,
|
|
476
|
-
isActive,
|
|
477
|
-
changeActive,
|
|
478
|
-
renderItem
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
const HiSelection = vue.defineComponent({
|
|
483
|
-
name: "HiSelection",
|
|
484
|
-
props: __spreadProps$2(__spreadValues$2({}, selectionListProps), {
|
|
485
|
-
tag: {
|
|
486
|
-
type: String,
|
|
487
|
-
default: "div"
|
|
488
|
-
}
|
|
489
|
-
}),
|
|
490
|
-
emits: selectionListEmits,
|
|
491
|
-
setup(props, context) {
|
|
492
|
-
const { isActive, changeActive, renderItem } = useSelectionList(props, context);
|
|
493
|
-
const { slots } = context;
|
|
494
|
-
return () => vue.h(props.tag, {}, vue.renderSlot(slots, "default", {
|
|
495
|
-
isActive,
|
|
496
|
-
changeActive,
|
|
497
|
-
renderItem
|
|
498
|
-
}));
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
var __defProp$1 = Object.defineProperty;
|
|
503
|
-
var __defProps$1 = Object.defineProperties;
|
|
504
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
505
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
506
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
507
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
508
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
509
|
-
var __spreadValues$1 = (a, b) => {
|
|
510
|
-
for (var prop in b || (b = {}))
|
|
511
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
512
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
513
|
-
if (__getOwnPropSymbols$1)
|
|
514
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
515
|
-
if (__propIsEnum$1.call(b, prop))
|
|
516
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
517
|
-
}
|
|
518
|
-
return a;
|
|
519
|
-
};
|
|
520
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
521
|
-
const switchProps = defineHookProps({
|
|
522
|
-
modelValue: {
|
|
523
|
-
type: Boolean,
|
|
524
|
-
default: false
|
|
525
|
-
},
|
|
526
|
-
class: {
|
|
527
|
-
type: classPropType,
|
|
528
|
-
required: true
|
|
529
|
-
},
|
|
530
|
-
activeClass: {
|
|
531
|
-
type: classPropType,
|
|
532
|
-
default: "checked"
|
|
533
|
-
},
|
|
534
|
-
unactiveClass: {
|
|
535
|
-
type: classPropType,
|
|
536
|
-
default: "unchecked"
|
|
537
|
-
},
|
|
538
|
-
activateEvent: {
|
|
539
|
-
type: String,
|
|
540
|
-
default: "click"
|
|
541
|
-
},
|
|
542
|
-
disabled: {
|
|
543
|
-
type: Boolean,
|
|
544
|
-
default: false
|
|
545
|
-
},
|
|
546
|
-
disabledClass: {
|
|
547
|
-
type: classPropType,
|
|
548
|
-
default: ""
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
const switchEmits = defineHookEmits(["update:modelValue", "change"]);
|
|
552
|
-
const useSwitch = defineHookComponent({
|
|
553
|
-
props: switchProps,
|
|
554
|
-
emits: switchEmits,
|
|
555
|
-
setup(props, context) {
|
|
556
|
-
const modelValue = core.useVModel(props, "modelValue", context.emit, {
|
|
557
|
-
passive: true,
|
|
558
|
-
defaultValue: false
|
|
559
|
-
});
|
|
560
|
-
const toggle = function(value) {
|
|
561
|
-
if (props.disabled) {
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const oldValue = modelValue.value;
|
|
565
|
-
const newValue = typeof value === "boolean" ? value : !oldValue;
|
|
566
|
-
if (newValue !== oldValue) {
|
|
567
|
-
modelValue.value = newValue;
|
|
568
|
-
context.emit("change", newValue);
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
const isDisabled = vue.computed(() => props.disabled);
|
|
572
|
-
const className = vue.computed(() => {
|
|
573
|
-
return cls([
|
|
574
|
-
props.class,
|
|
575
|
-
modelValue.value ? props.activeClass : props.unactiveClass,
|
|
576
|
-
isDisabled.value ? props.disabledClass : ""
|
|
577
|
-
]);
|
|
578
|
-
});
|
|
579
|
-
return {
|
|
580
|
-
toggle,
|
|
581
|
-
modelValue,
|
|
582
|
-
className,
|
|
583
|
-
isDisabled
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
const HiSwitch = vue.defineComponent({
|
|
588
|
-
name: "HiSwitch",
|
|
589
|
-
props: __spreadProps$1(__spreadValues$1({}, switchProps), {
|
|
590
|
-
tag: {
|
|
591
|
-
type: String,
|
|
592
|
-
default: "div"
|
|
593
|
-
}
|
|
594
|
-
}),
|
|
595
|
-
emits: switchEmits,
|
|
596
|
-
setup(props, context) {
|
|
597
|
-
const { slots } = context;
|
|
598
|
-
const { className, toggle, modelValue, isDisabled } = useSwitch(props, context);
|
|
599
|
-
return () => {
|
|
600
|
-
return vue.h(
|
|
601
|
-
props.tag,
|
|
602
|
-
{
|
|
603
|
-
class: className.value,
|
|
604
|
-
[`on${vue.capitalize(props.activateEvent)}`]: toggle
|
|
605
|
-
},
|
|
606
|
-
vue.renderSlot(slots, "default", {
|
|
607
|
-
active: modelValue.value,
|
|
608
|
-
isDisabled: isDisabled.value
|
|
609
|
-
})
|
|
610
|
-
);
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
var __defProp = Object.defineProperty;
|
|
616
|
-
var __defProps = Object.defineProperties;
|
|
617
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
618
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
619
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
620
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
621
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
622
|
-
var __spreadValues = (a, b) => {
|
|
623
|
-
for (var prop in b || (b = {}))
|
|
624
|
-
if (__hasOwnProp.call(b, prop))
|
|
625
|
-
__defNormalProp(a, prop, b[prop]);
|
|
626
|
-
if (__getOwnPropSymbols)
|
|
627
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
628
|
-
if (__propIsEnum.call(b, prop))
|
|
629
|
-
__defNormalProp(a, prop, b[prop]);
|
|
630
|
-
}
|
|
631
|
-
return a;
|
|
632
|
-
};
|
|
633
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
634
|
-
const iconProps = defineHookProps({
|
|
635
|
-
src: {
|
|
636
|
-
type: String,
|
|
637
|
-
required: true
|
|
638
|
-
},
|
|
639
|
-
size: {
|
|
640
|
-
type: [Number, String],
|
|
641
|
-
default: "1rem"
|
|
642
|
-
},
|
|
643
|
-
width: {
|
|
644
|
-
type: [Number, String]
|
|
645
|
-
},
|
|
646
|
-
height: {
|
|
647
|
-
type: [Number, String]
|
|
648
|
-
},
|
|
649
|
-
color: {
|
|
650
|
-
type: String
|
|
651
|
-
},
|
|
652
|
-
mask: {
|
|
653
|
-
type: [Boolean, String],
|
|
654
|
-
default: () => "auto"
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
const useIcon = defineHookComponent({
|
|
658
|
-
props: iconProps,
|
|
659
|
-
setup(props, context) {
|
|
660
|
-
const style = vue.computed(() => {
|
|
661
|
-
var _a, _b, _c, _d, _e, _f;
|
|
662
|
-
const icon = props.src;
|
|
663
|
-
const propSize = (_a = props.size) != null ? _a : "16px";
|
|
664
|
-
const size = typeof propSize === "number" ? `${propSize}px` : propSize;
|
|
665
|
-
const propWidth = (_b = props.width) != null ? _b : size;
|
|
666
|
-
const width = typeof propWidth === "number" ? `${propWidth}px` : propWidth;
|
|
667
|
-
const propHeight = (_c = props.height) != null ? _c : size;
|
|
668
|
-
const height = typeof propHeight === "number" ? `${propHeight}px` : propHeight;
|
|
669
|
-
const color = (_d = props.color) != null ? _d : "currentColor";
|
|
670
|
-
const mask = props.mask === "auto" ? icon.endsWith(".svg") : props.mask;
|
|
671
|
-
if (!mask) {
|
|
672
|
-
return __spreadValues({
|
|
673
|
-
"--icon-url": `url('${icon}')`,
|
|
674
|
-
"background-image": "var(--icon-url)",
|
|
675
|
-
"background-size": "100% 100%",
|
|
676
|
-
"height": height,
|
|
677
|
-
"width": width,
|
|
678
|
-
"display": "inline-block"
|
|
679
|
-
}, (_e = context.attrs.style) != null ? _e : {});
|
|
680
|
-
}
|
|
681
|
-
return __spreadValues({
|
|
682
|
-
"--icon-url": `url('${icon}')`,
|
|
683
|
-
"mask": "var(--icon-url) no-repeat",
|
|
684
|
-
"mask-size": "100% 100%",
|
|
685
|
-
"-webkit-mask": "var(--icon-url) no-repeat",
|
|
686
|
-
"-webkit-mask-size": "100% 100%",
|
|
687
|
-
"background-color": color,
|
|
688
|
-
"display": "inline-block",
|
|
689
|
-
"width": width,
|
|
690
|
-
"height": height
|
|
691
|
-
}, (_f = context.attrs.style) != null ? _f : {});
|
|
692
|
-
});
|
|
693
|
-
return {
|
|
694
|
-
style
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
const HiIcon = vue.defineComponent({
|
|
699
|
-
props: __spreadProps(__spreadValues({}, iconProps), {
|
|
700
|
-
tag: {
|
|
701
|
-
type: String,
|
|
702
|
-
default: "i"
|
|
703
|
-
}
|
|
704
|
-
}),
|
|
705
|
-
setup(props, context) {
|
|
706
|
-
const { style } = useIcon(props, context);
|
|
707
|
-
return () => {
|
|
708
|
-
return vue.h(props.tag, {
|
|
709
|
-
style: style.value
|
|
710
|
-
});
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
exports.HiIcon = HiIcon;
|
|
716
|
-
exports.HiItem = HiItem;
|
|
717
|
-
exports.HiSelection = HiSelection;
|
|
718
|
-
exports.HiSwitch = HiSwitch;
|
|
719
|
-
exports.defineHookComponent = defineHookComponent;
|
|
720
|
-
exports.defineHookEmits = defineHookEmits;
|
|
721
|
-
exports.defineHookProps = defineHookProps;
|
|
722
|
-
exports.iconProps = iconProps;
|
|
723
|
-
exports.isExtends = isExtends;
|
|
724
|
-
exports.selectionItemProps = selectionItemProps;
|
|
725
|
-
exports.selectionListEmits = selectionListEmits;
|
|
726
|
-
exports.selectionListProps = selectionListProps;
|
|
727
|
-
exports.switchEmits = switchEmits;
|
|
728
|
-
exports.switchProps = switchProps;
|
|
729
|
-
exports.useIcon = useIcon;
|
|
730
|
-
exports.useSelectionItem = useSelectionItem;
|
|
731
|
-
exports.useSelectionList = useSelectionList;
|
|
732
|
-
exports.useSwitch = useSwitch;
|