@mintplayer/vue-bootstrap 3.26.0 → 3.28.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.
@@ -0,0 +1,9 @@
1
+ //#region libs/mintplayer-vue-bootstrap/machine/src/vue-props.ts
2
+ function e(e) {
3
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t === !0 ? "" : t]));
4
+ }
5
+ function t(e) {
6
+ return Object.fromEntries(Object.entries(e).filter((e) => e[1] !== null));
7
+ }
8
+ //#endregion
9
+ export { t as n, e as t };
package/machine/index.mjs CHANGED
@@ -1 +1,3 @@
1
- export { t as useMachine, n as useSnapshot } from "../chunks/useMachine-DLZ7g_H3.mjs";
1
+ import { n as e, t } from "../chunks/useMachine-DLZ7g_H3.mjs";
2
+ import { n, t as r } from "../chunks/vue-props-NyhME1Ba.mjs";
3
+ export { t as useMachine, e as useSnapshot, r as vueProps, n as vueStyle };
@@ -1 +1,2 @@
1
1
  export * from './useMachine';
2
+ export * from './vue-props';
@@ -0,0 +1,13 @@
1
+ /** An attribute bag as a `@mintplayer/ui-core` `connect()` returns it. */
2
+ export type AttrBag = Record<string, string | boolean | null>;
3
+ /**
4
+ * Turn a core's attribute bag into `v-bind` input. In a bag `true` means "present and empty",
5
+ * but Vue renders a non-boolean attribute bound to `true` as `"true"`, so it becomes `''`;
6
+ * `null` (absent) Vue already removes. The Vue counterpart of React's `reactProps()`, so every
7
+ * front writes the same DOM.
8
+ */
9
+ export declare function vueProps(bag: AttrBag): Record<string, string | false | null>;
10
+ /** A style bag as a core's `connect()` returns it: CSS property names, `null` for unset. */
11
+ export type StyleBag = Record<string, string | null>;
12
+ /** Turn a core's style bag into a `:style` object: `null` is dropped, names (custom properties too) are kept as they are. */
13
+ export declare function vueStyle(bag: StyleBag): Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/vue-bootstrap",
3
- "version": "3.26.0",
3
+ "version": "3.28.0",
4
4
  "description": "Vue 3.5 SFC adapters around @mintplayer/web-components. Each sub-entry maps one-to-one with a WC sub-entry and exposes typed Vue components with v-model support for input WCs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -188,9 +188,9 @@
188
188
  }
189
189
  },
190
190
  "peerDependencies": {
191
- "@mintplayer/ui-core": "^1.0.0",
191
+ "@mintplayer/ui-core": "^1.1.0",
192
192
  "vue": "^3.5.0",
193
- "@mintplayer/web-components": "^2.21.0"
193
+ "@mintplayer/web-components": "^3.1.0"
194
194
  },
