@kernel4632/kima 0.9.7 → 0.9.8

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.
@@ -1,84 +1,115 @@
1
- import { onBeforeUnmount as e } from "vue";
1
+ import { nextTick as e, onBeforeUnmount as t, watch as n } from "vue";
2
2
  // src/utils/motion.js
3
- var t = /* @__PURE__ */ new WeakMap();
4
- function n(t, n = "[data-kima-flip-key]") {
5
- let r = /* @__PURE__ */ new Map(), a = 0, o = !1;
6
- function s() {
7
- let e = t?.value ?? t;
3
+ var r = /* @__PURE__ */ new WeakMap();
4
+ function i(r, i) {
5
+ let a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = 0;
6
+ function u() {
7
+ let e = r.value;
8
8
  return e?.nodeType === 1 ? e : e?.$el?.nodeType === 1 ? e.$el : null;
9
9
  }
10
- function c(e) {
11
- return e.getAttribute(n.slice(1, -1)) || e.dataset.kimaFlipKey || e;
10
+ function d() {
11
+ for (let e of c.values()) e.cancel();
12
+ c.clear();
12
13
  }
13
- function l() {
14
- let e = s();
15
- e && (r = new Map([...e.children].map((e) => {
16
- let t = e.getBoundingClientRect();
17
- return [c(e), {
18
- node: e,
19
- x: t.x,
20
- y: t.y
14
+ return n(i, () => {
15
+ l++;
16
+ let e = u();
17
+ if (!e) return;
18
+ let t = e.getBoundingClientRect();
19
+ a = new Map([...e.children].filter((e) => !e.inert).map((e) => {
20
+ let n = e.getBoundingClientRect();
21
+ return [e, {
22
+ rect: n,
23
+ x: n.x - t.x,
24
+ y: n.y - t.y
21
25
  }];
22
- })));
23
- }
24
- function u() {
25
- cancelAnimationFrame(a), a = requestAnimationFrame(() => {
26
- if (o) return;
27
- let e = s();
28
- if (!e || i(e) || !e.animate) {
29
- r.clear();
30
- return;
31
- }
32
- let t = getComputedStyle(e), n = t.getPropertyValue("--kima-duration-slow").trim(), a = n ? parseFloat(n) * (n.endsWith("ms") ? 1 : 1e3) : 300;
33
- if (!Number.isFinite(a) || a <= 0) r.clear();
34
- else {
35
- for (let n of e.children) {
36
- let e = r.get(c(n));
37
- if (!e) continue;
38
- let i = n.getBoundingClientRect(), o = e.x - i.x, s = e.y - i.y;
39
- Math.abs(o) < .5 && Math.abs(s) < .5 || n.animate([{ transform: `translate(${o}px, ${s}px)` }, { transform: "translate(0, 0)" }], {
40
- duration: a,
41
- easing: t.getPropertyValue("--kima-curve-emphasized").trim() || "ease-out"
42
- });
26
+ })), d();
27
+ }, {
28
+ flush: "pre",
29
+ deep: !0
30
+ }), n(i, async () => {
31
+ let t = l;
32
+ if (await e(), t !== l) return;
33
+ let n = u();
34
+ if (!n || o(n) || !n.animate) {
35
+ a.clear();
36
+ return;
37
+ }
38
+ let r = getComputedStyle(n), i = s(r.getPropertyValue("--kima-duration-slow")), d = s(r.getPropertyValue("--kima-duration-fast")), f = r.getPropertyValue("--kima-curve-emphasized").trim() || "ease-out", p = n.getBoundingClientRect(), m = [...n.children].filter((e) => !e.inert && a.has(e)).map((e) => {
39
+ let t = e.getBoundingClientRect(), n = a.get(e);
40
+ return {
41
+ node: e,
42
+ dx: n.x - (t.x - p.x),
43
+ dy: n.y - (t.y - p.y)
44
+ };
45
+ }), h = m.some(({ dy: e }) => e < -.5);
46
+ for (let { node: e, dx: t, dy: n } of m) {
47
+ if (!i || Math.abs(t) + Math.abs(n) < .5) continue;
48
+ let r = [
49
+ {
50
+ transform: `translate(${t}px, ${n}px)`,
51
+ offset: 0,
52
+ easing: f
53
+ },
54
+ {
55
+ transform: h ? `translate(${t}px, 0)` : `translate(0, ${n}px)`,
56
+ offset: .5,
57
+ easing: f
58
+ },
59
+ {
60
+ transform: "translate(0, 0)",
61
+ offset: 1
43
62
  }
44
- r.clear();
45
- }
46
- });
47
- }
48
- return e(() => {
49
- o = !0, cancelAnimationFrame(a);
63
+ ], a = e.animate(r, {
64
+ duration: i,
65
+ delay: d,
66
+ fill: "backwards"
67
+ });
68
+ c.set(e, a), a.finished.then(() => {
69
+ c.get(e) === a && c.delete(e);
70
+ }).catch(() => {});
71
+ }
72
+ a.clear();
73
+ }, {
74
+ flush: "post",
75
+ deep: !0
76
+ }), t(() => {
77
+ l++, d();
50
78
  }), {
51
- capture: l,
52
- play: u
79
+ beforeLeave(e) {
80
+ p(e, a.get(e)?.rect);
81
+ },
82
+ beforeEnter: f,
83
+ leaveCancelled: f
53
84
  };
54
85
  }
55
- var r = /* @__PURE__ */ new WeakMap();
56
- function i(e) {
86
+ var a = /* @__PURE__ */ new WeakMap();
87
+ function o(e) {
57
88
  return (e?.closest?.("[data-kima-reduced-motion]"))?.getAttribute("data-kima-reduced-motion") === "reduce" ? !0 : e?.ownerDocument?.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
58
89
  }
59
- function a(e) {
90
+ function s(e) {
60
91
  let t = parseFloat(e) || 0;
61
92
  return e.trim().endsWith("ms") ? t : t * 1e3;
62
93
  }
63
- function o(e) {
94
+ function c(e) {
64
95
  e.inert = !0, e.setAttribute("aria-hidden", "true");
65
96
  }
66
- function s(e) {
97
+ function l(e) {
67
98
  e.inert = !1, e.removeAttribute("aria-hidden");
68
99
  }
69
- var c = {
70
- onBeforeEnter: s,
71
- onBeforeLeave: o
72
- }, l = /* @__PURE__ */ new WeakMap();
73
- function u(e) {
74
- let t = l.get(e);
75
- t && (Object.assign(e.style, t), l.delete(e)), s(e);
100
+ var u = {
101
+ onBeforeEnter: l,
102
+ onBeforeLeave: c
103
+ }, d = /* @__PURE__ */ new WeakMap();
104
+ function f(e) {
105
+ let t = d.get(e);
106
+ t && (Object.assign(e.style, t), d.delete(e)), l(e);
76
107
  }
77
- function d(e) {
78
- let t = e.parentElement;
79
- if (!t) return;
80
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
81
- e.ownerDocument.defaultView.getComputedStyle(t).position === "static" && (t.style.position = "relative"), l.has(e) || l.set(e, Object.fromEntries([
108
+ function p(e, t) {
109
+ let n = e.parentElement;
110
+ if (!n) return;
111
+ let r = t ?? e.getBoundingClientRect(), i = n.getBoundingClientRect();
112
+ e.ownerDocument.defaultView.getComputedStyle(n).position === "static" && (n.style.position = "relative"), d.has(e) || d.set(e, Object.fromEntries([
82
113
  "position",
83
114
  "top",
84
115
  "left",
@@ -90,36 +121,36 @@ function d(e) {
90
121
  "margin"
91
122
  ].map((t) => [t, e.style[t]]))), Object.assign(e.style, {
92
123
  position: "absolute",
93
- top: `${n.top - r.top - t.clientTop + t.scrollTop}px`,
94
- left: `${n.left - r.left - t.clientLeft + t.scrollLeft}px`,
124
+ top: `${r.top - i.top - n.clientTop + n.scrollTop}px`,
125
+ left: `${r.left - i.left - n.clientLeft + n.scrollLeft}px`,
95
126
  right: "auto",
96
127
  bottom: "auto",
97
- width: `${n.width}px`,
98
- height: `${n.height}px`,
128
+ width: `${r.width}px`,
129
+ height: `${r.height}px`,
99
130
  boxSizing: "border-box",
100
131
  margin: "0"
101
- }), o(e);
132
+ }), c(e);
102
133
  }
103
- var f = /* @__PURE__ */ new WeakMap();
104
- function p(e) {
134
+ var m = /* @__PURE__ */ new WeakMap();
135
+ function h(e) {
105
136
  let t = e?.getBoundingClientRect().height || 0;
106
- t > 0 && f.set(e, t);
137
+ t > 0 && m.set(e, t);
107
138
  }
108
- function m(e) {
109
- let n = t.get(e);
110
- n && (r.set(e, {
139
+ function g(e) {
140
+ let t = r.get(e);
141
+ t && (a.set(e, {
111
142
  height: e.getBoundingClientRect().height,
112
143
  opacity: getComputedStyle(e).opacity
113
- }), n.observer?.disconnect(), t.delete(e), n.animation?.cancel(), e.style.overflow = n.overflow);
144
+ }), t.observer?.disconnect(), r.delete(e), t.animation?.cancel(), e.style.overflow = t.overflow);
114
145
  }
115
- function h(e, n, o) {
116
- let s = e.ownerDocument.defaultView, c = e.style.display === "none" || s.getComputedStyle(e).display === "none";
117
- o && c && (e.style.display = "");
118
- let l = s.getComputedStyle(e), u = r.get(e);
119
- r.delete(e);
120
- let d = e.getBoundingClientRect().height || f.get(e) || 0, p = i(e) ? 0 : a(l.getPropertyValue("--kima-duration-slow") || "300ms"), m = l.getPropertyValue("--kima-curve-emphasized").trim() || "ease-out";
121
- if (!p || !e.animate) {
122
- n();
146
+ function _(e, t, n) {
147
+ let i = e.ownerDocument.defaultView, c = e.style.display === "none" || i.getComputedStyle(e).display === "none";
148
+ n && c && (e.style.display = "");
149
+ let l = i.getComputedStyle(e), u = a.get(e);
150
+ a.delete(e);
151
+ let d = e.getBoundingClientRect().height || m.get(e) || 0, f = o(e) ? 0 : s(l.getPropertyValue("--kima-duration-slow") || "300ms"), p = l.getPropertyValue("--kima-curve-emphasized").trim() || "ease-out";
152
+ if (!f || !e.animate) {
153
+ t();
123
154
  return;
124
155
  }
125
156
  let h = {
@@ -127,38 +158,38 @@ function h(e, n, o) {
127
158
  animation: null,
128
159
  observer: null
129
160
  };
130
- t.set(e, h), e.style.overflow = "clip";
131
- let g = o ? d : 0;
132
- function _(r, i) {
133
- let a = e.animate([{
134
- height: `${r}px`,
135
- opacity: i
161
+ r.set(e, h), e.style.overflow = "clip";
162
+ let g = n ? d : 0;
163
+ function _(i, a) {
164
+ let o = e.animate([{
165
+ height: `${i}px`,
166
+ opacity: a
136
167
  }, {
137
168
  height: `${g}px`,
138
- opacity: +!!o
169
+ opacity: +!!n
139
170
  }], {
140
- duration: p,
141
- easing: m,
171
+ duration: f,
172
+ easing: p,
142
173
  fill: "both"
143
174
  });
144
- h.animation = a, a.finished.then(() => {
145
- t.get(e) === h && h.animation === a && (h.observer?.disconnect(), t.delete(e), e.style.overflow = h.overflow, n(), a.cancel());
175
+ h.animation = o, o.finished.then(() => {
176
+ r.get(e) === h && h.animation === o && (h.observer?.disconnect(), r.delete(e), e.style.overflow = h.overflow, t(), o.cancel());
146
177
  }).catch(() => {});
147
178
  }
148
- if (_(u?.height ?? (o ? 0 : d), u?.opacity ?? (o ? 0 : l.opacity)), o && s.ResizeObserver && e.firstElementChild) {
149
- let n = e.firstElementChild.getBoundingClientRect().height;
150
- h.observer = new s.ResizeObserver(() => {
151
- let r = e.firstElementChild?.getBoundingClientRect().height ?? n;
152
- if (Math.abs(r - n) < .5 || t.get(e) !== h) return;
153
- let i = e.getBoundingClientRect().height, a = s.getComputedStyle(e).opacity;
154
- g += r - n, n = r, h.animation.cancel(), _(i, a);
179
+ if (_(u?.height ?? (n ? 0 : d), u?.opacity ?? (n ? 0 : l.opacity)), n && i.ResizeObserver && e.firstElementChild) {
180
+ let t = e.firstElementChild.getBoundingClientRect().height;
181
+ h.observer = new i.ResizeObserver(() => {
182
+ let n = e.firstElementChild?.getBoundingClientRect().height ?? t;
183
+ if (Math.abs(n - t) < .5 || r.get(e) !== h) return;
184
+ let a = e.getBoundingClientRect().height, o = i.getComputedStyle(e).opacity;
185
+ g += n - t, t = n, h.animation.cancel(), _(a, o);
155
186
  }), h.observer.observe(e.firstElementChild);
156
187
  }
157
188
  }
158
- var g = {
159
- onEnter: (e, t) => h(e, t, !0),
160
- onLeave: (e, t) => h(e, t, !1),
161
- onEnterCancelled: m,
162
- onLeaveCancelled: m
189
+ var v = {
190
+ onEnter: (e, t) => _(e, t, !0),
191
+ onLeave: (e, t) => _(e, t, !1),
192
+ onEnterCancelled: g,
193
+ onLeaveCancelled: g
163
194
  };
164
- export { s as activateMotionElement, g as collapseTransition, d as freezeLeaveLayout, i as prefersReducedMotion, c as presenceTransition, p as rememberCollapseHeight, u as restoreLeaveLayout, o as retireMotionElement, n as useLayoutFlip };
195
+ export { l as activateMotionElement, v as collapseTransition, p as freezeLeaveLayout, o as prefersReducedMotion, u as presenceTransition, h as rememberCollapseHeight, f as restoreLeaveLayout, c as retireMotionElement, i as useLayoutFlip };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernel4632/kima",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "KIMA (Kinetic, Interaction, Motion, Alive) - a Material 3 style Web UI design system and component library.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- @keyframes kima-ripple-glow-df3ec98f{0%{opacity:.14}55%{opacity:.1}to{opacity:0}}.kima-list[data-v-df3ec98f]{box-sizing:border-box;min-width:0;font-family:var(--kima-font-family);font-size:var(--kima-font-size-body-medium);font-weight:var(--kima-font-weight-semi-bold);line-height:var(--kima-line-height-normal);color:var(--kima-color-on-surface);overflow-wrap:anywhere;gap:var(--kima-list-gap,var(--kima-space-3));width:100%;min-width:0;margin:0;padding:0;list-style-position:inside;display:grid}.kima-list[data-v-df3ec98f]:is(ul){list-style:none}.kima-list__item[data-v-df3ec98f]{background:var(--kima-color-layer-1);min-height:var(--kima-list-item-height);padding:var(--kima-space-5);border-radius:var(--kima-radius-m);border:0}.kima-list--plain .kima-list__item[data-v-df3ec98f]{background:0 0;border-radius:0;min-height:0;padding:0}.kima-list:is(ul) .kima-list__item[data-v-df3ec98f]{align-items:center;gap:var(--kima-space-4);display:flex}.kima-list__body[data-v-df3ec98f]{flex:1;min-width:0}.kima-list p[data-v-df3ec98f]{margin:var(--kima-space-2) 0 0;color:var(--kima-color-on-surface-variant)}.kima-list__action[data-v-df3ec98f]{gap:var(--kima-space-2);flex-wrap:wrap;display:flex}.kima-list__empty[data-v-df3ec98f]{padding:var(--kima-space-6);color:var(--kima-color-on-surface-variant);list-style:none}
@@ -1 +0,0 @@
1
- @keyframes kima-ripple-glow-cf70a212{0%{opacity:.14}55%{opacity:.1}to{opacity:0}}.kima-multi-select[data-v-cf70a212]{min-width:0;color:var(--kima-color-on-surface);font-family:var(--kima-font-family);font-size:var(--kima-font-size-body-medium);gap:var(--kima-space-3);max-width:100%;line-height:1.5;display:grid;position:relative}.kima-multi-select__control[data-v-cf70a212],.kima-multi-select__chips[data-v-cf70a212]{align-items:center;gap:var(--kima-space-2);flex-wrap:wrap;grid-column:1/-1;display:flex}.kima-multi-select__chip[data-v-cf70a212],.kima-multi-select__clear[data-v-cf70a212]{display:inline-flex}.kima-multi-select__chips[data-v-cf70a212]:empty{display:none}.kima-multi-select__search[data-v-cf70a212]{box-sizing:border-box;width:100%;min-height:48px;margin-bottom:var(--kima-space-2);padding:var(--kima-space-3);border-radius:var(--kima-radius-m);background:var(--kima-color-layer-2);color:var(--kima-color-on-surface);font:inherit;border:0}.kima-multi-select__search[data-v-cf70a212]:focus{outline:var(--kima-focus-ring-width) solid var(--kima-color-primary);outline-offset:-2px}.kima-multi-select__list[data-v-cf70a212]{outline:none}.kima-multi-select__item[data-v-cf70a212]:focus-visible{outline:var(--kima-focus-ring-width) solid var(--kima-color-primary);outline-offset:var(--kima-focus-ring-offset)}.kima-multi-select__item[data-v-cf70a212]:disabled,.kima-multi-select__item[aria-disabled=true][data-v-cf70a212]{cursor:not-allowed;opacity:var(--kima-opacity-disabled)}.kima-multi-select__item[data-v-cf70a212]{box-sizing:border-box;justify-content:space-between;align-items:center;gap:var(--kima-space-3);width:100%;min-height:48px;padding:var(--kima-space-2) var(--kima-space-3);border-radius:var(--kima-radius-s);background:var(--kima-color-transparent);color:var(--kima-color-on-surface);font:inherit;text-align:start;cursor:pointer;transition:background-color var(--kima-duration-effects) var(--kima-curve-standard), color var(--kima-duration-effects) var(--kima-curve-standard);border:0;display:flex}.kima-multi-select__item[data-v-cf70a212]:hover:not([aria-disabled=true]):not([data-disabled]),.kima-multi-select__item[data-highlighted][data-v-cf70a212],.kima-multi-select__item[data-active=true][data-v-cf70a212]{background:var(--kima-color-layer-3)}.kima-multi-select__item[aria-selected=true][data-v-cf70a212]{color:var(--kima-color-on-primary-container);background:var(--kima-color-primary-container)}.kima-multi-select__item[aria-selected=true][data-v-cf70a212]:hover,.kima-multi-select__item[aria-selected=true][data-active=true][data-v-cf70a212]{background:var(--kima-color-primary-container-hover)}.kima-multi-select__item[data-disabled][data-v-cf70a212]{opacity:var(--kima-opacity-disabled);cursor:not-allowed}.kima-multi-select__native[data-v-cf70a212]{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.kima-multi-select small[data-v-cf70a212]{color:var(--kima-color-on-surface-variant);display:block}.kima-multi-select__popup{min-width:0;color:var(--kima-color-on-surface);font-family:var(--kima-font-family);font-size:var(--kima-font-size-body-medium);background:var(--kima-color-popup);box-shadow:var(--kima-elevation-3);box-sizing:border-box;z-index:60;width:min(360px,100vw - 24px);max-height:min(70vh, var(--reka-popper-available-height,70vh));padding:var(--kima-space-4);border-radius:var(--kima-radius-l);padding:var(--kima-space-2);border:0;outline:none;line-height:1.5;overflow:auto}
@@ -1 +0,0 @@
1
- .kima-tag-group[data-v-b575c982]{color:var(--kima-color-on-surface);font-family:var(--kima-font-family)}.kima-tag-group__items[data-v-b575c982]{gap:var(--kima-space-2);flex-wrap:wrap;display:flex;position:relative}