@hoci/core 0.5.0 → 0.5.1
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 +249 -5
- package/dist/index.d.cts +150 -4
- package/dist/index.d.mts +150 -4
- package/dist/index.d.ts +150 -4
- package/dist/index.mjs +249 -9
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -298,7 +298,7 @@ const useSelectionList = shared.defineHookComponent({
|
|
|
298
298
|
}));
|
|
299
299
|
const renderItem = () => {
|
|
300
300
|
const children = options.filter((e) => actives.includes(e.value)).map((e) => e.render());
|
|
301
|
-
return props.multiple ? children : children
|
|
301
|
+
return props.multiple ? children : shared.getFirstChilld(children);
|
|
302
302
|
};
|
|
303
303
|
const slotData = {
|
|
304
304
|
isActive,
|
|
@@ -362,12 +362,10 @@ const useSelectionItem = shared.defineHookComponent({
|
|
|
362
362
|
return Array.isArray(label2) ? label2 : [label2];
|
|
363
363
|
});
|
|
364
364
|
function render() {
|
|
365
|
-
return
|
|
365
|
+
return slots.default?.({
|
|
366
366
|
active: context.isActive(props.value),
|
|
367
367
|
activate
|
|
368
|
-
}
|
|
369
|
-
return label.value;
|
|
370
|
-
});
|
|
368
|
+
}) ?? label.value.filter(Boolean);
|
|
371
369
|
}
|
|
372
370
|
let remove = () => {
|
|
373
371
|
};
|
|
@@ -556,11 +554,256 @@ const useIcon = shared.defineHookComponent({
|
|
|
556
554
|
}
|
|
557
555
|
});
|
|
558
556
|
|
|
557
|
+
const configProviderProps = shared.defineHookProps({
|
|
558
|
+
icon: {
|
|
559
|
+
type: Object
|
|
560
|
+
},
|
|
561
|
+
activateEvent: {
|
|
562
|
+
type: String
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
const popoverProps = shared.defineHookProps({
|
|
567
|
+
popupClass: {
|
|
568
|
+
type: String
|
|
569
|
+
},
|
|
570
|
+
placement: {
|
|
571
|
+
type: String,
|
|
572
|
+
default: () => "auto"
|
|
573
|
+
},
|
|
574
|
+
triggerEvent: {
|
|
575
|
+
type: String,
|
|
576
|
+
default: () => "hover"
|
|
577
|
+
},
|
|
578
|
+
offset: {
|
|
579
|
+
type: Number,
|
|
580
|
+
default: () => 8
|
|
581
|
+
},
|
|
582
|
+
lazy: {
|
|
583
|
+
type: Boolean,
|
|
584
|
+
default: () => false
|
|
585
|
+
},
|
|
586
|
+
visible: {
|
|
587
|
+
type: Boolean,
|
|
588
|
+
default: () => false
|
|
589
|
+
},
|
|
590
|
+
disabled: {
|
|
591
|
+
type: Boolean,
|
|
592
|
+
default: () => false
|
|
593
|
+
},
|
|
594
|
+
teleport: {
|
|
595
|
+
type: [String, Object, Boolean],
|
|
596
|
+
default: () => true
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
const popoverEmits = shared.defineHookEmits(["update:visible", "change"]);
|
|
600
|
+
const usePopover = shared.defineHookComponent({
|
|
601
|
+
props: popoverProps,
|
|
602
|
+
emits: popoverEmits,
|
|
603
|
+
setup(props, context) {
|
|
604
|
+
const visible = core.useVModel(props, "visible", context.emit, {
|
|
605
|
+
passive: true
|
|
606
|
+
});
|
|
607
|
+
const triggerRef = vue.ref();
|
|
608
|
+
const popupRef = vue.ref();
|
|
609
|
+
const validate = (event) => {
|
|
610
|
+
const events2 = Array.isArray(event) ? event : [event];
|
|
611
|
+
return !props.disabled && events2.includes(props.triggerEvent);
|
|
612
|
+
};
|
|
613
|
+
let timer;
|
|
614
|
+
const toggle = (_value) => {
|
|
615
|
+
const value = _value ?? !visible.value;
|
|
616
|
+
visible.value = value;
|
|
617
|
+
context.emit("change", value);
|
|
618
|
+
};
|
|
619
|
+
function onMouseover() {
|
|
620
|
+
if (!validate("hover")) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
timer = setTimeout(
|
|
624
|
+
() => {
|
|
625
|
+
toggle(true);
|
|
626
|
+
},
|
|
627
|
+
props.lazy ? 800 : 100
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
function onMouseout() {
|
|
631
|
+
if (!validate("hover")) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
clearTimeout(timer);
|
|
635
|
+
toggle(false);
|
|
636
|
+
}
|
|
637
|
+
const onClick = (e) => {
|
|
638
|
+
if (!validate("click")) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
e.preventDefault();
|
|
642
|
+
e.stopPropagation();
|
|
643
|
+
toggle();
|
|
644
|
+
};
|
|
645
|
+
core.onClickOutside(triggerRef, () => {
|
|
646
|
+
if (!validate(["click", "contextmenu", "touch", "dblclick", "mousedown"])) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
toggle(false);
|
|
650
|
+
}, {
|
|
651
|
+
ignore: [popupRef]
|
|
652
|
+
});
|
|
653
|
+
const onContextmenu = (e) => {
|
|
654
|
+
if (!validate("contextmenu")) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
e.preventDefault();
|
|
658
|
+
e.stopPropagation();
|
|
659
|
+
toggle();
|
|
660
|
+
};
|
|
661
|
+
const onFocusin = () => {
|
|
662
|
+
if (!validate("focus")) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
toggle(true);
|
|
666
|
+
};
|
|
667
|
+
const onFocusout = () => {
|
|
668
|
+
if (!validate("focus")) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
toggle(false);
|
|
672
|
+
};
|
|
673
|
+
const onTouchend = () => {
|
|
674
|
+
if (!validate("touch")) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
toggle(true);
|
|
678
|
+
};
|
|
679
|
+
const onDblclick = () => {
|
|
680
|
+
if (!validate("dblclick")) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
toggle(true);
|
|
684
|
+
};
|
|
685
|
+
const onMousedown = () => {
|
|
686
|
+
if (!validate("mousedown")) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
toggle(true);
|
|
690
|
+
};
|
|
691
|
+
const onMouseup = () => {
|
|
692
|
+
if (!validate("mousedown")) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
toggle(false);
|
|
696
|
+
};
|
|
697
|
+
const events = {
|
|
698
|
+
onMouseover,
|
|
699
|
+
onMouseout,
|
|
700
|
+
onMousedown,
|
|
701
|
+
onMouseup,
|
|
702
|
+
onContextmenu,
|
|
703
|
+
onClick,
|
|
704
|
+
onDblclick,
|
|
705
|
+
onFocusin,
|
|
706
|
+
onFocusout,
|
|
707
|
+
onTouchend
|
|
708
|
+
};
|
|
709
|
+
const dropdownPosition = vue.reactive({ x: 0, y: 0 });
|
|
710
|
+
const popupClass = vue.computed(() => {
|
|
711
|
+
return props.popupClass;
|
|
712
|
+
});
|
|
713
|
+
function resize() {
|
|
714
|
+
const trigger = triggerRef.value;
|
|
715
|
+
const popup = popupRef.value;
|
|
716
|
+
if (!!trigger && !!popup && visible.value) {
|
|
717
|
+
const { width, height, left, top } = trigger.getBoundingClientRect();
|
|
718
|
+
const { clientWidth: pWidth, clientHeight: pHeight } = popup;
|
|
719
|
+
let x = 0;
|
|
720
|
+
let y = 0;
|
|
721
|
+
const offset = props.offset;
|
|
722
|
+
switch (props.placement) {
|
|
723
|
+
case "auto":
|
|
724
|
+
case "bottom":
|
|
725
|
+
x = left - (pWidth - width) / 2;
|
|
726
|
+
y = top + height + offset;
|
|
727
|
+
break;
|
|
728
|
+
case "bottom-left":
|
|
729
|
+
x = left;
|
|
730
|
+
y = top + height + offset;
|
|
731
|
+
break;
|
|
732
|
+
case "bottom-right":
|
|
733
|
+
x = left + width - pWidth;
|
|
734
|
+
y = top + height + offset;
|
|
735
|
+
break;
|
|
736
|
+
case "top":
|
|
737
|
+
x = left - (pWidth - width) / 2;
|
|
738
|
+
y = top - pHeight - offset;
|
|
739
|
+
break;
|
|
740
|
+
case "top-left":
|
|
741
|
+
x = left;
|
|
742
|
+
y = top - pHeight - offset;
|
|
743
|
+
break;
|
|
744
|
+
case "top-right":
|
|
745
|
+
x = left + width - pWidth;
|
|
746
|
+
y = top - pHeight - offset;
|
|
747
|
+
break;
|
|
748
|
+
case "left":
|
|
749
|
+
x = left - pWidth - offset;
|
|
750
|
+
y = top - (pHeight - height) / 2;
|
|
751
|
+
break;
|
|
752
|
+
case "left-top":
|
|
753
|
+
x = left - pWidth - offset;
|
|
754
|
+
y = top;
|
|
755
|
+
break;
|
|
756
|
+
case "left-bottom":
|
|
757
|
+
x = left - pWidth - offset;
|
|
758
|
+
y = top + height - pHeight;
|
|
759
|
+
break;
|
|
760
|
+
case "right":
|
|
761
|
+
x = left + width + offset;
|
|
762
|
+
y = top - (pHeight - height) / 2;
|
|
763
|
+
break;
|
|
764
|
+
case "right-top":
|
|
765
|
+
x = left + width + offset;
|
|
766
|
+
y = top;
|
|
767
|
+
break;
|
|
768
|
+
case "right-bottom":
|
|
769
|
+
x = left + width + offset;
|
|
770
|
+
y = top + height - pHeight;
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
dropdownPosition.x = x;
|
|
774
|
+
dropdownPosition.y = y;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
vue.watch(visible, () => {
|
|
778
|
+
vue.nextTick(resize);
|
|
779
|
+
});
|
|
780
|
+
const popupStyle = vue.computed(() => {
|
|
781
|
+
return {
|
|
782
|
+
left: tslx.px(dropdownPosition.x),
|
|
783
|
+
top: tslx.px(dropdownPosition.y),
|
|
784
|
+
visibility: visible.value ? "visible" : "hidden",
|
|
785
|
+
position: "fixed"
|
|
786
|
+
};
|
|
787
|
+
});
|
|
788
|
+
return {
|
|
789
|
+
events,
|
|
790
|
+
dropdownPosition,
|
|
791
|
+
triggerRef,
|
|
792
|
+
popupRef,
|
|
793
|
+
popupClass,
|
|
794
|
+
popupStyle
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
|
|
559
799
|
exports.AFFIX_TARGET_KEY = AFFIX_TARGET_KEY;
|
|
560
800
|
exports.affixEmits = affixEmits;
|
|
561
801
|
exports.affixProps = affixProps;
|
|
802
|
+
exports.configProviderProps = configProviderProps;
|
|
562
803
|
exports.iconProps = iconProps;
|
|
563
804
|
exports.itemProps = itemProps;
|
|
805
|
+
exports.popoverEmits = popoverEmits;
|
|
806
|
+
exports.popoverProps = popoverProps;
|
|
564
807
|
exports.provideAffixTarget = provideAffixTarget;
|
|
565
808
|
exports.selectionEmits = selectionEmits;
|
|
566
809
|
exports.selectionProps = selectionProps;
|
|
@@ -568,6 +811,7 @@ exports.switchEmits = switchEmits;
|
|
|
568
811
|
exports.switchProps = switchProps;
|
|
569
812
|
exports.useAffix = useAffix;
|
|
570
813
|
exports.useIcon = useIcon;
|
|
814
|
+
exports.usePopover = usePopover;
|
|
571
815
|
exports.useSelectionContext = useSelectionContext;
|
|
572
816
|
exports.useSelectionItem = useSelectionItem;
|
|
573
817
|
exports.useSelectionList = useSelectionList;
|
package/dist/index.d.cts
CHANGED
|
@@ -358,9 +358,7 @@ declare const itemProps: {
|
|
|
358
358
|
};
|
|
359
359
|
declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
360
360
|
activate: () => void;
|
|
361
|
-
render: () =>
|
|
362
|
-
[key: string]: any;
|
|
363
|
-
}>;
|
|
361
|
+
render: () => ElementLike;
|
|
364
362
|
isActive: vue.ComputedRef<boolean>;
|
|
365
363
|
isDisabled: vue.ComputedRef<boolean>;
|
|
366
364
|
className: vue.ComputedRef<string>;
|
|
@@ -596,4 +594,152 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
596
594
|
color: string;
|
|
597
595
|
}>;
|
|
598
596
|
|
|
599
|
-
|
|
597
|
+
declare const configProviderProps: {
|
|
598
|
+
icon: {
|
|
599
|
+
type: PropType<Partial<{
|
|
600
|
+
size: number | undefined;
|
|
601
|
+
sizeUnit: string | undefined;
|
|
602
|
+
}>>;
|
|
603
|
+
};
|
|
604
|
+
activateEvent: {
|
|
605
|
+
type: PropType<Partial<_hoci_shared.ActivateEvent>>;
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
type Placement = "bottom" | "top" | "left" | "right" | "auto" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
|
|
610
|
+
type TriggerEvent = "click" | "mousedown" | "dblclick" | "hover" | "contextmenu" | "focus" | "touch";
|
|
611
|
+
declare const popoverProps: {
|
|
612
|
+
popupClass: {
|
|
613
|
+
type: StringConstructor;
|
|
614
|
+
};
|
|
615
|
+
placement: {
|
|
616
|
+
type: PropType<Placement>;
|
|
617
|
+
default: () => "auto";
|
|
618
|
+
};
|
|
619
|
+
triggerEvent: {
|
|
620
|
+
type: PropType<TriggerEvent>;
|
|
621
|
+
default: () => "hover";
|
|
622
|
+
};
|
|
623
|
+
offset: {
|
|
624
|
+
type: NumberConstructor;
|
|
625
|
+
default: () => 8;
|
|
626
|
+
};
|
|
627
|
+
lazy: {
|
|
628
|
+
type: BooleanConstructor;
|
|
629
|
+
default: () => false;
|
|
630
|
+
};
|
|
631
|
+
visible: {
|
|
632
|
+
type: BooleanConstructor;
|
|
633
|
+
default: () => false;
|
|
634
|
+
};
|
|
635
|
+
disabled: {
|
|
636
|
+
type: BooleanConstructor;
|
|
637
|
+
default: () => false;
|
|
638
|
+
};
|
|
639
|
+
teleport: {
|
|
640
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
641
|
+
default: () => true;
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
declare const popoverEmits: ("change" | "update:visible")[];
|
|
645
|
+
declare const usePopover: _hoci_shared.HookComponent<{
|
|
646
|
+
events: {
|
|
647
|
+
onMouseover: () => void;
|
|
648
|
+
onMouseout: () => void;
|
|
649
|
+
onMousedown: () => void;
|
|
650
|
+
onMouseup: () => void;
|
|
651
|
+
onContextmenu: (e: MouseEvent) => void;
|
|
652
|
+
onClick: (e: MouseEvent) => void;
|
|
653
|
+
onDblclick: () => void;
|
|
654
|
+
onFocusin: () => void;
|
|
655
|
+
onFocusout: () => void;
|
|
656
|
+
onTouchend: () => void;
|
|
657
|
+
};
|
|
658
|
+
dropdownPosition: {
|
|
659
|
+
x: number;
|
|
660
|
+
y: number;
|
|
661
|
+
};
|
|
662
|
+
triggerRef: vue.Ref<HTMLElement | undefined>;
|
|
663
|
+
popupRef: vue.Ref<HTMLElement | undefined>;
|
|
664
|
+
popupClass: vue.ComputedRef<string | undefined>;
|
|
665
|
+
popupStyle: vue.ComputedRef<{
|
|
666
|
+
left: string;
|
|
667
|
+
top: string;
|
|
668
|
+
visibility: string;
|
|
669
|
+
position: string;
|
|
670
|
+
}>;
|
|
671
|
+
}, ("change" | "update:visible")[], {
|
|
672
|
+
popupClass: {
|
|
673
|
+
type: StringConstructor;
|
|
674
|
+
};
|
|
675
|
+
placement: {
|
|
676
|
+
type: PropType<Placement>;
|
|
677
|
+
default: () => "auto";
|
|
678
|
+
};
|
|
679
|
+
triggerEvent: {
|
|
680
|
+
type: PropType<TriggerEvent>;
|
|
681
|
+
default: () => "hover";
|
|
682
|
+
};
|
|
683
|
+
offset: {
|
|
684
|
+
type: NumberConstructor;
|
|
685
|
+
default: () => 8;
|
|
686
|
+
};
|
|
687
|
+
lazy: {
|
|
688
|
+
type: BooleanConstructor;
|
|
689
|
+
default: () => false;
|
|
690
|
+
};
|
|
691
|
+
visible: {
|
|
692
|
+
type: BooleanConstructor;
|
|
693
|
+
default: () => false;
|
|
694
|
+
};
|
|
695
|
+
disabled: {
|
|
696
|
+
type: BooleanConstructor;
|
|
697
|
+
default: () => false;
|
|
698
|
+
};
|
|
699
|
+
teleport: {
|
|
700
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
701
|
+
default: () => true;
|
|
702
|
+
};
|
|
703
|
+
}, vue.ExtractPropTypes<{
|
|
704
|
+
popupClass: {
|
|
705
|
+
type: StringConstructor;
|
|
706
|
+
};
|
|
707
|
+
placement: {
|
|
708
|
+
type: PropType<Placement>;
|
|
709
|
+
default: () => "auto";
|
|
710
|
+
};
|
|
711
|
+
triggerEvent: {
|
|
712
|
+
type: PropType<TriggerEvent>;
|
|
713
|
+
default: () => "hover";
|
|
714
|
+
};
|
|
715
|
+
offset: {
|
|
716
|
+
type: NumberConstructor;
|
|
717
|
+
default: () => 8;
|
|
718
|
+
};
|
|
719
|
+
lazy: {
|
|
720
|
+
type: BooleanConstructor;
|
|
721
|
+
default: () => false;
|
|
722
|
+
};
|
|
723
|
+
visible: {
|
|
724
|
+
type: BooleanConstructor;
|
|
725
|
+
default: () => false;
|
|
726
|
+
};
|
|
727
|
+
disabled: {
|
|
728
|
+
type: BooleanConstructor;
|
|
729
|
+
default: () => false;
|
|
730
|
+
};
|
|
731
|
+
teleport: {
|
|
732
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
733
|
+
default: () => true;
|
|
734
|
+
};
|
|
735
|
+
}>, {
|
|
736
|
+
offset: number;
|
|
737
|
+
visible: boolean;
|
|
738
|
+
disabled: boolean;
|
|
739
|
+
placement: Placement;
|
|
740
|
+
triggerEvent: TriggerEvent;
|
|
741
|
+
lazy: boolean;
|
|
742
|
+
teleport: string | boolean | HTMLElement;
|
|
743
|
+
}>;
|
|
744
|
+
|
|
745
|
+
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.d.mts
CHANGED
|
@@ -358,9 +358,7 @@ declare const itemProps: {
|
|
|
358
358
|
};
|
|
359
359
|
declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
360
360
|
activate: () => void;
|
|
361
|
-
render: () =>
|
|
362
|
-
[key: string]: any;
|
|
363
|
-
}>;
|
|
361
|
+
render: () => ElementLike;
|
|
364
362
|
isActive: vue.ComputedRef<boolean>;
|
|
365
363
|
isDisabled: vue.ComputedRef<boolean>;
|
|
366
364
|
className: vue.ComputedRef<string>;
|
|
@@ -596,4 +594,152 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
596
594
|
color: string;
|
|
597
595
|
}>;
|
|
598
596
|
|
|
599
|
-
|
|
597
|
+
declare const configProviderProps: {
|
|
598
|
+
icon: {
|
|
599
|
+
type: PropType<Partial<{
|
|
600
|
+
size: number | undefined;
|
|
601
|
+
sizeUnit: string | undefined;
|
|
602
|
+
}>>;
|
|
603
|
+
};
|
|
604
|
+
activateEvent: {
|
|
605
|
+
type: PropType<Partial<_hoci_shared.ActivateEvent>>;
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
type Placement = "bottom" | "top" | "left" | "right" | "auto" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
|
|
610
|
+
type TriggerEvent = "click" | "mousedown" | "dblclick" | "hover" | "contextmenu" | "focus" | "touch";
|
|
611
|
+
declare const popoverProps: {
|
|
612
|
+
popupClass: {
|
|
613
|
+
type: StringConstructor;
|
|
614
|
+
};
|
|
615
|
+
placement: {
|
|
616
|
+
type: PropType<Placement>;
|
|
617
|
+
default: () => "auto";
|
|
618
|
+
};
|
|
619
|
+
triggerEvent: {
|
|
620
|
+
type: PropType<TriggerEvent>;
|
|
621
|
+
default: () => "hover";
|
|
622
|
+
};
|
|
623
|
+
offset: {
|
|
624
|
+
type: NumberConstructor;
|
|
625
|
+
default: () => 8;
|
|
626
|
+
};
|
|
627
|
+
lazy: {
|
|
628
|
+
type: BooleanConstructor;
|
|
629
|
+
default: () => false;
|
|
630
|
+
};
|
|
631
|
+
visible: {
|
|
632
|
+
type: BooleanConstructor;
|
|
633
|
+
default: () => false;
|
|
634
|
+
};
|
|
635
|
+
disabled: {
|
|
636
|
+
type: BooleanConstructor;
|
|
637
|
+
default: () => false;
|
|
638
|
+
};
|
|
639
|
+
teleport: {
|
|
640
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
641
|
+
default: () => true;
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
declare const popoverEmits: ("change" | "update:visible")[];
|
|
645
|
+
declare const usePopover: _hoci_shared.HookComponent<{
|
|
646
|
+
events: {
|
|
647
|
+
onMouseover: () => void;
|
|
648
|
+
onMouseout: () => void;
|
|
649
|
+
onMousedown: () => void;
|
|
650
|
+
onMouseup: () => void;
|
|
651
|
+
onContextmenu: (e: MouseEvent) => void;
|
|
652
|
+
onClick: (e: MouseEvent) => void;
|
|
653
|
+
onDblclick: () => void;
|
|
654
|
+
onFocusin: () => void;
|
|
655
|
+
onFocusout: () => void;
|
|
656
|
+
onTouchend: () => void;
|
|
657
|
+
};
|
|
658
|
+
dropdownPosition: {
|
|
659
|
+
x: number;
|
|
660
|
+
y: number;
|
|
661
|
+
};
|
|
662
|
+
triggerRef: vue.Ref<HTMLElement | undefined>;
|
|
663
|
+
popupRef: vue.Ref<HTMLElement | undefined>;
|
|
664
|
+
popupClass: vue.ComputedRef<string | undefined>;
|
|
665
|
+
popupStyle: vue.ComputedRef<{
|
|
666
|
+
left: string;
|
|
667
|
+
top: string;
|
|
668
|
+
visibility: string;
|
|
669
|
+
position: string;
|
|
670
|
+
}>;
|
|
671
|
+
}, ("change" | "update:visible")[], {
|
|
672
|
+
popupClass: {
|
|
673
|
+
type: StringConstructor;
|
|
674
|
+
};
|
|
675
|
+
placement: {
|
|
676
|
+
type: PropType<Placement>;
|
|
677
|
+
default: () => "auto";
|
|
678
|
+
};
|
|
679
|
+
triggerEvent: {
|
|
680
|
+
type: PropType<TriggerEvent>;
|
|
681
|
+
default: () => "hover";
|
|
682
|
+
};
|
|
683
|
+
offset: {
|
|
684
|
+
type: NumberConstructor;
|
|
685
|
+
default: () => 8;
|
|
686
|
+
};
|
|
687
|
+
lazy: {
|
|
688
|
+
type: BooleanConstructor;
|
|
689
|
+
default: () => false;
|
|
690
|
+
};
|
|
691
|
+
visible: {
|
|
692
|
+
type: BooleanConstructor;
|
|
693
|
+
default: () => false;
|
|
694
|
+
};
|
|
695
|
+
disabled: {
|
|
696
|
+
type: BooleanConstructor;
|
|
697
|
+
default: () => false;
|
|
698
|
+
};
|
|
699
|
+
teleport: {
|
|
700
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
701
|
+
default: () => true;
|
|
702
|
+
};
|
|
703
|
+
}, vue.ExtractPropTypes<{
|
|
704
|
+
popupClass: {
|
|
705
|
+
type: StringConstructor;
|
|
706
|
+
};
|
|
707
|
+
placement: {
|
|
708
|
+
type: PropType<Placement>;
|
|
709
|
+
default: () => "auto";
|
|
710
|
+
};
|
|
711
|
+
triggerEvent: {
|
|
712
|
+
type: PropType<TriggerEvent>;
|
|
713
|
+
default: () => "hover";
|
|
714
|
+
};
|
|
715
|
+
offset: {
|
|
716
|
+
type: NumberConstructor;
|
|
717
|
+
default: () => 8;
|
|
718
|
+
};
|
|
719
|
+
lazy: {
|
|
720
|
+
type: BooleanConstructor;
|
|
721
|
+
default: () => false;
|
|
722
|
+
};
|
|
723
|
+
visible: {
|
|
724
|
+
type: BooleanConstructor;
|
|
725
|
+
default: () => false;
|
|
726
|
+
};
|
|
727
|
+
disabled: {
|
|
728
|
+
type: BooleanConstructor;
|
|
729
|
+
default: () => false;
|
|
730
|
+
};
|
|
731
|
+
teleport: {
|
|
732
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
733
|
+
default: () => true;
|
|
734
|
+
};
|
|
735
|
+
}>, {
|
|
736
|
+
offset: number;
|
|
737
|
+
visible: boolean;
|
|
738
|
+
disabled: boolean;
|
|
739
|
+
placement: Placement;
|
|
740
|
+
triggerEvent: TriggerEvent;
|
|
741
|
+
lazy: boolean;
|
|
742
|
+
teleport: string | boolean | HTMLElement;
|
|
743
|
+
}>;
|
|
744
|
+
|
|
745
|
+
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.d.ts
CHANGED
|
@@ -358,9 +358,7 @@ declare const itemProps: {
|
|
|
358
358
|
};
|
|
359
359
|
declare const useSelectionItem: _hoci_shared.HookComponent<{
|
|
360
360
|
activate: () => void;
|
|
361
|
-
render: () =>
|
|
362
|
-
[key: string]: any;
|
|
363
|
-
}>;
|
|
361
|
+
render: () => ElementLike;
|
|
364
362
|
isActive: vue.ComputedRef<boolean>;
|
|
365
363
|
isDisabled: vue.ComputedRef<boolean>;
|
|
366
364
|
className: vue.ComputedRef<string>;
|
|
@@ -596,4 +594,152 @@ declare const useIcon: _hoci_shared.HookComponent<{
|
|
|
596
594
|
color: string;
|
|
597
595
|
}>;
|
|
598
596
|
|
|
599
|
-
|
|
597
|
+
declare const configProviderProps: {
|
|
598
|
+
icon: {
|
|
599
|
+
type: PropType<Partial<{
|
|
600
|
+
size: number | undefined;
|
|
601
|
+
sizeUnit: string | undefined;
|
|
602
|
+
}>>;
|
|
603
|
+
};
|
|
604
|
+
activateEvent: {
|
|
605
|
+
type: PropType<Partial<_hoci_shared.ActivateEvent>>;
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
type Placement = "bottom" | "top" | "left" | "right" | "auto" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-top" | "left-bottom" | "right-top" | "right-bottom";
|
|
610
|
+
type TriggerEvent = "click" | "mousedown" | "dblclick" | "hover" | "contextmenu" | "focus" | "touch";
|
|
611
|
+
declare const popoverProps: {
|
|
612
|
+
popupClass: {
|
|
613
|
+
type: StringConstructor;
|
|
614
|
+
};
|
|
615
|
+
placement: {
|
|
616
|
+
type: PropType<Placement>;
|
|
617
|
+
default: () => "auto";
|
|
618
|
+
};
|
|
619
|
+
triggerEvent: {
|
|
620
|
+
type: PropType<TriggerEvent>;
|
|
621
|
+
default: () => "hover";
|
|
622
|
+
};
|
|
623
|
+
offset: {
|
|
624
|
+
type: NumberConstructor;
|
|
625
|
+
default: () => 8;
|
|
626
|
+
};
|
|
627
|
+
lazy: {
|
|
628
|
+
type: BooleanConstructor;
|
|
629
|
+
default: () => false;
|
|
630
|
+
};
|
|
631
|
+
visible: {
|
|
632
|
+
type: BooleanConstructor;
|
|
633
|
+
default: () => false;
|
|
634
|
+
};
|
|
635
|
+
disabled: {
|
|
636
|
+
type: BooleanConstructor;
|
|
637
|
+
default: () => false;
|
|
638
|
+
};
|
|
639
|
+
teleport: {
|
|
640
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
641
|
+
default: () => true;
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
declare const popoverEmits: ("change" | "update:visible")[];
|
|
645
|
+
declare const usePopover: _hoci_shared.HookComponent<{
|
|
646
|
+
events: {
|
|
647
|
+
onMouseover: () => void;
|
|
648
|
+
onMouseout: () => void;
|
|
649
|
+
onMousedown: () => void;
|
|
650
|
+
onMouseup: () => void;
|
|
651
|
+
onContextmenu: (e: MouseEvent) => void;
|
|
652
|
+
onClick: (e: MouseEvent) => void;
|
|
653
|
+
onDblclick: () => void;
|
|
654
|
+
onFocusin: () => void;
|
|
655
|
+
onFocusout: () => void;
|
|
656
|
+
onTouchend: () => void;
|
|
657
|
+
};
|
|
658
|
+
dropdownPosition: {
|
|
659
|
+
x: number;
|
|
660
|
+
y: number;
|
|
661
|
+
};
|
|
662
|
+
triggerRef: vue.Ref<HTMLElement | undefined>;
|
|
663
|
+
popupRef: vue.Ref<HTMLElement | undefined>;
|
|
664
|
+
popupClass: vue.ComputedRef<string | undefined>;
|
|
665
|
+
popupStyle: vue.ComputedRef<{
|
|
666
|
+
left: string;
|
|
667
|
+
top: string;
|
|
668
|
+
visibility: string;
|
|
669
|
+
position: string;
|
|
670
|
+
}>;
|
|
671
|
+
}, ("change" | "update:visible")[], {
|
|
672
|
+
popupClass: {
|
|
673
|
+
type: StringConstructor;
|
|
674
|
+
};
|
|
675
|
+
placement: {
|
|
676
|
+
type: PropType<Placement>;
|
|
677
|
+
default: () => "auto";
|
|
678
|
+
};
|
|
679
|
+
triggerEvent: {
|
|
680
|
+
type: PropType<TriggerEvent>;
|
|
681
|
+
default: () => "hover";
|
|
682
|
+
};
|
|
683
|
+
offset: {
|
|
684
|
+
type: NumberConstructor;
|
|
685
|
+
default: () => 8;
|
|
686
|
+
};
|
|
687
|
+
lazy: {
|
|
688
|
+
type: BooleanConstructor;
|
|
689
|
+
default: () => false;
|
|
690
|
+
};
|
|
691
|
+
visible: {
|
|
692
|
+
type: BooleanConstructor;
|
|
693
|
+
default: () => false;
|
|
694
|
+
};
|
|
695
|
+
disabled: {
|
|
696
|
+
type: BooleanConstructor;
|
|
697
|
+
default: () => false;
|
|
698
|
+
};
|
|
699
|
+
teleport: {
|
|
700
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
701
|
+
default: () => true;
|
|
702
|
+
};
|
|
703
|
+
}, vue.ExtractPropTypes<{
|
|
704
|
+
popupClass: {
|
|
705
|
+
type: StringConstructor;
|
|
706
|
+
};
|
|
707
|
+
placement: {
|
|
708
|
+
type: PropType<Placement>;
|
|
709
|
+
default: () => "auto";
|
|
710
|
+
};
|
|
711
|
+
triggerEvent: {
|
|
712
|
+
type: PropType<TriggerEvent>;
|
|
713
|
+
default: () => "hover";
|
|
714
|
+
};
|
|
715
|
+
offset: {
|
|
716
|
+
type: NumberConstructor;
|
|
717
|
+
default: () => 8;
|
|
718
|
+
};
|
|
719
|
+
lazy: {
|
|
720
|
+
type: BooleanConstructor;
|
|
721
|
+
default: () => false;
|
|
722
|
+
};
|
|
723
|
+
visible: {
|
|
724
|
+
type: BooleanConstructor;
|
|
725
|
+
default: () => false;
|
|
726
|
+
};
|
|
727
|
+
disabled: {
|
|
728
|
+
type: BooleanConstructor;
|
|
729
|
+
default: () => false;
|
|
730
|
+
};
|
|
731
|
+
teleport: {
|
|
732
|
+
type: PropType<string | boolean | HTMLElement>;
|
|
733
|
+
default: () => true;
|
|
734
|
+
};
|
|
735
|
+
}>, {
|
|
736
|
+
offset: number;
|
|
737
|
+
visible: boolean;
|
|
738
|
+
disabled: boolean;
|
|
739
|
+
placement: Placement;
|
|
740
|
+
triggerEvent: TriggerEvent;
|
|
741
|
+
lazy: boolean;
|
|
742
|
+
teleport: string | boolean | HTMLElement;
|
|
743
|
+
}>;
|
|
744
|
+
|
|
745
|
+
export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref, inject, computed, watchPostEffect, provide, reactive, renderSlot, watch } from 'vue';
|
|
2
|
-
import { toReactive, useElementBounding, useElementVisibility, useEventListener, syncRef, isDefined, tryOnScopeDispose, useVModel } from '@vueuse/core';
|
|
3
|
-
import { defineHookProps, defineHookEmits, defineHookComponent, useElement, throttleByRaf, isWindow, valuePropType, classPropType, labelPropType, useSharedConfig } from '@hoci/shared';
|
|
1
|
+
import { ref, inject, computed, watchPostEffect, provide, reactive, renderSlot, watch, nextTick } from 'vue';
|
|
2
|
+
import { toReactive, useElementBounding, useElementVisibility, useEventListener, syncRef, isDefined, tryOnScopeDispose, useVModel, onClickOutside } from '@vueuse/core';
|
|
3
|
+
import { defineHookProps, defineHookEmits, defineHookComponent, useElement, throttleByRaf, isWindow, valuePropType, classPropType, labelPropType, useSharedConfig, getFirstChilld } from '@hoci/shared';
|
|
4
4
|
export * from '@hoci/shared';
|
|
5
5
|
import { px, cls, createUnitFormat } from 'tslx';
|
|
6
6
|
|
|
@@ -297,7 +297,7 @@ const useSelectionList = defineHookComponent({
|
|
|
297
297
|
}));
|
|
298
298
|
const renderItem = () => {
|
|
299
299
|
const children = options.filter((e) => actives.includes(e.value)).map((e) => e.render());
|
|
300
|
-
return props.multiple ? children : children
|
|
300
|
+
return props.multiple ? children : getFirstChilld(children);
|
|
301
301
|
};
|
|
302
302
|
const slotData = {
|
|
303
303
|
isActive,
|
|
@@ -361,12 +361,10 @@ const useSelectionItem = defineHookComponent({
|
|
|
361
361
|
return Array.isArray(label2) ? label2 : [label2];
|
|
362
362
|
});
|
|
363
363
|
function render() {
|
|
364
|
-
return
|
|
364
|
+
return slots.default?.({
|
|
365
365
|
active: context.isActive(props.value),
|
|
366
366
|
activate
|
|
367
|
-
}
|
|
368
|
-
return label.value;
|
|
369
|
-
});
|
|
367
|
+
}) ?? label.value.filter(Boolean);
|
|
370
368
|
}
|
|
371
369
|
let remove = () => {
|
|
372
370
|
};
|
|
@@ -555,4 +553,246 @@ const useIcon = defineHookComponent({
|
|
|
555
553
|
}
|
|
556
554
|
});
|
|
557
555
|
|
|
558
|
-
|
|
556
|
+
const configProviderProps = defineHookProps({
|
|
557
|
+
icon: {
|
|
558
|
+
type: Object
|
|
559
|
+
},
|
|
560
|
+
activateEvent: {
|
|
561
|
+
type: String
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
const popoverProps = defineHookProps({
|
|
566
|
+
popupClass: {
|
|
567
|
+
type: String
|
|
568
|
+
},
|
|
569
|
+
placement: {
|
|
570
|
+
type: String,
|
|
571
|
+
default: () => "auto"
|
|
572
|
+
},
|
|
573
|
+
triggerEvent: {
|
|
574
|
+
type: String,
|
|
575
|
+
default: () => "hover"
|
|
576
|
+
},
|
|
577
|
+
offset: {
|
|
578
|
+
type: Number,
|
|
579
|
+
default: () => 8
|
|
580
|
+
},
|
|
581
|
+
lazy: {
|
|
582
|
+
type: Boolean,
|
|
583
|
+
default: () => false
|
|
584
|
+
},
|
|
585
|
+
visible: {
|
|
586
|
+
type: Boolean,
|
|
587
|
+
default: () => false
|
|
588
|
+
},
|
|
589
|
+
disabled: {
|
|
590
|
+
type: Boolean,
|
|
591
|
+
default: () => false
|
|
592
|
+
},
|
|
593
|
+
teleport: {
|
|
594
|
+
type: [String, Object, Boolean],
|
|
595
|
+
default: () => true
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
const popoverEmits = defineHookEmits(["update:visible", "change"]);
|
|
599
|
+
const usePopover = defineHookComponent({
|
|
600
|
+
props: popoverProps,
|
|
601
|
+
emits: popoverEmits,
|
|
602
|
+
setup(props, context) {
|
|
603
|
+
const visible = useVModel(props, "visible", context.emit, {
|
|
604
|
+
passive: true
|
|
605
|
+
});
|
|
606
|
+
const triggerRef = ref();
|
|
607
|
+
const popupRef = ref();
|
|
608
|
+
const validate = (event) => {
|
|
609
|
+
const events2 = Array.isArray(event) ? event : [event];
|
|
610
|
+
return !props.disabled && events2.includes(props.triggerEvent);
|
|
611
|
+
};
|
|
612
|
+
let timer;
|
|
613
|
+
const toggle = (_value) => {
|
|
614
|
+
const value = _value ?? !visible.value;
|
|
615
|
+
visible.value = value;
|
|
616
|
+
context.emit("change", value);
|
|
617
|
+
};
|
|
618
|
+
function onMouseover() {
|
|
619
|
+
if (!validate("hover")) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
timer = setTimeout(
|
|
623
|
+
() => {
|
|
624
|
+
toggle(true);
|
|
625
|
+
},
|
|
626
|
+
props.lazy ? 800 : 100
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
function onMouseout() {
|
|
630
|
+
if (!validate("hover")) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
clearTimeout(timer);
|
|
634
|
+
toggle(false);
|
|
635
|
+
}
|
|
636
|
+
const onClick = (e) => {
|
|
637
|
+
if (!validate("click")) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
e.preventDefault();
|
|
641
|
+
e.stopPropagation();
|
|
642
|
+
toggle();
|
|
643
|
+
};
|
|
644
|
+
onClickOutside(triggerRef, () => {
|
|
645
|
+
if (!validate(["click", "contextmenu", "touch", "dblclick", "mousedown"])) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
toggle(false);
|
|
649
|
+
}, {
|
|
650
|
+
ignore: [popupRef]
|
|
651
|
+
});
|
|
652
|
+
const onContextmenu = (e) => {
|
|
653
|
+
if (!validate("contextmenu")) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
e.preventDefault();
|
|
657
|
+
e.stopPropagation();
|
|
658
|
+
toggle();
|
|
659
|
+
};
|
|
660
|
+
const onFocusin = () => {
|
|
661
|
+
if (!validate("focus")) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
toggle(true);
|
|
665
|
+
};
|
|
666
|
+
const onFocusout = () => {
|
|
667
|
+
if (!validate("focus")) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
toggle(false);
|
|
671
|
+
};
|
|
672
|
+
const onTouchend = () => {
|
|
673
|
+
if (!validate("touch")) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
toggle(true);
|
|
677
|
+
};
|
|
678
|
+
const onDblclick = () => {
|
|
679
|
+
if (!validate("dblclick")) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
toggle(true);
|
|
683
|
+
};
|
|
684
|
+
const onMousedown = () => {
|
|
685
|
+
if (!validate("mousedown")) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
toggle(true);
|
|
689
|
+
};
|
|
690
|
+
const onMouseup = () => {
|
|
691
|
+
if (!validate("mousedown")) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
toggle(false);
|
|
695
|
+
};
|
|
696
|
+
const events = {
|
|
697
|
+
onMouseover,
|
|
698
|
+
onMouseout,
|
|
699
|
+
onMousedown,
|
|
700
|
+
onMouseup,
|
|
701
|
+
onContextmenu,
|
|
702
|
+
onClick,
|
|
703
|
+
onDblclick,
|
|
704
|
+
onFocusin,
|
|
705
|
+
onFocusout,
|
|
706
|
+
onTouchend
|
|
707
|
+
};
|
|
708
|
+
const dropdownPosition = reactive({ x: 0, y: 0 });
|
|
709
|
+
const popupClass = computed(() => {
|
|
710
|
+
return props.popupClass;
|
|
711
|
+
});
|
|
712
|
+
function resize() {
|
|
713
|
+
const trigger = triggerRef.value;
|
|
714
|
+
const popup = popupRef.value;
|
|
715
|
+
if (!!trigger && !!popup && visible.value) {
|
|
716
|
+
const { width, height, left, top } = trigger.getBoundingClientRect();
|
|
717
|
+
const { clientWidth: pWidth, clientHeight: pHeight } = popup;
|
|
718
|
+
let x = 0;
|
|
719
|
+
let y = 0;
|
|
720
|
+
const offset = props.offset;
|
|
721
|
+
switch (props.placement) {
|
|
722
|
+
case "auto":
|
|
723
|
+
case "bottom":
|
|
724
|
+
x = left - (pWidth - width) / 2;
|
|
725
|
+
y = top + height + offset;
|
|
726
|
+
break;
|
|
727
|
+
case "bottom-left":
|
|
728
|
+
x = left;
|
|
729
|
+
y = top + height + offset;
|
|
730
|
+
break;
|
|
731
|
+
case "bottom-right":
|
|
732
|
+
x = left + width - pWidth;
|
|
733
|
+
y = top + height + offset;
|
|
734
|
+
break;
|
|
735
|
+
case "top":
|
|
736
|
+
x = left - (pWidth - width) / 2;
|
|
737
|
+
y = top - pHeight - offset;
|
|
738
|
+
break;
|
|
739
|
+
case "top-left":
|
|
740
|
+
x = left;
|
|
741
|
+
y = top - pHeight - offset;
|
|
742
|
+
break;
|
|
743
|
+
case "top-right":
|
|
744
|
+
x = left + width - pWidth;
|
|
745
|
+
y = top - pHeight - offset;
|
|
746
|
+
break;
|
|
747
|
+
case "left":
|
|
748
|
+
x = left - pWidth - offset;
|
|
749
|
+
y = top - (pHeight - height) / 2;
|
|
750
|
+
break;
|
|
751
|
+
case "left-top":
|
|
752
|
+
x = left - pWidth - offset;
|
|
753
|
+
y = top;
|
|
754
|
+
break;
|
|
755
|
+
case "left-bottom":
|
|
756
|
+
x = left - pWidth - offset;
|
|
757
|
+
y = top + height - pHeight;
|
|
758
|
+
break;
|
|
759
|
+
case "right":
|
|
760
|
+
x = left + width + offset;
|
|
761
|
+
y = top - (pHeight - height) / 2;
|
|
762
|
+
break;
|
|
763
|
+
case "right-top":
|
|
764
|
+
x = left + width + offset;
|
|
765
|
+
y = top;
|
|
766
|
+
break;
|
|
767
|
+
case "right-bottom":
|
|
768
|
+
x = left + width + offset;
|
|
769
|
+
y = top + height - pHeight;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
dropdownPosition.x = x;
|
|
773
|
+
dropdownPosition.y = y;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
watch(visible, () => {
|
|
777
|
+
nextTick(resize);
|
|
778
|
+
});
|
|
779
|
+
const popupStyle = computed(() => {
|
|
780
|
+
return {
|
|
781
|
+
left: px(dropdownPosition.x),
|
|
782
|
+
top: px(dropdownPosition.y),
|
|
783
|
+
visibility: visible.value ? "visible" : "hidden",
|
|
784
|
+
position: "fixed"
|
|
785
|
+
};
|
|
786
|
+
});
|
|
787
|
+
return {
|
|
788
|
+
events,
|
|
789
|
+
dropdownPosition,
|
|
790
|
+
triggerRef,
|
|
791
|
+
popupRef,
|
|
792
|
+
popupClass,
|
|
793
|
+
popupStyle
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
export { AFFIX_TARGET_KEY, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoci/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "chizuki",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"vue": "^3.3.4"
|
|
22
|
+
"vue": "^3.0.0-0"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@vueuse/core": "
|
|
25
|
+
"@vueuse/core": ">=10.5.0",
|
|
27
26
|
"maybe-types": "^0.1.0",
|
|
28
27
|
"tslx": "^0.1.1",
|
|
29
|
-
"@hoci/shared": "0.5.
|
|
28
|
+
"@hoci/shared": "0.5.1"
|
|
30
29
|
},
|
|
31
30
|
"scripts": {
|
|
32
31
|
"build": "unbuild",
|