195
195
  "dependencies": {
196
196
  "tslib": "^2.3.0"
@@ -1,20 +1,186 @@
1
- import { createElementBlock as e, defineComponent as t, mergeProps as n, onMounted as r, openBlock as i, ref as a, renderSlot as o, watch as s } from "vue";
2
- import "@mintplayer/web-components/tile-manager";
3
- //#endregion
4
- //#region libs/mintplayer-vue-bootstrap/tile-manager/src/BsTileManager.vue
5
- var c = /* @__PURE__ */ t({
1
+ import { t as e } from "../chunks/useMachine-DLZ7g_H3.mjs";
2
+ import { n as t, t as n } from "../chunks/vue-props-NyhME1Ba.mjs";
3
+ import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, defineComponent as u, mergeModels as d, mergeProps as f, onBeforeUnmount as ee, onMounted as p, openBlock as m, ref as h, renderList as g, renderSlot as _, resolveDynamicComponent as te, toDisplayString as v, unref as y, useAttrs as b, useId as x, useModel as ne, watch as S, withCtx as re } from "vue";
4
+ import { installLightStyles as ie } from "@mintplayer/ui-core/scoped-styles";
5
+ import { DEFAULT_GAP as C, DEFAULT_MIN_COLUMN_WIDTH as w, TILE_MANAGER_SCOPE as T, TileFlip as E, TileManagerMachine as D, breakpointCss as O, connect as k, gridPointer as A, readCellMetrics as j, tileManagerScopedStyles as M, withoutNarrowerLayouts as N } from "@mintplayer/ui-core/tile-manager";
6
+ //#region libs/mintplayer-vue-bootstrap/tile-manager/src/BsTileManager.vue?vue&type=script&setup=true&lang.ts
7
+ var P = [
8
+ "onPointerdown",
9
+ "onKeydown",
10
+ "onFocus",
11
+ "onBlur"
12
+ ], ae = ["onPointerdown"], oe = ["onPointerdown"], F = /* @__PURE__ */ u({
6
13
  inheritAttrs: !1,
7
14
  __name: "BsTileManager",
8
- props: { tiles: {} },
9
- setup(t) {
10
- let c = t, l = a(null), u = () => {
11
- l.value && (l.value.tiles = c.tiles ?? []);
15
+ props: /*@__PURE__*/ d({
16
+ tiles: { default: () => [] },
17
+ breakpoints: { default: null },
18
+ stackBelow: { default: null },
19
+ maxColumns: { default: 6 },
20
+ minColumnWidth: { default: w },
21
+ minRowHeight: { default: "8rem" },
22
+ gap: { default: C },
23
+ dragMode: { default: "header" },
24
+ resizeMode: { default: "hover" },
25
+ animateReflow: {
26
+ type: Boolean,
27
+ default: !0
28
+ },
29
+ label: { default: null },
30
+ messages: { default: () => ({}) }
31
+ }, {
32
+ layouts: { default: () => ({}) },
33
+ layoutsModifiers: {}
34
+ }),
35
+ emits: /*@__PURE__*/ d([
36
+ "layoutPreview",
37
+ "layoutChange",
38
+ "columnCountChange",
39
+ "gestureBlocked"
40
+ ], ["update:layouts"]),
41
+ setup(u, { expose: d, emit: C }) {
42
+ let w = u, N = ne(u, "layouts"), F = C, I = `bs-tile-manager-${x().replace(/[^a-zA-Z0-9_-]/g, "")}`, [L, R] = e(() => {
43
+ let e = new D({ vibrate: (e) => navigator.vibrate?.(e) });
44
+ return e.setInputs({
45
+ tiles: w.tiles,
46
+ layouts: N.value,
47
+ breakpoints: w.breakpoints,
48
+ stackBelow: w.stackBelow,
49
+ maxColumns: w.maxColumns,
50
+ minColumnWidth: w.minColumnWidth,
51
+ minRowHeight: w.minRowHeight,
52
+ gap: w.gap,
53
+ dragMode: w.dragMode,
54
+ resizeMode: w.resizeMode,
55
+ label: w.label,
56
+ messages: w.messages
57
+ }), e;
58
+ });
59
+ ie(T, M), S(() => w.tiles, (e) => L.setInputs({ tiles: e })), S(() => w.breakpoints, (e) => L.setInputs({ breakpoints: e })), S(() => w.stackBelow, (e) => L.setInputs({ stackBelow: e })), S(() => w.maxColumns, (e) => L.setInputs({ maxColumns: e })), S(() => w.minColumnWidth, (e) => L.setInputs({ minColumnWidth: e })), S(() => w.minRowHeight, (e) => L.setInputs({ minRowHeight: e })), S(() => w.gap, (e) => L.setInputs({ gap: e })), S(() => w.dragMode, (e) => L.setInputs({ dragMode: e })), S(() => w.resizeMode, (e) => L.setInputs({ resizeMode: e })), S(() => w.label, (e) => L.setInputs({ label: e })), S(() => w.messages, (e) => L.setInputs({ messages: e })), S(N, (e) => {
60
+ e !== L.snapshot.layouts && L.setInputs({ layouts: e });
61
+ });
62
+ let z = L.onEvent((e) => {
63
+ let { type: t, ...n } = e;
64
+ switch (t) {
65
+ case "layoutchange": {
66
+ let e = n;
67
+ N.value = e.layouts, F("layoutChange", e);
68
+ break;
69
+ }
70
+ case "layoutpreview":
71
+ F("layoutPreview", n);
72
+ break;
73
+ case "columncountchange":
74
+ F("columnCountChange", n);
75
+ break;
76
+ case "gestureblocked": F("gestureBlocked", n);
77
+ }
78
+ }), B = h(null), V = h(null), H = new E(), U = !1, W = 0, G = null, K = L.subscribe(() => {
79
+ let e = L.rendered;
80
+ e !== G && (G = e, V.value && w.animateReflow && L.snapshot.measured && (H.first(V.value), U = !0));
81
+ });
82
+ S(R, (e) => {
83
+ if (U && V.value && (U = !1, H.play(V.value, e.gesture.kind === "drag" ? e.gesture.tileId : null)), e.focusRequest && e.focusRequest.seq !== W) {
84
+ W = e.focusRequest.seq;
85
+ let t = e.focusRequest.tileId;
86
+ Array.from(B.value?.querySelectorAll("[data-tile-id]") ?? []).find((e) => e.dataset.tileId === t)?.focus();
87
+ }
88
+ }, { flush: "post" });
89
+ let q = null, J = 0, Y = () => {
90
+ document.visibilityState === "hidden" && L.cancelGesture();
12
91
  };
13
- return r(u), s(() => c.tiles, u), (t, r) => (i(), e("mp-tile-manager", n({
14
- ref_key: "el",
15
- ref: l
16
- }, t.$attrs), [o(t.$slots, "default")], 16));
92
+ p(() => {
93
+ let e = V.value;
94
+ if (!e || typeof ResizeObserver > "u") return;
95
+ let t = 0;
96
+ q = new ResizeObserver((e) => {
97
+ let n = e[e.length - 1];
98
+ t = n.contentBoxSize?.[0]?.inlineSize ?? n.contentRect.width, !J && (J = requestAnimationFrame(() => {
99
+ J = 0, L.measure(t);
100
+ }));
101
+ }), q.observe(e), document.addEventListener("visibilitychange", Y);
102
+ }), ee(() => {
103
+ z(), K(), q?.disconnect(), cancelAnimationFrame(J), document.removeEventListener("visibilitychange", Y);
104
+ });
105
+ function X(e, t, n) {
106
+ let r = V.value;
107
+ r && L.pointerDown(t, n, A(e, r), j(r, L.snapshot.columnCount)) === "capture" && (e.preventDefault(), e.currentTarget.closest("[data-tile-id]")?.setPointerCapture(e.pointerId));
108
+ }
109
+ function se(e) {
110
+ let t = V.value;
111
+ t && L.pointerMove(A(e, t)) === "capture" && e.currentTarget.setPointerCapture(e.pointerId);
112
+ }
113
+ function ce(e, t) {
114
+ L.keydown(t, e.key, { shift: e.shiftKey }) && e.preventDefault();
115
+ }
116
+ let Z = i(() => (R.value, k(L, I))), Q = i(() => new Map(w.tiles.map((e) => [e.id, e]))), $ = i(() => R.value.measured ? null : O(R.value.layouts, R.value.tiles, R.value, I)), le = b();
117
+ function ue() {
118
+ let { role: e, class: r, style: i, "aria-describedby": a, ...o } = le, { class: s, "aria-describedby": c, ...l } = Z.value.board.attrs;
119
+ return {
120
+ ...n(l),
121
+ ...o,
122
+ class: [
123
+ "mp-tile-manager",
124
+ s,
125
+ r
126
+ ],
127
+ style: [t(Z.value.board.style), i],
128
+ "aria-describedby": [c, a].filter(Boolean).join(" ") || void 0
129
+ };
130
+ }
131
+ return d({
132
+ captureLayout: () => ({
133
+ columnCount: L.snapshot.columnCount,
134
+ layout: L.rendered.map((e) => ({
135
+ id: e.id,
136
+ position: { ...e.position }
137
+ }))
138
+ }),
139
+ resetLayout: (e) => L.resetLayout(e),
140
+ isGestureActive: () => {
141
+ let e = L.snapshot.gesture.kind;
142
+ return e === "drag" || e === "resize";
143
+ }
144
+ }), (e, i) => (m(), s("div", f({
145
+ ref_key: "boardRef",
146
+ ref: B
147
+ }, ue(), { role: "region" }), [
148
+ $.value ? (m(), a(te("style"), { key: 0 }, {
149
+ default: re(() => [l(v($.value), 1)]),
150
+ _: 1
151
+ })) : o("", !0),
152
+ c("div", f({ class: "tile-container" }, y(n)(Z.value.container)), [c("div", f({
153
+ ref_key: "gridRef",
154
+ ref: V,
155
+ class: "tile-grid"
156
+ }, y(n)(Z.value.grid.attrs), { style: y(t)(Z.value.grid.style) }), [(m(!0), s(r, null, g(Z.value.tiles, (a) => (m(), s("div", f({
157
+ key: a.id,
158
+ class: "tile"
159
+ }, { ref_for: !0 }, y(n)(a.attrs), {
160
+ style: y(t)(a.style),
161
+ onPointerdown: (e) => X(e, a.id, "body"),
162
+ onPointermove: se,
163
+ onPointerup: i[0] ||= (e) => y(L).pointerUp(e),
164
+ onPointercancel: i[1] ||= (e) => y(L).pointerCancel(e),
165
+ onLostpointercapture: i[2] ||= (e) => y(L).pointerCancel(e),
166
+ onKeydown: (e) => ce(e, a.id),
167
+ onFocus: (e) => y(L).focus(a.id),
168
+ onBlur: (e) => y(L).blur(a.id)
169
+ }), [
170
+ c("div", f({ class: "tile-header" }, { ref_for: !0 }, y(n)(a.header), { onPointerdown: (e) => X(e, a.id, "header") }), [Q.value.get(a.id) ? _(e.$slots, "header", { tile: Q.value.get(a.id) }, void 0, void 0, 0) : o("", !0)], 16, ae),
171
+ c("div", f({ class: "tile-content" }, { ref_for: !0 }, y(n)(a.content)), [Q.value.get(a.id) ? _(e.$slots, "content", { tile: Q.value.get(a.id) }, void 0, void 0, 0) : o("", !0)], 16),
172
+ (m(!0), s(r, null, g(a.grips, (e) => (m(), s("span", f({
173
+ key: e.handle,
174
+ class: "tile-grip"
175
+ }, { ref_for: !0 }, y(n)(e.attrs), { onPointerdown: (t) => X(t, a.id, e.handle) }), null, 16, oe))), 128))
176
+ ], 16, P))), 128))], 16)], 16),
177
+ (m(!0), s(r, null, g(Z.value.descriptions, (e) => (m(), s("div", f({
178
+ key: e.key,
179
+ class: "tile-sr-only"
180
+ }, { ref_for: !0 }, y(n)(e.attrs)), v(e.text), 17))), 128)),
181
+ c("span", f({ class: "tile-sr-only" }, y(n)(Z.value.live.attrs)), v(Z.value.live.text), 17)
182
+ ], 16));
17
183
  }
18
184
  });
19
185
  //#endregion
20
- export { c as BsTileManager };
186
+ export { F as BsTileManager, N as withoutNarrowerLayouts };
@@ -1,25 +1,70 @@
1
- import { MintTile } from '@mintplayer/web-components/tile-manager';
2
- type __VLS_Props = {
3
- tiles?: MintTile[];
4
- };
5
- declare function __VLS_template(): {
6
- attrs: Partial<{}>;
7
- slots: {
8
- default?(_: {}): any;
9
- };
10
- refs: {
11
- el: unknown;
1
+ import { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TileResizeMode } from '@mintplayer/ui-core/tile-manager';
2
+ import { BsTileColumnCountChange } from './types';
3
+ declare const _default: <T extends MintTile>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
5
+ readonly onGestureBlocked?: ((blocked: TileGestureBlocked) => any) | undefined;
6
+ readonly "onUpdate:layouts"?: ((value: Readonly<Record<number, TileLayoutSnapshot>>) => any) | undefined;
7
+ readonly onLayoutPreview?: ((change: TileLayoutChange) => any) | undefined;
8
+ readonly onLayoutChange?: ((change: TileLayoutChange) => any) | undefined;
9
+ readonly onColumnCountChange?: ((change: BsTileColumnCountChange) => any) | undefined;
10
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onGestureBlocked" | "onUpdate:layouts" | "onLayoutPreview" | "onLayoutChange" | "onColumnCountChange"> & ({
11
+ layouts?: TileLayouts;
12
+ } & {
13
+ /** The visible tiles, in DOM order. */
14
+ tiles?: readonly T[];
15
+ /** Explicit `{ minWidth, columns }` map. Wins over `stackBelow` and the generated map. */
16
+ breakpoints?: readonly TileBreakpoint[] | null;
17
+ /** px. Below this width the tiles stack in one column. */
18
+ stackBelow?: number | null;
19
+ /** Upper bound of the generated map when `layouts` is empty. */
20
+ maxColumns?: number;
21
+ /** px. No column is narrower than this, except at one column. */
22
+ minColumnWidth?: number;
23
+ /** CSS length of one grid row. */
24
+ minRowHeight?: string;
25
+ /** px between tiles. */
26
+ gap?: number;
27
+ dragMode?: TileDragMode;
28
+ resizeMode?: TileResizeMode;
29
+ /** Animate tiles to their new place when the layout reflows. Off under reduced motion. */
30
+ animateReflow?: boolean;
31
+ /** Accessible name of the board. An `aria-label` / `aria-labelledby` attribute wins. */
32
+ label?: string | null;
33
+ /** Localized strings for the board's descriptions and announcements. */
34
+ messages?: Partial<TileManagerMessages>;
35
+ }) & Partial<{}>> & import('vue').PublicProps;
36
+ expose(exposed: import('vue').ShallowUnwrapRef<{
37
+ /** What is rendered: the resolved column count and its layout (the preview while editing). */
38
+ captureLayout: () => {
39
+ columnCount: number;
40
+ layout: TileLayoutSnapshot;
41
+ };
42
+ /** Drops `layouts[count]` and commits, so that count derives again (D15). */
43
+ resetLayout: (count: number) => void;
44
+ /** True while a pointer drag or resize is in flight. */
45
+ isGestureActive: () => boolean;
46
+ }>): void;
47
+ attrs: any;
48
+ slots: Readonly<{
49
+ header?(props: {
50
+ tile: T;
51
+ }): unknown;
52
+ content?(props: {
53
+ tile: T;
54
+ }): unknown;
55
+ }> & {
56
+ header?(props: {
57
+ tile: T;
58
+ }): unknown;
59
+ content?(props: {
60
+ tile: T;
61
+ }): unknown;
12
62
  };
13
- rootEl: any;
63
+ emit: (((evt: "gestureBlocked", blocked: TileGestureBlocked) => void) & ((evt: "layoutPreview", change: TileLayoutChange) => void) & ((evt: "layoutChange", change: TileLayoutChange) => void) & ((evt: "columnCountChange", change: BsTileColumnCountChange) => void)) & ((evt: "update:layouts", value: Readonly<Record<number, TileLayoutSnapshot>>) => void);
64
+ }>) => import('vue').VNode & {
65
+ __ctx?: Awaited<typeof __VLS_setup>;
14
66
  };
15
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
16
- declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
17
- el: unknown;
18
- }, any>;
19
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
20
67
  export default _default;
21
- type __VLS_WithTemplateSlots<T, S> = T & {
22
- new (): {
23
- $slots: S;
24
- };
25
- };
68
+ type __VLS_PrettifyLocal<T> = {
69
+ [K in keyof T]: T[K];
70
+ } & {};
@@ -1 +1,4 @@
1
1
  export { default as BsTileManager } from './BsTileManager.vue';
2
+ export type { BsTileColumnCountChange, BsTileManagerExposed } from './types';
3
+ export type { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TilePosition, TileResizeMode, TileSize, } from '@mintplayer/ui-core/tile-manager';
4
+ export { withoutNarrowerLayouts } from '@mintplayer/ui-core/tile-manager';
@@ -0,0 +1,18 @@
1
+ import { TileLayoutSnapshot } from '@mintplayer/ui-core/tile-manager';
2
+ /** Payload of `columnCountChange`. */
3
+ export interface BsTileColumnCountChange {
4
+ columnCount: number;
5
+ previous: number | null;
6
+ }
7
+ /** What a template ref on `<BsTileManager>` exposes. */
8
+ export interface BsTileManagerExposed {
9
+ /** What is rendered: the resolved column count and its layout (the preview while editing). */
10
+ captureLayout(): {
11
+ columnCount: number;
12
+ layout: TileLayoutSnapshot;
13
+ };
14
+ /** Drops `layouts[count]` and commits, so that count derives again (D15). */
15
+ resetLayout(count: number): void;
16
+ /** True while a pointer drag or resize is in flight. */
17
+ isGestureActive(): boolean;
18
+ }