gg-wf-scripts 4.1.0 → 5.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.
- package/LICENSE +21 -0
- package/README.md +10 -437
- package/dist/attrs.d.ts +2 -0
- package/dist/attrs.js +2 -0
- package/dist/attrs.js.map +1 -1
- package/dist/auth-engine.d.ts +6 -0
- package/dist/auth-engine.js +53 -0
- package/dist/auth-engine.js.map +1 -0
- package/dist/bridges.js +22 -7
- package/dist/bridges.js.map +1 -1
- package/dist/data-engine.js +19 -4
- package/dist/data-engine.js.map +1 -1
- package/dist/helpers/dom.d.ts +3 -0
- package/dist/helpers/dom.js +19 -3
- package/dist/helpers/dom.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Garrett Cannon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,446 +5,19 @@ A declarative attribute engine for Webflow sites. Add `gg-*` attributes to your
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
npm install gg-scripts
|
|
8
|
+
npm install gg-wf-scripts
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Documentation
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Full docs, guides, and API reference live at **[garrettcannon.dev/gg-wf-scripts](https://garrettcannon.dev/gg-wf-scripts/)**.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
- [Getting started](https://garrettcannon.dev/gg-wf-scripts/guide/getting-started)
|
|
16
|
+
- [Quick reference](https://garrettcannon.dev/gg-wf-scripts/quick-reference)
|
|
17
|
+
- [Attributes](https://garrettcannon.dev/gg-wf-scripts/attributes/data)
|
|
18
|
+
- [API](https://garrettcannon.dev/gg-wf-scripts/api/init)
|
|
19
|
+
- For LLMs: [llms.txt](https://garrettcannon.dev/gg-wf-scripts/llms.txt) · [llms-full.txt](https://garrettcannon.dev/gg-wf-scripts/llms-full.txt)
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
## License
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
context: { sb },
|
|
23
|
-
auth: {
|
|
24
|
-
getUser: async () => (await sb.auth.getUser()).data.user?.id ?? null,
|
|
25
|
-
onChange: (cb) => sb.auth.onAuthStateChange((_e, session) => cb(session?.user?.id ?? null)),
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
app.addQuery("posts_list", async ({ sb }, params) => {
|
|
30
|
-
const q = params.get("q") ?? "";
|
|
31
|
-
const { data } = await sb
|
|
32
|
-
.from("posts")
|
|
33
|
-
.select("*")
|
|
34
|
-
.ilike("title", `%${q}%`)
|
|
35
|
-
.order("created_at", { ascending: false });
|
|
36
|
-
return data ?? [];
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
app.addAction("delete_post", async ({ sb }, { id }) => {
|
|
40
|
-
const { error } = await sb.from("posts").delete().eq("id", id);
|
|
41
|
-
return error ? { ok: false, error } : { ok: true };
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
app.start();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Bundle with esbuild:
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
npx esbuild src/index.js --bundle --outfile=dist/site.js --format=iife --target=es2020 --platform=browser
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Load on your site:
|
|
54
|
-
|
|
55
|
-
```html
|
|
56
|
-
<script src="https://your-cdn.com/site.js"></script>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Attributes
|
|
60
|
-
|
|
61
|
-
### Data binding
|
|
62
|
-
|
|
63
|
-
Display data from your queries in the DOM.
|
|
64
|
-
|
|
65
|
-
```html
|
|
66
|
-
<!-- Single record: populates [gg-field] descendants -->
|
|
67
|
-
<div gg-data="post_by_id">
|
|
68
|
-
<h1 gg-field="title">Loading...</h1>
|
|
69
|
-
<p gg-field="body"></p>
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<!-- Form pre-fill: sets value/checked on named inputs -->
|
|
73
|
-
<form gg-data-form="post_by_id">
|
|
74
|
-
<input name="title" />
|
|
75
|
-
<textarea name="body"></textarea>
|
|
76
|
-
</form>
|
|
77
|
-
|
|
78
|
-
<!-- List: clones the template for each record -->
|
|
79
|
-
<ul gg-data-list="posts_list">
|
|
80
|
-
<li gg-list-template>
|
|
81
|
-
<h3 gg-field="title"></h3>
|
|
82
|
-
<span gg-field="author.name"></span>
|
|
83
|
-
</li>
|
|
84
|
-
</ul>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
`gg-field` supports dot-paths for nested data (e.g. `author.name`).
|
|
88
|
-
|
|
89
|
-
#### Passing data to web components / React
|
|
90
|
-
|
|
91
|
-
For elements that manage their own DOM (custom elements wrapping React, Lit, etc.), pull the record from the container's `__ggRecord` property after each query run. Every `gg-data`, `gg-data-form`, and cloned `gg-data-list` row exposes the record this way, and the engine dispatches a `gg-data-ready` CustomEvent on the same element with `detail.record` once it's set.
|
|
92
|
-
|
|
93
|
-
```html
|
|
94
|
-
<form gg-data-form="post_form">
|
|
95
|
-
<input name="title" />
|
|
96
|
-
<my-select name="school_id"></my-select>
|
|
97
|
-
</form>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
// Inside <my-select> — read the parent record once it's ready.
|
|
102
|
-
const form = host.closest("form");
|
|
103
|
-
form.addEventListener("gg-data-ready", (e) => {
|
|
104
|
-
const record = e.detail.record;
|
|
105
|
-
// hydrate from record[host.getAttribute("name")] or whatever path makes sense
|
|
106
|
-
});
|
|
107
|
-
// Already populated? Read it directly:
|
|
108
|
-
if (form.__ggRecord) hydrate(form.__ggRecord);
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
The event bubbles, so each form/container's events are scoped to that subtree — listeners attached to one form never fire for another. From inside a shadow root, walk out via `getRootNode().host` before calling `closest("form")`.
|
|
112
|
-
|
|
113
|
-
#### Calling queries / actions from custom code
|
|
114
|
-
|
|
115
|
-
`init()` sets `window.ggApp` by default and dispatches a `gg-app-ready` CustomEvent on `document` (with `detail.app`). Components can call any registered handler imperatively — useful for typeahead/combobox patterns that don't fit the declarative `gg-data*` model:
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
const app = window.ggApp; // or await `gg-app-ready`
|
|
119
|
-
const results = await app.queries.search_schools(
|
|
120
|
-
app.context,
|
|
121
|
-
new URLSearchParams({ q: "acme" }),
|
|
122
|
-
);
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Set `expose: false` on `init()` if you'd rather wire the reference yourself.
|
|
126
|
-
|
|
127
|
-
#### Re-running on URL changes
|
|
128
|
-
|
|
129
|
-
Add `gg-data-on` to re-run a query when specific URL params change:
|
|
130
|
-
|
|
131
|
-
```html
|
|
132
|
-
<div gg-data="post_by_id" gg-data-on="id">
|
|
133
|
-
<h1 gg-field="title"></h1>
|
|
134
|
-
</div>
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### URL query params
|
|
138
|
-
|
|
139
|
-
Read and write URL query params declaratively.
|
|
140
|
-
|
|
141
|
-
```html
|
|
142
|
-
<!-- On click, set ?modal=view&id=42 -->
|
|
143
|
-
<button gg-query-set="modal:view,id:42">Open</button>
|
|
144
|
-
|
|
145
|
-
<!-- On click, remove ?modal and ?id -->
|
|
146
|
-
<button gg-query-remove="modal,id">Close</button>
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
#### Two-way input binding
|
|
150
|
-
|
|
151
|
-
Mirror an input's value into a URL param as the user types. Empty value removes the param. The input is also populated from the URL on load and back/forward navigation.
|
|
152
|
-
|
|
153
|
-
```html
|
|
154
|
-
<!-- Bind to ?q=... with a 300ms debounce -->
|
|
155
|
-
<input gg-query-bind="q" gg-query-debounce="300" placeholder="Search..." />
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Combine with `gg-data-on` to re-run a query as the user types:
|
|
159
|
-
|
|
160
|
-
```html
|
|
161
|
-
<input gg-query-bind="q" gg-query-debounce="300" />
|
|
162
|
-
|
|
163
|
-
<ul gg-data-list="search_posts" gg-data-on="q">
|
|
164
|
-
<li gg-list-template><span gg-field="title"></span></li>
|
|
165
|
-
</ul>
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Content switcher
|
|
169
|
-
|
|
170
|
-
Show/hide children based on a state value.
|
|
171
|
-
|
|
172
|
-
```html
|
|
173
|
-
<!-- State driven by URL param ?view=... -->
|
|
174
|
-
<div gg-switch-query="view">
|
|
175
|
-
<section gg-case="">Pick a view</section>
|
|
176
|
-
<section gg-case="list">List view</section>
|
|
177
|
-
<section gg-case="grid">Grid view</section>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<!-- State driven by a field on the nearest gg-data record -->
|
|
181
|
-
<span gg-switch-field="status">
|
|
182
|
-
<span gg-case="published">Published</span>
|
|
183
|
-
<span gg-case="draft">Draft</span>
|
|
184
|
-
<span gg-case="">Unknown</span>
|
|
185
|
-
</span>
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
`gg-case=""` acts as the default/empty state.
|
|
189
|
-
|
|
190
|
-
### Dialog
|
|
191
|
-
|
|
192
|
-
A single `<dialog>` element is managed automatically via the `modal` URL param.
|
|
193
|
-
|
|
194
|
-
```html
|
|
195
|
-
<div gg-query-set="modal:confirm,id:42">Delete</div>
|
|
196
|
-
|
|
197
|
-
<dialog>
|
|
198
|
-
<p>Are you sure?</p>
|
|
199
|
-
<button gg-query-remove="modal,id">Cancel</button>
|
|
200
|
-
</dialog>
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Setting `?modal=...` opens the dialog. Removing it (or pressing Escape, or clicking the backdrop) closes it. Back button navigation is handled automatically.
|
|
204
|
-
|
|
205
|
-
### Auth and role gating
|
|
206
|
-
|
|
207
|
-
Show or hide elements based on auth state. You provide the auth adapter, so any backend works.
|
|
208
|
-
|
|
209
|
-
```html
|
|
210
|
-
<a href="/login" gg-auth="false">Log in</a>
|
|
211
|
-
<a href="/account" gg-auth="true">My account</a>
|
|
212
|
-
<a href="/admin" gg-role="superuser">Admin panel</a>
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
`gg-auth` is set on `<body>` as `"true"` or `"false"`. `gg-role` is set if you provide a `roleQuery` (see [Auth config](#auth-config)).
|
|
216
|
-
|
|
217
|
-
### Form actions
|
|
218
|
-
|
|
219
|
-
Override a form's submit to run a registered handler instead of the browser default. The handler receives the form's `FormData` directly.
|
|
220
|
-
|
|
221
|
-
```html
|
|
222
|
-
<form gg-form-action="create_post">
|
|
223
|
-
<input name="title" required />
|
|
224
|
-
<textarea name="body"></textarea>
|
|
225
|
-
<button type="submit">Save</button>
|
|
226
|
-
</form>
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
```js
|
|
230
|
-
app.addFormAction("create_post", async ({ sb }, formData) => {
|
|
231
|
-
const { error } = await sb.from("posts").insert({
|
|
232
|
-
title: formData.get("title"),
|
|
233
|
-
body: formData.get("body"),
|
|
234
|
-
});
|
|
235
|
-
return error ? { ok: false, error } : { ok: true };
|
|
236
|
-
});
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
The handler receives `(context, formData, params)`. `preventDefault` is called automatically — the form will not submit to its `action` URL. Return `{ ok: true }` or `{ ok: false, error }`.
|
|
240
|
-
|
|
241
|
-
#### Validation errors
|
|
242
|
-
|
|
243
|
-
Form actions can return validation errors and the engine will display them via attributes on your markup.
|
|
244
|
-
|
|
245
|
-
```js
|
|
246
|
-
app.addFormAction("create_post", async ({ sb }, formData) => {
|
|
247
|
-
const title = formData.get("title");
|
|
248
|
-
if (!title) {
|
|
249
|
-
return {
|
|
250
|
-
ok: false,
|
|
251
|
-
field_errors: [{ name: "title", message: "Title is required" }],
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
const { error } = await sb.from("posts").insert({ title });
|
|
255
|
-
return error
|
|
256
|
-
? { ok: false, error: "Could not save — please try again." }
|
|
257
|
-
: { ok: true };
|
|
258
|
-
});
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
Markup:
|
|
262
|
-
|
|
263
|
-
```html
|
|
264
|
-
<form gg-form-action="create_post">
|
|
265
|
-
<input name="title" />
|
|
266
|
-
<p gg-form-field-error="title"></p>
|
|
267
|
-
|
|
268
|
-
<textarea name="body"></textarea>
|
|
269
|
-
<p gg-form-field-error="body"></p>
|
|
270
|
-
|
|
271
|
-
<!-- Optional: list every field error in one place -->
|
|
272
|
-
<ul gg-form-error-list>
|
|
273
|
-
<li gg-list-template>
|
|
274
|
-
<strong gg-field="name"></strong>: <span gg-field="message"></span>
|
|
275
|
-
</li>
|
|
276
|
-
</ul>
|
|
277
|
-
|
|
278
|
-
<!-- Optional: form-level error (the result.error string) -->
|
|
279
|
-
<p gg-form-error></p>
|
|
280
|
-
|
|
281
|
-
<button type="submit">Save</button>
|
|
282
|
-
</form>
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
What the engine does:
|
|
286
|
-
- Sets `gg-form-field-invalid="true"` on each invalid input — target with CSS like `input[gg-form-field-invalid="true"] { border-color: red; }`.
|
|
287
|
-
- Sets the `textContent` of `[gg-form-field-error="<name>"]` elements to the matching message.
|
|
288
|
-
- Populates `[gg-form-error-list]` using the same template pattern as `gg-data-list` (clones `[gg-list-template]`, applies `gg-field` bindings).
|
|
289
|
-
- Sets the `textContent` of `[gg-form-error]` to the top-level `error` string.
|
|
290
|
-
- All errors are cleared at the start of each submit, and a field's invalid attr + message are cleared when the user types in that field.
|
|
291
|
-
|
|
292
|
-
### Form visibility
|
|
293
|
-
|
|
294
|
-
Conditionally show/hide elements based on form field values.
|
|
295
|
-
|
|
296
|
-
```html
|
|
297
|
-
<form>
|
|
298
|
-
<label><input type="radio" name="reason" value="scheduling" /> Scheduling</label>
|
|
299
|
-
<label><input type="radio" name="reason" value="other" /> Other</label>
|
|
300
|
-
|
|
301
|
-
<div gg-visible-when="reason:other">
|
|
302
|
-
<input type="text" name="other_reason" placeholder="Please specify" />
|
|
303
|
-
</div>
|
|
304
|
-
</form>
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Hidden elements get `display: none`, `inert`, and `aria-hidden="true"`. Transitions are a 200ms opacity fade. Use `gg-form-scope` on a non-`<form>` ancestor when `closest("form")` can't reach the inputs (e.g. shadow DOM).
|
|
308
|
-
|
|
309
|
-
### Actions
|
|
310
|
-
|
|
311
|
-
Run mutations on click. Actions receive the context object and a data object.
|
|
312
|
-
|
|
313
|
-
```html
|
|
314
|
-
<!-- Simple action, no data needed -->
|
|
315
|
-
<button gg-action="sign_out">Sign out</button>
|
|
316
|
-
|
|
317
|
-
<!-- Action with explicit data -->
|
|
318
|
-
<button gg-action="update_status" gg-action-data="status:archived">Archive</button>
|
|
319
|
-
|
|
320
|
-
<!-- Inside a data list, the action automatically receives the row's record -->
|
|
321
|
-
<ul gg-data-list="posts_list">
|
|
322
|
-
<li gg-list-template>
|
|
323
|
-
<h3 gg-field="title"></h3>
|
|
324
|
-
<button gg-action="delete_post">Delete</button>
|
|
325
|
-
</li>
|
|
326
|
-
</ul>
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
When an action is inside a `gg-data` or `gg-data-list` container, it automatically receives the record as its data. Explicit `gg-action-data` values are merged on top (and win on conflict).
|
|
330
|
-
|
|
331
|
-
Action functions should return `{ ok: true }` or `{ ok: false, error }`:
|
|
332
|
-
|
|
333
|
-
```js
|
|
334
|
-
app.addAction("delete_post", async ({ sb }, { id }) => {
|
|
335
|
-
const { error } = await sb.from("posts").delete().eq("id", id);
|
|
336
|
-
return error ? { ok: false, error } : { ok: true };
|
|
337
|
-
});
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Loading states
|
|
341
|
-
|
|
342
|
-
While an action, query, or form action is in flight, the engine sets `gg-loading="true"` on the relevant element so you can style spinners, skeletons, or disabled visuals purely in CSS.
|
|
343
|
-
|
|
344
|
-
| Trigger | Where `gg-loading` is set | Disabled? |
|
|
345
|
-
|---|---|---|
|
|
346
|
-
| `gg-action` | The trigger element itself | Native `disabled` is set if it's a `<button>` or `<input>` |
|
|
347
|
-
| `gg-data` / `gg-data-list` / `gg-data-form` | The container | n/a (not click-triggered) |
|
|
348
|
-
| `gg-form-action` | The `<form>` and every submit control inside it (`button[type="submit"]`, untyped `<button>`, `input[type="submit"]`) | Submit controls get native `disabled` |
|
|
349
|
-
|
|
350
|
-
Re-clicks on a loading `gg-action` and re-submits on a loading `gg-form-action` are ignored. The attribute is removed in a `finally` block, so it's cleared even if the handler throws.
|
|
351
|
-
|
|
352
|
-
Style with CSS:
|
|
353
|
-
|
|
354
|
-
```css
|
|
355
|
-
[gg-loading] { opacity: 0.6; pointer-events: none; }
|
|
356
|
-
[gg-loading]::after { content: " ⟳"; }
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Confirm prompts
|
|
360
|
-
|
|
361
|
-
Add `gg-confirm` to a `gg-action` trigger or `gg-form-action` form to require a `window.confirm` dialog before the handler runs. If the user cancels, the action is skipped (and form submission is prevented). Customize the prompt text with `gg-confirm-text`; if omitted it defaults to `"Are you sure?"`.
|
|
362
|
-
|
|
363
|
-
```html
|
|
364
|
-
<button gg-action="delete_post" gg-confirm gg-confirm-text="Delete this post?">
|
|
365
|
-
Delete
|
|
366
|
-
</button>
|
|
367
|
-
|
|
368
|
-
<form gg-form-action="wipe_account" gg-confirm gg-confirm-text="This cannot be undone. Continue?">
|
|
369
|
-
...
|
|
370
|
-
</form>
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
## Config
|
|
374
|
-
|
|
375
|
-
### `init(options)`
|
|
376
|
-
|
|
377
|
-
Returns an app instance with `addQuery`, `addAction`, and `start` methods.
|
|
378
|
-
|
|
379
|
-
| Option | Type | Required | Description |
|
|
380
|
-
|---|---|---|---|
|
|
381
|
-
| `context` | `object` | No | Arbitrary object passed to every query and action. Put backend clients or anything else your handlers need on it. Defaults to `{}`. |
|
|
382
|
-
| `auth` | `object` | No | Auth adapter (see below). If omitted, `gg-auth`/`gg-role` attrs are never set. |
|
|
383
|
-
| `debug` | `boolean` | No | When `true`, every query and action is logged to the console (trigger/container, data, result, duration). Defaults to `false`. |
|
|
384
|
-
| `expose` | `boolean` | No | When `true` (default), the App is set as `window.ggApp` and a `gg-app-ready` CustomEvent is dispatched on `document` so React/web-component islands can pick it up. Set to `false` for tests, multiple instances, or non-browser hosts. |
|
|
385
|
-
|
|
386
|
-
### Auth adapter
|
|
387
|
-
|
|
388
|
-
| Option | Type | Description |
|
|
389
|
-
|---|---|---|
|
|
390
|
-
| `auth.getUser` | `() => string \| null \| Promise<string \| null>` | Returns the current user id, or `null` when signed out. Called once on start. |
|
|
391
|
-
| `auth.onChange` | `(cb: (userId: string \| null) => void) => void` | Subscribe to auth changes. Optional but recommended — without it, `gg-auth` won't update on sign-in/out. |
|
|
392
|
-
| `auth.roleQuery` | `async (context, userId) => string \| null` | Returns the user's role string. Called on every auth change. If omitted, `gg-role` is never set. |
|
|
393
|
-
|
|
394
|
-
Example with Supabase:
|
|
395
|
-
|
|
396
|
-
```js
|
|
397
|
-
import { createClient } from "@supabase/supabase-js";
|
|
398
|
-
|
|
399
|
-
const sb = createClient("...", "...");
|
|
400
|
-
|
|
401
|
-
const app = init({
|
|
402
|
-
context: { sb },
|
|
403
|
-
auth: {
|
|
404
|
-
getUser: async () => (await sb.auth.getUser()).data.user?.id ?? null,
|
|
405
|
-
onChange: (cb) => sb.auth.onAuthStateChange((_e, session) => cb(session?.user?.id ?? null)),
|
|
406
|
-
roleQuery: async ({ sb }, userId) => {
|
|
407
|
-
const { data } = await sb
|
|
408
|
-
.from("user_roles")
|
|
409
|
-
.select("role")
|
|
410
|
-
.eq("user_id", userId)
|
|
411
|
-
.single();
|
|
412
|
-
return data?.role ?? null;
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
});
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### `app.addQuery(id, fn)`
|
|
419
|
-
|
|
420
|
-
Register a data query. `fn` receives `(context, params)` where `params` is a `URLSearchParams` snapshot of the current URL query string. Use `params.get("id")` for single values or `params.getAll("tag")` for multi-value params. Return:
|
|
421
|
-
- A single object (or `null`) for use with `gg-data` or `gg-data-form`
|
|
422
|
-
- An array for use with `gg-data-list`
|
|
423
|
-
|
|
424
|
-
### `app.addAction(id, fn)`
|
|
425
|
-
|
|
426
|
-
Register an action. `fn` receives `(context, data, params)` where `params` is a `URLSearchParams` snapshot of the current URL query string. Return `{ ok: true }` or `{ ok: false, error }`.
|
|
427
|
-
|
|
428
|
-
### `app.addFormAction(id, fn)`
|
|
429
|
-
|
|
430
|
-
Register a form action. `fn` receives `(context, formData, params)` where `formData` is a `FormData` snapshot of the submitted form. The default submit is prevented automatically. Return `{ ok: true }` or `{ ok: false, error }`.
|
|
431
|
-
|
|
432
|
-
### `app.start()`
|
|
433
|
-
|
|
434
|
-
Initializes all engines and starts listening for DOM events. Call this after registering all queries and actions.
|
|
435
|
-
|
|
436
|
-
## Exports
|
|
437
|
-
|
|
438
|
-
The library also exports utility functions for use in your queries and actions:
|
|
439
|
-
|
|
440
|
-
```js
|
|
441
|
-
import {
|
|
442
|
-
init,
|
|
443
|
-
getPath, // resolve dot-paths on objects
|
|
444
|
-
populateFields, // set [gg-field] descendants from a record
|
|
445
|
-
setSwitchState, // write gg-switch-state on an element
|
|
446
|
-
applySwitchState, // toggle [gg-case] children to match state
|
|
447
|
-
setQueryParams, // programmatically set URL params
|
|
448
|
-
removeQueryParams, // programmatically remove URL params
|
|
449
|
-
} from "gg-wf-scripts";
|
|
450
|
-
```
|
|
23
|
+
[MIT](./LICENSE) © Garrett Cannon
|
package/dist/attrs.d.ts
CHANGED
package/dist/attrs.js
CHANGED
package/dist/attrs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attrs.js","sourceRoot":"","sources":["../src/attrs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,UAAU;IACV,MAAM,EAAE,WAAW;IACnB,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAE5B,eAAe;IACf,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,UAAU;IACjB,YAAY,EAAE,kBAAkB;IAEhC,cAAc;IACd,cAAc,EAAE,qBAAqB;IACrC,gBAAgB,EAAE,uBAAuB;IACzC,SAAS,EAAE,eAAe;IAC1B,aA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IAAI,IAAI,CAAC,IAAI,GAAG;IACtB,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG;CACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toggle display:none on [gg-auth] and [gg-role] elements based on the
|
|
3
|
+
* matching attribute on <body> (set by initAuth). Comma-separated values on
|
|
4
|
+
* an element act as OR alternatives: gg-role="admin,editor".
|
|
5
|
+
*/
|
|
6
|
+
export declare function initAuthEngine(): () => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ATTR, SEL } from "./attrs.js";
|
|
2
|
+
import { onElement } from "./dom-observer.js";
|
|
3
|
+
function isMatch(elValue, bodyValue) {
|
|
4
|
+
return elValue
|
|
5
|
+
.split(",")
|
|
6
|
+
.map((v) => v.trim())
|
|
7
|
+
.includes(bodyValue);
|
|
8
|
+
}
|
|
9
|
+
function applyVisibility(el, attr) {
|
|
10
|
+
if (!(el instanceof HTMLElement))
|
|
11
|
+
return;
|
|
12
|
+
if (el === document.body)
|
|
13
|
+
return;
|
|
14
|
+
const elValue = el.getAttribute(attr);
|
|
15
|
+
if (elValue == null)
|
|
16
|
+
return;
|
|
17
|
+
const bodyValue = document.body.getAttribute(attr) ?? "";
|
|
18
|
+
el.style.display = isMatch(elValue, bodyValue) ? "" : "none";
|
|
19
|
+
}
|
|
20
|
+
function applyAll(attr) {
|
|
21
|
+
document
|
|
22
|
+
.querySelectorAll(`[${attr}]`)
|
|
23
|
+
.forEach((el) => applyVisibility(el, attr));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Toggle display:none on [gg-auth] and [gg-role] elements based on the
|
|
27
|
+
* matching attribute on <body> (set by initAuth). Comma-separated values on
|
|
28
|
+
* an element act as OR alternatives: gg-role="admin,editor".
|
|
29
|
+
*/
|
|
30
|
+
export function initAuthEngine() {
|
|
31
|
+
const observer = new MutationObserver((mutations) => {
|
|
32
|
+
for (const m of mutations) {
|
|
33
|
+
if (m.target !== document.body)
|
|
34
|
+
continue;
|
|
35
|
+
if (m.attributeName === ATTR.auth)
|
|
36
|
+
applyAll(ATTR.auth);
|
|
37
|
+
else if (m.attributeName === ATTR.role)
|
|
38
|
+
applyAll(ATTR.role);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
observer.observe(document.body, {
|
|
42
|
+
attributes: true,
|
|
43
|
+
attributeFilter: [ATTR.auth, ATTR.role],
|
|
44
|
+
});
|
|
45
|
+
const unbindAuth = onElement(SEL.auth, (el) => applyVisibility(el, ATTR.auth));
|
|
46
|
+
const unbindRole = onElement(SEL.role, (el) => applyVisibility(el, ATTR.role));
|
|
47
|
+
return () => {
|
|
48
|
+
observer.disconnect();
|
|
49
|
+
unbindAuth();
|
|
50
|
+
unbindRole();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=auth-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-engine.js","sourceRoot":"","sources":["../src/auth-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,SAAS,OAAO,CAAC,OAAe,EAAE,SAAiB;IACjD,OAAO,OAAO;SACX,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,QAAQ,CAAC,SAAS,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,eAAe,CAAC,EAAW,EAAE,IAAY;IAChD,IAAI,CAAC,CAAC,EAAE,YAAY,WAAW,CAAC;QAAE,OAAO;IACzC,IAAI,EAAE,KAAK,QAAQ,CAAC,IAAI;QAAE,OAAO;IACjC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,IAAI,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AAC,CAC/B,CAAC;IACF,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAC5C,eAAe,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAC/B,CAAC;IAEF,OAAO,GAAG,EAAE;QACV,QAAQ,CAAC,UAAU,EAAE,CAAC;QACtB,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/bridges.js
CHANGED
|
@@ -2,21 +2,36 @@ import { ATTR, SEL } from "./attrs.js";
|
|
|
2
2
|
import { setSwitchState } from "./helpers/dom.js";
|
|
3
3
|
import { onQueryChanged } from "./query-params.js";
|
|
4
4
|
import { onElement } from "./dom-observer.js";
|
|
5
|
+
function parseKeys(attr) {
|
|
6
|
+
return (attr ?? "")
|
|
7
|
+
.split(",")
|
|
8
|
+
.map((k) => k.trim())
|
|
9
|
+
.filter(Boolean);
|
|
10
|
+
}
|
|
11
|
+
function joinParamValues(keys, params) {
|
|
12
|
+
return keys.map((k) => params.get(k) ?? "").join(",");
|
|
13
|
+
}
|
|
5
14
|
export function initBridges() {
|
|
6
15
|
// ---- gg-switch-query: URL params → gg-switch-state ----
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
// Multi-key form: gg-switch-query="sortBy,sortDir" reads both params and
|
|
17
|
+
// joins them positionally into the state (matched by gg-case="date,asc").
|
|
18
|
+
const unsubscribeQuery = onQueryChanged((key) => {
|
|
19
|
+
const params = new URLSearchParams(window.location.search);
|
|
20
|
+
document.querySelectorAll(SEL.switchQuery).forEach((el) => {
|
|
21
|
+
const keys = parseKeys(el.getAttribute(ATTR.switchQuery));
|
|
22
|
+
if (!keys.includes(key))
|
|
23
|
+
return;
|
|
24
|
+
setSwitchState(el, joinParamValues(keys, params));
|
|
25
|
+
});
|
|
11
26
|
});
|
|
12
27
|
// Apply current URL state to every [gg-switch-query] element on the page,
|
|
13
28
|
// including any inserted later via Webflow IX or CMS templates.
|
|
14
29
|
const unbindSwitch = onElement(SEL.switchQuery, (el) => {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
30
|
+
const keys = parseKeys(el.getAttribute(ATTR.switchQuery));
|
|
31
|
+
if (!keys.length)
|
|
17
32
|
return;
|
|
18
33
|
const params = new URLSearchParams(window.location.search);
|
|
19
|
-
setSwitchState(el, params
|
|
34
|
+
setSwitchState(el, joinParamValues(keys, params));
|
|
20
35
|
});
|
|
21
36
|
// ---- webflow:emit → Webflow IX ----
|
|
22
37
|
let wfHandler = null;
|
package/dist/bridges.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridges.js","sourceRoot":"","sources":["../src/bridges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,UAAU,WAAW;IACzB,0DAA0D;IAC1D,MAAM,gBAAgB,GAAG,cAAc,CAAC,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"bridges.js","sourceRoot":"","sources":["../src/bridges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,SAAS,SAAS,CAAC,IAAmB;IACpC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;SAChB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,E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AAQ,CAAC,MAAM,CAAC,CAAC;QAC3D,cAAc,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,sCAAsC;IACtC,IAAI,SAAS,GAAgC,IAAI,CAAC;IAClD,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpC,SAAS,GAAG,CAAC,CAAQ,EAAE,EAAE;gBACvB,MAAM,MAAM,GAAI,CAAoC,CAAC,MAAM,CAAC;gBAC5D,IAAI,MAAM,EAAE,KAAK;oBAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC,CAAC;YACF,QAAQ,CAAC,gBAAgB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC,OAAO,GAAG,EAAE;QACV,gBAAgB,EAAE,CAAC;QACnB,YAAY,EAAE,CAAC;QACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,IAAI,SAAS;YAAE,QAAQ,CAAC,mBAAmB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/data-engine.js
CHANGED
|
@@ -8,10 +8,23 @@ import { onElement } from "./dom-observer.js";
|
|
|
8
8
|
import { onQueryChanged, getParams } from "./query-params.js";
|
|
9
9
|
function applySwitchFields(root, record) {
|
|
10
10
|
root.querySelectorAll(SEL.switchField).forEach((el) => {
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
11
|
+
const attr = el.getAttribute(ATTR.switchField);
|
|
12
|
+
if (!attr)
|
|
13
13
|
return;
|
|
14
|
-
const
|
|
14
|
+
const paths = attr
|
|
15
|
+
.split(",")
|
|
16
|
+
.map((p) => p.trim())
|
|
17
|
+
.filter(Boolean);
|
|
18
|
+
if (!paths.length)
|
|
19
|
+
return;
|
|
20
|
+
const value = paths.length === 1
|
|
21
|
+
? getPath(record, paths[0])
|
|
22
|
+
: paths
|
|
23
|
+
.map((p) => {
|
|
24
|
+
const v = getPath(record, p);
|
|
25
|
+
return v == null ? "" : String(v);
|
|
26
|
+
})
|
|
27
|
+
.join(",");
|
|
15
28
|
setSwitchState(el, value);
|
|
16
29
|
applySwitchState(el);
|
|
17
30
|
});
|
|
@@ -76,7 +89,9 @@ async function runQuery(container, deps) {
|
|
|
76
89
|
result.forEach((record) => {
|
|
77
90
|
const clone = template.cloneNode(true);
|
|
78
91
|
clone.removeAttribute(ATTR.listTemplate);
|
|
79
|
-
clone
|
|
92
|
+
if (clone instanceof HTMLButtonElement) {
|
|
93
|
+
clone.setAttribute(ATTR.querySet, `modal:view,id:${record.id}`);
|
|
94
|
+
}
|
|
80
95
|
clone.style.display = "flex";
|
|
81
96
|
if (record?.id != null)
|
|
82
97
|
clone.id = String(record.id);
|
package/dist/data-engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-engine.js","sourceRoot":"","sources":["../src/data-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBA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GAAG,IAAI,OAAO,EAAW,CAAC;IACpC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE;QAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO;QACzB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,GAAG,EAAE,EAAE;QACzC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACrD,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,MAAM,EAAE,CAAC;QACT,WAAW,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/helpers/dom.d.ts
CHANGED
|
@@ -12,5 +12,8 @@ export declare function setSwitchState(el: Element, value: unknown): void;
|
|
|
12
12
|
/**
|
|
13
13
|
* Show the [gg-case] child whose value matches the container's current
|
|
14
14
|
* gg-switch-state; hide the rest with display:none.
|
|
15
|
+
*
|
|
16
|
+
* Comma in state/case = positional AND match. Pipe in a case position = OR
|
|
17
|
+
* alternation within that position.
|
|
15
18
|
*/
|
|
16
19
|
export declare function applySwitchState(container: Element): void;
|
package/dist/helpers/dom.js
CHANGED
|
@@ -21,19 +21,35 @@ export function populateFields(root, record) {
|
|
|
21
21
|
export function setSwitchState(el, value) {
|
|
22
22
|
el.setAttribute("gg-switch-state", value == null ? "" : String(value));
|
|
23
23
|
}
|
|
24
|
+
function splitTrim(value, sep) {
|
|
25
|
+
return value.split(sep).map((s) => s.trim());
|
|
26
|
+
}
|
|
27
|
+
function caseMatches(caseAttr, state) {
|
|
28
|
+
const stateParts = splitTrim(state, ",");
|
|
29
|
+
const caseParts = splitTrim(caseAttr, ",");
|
|
30
|
+
if (caseParts.length !== stateParts.length)
|
|
31
|
+
return false;
|
|
32
|
+
return caseParts.every((part, i) => {
|
|
33
|
+
const alternatives = splitTrim(part, "|");
|
|
34
|
+
return alternatives.includes(stateParts[i] ?? "");
|
|
35
|
+
});
|
|
36
|
+
}
|
|
24
37
|
/**
|
|
25
38
|
* Show the [gg-case] child whose value matches the container's current
|
|
26
39
|
* gg-switch-state; hide the rest with display:none.
|
|
40
|
+
*
|
|
41
|
+
* Comma in state/case = positional AND match. Pipe in a case position = OR
|
|
42
|
+
* alternation within that position.
|
|
27
43
|
*/
|
|
28
44
|
export function applySwitchState(container) {
|
|
29
45
|
const state = container.getAttribute("gg-switch-state") ?? "";
|
|
30
46
|
Array.from(container.children).forEach((child) => {
|
|
31
47
|
if (!(child instanceof HTMLElement))
|
|
32
48
|
return;
|
|
33
|
-
|
|
49
|
+
const caseAttr = child.getAttribute("gg-case");
|
|
50
|
+
if (caseAttr == null)
|
|
34
51
|
return;
|
|
35
|
-
|
|
36
|
-
child.style.display = match ? "" : "none";
|
|
52
|
+
child.style.display = caseMatches(caseAttr, state) ? "" : "none";
|
|
37
53
|
});
|
|
38
54
|
}
|
|
39
55
|
//# sourceMappingURL=dom.js.map
|
package/dist/helpers/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","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EAAE;QAC/C,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC;YAAE,OAAO;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,QAAQ,IAAI,IAAI;YAAE,OAAO;QAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { setQueryParams, removeQueryParams, initQueryParams } from "./query-params.js";
|
|
2
2
|
import { initAuth } from "./auth.js";
|
|
3
|
+
import { initAuthEngine } from "./auth-engine.js";
|
|
3
4
|
import { initSwitchEngine } from "./switch-engine.js";
|
|
4
5
|
import { initDialog } from "./dialog.js";
|
|
5
6
|
import { initBridges } from "./bridges.js";
|
|
@@ -46,6 +47,7 @@ export function init({ context = {}, auth, debug = false, expose = true, } = {})
|
|
|
46
47
|
if (auth)
|
|
47
48
|
initAuth(context, auth);
|
|
48
49
|
cleanups.push(startDomObserver());
|
|
50
|
+
cleanups.push(initAuthEngine());
|
|
49
51
|
cleanups.push(initSwitchEngine());
|
|
50
52
|
cleanups.push(initQueryParams());
|
|
51
53
|
cleanups.push(initDialog());
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAoB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,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