@unisim/sdk 0.202.0 → 0.203.1
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 +88 -0
- package/dist/boxStyles.d.ts.map +1 -1
- package/dist/boxStyles.js +28 -7
- package/dist/boxStyles.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +32 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/phone/BottomSheet.d.ts +40 -0
- package/dist/phone/BottomSheet.d.ts.map +1 -0
- package/dist/phone/BottomSheet.js +51 -0
- package/dist/phone/BottomSheet.js.map +1 -0
- package/dist/phone/PhonePage.d.ts +46 -0
- package/dist/phone/PhonePage.d.ts.map +1 -0
- package/dist/phone/PhonePage.js +52 -0
- package/dist/phone/PhonePage.js.map +1 -0
- package/dist/phone/dialogs.d.ts +43 -0
- package/dist/phone/dialogs.d.ts.map +1 -0
- package/dist/phone/dialogs.js +128 -0
- package/dist/phone/dialogs.js.map +1 -0
- package/dist/phone/edgeSwipe.d.ts +18 -0
- package/dist/phone/edgeSwipe.d.ts.map +1 -0
- package/dist/phone/edgeSwipe.js +190 -0
- package/dist/phone/edgeSwipe.js.map +1 -0
- package/dist/phone/gestures.d.ts +60 -0
- package/dist/phone/gestures.d.ts.map +1 -0
- package/dist/phone/gestures.js +329 -0
- package/dist/phone/gestures.js.map +1 -0
- package/dist/phone/index.d.ts +16 -0
- package/dist/phone/index.d.ts.map +1 -0
- package/dist/phone/index.js +15 -0
- package/dist/phone/index.js.map +1 -0
- package/dist/phone/layers.d.ts +44 -0
- package/dist/phone/layers.d.ts.map +1 -0
- package/dist/phone/layers.js +225 -0
- package/dist/phone/layers.js.map +1 -0
- package/dist/phone/scrollHint.d.ts +22 -0
- package/dist/phone/scrollHint.d.ts.map +1 -0
- package/dist/phone/scrollHint.js +81 -0
- package/dist/phone/scrollHint.js.map +1 -0
- package/dist/phone/shared.d.ts +24 -0
- package/dist/phone/shared.d.ts.map +1 -0
- package/dist/phone/shared.js +59 -0
- package/dist/phone/shared.js.map +1 -0
- package/dist/phone/styles.d.ts +11 -0
- package/dist/phone/styles.d.ts.map +1 -0
- package/dist/phone/styles.js +163 -0
- package/dist/phone/styles.js.map +1 -0
- package/dist/phone/text.d.ts +6 -0
- package/dist/phone/text.d.ts.map +1 -0
- package/dist/phone/text.js +15 -0
- package/dist/phone/text.js.map +1 -0
- package/dist/revealOnExpand.d.ts.map +1 -1
- package/dist/revealOnExpand.js +28 -1
- package/dist/revealOnExpand.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/phone/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,aAAa;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEzG,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAEpE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type PhoneLayerKind = 'page' | 'sheet';
|
|
2
|
+
export interface PhoneLayerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Keep a history entry per open layer, so Android's back gesture (and the
|
|
5
|
+
* browser's Back) closes the top one. Default true. Turn it off only in an
|
|
6
|
+
* app that keeps its own history for its layers.
|
|
7
|
+
*/
|
|
8
|
+
history?: boolean;
|
|
9
|
+
/** The z-index of the first layer; each one above it is 2 higher. Default 1200 (over the SDK navbar and the website's dialogs). */
|
|
10
|
+
baseZ?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Set the stack's options. Call once, before the first layer opens. */
|
|
13
|
+
export declare function configurePhoneLayers(options: PhoneLayerOptions): void;
|
|
14
|
+
export interface PhoneLayerState {
|
|
15
|
+
/** Its place in the stack, 0 for the first one open. */
|
|
16
|
+
index: number;
|
|
17
|
+
/** Nothing is open over it. */
|
|
18
|
+
isTop: boolean;
|
|
19
|
+
/** Its z-index. */
|
|
20
|
+
zIndex: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Put a page or sheet on the stack for as long as `open` (default true) and
|
|
24
|
+
* it is mounted. Back (Android's gesture, the browser's) calls `close` on the
|
|
25
|
+
* top layer; answer `false` to stay. Pages and sheets from this kit call it
|
|
26
|
+
* themselves — use it for a layer of your own (a non-modal tool sheet, a page
|
|
27
|
+
* whose chrome is the app's).
|
|
28
|
+
*/
|
|
29
|
+
export declare function usePhoneLayer(kind: PhoneLayerKind, close: () => boolean | void, options?: {
|
|
30
|
+
open?: boolean;
|
|
31
|
+
lockScroll?: boolean;
|
|
32
|
+
}): PhoneLayerState;
|
|
33
|
+
/** How many pages and sheets are open (re-renders when it changes). */
|
|
34
|
+
export declare function usePhoneLayerCount(): number;
|
|
35
|
+
/** Is any page or sheet open? For an app that must stand still under one (a tab bar's search request). */
|
|
36
|
+
export declare function useAnyPhoneLayerOpen(): boolean;
|
|
37
|
+
/** Close the top layer, as Back would. Answers false when nothing is open or it refused. */
|
|
38
|
+
export declare function closeTopPhoneLayer(): boolean;
|
|
39
|
+
/** For tests and diagnostics: the open layers' kinds, bottom first, and our history entries. */
|
|
40
|
+
export declare function phoneLayerDebug(): {
|
|
41
|
+
kinds: PhoneLayerKind[];
|
|
42
|
+
pushed: number;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=layers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../src/phone/layers.ts"],"names":[],"mappings":"AAoCA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mIAAmI;IACnI,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAoCD,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAGrE;AAoGD,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,MAAM,OAAO,GAAG,IAAI,EAC3B,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACrD,eAAe,CA2BjB;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,0GAA0G;AAC1G,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,gGAAgG;AAChG,wBAAgB,eAAe,IAAI;IAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAE7E"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// The layer stack: every page and sheet the phone chrome has open, newest on
|
|
3
|
+
// top, and the browser history entries that make Android's back gesture close
|
|
4
|
+
// them one at a time.
|
|
5
|
+
//
|
|
6
|
+
// ⚠️ EVERY OPEN LAYER IS ONE HISTORY ENTRY. Capacitor's Android back goes
|
|
7
|
+
// `history.back()` while there is history and leaves the app when there is
|
|
8
|
+
// none, so without these the back gesture quits the app from inside a sheet.
|
|
9
|
+
// The browser's Back does the same in development.
|
|
10
|
+
//
|
|
11
|
+
// Reconciled from four copies (2026-10-22):
|
|
12
|
+
// - Universal PDF (`useHistoryLayers`, NativeApp.tsx) KEPT BY COUNTING, not
|
|
13
|
+
// by state objects: something else may `replaceState(null)` the current
|
|
14
|
+
// entry (PDF's own store does whenever the document's slug changes), which
|
|
15
|
+
// would wipe anything stored on it. Kept here.
|
|
16
|
+
// - Universal BlackBook (`layers.tsx`) — one entry PER LAYER, layers ordered
|
|
17
|
+
// by when they opened, z-index from that order, and only the top layer
|
|
18
|
+
// answering Escape and the edge swipe. Kept here.
|
|
19
|
+
// - Universal Images / Converter / Compress (`layers.ts`) — ONE entry for
|
|
20
|
+
// "something is open", re-armed after each Back. Replaced by the per-layer
|
|
21
|
+
// count, which needs no re-arming. Their good idea is kept: the history
|
|
22
|
+
// is put right a tick LATER, so a sheet that closes as the page it opened
|
|
23
|
+
// arrives (More ▸ Tune this app) nets out to nothing instead of racing a
|
|
24
|
+
// `history.go(-1)` against a `pushState()` (BlackBook pushed at once and
|
|
25
|
+
// went back in a microtask, which is exactly that race).
|
|
26
|
+
// - A layer may refuse to close: its `close` answers `false` (Images'
|
|
27
|
+
// `canGoBack`, PDF's `backGuard`), or it simply stays mounted (it asked
|
|
28
|
+
// first). Either way, a tick after the Back its entry is pushed again, so
|
|
29
|
+
// the next Back still has something to take (BlackBook).
|
|
30
|
+
//
|
|
31
|
+
// Our own `history.go(-n)` is told apart from a real Back by a counter, and a
|
|
32
|
+
// popstate while we own no entries is left alone (it is the app's own).
|
|
33
|
+
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
34
|
+
const config = { history: true, baseZ: 1200 };
|
|
35
|
+
let layers = [];
|
|
36
|
+
let nextId = 1;
|
|
37
|
+
/** History entries we have pushed and not taken back. */
|
|
38
|
+
let pushed = 0;
|
|
39
|
+
/** Our own `history.go(-n)`s still to arrive as popstate. */
|
|
40
|
+
let ownPops = 0;
|
|
41
|
+
let syncQueued = false;
|
|
42
|
+
let ownPopScroll = null;
|
|
43
|
+
let syncAfterPop = false;
|
|
44
|
+
let listening = false;
|
|
45
|
+
const subscribers = new Set();
|
|
46
|
+
function emit() {
|
|
47
|
+
for (const fn of subscribers)
|
|
48
|
+
fn();
|
|
49
|
+
}
|
|
50
|
+
function subscribe(fn) {
|
|
51
|
+
subscribers.add(fn);
|
|
52
|
+
return () => {
|
|
53
|
+
subscribers.delete(fn);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const snapshot = () => layers;
|
|
57
|
+
const serverSnapshot = () => [];
|
|
58
|
+
/** Set the stack's options. Call once, before the first layer opens. */
|
|
59
|
+
export function configurePhoneLayers(options) {
|
|
60
|
+
if (options.history !== undefined)
|
|
61
|
+
config.history = options.history;
|
|
62
|
+
if (options.baseZ !== undefined)
|
|
63
|
+
config.baseZ = options.baseZ;
|
|
64
|
+
}
|
|
65
|
+
/** Make the number of our history entries match the number of open layers, a tick from now. */
|
|
66
|
+
function scheduleSync() {
|
|
67
|
+
if (!config.history || syncQueued || typeof window === 'undefined')
|
|
68
|
+
return;
|
|
69
|
+
syncQueued = true;
|
|
70
|
+
window.setTimeout(() => {
|
|
71
|
+
syncQueued = false;
|
|
72
|
+
// Our own traversal is still on its way: history is not where `pushed`
|
|
73
|
+
// says until it lands, so wait for it (a pushState now could be undone by it).
|
|
74
|
+
if (ownPops > 0) {
|
|
75
|
+
syncAfterPop = true;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const want = layers.filter((l) => !l.closing).length;
|
|
79
|
+
if (want > pushed) {
|
|
80
|
+
for (let i = pushed; i < want; i++)
|
|
81
|
+
window.history.pushState({ unisimPhoneLayer: i + 1 }, '');
|
|
82
|
+
pushed = want;
|
|
83
|
+
}
|
|
84
|
+
else if (want < pushed) {
|
|
85
|
+
const n = pushed - want;
|
|
86
|
+
pushed = want;
|
|
87
|
+
ownPops++;
|
|
88
|
+
// The traversal restores the scroll position the entry was left at;
|
|
89
|
+
// the app underneath stays exactly where it is now instead.
|
|
90
|
+
ownPopScroll = { x: window.scrollX, y: window.scrollY };
|
|
91
|
+
window.history.go(-n);
|
|
92
|
+
}
|
|
93
|
+
}, 0);
|
|
94
|
+
}
|
|
95
|
+
function onPopState() {
|
|
96
|
+
if (ownPops > 0) {
|
|
97
|
+
ownPops--;
|
|
98
|
+
const at = ownPopScroll;
|
|
99
|
+
ownPopScroll = null;
|
|
100
|
+
if (at && (window.scrollX !== at.x || window.scrollY !== at.y))
|
|
101
|
+
window.scrollTo(at.x, at.y);
|
|
102
|
+
if (ownPops === 0 && syncAfterPop) {
|
|
103
|
+
syncAfterPop = false;
|
|
104
|
+
scheduleSync();
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (pushed === 0)
|
|
109
|
+
return;
|
|
110
|
+
pushed--;
|
|
111
|
+
const top = [...layers].reverse().find((l) => !l.closing);
|
|
112
|
+
if (!top)
|
|
113
|
+
return;
|
|
114
|
+
top.closing = true;
|
|
115
|
+
top.close();
|
|
116
|
+
// Refused (it answered false, or it is simply still here a tick later — it
|
|
117
|
+
// asked first): it keeps its place, and its entry is pushed again.
|
|
118
|
+
window.setTimeout(() => {
|
|
119
|
+
if (!layers.includes(top))
|
|
120
|
+
return;
|
|
121
|
+
top.closing = false;
|
|
122
|
+
emit();
|
|
123
|
+
scheduleSync();
|
|
124
|
+
}, 0);
|
|
125
|
+
}
|
|
126
|
+
function listen() {
|
|
127
|
+
if (listening || typeof window === 'undefined')
|
|
128
|
+
return;
|
|
129
|
+
listening = true;
|
|
130
|
+
window.addEventListener('popstate', onPopState);
|
|
131
|
+
}
|
|
132
|
+
function register(kind, close) {
|
|
133
|
+
listen();
|
|
134
|
+
const layer = { id: nextId++, kind, close, closing: false };
|
|
135
|
+
layers = [...layers, layer];
|
|
136
|
+
emit();
|
|
137
|
+
scheduleSync();
|
|
138
|
+
return layer;
|
|
139
|
+
}
|
|
140
|
+
function unregister(layer) {
|
|
141
|
+
if (!layers.includes(layer))
|
|
142
|
+
return;
|
|
143
|
+
layers = layers.filter((l) => l !== layer);
|
|
144
|
+
emit();
|
|
145
|
+
scheduleSync();
|
|
146
|
+
}
|
|
147
|
+
// ── Scroll lock ───────────────────────────────────────────────────────────────
|
|
148
|
+
// Counted, so layers closing out of order put the page's own overflow back
|
|
149
|
+
// only when the last one goes (Family and BlackBook each saved and restored
|
|
150
|
+
// per layer, which restores the wrong value when two overlap).
|
|
151
|
+
let locks = 0;
|
|
152
|
+
let savedOverflow = '';
|
|
153
|
+
function lockScroll() {
|
|
154
|
+
if (typeof document === 'undefined')
|
|
155
|
+
return () => { };
|
|
156
|
+
if (locks++ === 0) {
|
|
157
|
+
savedOverflow = document.body.style.overflow;
|
|
158
|
+
document.body.style.overflow = 'hidden';
|
|
159
|
+
}
|
|
160
|
+
let done = false;
|
|
161
|
+
return () => {
|
|
162
|
+
if (done)
|
|
163
|
+
return;
|
|
164
|
+
done = true;
|
|
165
|
+
if (--locks === 0)
|
|
166
|
+
document.body.style.overflow = savedOverflow;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Put a page or sheet on the stack for as long as `open` (default true) and
|
|
171
|
+
* it is mounted. Back (Android's gesture, the browser's) calls `close` on the
|
|
172
|
+
* top layer; answer `false` to stay. Pages and sheets from this kit call it
|
|
173
|
+
* themselves — use it for a layer of your own (a non-modal tool sheet, a page
|
|
174
|
+
* whose chrome is the app's).
|
|
175
|
+
*/
|
|
176
|
+
export function usePhoneLayer(kind, close, options = {}) {
|
|
177
|
+
const open = options.open ?? true;
|
|
178
|
+
const lock = options.lockScroll ?? false;
|
|
179
|
+
const closeRef = useRef(close);
|
|
180
|
+
closeRef.current = close;
|
|
181
|
+
const [layer, setLayer] = useState(null);
|
|
182
|
+
useLayoutEffect(() => {
|
|
183
|
+
if (!open)
|
|
184
|
+
return;
|
|
185
|
+
const l = register(kind, () => closeRef.current());
|
|
186
|
+
setLayer(l);
|
|
187
|
+
return () => {
|
|
188
|
+
unregister(l);
|
|
189
|
+
setLayer((cur) => (cur === l ? null : cur));
|
|
190
|
+
};
|
|
191
|
+
}, [kind, open]);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (!open || !lock)
|
|
194
|
+
return;
|
|
195
|
+
return lockScroll();
|
|
196
|
+
}, [open, lock]);
|
|
197
|
+
const all = useSyncExternalStore(subscribe, snapshot, serverSnapshot);
|
|
198
|
+
const i = layer ? all.indexOf(layer) : -1;
|
|
199
|
+
const index = i < 0 ? all.length : i;
|
|
200
|
+
return {
|
|
201
|
+
index,
|
|
202
|
+
isTop: i >= 0 && i === all.length - 1,
|
|
203
|
+
zIndex: config.baseZ + index * 2,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/** How many pages and sheets are open (re-renders when it changes). */
|
|
207
|
+
export function usePhoneLayerCount() {
|
|
208
|
+
return useSyncExternalStore(subscribe, snapshot, serverSnapshot).length;
|
|
209
|
+
}
|
|
210
|
+
/** Is any page or sheet open? For an app that must stand still under one (a tab bar's search request). */
|
|
211
|
+
export function useAnyPhoneLayerOpen() {
|
|
212
|
+
return usePhoneLayerCount() > 0;
|
|
213
|
+
}
|
|
214
|
+
/** Close the top layer, as Back would. Answers false when nothing is open or it refused. */
|
|
215
|
+
export function closeTopPhoneLayer() {
|
|
216
|
+
const top = [...layers].reverse().find((l) => !l.closing);
|
|
217
|
+
if (!top)
|
|
218
|
+
return false;
|
|
219
|
+
return top.close() !== false;
|
|
220
|
+
}
|
|
221
|
+
/** For tests and diagnostics: the open layers' kinds, bottom first, and our history entries. */
|
|
222
|
+
export function phoneLayerDebug() {
|
|
223
|
+
return { kinds: layers.map((l) => l.kind), pushed };
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=layers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/phone/layers.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,6EAA6E;AAC7E,8EAA8E;AAC9E,sBAAsB;AACtB,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,mDAAmD;AACnD,EAAE;AACF,4CAA4C;AAC5C,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,kDAAkD;AAClD,8EAA8E;AAC9E,0EAA0E;AAC1E,qDAAqD;AACrD,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,4DAA4D;AAC5D,uEAAuE;AACvE,2EAA2E;AAC3E,6EAA6E;AAC7E,4DAA4D;AAC5D,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AAExE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAwB1F,MAAM,MAAM,GAAgC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAC1E,IAAI,MAAM,GAAY,EAAE,CAAA;AACxB,IAAI,MAAM,GAAG,CAAC,CAAA;A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AA;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,kBAAkB;IAChC,OAAO,oBAAoB,CAAC,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,MAAM,CAAA;AACzE,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,oBAAoB;IAClC,OAAO,kBAAkB,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IACzD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IACtB,OAAO,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,CAAA;AAC9B,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,eAAe;IAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
/** How wide the fade is, in px. */
|
|
3
|
+
export declare const SCROLL_HINT_FADE_PX = 28;
|
|
4
|
+
export interface ScrollHint<T extends HTMLElement> {
|
|
5
|
+
/** Put on the scroller. */
|
|
6
|
+
ref: (el: T | null) => void;
|
|
7
|
+
/** Spread onto the scroller: the edge fade (a CSS mask), only while there is more that way. */
|
|
8
|
+
style: CSSProperties;
|
|
9
|
+
/** Add to the scroller: hides its scrollbar (the fade says it scrolls). */
|
|
10
|
+
className: string;
|
|
11
|
+
/** Is there more before / after what is in view? */
|
|
12
|
+
more: {
|
|
13
|
+
start: boolean;
|
|
14
|
+
end: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `const hint = useScrollHint<HTMLDivElement>()` then
|
|
19
|
+
* `<div ref={hint.ref} className={hint.className} style={{ ...hint.style, overflowX: 'auto' }}>`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useScrollHint<T extends HTMLElement = HTMLDivElement>(): ScrollHint<T>;
|
|
22
|
+
//# sourceMappingURL=scrollHint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollHint.d.ts","sourceRoot":"","sources":["../../src/phone/scrollHint.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAGpF,mCAAmC;AACnC,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,WAAW;IAC/C,2BAA2B;IAC3B,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;IAC3B,+FAA+F;IAC/F,KAAK,EAAE,aAAa,CAAA;IACpB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,CAAA;CACvC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,KAAK,UAAU,CAAC,CAAC,CAAC,CAqDrF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// A row that scrolls sideways shows that it does (BRANDING.md ▸ "A row that
|
|
3
|
+
// scrolls shows it scrolls", owner rule 2026-10-18: "needs to be obvious you
|
|
4
|
+
// can scroll … make it a global rule"): a fade at each edge that has more
|
|
5
|
+
// beyond it, so the cut-off item reads as "continues" rather than "clipped".
|
|
6
|
+
// No nudge: the row slid along and back as it appeared until James dropped it
|
|
7
|
+
// (2026-10-19: "doesn't need the peek anymore, the fade on the last item
|
|
8
|
+
// works well").
|
|
9
|
+
//
|
|
10
|
+
// Moved here from Universal PDF's `src/native/parts.tsx`. Kept from the
|
|
11
|
+
// Images / Converter / Compress copy: it also re-measures when an item
|
|
12
|
+
// changes size. New here: the ref is a callback, so a row that mounts later
|
|
13
|
+
// than the component that calls this (PDF needed a component of its own for
|
|
14
|
+
// each such row) is measured all the same, and items added or removed are
|
|
15
|
+
// noticed.
|
|
16
|
+
//
|
|
17
|
+
// The other half of the rule is the app's: size the items so one is cut off
|
|
18
|
+
// at the edge (five and a half across, not five), and a snapping row needs
|
|
19
|
+
// `scroll-padding` matching its padding so it rests at the start.
|
|
20
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
21
|
+
import { injectPhoneStyles } from './styles.js';
|
|
22
|
+
/** How wide the fade is, in px. */
|
|
23
|
+
export const SCROLL_HINT_FADE_PX = 28;
|
|
24
|
+
/**
|
|
25
|
+
* `const hint = useScrollHint<HTMLDivElement>()` then
|
|
26
|
+
* `<div ref={hint.ref} className={hint.className} style={{ ...hint.style, overflowX: 'auto' }}>`.
|
|
27
|
+
*/
|
|
28
|
+
export function useScrollHint() {
|
|
29
|
+
const [el, setEl] = useState(null);
|
|
30
|
+
const [more, setMore] = useState({ start: false, end: false });
|
|
31
|
+
const ref = useCallback((node) => setEl(node), []);
|
|
32
|
+
const last = useRef(more);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
injectPhoneStyles();
|
|
35
|
+
}, []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!el)
|
|
38
|
+
return;
|
|
39
|
+
const measure = () => {
|
|
40
|
+
const max = el.scrollWidth - el.clientWidth;
|
|
41
|
+
const next = { start: el.scrollLeft > 2, end: el.scrollLeft < max - 2 };
|
|
42
|
+
if (next.start !== last.current.start || next.end !== last.current.end) {
|
|
43
|
+
last.current = next;
|
|
44
|
+
setMore(next);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
measure();
|
|
48
|
+
el.addEventListener('scroll', measure, { passive: true });
|
|
49
|
+
const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
|
|
50
|
+
const watchItems = () => {
|
|
51
|
+
if (!ro)
|
|
52
|
+
return;
|
|
53
|
+
ro.disconnect();
|
|
54
|
+
ro.observe(el);
|
|
55
|
+
for (const child of Array.from(el.children))
|
|
56
|
+
ro.observe(child);
|
|
57
|
+
};
|
|
58
|
+
watchItems();
|
|
59
|
+
const mo = typeof MutationObserver === 'undefined' ? null : new MutationObserver(() => {
|
|
60
|
+
watchItems();
|
|
61
|
+
measure();
|
|
62
|
+
});
|
|
63
|
+
mo?.observe(el, { childList: true });
|
|
64
|
+
return () => {
|
|
65
|
+
el.removeEventListener('scroll', measure);
|
|
66
|
+
ro?.disconnect();
|
|
67
|
+
mo?.disconnect();
|
|
68
|
+
};
|
|
69
|
+
}, [el]);
|
|
70
|
+
const F = SCROLL_HINT_FADE_PX;
|
|
71
|
+
const mask = more.start || more.end
|
|
72
|
+
? `linear-gradient(to right, ${more.start ? 'transparent' : '#000'} 0, #000 ${more.start ? F : 0}px, #000 calc(100% - ${more.end ? F : 0}px), ${more.end ? 'transparent' : '#000'} 100%)`
|
|
73
|
+
: undefined;
|
|
74
|
+
return {
|
|
75
|
+
ref,
|
|
76
|
+
style: mask ? { maskImage: mask, WebkitMaskImage: mask } : {},
|
|
77
|
+
className: 'unisim-phone-row',
|
|
78
|
+
more,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=scrollHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollHint.js","sourceRoot":"","sources":["../../src/phone/scrollHint.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,gBAAgB;AAChB,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,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,MAAM,CAAC,GAAG,mBAAmB,CAAA;IAC7B,MAAM,IAAI,GACR,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG;QACpB,CAAC,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,QAAQ;QACzL,CAAC,CAAC,SAAS,CAAA;IACf,OAAO;QACL,GAAG;QACH,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;QAC7D,SAAS,EAAE,kBAAkB;QAC7B,IAAI;KACL,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Escape closes the layer while it is the top one (as the website's dialogs
|
|
4
|
+
* did). Capture phase, and stopped once handled, so a website dialog still
|
|
5
|
+
* mounted underneath does not close with it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useEscape(active: boolean, onEscape: () => void): void;
|
|
8
|
+
/**
|
|
9
|
+
* Focus into the layer as it opens (the layer itself, never a text box: the
|
|
10
|
+
* keyboard comes up only when asked for), and back where it was as it
|
|
11
|
+
* closes, if that is still on the page.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Once per opening, not on each new callback: re-running this on every
|
|
14
|
+
* render put the focus back on the layer under a box being typed in, so each
|
|
15
|
+
* keystroke lost the keyboard (Universal PDF, 2026-10-22).
|
|
16
|
+
*/
|
|
17
|
+
export declare function useFocusHandOff(ref: RefObject<HTMLElement | null>, active: boolean): void;
|
|
18
|
+
/**
|
|
19
|
+
* When the layer last opened (performance.now()), for its
|
|
20
|
+
* `data-phone-opened-at`: the SDK's reveal-on-open reads it so a page's own
|
|
21
|
+
* contents do not scroll it as it arrives (revealOnExpand.ts, `inFreshLayer`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function useOpenedAt(open: boolean): number | undefined;
|
|
24
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/phone/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEzD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAcrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CASzF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK7D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Escape closes the layer while it is the top one (as the website's dialogs
|
|
5
|
+
* did). Capture phase, and stopped once handled, so a website dialog still
|
|
6
|
+
* mounted underneath does not close with it.
|
|
7
|
+
*/
|
|
8
|
+
export function useEscape(active, onEscape) {
|
|
9
|
+
const ref = useRef(onEscape);
|
|
10
|
+
ref.current = onEscape;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!active || typeof document === 'undefined')
|
|
13
|
+
return;
|
|
14
|
+
const onKey = (e) => {
|
|
15
|
+
if (e.key !== 'Escape' || e.defaultPrevented)
|
|
16
|
+
return;
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
ref.current();
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener('keydown', onKey, true);
|
|
22
|
+
return () => document.removeEventListener('keydown', onKey, true);
|
|
23
|
+
}, [active]);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Focus into the layer as it opens (the layer itself, never a text box: the
|
|
27
|
+
* keyboard comes up only when asked for), and back where it was as it
|
|
28
|
+
* closes, if that is still on the page.
|
|
29
|
+
*
|
|
30
|
+
* ⚠️ Once per opening, not on each new callback: re-running this on every
|
|
31
|
+
* render put the focus back on the layer under a box being typed in, so each
|
|
32
|
+
* keystroke lost the keyboard (Universal PDF, 2026-10-22).
|
|
33
|
+
*/
|
|
34
|
+
export function useFocusHandOff(ref, active) {
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!active || typeof document === 'undefined')
|
|
37
|
+
return;
|
|
38
|
+
const before = document.activeElement;
|
|
39
|
+
ref.current?.focus({ preventScroll: true });
|
|
40
|
+
return () => {
|
|
41
|
+
if (before?.isConnected)
|
|
42
|
+
before.focus?.({ preventScroll: true });
|
|
43
|
+
};
|
|
44
|
+
}, [ref, active]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* When the layer last opened (performance.now()), for its
|
|
48
|
+
* `data-phone-opened-at`: the SDK's reveal-on-open reads it so a page's own
|
|
49
|
+
* contents do not scroll it as it arrives (revealOnExpand.ts, `inFreshLayer`).
|
|
50
|
+
*/
|
|
51
|
+
export function useOpenedAt(open) {
|
|
52
|
+
const at = useRef(undefined);
|
|
53
|
+
if (!open)
|
|
54
|
+
at.current = undefined;
|
|
55
|
+
else if (at.current === undefined && typeof performance !== 'undefined')
|
|
56
|
+
at.current = Math.max(1, performance.now());
|
|
57
|
+
return at.current;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","source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AAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;QAClE,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,MAAM,EAAE,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAA;IAChD,IAAI,CAAC,IAAI;QAAE,EAAE,CAAC,OAAO,GAAG,SAAS,CAAA;SAC5B,IAAI,EAAE,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,WAAW,KAAK,WAAW;QAAE,EAAE,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;IACpH,OAAO,EAAE,CAAC,OAAO,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const PHONE_STYLE_ID = "unisim-phone-kit";
|
|
2
|
+
/** Put the kit's stylesheet in the document once. A no-op on the server. */
|
|
3
|
+
export declare function injectPhoneStyles(): void;
|
|
4
|
+
export type PhoneTheme = 'light' | 'dark' | 'auto';
|
|
5
|
+
/** The attribute that pins a layer's theme (nothing for 'auto'). */
|
|
6
|
+
export declare function themeAttr(theme: PhoneTheme | undefined): {
|
|
7
|
+
'data-uph-theme'?: 'light' | 'dark';
|
|
8
|
+
};
|
|
9
|
+
/** Join class names, skipping the empty ones. */
|
|
10
|
+
export declare function cx(...names: (string | false | null | undefined)[]): string;
|
|
11
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/phone/styles.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,cAAc,qBAAqB,CAAA;AA6FhD,4EAA4E;AAC5E,wBAAgB,iBAAiB,IAAI,IAAI,CAOxC;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAElD,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG;IAAE,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,CAEhG;AAED,iDAAiD;AACjD,wBAAgB,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAE1E"}
|