@hoci/components 0.5.6 → 0.5.7
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 +23 -7
- package/dist/index.d.cts +12 -6
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.mjs +24 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ const HiItem = vue.defineComponent({
|
|
|
53
53
|
default: "div"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
+
emits: core.itemEmits,
|
|
56
57
|
setup(props, context) {
|
|
57
58
|
const { render, activate, className, isDisabled, activateEvent } = core.useSelectionItem(
|
|
58
59
|
props,
|
|
@@ -191,15 +192,20 @@ const selectionEmits = shared.defineHookEmits([
|
|
|
191
192
|
"update:modelValue",
|
|
192
193
|
"change",
|
|
193
194
|
"load",
|
|
194
|
-
"unload"
|
|
195
|
+
"unload",
|
|
196
|
+
"reject"
|
|
195
197
|
]);
|
|
196
198
|
const HiSelectionContextSymbol = Symbol("[hi-selection]context");
|
|
197
199
|
function useSelectionContext() {
|
|
198
200
|
const sharedConfig = shared.useSharedConfig();
|
|
199
201
|
return vue.inject(HiSelectionContextSymbol, {
|
|
200
202
|
isActive: () => false,
|
|
203
|
+
activate: () => {
|
|
204
|
+
},
|
|
201
205
|
changeActive: () => {
|
|
202
206
|
},
|
|
207
|
+
reject: () => {
|
|
208
|
+
},
|
|
203
209
|
activeClass: "active",
|
|
204
210
|
unactiveClass: "unactive",
|
|
205
211
|
disabledClass: "disabled",
|
|
@@ -247,7 +253,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
247
253
|
function isActive(value) {
|
|
248
254
|
return actives.includes(value);
|
|
249
255
|
}
|
|
250
|
-
function
|
|
256
|
+
function activate(value) {
|
|
251
257
|
if (isActive(value)) {
|
|
252
258
|
if (props.multiple || props.clearable) {
|
|
253
259
|
actives.splice(actives.indexOf(value), 1);
|
|
@@ -266,6 +272,9 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
266
272
|
}
|
|
267
273
|
}
|
|
268
274
|
}
|
|
275
|
+
function reject(value) {
|
|
276
|
+
emit("reject", value);
|
|
277
|
+
}
|
|
269
278
|
const init = (option) => {
|
|
270
279
|
function remove() {
|
|
271
280
|
const index = options.findIndex((e) => e.id === option.id);
|
|
@@ -296,8 +305,10 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
296
305
|
defaultValue: vue.computed(() => props.defaultValue),
|
|
297
306
|
activateEvent: vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent),
|
|
298
307
|
active: currentValue,
|
|
299
|
-
|
|
308
|
+
activate,
|
|
309
|
+
changeActive: activate,
|
|
300
310
|
isActive,
|
|
311
|
+
reject,
|
|
301
312
|
init
|
|
302
313
|
}));
|
|
303
314
|
const renderItem = () => {
|
|
@@ -306,7 +317,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
306
317
|
};
|
|
307
318
|
const slotData = {
|
|
308
319
|
isActive,
|
|
309
|
-
changeActive,
|
|
320
|
+
changeActive: activate,
|
|
310
321
|
renderItem
|
|
311
322
|
};
|
|
312
323
|
const render = () => {
|
|
@@ -316,7 +327,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
316
327
|
options,
|
|
317
328
|
actives,
|
|
318
329
|
isActive,
|
|
319
|
-
changeActive,
|
|
330
|
+
changeActive: activate,
|
|
320
331
|
renderItem,
|
|
321
332
|
render
|
|
322
333
|
};
|
|
@@ -402,15 +413,19 @@ const itemProps = shared.defineHookProps({
|
|
|
402
413
|
default: false
|
|
403
414
|
}
|
|
404
415
|
});
|
|
416
|
+
const itemEmits = shared.defineHookEmits(["reject"]);
|
|
405
417
|
const useSelectionItem = shared.defineHookComponent({
|
|
406
418
|
props: itemProps,
|
|
407
|
-
|
|
419
|
+
emits: itemEmits,
|
|
420
|
+
setup(props, { slots, emit }) {
|
|
408
421
|
const context = useSelectionContext();
|
|
409
422
|
const activate = () => {
|
|
410
423
|
if (props.disabled) {
|
|
424
|
+
emit("reject", props.value);
|
|
425
|
+
context.reject(props.value);
|
|
411
426
|
return;
|
|
412
427
|
}
|
|
413
|
-
context.
|
|
428
|
+
context.activate(props.value);
|
|
414
429
|
};
|
|
415
430
|
const label = vue.computed(() => {
|
|
416
431
|
let label2 = props.label ?? context.label;
|
|
@@ -472,6 +487,7 @@ const HiTabPane = vue.defineComponent({
|
|
|
472
487
|
props: {
|
|
473
488
|
...itemProps
|
|
474
489
|
},
|
|
490
|
+
emits: itemEmits,
|
|
475
491
|
setup(props, context) {
|
|
476
492
|
const { className, activateEvent, activate, isDisabled, label } = useSelectionItem(props, context);
|
|
477
493
|
return () => {
|
package/dist/index.d.cts
CHANGED
|
@@ -106,7 +106,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
106
106
|
};
|
|
107
107
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
108
108
|
[key: string]: any;
|
|
109
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue")[], "change" | "load" | "unload" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
109
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], "change" | "load" | "unload" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
110
110
|
as: {
|
|
111
111
|
type: StringConstructor;
|
|
112
112
|
default: string;
|
|
@@ -153,6 +153,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
153
153
|
onLoad?: ((...args: any[]) => any) | undefined;
|
|
154
154
|
onUnload?: ((...args: any[]) => any) | undefined;
|
|
155
155
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
156
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
156
157
|
}, {
|
|
157
158
|
multiple: number | boolean;
|
|
158
159
|
modelValue: any;
|
|
@@ -193,7 +194,7 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
193
194
|
};
|
|
194
195
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
195
196
|
[key: string]: any;
|
|
196
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
197
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
197
198
|
as: {
|
|
198
199
|
type: StringConstructor;
|
|
199
200
|
default: string;
|
|
@@ -219,7 +220,9 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
219
220
|
type: BooleanConstructor;
|
|
220
221
|
default: boolean;
|
|
221
222
|
};
|
|
222
|
-
}
|
|
223
|
+
}>> & {
|
|
224
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
225
|
+
}, {
|
|
223
226
|
value: any;
|
|
224
227
|
disabled: boolean;
|
|
225
228
|
keepAlive: boolean;
|
|
@@ -316,7 +319,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
316
319
|
};
|
|
317
320
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
318
321
|
[key: string]: any;
|
|
319
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
322
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue" | "reject")[], "change" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
320
323
|
as: {
|
|
321
324
|
type: StringConstructor;
|
|
322
325
|
default: string;
|
|
@@ -347,6 +350,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
347
350
|
}>> & {
|
|
348
351
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
349
352
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
353
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
350
354
|
}, {
|
|
351
355
|
disabled: boolean;
|
|
352
356
|
modelValue: boolean;
|
|
@@ -544,7 +548,7 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
544
548
|
};
|
|
545
549
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
546
550
|
[key: string]: any;
|
|
547
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
551
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
548
552
|
value: {
|
|
549
553
|
type: vue.PropType<any>;
|
|
550
554
|
default(): string;
|
|
@@ -566,7 +570,9 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
566
570
|
type: BooleanConstructor;
|
|
567
571
|
default: boolean;
|
|
568
572
|
};
|
|
569
|
-
}
|
|
573
|
+
}>> & {
|
|
574
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
575
|
+
}, {
|
|
570
576
|
value: any;
|
|
571
577
|
disabled: boolean;
|
|
572
578
|
keepAlive: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -106,7 +106,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
106
106
|
};
|
|
107
107
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
108
108
|
[key: string]: any;
|
|
109
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue")[], "change" | "load" | "unload" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
109
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], "change" | "load" | "unload" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
110
110
|
as: {
|
|
111
111
|
type: StringConstructor;
|
|
112
112
|
default: string;
|
|
@@ -153,6 +153,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
153
153
|
onLoad?: ((...args: any[]) => any) | undefined;
|
|
154
154
|
onUnload?: ((...args: any[]) => any) | undefined;
|
|
155
155
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
156
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
156
157
|
}, {
|
|
157
158
|
multiple: number | boolean;
|
|
158
159
|
modelValue: any;
|
|
@@ -193,7 +194,7 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
193
194
|
};
|
|
194
195
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
195
196
|
[key: string]: any;
|
|
196
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
197
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
197
198
|
as: {
|
|
198
199
|
type: StringConstructor;
|
|
199
200
|
default: string;
|
|
@@ -219,7 +220,9 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
219
220
|
type: BooleanConstructor;
|
|
220
221
|
default: boolean;
|
|
221
222
|
};
|
|
222
|
-
}
|
|
223
|
+
}>> & {
|
|
224
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
225
|
+
}, {
|
|
223
226
|
value: any;
|
|
224
227
|
disabled: boolean;
|
|
225
228
|
keepAlive: boolean;
|
|
@@ -316,7 +319,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
316
319
|
};
|
|
317
320
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
318
321
|
[key: string]: any;
|
|
319
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
322
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue" | "reject")[], "change" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
320
323
|
as: {
|
|
321
324
|
type: StringConstructor;
|
|
322
325
|
default: string;
|
|
@@ -347,6 +350,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
347
350
|
}>> & {
|
|
348
351
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
349
352
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
353
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
350
354
|
}, {
|
|
351
355
|
disabled: boolean;
|
|
352
356
|
modelValue: boolean;
|
|
@@ -544,7 +548,7 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
544
548
|
};
|
|
545
549
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
546
550
|
[key: string]: any;
|
|
547
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
551
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
548
552
|
value: {
|
|
549
553
|
type: vue.PropType<any>;
|
|
550
554
|
default(): string;
|
|
@@ -566,7 +570,9 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
566
570
|
type: BooleanConstructor;
|
|
567
571
|
default: boolean;
|
|
568
572
|
};
|
|
569
|
-
}
|
|
573
|
+
}>> & {
|
|
574
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
575
|
+
}, {
|
|
570
576
|
value: any;
|
|
571
577
|
disabled: boolean;
|
|
572
578
|
keepAlive: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
106
106
|
};
|
|
107
107
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
108
108
|
[key: string]: any;
|
|
109
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue")[], "change" | "load" | "unload" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
109
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], "change" | "load" | "unload" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
110
110
|
as: {
|
|
111
111
|
type: StringConstructor;
|
|
112
112
|
default: string;
|
|
@@ -153,6 +153,7 @@ declare const HiSelection: vue.DefineComponent<{
|
|
|
153
153
|
onLoad?: ((...args: any[]) => any) | undefined;
|
|
154
154
|
onUnload?: ((...args: any[]) => any) | undefined;
|
|
155
155
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
156
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
156
157
|
}, {
|
|
157
158
|
multiple: number | boolean;
|
|
158
159
|
modelValue: any;
|
|
@@ -193,7 +194,7 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
193
194
|
};
|
|
194
195
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
195
196
|
[key: string]: any;
|
|
196
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
197
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
197
198
|
as: {
|
|
198
199
|
type: StringConstructor;
|
|
199
200
|
default: string;
|
|
@@ -219,7 +220,9 @@ declare const HiItem: vue.DefineComponent<{
|
|
|
219
220
|
type: BooleanConstructor;
|
|
220
221
|
default: boolean;
|
|
221
222
|
};
|
|
222
|
-
}
|
|
223
|
+
}>> & {
|
|
224
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
225
|
+
}, {
|
|
223
226
|
value: any;
|
|
224
227
|
disabled: boolean;
|
|
225
228
|
keepAlive: boolean;
|
|
@@ -316,7 +319,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
316
319
|
};
|
|
317
320
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
318
321
|
[key: string]: any;
|
|
319
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
322
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:modelValue" | "reject")[], "change" | "update:modelValue" | "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
320
323
|
as: {
|
|
321
324
|
type: StringConstructor;
|
|
322
325
|
default: string;
|
|
@@ -347,6 +350,7 @@ declare const HiSwitch: vue.DefineComponent<{
|
|
|
347
350
|
}>> & {
|
|
348
351
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
349
352
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
353
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
350
354
|
}, {
|
|
351
355
|
disabled: boolean;
|
|
352
356
|
modelValue: boolean;
|
|
@@ -544,7 +548,7 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
544
548
|
};
|
|
545
549
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
546
550
|
[key: string]: any;
|
|
547
|
-
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
551
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "reject"[], "reject", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
548
552
|
value: {
|
|
549
553
|
type: vue.PropType<any>;
|
|
550
554
|
default(): string;
|
|
@@ -566,7 +570,9 @@ declare const HiTabPane: vue.DefineComponent<{
|
|
|
566
570
|
type: BooleanConstructor;
|
|
567
571
|
default: boolean;
|
|
568
572
|
};
|
|
569
|
-
}
|
|
573
|
+
}>> & {
|
|
574
|
+
onReject?: ((...args: any[]) => any) | undefined;
|
|
575
|
+
}, {
|
|
570
576
|
value: any;
|
|
571
577
|
disabled: boolean;
|
|
572
578
|
keepAlive: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h, renderSlot, reactive, computed, provide, inject, KeepAlive, watch, Teleport } from 'vue';
|
|
2
|
-
import { affixProps, useAffix, selectionProps as selectionProps$1, selectionEmits as selectionEmits$1, useSelectionList as useSelectionList$1, itemProps as itemProps$1, useSelectionItem as useSelectionItem$1, iconProps, useIcon, switchProps, switchEmits, useSwitch, configProviderProps, provideSharedConfig, popoverProps, popoverEmits, usePopover } from '@hoci/core';
|
|
2
|
+
import { affixProps, useAffix, selectionProps as selectionProps$1, selectionEmits as selectionEmits$1, useSelectionList as useSelectionList$1, itemProps as itemProps$1, itemEmits as itemEmits$1, useSelectionItem as useSelectionItem$1, iconProps, useIcon, switchProps, switchEmits, useSwitch, configProviderProps, provideSharedConfig, popoverProps, popoverEmits, usePopover } from '@hoci/core';
|
|
3
3
|
import { capitalize, cls } from 'tslx';
|
|
4
4
|
import { defineHookProps, valuePropType, classPropType, labelPropType, defineHookEmits, defineHookComponent, useSharedConfig, toReactive, getFirstChilld } from '@hoci/shared';
|
|
5
5
|
import { syncRef, isDefined, tryOnScopeDispose } from '@vueuse/core';
|
|
@@ -51,6 +51,7 @@ const HiItem = defineComponent({
|
|
|
51
51
|
default: "div"
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
+
emits: itemEmits$1,
|
|
54
55
|
setup(props, context) {
|
|
55
56
|
const { render, activate, className, isDisabled, activateEvent } = useSelectionItem$1(
|
|
56
57
|
props,
|
|
@@ -189,15 +190,20 @@ const selectionEmits = defineHookEmits([
|
|
|
189
190
|
"update:modelValue",
|
|
190
191
|
"change",
|
|
191
192
|
"load",
|
|
192
|
-
"unload"
|
|
193
|
+
"unload",
|
|
194
|
+
"reject"
|
|
193
195
|
]);
|
|
194
196
|
const HiSelectionContextSymbol = Symbol("[hi-selection]context");
|
|
195
197
|
function useSelectionContext() {
|
|
196
198
|
const sharedConfig = useSharedConfig();
|
|
197
199
|
return inject(HiSelectionContextSymbol, {
|
|
198
200
|
isActive: () => false,
|
|
201
|
+
activate: () => {
|
|
202
|
+
},
|
|
199
203
|
changeActive: () => {
|
|
200
204
|
},
|
|
205
|
+
reject: () => {
|
|
206
|
+
},
|
|
201
207
|
activeClass: "active",
|
|
202
208
|
unactiveClass: "unactive",
|
|
203
209
|
disabledClass: "disabled",
|
|
@@ -245,7 +251,7 @@ const useSelectionList = defineHookComponent({
|
|
|
245
251
|
function isActive(value) {
|
|
246
252
|
return actives.includes(value);
|
|
247
253
|
}
|
|
248
|
-
function
|
|
254
|
+
function activate(value) {
|
|
249
255
|
if (isActive(value)) {
|
|
250
256
|
if (props.multiple || props.clearable) {
|
|
251
257
|
actives.splice(actives.indexOf(value), 1);
|
|
@@ -264,6 +270,9 @@ const useSelectionList = defineHookComponent({
|
|
|
264
270
|
}
|
|
265
271
|
}
|
|
266
272
|
}
|
|
273
|
+
function reject(value) {
|
|
274
|
+
emit("reject", value);
|
|
275
|
+
}
|
|
267
276
|
const init = (option) => {
|
|
268
277
|
function remove() {
|
|
269
278
|
const index = options.findIndex((e) => e.id === option.id);
|
|
@@ -294,8 +303,10 @@ const useSelectionList = defineHookComponent({
|
|
|
294
303
|
defaultValue: computed(() => props.defaultValue),
|
|
295
304
|
activateEvent: computed(() => props.activateEvent ?? sharedConfig.activateEvent),
|
|
296
305
|
active: currentValue,
|
|
297
|
-
|
|
306
|
+
activate,
|
|
307
|
+
changeActive: activate,
|
|
298
308
|
isActive,
|
|
309
|
+
reject,
|
|
299
310
|
init
|
|
300
311
|
}));
|
|
301
312
|
const renderItem = () => {
|
|
@@ -304,7 +315,7 @@ const useSelectionList = defineHookComponent({
|
|
|
304
315
|
};
|
|
305
316
|
const slotData = {
|
|
306
317
|
isActive,
|
|
307
|
-
changeActive,
|
|
318
|
+
changeActive: activate,
|
|
308
319
|
renderItem
|
|
309
320
|
};
|
|
310
321
|
const render = () => {
|
|
@@ -314,7 +325,7 @@ const useSelectionList = defineHookComponent({
|
|
|
314
325
|
options,
|
|
315
326
|
actives,
|
|
316
327
|
isActive,
|
|
317
|
-
changeActive,
|
|
328
|
+
changeActive: activate,
|
|
318
329
|
renderItem,
|
|
319
330
|
render
|
|
320
331
|
};
|
|
@@ -400,15 +411,19 @@ const itemProps = defineHookProps({
|
|
|
400
411
|
default: false
|
|
401
412
|
}
|
|
402
413
|
});
|
|
414
|
+
const itemEmits = defineHookEmits(["reject"]);
|
|
403
415
|
const useSelectionItem = defineHookComponent({
|
|
404
416
|
props: itemProps,
|
|
405
|
-
|
|
417
|
+
emits: itemEmits,
|
|
418
|
+
setup(props, { slots, emit }) {
|
|
406
419
|
const context = useSelectionContext();
|
|
407
420
|
const activate = () => {
|
|
408
421
|
if (props.disabled) {
|
|
422
|
+
emit("reject", props.value);
|
|
423
|
+
context.reject(props.value);
|
|
409
424
|
return;
|
|
410
425
|
}
|
|
411
|
-
context.
|
|
426
|
+
context.activate(props.value);
|
|
412
427
|
};
|
|
413
428
|
const label = computed(() => {
|
|
414
429
|
let label2 = props.label ?? context.label;
|
|
@@ -470,6 +485,7 @@ const HiTabPane = defineComponent({
|
|
|
470
485
|
props: {
|
|
471
486
|
...itemProps
|
|
472
487
|
},
|
|
488
|
+
emits: itemEmits,
|
|
473
489
|
setup(props, context) {
|
|
474
490
|
const { className, activateEvent, activate, isDisabled, label } = useSelectionItem(props, context);
|
|
475
491
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoci/components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Chizuki <chizukicn@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"maybe-types": "^0.2.0",
|
|
33
33
|
"tslx": "^0.1.1",
|
|
34
|
-
"@hoci/core": "0.5.
|
|
35
|
-
"@hoci/shared": "0.5.
|
|
34
|
+
"@hoci/core": "0.5.7",
|
|
35
|
+
"@hoci/shared": "0.5.7"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild",
|