@kernel4632/kima 0.30.0 → 0.31.0
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/README.md +21 -6
- package/dist/components/containment/morph.ce.vue_vue_type_style_index_0_scoped_10a98d89_lang.css +1 -0
- package/dist/components/core/combobox.ce.vue_vue_type_style_index_0_scoped_82d70c66_lang.css +1 -0
- package/dist/components/core/dialog.ce.vue_vue_type_style_index_0_scoped_638cbfdc_lang.css +1 -0
- package/dist/components/core/{fab-menu.ce.vue_vue_type_style_index_0_scoped_7c25d968_lang.css → fab-menu.ce.vue_vue_type_style_index_0_scoped_eff6cc0c_lang.css} +1 -1
- package/dist/components/core/{morph-field.ce.vue_vue_type_style_index_0_scoped_47863e8f_lang.css → morph-field.ce.vue_vue_type_style_index_0_scoped_d8ed6708_lang.css} +1 -1
- package/dist/components/core/{select.ce.vue_vue_type_style_index_0_scoped_bf4d9de4_lang.css → select.ce.vue_vue_type_style_index_0_scoped_8fda1ce2_lang.css} +1 -1
- package/dist/components/core/split-button.ce.vue_vue_type_style_index_0_scoped_b4a612b7_lang.css +1 -0
- package/dist/kima-elements-core.js +2325 -2342
- package/dist/kima-elements.js +7591 -7234
- package/dist/kima.js +21 -20
- package/dist/style.css +9 -7
- package/dist/styles/_tokens.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/core.css +6 -6
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/morph-field.css +1 -1
- package/dist/styles/morph.css +2 -0
- package/dist/styles/select.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/vue/components/containment/morph.ce.js +81 -0
- package/dist/vue/components/core/combobox.ce.js +116 -117
- package/dist/vue/components/core/dialog.ce.js +55 -56
- package/dist/vue/components/core/fab-menu.ce.js +51 -59
- package/dist/vue/components/core/morph-field.ce.js +33 -35
- package/dist/vue/components/core/select.ce.js +167 -168
- package/dist/vue/components/core/split-button.ce.js +54 -62
- package/dist/vue/utils/interaction.js +19 -22
- package/dist/vue/utils/model.js +29 -0
- package/dist/vue/utils/morph.js +306 -0
- package/dist/vue/utils/navigation.js +14 -17
- package/dist/vue/utils/shell.js +12 -20
- package/package.json +1 -1
- package/dist/components/core/combobox.ce.vue_vue_type_style_index_0_scoped_ba7220f2_lang.css +0 -1
- package/dist/components/core/dialog.ce.vue_vue_type_style_index_0_scoped_09f96946_lang.css +0 -1
- package/dist/components/core/split-button.ce.vue_vue_type_style_index_0_scoped_a8ef75a5_lang.css +0 -1
|
@@ -2,21 +2,22 @@ import { useNormalizedRadius as e } from "../../utils/radius.js";
|
|
|
2
2
|
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
3
|
import n from "./icon.ce.js";
|
|
4
4
|
import { useRipple as r } from "../../utils/ripple.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { useModelState as i } from "../../utils/model.js";
|
|
6
|
+
import { register as a, unregister as o } from "../../utils/popup-manager.js";
|
|
7
|
+
import { cancelPopupLeave as s, playPopupLeave as c } from "../../utils/popup-motion.js";
|
|
8
|
+
import { dismissInteraction as l } from "../../utils/interaction.js";
|
|
8
9
|
/* empty css */
|
|
9
|
-
import { Fragment as
|
|
10
|
-
import { ArrowDown01Icon as
|
|
11
|
-
import { PopoverContent as
|
|
10
|
+
import { Fragment as ee, computed as te, createBlock as ne, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createVNode as p, mergeProps as m, nextTick as h, normalizeClass as g, onBeforeUnmount as _, onMounted as v, openBlock as y, ref as b, renderList as x, toDisplayString as S, unref as C, useAttrs as re, useId as ie, watch as w, withCtx as T } from "vue";
|
|
11
|
+
import { ArrowDown01Icon as E } from "@hugeicons/core-free-icons";
|
|
12
|
+
import { PopoverContent as D, PopoverRoot as O } from "reka-ui";
|
|
12
13
|
// src/components/core/split-button.ce.vue
|
|
13
|
-
var
|
|
14
|
+
var k = ["disabled"], A = [
|
|
14
15
|
"disabled",
|
|
15
16
|
"aria-expanded",
|
|
16
17
|
"aria-label"
|
|
17
|
-
],
|
|
18
|
+
], j = ["aria-label"], M = ["disabled", "onClick"], N = /*#__PURE__*/ t(/* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
18
19
|
__name: "split-button.ce",
|
|
19
|
-
props:
|
|
20
|
+
props: {
|
|
20
21
|
label: {
|
|
21
22
|
type: String,
|
|
22
23
|
default: ""
|
|
@@ -33,94 +34,85 @@ var j = ["disabled"], M = [
|
|
|
33
34
|
radius: {
|
|
34
35
|
type: [String, Number],
|
|
35
36
|
default: null
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
open: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: !1
|
|
41
37
|
},
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
emits:
|
|
38
|
+
open: Boolean
|
|
39
|
+
},
|
|
40
|
+
emits: [
|
|
45
41
|
"update:open",
|
|
46
42
|
"select",
|
|
47
43
|
"click"
|
|
48
|
-
],
|
|
49
|
-
setup(t, { emit:
|
|
50
|
-
let
|
|
44
|
+
],
|
|
45
|
+
setup(t, { emit: N }) {
|
|
46
|
+
let P = t, F = N, [I, L] = i(P, "open", F), R = re(), z = b(null), B = b(null), V = b(null), H = b(null), { radiusAttrs: U, radiusStyle: W } = e(V, () => P.radius);
|
|
51
47
|
r(z), r(B);
|
|
52
|
-
let G =
|
|
48
|
+
let G = te(() => [
|
|
53
49
|
"filled",
|
|
54
50
|
"tonal",
|
|
55
51
|
"outlined",
|
|
56
52
|
"elevated"
|
|
57
|
-
].includes(
|
|
53
|
+
].includes(P.variant) ? P.variant : "filled");
|
|
58
54
|
function K() {
|
|
59
|
-
!
|
|
55
|
+
!P.disabled && P.items.length && L(!I.value);
|
|
60
56
|
}
|
|
61
57
|
function q(e) {
|
|
62
|
-
e.disabled || (L
|
|
58
|
+
e.disabled || (L(!1), F("select", e.value));
|
|
63
59
|
}
|
|
64
|
-
let J = `kima-split-button-${
|
|
60
|
+
let J = `kima-split-button-${ie()}`, Y = !1, ae = (e) => e.includes(V.value) || e.includes(H.value);
|
|
65
61
|
function X(e) {
|
|
66
|
-
Y && (e ?
|
|
67
|
-
close: () =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
isInside: ie
|
|
71
|
-
}) : a(J));
|
|
62
|
+
Y && (e ? a(J, {
|
|
63
|
+
close: () => L(!1),
|
|
64
|
+
isInside: ae
|
|
65
|
+
}) : o(J));
|
|
72
66
|
}
|
|
73
|
-
|
|
74
|
-
let Z =
|
|
75
|
-
|
|
76
|
-
e ? (Q += 1, Z.value = !1,
|
|
77
|
-
if (!H.value ||
|
|
67
|
+
w(I, X);
|
|
68
|
+
let Z = b(!1), Q = 0;
|
|
69
|
+
w(I, (e) => {
|
|
70
|
+
e ? (Q += 1, Z.value = !1, s(H.value)) : H.value && (Z.value = !0, h(() => {
|
|
71
|
+
if (!H.value || I.value) return;
|
|
78
72
|
let e = ++Q;
|
|
79
|
-
|
|
73
|
+
c(H.value, () => {
|
|
80
74
|
e === Q && (Z.value = !1);
|
|
81
75
|
});
|
|
82
76
|
}));
|
|
83
77
|
});
|
|
84
78
|
function $(e) {
|
|
85
|
-
|
|
86
|
-
L.value = !1;
|
|
87
|
-
});
|
|
79
|
+
I.value && e.key === "Escape" && l(e, () => L(!1));
|
|
88
80
|
}
|
|
89
|
-
return
|
|
90
|
-
Y = !0, X(
|
|
91
|
-
}),
|
|
92
|
-
Y = !1,
|
|
93
|
-
}), (e, r) => (
|
|
81
|
+
return v(() => {
|
|
82
|
+
Y = !0, X(I.value), window.addEventListener("keydown", $, !0);
|
|
83
|
+
}), _(() => {
|
|
84
|
+
Y = !1, o(J), window.removeEventListener("keydown", $, !0);
|
|
85
|
+
}), (e, r) => (y(), d("div", m({
|
|
94
86
|
ref_key: "root",
|
|
95
87
|
ref: V
|
|
96
|
-
},
|
|
97
|
-
style:
|
|
88
|
+
}, C(U), {
|
|
89
|
+
style: C(W),
|
|
98
90
|
class: ["kima-split-button", `kima-split-button--${G.value}`]
|
|
99
91
|
}), [
|
|
100
|
-
f("button",
|
|
92
|
+
f("button", m({
|
|
101
93
|
ref_key: "mainButton",
|
|
102
94
|
ref: z,
|
|
103
95
|
class: "kima-split-button__main",
|
|
104
96
|
disabled: t.disabled
|
|
105
|
-
},
|
|
97
|
+
}, C(R), { onClick: r[0] ||= (e) => F("click", e) }), [f("span", null, S(t.label), 1)], 16, k),
|
|
106
98
|
f("button", {
|
|
107
99
|
ref_key: "trailButton",
|
|
108
100
|
ref: B,
|
|
109
|
-
class:
|
|
101
|
+
class: g(["kima-split-button__trail", { "kima-split-button__trail--open": C(I) }]),
|
|
110
102
|
disabled: t.disabled,
|
|
111
|
-
"aria-expanded":
|
|
103
|
+
"aria-expanded": C(I),
|
|
112
104
|
"aria-haspopup": "menu",
|
|
113
105
|
"aria-label": `${t.label} 更多选项`,
|
|
114
106
|
onClick: K
|
|
115
107
|
}, [p(n, {
|
|
116
|
-
icon:
|
|
108
|
+
icon: C(E),
|
|
117
109
|
size: 20
|
|
118
|
-
}, null, 8, ["icon"])], 10,
|
|
119
|
-
p(
|
|
120
|
-
open:
|
|
110
|
+
}, null, 8, ["icon"])], 10, A),
|
|
111
|
+
p(C(O), {
|
|
112
|
+
open: C(I) && !t.disabled,
|
|
121
113
|
modal: !1
|
|
122
114
|
}, {
|
|
123
|
-
default:
|
|
115
|
+
default: T(() => [C(I) || Z.value ? (y(), ne(C(D), {
|
|
124
116
|
key: 0,
|
|
125
117
|
"as-child": "",
|
|
126
118
|
reference: V.value,
|
|
@@ -133,24 +125,24 @@ var j = ["disabled"], M = [
|
|
|
133
125
|
"hide-when-detached": "",
|
|
134
126
|
"force-mount": ""
|
|
135
127
|
}, {
|
|
136
|
-
default:
|
|
128
|
+
default: T(() => [f("div", {
|
|
137
129
|
ref_key: "menu",
|
|
138
130
|
ref: H,
|
|
139
131
|
class: "kima-split-button__menu",
|
|
140
132
|
role: "menu",
|
|
141
133
|
"aria-label": `${t.label} 菜单`
|
|
142
|
-
}, [(
|
|
134
|
+
}, [(y(!0), d(ee, null, x(t.items, (e) => (y(), d("button", {
|
|
143
135
|
key: e.value,
|
|
144
136
|
class: "kima-split-button__menu-item",
|
|
145
137
|
role: "menuitem",
|
|
146
138
|
disabled: e.disabled,
|
|
147
139
|
onClick: (t) => q(e)
|
|
148
|
-
},
|
|
140
|
+
}, S(e.label), 9, M))), 128))], 8, j)]),
|
|
149
141
|
_: 1
|
|
150
|
-
}, 8, ["reference"])) :
|
|
142
|
+
}, 8, ["reference"])) : u("", !0)]),
|
|
151
143
|
_: 1
|
|
152
144
|
}, 8, ["open"])
|
|
153
145
|
], 16));
|
|
154
146
|
}
|
|
155
|
-
}), [["__scopeId", "data-v-
|
|
156
|
-
export {
|
|
147
|
+
}), [["__scopeId", "data-v-b4a612b7"]]);
|
|
148
|
+
export { N as default };
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { useNativeSlots as e } from "./native-slots.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useModelState as t } from "./model.js";
|
|
3
|
+
import { computed as n, ref as r, useAttrs as i } from "vue";
|
|
3
4
|
// src/utils/interaction.js
|
|
4
|
-
function
|
|
5
|
-
let
|
|
5
|
+
function a() {
|
|
6
|
+
let t = r(null), a = i(), { hasNativeSlot: o, isCustomElement: s } = e(t);
|
|
6
7
|
return {
|
|
7
|
-
root:
|
|
8
|
-
attrs:
|
|
9
|
-
forwardedAttrs:
|
|
10
|
-
...
|
|
8
|
+
root: t,
|
|
9
|
+
attrs: a,
|
|
10
|
+
forwardedAttrs: n(() => s ? {
|
|
11
|
+
...a,
|
|
11
12
|
id: void 0
|
|
12
|
-
} :
|
|
13
|
+
} : a),
|
|
13
14
|
hasNativeSlot: o
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
function u(e) {
|
|
22
|
-
Object.is(l.value, e) || (l.value = c(e), a && (a[t] = c(e)), r(`update:${t}`, c(e)));
|
|
23
|
-
}
|
|
24
|
-
return [l, u];
|
|
17
|
+
function o(e, n, r) {
|
|
18
|
+
return t(e, n, r, {
|
|
19
|
+
clone: (e) => Array.isArray(e) ? [...e] : e,
|
|
20
|
+
deep: !0
|
|
21
|
+
});
|
|
25
22
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
23
|
+
function s(e) {
|
|
24
|
+
return n(() => {
|
|
28
25
|
let [t, n] = String(e.placement || "bottom-start").split("-");
|
|
29
26
|
return {
|
|
30
27
|
side: [
|
|
@@ -41,14 +38,14 @@ function u(e) {
|
|
|
41
38
|
};
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
|
-
function
|
|
41
|
+
function c(e, t) {
|
|
45
42
|
e.preventDefault(), e.stopPropagation(), t();
|
|
46
43
|
}
|
|
47
|
-
function
|
|
44
|
+
function l(e) {
|
|
48
45
|
let t = [];
|
|
49
46
|
function n(e) {
|
|
50
47
|
for (let r of e) t.push(r), Array.isArray(r.children) && n(r.children);
|
|
51
48
|
}
|
|
52
49
|
return n(e), t;
|
|
53
50
|
}
|
|
54
|
-
export {
|
|
51
|
+
export { c as dismissInteraction, l as flattenChoices, o as useInteractionModel, a as useInteractionRoot, s as usePlacement };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { computed as e, getCurrentInstance as t, ref as n, shallowRef as r, useHost as i, watch as a } from "vue";
|
|
2
|
+
// src/utils/model.js
|
|
3
|
+
var o = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
4
|
+
function s(s, c, l, { clone: u = (e) => e, deep: d = !1, claim: f = (e, t) => t } = {}) {
|
|
5
|
+
let p = t(), m = p?.ce ? i() : null, h = o(c), g = r(u(s[c]));
|
|
6
|
+
function _() {
|
|
7
|
+
if (m) return !1;
|
|
8
|
+
let e = p?.vnode?.props;
|
|
9
|
+
if (!e) return !1;
|
|
10
|
+
let t = Object.hasOwn(e, c) ? c : Object.hasOwn(e, h) ? h : null;
|
|
11
|
+
return t !== null && e[t] !== void 0;
|
|
12
|
+
}
|
|
13
|
+
let v = n(f(s[c], _()));
|
|
14
|
+
function y() {
|
|
15
|
+
return !v.value && _() && (v.value = !0), f(s[c], v.value);
|
|
16
|
+
}
|
|
17
|
+
let b = e(() => f(s[c], v.value) ? s[c] : g.value);
|
|
18
|
+
a(() => s[c], (e) => {
|
|
19
|
+
!v.value && _() && (v.value = !0), g.value = u(e);
|
|
20
|
+
}, { deep: d });
|
|
21
|
+
function x(e) {
|
|
22
|
+
if (y()) return !Object.is(s[c], e) && (l(`update:${c}`, u(e)), !0);
|
|
23
|
+
if (Object.is(g.value, e)) return !1;
|
|
24
|
+
let t = u(e);
|
|
25
|
+
return g.value = t, m && (m[c] = t), l(`update:${c}`, u(e)), !0;
|
|
26
|
+
}
|
|
27
|
+
return [b, x];
|
|
28
|
+
}
|
|
29
|
+
export { s as useModelState };
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { prefersReducedMotion as e } from "./motion.js";
|
|
2
|
+
import { computed as t, onBeforeUnmount as n, onMounted as r, ref as i, shallowRef as a, watch as o } from "vue";
|
|
3
|
+
// src/utils/morph.js
|
|
4
|
+
var s = "data-morph-part", c = "data-morph-height", l = "data-morph-height-source", u = "data-morph-when", d = "data-morph-grow", f = "data-morph-reflow", p = "data-morph-anchor", ee = [
|
|
5
|
+
"width",
|
|
6
|
+
"height",
|
|
7
|
+
"x",
|
|
8
|
+
"y",
|
|
9
|
+
"line-center",
|
|
10
|
+
"visible"
|
|
11
|
+
];
|
|
12
|
+
function m(e) {
|
|
13
|
+
return `${Math.round(e * 100) / 100}px`;
|
|
14
|
+
}
|
|
15
|
+
function h(e) {
|
|
16
|
+
return Math.round(e * 100) / 100;
|
|
17
|
+
}
|
|
18
|
+
function g(e) {
|
|
19
|
+
return Number.parseFloat(e) || 0;
|
|
20
|
+
}
|
|
21
|
+
function _(e) {
|
|
22
|
+
return e?.getBoundingClientRect().height || 0;
|
|
23
|
+
}
|
|
24
|
+
function v(e) {
|
|
25
|
+
let t = e?.ownerDocument?.defaultView;
|
|
26
|
+
if (!t) return {
|
|
27
|
+
duration: 320,
|
|
28
|
+
easing: "ease-out"
|
|
29
|
+
};
|
|
30
|
+
let n = t.getComputedStyle(e);
|
|
31
|
+
for (let e of ["--kima-morph-spring", "--kima-spring-spatial-m3-close"]) {
|
|
32
|
+
let t = n.getPropertyValue(e).trim().match(/^([\d.]+)(ms|s)\s+([\s\S]+)$/);
|
|
33
|
+
if (t) return {
|
|
34
|
+
duration: t[2] === "ms" ? Number(t[1]) : Number(t[1]) * 1e3,
|
|
35
|
+
easing: t[3].trim()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
let r = n.getPropertyValue("--kima-duration-slow").trim(), i = /^([\d.]+)(ms|s)$/.exec(r);
|
|
39
|
+
return {
|
|
40
|
+
duration: i ? i[2] === "ms" ? Number(i[1]) : Number(i[1]) * 1e3 : 320,
|
|
41
|
+
easing: "ease-out"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function y(e, t, n, r = v(e)) {
|
|
45
|
+
return e.animate([{ height: `${t}px` }, { height: `${n}px` }], {
|
|
46
|
+
duration: r.duration,
|
|
47
|
+
easing: r.easing,
|
|
48
|
+
fill: "both"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function te(e, t) {
|
|
52
|
+
let n = e.ownerDocument.defaultView;
|
|
53
|
+
if (!n) return 0;
|
|
54
|
+
let r = (t.matches("textarea, input, [contenteditable]") ? t : t.querySelector("textarea, input, [contenteditable]:not([contenteditable=\"false\"])")) || t, i = n.getComputedStyle(r), a = g(i.lineHeight) || g(i.fontSize) * 1.5 || 20;
|
|
55
|
+
return r.getBoundingClientRect().top - e.getBoundingClientRect().top + g(i.borderTopWidth) + g(i.paddingTop) + a / 2;
|
|
56
|
+
}
|
|
57
|
+
function b(v, b = {}) {
|
|
58
|
+
let x = i(!1), S = a(/* @__PURE__ */ new Map()), C = t(() => !!b.expanded?.()), ne = b.grow === "animate" ? "animate" : "instant", w = null, T = null, E = 0, D = 0, O = !1, k = -1, A = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), ie = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
function P(e, t) {
|
|
60
|
+
let n = e.get(t);
|
|
61
|
+
return n || (n = /* @__PURE__ */ new Map(), e.set(t, n)), n;
|
|
62
|
+
}
|
|
63
|
+
function F(e, t, n, r, i) {
|
|
64
|
+
t.get(n) !== i && (t.set(n, i), e.style.setProperty(r, i));
|
|
65
|
+
}
|
|
66
|
+
function ae(e, t) {
|
|
67
|
+
let n = P(re, e);
|
|
68
|
+
if (F(e, n, "width", "--kima-morph-width", m(t.width)), F(e, n, "height", "--kima-morph-height", m(t.height)), F(e, n, "x", "--kima-morph-x", m(t.x)), F(e, n, "y", "--kima-morph-y", m(t.y)), t.lineCenter !== null && F(e, n, "line-center", "--kima-morph-line-center", m(t.lineCenter)), F(e, n, "visible", "--kima-morph-visible", t.visible ? "1" : "0"), e.getAttribute(u)) {
|
|
69
|
+
let n = t.visible ? "true" : "false";
|
|
70
|
+
e.getAttribute("data-morph-visible") !== n && e.setAttribute("data-morph-visible", n), N.get(e) !== !t.visible && (N.set(e, !t.visible), t.visible ? e.removeAttribute("inert") : e.setAttribute("inert", ""));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function I(e, t, n) {
|
|
74
|
+
let r = j.get(t);
|
|
75
|
+
r || (r = /* @__PURE__ */ new Map(), j.set(t, r));
|
|
76
|
+
for (let i of ee) {
|
|
77
|
+
let a = n[i === "line-center" ? "lineCenter" : i];
|
|
78
|
+
a == null ? r.has(i) && (e.style.removeProperty(`--kima-morph-${t}-${i}`), r.delete(i)) : F(e, r, i, `--kima-morph-${t}-${i}`, typeof a == "number" ? m(a) : a);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function L(e) {
|
|
82
|
+
let t = v.value;
|
|
83
|
+
for (let [n, r] of j) if (!e.has(n)) {
|
|
84
|
+
for (let e of r.keys()) t?.style.removeProperty(`--kima-morph-${n}-${e}`);
|
|
85
|
+
j.delete(n);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function R(e) {
|
|
89
|
+
w && e && e.nodeType === 1 && !A.has(e) && (A.add(e), w.observe(e));
|
|
90
|
+
}
|
|
91
|
+
function z(e) {
|
|
92
|
+
for (let t of A) t !== e && (t.isConnected && e.contains(t) || (w?.unobserve(t), A.delete(t)));
|
|
93
|
+
}
|
|
94
|
+
function B(e) {
|
|
95
|
+
return e.querySelector(`[${l}]`) || e.firstElementChild || e;
|
|
96
|
+
}
|
|
97
|
+
function V(e, t) {
|
|
98
|
+
let n = _(t);
|
|
99
|
+
if (t === e) return n;
|
|
100
|
+
let r = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
101
|
+
return n + g(r.paddingTop) + g(r.paddingBottom) + g(r.borderTopWidth) + g(r.borderBottomWidth);
|
|
102
|
+
}
|
|
103
|
+
function H(t) {
|
|
104
|
+
if (!t?.isConnected || !x.value || e(t)) return;
|
|
105
|
+
let n = G(t);
|
|
106
|
+
if (n.animation) return;
|
|
107
|
+
if (B(t) === t) {
|
|
108
|
+
U(t, n);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (n.holding) {
|
|
112
|
+
t.style.height = `${n.hold}px`;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let r = n.natural >= 0 ? n.natural : _(t);
|
|
116
|
+
n.holding = !0, n.hold = r, n.holdStyle = t.style.height, t.style.height = `${r}px`;
|
|
117
|
+
}
|
|
118
|
+
function U(e, t) {
|
|
119
|
+
t.holding && (t.holding = !1, t.hold = -1, e.style.height = t.holdStyle, t.holdStyle = "");
|
|
120
|
+
}
|
|
121
|
+
function W(e, t) {
|
|
122
|
+
U(e, t), t.animation && (t.animation.cancel(), t.animation = null, e.style.overflow = t.overflow);
|
|
123
|
+
}
|
|
124
|
+
function G(e) {
|
|
125
|
+
let t = M.get(e);
|
|
126
|
+
return t || (t = {
|
|
127
|
+
natural: -1,
|
|
128
|
+
width: -1,
|
|
129
|
+
animation: null,
|
|
130
|
+
overflow: "",
|
|
131
|
+
holding: !1,
|
|
132
|
+
hold: -1,
|
|
133
|
+
holdStyle: ""
|
|
134
|
+
}, M.set(e, t)), t;
|
|
135
|
+
}
|
|
136
|
+
function K(e, t) {
|
|
137
|
+
let n = G(e);
|
|
138
|
+
W(e, n);
|
|
139
|
+
let r = B(e);
|
|
140
|
+
n.natural = t, n.width = r.getBoundingClientRect().width;
|
|
141
|
+
}
|
|
142
|
+
function oe(e) {
|
|
143
|
+
return !!e.getAnimations?.().some((e) => e.transitionProperty === "height");
|
|
144
|
+
}
|
|
145
|
+
function q(e) {
|
|
146
|
+
e?.isConnected && Y(e, V(e, B(e)));
|
|
147
|
+
}
|
|
148
|
+
let J = `[${u}][data-morph-hidden="block"]`;
|
|
149
|
+
function se(e) {
|
|
150
|
+
let t = v.value;
|
|
151
|
+
if (!t) return;
|
|
152
|
+
let n = (e) => e?.closest("[data-kima-morph]") === t, r = /* @__PURE__ */ new Set();
|
|
153
|
+
for (let i of e) {
|
|
154
|
+
let e = i.target.nodeType === 1 ? i.target : i.target.parentElement;
|
|
155
|
+
if (!e || !t.contains(e)) continue;
|
|
156
|
+
let a = e.closest(`[${c}]`);
|
|
157
|
+
if (a && a !== t && n(a)) {
|
|
158
|
+
if (r.has(a)) continue;
|
|
159
|
+
r.add(a), q(a);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let o = e.closest(J);
|
|
163
|
+
o && n(o) && o.getAttribute("data-morph-visible") === "true" && (r.has(o) || (r.add(o), q(o)));
|
|
164
|
+
}
|
|
165
|
+
r.size && Q();
|
|
166
|
+
}
|
|
167
|
+
function ce(e, t) {
|
|
168
|
+
return t.animation ? _(e) : t.holding ? t.hold : e.matches(J) && oe(e) ? _(e) : t.natural;
|
|
169
|
+
}
|
|
170
|
+
function Y(t, n, { reflow: r, grow: i } = {}) {
|
|
171
|
+
if (!t) return;
|
|
172
|
+
let a = G(t), o = B(t).getBoundingClientRect().width;
|
|
173
|
+
if (r === void 0 && (r = a.width >= 0 && Math.abs(o - a.width) > .5, t.getAttribute(f) === "ignore" && (r = !1)), a.width = o, a.natural < 0) {
|
|
174
|
+
a.natural = n, U(t, a);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (Math.abs(n - a.natural) < .5) {
|
|
178
|
+
U(t, a);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
let s = ce(t, a);
|
|
182
|
+
a.natural = n;
|
|
183
|
+
let c = (i || t.getAttribute(d) || (t.matches(J) ? "animate" : ne)) !== "animate";
|
|
184
|
+
if (!x.value || r || e(t) || !t.animate || c && n >= s - .5 || Math.abs(n - s) < .5) {
|
|
185
|
+
W(t, a);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
W(t, a), a.overflow = t.style.overflow, t.style.overflow = "clip";
|
|
189
|
+
let l = y(t, s, n);
|
|
190
|
+
a.animation = l, l.finished.then(() => {
|
|
191
|
+
a.animation === l && (a.animation = null, l.cancel(), t.style.overflow = a.overflow);
|
|
192
|
+
}).catch(() => {});
|
|
193
|
+
}
|
|
194
|
+
function le(e, t) {
|
|
195
|
+
let n = e.getAttribute(u);
|
|
196
|
+
return n ? n === "expanded" ? t : !t : null;
|
|
197
|
+
}
|
|
198
|
+
function X() {
|
|
199
|
+
let e = v.value;
|
|
200
|
+
if (!e) return;
|
|
201
|
+
let t = C.value;
|
|
202
|
+
for (let n of e.querySelectorAll(`[${u}]`)) {
|
|
203
|
+
let e = le(n, t), r = e ? "true" : "false", i = n.getAttribute("data-morph-visible") === "true", a = n.getAttribute("data-morph-hidden") === "block", o = i !== e;
|
|
204
|
+
a && o && !e && K(n, V(n, B(n))), n.getAttribute("data-morph-visible") !== r && n.setAttribute("data-morph-visible", r), a && o && e && K(n, V(n, B(n))), F(n, P(ie, n), "visible", "--kima-morph-visible", e ? "1" : "0"), N.get(n) !== !e && (N.set(n, !e), e ? n.removeAttribute("inert") : n.setAttribute("inert", "")), R(n);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function Z() {
|
|
208
|
+
E = 0;
|
|
209
|
+
let e = v.value;
|
|
210
|
+
if (!e) return;
|
|
211
|
+
let t = e.getBoundingClientRect();
|
|
212
|
+
k = t.width;
|
|
213
|
+
let n = C.value, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
214
|
+
for (let a of e.querySelectorAll(`[${s}]`)) {
|
|
215
|
+
let o = a.getAttribute(s).trim();
|
|
216
|
+
if (!o) continue;
|
|
217
|
+
let c = a.getBoundingClientRect(), l = a.getAttribute(u), d = !l || (l === "expanded" ? n : !n), f = {
|
|
218
|
+
width: h(c.width),
|
|
219
|
+
height: h(c.height),
|
|
220
|
+
x: h(c.left - t.left),
|
|
221
|
+
y: h(c.top - t.top),
|
|
222
|
+
lineCenter: a.hasAttribute(p) ? h(te(e, a)) : null,
|
|
223
|
+
visible: d
|
|
224
|
+
};
|
|
225
|
+
r.set(o, f), i.add(o), ae(a, f), I(e, o, f), R(a);
|
|
226
|
+
}
|
|
227
|
+
L(i);
|
|
228
|
+
for (let t of e.querySelectorAll(`[${c}]`)) {
|
|
229
|
+
let e = B(t);
|
|
230
|
+
R(e), R(t);
|
|
231
|
+
let n = M.get(t);
|
|
232
|
+
e === t && n?.animation || Y(t, V(t, e));
|
|
233
|
+
}
|
|
234
|
+
for (let t of e.querySelectorAll(J)) {
|
|
235
|
+
if (t.getAttribute("data-morph-visible") !== "true") continue;
|
|
236
|
+
let e = B(t);
|
|
237
|
+
R(e), R(t), !M.has(t) && K(t, V(t, e));
|
|
238
|
+
}
|
|
239
|
+
z(e), S.value = r, b.onMeasure?.({
|
|
240
|
+
root: e,
|
|
241
|
+
expanded: n,
|
|
242
|
+
parts: r,
|
|
243
|
+
setExpanded: b.setExpanded,
|
|
244
|
+
syncHeight: Y
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function Q() {
|
|
248
|
+
if (O) return;
|
|
249
|
+
let e = v.value?.ownerDocument?.defaultView;
|
|
250
|
+
e?.requestAnimationFrame ? E ||= e.requestAnimationFrame(Z) : Z();
|
|
251
|
+
}
|
|
252
|
+
function ue(e) {
|
|
253
|
+
let t = !1;
|
|
254
|
+
for (let n of e) {
|
|
255
|
+
if (n.target !== v.value) {
|
|
256
|
+
if (M.get(n.target)?.animation) continue;
|
|
257
|
+
t = !0;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
let e = n.borderBoxSize?.[0]?.inlineSize ?? n.contentRect.width;
|
|
261
|
+
Math.abs(e - k) < .5 || (t = !0);
|
|
262
|
+
}
|
|
263
|
+
t && Q();
|
|
264
|
+
}
|
|
265
|
+
function de() {
|
|
266
|
+
let e = v.value;
|
|
267
|
+
if (e) for (let t of e.querySelectorAll(`[${c}]`)) H(t);
|
|
268
|
+
}
|
|
269
|
+
o(C, () => {
|
|
270
|
+
de(), X(), $(), Q();
|
|
271
|
+
}, { flush: "post" });
|
|
272
|
+
function $() {
|
|
273
|
+
let e = v.value;
|
|
274
|
+
if (!e) return;
|
|
275
|
+
let t = C.value ? "true" : "false";
|
|
276
|
+
e.getAttribute("data-morph-expanded") !== t && e.setAttribute("data-morph-expanded", t);
|
|
277
|
+
}
|
|
278
|
+
return r(() => {
|
|
279
|
+
let e = v.value;
|
|
280
|
+
if (!e) return;
|
|
281
|
+
e.setAttribute("data-kima-morph", ""), X(), $();
|
|
282
|
+
let t = e.ownerDocument.defaultView;
|
|
283
|
+
t?.ResizeObserver && (w = new t.ResizeObserver(ue), R(e)), Z(), t?.MutationObserver && (T = new t.MutationObserver(se), T.observe(e, {
|
|
284
|
+
childList: !0,
|
|
285
|
+
characterData: !0,
|
|
286
|
+
subtree: !0
|
|
287
|
+
})), t?.requestAnimationFrame ? D = t.requestAnimationFrame(() => {
|
|
288
|
+
D = t.requestAnimationFrame(() => {
|
|
289
|
+
O || (x.value = !0, e.setAttribute("data-morph-ready", ""));
|
|
290
|
+
});
|
|
291
|
+
}) : (x.value = !0, e.setAttribute("data-morph-ready", ""));
|
|
292
|
+
}), n(() => {
|
|
293
|
+
O = !0, w?.disconnect(), w = null, T?.disconnect(), T = null;
|
|
294
|
+
let e = v.value?.ownerDocument?.defaultView;
|
|
295
|
+
D && e?.cancelAnimationFrame(D), E && e?.cancelAnimationFrame(E);
|
|
296
|
+
for (let [e, t] of M) W(e, t);
|
|
297
|
+
M.clear();
|
|
298
|
+
}), {
|
|
299
|
+
ready: x,
|
|
300
|
+
parts: S,
|
|
301
|
+
measure: Z,
|
|
302
|
+
schedule: Q,
|
|
303
|
+
syncHeight: Y
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
export { y as animateHeight, v as springTiming, b as useMorphLayout };
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { useNativeSlots as e } from "./native-slots.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useModelState as t } from "./model.js";
|
|
3
|
+
import { computed as n, ref as r, useAttrs as i } from "vue";
|
|
3
4
|
// src/utils/navigation.js
|
|
4
|
-
function
|
|
5
|
-
let
|
|
5
|
+
function a() {
|
|
6
|
+
let t = r(null), a = i(), { hasNativeSlot: o, isCustomElement: s } = e(t);
|
|
6
7
|
return {
|
|
7
|
-
root:
|
|
8
|
-
forwardedAttrs:
|
|
9
|
-
...
|
|
8
|
+
root: t,
|
|
9
|
+
forwardedAttrs: n(() => s ? {
|
|
10
|
+
...a,
|
|
10
11
|
id: void 0
|
|
11
|
-
} :
|
|
12
|
+
} : a),
|
|
12
13
|
hasNativeSlot: o,
|
|
13
14
|
isCustomElement: s
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
let a =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
function l(e) {
|
|
22
|
-
Object.is(e, c.value) || (c.value = e, a && (a[t] = e), r(`update:${t}`, e), r("change", e));
|
|
23
|
-
}
|
|
24
|
-
return [c, l];
|
|
17
|
+
function o(e, n, r, i) {
|
|
18
|
+
let [a, o] = t(e, n, r, i);
|
|
19
|
+
return [a, (e) => {
|
|
20
|
+
o(e) && r("change", e);
|
|
21
|
+
}];
|
|
25
22
|
}
|
|
26
|
-
export {
|
|
23
|
+
export { o as useNavigationModel, a as useNavigationRoot };
|