@brytdesigns/web-component-core 1.1.6 → 3.0.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.
Files changed (84) hide show
  1. package/dist/main/animation/awaitAllAnimations.js +28 -32
  2. package/dist/main/animation/awaitAllAnimations.js.map +1 -1
  3. package/dist/main/animation/content.js +156 -0
  4. package/dist/main/animation/content.js.map +1 -0
  5. package/dist/main/animation/controlsToPromise.js +6 -5
  6. package/dist/main/animation/controlsToPromise.js.map +1 -1
  7. package/dist/main/animation/getTransitionConfig.js +52 -51
  8. package/dist/main/animation/getTransitionConfig.js.map +1 -1
  9. package/dist/main/animation/index.d.ts +61 -1
  10. package/dist/main/animation/index.js +5 -5
  11. package/dist/main/focusTrap/index.d.ts +1 -1
  12. package/dist/main/focusTrap/index.js +10 -14
  13. package/dist/main/focusTrap/index.js.map +1 -1
  14. package/dist/main/hooks/index.d.ts +14 -9
  15. package/dist/main/hooks/index.js +5 -6
  16. package/dist/main/hooks/internal/getValueFromPath.js +9 -10
  17. package/dist/main/hooks/internal/getValueFromPath.js.map +1 -1
  18. package/dist/main/hooks/makePathContextHooks.js +58 -68
  19. package/dist/main/hooks/makePathContextHooks.js.map +1 -1
  20. package/dist/main/hooks/makePathDataArrayComponent.js +61 -67
  21. package/dist/main/hooks/makePathDataArrayComponent.js.map +1 -1
  22. package/dist/main/hooks/makePathDataArrayItemComponent.js +17 -21
  23. package/dist/main/hooks/makePathDataArrayItemComponent.js.map +1 -1
  24. package/dist/main/hooks/makePathDataComponent.js +31 -33
  25. package/dist/main/hooks/makePathDataComponent.js.map +1 -1
  26. package/dist/main/index.d.ts +304 -27
  27. package/dist/main/index.js +28 -7
  28. package/dist/main/promise/abortablePromise.js +10 -15
  29. package/dist/main/promise/abortablePromise.js.map +1 -1
  30. package/dist/main/promise/index.js +2 -3
  31. package/dist/main/utils/a11y.js +133 -0
  32. package/dist/main/utils/a11y.js.map +1 -0
  33. package/dist/main/utils/body-scroll-lock.js +40 -18
  34. package/dist/main/utils/body-scroll-lock.js.map +1 -1
  35. package/dist/main/utils/checkLoaded.js +4 -4
  36. package/dist/main/utils/checkLoaded.js.map +1 -1
  37. package/dist/main/utils/createRemoteContext.js +85 -0
  38. package/dist/main/utils/createRemoteContext.js.map +1 -0
  39. package/dist/main/utils/disclosure.js +52 -0
  40. package/dist/main/utils/disclosure.js.map +1 -0
  41. package/dist/main/utils/formatValue.js +14 -18
  42. package/dist/main/utils/formatValue.js.map +1 -1
  43. package/dist/main/utils/getContextFromProvider.js +15 -10
  44. package/dist/main/utils/getContextFromProvider.js.map +1 -1
  45. package/dist/main/utils/getTemplateContent.js +6 -7
  46. package/dist/main/utils/getTemplateContent.js.map +1 -1
  47. package/dist/main/utils/guarded-effect.js +72 -0
  48. package/dist/main/utils/guarded-effect.js.map +1 -0
  49. package/dist/main/utils/index.d.ts +237 -20
  50. package/dist/main/utils/index.js +15 -12
  51. package/dist/main/utils/invokeOnLoaded.js +13 -13
  52. package/dist/main/utils/invokeOnLoaded.js.map +1 -1
  53. package/dist/main/utils/isCustomElement.js +4 -3
  54. package/dist/main/utils/isCustomElement.js.map +1 -1
  55. package/dist/main/utils/nested-overlays.js +36 -0
  56. package/dist/main/utils/nested-overlays.js.map +1 -0
  57. package/dist/main/utils/solid-element.js +48 -88
  58. package/dist/main/utils/solid-element.js.map +1 -1
  59. package/dist/main/utils/toHyphenated.js +4 -3
  60. package/dist/main/utils/toHyphenated.js.map +1 -1
  61. package/package.json +16 -15
  62. package/dist/esm/animation/index.js +0 -97
  63. package/dist/esm/animation/index.js.map +0 -1
  64. package/dist/esm/focusTrap/index.js +0 -18
  65. package/dist/esm/focusTrap/index.js.map +0 -1
  66. package/dist/esm/hooks/index.js +0 -235
  67. package/dist/esm/hooks/index.js.map +0 -1
  68. package/dist/esm/index.js +0 -547
  69. package/dist/esm/index.js.map +0 -1
  70. package/dist/esm/promise/index.js +0 -20
  71. package/dist/esm/promise/index.js.map +0 -1
  72. package/dist/esm/utils/index.js +0 -236
  73. package/dist/esm/utils/index.js.map +0 -1
  74. package/dist/main/animation/index.js.map +0 -1
  75. package/dist/main/hooks/index.js.map +0 -1
  76. package/dist/main/hooks/internal/index.js +0 -3
  77. package/dist/main/hooks/internal/index.js.map +0 -1
  78. package/dist/main/hooks/internal/types.js +0 -3
  79. package/dist/main/hooks/internal/types.js.map +0 -1
  80. package/dist/main/index.js.map +0 -1
  81. package/dist/main/promise/index.js.map +0 -1
  82. package/dist/main/utils/createWithElementContext.js +0 -64
  83. package/dist/main/utils/createWithElementContext.js.map +0 -1
  84. package/dist/main/utils/index.js.map +0 -1
@@ -1,32 +1,249 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  import { BodyScrollOptions } from 'body-scroll-lock-upgrade';
4
- import { ComponentType as mComponentType, ICustomElement, createContext } from 'component-register';
5
- import { Accessor } from 'solid-js';
4
+ import { ComponentType as ComponentRegisterComponentType, ICustomElement, createContext } from 'component-register';
5
+ import { EffectFunction, EffectOptions } from 'solid-js';
6
6
 
