@unisim/sdk 0.202.0 → 0.203.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 +82 -0
- 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 +139 -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,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,MA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AA;IACpC,OAAO;QACL,KAAK;QACL,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC;QACrC,MAAM,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC;KACjC,CAAA;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":[],"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CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACzC,EAAE,EAAE,UAAU,EAAE,CAAA;YAChB,EAAE,EAAE,UAAU,EAAE,CAAA;QAClB,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAER,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","sourceRoot":"","sources":["../../src/phone/shared.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAEzD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAe,EAAE,QAAoB;IAC7D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5B,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAA;IACtB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAM;QACtD,MAAM,KAAK,GAAG,CAAC,CAAgB,EAAE,EAAE;YACjC,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,gBAAgB;gBAAE,OAAM;YACpD,CAAC,CAAC,cAAc,EAAE,CAAA;YAClB,CAAC,CAAC,eAAe,EAAE,CAAA;YACnB,GAAG,CAAC,OAAO,EAAE,CAAA;QACf,CAAC,CAAA;QACD,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QACjD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IACnE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAkC,EAAE,MAAe;IACjF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAM;QACtD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAmC,CAAA;QAC3D,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3C,OAAO,GAAG,EAAE;YACV,IAAI,MAAM,EAAE,WAAW;gBAAE,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":"AAkCA,eAAO,MAAM,cAAc,qBAAqB,CAAA;AA0FhD,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"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// The phone kit's one stylesheet, injected the first time a page or sheet
|
|
3
|
+
// renders (the SDK ships no CSS file, and an app may have no Tailwind).
|
|
4
|
+
//
|
|
5
|
+
// Every rule is wrapped in `:where()`, so it weighs nothing: any class the app
|
|
6
|
+
// passes (`className`, Tailwind or its own) wins without `!important`.
|
|
7
|
+
//
|
|
8
|
+
// ── Tokens ───────────────────────────────────────────────────────────────────
|
|
9
|
+
// The colours are CSS custom properties on each layer, light by default (the
|
|
10
|
+
// suite's rule: light until the person picks dark or system). Dark follows the
|
|
11
|
+
// SDK theme store's `html.dark` (or `html[data-theme="dark"]`), unless the
|
|
12
|
+
// component was given `theme="light" | "dark"`, which pins it. An app re-skins
|
|
13
|
+
// the kit by setting the same properties on `.unisim-phone-layer` (and under
|
|
14
|
+
// its own dark selector), e.g.
|
|
15
|
+
//
|
|
16
|
+
// .unisim-phone-layer { --uph-accent: #1d4ed8; --uph-bg: #fbf6ee; }
|
|
17
|
+
//
|
|
18
|
+
// --uph-bg a page's ground
|
|
19
|
+
// --uph-surface bars, cards, the secondary button
|
|
20
|
+
// --uph-sheet a bottom sheet's ground
|
|
21
|
+
// --uph-text words
|
|
22
|
+
// --uph-muted quieter words
|
|
23
|
+
// --uph-line hairlines
|
|
24
|
+
// --uph-accent the back link (orange as TEXT: 5.18:1 on white)
|
|
25
|
+
// --uph-primary a filled button (white on it: 5.91:1)
|
|
26
|
+
// --uph-on-primary its label
|
|
27
|
+
// --uph-danger a destructive filled button (white on it: 4.83:1)
|
|
28
|
+
// --uph-scrim the dim behind a sheet
|
|
29
|
+
// --uph-grip the sheet's grip
|
|
30
|
+
//
|
|
31
|
+
// Motion: a page slides in from the right, a sheet rises, its scrim fades;
|
|
32
|
+
// none of it under prefers-reduced-motion.
|
|
33
|
+
export const PHONE_STYLE_ID = 'unisim-phone-kit';
|
|
34
|
+
const CSS = `
|
|
35
|
+
:where(.unisim-phone-layer){
|
|
36
|
+
--uph-bg:#f8fafc;--uph-surface:#ffffff;--uph-sheet:#f8fafc;--uph-text:#0f172a;--uph-muted:#64748b;
|
|
37
|
+
--uph-line:#e2e8f0;--uph-accent:#c2410c;--uph-primary:#ad4200;--uph-on-primary:#ffffff;
|
|
38
|
+
--uph-danger:#dc2626;--uph-scrim:rgba(15,23,42,0.45);--uph-grip:#cbd5e1;
|
|
39
|
+
color:var(--uph-text);
|
|
40
|
+
font-family:inherit;
|
|
41
|
+
-webkit-tap-highlight-color:transparent;
|
|
42
|
+
}
|
|
43
|
+
:where(html.dark, html[data-theme="dark"]) :where(.unisim-phone-layer:not([data-uph-theme="light"])),
|
|
44
|
+
:where(.unisim-phone-layer[data-uph-theme="dark"]){
|
|
45
|
+
--uph-bg:#0a0e16;--uph-surface:#121a2a;--uph-sheet:#121a2a;--uph-text:#e6eaf2;--uph-muted:#9fb0c6;
|
|
46
|
+
--uph-line:#334155;--uph-accent:#ff9a1f;--uph-primary:#ad4200;--uph-on-primary:#ffffff;
|
|
47
|
+
--uph-danger:#dc2626;--uph-scrim:rgba(0,0,0,0.6);--uph-grip:#475569;
|
|
48
|
+
}
|
|
49
|
+
:where(.unisim-phone-page){
|
|
50
|
+
position:fixed;inset:0;display:flex;flex-direction:column;background:var(--uph-bg);outline:none;
|
|
51
|
+
animation:uph-slide 220ms cubic-bezier(0.2,0.8,0.2,1);
|
|
52
|
+
}
|
|
53
|
+
:where(.unisim-phone-page[hidden]){display:none}
|
|
54
|
+
:where(.unisim-phone-bar){
|
|
55
|
+
flex:none;background:var(--uph-surface);border-bottom:1px solid var(--uph-line);
|
|
56
|
+
padding-top:env(safe-area-inset-top,0px);
|
|
57
|
+
}
|
|
58
|
+
:where(.unisim-phone-bar-row){position:relative;display:flex;align-items:center;min-height:52px;padding:0 6px}
|
|
59
|
+
:where(.unisim-phone-back){
|
|
60
|
+
position:relative;z-index:1;display:flex;align-items:center;gap:2px;min-height:44px;max-width:45%;
|
|
61
|
+
padding:0 8px;border:0;border-radius:10px;background:none;color:var(--uph-accent);
|
|
62
|
+
font:inherit;font-size:16px;cursor:pointer;
|
|
63
|
+
}
|
|
64
|
+
:where(.unisim-phone-back:disabled){opacity:0.4;cursor:default}
|
|
65
|
+
:where(.unisim-phone-back > span){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
66
|
+
:where(.unisim-phone-title){
|
|
67
|
+
position:absolute;left:96px;right:96px;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
68
|
+
text-align:center;font-size:16px;font-weight:600;pointer-events:none;transition:opacity 150ms ease;
|
|
69
|
+
}
|
|
70
|
+
:where(.unisim-phone-actions){position:relative;z-index:1;margin-left:auto;display:flex;align-items:center;gap:4px}
|
|
71
|
+
:where(.unisim-phone-body){flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
|
|
72
|
+
:where(.unisim-phone-large-title){margin:0;padding:4px 16px 0;font-size:30px;line-height:1.15;font-weight:800}
|
|
73
|
+
:where(.unisim-phone-sub){margin:4px 0 0;padding:0 16px;font-size:14px;line-height:1.5;color:var(--uph-muted)}
|
|
74
|
+
:where(.unisim-phone-foot){
|
|
75
|
+
flex:none;background:var(--uph-surface);border-top:1px solid var(--uph-line);
|
|
76
|
+
padding:12px 16px calc(env(safe-area-inset-bottom,0px) + 12px);
|
|
77
|
+
}
|
|
78
|
+
:where(.unisim-phone-sheet-wrap){position:fixed;inset:0}
|
|
79
|
+
:where(.unisim-phone-scrim){position:absolute;inset:0;background:var(--uph-scrim);animation:uph-fade 160ms ease-out}
|
|
80
|
+
:where(.unisim-phone-scrim[data-tone="dark"]){background:rgba(0,0,0,0.6)}
|
|
81
|
+
:where(.unisim-phone-sheet){
|
|
82
|
+
position:absolute;left:0;right:0;bottom:0;margin:0 auto;max-width:640px;display:flex;flex-direction:column;
|
|
83
|
+
max-height:calc(100% - env(safe-area-inset-top,0px) - 32px);
|
|
84
|
+
padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px);
|
|
85
|
+
background:var(--uph-sheet);color:var(--uph-text);border-radius:22px 22px 0 0;
|
|
86
|
+
box-shadow:0 -10px 40px -12px rgba(0,0,0,0.35);outline:none;
|
|
87
|
+
animation:uph-rise 200ms cubic-bezier(0.2,0.8,0.2,1);
|
|
88
|
+
}
|
|
89
|
+
:where(.unisim-phone-grip){flex:none;align-self:stretch;display:flex;justify-content:center;padding:8px 0;touch-action:none;cursor:grab}
|
|
90
|
+
:where(.unisim-phone-grip > span){display:block;width:40px;height:5px;border-radius:999px;background:var(--uph-grip,#cbd5e1)}
|
|
91
|
+
:where(.unisim-phone-sheet-title){flex:none;margin:0;padding:0 20px 8px;font-size:20px;font-weight:700}
|
|
92
|
+
:where(.unisim-phone-sheet-body){
|
|
93
|
+
min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0 16px;
|
|
94
|
+
display:flex;flex-direction:column;gap:12px;
|
|
95
|
+
}
|
|
96
|
+
:where(.unisim-phone-sheet-body > *){flex:none}
|
|
97
|
+
:where(.unisim-phone-sheet-foot){flex:none;padding:12px 16px 0}
|
|
98
|
+
:where(.unisim-phone-btn){
|
|
99
|
+
display:block;width:100%;min-height:50px;padding:12px 16px;border-radius:16px;border:1px solid var(--uph-line);
|
|
100
|
+
background:var(--uph-surface);color:var(--uph-text);font:inherit;font-size:17px;cursor:pointer;
|
|
101
|
+
}
|
|
102
|
+
:where(.unisim-phone-btn[data-tone="primary"]){background:var(--uph-primary);color:var(--uph-on-primary);border-color:transparent;font-weight:600}
|
|
103
|
+
:where(.unisim-phone-btn[data-tone="danger"]){background:var(--uph-danger);color:#fff;border-color:transparent;font-weight:600}
|
|
104
|
+
:where(.unisim-phone-btn:disabled){opacity:0.5;cursor:default}
|
|
105
|
+
:where(.unisim-phone-message){margin:0;padding:4px 4px 0;font-size:16px;line-height:1.4;text-align:center}
|
|
106
|
+
:where(.unisim-phone-message-title){margin:0;padding:0 4px;font-size:18px;font-weight:700;text-align:center}
|
|
107
|
+
:where(.unisim-phone-input){
|
|
108
|
+
display:block;width:100%;box-sizing:border-box;height:48px;padding:0 12px;border-radius:12px;
|
|
109
|
+
border:1px solid var(--uph-line);background:var(--uph-surface);color:var(--uph-text);font:inherit;font-size:16px;
|
|
110
|
+
}
|
|
111
|
+
:where(.unisim-phone-row){scrollbar-width:none;-webkit-overflow-scrolling:touch}
|
|
112
|
+
:where(.unisim-phone-row)::-webkit-scrollbar{display:none}
|
|
113
|
+
@keyframes uph-slide{from{transform:translateX(28px);opacity:0.5}to{transform:none;opacity:1}}
|
|
114
|
+
@keyframes uph-rise{from{transform:translateY(40px);opacity:0.4}to{transform:none;opacity:1}}
|
|
115
|
+
@keyframes uph-fade{from{opacity:0}to{opacity:1}}
|
|
116
|
+
@media (prefers-reduced-motion: reduce){
|
|
117
|
+
:where(.unisim-phone-page, .unisim-phone-sheet, .unisim-phone-scrim){animation:none}
|
|
118
|
+
:where(.unisim-phone-title){transition:none}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
/** Put the kit's stylesheet in the document once. A no-op on the server. */
|
|
122
|
+
export function injectPhoneStyles() {
|
|
123
|
+
if (typeof document === 'undefined' || document.getElementById(PHONE_STYLE_ID))
|
|
124
|
+
return;
|
|
125
|
+
const style = document.createElement('style');
|
|
126
|
+
style.id = PHONE_STYLE_ID;
|
|
127
|
+
style.textContent = CSS;
|
|
128
|
+
// First in <head>, so an app's own stylesheet comes after it and wins ties.
|
|
129
|
+
document.head.insertBefore(style, document.head.firstChild);
|
|
130
|
+
}
|
|
131
|
+
/** The attribute that pins a layer's theme (nothing for 'auto'). */
|
|
132
|
+
export function themeAttr(theme) {
|
|
133
|
+
return theme === 'light' || theme === 'dark' ? { 'data-uph-theme': theme } : {};
|
|
134
|
+
}
|
|
135
|
+
/** Join class names, skipping the empty ones. */
|
|
136
|
+
export function cx(...names) {
|
|
137
|
+
return names.filter(Boolean).join(' ');
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/phone/styles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,0EAA0E;AAC1E,wEAAwE;AACxE,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,+BAA+B;AAC/B,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,qCAAqC;AACrC,uDAAuD;AACvD,6CAA6C;AAC7C,2BAA2B;AAC3B,mCAAmC;AACnC,+BAA+B;AAC/B,qEAAqE;AACrE,2DAA2D;AAC3D,+BAA+B;AAC/B,uEAAuE;AACvE,4CAA4C;AAC5C,sCAAsC;AACtC,EAAE;AACF,2EAA2E;AAC3E,2CAA2C;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAEhD,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFX,CAAA;AAED,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAC;QAAE,OAAM;IACtF,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC7C,KAAK,CAAC,EAAE,GAAG,cAAc,CAAA;IACzB,KAAK,CAAC,WAAW,GAAG,GAAG,CAAA;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAC7D,CAAC;AAID,oEAAoE;AACpE,MAAM,UAAU,SAAS,CAAC,KAA6B;IACrD,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACjF,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,EAAE,CAAC,GAAG,KAA4C;IAChE,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kit's own words (Back, Cancel, OK) in the app's language: the
|
|
3
|
+
* `language` prop, else <UniversalProvider>'s, else the page's `<html lang>`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function usePhoneText(language?: string | null): (key: 'back' | 'cancel' | 'ok') => string;
|
|
6
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/phone/text.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,KAAK,MAAM,CAOhG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { t } from '../i18n.js';
|
|
3
|
+
import { useOptionalLanguage } from '../provider.js';
|
|
4
|
+
/**
|
|
5
|
+
* The kit's own words (Back, Cancel, OK) in the app's language: the
|
|
6
|
+
* `language` prop, else <UniversalProvider>'s, else the page's `<html lang>`.
|
|
7
|
+
*/
|
|
8
|
+
export function usePhoneText(language) {
|
|
9
|
+
const fromProvider = useOptionalLanguage();
|
|
10
|
+
const lang = language ??
|
|
11
|
+
fromProvider ??
|
|
12
|
+
(typeof document !== 'undefined' ? document.documentElement.lang || null : null);
|
|
13
|
+
return (key) => t(lang, `phone.${key}`);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/phone/text.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,QAAwB;IACnD,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAA;IAC1C,MAAM,IAAI,GACR,QAAQ;QACR,YAAY;QACZ,CAAC,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAClF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revealOnExpand.d.ts","sourceRoot":"","sources":["../src/revealOnExpand.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;
|
|
1
|
+
{"version":3,"file":"revealOnExpand.d.ts","sourceRoot":"","sources":["../src/revealOnExpand.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAuID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,GAAE,qBAA0B,GAClC,IAAI,CAoCN;AA4BD;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED,yEAAyE;AACzE,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,IAAI,CA2DrF"}
|