yuyeon 0.0.12 → 0.0.14
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/style.css +1 -1
- package/dist/yuyeon.mjs +2370 -1926
- package/dist/yuyeon.umd.js +1 -1
- package/lib/components/card/YCard.scss +5 -0
- package/lib/components/chip/YChip.mjs +1 -0
- package/lib/components/chip/YChip.mjs.map +1 -1
- package/lib/components/chip/YChip.scss +7 -0
- package/lib/components/dialog/YDialog.mjs +24 -15
- package/lib/components/dialog/YDialog.mjs.map +1 -1
- package/lib/components/dialog/YDialog.scss +12 -0
- package/lib/components/dropdown/YDropdown.mjs +7 -0
- package/lib/components/dropdown/YDropdown.mjs.map +1 -0
- package/lib/components/dropdown/index.mjs +2 -0
- package/lib/components/dropdown/index.mjs.map +1 -0
- package/lib/components/layer/YLayer.mjs +99 -49
- package/lib/components/layer/YLayer.mjs.map +1 -1
- package/lib/components/menu/YMenu.mjs +20 -110
- package/lib/components/menu/YMenu.mjs.map +1 -1
- package/lib/components/pagination/YPagination.mjs +18 -7
- package/lib/components/pagination/YPagination.mjs.map +1 -1
- package/lib/components/pagination/YPagination.scss +10 -1
- package/lib/components/table/YDataTableBody.mjs +14 -2
- package/lib/components/table/YDataTableBody.mjs.map +1 -1
- package/lib/composables/coordinate/arrangement.mjs +14 -0
- package/lib/composables/coordinate/arrangement.mjs.map +1 -0
- package/lib/composables/coordinate/index.mjs +67 -0
- package/lib/composables/coordinate/index.mjs.map +1 -0
- package/lib/composables/coordinate/levitation.mjs +300 -0
- package/lib/composables/coordinate/levitation.mjs.map +1 -0
- package/lib/composables/coordinate/types.mjs +2 -0
- package/lib/composables/coordinate/types.mjs.map +1 -0
- package/lib/composables/coordinate/utils/point.mjs +55 -0
- package/lib/composables/coordinate/utils/point.mjs.map +1 -0
- package/lib/styles/base.scss +6 -0
- package/lib/styles/settings/provided.scss +33 -35
- package/lib/util/Rect.mjs +12 -0
- package/lib/util/Rect.mjs.map +1 -1
- package/lib/util/anchor.mjs +53 -0
- package/lib/util/anchor.mjs.map +1 -0
- package/lib/util/reactivity.mjs +14 -0
- package/lib/util/reactivity.mjs.map +1 -0
- package/package.json +1 -1
- package/types/components/chip/YChip.d.ts +1 -0
- package/types/components/dialog/YDialog.d.ts +1625 -8
- package/types/components/layer/YLayer.d.ts +1786 -1
- package/types/components/menu/YMenu.d.ts +1701 -43
- package/types/components/pagination/YPagination.d.ts +34 -14
- package/types/components/snackbar/YSnackbar.d.ts +2 -2
- package/types/components/table/YDataTable.d.ts +8 -8
- package/types/components/table/YDataTableBody.d.ts +4 -0
- package/types/components/table/YDataTableCell.d.ts +3 -3
- package/types/components/table/YDataTableServer.d.ts +8 -8
- package/types/components/table/composibles/header.d.ts +2 -2
- package/types/components/table/composibles/selection.d.ts +4 -4
- package/types/components/tooltip/YTooltip.d.ts +1620 -6
- package/types/composables/coordinate/arrangement.d.ts +6 -0
- package/types/composables/coordinate/index.d.ts +1638 -0
- package/types/composables/coordinate/levitation.d.ts +6 -0
- package/types/composables/coordinate/types.d.ts +6 -0
- package/types/composables/coordinate/utils/point.d.ts +21 -0
- package/types/util/Rect.d.ts +36 -0
- package/types/util/anchor.d.ts +23 -0
- package/types/util/reactivity.d.ts +2 -0
- package/types/util/scroll.d.ts +3 -0
|
@@ -5,6 +5,7 @@ import { bindClasses } from "../../util/vue-component.mjs";
|
|
|
5
5
|
import { YCard } from "../card/index.mjs";
|
|
6
6
|
import { YLayer } from "../layer/index.mjs";
|
|
7
7
|
import "./YDialog.scss";
|
|
8
|
+
import { useModelDuplex } from "../../composables/communication.mjs";
|
|
8
9
|
export const YDialog = defineComponent({
|
|
9
10
|
name: 'YDialog',
|
|
10
11
|
components: {
|
|
@@ -15,12 +16,13 @@ export const YDialog = defineComponent({
|
|
|
15
16
|
modelValue: {
|
|
16
17
|
type: Boolean
|
|
17
18
|
},
|
|
19
|
+
persistent: {
|
|
20
|
+
type: Boolean
|
|
21
|
+
},
|
|
18
22
|
dialogClasses: {
|
|
19
23
|
type: [Array, String, Object]
|
|
20
24
|
},
|
|
21
|
-
|
|
22
|
-
type: Boolean
|
|
23
|
-
}
|
|
25
|
+
disabled: Boolean
|
|
24
26
|
},
|
|
25
27
|
emits: ['update:modelValue'],
|
|
26
28
|
setup(props, _ref) {
|
|
@@ -28,14 +30,7 @@ export const YDialog = defineComponent({
|
|
|
28
30
|
emit,
|
|
29
31
|
slots
|
|
30
32
|
} = _ref;
|
|
31
|
-
const active =
|
|
32
|
-
get: () => {
|
|
33
|
-
return !!props.modelValue;
|
|
34
|
-
},
|
|
35
|
-
set: v => {
|
|
36
|
-
emit('update:modelValue', v);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
33
|
+
const active = useModelDuplex(props);
|
|
39
34
|
const classes = computed(() => {
|
|
40
35
|
const boundClasses = bindClasses(props.dialogClasses);
|
|
41
36
|
return {
|
|
@@ -69,15 +64,28 @@ export const YDialog = defineComponent({
|
|
|
69
64
|
function onUpdate(v) {
|
|
70
65
|
active.value = v;
|
|
71
66
|
}
|
|
67
|
+
function onClick(e) {
|
|
68
|
+
const currentActive = active.value;
|
|
69
|
+
if (!props.disabled) {
|
|
70
|
+
active.value = !currentActive;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
watch(() => layer.value?.baseEl, (neo, old) => {
|
|
74
|
+
if (neo) {
|
|
75
|
+
neo.addEventListener('click', onClick);
|
|
76
|
+
} else if (old) {
|
|
77
|
+
old.removeEventListener('click', onClick);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
72
80
|
watch(() => active.value, neo => {
|
|
73
81
|
neo ? installFocusTrap() : dismantleFocusTrap();
|
|
74
82
|
}, {
|
|
75
83
|
immediate: true
|
|
76
84
|
});
|
|
77
85
|
useRender(() => {
|
|
78
|
-
return _createVNode(_Fragment, null, [
|
|
79
|
-
"
|
|
80
|
-
"onUpdate:modelValue":
|
|
86
|
+
return _createVNode(_Fragment, null, [_createVNode(YLayer, {
|
|
87
|
+
"modelValue": active.value,
|
|
88
|
+
"onUpdate:modelValue": $event => active.value = $event,
|
|
81
89
|
"scrim": true,
|
|
82
90
|
"classes": classes.value,
|
|
83
91
|
"persistent": props.persistent,
|
|
@@ -88,7 +96,8 @@ export const YDialog = defineComponent({
|
|
|
88
96
|
args[_key] = arguments[_key];
|
|
89
97
|
}
|
|
90
98
|
return slots.default?.(...args);
|
|
91
|
-
}
|
|
99
|
+
},
|
|
100
|
+
base: slots.base
|
|
92
101
|
})]);
|
|
93
102
|
});
|
|
94
103
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDialog.mjs","names":["computed","defineComponent","ref","watch","useRender","bindClasses","YCard","YLayer","YDialog","name","components","props","modelValue","type","Boolean","dialogClasses","Array","String","Object","
|
|
1
|
+
{"version":3,"file":"YDialog.mjs","names":["computed","defineComponent","ref","watch","useRender","bindClasses","YCard","YLayer","useModelDuplex","YDialog","name","components","props","modelValue","type","Boolean","persistent","dialogClasses","Array","String","Object","disabled","emits","setup","_ref","emit","slots","active","classes","boundClasses","layer","onFocusin","e","prevTarget","relatedTarget","target","value","content$","document","includes","contains","focusableSelector","focusables","querySelectorAll","filter","el","hasAttribute","matches","length","firstChild","lastChild","focus","installFocusTrap","addEventListener","dismantleFocusTrap","removeEventListener","onUpdate","v","onClick","currentActive","baseEl","neo","old","immediate","_createVNode","_Fragment","$event","default","_len","arguments","args","_key","base"],"sources":["../../../src/components/dialog/YDialog.tsx"],"sourcesContent":["import type { PropType } from 'vue';\nimport { computed, defineComponent, ref, watch } from 'vue';\n\nimport { useRender } from '../../composables/component';\nimport { bindClasses } from '../../util/vue-component';\nimport { YCard } from '../card';\nimport { YLayer } from '../layer';\n\nimport './YDialog.scss';\nimport { useModelDuplex } from \"../../composables/communication\";\n\nexport const YDialog = defineComponent({\n name: 'YDialog',\n components: {\n YLayer,\n YCard,\n },\n props: {\n modelValue: {\n type: Boolean as PropType<boolean>,\n },\n persistent: {\n type: Boolean,\n },\n dialogClasses: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n disabled: Boolean,\n },\n emits: ['update:modelValue'],\n setup(props, { emit, slots }) {\n const active = useModelDuplex(props);\n\n const classes = computed(() => {\n const boundClasses = bindClasses(props.dialogClasses);\n return {\n ...boundClasses,\n 'y-dialog': true,\n };\n });\n\n const layer = ref<typeof YLayer>();\n\n function onFocusin(e: FocusEvent) {\n const prevTarget = e.relatedTarget as HTMLElement | null;\n const target = e.target as HTMLElement | null;\n if (\n prevTarget !== target &&\n layer.value?.content$ &&\n ![document, layer.value?.content$].includes(target) &&\n !layer.value?.content$.contains(target)\n ) {\n const focusableSelector =\n 'button, [href], input:not([type=\"hidden\"]), select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n const focusables = [\n ...layer.value.content$.querySelectorAll(focusableSelector),\n ].filter(\n (el) =>\n !el.hasAttribute('disabled') && !el.matches('[tabindex=\"-1\"]'),\n ) as HTMLElement[];\n if (!focusables.length) return;\n const firstChild = focusables[0];\n const lastChild = focusables[focusables.length - 1];\n if (firstChild === lastChild) {\n lastChild.focus();\n } else {\n firstChild.focus();\n }\n }\n }\n\n function installFocusTrap() {\n document.addEventListener('focusin', onFocusin);\n }\n\n function dismantleFocusTrap() {\n document.removeEventListener('focusin', onFocusin);\n }\n\n function onUpdate(v: boolean) {\n active.value = v;\n }\n\n function onClick(e: MouseEvent) {\n const currentActive = active.value;\n if (!props.disabled) {\n active.value = !currentActive;\n }\n }\n\n watch(() => layer.value?.baseEl, (neo, old) => {\n if (neo) {\n neo.addEventListener('click', onClick);\n } else if (old) {\n old.removeEventListener('click', onClick);\n }\n });\n\n watch(\n () => active.value,\n (neo) => {\n neo ? installFocusTrap() : dismantleFocusTrap();\n },\n { immediate: true },\n );\n\n useRender(() => {\n return (\n <>\n <YLayer\n v-model={active.value}\n scrim\n classes={classes.value}\n persistent={props.persistent}\n ref={layer}\n >\n {{\n default: (...args: any[]) => slots.default?.(...args),\n base: slots.base\n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,4 +2,16 @@
|
|
|
2
2
|
justify-content: center;
|
|
3
3
|
align-items: center;
|
|
4
4
|
backdrop-filter: blur(0.8px) saturate(0.4);
|
|
5
|
+
|
|
6
|
+
.y-layer {
|
|
7
|
+
&__content > .y-card {
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.y-layer--finish {
|
|
13
|
+
.y-layer__content > .y-card > .y-card__footer {
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
5
17
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { defineComponent } from 'vue';
|
|
2
|
+
import { propsFactory } from "../../util/vue-component.mjs";
|
|
3
|
+
export const pressYDropdownPropsOptions = propsFactory({}, 'YDropdown');
|
|
4
|
+
export const YDropdown = defineComponent({
|
|
5
|
+
name: 'YDropdown'
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=YDropdown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YDropdown.mjs","names":["defineComponent","propsFactory","pressYDropdownPropsOptions","YDropdown","name"],"sources":["../../../src/components/dropdown/YDropdown.tsx"],"sourcesContent":["import { defineComponent } from 'vue';\nimport { propsFactory } from \"../../util/vue-component\";\n\nexport const pressYDropdownPropsOptions = propsFactory({}, 'YDropdown');\n\nexport const YDropdown = defineComponent({\n name: 'YDropdown',\n});\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,KAAK;AAAC,SAC7BC,YAAY;AAErB,OAAO,MAAMC,0BAA0B,GAAGD,YAAY,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;AAEvE,OAAO,MAAME,SAAS,GAAGH,eAAe,CAAC;EACvCI,IAAI,EAAE;AACR,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/dropdown/index.ts"],"sourcesContent":["export * from './YDropdown';\r\n"],"mappings":""}
|
|
@@ -1,12 +1,44 @@
|
|
|
1
|
-
import { mergeProps as _mergeProps, withDirectives as _withDirectives, resolveDirective as _resolveDirective, vShow as _vShow, createVNode as _createVNode } from "vue";
|
|
2
|
-
import { Teleport, Transition, computed, defineComponent, reactive, ref, toRef } from
|
|
1
|
+
import { mergeProps as _mergeProps, withDirectives as _withDirectives, resolveDirective as _resolveDirective, vShow as _vShow, createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
+
import { Teleport, Transition, computed, defineComponent, mergeProps, reactive, ref, toRef, watchEffect, shallowRef } from "vue";
|
|
3
3
|
import { useRender } from "../../composables/component.mjs";
|
|
4
4
|
import { useLayerGroup } from "../../composables/layer-group.mjs";
|
|
5
5
|
import { useLazy } from "../../composables/timing.mjs";
|
|
6
6
|
import { PolyTransition, polyTransitionPropOptions, usePolyTransition } from "../../composables/transition.mjs";
|
|
7
7
|
import { ComplementClick } from "../../directives/complement-click/index.mjs";
|
|
8
|
-
import { bindClasses } from "../../util/vue-component.mjs";
|
|
8
|
+
import { bindClasses, propsFactory } from "../../util/vue-component.mjs";
|
|
9
9
|
import "./YLayer.scss";
|
|
10
|
+
import { pressCoordinateProps, useCoordinate } from "../../composables/coordinate/index.mjs";
|
|
11
|
+
export const pressYLayerProps = propsFactory({
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: Boolean
|
|
14
|
+
},
|
|
15
|
+
scrim: {
|
|
16
|
+
type: Boolean
|
|
17
|
+
},
|
|
18
|
+
eager: {
|
|
19
|
+
type: Boolean
|
|
20
|
+
},
|
|
21
|
+
classes: {
|
|
22
|
+
type: [Array, String, Object]
|
|
23
|
+
},
|
|
24
|
+
contentClasses: {
|
|
25
|
+
type: [Array, String, Object]
|
|
26
|
+
},
|
|
27
|
+
closeClickScrim: {
|
|
28
|
+
type: Boolean
|
|
29
|
+
},
|
|
30
|
+
persistent: Boolean,
|
|
31
|
+
contentStyles: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: () => {}
|
|
34
|
+
},
|
|
35
|
+
disabled: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
...polyTransitionPropOptions,
|
|
40
|
+
...pressCoordinateProps()
|
|
41
|
+
}, 'YLayer');
|
|
10
42
|
export const YLayer = defineComponent({
|
|
11
43
|
name: 'YLayer',
|
|
12
44
|
inheritAttrs: false,
|
|
@@ -17,38 +49,12 @@ export const YLayer = defineComponent({
|
|
|
17
49
|
ComplementClick
|
|
18
50
|
},
|
|
19
51
|
props: {
|
|
20
|
-
|
|
21
|
-
type: Boolean
|
|
22
|
-
},
|
|
23
|
-
scrim: {
|
|
24
|
-
type: Boolean
|
|
25
|
-
},
|
|
26
|
-
eager: {
|
|
27
|
-
type: Boolean
|
|
28
|
-
},
|
|
29
|
-
classes: {
|
|
30
|
-
type: [Array, String, Object]
|
|
31
|
-
},
|
|
32
|
-
contentClasses: {
|
|
33
|
-
type: [Array, String, Object]
|
|
34
|
-
},
|
|
35
|
-
closeClickScrim: {
|
|
36
|
-
type: Boolean
|
|
37
|
-
},
|
|
38
|
-
persistent: Boolean,
|
|
39
|
-
contentStyles: {
|
|
40
|
-
type: Object,
|
|
41
|
-
default: () => {}
|
|
42
|
-
},
|
|
43
|
-
disabled: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: false
|
|
46
|
-
},
|
|
47
|
-
...polyTransitionPropOptions
|
|
52
|
+
...pressYLayerProps()
|
|
48
53
|
},
|
|
49
54
|
emits: {
|
|
50
55
|
'update:modelValue': value => true,
|
|
51
|
-
'click:complement': mouseEvent => true
|
|
56
|
+
'click:complement': mouseEvent => true,
|
|
57
|
+
'afterLeave': () => true
|
|
52
58
|
},
|
|
53
59
|
setup(props, _ref) {
|
|
54
60
|
let {
|
|
@@ -57,6 +63,12 @@ export const YLayer = defineComponent({
|
|
|
57
63
|
attrs,
|
|
58
64
|
slots
|
|
59
65
|
} = _ref;
|
|
66
|
+
const el$ = ref();
|
|
67
|
+
const base$ = ref();
|
|
68
|
+
const scrim$ = ref();
|
|
69
|
+
const content$ = ref();
|
|
70
|
+
const baseSlot = ref();
|
|
71
|
+
const baseEl = ref();
|
|
60
72
|
const {
|
|
61
73
|
layerGroup
|
|
62
74
|
} = useLayerGroup();
|
|
@@ -71,14 +83,22 @@ export const YLayer = defineComponent({
|
|
|
71
83
|
emit('update:modelValue', v);
|
|
72
84
|
}
|
|
73
85
|
});
|
|
86
|
+
const finish = shallowRef(false);
|
|
74
87
|
const disabled = toRef(props, 'disabled');
|
|
75
88
|
const {
|
|
76
89
|
lazyValue,
|
|
77
90
|
onAfterUpdate
|
|
78
91
|
} = useLazy(!!props.eager, active);
|
|
79
92
|
const rendered = computed(() => !disabled.value && (lazyValue.value || active.value));
|
|
80
|
-
const
|
|
81
|
-
|
|
93
|
+
const {
|
|
94
|
+
coordinate,
|
|
95
|
+
coordinateStyles,
|
|
96
|
+
updateCoordinate
|
|
97
|
+
} = useCoordinate(props, {
|
|
98
|
+
contentEl: content$,
|
|
99
|
+
baseEl,
|
|
100
|
+
active
|
|
101
|
+
});
|
|
82
102
|
function onClickComplementLayer(mouseEvent) {
|
|
83
103
|
emit('click:complement', mouseEvent);
|
|
84
104
|
if (!props.persistent) {
|
|
@@ -96,27 +116,32 @@ export const YLayer = defineComponent({
|
|
|
96
116
|
const complementClickOption = reactive({
|
|
97
117
|
handler: onClickComplementLayer,
|
|
98
118
|
determine: closeConditional,
|
|
99
|
-
include: () => [
|
|
100
|
-
// activatorEl.value
|
|
101
|
-
]
|
|
102
|
-
});
|
|
103
|
-
expose({
|
|
104
|
-
scrim$,
|
|
105
|
-
content$,
|
|
106
|
-
active,
|
|
107
|
-
onAfterUpdate
|
|
119
|
+
include: () => []
|
|
108
120
|
});
|
|
109
121
|
function onAfterEnter() {
|
|
110
|
-
|
|
122
|
+
finish.value = true;
|
|
111
123
|
}
|
|
112
124
|
function onAfterLeave() {
|
|
113
125
|
onAfterUpdate();
|
|
126
|
+
finish.value = false;
|
|
127
|
+
emit('afterLeave');
|
|
114
128
|
}
|
|
115
129
|
function onClickScrim() {
|
|
116
130
|
if (props.closeClickScrim) {
|
|
117
131
|
active.value = false;
|
|
118
132
|
}
|
|
119
133
|
}
|
|
134
|
+
const baseFromSlotEl = computed(() => {
|
|
135
|
+
return baseSlot.value?.[0]?.el;
|
|
136
|
+
});
|
|
137
|
+
watchEffect(() => {
|
|
138
|
+
if (!base$.value) {
|
|
139
|
+
baseEl.value = baseFromSlotEl.value;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const base = base$.value;
|
|
143
|
+
baseEl.value = base$.value?.$el ? base$.value?.$el : base;
|
|
144
|
+
});
|
|
120
145
|
const computedStyle = computed(() => {
|
|
121
146
|
return {
|
|
122
147
|
zIndex: '2000'
|
|
@@ -138,14 +163,35 @@ export const YLayer = defineComponent({
|
|
|
138
163
|
...boundClasses
|
|
139
164
|
};
|
|
140
165
|
});
|
|
166
|
+
expose({
|
|
167
|
+
scrim$,
|
|
168
|
+
base$,
|
|
169
|
+
content$,
|
|
170
|
+
baseEl,
|
|
171
|
+
active,
|
|
172
|
+
onAfterUpdate,
|
|
173
|
+
updateCoordinate
|
|
174
|
+
});
|
|
141
175
|
useRender(() => {
|
|
142
|
-
|
|
176
|
+
const slotBase = slots.base?.({
|
|
177
|
+
active: active.value,
|
|
178
|
+
props: mergeProps({
|
|
179
|
+
ref: base$,
|
|
180
|
+
class: {
|
|
181
|
+
'y-layer-base': true,
|
|
182
|
+
'y-layer-base--active': active.value
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
baseSlot.value = slotBase;
|
|
187
|
+
return _createVNode(_Fragment, null, [slotBase, _createVNode(Teleport, {
|
|
143
188
|
"disabled": !layerGroup.value,
|
|
144
189
|
"to": layerGroup.value
|
|
145
190
|
}, {
|
|
146
191
|
default: () => [rendered.value && _createVNode("div", _mergeProps({
|
|
147
192
|
"class": {
|
|
148
193
|
'y-layer': true,
|
|
194
|
+
'y-layer--finish': finish.value,
|
|
149
195
|
...computedClass.value
|
|
150
196
|
},
|
|
151
197
|
"style": computedStyle.value
|
|
@@ -168,15 +214,18 @@ export const YLayer = defineComponent({
|
|
|
168
214
|
'y-layer__content': true,
|
|
169
215
|
...computedContentClasses.value
|
|
170
216
|
},
|
|
171
|
-
"style":
|
|
172
|
-
|
|
217
|
+
"style": [{
|
|
218
|
+
...coordinateStyles.value,
|
|
219
|
+
...props.contentStyles
|
|
220
|
+
}],
|
|
221
|
+
"ref": content$
|
|
173
222
|
}, [slots.default?.({
|
|
174
223
|
active: active.value
|
|
175
224
|
})]), [[_vShow, active.value], [_resolveDirective("complement-click"), {
|
|
176
225
|
...complementClickOption
|
|
177
226
|
}]])]
|
|
178
227
|
})])]
|
|
179
|
-
});
|
|
228
|
+
})]);
|
|
180
229
|
});
|
|
181
230
|
return {
|
|
182
231
|
complementClickOption,
|
|
@@ -186,7 +235,8 @@ export const YLayer = defineComponent({
|
|
|
186
235
|
onAfterUpdate: onAfterUpdate,
|
|
187
236
|
scrim$,
|
|
188
237
|
content$,
|
|
189
|
-
polyTransitionBindProps
|
|
238
|
+
polyTransitionBindProps,
|
|
239
|
+
coordinateStyles
|
|
190
240
|
};
|
|
191
241
|
}
|
|
192
242
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YLayer.mjs","names":["Teleport","Transition","computed","defineComponent","reactive","ref","toRef","useRender","useLayerGroup","useLazy","PolyTransition","polyTransitionPropOptions","usePolyTransition","ComplementClick","bindClasses","YLayer","name","inheritAttrs","components","directives","props","modelValue","type","Boolean","scrim","eager","classes","Array","String","Object","contentClasses","closeClickScrim","persistent","contentStyles","default","disabled","emits","value","mouseEvent","setup","_ref","emit","expose","attrs","slots","layerGroup","polyTransitionBindProps","active","get","set","v","lazyValue","onAfterUpdate","rendered","scrim$","content$","onClickComplementLayer","target","closeConditional","complementClickOption","handler","determine","include","onAfterEnter","onAfterLeave","onClickScrim","computedStyle","zIndex","computedClass","boundClasses","computedContentClasses","_createVNode","_mergeProps","_withDirectives","_vShow","_resolveDirective"],"sources":["../../../src/components/layer/YLayer.tsx"],"sourcesContent":["import {\n CSSProperties,\n Prop,\n PropType,\n Teleport,\n Transition,\n computed,\n defineComponent,\n reactive,\n ref,\n toRef,\n} from 'vue';\n\nimport { useRender } from '../../composables/component';\nimport { useLayerGroup } from '../../composables/layer-group';\nimport { useLazy } from '../../composables/timing';\nimport {\n PolyTransition,\n polyTransitionPropOptions,\n usePolyTransition,\n} from '../../composables/transition';\nimport {\n ComplementClick,\n ComplementClickBindingOptions,\n} from '../../directives/complement-click';\nimport { bindClasses } from '../../util/vue-component';\n\nimport './YLayer.scss';\n\nexport const YLayer = defineComponent({\n name: 'YLayer',\n inheritAttrs: false,\n components: {\n PolyTransition,\n },\n directives: {\n ComplementClick,\n },\n props: {\n modelValue: {\n type: Boolean as PropType<boolean>,\n },\n scrim: {\n type: Boolean as PropType<boolean>,\n },\n eager: {\n type: Boolean as PropType<boolean>,\n },\n classes: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n contentClasses: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n closeClickScrim: {\n type: Boolean as PropType<boolean>,\n },\n persistent: Boolean as PropType<boolean>,\n contentStyles: {\n type: Object as PropType<CSSProperties>,\n default: () => {},\n },\n disabled: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n ...polyTransitionPropOptions,\n },\n emits: {\n 'update:modelValue': (value: boolean) => true,\n 'click:complement': (mouseEvent: MouseEvent) => true,\n },\n setup(props, { emit, expose, attrs, slots }) {\n const { layerGroup } = useLayerGroup();\n const { polyTransitionBindProps } = usePolyTransition(props);\n const active = computed<boolean>({\n get: (): boolean => {\n return !!props.modelValue;\n },\n set: (v: boolean) => {\n emit('update:modelValue', v);\n },\n });\n const disabled = toRef(props, 'disabled');\n const { lazyValue, onAfterUpdate } = useLazy(!!props.eager, active);\n const rendered = computed<boolean>(\n () => !disabled.value && (lazyValue.value || active.value),\n );\n const scrim$ = ref<HTMLElement>();\n const content$ = ref<HTMLElement>();\n\n function onClickComplementLayer(mouseEvent: MouseEvent) {\n emit('click:complement', mouseEvent);\n if (!props.persistent) {\n if (\n scrim$.value !== null &&\n scrim$.value === mouseEvent.target &&\n props.closeClickScrim\n ) {\n active.value = false;\n }\n } else {\n // TODO: shrug ani\n }\n }\n\n function closeConditional(): boolean {\n return active.value; // TODO: && groupTopLevel.value;\n }\n\n const complementClickOption = reactive<ComplementClickBindingOptions>({\n handler: onClickComplementLayer,\n determine: closeConditional,\n include: () => [\n // activatorEl.value\n ],\n });\n\n expose({\n scrim$,\n content$,\n active,\n onAfterUpdate,\n });\n\n function onAfterEnter() {\n // console.log('after')\n }\n\n function onAfterLeave() {\n onAfterUpdate();\n }\n\n function onClickScrim() {\n if (props.closeClickScrim) {\n active.value = false;\n }\n }\n\n const computedStyle = computed(() => {\n return {\n zIndex: '2000',\n };\n });\n\n const computedClass = computed<Record<string, boolean>>(() => {\n const { classes } = props;\n const boundClasses = bindClasses(classes);\n return {\n ...boundClasses,\n 'y-layer--active': !!active.value,\n };\n });\n\n const computedContentClasses = computed<Record<string, boolean>>(() => {\n const boundClasses = bindClasses(props.contentClasses);\n return {\n ...boundClasses,\n };\n });\n\n useRender(() => {\n return (\n <Teleport disabled={!layerGroup.value} to={layerGroup.value as any}>\n {rendered.value && (\n <div\n class={{ 'y-layer': true, ...computedClass.value }}\n style={computedStyle.value}\n {...attrs}\n >\n <Transition name=\"fade\" appear>\n {active.value && props.scrim && (\n <div\n class=\"y-layer__scrim\"\n onClick={onClickScrim}\n ref=\"scrim$\"\n ></div>\n )}\n </Transition>\n <PolyTransition\n onAfterEnter={onAfterEnter}\n onAfterLeave={onAfterLeave}\n appear\n {...polyTransitionBindProps.value}\n >\n <div\n v-show={active.value}\n v-complement-click={{ ...complementClickOption }}\n class={{\n 'y-layer__content': true,\n ...computedContentClasses.value,\n }}\n style={props.contentStyles}\n ref=\"content$\"\n >\n {slots.default?.({ active: active.value })}\n </div>\n </PolyTransition>\n </div>\n )}\n </Teleport>\n );\n });\n\n return {\n complementClickOption,\n layerGroup,\n active,\n rendered,\n onAfterUpdate: onAfterUpdate as () => void,\n scrim$,\n content$,\n polyTransitionBindProps,\n };\n },\n});\n\nexport type YLayer = InstanceType<typeof YLayer>;\n"],"mappings":";AAAA,SAIEA,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,eAAe,EACfC,QAAQ,EACRC,GAAG,EACHC,KAAK,QACA,KAAK;AAAC,SAEJC,SAAS;AAAA,SACTC,aAAa;AAAA,SACbC,OAAO;AAAA,SAEdC,cAAc,EACdC,yBAAyB,EACzBC,iBAAiB;AAAA,SAGjBC,eAAe;AAAA,SAGRC,WAAW;AAEpB;AAEA,OAAO,MAAMC,MAAM,GAAGZ,eAAe,CAAC;EACpCa,IAAI,EAAE,QAAQ;EACdC,YAAY,EAAE,KAAK;EACnBC,UAAU,EAAE;IACVR;EACF,CAAC;EACDS,UAAU,EAAE;IACVN;EACF,CAAC;EACDO,KAAK,EAAE;IACLC,UAAU,EAAE;MACVC,IAAI,EAAEC;IACR,CAAC;IACDC,KAAK,EAAE;MACLF,IAAI,EAAEC;IACR,CAAC;IACDE,KAAK,EAAE;MACLH,IAAI,EAAEC;IACR,CAAC;IACDG,OAAO,EAAE;MACPJ,IAAI,EAAE,CAACK,KAAK,EAAEC,MAAM,EAAEC,MAAM;IAG9B,CAAC;IACDC,cAAc,EAAE;MACdR,IAAI,EAAE,CAACK,KAAK,EAAEC,MAAM,EAAEC,MAAM;IAG9B,CAAC;IACDE,eAAe,EAAE;MACfT,IAAI,EAAEC;IACR,CAAC;IACDS,UAAU,EAAET,OAA4B;IACxCU,aAAa,EAAE;MACbX,IAAI,EAAEO,MAAiC;MACvCK,OAAO,EAAEA,CAAA,KAAM,CAAC;IAClB,CAAC;IACDC,QAAQ,EAAE;MACRb,IAAI,EAAEC,OAA4B;MAClCW,O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C,QAAQ;MACRT;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YLayer.mjs","names":["Teleport","Transition","computed","defineComponent","mergeProps","reactive","ref","toRef","watchEffect","shallowRef","useRender","useLayerGroup","useLazy","PolyTransition","polyTransitionPropOptions","usePolyTransition","ComplementClick","bindClasses","propsFactory","pressCoordinateProps","useCoordinate","pressYLayerProps","modelValue","type","Boolean","scrim","eager","classes","Array","String","Object","contentClasses","closeClickScrim","persistent","contentStyles","default","disabled","YLayer","name","inheritAttrs","components","directives","props","emits","value","mouseEvent","afterLeave","setup","_ref","emit","expose","attrs","slots","el$","base$","scrim$","content$","baseSlot","baseEl","layerGroup","polyTransitionBindProps","active","get","set","v","finish","lazyValue","onAfterUpdate","rendered","coordinate","coordinateStyles","updateCoordinate","contentEl","onClickComplementLayer","target","closeConditional","complementClickOption","handler","determine","include","onAfterEnter","onAfterLeave","onClickScrim","baseFromSlotEl","el","base","$el","computedStyle","zIndex","computedClass","boundClasses","computedContentClasses","slotBase","class","_createVNode","_Fragment","_mergeProps","_withDirectives","_vShow","_resolveDirective"],"sources":["../../../src/components/layer/YLayer.tsx"],"sourcesContent":["import type { CSSProperties, PropType } from 'vue';\nimport {\n Teleport,\n Transition,\n computed,\n defineComponent,\n mergeProps,\n nextTick,\n reactive,\n ref,\n toRef,\n watch,\n watchEffect, shallowRef\n} from \"vue\";\n\nimport { useRender } from '../../composables/component';\nimport { useLayerGroup } from '../../composables/layer-group';\nimport { useLazy } from '../../composables/timing';\nimport {\n PolyTransition,\n polyTransitionPropOptions,\n usePolyTransition,\n} from '../../composables/transition';\nimport {\n ComplementClick,\n ComplementClickBindingOptions,\n} from '../../directives/complement-click';\nimport { bindClasses, propsFactory } from \"../../util/vue-component\";\n\nimport './YLayer.scss';\nimport { pressCoordinateProps, useCoordinate } from \"../../composables/coordinate\";\n\nexport const pressYLayerProps = propsFactory({\n modelValue: {\n type: Boolean as PropType<boolean>,\n },\n scrim: {\n type: Boolean as PropType<boolean>,\n },\n eager: {\n type: Boolean as PropType<boolean>,\n },\n classes: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n contentClasses: {\n type: [Array, String, Object] as PropType<\n string[] | string | Record<string, any>\n >,\n },\n closeClickScrim: {\n type: Boolean as PropType<boolean>,\n },\n persistent: Boolean as PropType<boolean>,\n contentStyles: {\n type: Object as PropType<CSSProperties>,\n default: () => {},\n },\n disabled: {\n type: Boolean as PropType<boolean>,\n default: false,\n },\n ...polyTransitionPropOptions,\n ...pressCoordinateProps(),\n}, 'YLayer');\n\nexport const YLayer = defineComponent({\n name: 'YLayer',\n inheritAttrs: false,\n components: {\n PolyTransition,\n },\n directives: {\n ComplementClick,\n },\n props: {\n ...pressYLayerProps(),\n },\n emits: {\n 'update:modelValue': (value: boolean) => true,\n 'click:complement': (mouseEvent: MouseEvent) => true,\n 'afterLeave': () => true,\n },\n setup(props, { emit, expose, attrs, slots }) {\n const el$ = ref<typeof YLayer>();\n const base$ = ref();\n const scrim$ = ref<HTMLElement>();\n const content$ = ref<HTMLElement>();\n const baseSlot = ref();\n const baseEl = ref<HTMLElement>();\n\n const { layerGroup } = useLayerGroup();\n const { polyTransitionBindProps } = usePolyTransition(props);\n const active = computed<boolean>({\n get: (): boolean => {\n return !!props.modelValue;\n },\n set: (v: boolean) => {\n emit('update:modelValue', v);\n },\n });\n const finish = shallowRef(false);\n\n const disabled = toRef(props, 'disabled');\n const { lazyValue, onAfterUpdate } = useLazy(!!props.eager, active);\n const rendered = computed<boolean>(\n () => !disabled.value && (lazyValue.value || active.value),\n );\n\n\n const { coordinate, coordinateStyles, updateCoordinate } = useCoordinate(\n props,\n { contentEl: content$, baseEl, active },\n );\n\n function onClickComplementLayer(mouseEvent: MouseEvent) {\n emit('click:complement', mouseEvent);\n if (!props.persistent) {\n if (\n scrim$.value !== null &&\n scrim$.value === mouseEvent.target &&\n props.closeClickScrim\n ) {\n active.value = false;\n }\n } else {\n // TODO: shrug ani\n }\n }\n\n function closeConditional(): boolean {\n return active.value; // TODO: && groupTopLevel.value;\n }\n\n const complementClickOption = reactive<ComplementClickBindingOptions>({\n handler: onClickComplementLayer,\n determine: closeConditional,\n include: () => [],\n });\n\n function onAfterEnter() {\n finish.value = true;\n }\n\n function onAfterLeave() {\n onAfterUpdate();\n finish.value = false;\n emit('afterLeave')\n }\n\n function onClickScrim() {\n if (props.closeClickScrim) {\n active.value = false;\n }\n }\n\n const baseFromSlotEl = computed(() => {\n return baseSlot.value?.[0]?.el;\n });\n\n watchEffect(() => {\n if (!base$.value) {\n baseEl.value = baseFromSlotEl.value;\n return;\n }\n const base = base$.value;\n baseEl.value = base$.value?.$el ? base$.value?.$el : base;\n });\n\n const computedStyle = computed(() => {\n return {\n zIndex: '2000',\n };\n });\n\n const computedClass = computed<Record<string, boolean>>(() => {\n const { classes } = props;\n const boundClasses = bindClasses(classes);\n return {\n ...boundClasses,\n 'y-layer--active': !!active.value,\n };\n });\n\n const computedContentClasses = computed<Record<string, boolean>>(() => {\n const boundClasses = bindClasses(props.contentClasses);\n return {\n ...boundClasses,\n };\n });\n\n expose({\n scrim$,\n base$,\n content$,\n baseEl,\n active,\n onAfterUpdate,\n updateCoordinate,\n });\n\n useRender(() => {\n const slotBase = slots.base?.({\n active: active.value,\n props: mergeProps({\n ref: base$,\n class: {\n 'y-layer-base': true,\n 'y-layer-base--active': active.value,\n },\n }),\n });\n baseSlot.value = slotBase;\n return (\n <>\n {slotBase}\n <Teleport disabled={!layerGroup.value} to={layerGroup.value as any}>\n {rendered.value && (\n <div\n class={{ 'y-layer': true, 'y-layer--finish': finish.value, ...computedClass.value }}\n style={computedStyle.value}\n {...attrs}\n >\n <Transition name=\"fade\" appear>\n {active.value && props.scrim && (\n <div\n class=\"y-layer__scrim\"\n onClick={onClickScrim}\n ref=\"scrim$\"\n ></div>\n )}\n </Transition>\n <PolyTransition\n onAfterEnter={onAfterEnter}\n onAfterLeave={onAfterLeave}\n appear\n {...polyTransitionBindProps.value}\n >\n <div\n v-show={active.value}\n v-complement-click={{ ...complementClickOption }}\n class={{\n 'y-layer__content': true,\n ...computedContentClasses.value,\n }}\n style={[{...coordinateStyles.value, ...props.contentStyles}]}\n ref={content$}\n >\n {slots.default?.({ active: active.value })}\n </div>\n </PolyTransition>\n </div>\n )}\n </Teleport>\n </>\n );\n });\n\n return {\n complementClickOption,\n layerGroup,\n active,\n rendered,\n onAfterUpdate: onAfterUpdate as () => void,\n scrim$,\n content$,\n polyTransitionBindProps,\n coordinateStyles,\n };\n },\n});\n\nexport type YLayer = InstanceType<typeof YLayer>;\n"],"mappings":";AACA,SACEA,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,eAAe,EACfC,UAAU,EAEVC,QAAQ,EACRC,GAAG,EACHC,KAAK,EAELC,WAAW,EAAEC,UAAU,QAClB,KAAK;AAAC,SAEJC,SAAS;AAAA,SACTC,aAAa;AAAA,SACbC,OAAO;AAAA,SAEdC,cAAc,EACdC,yBAAyB,EACzBC,iBAAiB;AAAA,SAGjBC,eAAe;AAAA,SAGRC,WAAW,EAAEC,YAAY;AAElC;AAAuB,SACdC,oBAAoB,EAAEC,aAAa;AAE5C,OAAO,MAAMC,gBAAgB,GAAGH,YAAY,CAAC;EAC3CI,UAAU,EAAE;IACVC,IAAI,EAAEC;EACR,CAAC;EACDC,KAAK,EAAE;IACLF,IAAI,EAAEC;EACR,CAAC;EACDE,KAAK,EAAE;IACLH,IAAI,EAAEC;EACR,CAAC;EACDG,OAAO,EAAE;IACPJ,IAAI,EAAE,CAACK,KAAK,EAAEC,MAAM,EAAEC,MAAM;EAG9B,CAAC;EACDC,cAAc,EAAE;IACdR,IAAI,EAAE,CAACK,KAAK,EAAEC,MAAM,EAAEC,MAAM;EAG9B,CAAC;EACDE,eAAe,EAAE;IACfT,IAAI,EAAEC;EACR,CAAC;EACDS,UAAU,EAAET,OAA4B;EACxCU,aAAa,EAAE;IACbX,IAAI,EAAEO,MAAiC;IACvCK,OAAO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AAA,gBAGahB,YAAY;UAAA,gBACZC,YAAY;UAAA;QAAA,GAEtBrB,uBAAuB,CAAChB,KAAK;UAAAT,OAAA,EAAAA,CAAA,MAAA8D,eAAA,CAAAH,YAAA;YAAA,SAKxB;cACL,kBAAkB,EAAE,IAAI;cACxB,GAAGH,sBAAsB,CAAC/C;YAC5B,CAAC;YAAA,SACM,CAAC;cAAC,GAAG0B,gBAAgB,CAAC1B,KAAK;cAAE,GAAGF,KAAK,CAACR;YAAa,CAAC,CAAC;YAAA,OACvDsB;UAAQ,IAEZJ,KAAK,CAACjB,OAAO,GAAG;YAAE0B,MAAM,EAAEA,MAAM,CAACjB;UAAM,CAAC,CAAC,MAAAsD,MAAA,EATlCrC,MAAM,CAACjB,KAAK,IAAAuD,iBAAA,sBACA;YAAE,GAAGvB;UAAsB,CAAC;QAAA,IAYvD;MAAA;IAIT,CAAC,CAAC;IAEF,OAAO;MACLA,qBAAqB;MACrBjB,UAAU;MACVE,MAAM;MACNO,QAAQ;MACRD,aAAa,EAAEA,aAA2B;MAC1CZ,MAAM;MACNC,QAAQ;MACRI,uBAAuB;MACvBU;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
-
import { computed, defineComponent,
|
|
1
|
+
import { mergeProps as _mergeProps, createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
+
import { computed, defineComponent, ref, watch } from 'vue';
|
|
3
3
|
import { useModelDuplex } from "../../composables/communication.mjs";
|
|
4
4
|
import { useRender } from "../../composables/component.mjs";
|
|
5
|
+
import { pressCoordinateProps } from "../../composables/coordinate/index.mjs";
|
|
5
6
|
import { polyTransitionPropOptions } from "../../composables/transition.mjs";
|
|
6
7
|
import { toKebabCase } from "../../util/string.mjs";
|
|
7
|
-
import { bindClasses } from "../../util/vue-component.mjs";
|
|
8
|
+
import { bindClasses, chooseProps } from "../../util/vue-component.mjs";
|
|
8
9
|
import { YLayer } from "../layer/index.mjs";
|
|
9
10
|
import "./YMenu.scss";
|
|
10
|
-
import { toStyleSizeValue } from "../../util/ui.mjs";
|
|
11
11
|
const NAME = 'YMenu';
|
|
12
12
|
const CLASS_NAME = toKebabCase(NAME);
|
|
13
13
|
export const YMenuPropOptions = {
|
|
@@ -22,14 +22,6 @@ export const YMenuPropOptions = {
|
|
|
22
22
|
type: Boolean,
|
|
23
23
|
default: false
|
|
24
24
|
},
|
|
25
|
-
position: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'default'
|
|
28
|
-
},
|
|
29
|
-
align: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'start'
|
|
32
|
-
},
|
|
33
25
|
openOnHover: {
|
|
34
26
|
type: Boolean,
|
|
35
27
|
default: false
|
|
@@ -41,9 +33,9 @@ export const YMenuPropOptions = {
|
|
|
41
33
|
type: Boolean,
|
|
42
34
|
default: true
|
|
43
35
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
36
|
+
...pressCoordinateProps({
|
|
37
|
+
coordinateStrategy: 'levitation'
|
|
38
|
+
})
|
|
47
39
|
};
|
|
48
40
|
|
|
49
41
|
/**
|
|
@@ -66,10 +58,6 @@ export const YMenu = defineComponent({
|
|
|
66
58
|
expose
|
|
67
59
|
} = _ref;
|
|
68
60
|
const el$ = ref();
|
|
69
|
-
const base$ = ref();
|
|
70
|
-
const baseSlot = ref();
|
|
71
|
-
const baseEl = ref();
|
|
72
|
-
const contentEl = ref();
|
|
73
61
|
const classes = computed(() => {
|
|
74
62
|
const boundClasses = bindClasses(props.menuClasses);
|
|
75
63
|
return {
|
|
@@ -86,73 +74,6 @@ export const YMenu = defineComponent({
|
|
|
86
74
|
if (!(v && props.disabled)) model.value = v;
|
|
87
75
|
}
|
|
88
76
|
});
|
|
89
|
-
const position = toRef(props, 'position');
|
|
90
|
-
const align = toRef(props, 'align');
|
|
91
|
-
const coordinate = ref();
|
|
92
|
-
const coordinateStyles = computed(() => {
|
|
93
|
-
return coordinate.value ?? {};
|
|
94
|
-
});
|
|
95
|
-
function computeCoordinates() {
|
|
96
|
-
const $base = baseEl.value;
|
|
97
|
-
const actived = active.value;
|
|
98
|
-
if ($base && actived) {
|
|
99
|
-
const $content = contentEl.value;
|
|
100
|
-
const rect = $base.getBoundingClientRect();
|
|
101
|
-
let top = rect.top;
|
|
102
|
-
let left = rect.left + rect.width / 2;
|
|
103
|
-
if ($content) {
|
|
104
|
-
if (position.value === 'top' || position.value === 'bottom') {
|
|
105
|
-
if (position.value === 'top') {
|
|
106
|
-
top -= $content.clientHeight;
|
|
107
|
-
top -= 8; // Offset
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (position.value === 'bottom') {
|
|
111
|
-
top += rect.height;
|
|
112
|
-
top += 8; // Offset
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (align.value === 'center') {
|
|
117
|
-
left -= $content.clientWidth / 2;
|
|
118
|
-
} else if (align.value === 'start') {
|
|
119
|
-
left = rect.left;
|
|
120
|
-
} else if (align.value === 'end') {
|
|
121
|
-
left = rect.right;
|
|
122
|
-
left -= $content.clientWidth;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (props.offsetY) {
|
|
126
|
-
top += +props.offsetY;
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
top: `${top}px`,
|
|
130
|
-
left: `${left}px`,
|
|
131
|
-
minWidth: toStyleSizeValue(rect.width)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
return {};
|
|
135
|
-
}
|
|
136
|
-
const baseFromSlotEl = computed(() => {
|
|
137
|
-
return baseSlot.value?.[0]?.el;
|
|
138
|
-
});
|
|
139
|
-
watchEffect(() => {
|
|
140
|
-
if (!base$.value) {
|
|
141
|
-
baseEl.value = baseFromSlotEl.value;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const base = base$.value;
|
|
145
|
-
baseEl.value = base$.value?.$el ? base$.value?.$el : base;
|
|
146
|
-
});
|
|
147
|
-
watch(active, neo => {
|
|
148
|
-
if (neo) {
|
|
149
|
-
nextTick(() => {
|
|
150
|
-
const $content = el$.value?.content$;
|
|
151
|
-
contentEl.value = $content;
|
|
152
|
-
coordinate.value = computeCoordinates();
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
77
|
function onMouseenter(e) {
|
|
157
78
|
if (props.openOnHover) {
|
|
158
79
|
active.value = true;
|
|
@@ -182,7 +103,7 @@ export const YMenu = defineComponent({
|
|
|
182
103
|
el.removeEventListener('mouseenter', onMouseenter);
|
|
183
104
|
el.removeEventListener('mouseleave', onMouseleave);
|
|
184
105
|
}
|
|
185
|
-
watch(baseEl, (neo, old) => {
|
|
106
|
+
watch(() => el$.value?.baseEl, (neo, old) => {
|
|
186
107
|
if (neo) {
|
|
187
108
|
bindHover(neo);
|
|
188
109
|
neo.addEventListener('click', onClick);
|
|
@@ -192,45 +113,34 @@ export const YMenu = defineComponent({
|
|
|
192
113
|
}
|
|
193
114
|
});
|
|
194
115
|
useRender(() => {
|
|
195
|
-
|
|
196
|
-
active: active.value,
|
|
197
|
-
props: mergeProps({
|
|
198
|
-
ref: base$,
|
|
199
|
-
class: {
|
|
200
|
-
'y-menu-base': true,
|
|
201
|
-
'y-menu-base--active': active.value
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
});
|
|
205
|
-
baseSlot.value = slotBase;
|
|
206
|
-
return _createVNode(_Fragment, null, [slotBase, _createVNode(YLayer, {
|
|
207
|
-
"modelValue": active.value,
|
|
208
|
-
"onUpdate:modelValue": $event => active.value = $event,
|
|
116
|
+
return _createVNode(_Fragment, null, [_createVNode(YLayer, _mergeProps({
|
|
209
117
|
"ref": el$,
|
|
210
118
|
"classes": classes.value,
|
|
211
119
|
"scrim": false,
|
|
212
120
|
"disabled": props.disabled,
|
|
213
|
-
"content-styles": {
|
|
214
|
-
...coordinateStyles.value
|
|
215
|
-
},
|
|
216
121
|
"content-classes": ['y-menu__content'],
|
|
217
122
|
"transition": props.transition,
|
|
218
123
|
"onClick:complement": onComplementClick
|
|
219
|
-
}, {
|
|
124
|
+
}, chooseProps(props, YLayer.props), {
|
|
125
|
+
"modelValue": active.value,
|
|
126
|
+
"onUpdate:modelValue": $event => active.value = $event
|
|
127
|
+
}), {
|
|
220
128
|
default: function () {
|
|
221
129
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
222
130
|
args[_key] = arguments[_key];
|
|
223
131
|
}
|
|
224
132
|
return _createVNode(_Fragment, null, [slots.default?.(...args) ?? '']);
|
|
133
|
+
},
|
|
134
|
+
base: function () {
|
|
135
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
136
|
+
args[_key2] = arguments[_key2];
|
|
137
|
+
}
|
|
138
|
+
return slots.base?.(...args);
|
|
225
139
|
}
|
|
226
140
|
})]);
|
|
227
141
|
});
|
|
228
142
|
return {
|
|
229
|
-
|
|
230
|
-
el$,
|
|
231
|
-
baseEl,
|
|
232
|
-
coordinatesStyles: coordinateStyles,
|
|
233
|
-
baseSlot
|
|
143
|
+
el$
|
|
234
144
|
};
|
|
235
145
|
}
|
|
236
146
|
});
|