7
- export declare function toHyphenated(str: string): string;
8
- export type ComponentType<T> = mComponentType<T>;
9
- export type CorrectComponentOptions = {
10
- element: HTMLElement & ICustomElement;
7
+ /**
8
+ * Shared accessibility helpers.
9
+ *
10
+ * Everything here was either duplicated across leaf packages or missing
11
+ * entirely while each overlay reimplemented a piece of it.
12
+ */
13
+ /**
14
+ * Visually hidden, still in the accessibility tree.
15
+ *
16
+ * Byte-identical to the copies that lived in `keen-slider-scrollbar`,
17
+ * `keen-slider-navigation-arrows` and `keen-slider-navigation-dots` — three
18
+ * copies of the same clip-rect incantation, none of which could be fixed
19
+ * without finding the other two.
20
+ */
21
+ export declare const srOnly = "border-width:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin-top:-1px !important;margin-bottom:-1px !important;margin-right:-1px !important;margin-left:-1px !important;overflow:hidden !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important;";
22
+ /**
23
+ * The panel belonging to this overlay — `dialog-content`, `drawer-content` or
24
+ * `modal-panel` — skipping the panels of overlays nested inside it.
25
+ *
26
+ * Same shape as `findDisclosureContent`, and for the same reason: a plain
27
+ * `querySelector` finds a nested overlay's panel first whenever the nested one
28
+ * is authored above its parent's own content.
29
+ */
30
+ export declare function findOverlayPanel(context: HTMLElement, panelTag: string, selector?: string): HTMLElement | null;
31
+ export type FocusReturn = {
32
+ /** Remembers what holds focus now, to restore later. */
33
+ record: () => void;
34
+ /** Restores it. Returns whether focus was actually moved. */
35
+ restore: () => boolean;
11
36
  };
12
- export type CorrectComponentType<T> = (props: T, options: CorrectComponentOptions) => unknown;
13
- export declare function customElement<T extends object>(tagName: string, props: T, Component?: ComponentType<T>, ...rest: ((C: ComponentType<T>) => ComponentType<T>)[]): import("component-register/types/utils").ComponentType<any>;
14
- export declare function customShadowlessElement<T extends object>(tagName: string, props: T, Component?: ComponentType<T>, ...rest: ((C: ComponentType<T>) => ComponentType<T>)[]): import("component-register/types/utils").ComponentType<any>;
15
- export declare const correctElementType: <T>(component: CorrectComponentType<T>) => ComponentType<T>;
16
- export declare function isCustomElement(element: any): element is ICustomElement & HTMLElement;
17
- export declare function getContextFromProvider<T>(context: ReturnType<typeof createContext>, element: Element): T;
37
+ /**
38
+ * Remembers where focus came from when an overlay opens, and puts it back when
39
+ * the overlay closes.
40
+ *
41
+ * `focus-trap` already does this, but only while a trap is active — so an
42
+ * overlay with `should-trap-focus="false"` dropped focus on the floor, and a
43
+ * keyboard user was returned to the top of the document. Keeping it separate
44
+ * means focus return is a property of opening and closing rather than a
45
+ * side effect of trapping.
46
+ *
47
+ * Focus already inside the overlay is not recorded: that is where focus is
48
+ * going, not where it came from, and restoring to it would strand the user in
49
+ * a hidden subtree.
50
+ */
51
+ export declare function createFocusReturn(element: HTMLElement): FocusReturn;
52
+ export type EscapeHandlerOptions = {
53
+ /** The overlay root — the element carrying `is-open`. */
54
+ element: HTMLElement;
55
+ /** Called when Escape should close this overlay. */
56
+ onEscape: () => void;
57
+ /** Checked at key time, so toggling the attribute takes effect at once. */
58
+ isEnabled?: () => boolean;
59
+ /** Overridable for tests; defaults to the three overlay context tags. */
60
+ selector?: string;
61
+ };
62
+ /**
63
+ * Closes the topmost overlay on Escape. Returns its own teardown.
64
+ *
65
+ * This exists because Escape was previously `focus-trap`'s `escapeDeactivates`
66
+ * option, which has two consequences nobody wanted: Escape did nothing at all
67
+ * unless focus trapping was *also* on, and the two settings could not be
68
+ * configured independently even though they are different promises to the
69
+ * user.
70
+ *
71
+ * Only the innermost open overlay responds, so Escape inside a nested dialog
72
+ * closes that dialog rather than collapsing the whole stack.
73
+ */
74
+ export declare function createEscapeHandler({ element, onEscape, isEnabled, selector, }: EscapeHandlerOptions): () => void;
75
+ export type Politeness = "polite" | "assertive";
76
+ /**
77
+ * Announces a message to assistive tech through a single shared live region.
78
+ *
79
+ * One region for the whole page, not one per component: a live region has to
80
+ * be in the DOM *before* its content changes for the change to be announced,
81
+ * so a component that creates one and fills it in the same tick announces
82
+ * nothing. Creating it once, on first use, sidesteps that.
83
+ *
84
+ * The text is cleared and set on a later tick for the same reason in reverse —
85
+ * writing identical text is not a change, so a screen reader stays silent when
86
+ * the same message is announced twice in a row.
87
+ */
88
+ export declare function announce(message: string, politeness?: Politeness): void;
89
+ export declare const disableBodyScroll: (element: ICustomElement & HTMLElement, options?: BodyScrollOptions) => void;
90
+ export declare const enableBodyScroll: (element: ICustomElement & HTMLElement) => void;
18
91
  export declare function checkLoaded(): boolean;
19
- export declare function invokeOnLoaded(fn: () => void, { signal }: {
20
- signal?: AbortSignal;
21
- }): void;
92
+ export type ContextRef = {
93
+ id: symbol;
94
+ };
95
+ export declare class RemoteContextError extends Error {
96
+ readonly target: unknown;
97
+ constructor(message: string, target: unknown);
98
+ }
99
+ export type RemoteContextOptions = {
100
+ /**
101
+ * Map a `target` to the element that actually provides the context.
102
+ *
103
+ * Synchronous by design — it answers "which element, given the DOM as it is
104
+ * now". Waiting for the element to appear is the helper's job, and it
105
+ * re-runs `resolve` on each mutation, so a strategy never has to implement
106
+ * retrying itself.
107
+ *
108
+ * Defaults to `document.querySelector(target)`, falling back to the host
109
+ * element when `target` is empty.
110
+ */
111
+ resolve?: (target: string | undefined, host: HTMLElement) => Element | null;
112
+ /** Label used in warnings and errors. Defaults to the context's symbol. */
113
+ name?: string;
114
+ };
115
+ /**
116
+ * Build a hook that resolves one context from a *lateral* element.
117
+ *
118
+ * ```ts
119
+ * export const useDrawerAt = createRemoteContext<DrawerContext>(DrawerContextState);
120
+ * ```
121
+ */
122
+ export declare function createRemoteContext<T>(context: ContextRef, { resolve, name }?: RemoteContextOptions): (target: () => string | undefined, host: HTMLElement) => import("solid-js").SourceAccessor<T & ({} | null)>;
22
123
  /**
23
- * Creates a HOF to ensure that a given callback is invoked only after the context for the element is ready.
24
- * */
25
- export declare function createWithElementContext<Context extends ReturnType<typeof createContext>, ContextState = null>(context: Context): <D extends any>(target: string | Accessor<string> | Accessor<() => Element>, dependencies: Accessor<D> | undefined, cb: (context: ContextState, dependencies: D) => void | (() => void)) => void;
124
+ * ARIA wiring for disclosure widgets (accordion and collapsible): the
125
+ * trigger's button reports whether its content is open and which content it
126
+ * controls.
127
+ */
128
+ /**
129
+ * The element a trigger exposes to assistive tech: the trigger itself when it
130
+ * has `role="button"`, otherwise the first button inside it.
131
+ */
132
+ export declare function findDisclosureControl(trigger: HTMLElement): HTMLElement | null;
133
+ /**
134
+ * The content belonging to the same item as `trigger`, skipping the content of items
135
+ * nested inside it.
136
+ */
137
+ export declare function findDisclosureContent(trigger: HTMLElement, itemTag: string, contentTag: string): HTMLElement | null;
138
+ /** Returns the element's id, assigning a unique `${prefix}-N` if it has none. */
139
+ export declare function ensureId(element: HTMLElement, prefix: string): string;
140
+ /**
141
+ * Points the control's `aria-controls` at the content, unless the markup already
142
+ * set one. Returns whether the control is linked.
143
+ */
144
+ export declare function linkDisclosureControl(control: HTMLElement, content: HTMLElement | null, idPrefix: string): boolean;
26
145
  export type Format = "currency" | "number" | "boolean" | "invert_boolean" | string;
27
146
  export declare function formatValue(format: Format, value: unknown): any;
147
+ /**
148
+ * Read a `component-register` context off an element, synchronously.
149
+ *
150
+ * The imperative counterpart to `createRemoteContext`: no waiting, no effect,
151
+ * callable from a plain `<script>` in a Liquid template when you already know
152
+ * the element is there. Deliberately kept separate — forcing an async,
153
+ * effect-shaped API on this use case would break theme scripts for no gain.
154
+ */
155
+ export declare function getContextFromProvider<T>(context: ReturnType<typeof createContext>, element: Element): T & ({} | null);
28
156
  export declare function getTemplateContent(element: HTMLElement, state: string): DocumentFragment | null;
29
- export declare const disableBodyScroll: (element: ICustomElement & HTMLElement, options?: BodyScrollOptions) => void;
30
- export declare const enableBodyScroll: (element: ICustomElement & HTMLElement) => void;
157
+ /**
158
+ * `createEffect` whose **apply phase cannot take the page down**.
159
+ *
160
+ * ## Why this exists
161
+ *
162
+ * Solid 2 treats the two phases of an effect very differently, and only one
163
+ * of them is dangerous. Measured against the installed `2.0.0-rc.14`, in
164
+ * `tests/component/reactivity-halt.test.ts`:
165
+ *
166
+ * | throw site | rest of the page |
167
+ * | ----------------- | --------------------------- |
168
+ * | component setup | unaffected |
169
+ * | compute phase | unaffected — the run is skipped and logged |
170
+ * | **apply phase** | **every computation on the page stops, permanently** |
171
+ *
172
+ * An uncaught apply-phase throw calls the runtime's `haltReactivity`, which
173
+ * is module-level global state. On a Shopify page every Bryt element shares
174
+ * one `solid-js` singleton, so one bad attribute on one element freezes every
175
+ * drawer, modal, slider and the cart until the shopper reloads.
176
+ *
177
+ * ## Why not an error boundary
178
+ *
179
+ * Because it does not work. `createErrorBoundary` is documented as catching
180
+ * this, and it does not in rc.14: the characterization test drives a
181
+ * subscribed boundary around the throwing effect and the fallback never runs
182
+ * while the rest of the page still freezes. Upstream's own guidance in
183
+ * `@solidjs/signals`' `createEffect` docblock is the half that holds —
184
+ *
185
+ * > The **effect phase is different**: it is your own imperative code, so
186
+ * > handle failures with `try/catch` where they occur.
187
+ *
188
+ * — which is all this function is. If a later release makes boundaries catch
189
+ * it, the characterization test starts failing and says so.
190
+ *
191
+ * The compute phase is deliberately NOT guarded. It is already non-fatal, and
192
+ * swallowing a compute error would hide a genuine reactivity bug behind an
193
+ * effect that silently stops updating.
194
+ *
195
+ * @param compute the tracking phase — reads signals, returns the value
196
+ * @param apply the imperative phase, may return a cleanup function
197
+ * @param options forwarded to `createEffect`; `name` is used in the report
198
+ */
199
+ export declare function createGuardedEffect<const T>(compute: (prev: T | undefined) => T, apply: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
200
+ export declare function invokeOnLoaded(fn: () => void, { signal }: {
201
+ signal?: AbortSignal;
202
+ }): void;
203
+ export declare function isCustomElement(element: any): element is ICustomElement & HTMLElement;
204
+ /**
205
+ * Closing an overlay has to close the overlays inside it.
206
+ *
207
+ * A dialog nested in another is hidden along with its parent, but
208
+ * nothing changes its own `isOpen`. It keeps reporting `is-open="true"` while
209
+ * invisible, never fires `drawer:close`, never releases what it holds, and
210
+ * reappears still open when the parent is opened again.
211
+ *
212
+ * These components have no concept of a parent — no containment check anywhere
213
+ * in either package — so the relationship is established here, at the point
214
+ * where it is needed, rather than threaded through context.
215
+ *
216
+ * Writing a *descendant's* attribute is allowed in Solid 2. Writing the
217
+ * component's own prop is what `REACTIVE_WRITE_IN_OWNED_SCOPE` forbids, which
218
+ * is why this takes the element rather than a setter.
219
+ */
220
+ /**
221
+ * Both kinds, not just the caller's own. A modal inside a drawer is hidden by
222
+ * the drawer closing exactly as another drawer would be, and is left in the
223
+ * same wrong state.
224
+ */
225
+ export declare const OVERLAY_SELECTOR = "dialog-context, drawer-context, modal-context";
226
+ export declare function closeNestedOverlays(root: HTMLElement, selector?: string): HTMLElement[];
227
+ export type ComponentType<T> = ComponentRegisterComponentType<T>;
228
+ /**
229
+ * `component-register` types `options.element` as a bare `ICustomElement`, but
230
+ * at runtime it is always also an `HTMLElement`. Every component in this repo
231
+ * needs the DOM half.
232
+ */
233
+ export type CorrectComponentOptions = {
234
+ element: HTMLElement & ICustomElement;
235
+ };
236
+ export type CorrectComponentType<T> = (props: T, options: CorrectComponentOptions) => unknown;
237
+ export type Middleware<T> = (Component: ComponentType<T>) => ComponentType<T>;
238
+ export declare function customElement<T extends object>(tagName: string, props: T, Component: CorrectComponentType<T>, ...rest: Middleware<T>[]): import("component-register/types/utils").ComponentType<any>;
239
+ export declare function customShadowlessElement<T extends object>(tagName: string, props: T, Component: CorrectComponentType<T>, ...rest: Middleware<T>[]): import("component-register/types/utils").ComponentType<any>;
240
+ /**
241
+ * @deprecated The narrowing is built into `customElement` and
242
+ * `customShadowlessElement` now, so this is a type-level identity. It is kept
243
+ * only so packages still on Solid 1 keep compiling during the migration;
244
+ * delete the call rather than porting it.
245
+ */
246
+ export declare const correctElementType: <T>(component: CorrectComponentType<T>) => CorrectComponentType<T>;
247
+ export declare function toHyphenated(str: string): string;
31
248
 
32
249
  export {};
@@ -1,12 +1,15 @@
1
- export * from './toHyphenated.js';
2
- export * from './solid-element.js';
3
- export * from './isCustomElement.js';
4
- export * from './getContextFromProvider.js';
5
- export * from './checkLoaded.js';
6
- export * from './invokeOnLoaded.js';
7
- export * from './createWithElementContext.js';
8
- export * from './formatValue.js';
9
- export * from './getTemplateContent.js';
10
- export * from './body-scroll-lock.js';
11
- //# sourceMappingURL=index.js.map
12
- //# sourceMappingURL=index.js.map
1
+ import { OVERLAY_SELECTOR, closeNestedOverlays } from "./nested-overlays.js";
2
+ import { announce, createEscapeHandler, createFocusReturn, findOverlayPanel, srOnly } from "./a11y.js";
3
+ import { createGuardedEffect } from "./guarded-effect.js";
4
+ import { disableBodyScroll, enableBodyScroll } from "./body-scroll-lock.js";
5
+ import { checkLoaded } from "./checkLoaded.js";
6
+ import { RemoteContextError, createRemoteContext } from "./createRemoteContext.js";
7
+ import { ensureId, findDisclosureContent, findDisclosureControl, linkDisclosureControl } from "./disclosure.js";
8
+ import { formatValue } from "./formatValue.js";
9
+ import { getContextFromProvider } from "./getContextFromProvider.js";
10
+ import { getTemplateContent } from "./getTemplateContent.js";
11
+ import { invokeOnLoaded } from "./invokeOnLoaded.js";
12
+ import { isCustomElement } from "./isCustomElement.js";
13
+ import { correctElementType, customElement, customShadowlessElement } from "./solid-element.js";
14
+ import { toHyphenated } from "./toHyphenated.js";
15
+ export { OVERLAY_SELECTOR, RemoteContextError, announce, checkLoaded, closeNestedOverlays, correctElementType, createEscapeHandler, createFocusReturn, createGuardedEffect, createRemoteContext, customElement, customShadowlessElement, disableBodyScroll, enableBodyScroll, ensureId, findDisclosureContent, findDisclosureControl, findOverlayPanel, formatValue, getContextFromProvider, getTemplateContent, invokeOnLoaded, isCustomElement, linkDisclosureControl, srOnly, toHyphenated };
@@ -1,17 +1,17 @@
1
- import { checkLoaded } from './checkLoaded.js';
2
-
1
+ import { checkLoaded } from "./checkLoaded.js";
2
+ //#region src/utils/invokeOnLoaded.ts
3
3
  function invokeOnLoaded(fn, { signal }) {
4
- if (checkLoaded()) {
5
- const id = setTimeout(() => fn());
6
- signal?.addEventListener("abort", () => clearTimeout(id), {
7
- once: true
8
- });
9
- return;
10
- }
11
- window.addEventListener("DOMContentLoaded", fn, { signal, once: true });
12
- return;
4
+ if (checkLoaded()) {
5
+ const id = setTimeout(() => fn());
6
+ signal?.addEventListener("abort", () => clearTimeout(id), { once: true });
7
+ return;
8
+ }
9
+ window.addEventListener("DOMContentLoaded", fn, {
10
+ signal,
11
+ once: true
12
+ });
13
13
  }
14
-
14
+ //#endregion
15
15
  export { invokeOnLoaded };
16
- //# sourceMappingURL=invokeOnLoaded.js.map
16
+
17
17
  //# sourceMappingURL=invokeOnLoaded.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/invokeOnLoaded.ts"],"names":[],"mappings":";;AAEO,SAAS,cACd,CAAA,EAAA,EACA,EAAE,MAAA,EACF,EAAA;AACA,EAAA,IAAI,aAAe,EAAA;AACjB,IAAA,MAAM,EAAK,GAAA,UAAA,CAAW,MAAM,EAAA,EAAI,CAAA;AAChC,IAAA,MAAA,EAAQ,gBAAiB,CAAA,OAAA,EAAS,MAAM,YAAA,CAAa,EAAE,CAAG,EAAA;AAAA,MACxD,IAAM,EAAA;AAAA,KACP,CAAA;AACD,IAAA;AAAA;AAEF,EAAA,MAAA,CAAO,iBAAiB,kBAAoB,EAAA,EAAA,EAAI,EAAE,MAAQ,EAAA,IAAA,EAAM,MAAM,CAAA;AACtE,EAAA;AACF","file":"invokeOnLoaded.js","sourcesContent":["import { checkLoaded } from \"./checkLoaded.js\";\n\nexport function invokeOnLoaded(\n fn: () => void,\n { signal }: { signal?: AbortSignal },\n) {\n if (checkLoaded()) {\n const id = setTimeout(() => fn());\n signal?.addEventListener(\"abort\", () => clearTimeout(id), {\n once: true,\n });\n return;\n }\n window.addEventListener(\"DOMContentLoaded\", fn, { signal, once: true });\n return;\n}\n"]}
1
+ {"version":3,"file":"invokeOnLoaded.js","names":[],"sources":["../../../src/utils/invokeOnLoaded.ts"],"sourcesContent":["import { checkLoaded } from \"./checkLoaded.js\";\n\nexport function invokeOnLoaded(\n\tfn: () => void,\n\t{ signal }: { signal?: AbortSignal },\n) {\n\tif (checkLoaded()) {\n\t\tconst id = setTimeout(() => fn());\n\t\tsignal?.addEventListener(\"abort\", () => clearTimeout(id), {\n\t\t\tonce: true,\n\t\t});\n\t\treturn;\n\t}\n\twindow.addEventListener(\"DOMContentLoaded\", fn, { signal, once: true });\n\treturn;\n}\n"],"mappings":";;AAEA,SAAgB,eACf,IACA,EAAE,UACD;CACD,IAAI,YAAY,GAAG;EAClB,MAAM,KAAK,iBAAiB,GAAG,CAAC;EAChC,QAAQ,iBAAiB,eAAe,aAAa,EAAE,GAAG,EACzD,MAAM,KACP,CAAC;EACD;CACD;CACA,OAAO,iBAAiB,oBAAoB,IAAI;EAAE;EAAQ,MAAM;CAAK,CAAC;AAEvE"}
@@ -1,7 +1,8 @@
1
+ //#region src/utils/isCustomElement.ts
1
2
  function isCustomElement(element) {
2
- return Reflect.has(element, "__initialized");
3
+ return Reflect.has(element, "__initialized");
3
4
  }
4
-
5
+ //#endregion
5
6
  export { isCustomElement };
6
- //# sourceMappingURL=isCustomElement.js.map
7
+
7
8
  //# sourceMappingURL=isCustomElement.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/isCustomElement.ts"],"names":[],"mappings":"AACO,SAAS,gBACd,OACyC,EAAA;AACzC,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,OAAA,EAAS,eAAe,CAAA;AAC7C","file":"isCustomElement.js","sourcesContent":["import type { ICustomElement } from \"component-register\";\nexport function isCustomElement(\n element: any,\n): element is ICustomElement & HTMLElement {\n return Reflect.has(element, \"__initialized\");\n}\n"]}
1
+ {"version":3,"file":"isCustomElement.js","names":[],"sources":["../../../src/utils/isCustomElement.ts"],"sourcesContent":["import type { ICustomElement } from \"component-register\";\nexport function isCustomElement(\n\telement: any,\n): element is ICustomElement & HTMLElement {\n\treturn Reflect.has(element, \"__initialized\");\n}\n"],"mappings":";AACA,SAAgB,gBACf,SAC0C;CAC1C,OAAO,QAAQ,IAAI,SAAS,eAAe;AAC5C"}
@@ -0,0 +1,36 @@
1
+ //#region src/utils/nested-overlays.ts
2
+ /**
3
+ * Closing an overlay has to close the overlays inside it.
4
+ *
5
+ * A dialog nested in another is hidden along with its parent, but
6
+ * nothing changes its own `isOpen`. It keeps reporting `is-open="true"` while
7
+ * invisible, never fires `drawer:close`, never releases what it holds, and
8
+ * reappears still open when the parent is opened again.
9
+ *
10
+ * These components have no concept of a parent — no containment check anywhere
11
+ * in either package — so the relationship is established here, at the point
12
+ * where it is needed, rather than threaded through context.
13
+ *
14
+ * Writing a *descendant's* attribute is allowed in Solid 2. Writing the
15
+ * component's own prop is what `REACTIVE_WRITE_IN_OWNED_SCOPE` forbids, which
16
+ * is why this takes the element rather than a setter.
17
+ */
18
+ /**
19
+ * Both kinds, not just the caller's own. A modal inside a drawer is hidden by
20
+ * the drawer closing exactly as another drawer would be, and is left in the
21
+ * same wrong state.
22
+ */
23
+ var OVERLAY_SELECTOR = "dialog-context, drawer-context, modal-context";
24
+ function closeNestedOverlays(root, selector = OVERLAY_SELECTOR) {
25
+ const closed = [];
26
+ for (const nested of Array.from(root.querySelectorAll(selector))) {
27
+ if (nested.getAttribute("is-open") !== "true") continue;
28
+ nested.setAttribute("is-open", "false");
29
+ closed.push(nested);
30
+ }
31
+ return closed;
32
+ }
33
+ //#endregion
34
+ export { OVERLAY_SELECTOR, closeNestedOverlays };
35
+
36
+ //# sourceMappingURL=nested-overlays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nested-overlays.js","names":[],"sources":["../../../src/utils/nested-overlays.ts"],"sourcesContent":["/**\n * Closing an overlay has to close the overlays inside it.\n *\n * A dialog nested in another is hidden along with its parent, but\n * nothing changes its own `isOpen`. It keeps reporting `is-open=\"true\"` while\n * invisible, never fires `drawer:close`, never releases what it holds, and\n * reappears still open when the parent is opened again.\n *\n * These components have no concept of a parent — no containment check anywhere\n * in either package — so the relationship is established here, at the point\n * where it is needed, rather than threaded through context.\n *\n * Writing a *descendant's* attribute is allowed in Solid 2. Writing the\n * component's own prop is what `REACTIVE_WRITE_IN_OWNED_SCOPE` forbids, which\n * is why this takes the element rather than a setter.\n */\n\n/**\n * Both kinds, not just the caller's own. A modal inside a drawer is hidden by\n * the drawer closing exactly as another drawer would be, and is left in the\n * same wrong state.\n */\nexport const OVERLAY_SELECTOR = \"dialog-context, drawer-context, modal-context\";\n\nexport function closeNestedOverlays(\n\troot: HTMLElement,\n\tselector: string = OVERLAY_SELECTOR,\n): HTMLElement[] {\n\tconst closed: HTMLElement[] = [];\n\n\tfor (const nested of Array.from(\n\t\troot.querySelectorAll<HTMLElement>(selector),\n\t)) {\n\t\t// Only the ones actually open: an unconditional write would churn the\n\t\t// attribute on every close and re-run each descendant's effects.\n\t\tif (nested.getAttribute(\"is-open\") !== \"true\") continue;\n\t\tnested.setAttribute(\"is-open\", \"false\");\n\t\tclosed.push(nested);\n\t}\n\n\treturn closed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,mBAAmB;AAEhC,SAAgB,oBACf,MACA,WAAmB,kBACH;CAChB,MAAM,SAAwB,CAAC;CAE/B,KAAK,MAAM,UAAU,MAAM,KAC1B,KAAK,iBAA8B,QAAQ,CAC5C,GAAG;EAGF,IAAI,OAAO,aAAa,SAAS,MAAM,QAAQ;EAC/C,OAAO,aAAa,WAAW,OAAO;EACtC,OAAO,KAAK,MAAM;CACnB;CAEA,OAAO;AACR"}
@@ -1,93 +1,53 @@
1
- import { compose, register, noShadowDOM } from 'component-register';
2
- import { onCleanup, createRoot, createSignal } from 'solid-js';
3
- import { insert } from 'solid-js/web';
4
-
5
- function createProps(raw) {
6
- const keys = Object.keys(raw);
7
- const props = {};
8
- for (let i = 0; i < keys.length; i++) {
9
- const key = keys[i];
10
- if (typeof key === "undefined") continue;
11
- const [get, set] = createSignal(Reflect.get(raw, key));
12
- Object.defineProperty(props, key, {
13
- get,
14
- set(v) {
15
- set(() => v);
16
- }
17
- });
18
- }
19
- return props;
20
- }
21
- function lookupContext(el) {
22
- if (el.assignedSlot && el.assignedSlot._$owner)
23
- return el.assignedSlot._$owner;
24
- let next = el.parentNode;
25
- while (next && !next._$owner && !(next.assignedSlot && next.assignedSlot._$owner))
26
- next = next.parentNode;
27
- return next && next.assignedSlot ? next.assignedSlot._$owner : el._$owner;
28
- }
29
- function withSolid(ComponentType) {
30
- return (rawProps, options) => {
31
- const { element } = options;
32
- return createRoot((dispose) => {
33
- const props = createProps(rawProps);
34
- element.addPropertyChangedCallback(
35
- (key, val) => props[key] = val
36
- );
37
- element.addReleaseCallback(() => {
38
- element.renderRoot.textContent = "";
39
- dispose();
40
- });
41
- const comp = ComponentType(props, options);
42
- return insert(element.renderRoot, comp);
43
- }, lookupContext(element));
44
- };
45
- }
46
- function withNoShadowDOM(Component = () => {
47
- }) {
48
- return (props, options) => {
49
- noShadowDOM();
50
- const comp = Component(props, options);
51
- return comp;
52
- };
1
+ import { compose, noShadowDOM, register } from "component-register";
2
+ import { withSolid } from "@solidjs/element";
3
+ //#region src/utils/solid-element.ts
4
+ /**
5
+ * The custom-element layer, now a thin wrapper over upstream `@solidjs/element`.
6
+ *
7
+ * This file used to be a ~140-line fork of `solid-element`. Solid 2 makes most
8
+ * of it redundant, and upstream is now strictly better at the parts we forked
9
+ * for:
10
+ *
11
+ * - **Owner adoption across the DOM.** The fork carried its own
12
+ * `lookupContext` walking `_$owner` up the tree. Upstream v2 does the same
13
+ * walk, but adopts via `runWithOwner` (v2's `createRoot` dropped the owner
14
+ * argument the fork relied on) *and* guards the case where the owner was
15
+ * stamped by a second copy of the Solid runtime on the page — it warns and
16
+ * renders ownerless instead of leaving the render root empty. The fork had
17
+ * no such guard.
18
+ * - **Event delegation.** Upstream registers and unregisters the render root
19
+ * with `registerDelegatedRoot`, so delegated handlers fire inside it. The
20
+ * fork never did, which means delegated events in shadowless elements were
21
+ * already subtly wrong.
22
+ * - **Constructable components.** `compose` already routes them through
23
+ * `new`; the fork's own `isConstructable` probe was redundant.
24
+ * - **`bryt-designs:element-destroyed`.** Deleted. It existed so a *remote*
25
+ * consumer could learn its provider went away, and `component-register`'s
26
+ * `addReleaseCallback` is that hook exactly — it fires whether or not
27
+ * anything is listening. See `createRemoteContext`.
28
+ *
29
+ * What stays ours is `withNoShadowDOM` and the `element` narrowing.
30
+ */
31
+ function withNoShadowDOM(Component) {
32
+ return (props, options) => {
33
+ noShadowDOM();
34
+ return Component(props, options);
35
+ };
53
36
  }
54
- function customElement(tagName, props, Component = () => {
55
- }, ...rest) {
56
- return compose(register(tagName, props), withSolid, ...rest)(Component);
37
+ function customElement(tagName, props, Component, ...rest) {
38
+ return compose(register(tagName, props), withSolid, ...rest)(Component);
57
39
  }
58
- function isConstructable(fn) {
59
- if (typeof fn !== "function") return false;
60
- try {
61
- Reflect.construct(String, [], fn);
62
- return true;
63
- } catch {
64
- return false;
65
- }
40
+ function customShadowlessElement(tagName, props, Component, ...rest) {
41
+ return compose(register(tagName, props), withNoShadowDOM, withSolid, ...rest)(Component);
66
42
  }
67
- function customShadowlessElement(tagName, props, Component = () => {
68
- }, ...rest) {
69
- return compose(
70
- register(tagName, props),
71
- withNoShadowDOM,
72
- withSolid,
73
- ...rest
74
- )((...args) => {
75
- onCleanup(() => {
76
- const [_, { element }] = args;
77
- element.dispatchEvent(new CustomEvent("bryt-designs:element-destroyed"));
78
- });
79
- if (isConstructable(Component)) {
80
- return new Component(...args);
81
- }
82
- return Component(...args);
83
- });
84
- }
85
- const correctElementType = (component) => {
86
- return (props, options) => {
87
- return component(props, options);
88
- };
89
- };
90
-
43
+ /**
44
+ * @deprecated The narrowing is built into `customElement` and
45
+ * `customShadowlessElement` now, so this is a type-level identity. It is kept
46
+ * only so packages still on Solid 1 keep compiling during the migration;
47
+ * delete the call rather than porting it.
48
+ */
49
+ var correctElementType = (component) => component;
50
+ //#endregion
91
51
  export { correctElementType, customElement, customShadowlessElement };
92
- //# sourceMappingURL=solid-element.js.map
52
+
93
53
  //# sourceMappingURL=solid-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/solid-element.ts"],"names":[],"mappings":"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","file":"solid-element.js","sourcesContent":["import {\n register,\n type ComponentType as mComponentType,\n type ICustomElement,\n type FunctionComponent,\n type ComponentOptions,\n noShadowDOM,\n compose,\n} from \"component-register\";\nimport { createRoot, createSignal, onCleanup } from \"solid-js\";\nimport { insert } from \"solid-js/web\";\n\nexport type ComponentType<T> = mComponentType<T>;\n\ntype CorrectComponentOptions = { element: HTMLElement & ICustomElement };\n\nexport type CorrectComponentType<T> = (\n props: T,\n options: CorrectComponentOptions,\n) => unknown;\n\nfunction createProps<T extends object>(raw: T) {\n const keys = Object.keys(raw) as (keyof T)[];\n const props = {};\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (typeof key === \"undefined\") continue;\n const [get, set] = createSignal(Reflect.get(raw, key));\n Object.defineProperty(props, key, {\n get,\n set(v) {\n set(() => v);\n },\n });\n }\n return props as T;\n}\n\nfunction lookupContext(el: ICustomElement & { _$owner?: any }) {\n if (el.assignedSlot && el.assignedSlot._$owner)\n return el.assignedSlot._$owner;\n let next: Element & { _$owner?: any } = el.parentNode;\n while (\n next &&\n !next._$owner &&\n !(\n next.assignedSlot &&\n (next.assignedSlot as Element & { _$owner?: any })._$owner\n )\n )\n next = next.parentNode as Element;\n return next && next.assignedSlot\n ? (next.assignedSlot as Element & { _$owner?: any })._$owner\n : el._$owner;\n}\n\nfunction withSolid<T extends object>(\n ComponentType: ComponentType<T>,\n): ComponentType<T> {\n return (rawProps: T, options: ComponentOptions) => {\n const { element } = options as {\n element: ICustomElement & { _$owner?: any };\n };\n return createRoot((dispose: Function) => {\n const props = createProps<T>(rawProps);\n\n element.addPropertyChangedCallback(\n (key: string, val: any) => (props[key as keyof T] = val),\n );\n element.addReleaseCallback(() => {\n element.renderRoot.textContent = \"\";\n dispose();\n });\n\n const comp = (ComponentType as FunctionComponent<T>)(props as T, options);\n return insert(element.renderRoot, comp);\n }, lookupContext(element));\n };\n}\n\nfunction withNoShadowDOM<T extends object>(\n Component: ComponentType<T> = () => {},\n) {\n return (props: T, options: ComponentOptions) => {\n noShadowDOM();\n const comp = (Component as FunctionComponent<T>)(props, options);\n return comp;\n };\n}\n\nexport function customElement<T extends object>(\n tagName: string,\n props: T,\n Component: ComponentType<T> = () => {},\n ...rest: ((C: ComponentType<T>) => ComponentType<T>)[]\n) {\n return compose(register(tagName, props), withSolid, ...rest)(Component);\n}\n\nfunction isConstructable(fn: unknown): fn is new (...args: any[]) => any {\n if (typeof fn !== \"function\") return false;\n\n try {\n Reflect.construct(String, [], fn as Function);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function customShadowlessElement<T extends object>(\n tagName: string,\n props: T,\n Component: ComponentType<T> = () => {},\n ...rest: ((C: ComponentType<T>) => ComponentType<T>)[]\n) {\n return compose(\n register(tagName, props),\n withNoShadowDOM,\n withSolid,\n ...rest,\n )((...args) => {\n onCleanup(() => {\n const [_, { element }] = args;\n element.dispatchEvent(new CustomEvent(\"bryt-designs:element-destroyed\"));\n });\n if (isConstructable(Component)) {\n return new Component(...args);\n }\n return Component(...args);\n });\n}\n\nexport const correctElementType = <T>(\n component: CorrectComponentType<T>,\n): ComponentType<T> => {\n return (props: T, options) => {\n return component(props, options as CorrectComponentOptions);\n };\n};\n"]}
1
+ {"version":3,"file":"solid-element.js","names":[],"sources":["../../../src/utils/solid-element.ts"],"sourcesContent":["/**\n * The custom-element layer, now a thin wrapper over upstream `@solidjs/element`.\n *\n * This file used to be a ~140-line fork of `solid-element`. Solid 2 makes most\n * of it redundant, and upstream is now strictly better at the parts we forked\n * for:\n *\n * - **Owner adoption across the DOM.** The fork carried its own\n * `lookupContext` walking `_$owner` up the tree. Upstream v2 does the same\n * walk, but adopts via `runWithOwner` (v2's `createRoot` dropped the owner\n * argument the fork relied on) *and* guards the case where the owner was\n * stamped by a second copy of the Solid runtime on the page — it warns and\n * renders ownerless instead of leaving the render root empty. The fork had\n * no such guard.\n * - **Event delegation.** Upstream registers and unregisters the render root\n * with `registerDelegatedRoot`, so delegated handlers fire inside it. The\n * fork never did, which means delegated events in shadowless elements were\n * already subtly wrong.\n * - **Constructable components.** `compose` already routes them through\n * `new`; the fork's own `isConstructable` probe was redundant.\n * - **`bryt-designs:element-destroyed`.** Deleted. It existed so a *remote*\n * consumer could learn its provider went away, and `component-register`'s\n * `addReleaseCallback` is that hook exactly — it fires whether or not\n * anything is listening. See `createRemoteContext`.\n *\n * What stays ours is `withNoShadowDOM` and the `element` narrowing.\n */\nimport { withSolid } from \"@solidjs/element\";\nimport {\n\ttype ComponentType as ComponentRegisterComponentType,\n\tcompose,\n\ttype ICustomElement,\n\tnoShadowDOM,\n\tregister,\n} from \"component-register\";\n\nexport type ComponentType<T> = ComponentRegisterComponentType<T>;\n\n/**\n * `component-register` types `options.element` as a bare `ICustomElement`, but\n * at runtime it is always also an `HTMLElement`. Every component in this repo\n * needs the DOM half.\n */\nexport type CorrectComponentOptions = { element: HTMLElement & ICustomElement };\n\nexport type CorrectComponentType<T> = (\n\tprops: T,\n\toptions: CorrectComponentOptions,\n) => unknown;\n\ntype Middleware<T> = (Component: ComponentType<T>) => ComponentType<T>;\n\nfunction withNoShadowDOM<T>(Component: ComponentType<T>): ComponentType<T> {\n\treturn (props, options) => {\n\t\tnoShadowDOM();\n\t\treturn (Component as (p: T, o: typeof options) => unknown)(props, options);\n\t};\n}\n\nexport function customElement<T extends object>(\n\ttagName: string,\n\tprops: T,\n\tComponent: CorrectComponentType<T>,\n\t...rest: Middleware<T>[]\n) {\n\treturn compose(\n\t\tregister(tagName, props),\n\t\twithSolid,\n\t\t...rest,\n\t)(Component as ComponentType<T>);\n}\n\nexport function customShadowlessElement<T extends object>(\n\ttagName: string,\n\tprops: T,\n\tComponent: CorrectComponentType<T>,\n\t...rest: Middleware<T>[]\n) {\n\treturn compose(\n\t\tregister(tagName, props),\n\t\twithNoShadowDOM,\n\t\twithSolid,\n\t\t...rest,\n\t)(Component as ComponentType<T>);\n}\n\n/**\n * @deprecated The narrowing is built into `customElement` and\n * `customShadowlessElement` now, so this is a type-level identity. It is kept\n * only so packages still on Solid 1 keep compiling during the migration;\n * delete the call rather than porting it.\n */\nexport const correctElementType = <T>(\n\tcomponent: CorrectComponentType<T>,\n): CorrectComponentType<T> => component;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAS,gBAAmB,WAA+C;CAC1E,QAAQ,OAAO,YAAY;EAC1B,YAAY;EACZ,OAAQ,UAAmD,OAAO,OAAO;CAC1E;AACD;AAEA,SAAgB,cACf,SACA,OACA,WACA,GAAG,MACF;CACD,OAAO,QACN,SAAS,SAAS,KAAK,GACvB,WACA,GAAG,IACJ,CAAC,CAAC,SAA6B;AAChC;AAEA,SAAgB,wBACf,SACA,OACA,WACA,GAAG,MACF;CACD,OAAO,QACN,SAAS,SAAS,KAAK,GACvB,iBACA,WACA,GAAG,IACJ,CAAC,CAAC,SAA6B;AAChC;;;;;;;AAQA,IAAa,sBACZ,cAC6B"}
@@ -1,7 +1,8 @@
1
+ //#region src/utils/toHyphenated.ts
1
2
  function toHyphenated(str) {
2
- return str.replace(/([A-Z])/g, "-$1").toLowerCase();
3
+ return str.replace(/([A-Z])/g, "-$1").toLowerCase();
3
4
  }
4
-
5
+ //#endregion
5
6
  export { toHyphenated };
6
- //# sourceMappingURL=toHyphenated.js.map
7
+
7
8
  //# sourceMappingURL=toHyphenated.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/toHyphenated.ts"],"names":[],"mappings":"AAAO,SAAS,aAAa,GAAqB,EAAA;AAChD,EAAA,OAAO,GACJ,CAAA,OAAA,CAAQ,UAAY,EAAA,KAAK,EACzB,WAAY,EAAA;AACjB","file":"toHyphenated.js","sourcesContent":["export function toHyphenated(str: string): string {\n return str\n .replace(/([A-Z])/g, \"-$1\") // Insert hyphen before uppercase letters\n .toLowerCase(); // Convert the entire string to lowercase\n}\n"]}
1
+ {"version":3,"file":"toHyphenated.js","names":[],"sources":["../../../src/utils/toHyphenated.ts"],"sourcesContent":["export function toHyphenated(str: string): string {\n\treturn str\n\t\t.replace(/([A-Z])/g, \"-$1\") // Insert hyphen before uppercase letters\n\t\t.toLowerCase(); // Convert the entire string to lowercase\n}\n"],"mappings":";AAAA,SAAgB,aAAa,KAAqB;CACjD,OAAO,IACL,QAAQ,YAAY,KAAK,CAAC,CAC1B,YAAY;AACf"}