hoci 0.0.3 → 0.0.5
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 +27 -12
- package/dist/index.d.ts +15 -2
- package/dist/{index.mjs → index.esm.js} +28 -14
- package/package.json +12 -5
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,8 @@ const useSelectionItem = defineHookComponent({
|
|
|
56
56
|
const parentLabel = core.resolveRef(vue.inject(ItemLabelSymbol));
|
|
57
57
|
function render() {
|
|
58
58
|
return vue.renderSlot(slots, "default", {}, () => {
|
|
59
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
let label = (_a = props.label) != null ? _a : parentLabel.value;
|
|
60
61
|
if (label) {
|
|
61
62
|
if (typeof label == "function") {
|
|
62
63
|
label = label(props.value);
|
|
@@ -86,14 +87,22 @@ const useSelectionItem = defineHookComponent({
|
|
|
86
87
|
}
|
|
87
88
|
const isActive = vue.inject(IsActiveSymbol, () => false);
|
|
88
89
|
const changeActive = vue.inject(ChangeActiveSymbol, () => false);
|
|
89
|
-
const activeClass = vue.computed(() =>
|
|
90
|
-
|
|
90
|
+
const activeClass = vue.computed(() => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return (_b = (_a = vue.inject(ActiveClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "active";
|
|
93
|
+
});
|
|
94
|
+
const unactiveClass = vue.computed(() => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return (_b = (_a = vue.inject(UnactiveSymbol)) == null ? void 0 : _a.value) != null ? _b : "unactive";
|
|
97
|
+
});
|
|
91
98
|
const itemClass = vue.computed(() => {
|
|
92
|
-
|
|
99
|
+
var _a, _b;
|
|
100
|
+
return [(_b = (_a = vue.inject(ItemClassSymbol)) == null ? void 0 : _a.value) != null ? _b : ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
|
|
93
101
|
});
|
|
94
102
|
const activateEvent = core.resolveRef(() => {
|
|
103
|
+
var _a, _b;
|
|
95
104
|
const event = vue.inject(ActivateEventSymbol);
|
|
96
|
-
return props.activateEvent
|
|
105
|
+
return (_b = (_a = props.activateEvent) != null ? _a : event == null ? void 0 : event.value) != null ? _b : "click";
|
|
97
106
|
});
|
|
98
107
|
return {
|
|
99
108
|
activate() {
|
|
@@ -126,11 +135,12 @@ const selectionListProps = defineHookProps({
|
|
|
126
135
|
default: "div"
|
|
127
136
|
},
|
|
128
137
|
modelValue: {
|
|
129
|
-
type: valuePropType
|
|
138
|
+
type: valuePropType,
|
|
139
|
+
default: () => null
|
|
130
140
|
},
|
|
131
141
|
activeClass: {
|
|
132
142
|
type: classPropType,
|
|
133
|
-
default: ""
|
|
143
|
+
default: "active"
|
|
134
144
|
},
|
|
135
145
|
itemClass: {
|
|
136
146
|
type: classPropType,
|
|
@@ -151,7 +161,8 @@ const selectionListProps = defineHookProps({
|
|
|
151
161
|
type: Boolean
|
|
152
162
|
},
|
|
153
163
|
defaultValue: {
|
|
154
|
-
type: valuePropType
|
|
164
|
+
type: valuePropType,
|
|
165
|
+
default: () => null
|
|
155
166
|
},
|
|
156
167
|
activateEvent: {
|
|
157
168
|
type: String,
|
|
@@ -163,9 +174,10 @@ const useSelectionList = defineHookComponent({
|
|
|
163
174
|
props: selectionListProps,
|
|
164
175
|
emits: selectionListEmits,
|
|
165
176
|
setup(props, { slots, emit }) {
|
|
177
|
+
var _a;
|
|
166
178
|
const options = vue.reactive([]);
|
|
167
179
|
function toArray(value) {
|
|
168
|
-
if (value
|
|
180
|
+
if (!core.isDefined(value)) {
|
|
169
181
|
return [];
|
|
170
182
|
}
|
|
171
183
|
if (props.multiple && Array.isArray(value)) {
|
|
@@ -173,7 +185,7 @@ const useSelectionList = defineHookComponent({
|
|
|
173
185
|
}
|
|
174
186
|
return [value];
|
|
175
187
|
}
|
|
176
|
-
const actives = vue.reactive([...toArray(props.modelValue
|
|
188
|
+
const actives = vue.reactive([...toArray((_a = props.modelValue) != null ? _a : props.defaultValue)]);
|
|
177
189
|
const currentValue = vue.computed({
|
|
178
190
|
get() {
|
|
179
191
|
return props.multiple ? actives : actives[0];
|
|
@@ -188,7 +200,8 @@ const useSelectionList = defineHookComponent({
|
|
|
188
200
|
});
|
|
189
201
|
const modelValue = vue.computed({
|
|
190
202
|
get() {
|
|
191
|
-
|
|
203
|
+
var _a2;
|
|
204
|
+
return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
|
|
192
205
|
},
|
|
193
206
|
set(val) {
|
|
194
207
|
emit("update:modelValue", val);
|
|
@@ -316,7 +329,8 @@ const useSwitch = defineHookComponent({
|
|
|
316
329
|
);
|
|
317
330
|
const modelValue = vue.computed({
|
|
318
331
|
get() {
|
|
319
|
-
|
|
332
|
+
var _a;
|
|
333
|
+
return !!((_a = props.modelValue) != null ? _a : checked.value);
|
|
320
334
|
},
|
|
321
335
|
set(val) {
|
|
322
336
|
checked.value = val;
|
|
@@ -366,6 +380,7 @@ exports.defineHookProps = defineHookProps;
|
|
|
366
380
|
exports.selectionItemProps = selectionItemProps;
|
|
367
381
|
exports.selectionListEmits = selectionListEmits;
|
|
368
382
|
exports.selectionListProps = selectionListProps;
|
|
383
|
+
exports.switchEmits = switchEmits;
|
|
369
384
|
exports.switchProps = switchProps;
|
|
370
385
|
exports.useSelectionItem = useSelectionItem;
|
|
371
386
|
exports.useSelectionList = useSelectionList;
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ declare const selectionListProps: {
|
|
|
132
132
|
};
|
|
133
133
|
modelValue: {
|
|
134
134
|
type: PropType<any>;
|
|
135
|
+
default: () => null;
|
|
135
136
|
};
|
|
136
137
|
/**
|
|
137
138
|
* 选中时的 class
|
|
@@ -169,6 +170,7 @@ declare const selectionListProps: {
|
|
|
169
170
|
};
|
|
170
171
|
defaultValue: {
|
|
171
172
|
type: PropType<any>;
|
|
173
|
+
default: () => null;
|
|
172
174
|
};
|
|
173
175
|
activateEvent: {
|
|
174
176
|
type: PropType<ActivateEvent>;
|
|
@@ -197,6 +199,7 @@ declare const useSelectionList: HookComponent<{
|
|
|
197
199
|
};
|
|
198
200
|
modelValue: {
|
|
199
201
|
type: PropType<any>;
|
|
202
|
+
default: () => null;
|
|
200
203
|
};
|
|
201
204
|
/**
|
|
202
205
|
* 选中时的 class
|
|
@@ -234,6 +237,7 @@ declare const useSelectionList: HookComponent<{
|
|
|
234
237
|
};
|
|
235
238
|
defaultValue: {
|
|
236
239
|
type: PropType<any>;
|
|
240
|
+
default: () => null;
|
|
237
241
|
};
|
|
238
242
|
activateEvent: {
|
|
239
243
|
type: PropType<ActivateEvent>;
|
|
@@ -246,6 +250,7 @@ declare const useSelectionList: HookComponent<{
|
|
|
246
250
|
};
|
|
247
251
|
modelValue: {
|
|
248
252
|
type: PropType<any>;
|
|
253
|
+
default: () => null;
|
|
249
254
|
};
|
|
250
255
|
/**
|
|
251
256
|
* 选中时的 class
|
|
@@ -283,6 +288,7 @@ declare const useSelectionList: HookComponent<{
|
|
|
283
288
|
};
|
|
284
289
|
defaultValue: {
|
|
285
290
|
type: PropType<any>;
|
|
291
|
+
default: () => null;
|
|
286
292
|
};
|
|
287
293
|
activateEvent: {
|
|
288
294
|
type: PropType<ActivateEvent>;
|
|
@@ -296,6 +302,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
296
302
|
};
|
|
297
303
|
modelValue: {
|
|
298
304
|
type: PropType<any>;
|
|
305
|
+
default: () => null;
|
|
299
306
|
};
|
|
300
307
|
/**
|
|
301
308
|
* 选中时的 class
|
|
@@ -333,6 +340,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
333
340
|
};
|
|
334
341
|
defaultValue: {
|
|
335
342
|
type: PropType<any>;
|
|
343
|
+
default: () => null;
|
|
336
344
|
};
|
|
337
345
|
activateEvent: {
|
|
338
346
|
type: PropType<ActivateEvent>;
|
|
@@ -347,6 +355,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
347
355
|
};
|
|
348
356
|
modelValue: {
|
|
349
357
|
type: PropType<any>;
|
|
358
|
+
default: () => null;
|
|
350
359
|
};
|
|
351
360
|
/**
|
|
352
361
|
* 选中时的 class
|
|
@@ -384,6 +393,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
384
393
|
};
|
|
385
394
|
defaultValue: {
|
|
386
395
|
type: PropType<any>;
|
|
396
|
+
default: () => null;
|
|
387
397
|
};
|
|
388
398
|
activateEvent: {
|
|
389
399
|
type: PropType<ActivateEvent>;
|
|
@@ -397,7 +407,9 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
397
407
|
}, {
|
|
398
408
|
activateEvent: ActivateEvent;
|
|
399
409
|
itemClass: string | string[];
|
|
410
|
+
modelValue: any;
|
|
400
411
|
multiple: number | boolean;
|
|
412
|
+
defaultValue: any;
|
|
401
413
|
tag: string;
|
|
402
414
|
activeClass: string | string[];
|
|
403
415
|
unactiveClass: string | string[];
|
|
@@ -430,6 +442,7 @@ declare const switchProps: {
|
|
|
430
442
|
default: string;
|
|
431
443
|
};
|
|
432
444
|
};
|
|
445
|
+
declare const switchEmits: ("update:modelValue" | "change")[];
|
|
433
446
|
declare const useSwitch: HookComponent<{
|
|
434
447
|
toggle: (value?: any) => void;
|
|
435
448
|
modelValue: vue.WritableComputedRef<boolean>;
|
|
@@ -543,10 +556,10 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
543
556
|
}, {
|
|
544
557
|
activateEvent: ActivateEvent;
|
|
545
558
|
class: string | string[];
|
|
546
|
-
tag: string;
|
|
547
559
|
modelValue: boolean;
|
|
560
|
+
tag: string;
|
|
548
561
|
activeClass: string | string[];
|
|
549
562
|
unactiveClass: string | string[];
|
|
550
563
|
}>;
|
|
551
564
|
|
|
552
|
-
export { HiItem, HiSelection, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchProps, useSelectionItem, useSelectionList, useSwitch };
|
|
565
|
+
export { HiItem, HiSelection, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reactiveComputed, resolveRef, syncRef } from '@vueuse/core';
|
|
1
|
+
import { reactiveComputed, resolveRef, syncRef, isDefined } from '@vueuse/core';
|
|
2
2
|
import { defineComponent, h, capitalize, inject, watch, onDeactivated, computed, renderSlot, reactive, provide, ref } from 'vue';
|
|
3
3
|
|
|
4
4
|
function defineHookProps(props) {
|
|
@@ -54,7 +54,8 @@ const useSelectionItem = defineHookComponent({
|
|
|
54
54
|
const parentLabel = resolveRef(inject(ItemLabelSymbol));
|
|
55
55
|
function render() {
|
|
56
56
|
return renderSlot(slots, "default", {}, () => {
|
|
57
|
-
|
|
57
|
+
var _a;
|
|
58
|
+
let label = (_a = props.label) != null ? _a : parentLabel.value;
|
|
58
59
|
if (label) {
|
|
59
60
|
if (typeof label == "function") {
|
|
60
61
|
label = label(props.value);
|
|
@@ -84,14 +85,22 @@ const useSelectionItem = defineHookComponent({
|
|
|
84
85
|
}
|
|
85
86
|
const isActive = inject(IsActiveSymbol, () => false);
|
|
86
87
|
const changeActive = inject(ChangeActiveSymbol, () => false);
|
|
87
|
-
const activeClass = computed(() =>
|
|
88
|
-
|
|
88
|
+
const activeClass = computed(() => {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
return (_b = (_a = inject(ActiveClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "active";
|
|
91
|
+
});
|
|
92
|
+
const unactiveClass = computed(() => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
return (_b = (_a = inject(UnactiveSymbol)) == null ? void 0 : _a.value) != null ? _b : "unactive";
|
|
95
|
+
});
|
|
89
96
|
const itemClass = computed(() => {
|
|
90
|
-
|
|
97
|
+
var _a, _b;
|
|
98
|
+
return [(_b = (_a = inject(ItemClassSymbol)) == null ? void 0 : _a.value) != null ? _b : ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
|
|
91
99
|
});
|
|
92
100
|
const activateEvent = resolveRef(() => {
|
|
101
|
+
var _a, _b;
|
|
93
102
|
const event = inject(ActivateEventSymbol);
|
|
94
|
-
return props.activateEvent
|
|
103
|
+
return (_b = (_a = props.activateEvent) != null ? _a : event == null ? void 0 : event.value) != null ? _b : "click";
|
|
95
104
|
});
|
|
96
105
|
return {
|
|
97
106
|
activate() {
|
|
@@ -124,11 +133,12 @@ const selectionListProps = defineHookProps({
|
|
|
124
133
|
default: "div"
|
|
125
134
|
},
|
|
126
135
|
modelValue: {
|
|
127
|
-
type: valuePropType
|
|
136
|
+
type: valuePropType,
|
|
137
|
+
default: () => null
|
|
128
138
|
},
|
|
129
139
|
activeClass: {
|
|
130
140
|
type: classPropType,
|
|
131
|
-
default: ""
|
|
141
|
+
default: "active"
|
|
132
142
|
},
|
|
133
143
|
itemClass: {
|
|
134
144
|
type: classPropType,
|
|
@@ -149,7 +159,8 @@ const selectionListProps = defineHookProps({
|
|
|
149
159
|
type: Boolean
|
|
150
160
|
},
|
|
151
161
|
defaultValue: {
|
|
152
|
-
type: valuePropType
|
|
162
|
+
type: valuePropType,
|
|
163
|
+
default: () => null
|
|
153
164
|
},
|
|
154
165
|
activateEvent: {
|
|
155
166
|
type: String,
|
|
@@ -161,9 +172,10 @@ const useSelectionList = defineHookComponent({
|
|
|
161
172
|
props: selectionListProps,
|
|
162
173
|
emits: selectionListEmits,
|
|
163
174
|
setup(props, { slots, emit }) {
|
|
175
|
+
var _a;
|
|
164
176
|
const options = reactive([]);
|
|
165
177
|
function toArray(value) {
|
|
166
|
-
if (value
|
|
178
|
+
if (!isDefined(value)) {
|
|
167
179
|
return [];
|
|
168
180
|
}
|
|
169
181
|
if (props.multiple && Array.isArray(value)) {
|
|
@@ -171,7 +183,7 @@ const useSelectionList = defineHookComponent({
|
|
|
171
183
|
}
|
|
172
184
|
return [value];
|
|
173
185
|
}
|
|
174
|
-
const actives = reactive([...toArray(props.modelValue
|
|
186
|
+
const actives = reactive([...toArray((_a = props.modelValue) != null ? _a : props.defaultValue)]);
|
|
175
187
|
const currentValue = computed({
|
|
176
188
|
get() {
|
|
177
189
|
return props.multiple ? actives : actives[0];
|
|
@@ -186,7 +198,8 @@ const useSelectionList = defineHookComponent({
|
|
|
186
198
|
});
|
|
187
199
|
const modelValue = computed({
|
|
188
200
|
get() {
|
|
189
|
-
|
|
201
|
+
var _a2;
|
|
202
|
+
return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
|
|
190
203
|
},
|
|
191
204
|
set(val) {
|
|
192
205
|
emit("update:modelValue", val);
|
|
@@ -314,7 +327,8 @@ const useSwitch = defineHookComponent({
|
|
|
314
327
|
);
|
|
315
328
|
const modelValue = computed({
|
|
316
329
|
get() {
|
|
317
|
-
|
|
330
|
+
var _a;
|
|
331
|
+
return !!((_a = props.modelValue) != null ? _a : checked.value);
|
|
318
332
|
},
|
|
319
333
|
set(val) {
|
|
320
334
|
checked.value = val;
|
|
@@ -355,4 +369,4 @@ const HiSwitch = defineComponent({
|
|
|
355
369
|
}
|
|
356
370
|
});
|
|
357
371
|
|
|
358
|
-
export { HiItem, HiSelection, HiSwitch, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchProps, useSelectionItem, useSelectionList, useSwitch };
|
|
372
|
+
export { HiItem, HiSelection, HiSwitch, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
|
package/package.json
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hoci",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
|
-
"module": "dist/index.
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/"
|
|
10
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.esm.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
11
18
|
"author": "chizuki",
|
|
12
19
|
"license": "MIT",
|
|
13
20
|
"dependencies": {
|
|
14
|
-
"@vueuse/core": "^9.
|
|
21
|
+
"@vueuse/core": "^9.1.0",
|
|
15
22
|
"maybe-types": "^0.0.3"
|
|
16
23
|
},
|
|
17
|
-
"
|
|
18
|
-
"vue": "^3.2.
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"vue": "^3.2.31"
|
|
19
26
|
},
|
|
20
27
|
"scripts": {
|
|
21
28
|
"build": "unbuild",
|