@xy-planning-network/trees 0.4.0 → 0.4.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/trees.es.js +771 -142
- package/dist/trees.umd.js +6 -6
- package/package.json +1 -1
- package/src/lib-components/overlays/Popover/Popover.vue +109 -0
- package/src/lib-components/overlays/Popover/PopoverContent.vue +8 -0
- package/src/lib-components/overlays/Tooltip.vue +31 -0
- package/types/lib-components/index.d.ts +9 -1
- package/types/lib-components/overlays/Popover/Popover.vue.d.ts +15 -0
- package/types/lib-components/overlays/Popover/PopoverContent.vue.d.ts +2 -0
- package/types/lib-components/overlays/Tooltip.vue.d.ts +16 -0
package/package.json
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export type PopoverPosition =
|
|
3
|
+
| "top-left"
|
|
4
|
+
| "top-center"
|
|
5
|
+
| "top-right"
|
|
6
|
+
| "bottom-left"
|
|
7
|
+
| "bottom-center"
|
|
8
|
+
| "bottom-right"
|
|
9
|
+
| "left"
|
|
10
|
+
| "right"
|
|
11
|
+
</script>
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import {
|
|
14
|
+
Popover as HeadlessPopover,
|
|
15
|
+
PopoverButton as HeadlessPopoverButton,
|
|
16
|
+
PopoverPanel as HeadlessPopoverPanel,
|
|
17
|
+
} from "@headlessui/vue"
|
|
18
|
+
import { computed } from "vue"
|
|
19
|
+
|
|
20
|
+
const props = withDefaults(
|
|
21
|
+
defineProps<{
|
|
22
|
+
position?: PopoverPosition
|
|
23
|
+
}>(),
|
|
24
|
+
{
|
|
25
|
+
position: "top-center",
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const positionClasses = computed(() => {
|
|
30
|
+
// NOTE: by always pushing the screen width wrapper classes to the left we can avoid overflow scrolling
|
|
31
|
+
|
|
32
|
+
let wrapperClasses = ""
|
|
33
|
+
let contentClasses = ""
|
|
34
|
+
|
|
35
|
+
switch (props.position) {
|
|
36
|
+
case "top-left":
|
|
37
|
+
wrapperClasses =
|
|
38
|
+
"top-0 left-0 -translate-y-full -translate-x-full justify-end"
|
|
39
|
+
break
|
|
40
|
+
case "top-center":
|
|
41
|
+
wrapperClasses =
|
|
42
|
+
"top-0 -translate-y-full -translate-x-full left-1/2 justify-end"
|
|
43
|
+
contentClasses = "translate-x-1/2"
|
|
44
|
+
break
|
|
45
|
+
case "top-right":
|
|
46
|
+
wrapperClasses = "top-0 -translate-y-full right-0 justify-end"
|
|
47
|
+
contentClasses = "translate-x-full"
|
|
48
|
+
break
|
|
49
|
+
case "bottom-left":
|
|
50
|
+
wrapperClasses = "top-full left-0 -translate-x-full justify-end"
|
|
51
|
+
break
|
|
52
|
+
case "bottom-center":
|
|
53
|
+
wrapperClasses = "top-full -translate-x-full left-1/2 justify-end"
|
|
54
|
+
contentClasses = "translate-x-1/2"
|
|
55
|
+
break
|
|
56
|
+
case "bottom-right":
|
|
57
|
+
wrapperClasses = "top-full right-0 justify-end"
|
|
58
|
+
contentClasses = "translate-x-full"
|
|
59
|
+
break
|
|
60
|
+
case "left":
|
|
61
|
+
wrapperClasses =
|
|
62
|
+
"top-1/2 left-0 -translate-y-1/2 -translate-x-full justify-end"
|
|
63
|
+
break
|
|
64
|
+
case "right":
|
|
65
|
+
wrapperClasses = "top-1/2 -translate-y-1/2 right-0 justify-end"
|
|
66
|
+
contentClasses = "translate-x-full"
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
wrapper: wrapperClasses,
|
|
72
|
+
content: contentClasses,
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// TODO: maybe auto positioning - dynamic based on button location and closed overflow hidden container?
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<div class="flex">
|
|
81
|
+
<HeadlessPopover v-slot="{ open, close }" class="relative leading-none">
|
|
82
|
+
<HeadlessPopoverButton>
|
|
83
|
+
<slot name="button" :open="open" :close="close"></slot>
|
|
84
|
+
</HeadlessPopoverButton>
|
|
85
|
+
|
|
86
|
+
<transition
|
|
87
|
+
enter-active-class="transition-opacity transition-faster ease-out-quad"
|
|
88
|
+
leave-active-class="transition-opacity transition-faster ease-in-quad"
|
|
89
|
+
enter-from-class="opacity-0"
|
|
90
|
+
enter-to-class="opacity-100"
|
|
91
|
+
leave-from-class="opacity-100"
|
|
92
|
+
leave-to-class="opacity-0"
|
|
93
|
+
>
|
|
94
|
+
<!--NOTE: use prop "static" for dev work to keep the tooptip visible-->
|
|
95
|
+
<HeadlessPopoverPanel>
|
|
96
|
+
<!--positioning wrappers-->
|
|
97
|
+
<div
|
|
98
|
+
class="absolute z-10 transform w-screen flex"
|
|
99
|
+
:class="positionClasses.wrapper"
|
|
100
|
+
>
|
|
101
|
+
<div :class="positionClasses.content">
|
|
102
|
+
<slot :open="open" :close="close"></slot>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</HeadlessPopoverPanel>
|
|
106
|
+
</transition>
|
|
107
|
+
</HeadlessPopover>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import Popover, { PopoverPosition } from "./Popover/Popover.vue"
|
|
3
|
+
import { InformationCircleIcon } from "@heroicons/vue/outline"
|
|
4
|
+
import PopoverContent from "./Popover/PopoverContent.vue"
|
|
5
|
+
|
|
6
|
+
withDefaults(
|
|
7
|
+
defineProps<{
|
|
8
|
+
position: PopoverPosition
|
|
9
|
+
}>(),
|
|
10
|
+
{
|
|
11
|
+
position: "top-center",
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<Popover :position="position">
|
|
18
|
+
<template #button>
|
|
19
|
+
<div class="relative">
|
|
20
|
+
<!--creates a larger clickable surface area-->
|
|
21
|
+
<div
|
|
22
|
+
class="p-4 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
23
|
+
></div>
|
|
24
|
+
<InformationCircleIcon class="w-4 h-4" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
<PopoverContent class="text-xs leading-tight font-medium">
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</PopoverContent>
|
|
30
|
+
</Popover>
|
|
31
|
+
</template>
|
|
@@ -7,7 +7,11 @@ import { default as DownloadCell } from "./lists/DownloadCell.vue";
|
|
|
7
7
|
import { default as Flash } from "./overlays/Flash.vue";
|
|
8
8
|
import { default as Modal } from "./overlays/Modal.vue";
|
|
9
9
|
import { default as SidebarLayout } from "./layout/SidebarLayout.vue";
|
|
10
|
+
import { default as Popover } from "./overlays/Popover/Popover.vue";
|
|
11
|
+
import { default as PopoverPosition } from "./overlays/Popover/Popover.vue";
|
|
12
|
+
import { default as PopoverContent } from "./overlays/Popover/PopoverContent.vue";
|
|
10
13
|
import { default as Slideover } from "./overlays/Slideover.vue";
|
|
14
|
+
import { default as Tooltip } from "./overlays/Tooltip.vue";
|
|
11
15
|
import { default as StackedLayout } from "./layout/StackedLayout.vue";
|
|
12
16
|
import { default as Paginator } from "./navigation/Paginator.vue";
|
|
13
17
|
import { default as Spinner } from "./overlays/Spinner.vue";
|
|
@@ -26,7 +30,8 @@ import { default as Radio } from "./forms/Radio.vue";
|
|
|
26
30
|
import { default as Select } from "./forms/Select.vue";
|
|
27
31
|
import { default as TextArea } from "./forms/TextArea.vue";
|
|
28
32
|
import { default as YesOrNoRadio } from "./forms/YesOrNoRadio.vue";
|
|
29
|
-
export { ActionsDropdown, Cards, ContentModal, DateFilter, DetailList, DownloadCell, Flash, Modal, SidebarLayout, Slideover, StackedLayout,
|
|
33
|
+
export { ActionsDropdown, Cards, ContentModal, DateFilter, DetailList, DownloadCell, Flash, Modal, SidebarLayout, Slideover, StackedLayout, Popover, PopoverContent, PopoverPosition, // Type export
|
|
34
|
+
Paginator, Spinner, StaticTable, Steps, Table, Tabs, Toggle, Tooltip, BaseInput, Checkbox, DateRangePicker, InputHelp, InputLabel, MultiCheckboxes, Radio, Select, TextArea, YesOrNoRadio, };
|
|
30
35
|
/**
|
|
31
36
|
* declare global component types for App.use(Trees)
|
|
32
37
|
*/
|
|
@@ -41,6 +46,8 @@ export interface TreesComponents {
|
|
|
41
46
|
Modal: typeof Modal;
|
|
42
47
|
SidebarLayout: typeof SidebarLayout;
|
|
43
48
|
Slideover: typeof Slideover;
|
|
49
|
+
Popover: typeof Popover;
|
|
50
|
+
PopoverContent: typeof PopoverContent;
|
|
44
51
|
StackedLayout: typeof StackedLayout;
|
|
45
52
|
Paginator: typeof Paginator;
|
|
46
53
|
Spinner: typeof Spinner;
|
|
@@ -49,6 +56,7 @@ export interface TreesComponents {
|
|
|
49
56
|
Table: typeof Table;
|
|
50
57
|
Tabs: typeof Tabs;
|
|
51
58
|
Toggle: typeof Toggle;
|
|
59
|
+
Tooltip: typeof Tooltip;
|
|
52
60
|
BaseInput: typeof BaseInput;
|
|
53
61
|
Checkbox: typeof Checkbox;
|
|
54
62
|
DateRangePicker: typeof DateRangePicker;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type PopoverPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "left" | "right";
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
position: {
|
|
4
|
+
type: import("vue").PropType<PopoverPosition>;
|
|
5
|
+
} & {
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
}, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
9
|
+
position?: unknown;
|
|
10
|
+
} & {
|
|
11
|
+
position: PopoverPosition;
|
|
12
|
+
} & {}>, {
|
|
13
|
+
position: PopoverPosition;
|
|
14
|
+
}>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PopoverPosition } from "./Popover/Popover.vue";
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
position: {
|
|
4
|
+
type: import("vue").PropType<PopoverPosition>;
|
|
5
|
+
required: true;
|
|
6
|
+
} & {
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
}, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
10
|
+
position?: unknown;
|
|
11
|
+
} & {
|
|
12
|
+
position: PopoverPosition;
|
|
13
|
+
} & {}>, {
|
|
14
|
+
position: PopoverPosition;
|
|
15
|
+
}>;
|
|
16
|
+
export default _default;
|