@peektravel/app-utilities 0.7.3 → 0.7.4
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 +17 -0
- package/dist/ui/index.cjs +11 -0
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +16 -1
- package/dist/ui/index.d.ts +16 -1
- package/dist/ui/index.js +10 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/odyssey.css +30 -0
- package/docs/ui.md +27 -0
- package/llms.txt +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -374,6 +374,23 @@ attribute. Exported classes/types and helpers (`iconSvg`, `registerIcon`,
|
|
|
374
374
|
`portal`, `position`, `toast`) are available from `@peektravel/app-utilities/ui`
|
|
375
375
|
for subclassing or typing.
|
|
376
376
|
|
|
377
|
+
### Lazy registration & avoiding a flash of raw text
|
|
378
|
+
|
|
379
|
+
Registration is a side effect and **idempotent** — importing `/ui` twice (or from
|
|
380
|
+
two bundles) never throws. If you register lazily (a dynamic `import()`), two
|
|
381
|
+
things keep un-upgraded elements from flashing as their raw text: `odyssey.css`
|
|
382
|
+
ships a `:not(:defined) { visibility: hidden }` guard (load the CSS eagerly for it
|
|
383
|
+
to apply before first paint), and `whenOdysseyReady()` resolves once every
|
|
384
|
+
imported element has upgraded, so you can gate your first render on it:
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
import { whenOdysseyReady } from '@peektravel/app-utilities/ui';
|
|
388
|
+
await whenOdysseyReady();
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
A failed dynamic import still rejects at the `import()` call site — handle load
|
|
392
|
+
failures there.
|
|
393
|
+
|
|
377
394
|
### Using the components from React 19
|
|
378
395
|
|
|
379
396
|
React 19 sets JSX props on a custom element as DOM **properties**
|
package/dist/ui/index.cjs
CHANGED
|
@@ -291,11 +291,20 @@ function addReactSafeSetters(ctor) {
|
|
|
291
291
|
proto = Object.getPrototypeOf(proto);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
var registered = [];
|
|
294
295
|
function define(tag, ctor) {
|
|
295
296
|
if (typeof customElements === "undefined") return;
|
|
296
297
|
if (customElements.get(tag)) return;
|
|
297
298
|
addReactSafeSetters(ctor);
|
|
298
299
|
customElements.define(tag, ctor);
|
|
300
|
+
registered.push(tag);
|
|
301
|
+
}
|
|
302
|
+
function registeredTags() {
|
|
303
|
+
return registered.slice();
|
|
304
|
+
}
|
|
305
|
+
function whenOdysseyReady() {
|
|
306
|
+
if (typeof customElements === "undefined") return Promise.resolve();
|
|
307
|
+
return Promise.all(registered.map((tag) => customElements.whenDefined(tag))).then(() => void 0);
|
|
299
308
|
}
|
|
300
309
|
|
|
301
310
|
// src/ui/icons-data.ts
|
|
@@ -4458,8 +4467,10 @@ exports.portal = portal;
|
|
|
4458
4467
|
exports.position = position;
|
|
4459
4468
|
exports.registerIcon = registerIcon;
|
|
4460
4469
|
exports.registerTranslation = registerTranslation;
|
|
4470
|
+
exports.registeredTags = registeredTags;
|
|
4461
4471
|
exports.removePortal = removePortal;
|
|
4462
4472
|
exports.renderIconSvg = renderIconSvg;
|
|
4463
4473
|
exports.toast = toast;
|
|
4474
|
+
exports.whenOdysseyReady = whenOdysseyReady;
|
|
4464
4475
|
//# sourceMappingURL=index.cjs.map
|
|
4465
4476
|
//# sourceMappingURL=index.cjs.map
|