@tradalab/lyra 3.18.0 → 3.19.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 +2 -2
- package/dist/blocks/index.d.ts +236 -2
- package/dist/blocks/index.js +865 -19
- package/dist/blocks/index.js.map +1 -1
- package/dist/chunk-W3J2KTYP.js +82 -0
- package/dist/chunk-W3J2KTYP.js.map +1 -0
- package/dist/hooks/index.d.ts +9 -1
- package/dist/hooks/index.js +1 -1
- package/dist/shell/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-D2O4GTCC.js +0 -30
- package/dist/chunk-D2O4GTCC.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useStoredSetting, PLATE_KEY, isPlate, useRootAttribute, COMPACT_KEY } from './chunk-D7DMRCDY.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useCallback, useRef, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
// src/hooks/use-plate.ts
|
|
6
|
+
function usePlate() {
|
|
7
|
+
const [stored, store] = useStoredSetting(PLATE_KEY);
|
|
8
|
+
const plate = stored !== null && isPlate(stored) ? stored : null;
|
|
9
|
+
useRootAttribute("data-plate", plate);
|
|
10
|
+
return [plate, store];
|
|
11
|
+
}
|
|
12
|
+
function useCompact() {
|
|
13
|
+
const [stored, store] = useStoredSetting(COMPACT_KEY);
|
|
14
|
+
const compact = stored === "true";
|
|
15
|
+
const setCompact = useCallback((next) => store(next ? "true" : null), [store]);
|
|
16
|
+
useRootAttribute("data-compact", compact ? "true" : null);
|
|
17
|
+
return [compact, setCompact];
|
|
18
|
+
}
|
|
19
|
+
var same = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
20
|
+
function useDirtyFields(initial, current) {
|
|
21
|
+
return React.useMemo(() => {
|
|
22
|
+
const dirty = Object.keys(current).filter((k) => !same(initial[k], current[k]));
|
|
23
|
+
const set = new Set(dirty);
|
|
24
|
+
return { dirty, isDirty: dirty.length > 0, is: (key) => set.has(key) };
|
|
25
|
+
}, [initial, current]);
|
|
26
|
+
}
|
|
27
|
+
var KEY = /* @__PURE__ */ Symbol.for("@tradalab/lyra/back-layers");
|
|
28
|
+
function state() {
|
|
29
|
+
const g = globalThis;
|
|
30
|
+
return g[KEY] ??= { stack: [], ours: 0, waiting: 0, listening: false, next: 0 };
|
|
31
|
+
}
|
|
32
|
+
function entry(id) {
|
|
33
|
+
window.history.pushState({ ...window.history.state, lyraLayer: id }, "");
|
|
34
|
+
}
|
|
35
|
+
function onPop() {
|
|
36
|
+
const s = state();
|
|
37
|
+
if (s.ours > 0) {
|
|
38
|
+
s.ours--;
|
|
39
|
+
for (; s.ours === 0 && s.waiting > 0; s.waiting--) {
|
|
40
|
+
const layer = s.stack[s.stack.length - s.waiting];
|
|
41
|
+
if (layer) entry(layer.id);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
s.stack.pop()?.close();
|
|
46
|
+
}
|
|
47
|
+
function pushBackLayer(close) {
|
|
48
|
+
const s = state();
|
|
49
|
+
if (!s.listening) {
|
|
50
|
+
s.listening = true;
|
|
51
|
+
window.addEventListener("popstate", onPop);
|
|
52
|
+
}
|
|
53
|
+
const layer = { close, id: `l${s.next++}` };
|
|
54
|
+
s.stack.push(layer);
|
|
55
|
+
if (s.ours > 0) s.waiting++;
|
|
56
|
+
else entry(layer.id);
|
|
57
|
+
return () => {
|
|
58
|
+
const i = s.stack.indexOf(layer);
|
|
59
|
+
if (i < 0) return;
|
|
60
|
+
s.stack.splice(i, 1);
|
|
61
|
+
if (i !== s.stack.length) return;
|
|
62
|
+
if (s.waiting > 0) {
|
|
63
|
+
s.waiting--;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (window.history.state?.lyraLayer !== layer.id) return;
|
|
67
|
+
s.ours++;
|
|
68
|
+
window.history.back();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function useBackClose(open, onClose) {
|
|
72
|
+
const latest = useRef(onClose);
|
|
73
|
+
latest.current = onClose;
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!open) return;
|
|
76
|
+
return pushBackLayer(() => latest.current());
|
|
77
|
+
}, [open]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { pushBackLayer, useBackClose, useCompact, useDirtyFields, usePlate };
|
|
81
|
+
//# sourceMappingURL=chunk-W3J2KTYP.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-W3J2KTYP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-plate.ts","../src/hooks/use-compact.ts","../src/hooks/use-dirty-fields.ts","../src/hooks/use-back-close.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAA,GAA0D;AACxE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,SAAS,CAAA;AAClD,EAAA,MAAM,QAAQ,MAAA,KAAW,IAAA,IAAQ,OAAA,CAAQ,MAAM,IAAI,MAAA,GAAS,IAAA;AAC5D,EAAA,gBAAA,CAAiB,cAAc,KAAK,CAAA;AACpC,EAAA,OAAO,CAAC,OAAO,KAAK,CAAA;AACtB;ACbO,SAAS,UAAA,GAAoD;AAClE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,WAAW,CAAA;AACpD,EAAA,MAAM,UAAU,MAAA,KAAW,MAAA;AAC3B,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,CAAC,IAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,MAAA,GAAS,IAAI,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACtF,EAAA,gBAAA,CAAiB,cAAA,EAAgB,OAAA,GAAU,MAAA,GAAS,IAAI,CAAA;AACxD,EAAA,OAAO,CAAC,SAAS,UAAU,CAAA;AAC7B;ACTA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAY,CAAA,KAAe,CAAA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EAAA;AACF,MAAA;AAAA,IACF;AACA,IAAA,IAAK,MAAA,CAAO,OAAA,CAAQ,KAAA,EAAyC,SAAA,KAAc,MAAM,EAAA,EAAI;AACrF,IAAA,CAAA,CAAE,IAAA,EAAA;AACF,IAAA,MAAA,CAAO,QAAQ,IAAA,EAAK;AAAA,EACtB,CAAA;AACF;AAGO,SAAS,YAAA,CAAa,MAAe,OAAA,EAAqB;AAC/D,EAAA,MAAM,MAAA,GAAS,OAAO,OAAO,CAAA;AAC7B,EAAA,MAAA,CAAO,OAAA,GAAU,OAAA;AACjB,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,IAAA,EAAM;AACX,IAAA,OAAO,aAAA,CAAc,MAAM,MAAA,CAAO,OAAA,EAAS,CAAA;AAAA,EAC7C,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AACX","file":"chunk-W3J2KTYP.js","sourcesContent":["\"use client\"\n\nimport { PLATE_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\nimport { isPlate, type Plate } from \"./plate.js\"\n\n/**\n * The plate this device is set to, and a way to change it.\n *\n * A stored name that is no longer a plate - a rename, a downgrade to an older lyra - reads as no\n * plate. The alternative is an attribute no rule matches, which looks identical to the neutral\n * default on screen while the picker shows nothing selected at all, so the reader cannot tell that\n * their choice was dropped or get back to a known state.\n */\nexport function usePlate(): [Plate | null, (plate: Plate | null) => void] {\n const [stored, store] = useStoredSetting(PLATE_KEY)\n const plate = stored !== null && isPlate(stored) ? stored : null\n useRootAttribute(\"data-plate\", plate)\n return [plate, store]\n}\n","\"use client\"\n\nimport { useCallback } from \"react\"\nimport { COMPACT_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\n\nexport function useCompact(): [boolean, (compact: boolean) => void] {\n const [stored, store] = useStoredSetting(COMPACT_KEY)\n const compact = stored === \"true\"\n const setCompact = useCallback((next: boolean) => store(next ? \"true\" : null), [store])\n useRootAttribute(\"data-compact\", compact ? \"true\" : null)\n return [compact, setCompact]\n}\n","import * as React from \"react\"\n\nconst same = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b)\n\n/** Keys of `current` that differ from `initial`, compared by value; `isDirty` when any does. */\nexport function useDirtyFields<T extends Record<string, unknown>>(initial: T, current: T) {\n return React.useMemo(() => {\n const dirty = (Object.keys(current) as (keyof T)[]).filter((k) => !same(initial[k], current[k]))\n const set = new Set<keyof T>(dirty)\n return { dirty, isDirty: dirty.length > 0, is: (key: keyof T) => set.has(key) }\n }, [initial, current])\n}\n","\"use client\"\n\nimport { useEffect, useRef } from \"react\"\n\ntype Layer = { close: () => void; id: string }\n\ntype BackState = {\n stack: Layer[]\n ours: number\n waiting: number\n listening: boolean\n next: number\n}\n\nconst KEY = Symbol.for(\"@tradalab/lyra/back-layers\")\n\nfunction state(): BackState {\n const g = globalThis as { [KEY]?: BackState }\n return (g[KEY] ??= { stack: [], ours: 0, waiting: 0, listening: false, next: 0 })\n}\n\nfunction entry(id: string) {\n window.history.pushState({ ...window.history.state, lyraLayer: id }, \"\")\n}\n\nfunction onPop() {\n const s = state()\n if (s.ours > 0) {\n s.ours--\n for (; s.ours === 0 && s.waiting > 0; s.waiting--) {\n const layer = s.stack[s.stack.length - s.waiting]\n if (layer) entry(layer.id)\n }\n return\n }\n s.stack.pop()?.close()\n}\n\n/**\n * Holds one history entry while a layer is open, so Back (on Android, a WebView history step) calls `close`.\n * Returns a release for a layer that closed some other way; it drops the entry unless a navigation sits on top.\n */\nexport function pushBackLayer(close: () => void): () => void {\n const s = state()\n if (!s.listening) {\n s.listening = true\n window.addEventListener(\"popstate\", onPop)\n }\n const layer: Layer = { close, id: `l${s.next++}` }\n s.stack.push(layer)\n if (s.ours > 0) s.waiting++\n else entry(layer.id)\n return () => {\n const i = s.stack.indexOf(layer)\n if (i < 0) return\n s.stack.splice(i, 1)\n if (i !== s.stack.length) return\n if (s.waiting > 0) {\n s.waiting--\n return\n }\n if ((window.history.state as { lyraLayer?: string } | null)?.lyraLayer !== layer.id) return\n s.ours++\n window.history.back()\n }\n}\n\n/** Back calls `onClose` while `open` is true; the newest open layer closes first. */\nexport function useBackClose(open: boolean, onClose: () => void) {\n const latest = useRef(onClose)\n latest.current = onClose\n useEffect(() => {\n if (!open) return\n return pushBackLayer(() => latest.current())\n }, [open])\n}\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -16,4 +16,12 @@ declare function useDirtyFields<T extends Record<string, unknown>>(initial: T, c
|
|
|
16
16
|
is: (key: keyof T) => boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Holds one history entry while a layer is open, so Back (on Android, a WebView history step) calls `close`.
|
|
21
|
+
* Returns a release for a layer that closed some other way; it drops the entry unless a navigation sits on top.
|
|
22
|
+
*/
|
|
23
|
+
declare function pushBackLayer(close: () => void): () => void;
|
|
24
|
+
/** Back calls `onClose` while `open` is true; the newest open layer closes first. */
|
|
25
|
+
declare function useBackClose(open: boolean, onClose: () => void): void;
|
|
26
|
+
|
|
27
|
+
export { pushBackLayer, useBackClose, useDirtyFields, useMobile };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { useCompact, useDirtyFields, usePlate } from '../chunk-
|
|
2
|
+
export { pushBackLayer, useBackClose, useCompact, useDirtyFields, usePlate } from '../chunk-W3J2KTYP.js';
|
|
3
3
|
export { BEARING_PLATES, PLATES, derivePlate, isPlate, useMobile } from '../chunk-D7DMRCDY.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/shell/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { usePlate, useCompact } from '../chunk-
|
|
2
|
+
import { usePlate, useCompact } from '../chunk-W3J2KTYP.js';
|
|
3
3
|
import { SidebarInset, SidebarProvider, useSidebar, Sidebar, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, defaultAccountMenuLabels, initialsOf, PlatePicker, Switch, ScrollArea, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ScrollBar, Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbPage, BreadcrumbLink, BreadcrumbSeparator, Card, CardTitle, CardDescription, Tabs } from '../chunk-UNRT3B6P.js';
|
|
4
4
|
import '../chunk-D7DMRCDY.js';
|
|
5
5
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuLabel, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuItem } from '../chunk-OH3OMK7A.js';
|
package/package.json
CHANGED
package/dist/chunk-D2O4GTCC.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useStoredSetting, PLATE_KEY, isPlate, useRootAttribute, COMPACT_KEY } from './chunk-D7DMRCDY.js';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useCallback } from 'react';
|
|
4
|
-
|
|
5
|
-
// src/hooks/use-plate.ts
|
|
6
|
-
function usePlate() {
|
|
7
|
-
const [stored, store] = useStoredSetting(PLATE_KEY);
|
|
8
|
-
const plate = stored !== null && isPlate(stored) ? stored : null;
|
|
9
|
-
useRootAttribute("data-plate", plate);
|
|
10
|
-
return [plate, store];
|
|
11
|
-
}
|
|
12
|
-
function useCompact() {
|
|
13
|
-
const [stored, store] = useStoredSetting(COMPACT_KEY);
|
|
14
|
-
const compact = stored === "true";
|
|
15
|
-
const setCompact = useCallback((next) => store(next ? "true" : null), [store]);
|
|
16
|
-
useRootAttribute("data-compact", compact ? "true" : null);
|
|
17
|
-
return [compact, setCompact];
|
|
18
|
-
}
|
|
19
|
-
var same = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
20
|
-
function useDirtyFields(initial, current) {
|
|
21
|
-
return React.useMemo(() => {
|
|
22
|
-
const dirty = Object.keys(current).filter((k) => !same(initial[k], current[k]));
|
|
23
|
-
const set = new Set(dirty);
|
|
24
|
-
return { dirty, isDirty: dirty.length > 0, is: (key) => set.has(key) };
|
|
25
|
-
}, [initial, current]);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { useCompact, useDirtyFields, usePlate };
|
|
29
|
-
//# sourceMappingURL=chunk-D2O4GTCC.js.map
|
|
30
|
-
//# sourceMappingURL=chunk-D2O4GTCC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-plate.ts","../src/hooks/use-compact.ts","../src/hooks/use-dirty-fields.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAA,GAA0D;AACxE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,SAAS,CAAA;AAClD,EAAA,MAAM,QAAQ,MAAA,KAAW,IAAA,IAAQ,OAAA,CAAQ,MAAM,IAAI,MAAA,GAAS,IAAA;AAC5D,EAAA,gBAAA,CAAiB,cAAc,KAAK,CAAA;AACpC,EAAA,OAAO,CAAC,OAAO,KAAK,CAAA;AACtB;ACbO,SAAS,UAAA,GAAoD;AAClE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,WAAW,CAAA;AACpD,EAAA,MAAM,UAAU,MAAA,KAAW,MAAA;AAC3B,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,CAAC,IAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,MAAA,GAAS,IAAI,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACtF,EAAA,gBAAA,CAAiB,cAAA,EAAgB,OAAA,GAAU,MAAA,GAAS,IAAI,CAAA;AACxD,EAAA,OAAO,CAAC,SAAS,UAAU,CAAA;AAC7B;ACTA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAY,CAAA,KAAe,CAAA,KAAM,CAAA,IAAK,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA,KAAM,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA;AAGnF,SAAS,cAAA,CAAkD,SAAY,OAAA,EAAY;AACxF,EAAA,OAAa,cAAQ,MAAM;AACzB,IAAA,MAAM,QAAS,MAAA,CAAO,IAAA,CAAK,OAAO,CAAA,CAAkB,OAAO,CAAC,CAAA,KAAM,CAAC,IAAA,CAAK,QAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA;AAC/F,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAa,KAAK,CAAA;AAClC,IAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG,EAAA,EAAI,CAAC,GAAA,KAAiB,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA,EAAE;AAAA,EAChF,CAAA,EAAG,CAAC,OAAA,EAAS,OAAO,CAAC,CAAA;AACvB","file":"chunk-D2O4GTCC.js","sourcesContent":["\"use client\"\n\nimport { PLATE_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\nimport { isPlate, type Plate } from \"./plate.js\"\n\n/**\n * The plate this device is set to, and a way to change it.\n *\n * A stored name that is no longer a plate - a rename, a downgrade to an older lyra - reads as no\n * plate. The alternative is an attribute no rule matches, which looks identical to the neutral\n * default on screen while the picker shows nothing selected at all, so the reader cannot tell that\n * their choice was dropped or get back to a known state.\n */\nexport function usePlate(): [Plate | null, (plate: Plate | null) => void] {\n const [stored, store] = useStoredSetting(PLATE_KEY)\n const plate = stored !== null && isPlate(stored) ? stored : null\n useRootAttribute(\"data-plate\", plate)\n return [plate, store]\n}\n","\"use client\"\n\nimport { useCallback } from \"react\"\nimport { COMPACT_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\n\nexport function useCompact(): [boolean, (compact: boolean) => void] {\n const [stored, store] = useStoredSetting(COMPACT_KEY)\n const compact = stored === \"true\"\n const setCompact = useCallback((next: boolean) => store(next ? \"true\" : null), [store])\n useRootAttribute(\"data-compact\", compact ? \"true\" : null)\n return [compact, setCompact]\n}\n","import * as React from \"react\"\n\nconst same = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b)\n\n/** Keys of `current` that differ from `initial`, compared by value; `isDirty` when any does. */\nexport function useDirtyFields<T extends Record<string, unknown>>(initial: T, current: T) {\n return React.useMemo(() => {\n const dirty = (Object.keys(current) as (keyof T)[]).filter((k) => !same(initial[k], current[k]))\n const set = new Set<keyof T>(dirty)\n return { dirty, isDirty: dirty.length > 0, is: (key: keyof T) => set.has(key) }\n }, [initial, current])\n}\n"]}
|