@jant/core 0.3.19 → 0.3.21

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/dist/app.js CHANGED
@@ -75,9 +75,10 @@ import { createStorageDriver } from "./lib/storage.js";
75
75
  c.set("config", config);
76
76
  c.set("storage", createStorageDriver(c.env));
77
77
  if (c.env.AUTH_SECRET) {
78
+ const baseURL = c.env.SITE_URL || new URL(c.req.url).origin;
78
79
  const auth = createAuth(session, {
79
80
  secret: c.env.AUTH_SECRET,
80
- baseURL: c.env.SITE_URL
81
+ baseURL
81
82
  });
82
83
  c.set("auth", auth);
83
84
  }
@@ -164,6 +165,7 @@ import { createStorageDriver } from "./lib/storage.js";
164
165
  children: /*#__PURE__*/ _jsxs("form", {
165
166
  "data-signals": "{name: '', email: '', password: ''}",
166
167
  "data-on:submit__prevent": "@post('/setup')",
168
+ "data-indicator": "_loading",
167
169
  class: "flex flex-col gap-4",
168
170
  children: [
169
171
  /*#__PURE__*/ _jsxs("div", {
@@ -223,13 +225,26 @@ import { createStorageDriver } from "./lib/storage.js";
223
225
  })
224
226
  ]
225
227
  }),
226
- /*#__PURE__*/ _jsx("button", {
228
+ /*#__PURE__*/ _jsxs("button", {
227
229
  type: "submit",
228
230
  class: "btn",
229
- children: $__i18n._({
230
- id: "EGwzOK",
231
- message: "Complete Setup"
232
- })
231
+ "data-attr-disabled": "$_loading",
232
+ children: [
233
+ /*#__PURE__*/ _jsx("span", {
234
+ "data-show": "!$_loading",
235
+ children: $__i18n._({
236
+ id: "EGwzOK",
237
+ message: "Complete Setup"
238
+ })
239
+ }),
240
+ /*#__PURE__*/ _jsx("span", {
241
+ "data-show": "$_loading",
242
+ children: $__i18n._({
243
+ id: "k1ifdL",
244
+ message: "Processing..."
245
+ })
246
+ })
247
+ ]
233
248
  })
234
249
  ]
235
250
  })
@@ -313,6 +328,7 @@ import { createStorageDriver } from "./lib/storage.js";
313
328
  /*#__PURE__*/ _jsxs("form", {
314
329
  "data-signals": signals,
315
330
  "data-on:submit__prevent": "@post('/signin')",
331
+ "data-indicator": "_loading",
316
332
  class: "flex flex-col gap-4",
317
333
  children: [
318
334
  /*#__PURE__*/ _jsxs("div", {
@@ -351,13 +367,26 @@ import { createStorageDriver } from "./lib/storage.js";
351
367
  })
352
368
  ]
353
369
  }),
354
- /*#__PURE__*/ _jsx("button", {
370
+ /*#__PURE__*/ _jsxs("button", {
355
371
  type: "submit",
356
372
  class: "btn",
357
- children: $__i18n._({
358
- id: "n1ekoW",
359
- message: "Sign In"
360
- })
373
+ "data-attr-disabled": "$_loading",
374
+ children: [
375
+ /*#__PURE__*/ _jsx("span", {
376
+ "data-show": "!$_loading",
377
+ children: $__i18n._({
378
+ id: "n1ekoW",
379
+ message: "Sign In"
380
+ })
381
+ }),
382
+ /*#__PURE__*/ _jsx("span", {
383
+ "data-show": "$_loading",
384
+ children: $__i18n._({
385
+ id: "k1ifdL",
386
+ message: "Processing..."
387
+ })
388
+ })
389
+ ]
361
390
  })
362
391
  ]
363
392
  })
@@ -458,6 +487,7 @@ import { createStorageDriver } from "./lib/storage.js";
458
487
  children: /*#__PURE__*/ _jsxs("form", {
459
488
  "data-signals": signals,
460
489
  "data-on:submit__prevent": "@post('/reset')",
490
+ "data-indicator": "_loading",
461
491
  class: "flex flex-col gap-4",
462
492
  children: [
463
493
  /*#__PURE__*/ _jsxs("div", {
@@ -500,13 +530,26 @@ import { createStorageDriver } from "./lib/storage.js";
500
530
  })
501
531
  ]
502
532
  }),
503
- /*#__PURE__*/ _jsx("button", {
533
+ /*#__PURE__*/ _jsxs("button", {
504
534
  type: "submit",
505
535
  class: "btn",
506
- children: $__i18n._({
507
- id: "KbS2K9",
508
- message: "Reset Password"
509
- })
536
+ "data-attr-disabled": "$_loading",
537
+ children: [
538
+ /*#__PURE__*/ _jsx("span", {
539
+ "data-show": "!$_loading",
540
+ children: $__i18n._({
541
+ id: "KbS2K9",
542
+ message: "Reset Password"
543
+ })
544
+ }),
545
+ /*#__PURE__*/ _jsx("span", {
546
+ "data-show": "$_loading",
547
+ children: $__i18n._({
548
+ id: "k1ifdL",
549
+ message: "Processing..."
550
+ })
551
+ })
552
+ ]
510
553
  })
511
554
  ]
512
555
  })
@@ -86,6 +86,7 @@ function NewCollectionContent() {
86
86
  /*#__PURE__*/ _jsxs("form", {
87
87
  "data-signals": "{title: '', path: '', description: ''}",
88
88
  "data-on:submit__prevent": "@post('/dash/collections')",
89
+ "data-indicator": "_loading",
89
90
  class: "flex flex-col gap-4 max-w-lg",
90
91
  children: [
91
92
  /*#__PURE__*/ _jsxs("div", {
@@ -161,13 +162,26 @@ function NewCollectionContent() {
161
162
  /*#__PURE__*/ _jsxs("div", {
162
163
  class: "flex gap-2",
163
164
  children: [
164
- /*#__PURE__*/ _jsx("button", {
165
+ /*#__PURE__*/ _jsxs("button", {
165
166
  type: "submit",
166
167
  class: "btn",
167
- children: $__i18n._({
168
- id: "Pbm2/N",
169
- message: "Create Collection"
170
- })
168
+ "data-attr-disabled": "$_loading",
169
+ children: [
170
+ /*#__PURE__*/ _jsx("span", {
171
+ "data-show": "!$_loading",
172
+ children: $__i18n._({
173
+ id: "Pbm2/N",
174
+ message: "Create Collection"
175
+ })
176
+ }),
177
+ /*#__PURE__*/ _jsx("span", {
178
+ "data-show": "$_loading",
179
+ children: $__i18n._({
180
+ id: "k1ifdL",
181
+ message: "Processing..."
182
+ })
183
+ })
184
+ ]
171
185
  }),
172
186
  /*#__PURE__*/ _jsx("a", {
173
187
  href: "/dash/collections",
@@ -304,6 +318,7 @@ function EditCollectionContent({ collection }) {
304
318
  /*#__PURE__*/ _jsxs("form", {
305
319
  "data-signals": signals,
306
320
  "data-on:submit__prevent": `@post('/dash/collections/${collection.id}')`,
321
+ "data-indicator": "_loading",
307
322
  class: "flex flex-col gap-4 max-w-lg",
308
323
  children: [
309
324
  /*#__PURE__*/ _jsxs("div", {
@@ -364,13 +379,26 @@ function EditCollectionContent({ collection }) {
364
379
  /*#__PURE__*/ _jsxs("div", {
365
380
  class: "flex gap-2",
366
381
  children: [
367
- /*#__PURE__*/ _jsx("button", {
382
+ /*#__PURE__*/ _jsxs("button", {
368
383
  type: "submit",
369
384
  class: "btn",
370
- children: $__i18n._({
371
- id: "7Mk+/h",
372
- message: "Update Collection"
373
- })
385
+ "data-attr-disabled": "$_loading",
386
+ children: [
387
+ /*#__PURE__*/ _jsx("span", {
388
+ "data-show": "!$_loading",
389
+ children: $__i18n._({
390
+ id: "7Mk+/h",
391
+ message: "Update Collection"
392
+ })
393
+ }),
394
+ /*#__PURE__*/ _jsx("span", {
395
+ "data-show": "$_loading",
396
+ children: $__i18n._({
397
+ id: "k1ifdL",
398
+ message: "Processing..."
399
+ })
400
+ })
401
+ ]
374
402
  }),
375
403
  /*#__PURE__*/ _jsx("a", {
376
404
  href: `/dash/collections/${collection.id}`,
@@ -102,6 +102,7 @@ function NavigationFormContent({ link, isEdit }) {
102
102
  /*#__PURE__*/ _jsxs("form", {
103
103
  "data-signals": signals,
104
104
  "data-on:submit__prevent": `@post('${action}')`,
105
+ "data-indicator": "_loading",
105
106
  class: "flex flex-col gap-4 max-w-lg",
106
107
  children: [
107
108
  /*#__PURE__*/ _jsxs("div", {
@@ -159,16 +160,29 @@ function NavigationFormContent({ link, isEdit }) {
159
160
  /*#__PURE__*/ _jsxs("div", {
160
161
  class: "flex gap-2",
161
162
  children: [
162
- /*#__PURE__*/ _jsx("button", {
163
+ /*#__PURE__*/ _jsxs("button", {
163
164
  type: "submit",
164
165
  class: "btn",
165
- children: isEdit ? $__i18n._({
166
- id: "IUwGEM",
167
- message: "Save Changes"
168
- }) : $__i18n._({
169
- id: "kd7eBB",
170
- message: "Create Link"
171
- })
166
+ "data-attr-disabled": "$_loading",
167
+ children: [
168
+ /*#__PURE__*/ _jsx("span", {
169
+ "data-show": "!$_loading",
170
+ children: isEdit ? $__i18n._({
171
+ id: "IUwGEM",
172
+ message: "Save Changes"
173
+ }) : $__i18n._({
174
+ id: "kd7eBB",
175
+ message: "Create Link"
176
+ })
177
+ }),
178
+ /*#__PURE__*/ _jsx("span", {
179
+ "data-show": "$_loading",
180
+ children: $__i18n._({
181
+ id: "k1ifdL",
182
+ message: "Processing..."
183
+ })
184
+ })
185
+ ]
172
186
  }),
173
187
  /*#__PURE__*/ _jsx("a", {
174
188
  href: "/dash/navigation",
@@ -83,6 +83,7 @@ function NewRedirectContent() {
83
83
  /*#__PURE__*/ _jsxs("form", {
84
84
  "data-signals": "{fromPath: '', toPath: '', type: '301'}",
85
85
  "data-on:submit__prevent": "@post('/dash/redirects')",
86
+ "data-indicator": "_loading",
86
87
  class: "flex flex-col gap-4 max-w-lg",
87
88
  children: [
88
89
  /*#__PURE__*/ _jsxs("div", {
@@ -172,13 +173,26 @@ function NewRedirectContent() {
172
173
  /*#__PURE__*/ _jsxs("div", {
173
174
  class: "flex gap-2",
174
175
  children: [
175
- /*#__PURE__*/ _jsx("button", {
176
+ /*#__PURE__*/ _jsxs("button", {
176
177
  type: "submit",
177
178
  class: "btn",
178
- children: $__i18n._({
179
- id: "Mhf/H/",
180
- message: "Create Redirect"
181
- })
179
+ "data-attr-disabled": "$_loading",
180
+ children: [
181
+ /*#__PURE__*/ _jsx("span", {
182
+ "data-show": "!$_loading",
183
+ children: $__i18n._({
184
+ id: "Mhf/H/",
185
+ message: "Create Redirect"
186
+ })
187
+ }),
188
+ /*#__PURE__*/ _jsx("span", {
189
+ "data-show": "$_loading",
190
+ children: $__i18n._({
191
+ id: "k1ifdL",
192
+ message: "Processing..."
193
+ })
194
+ })
195
+ ]
182
196
  }),
183
197
  /*#__PURE__*/ _jsx("a", {
184
198
  href: "/dash/redirects",
@@ -78,6 +78,7 @@ function GeneralContent({ siteName, siteDescription, siteLanguage, siteNameFallb
78
78
  children: /*#__PURE__*/ _jsxs("form", {
79
79
  "data-signals": generalSignals,
80
80
  "data-on:submit__prevent": "@post('/dash/settings')",
81
+ "data-indicator": "_loading",
81
82
  children: [
82
83
  /*#__PURE__*/ _jsxs("div", {
83
84
  class: "card",
@@ -167,13 +168,26 @@ function GeneralContent({ siteName, siteDescription, siteLanguage, siteNameFallb
167
168
  })
168
169
  ]
169
170
  }),
170
- /*#__PURE__*/ _jsx("button", {
171
+ /*#__PURE__*/ _jsxs("button", {
171
172
  type: "submit",
172
173
  class: "btn mt-4",
173
- children: $__i18n._({
174
- id: "UGT5vp",
175
- message: "Save Settings"
176
- })
174
+ "data-attr-disabled": "$_loading",
175
+ children: [
176
+ /*#__PURE__*/ _jsx("span", {
177
+ "data-show": "!$_loading",
178
+ children: $__i18n._({
179
+ id: "UGT5vp",
180
+ message: "Save Settings"
181
+ })
182
+ }),
183
+ /*#__PURE__*/ _jsx("span", {
184
+ "data-show": "$_loading",
185
+ children: $__i18n._({
186
+ id: "k1ifdL",
187
+ message: "Processing..."
188
+ })
189
+ })
190
+ ]
177
191
  })
178
192
  ]
179
193
  })
@@ -334,6 +348,7 @@ function AccountContent({ userName }) {
334
348
  /*#__PURE__*/ _jsxs("form", {
335
349
  "data-signals": profileSignals,
336
350
  "data-on:submit__prevent": "@post('/dash/settings/account')",
351
+ "data-indicator": "_profileLoading",
337
352
  children: [
338
353
  /*#__PURE__*/ _jsxs("div", {
339
354
  class: "card",
@@ -369,19 +384,33 @@ function AccountContent({ userName }) {
369
384
  })
370
385
  ]
371
386
  }),
372
- /*#__PURE__*/ _jsx("button", {
387
+ /*#__PURE__*/ _jsxs("button", {
373
388
  type: "submit",
374
389
  class: "btn mt-4",
375
- children: $__i18n._({
376
- id: "ssqvZi",
377
- message: "Save Profile"
378
- })
390
+ "data-attr-disabled": "$_profileLoading",
391
+ children: [
392
+ /*#__PURE__*/ _jsx("span", {
393
+ "data-show": "!$_profileLoading",
394
+ children: $__i18n._({
395
+ id: "ssqvZi",
396
+ message: "Save Profile"
397
+ })
398
+ }),
399
+ /*#__PURE__*/ _jsx("span", {
400
+ "data-show": "$_profileLoading",
401
+ children: $__i18n._({
402
+ id: "k1ifdL",
403
+ message: "Processing..."
404
+ })
405
+ })
406
+ ]
379
407
  })
380
408
  ]
381
409
  }),
382
410
  /*#__PURE__*/ _jsxs("form", {
383
411
  "data-signals": "{currentPassword: '', newPassword: '', confirmPassword: ''}",
384
412
  "data-on:submit__prevent": "@post('/dash/settings/password')",
413
+ "data-indicator": "_passwordLoading",
385
414
  children: [
386
415
  /*#__PURE__*/ _jsxs("div", {
387
416
  class: "card",
@@ -460,13 +489,26 @@ function AccountContent({ userName }) {
460
489
  })
461
490
  ]
462
491
  }),
463
- /*#__PURE__*/ _jsx("button", {
492
+ /*#__PURE__*/ _jsxs("button", {
464
493
  type: "submit",
465
494
  class: "btn mt-4",
466
- children: $__i18n._({
467
- id: "VhMDMg",
468
- message: "Change Password"
469
- })
495
+ "data-attr-disabled": "$_passwordLoading",
496
+ children: [
497
+ /*#__PURE__*/ _jsx("span", {
498
+ "data-show": "!$_passwordLoading",
499
+ children: $__i18n._({
500
+ id: "VhMDMg",
501
+ message: "Change Password"
502
+ })
503
+ }),
504
+ /*#__PURE__*/ _jsx("span", {
505
+ "data-show": "$_passwordLoading",
506
+ children: $__i18n._({
507
+ id: "k1ifdL",
508
+ message: "Processing..."
509
+ })
510
+ })
511
+ ]
470
512
  })
471
513
  ]
472
514
  })
@@ -16,6 +16,7 @@ export const PageForm = ({ page, action, cancelUrl = "/dash/pages" })=>{
16
16
  return /*#__PURE__*/ _jsxs("form", {
17
17
  "data-signals": signals,
18
18
  "data-on:submit__prevent": `@post('${action}')`,
19
+ "data-indicator": "_loading",
19
20
  class: "flex flex-col gap-4",
20
21
  children: [
21
22
  /*#__PURE__*/ _jsx("div", {
@@ -149,16 +150,29 @@ export const PageForm = ({ page, action, cancelUrl = "/dash/pages" })=>{
149
150
  /*#__PURE__*/ _jsxs("div", {
150
151
  class: "flex gap-2",
151
152
  children: [
152
- /*#__PURE__*/ _jsx("button", {
153
+ /*#__PURE__*/ _jsxs("button", {
153
154
  type: "submit",
154
155
  class: "btn",
155
- children: isEdit ? $__i18n._({
156
- id: "oYPBa0",
157
- message: "Update Page"
158
- }) : $__i18n._({
159
- id: "Y+7JGK",
160
- message: "Create Page"
161
- })
156
+ "data-attr-disabled": "$_loading",
157
+ children: [
158
+ /*#__PURE__*/ _jsx("span", {
159
+ "data-show": "!$_loading",
160
+ children: isEdit ? $__i18n._({
161
+ id: "oYPBa0",
162
+ message: "Update Page"
163
+ }) : $__i18n._({
164
+ id: "Y+7JGK",
165
+ message: "Create Page"
166
+ })
167
+ }),
168
+ /*#__PURE__*/ _jsx("span", {
169
+ "data-show": "$_loading",
170
+ children: $__i18n._({
171
+ id: "k1ifdL",
172
+ message: "Processing..."
173
+ })
174
+ })
175
+ ]
162
176
  }),
163
177
  /*#__PURE__*/ _jsx("a", {
164
178
  href: cancelUrl,
@@ -21,6 +21,7 @@ export const PostForm = ({ post, action, mediaAttachments, r2PublicUrl, imageTra
21
21
  return /*#__PURE__*/ _jsxs("form", {
22
22
  "data-signals": signals,
23
23
  "data-on:submit__prevent": `@post('${action}')`,
24
+ "data-indicator": "_loading",
24
25
  class: "flex flex-col gap-4",
25
26
  children: [
26
27
  /*#__PURE__*/ _jsx("div", {
@@ -330,16 +331,29 @@ export const PostForm = ({ post, action, mediaAttachments, r2PublicUrl, imageTra
330
331
  /*#__PURE__*/ _jsxs("div", {
331
332
  class: "flex gap-2",
332
333
  children: [
333
- /*#__PURE__*/ _jsx("button", {
334
+ /*#__PURE__*/ _jsxs("button", {
334
335
  type: "submit",
335
336
  class: "btn",
336
- children: isEdit ? $__i18n._({
337
- id: "EkH9pt",
338
- message: "Update"
339
- }) : $__i18n._({
340
- id: "EEYbdt",
341
- message: "Publish"
342
- })
337
+ "data-attr-disabled": "$_loading",
338
+ children: [
339
+ /*#__PURE__*/ _jsx("span", {
340
+ "data-show": "!$_loading",
341
+ children: isEdit ? $__i18n._({
342
+ id: "EkH9pt",
343
+ message: "Update"
344
+ }) : $__i18n._({
345
+ id: "EEYbdt",
346
+ message: "Publish"
347
+ })
348
+ }),
349
+ /*#__PURE__*/ _jsx("span", {
350
+ "data-show": "$_loading",
351
+ children: $__i18n._({
352
+ id: "k1ifdL",
353
+ message: "Processing..."
354
+ })
355
+ })
356
+ ]
343
357
  }),
344
358
  /*#__PURE__*/ _jsx("a", {
345
359
  href: "/dash/posts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jant/core",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "description": "A modern, open-source microblogging platform built on Cloudflare Workers",
5
5
  "type": "module",
6
6
  "bin": {
package/src/app.tsx CHANGED
@@ -100,9 +100,10 @@ export function createApp(config: JantConfig = {}): App {
100
100
  c.set("storage", createStorageDriver(c.env));
101
101
 
102
102
  if (c.env.AUTH_SECRET) {
103
+ const baseURL = c.env.SITE_URL || new URL(c.req.url).origin;
103
104
  const auth = createAuth(session as unknown as D1Database, {
104
105
  secret: c.env.AUTH_SECRET,
105
- baseURL: c.env.SITE_URL,
106
+ baseURL,
106
107
  });
107
108
  c.set("auth", auth);
108
109
  }
@@ -200,6 +201,7 @@ export function createApp(config: JantConfig = {}): App {
200
201
  <form
201
202
  data-signals="{name: '', email: '', password: ''}"
202
203
  data-on:submit__prevent="@post('/setup')"
204
+ data-indicator="_loading"
203
205
  class="flex flex-col gap-4"
204
206
  >
205
207
  <div class="field">
@@ -247,11 +249,20 @@ export function createApp(config: JantConfig = {}): App {
247
249
  minLength={8}
248
250
  />
249
251
  </div>
250
- <button type="submit" class="btn">
251
- {t({
252
- message: "Complete Setup",
253
- comment: "@context: Setup form submit button",
254
- })}
252
+ <button type="submit" class="btn" data-attr-disabled="$_loading">
253
+ <span data-show="!$_loading">
254
+ {t({
255
+ message: "Complete Setup",
256
+ comment: "@context: Setup form submit button",
257
+ })}
258
+ </span>
259
+ <span data-show="$_loading">
260
+ {t({
261
+ message: "Processing...",
262
+ comment:
263
+ "@context: Loading text shown on submit button while request is in progress",
264
+ })}
265
+ </span>
255
266
  </button>
256
267
  </form>
257
268
  </section>
@@ -349,6 +360,7 @@ export function createApp(config: JantConfig = {}): App {
349
360
  <form
350
361
  data-signals={signals}
351
362
  data-on:submit__prevent="@post('/signin')"
363
+ data-indicator="_loading"
352
364
  class="flex flex-col gap-4"
353
365
  >
354
366
  <div class="field">
@@ -374,11 +386,20 @@ export function createApp(config: JantConfig = {}): App {
374
386
  required
375
387
  />
376
388
  </div>
377
- <button type="submit" class="btn">
378
- {t({
379
- message: "Sign In",
380
- comment: "@context: Sign in form submit button",
381
- })}
389
+ <button type="submit" class="btn" data-attr-disabled="$_loading">
390
+ <span data-show="!$_loading">
391
+ {t({
392
+ message: "Sign In",
393
+ comment: "@context: Sign in form submit button",
394
+ })}
395
+ </span>
396
+ <span data-show="$_loading">
397
+ {t({
398
+ message: "Processing...",
399
+ comment:
400
+ "@context: Loading text shown on submit button while request is in progress",
401
+ })}
402
+ </span>
382
403
  </button>
383
404
  </form>
384
405
  </section>
@@ -470,6 +491,7 @@ export function createApp(config: JantConfig = {}): App {
470
491
  <form
471
492
  data-signals={signals}
472
493
  data-on:submit__prevent="@post('/reset')"
494
+ data-indicator="_loading"
473
495
  class="flex flex-col gap-4"
474
496
  >
475
497
  <div class="field">
@@ -504,11 +526,20 @@ export function createApp(config: JantConfig = {}): App {
504
526
  autocomplete="new-password"
505
527
  />
506
528
  </div>
507
- <button type="submit" class="btn">
508
- {t({
509
- message: "Reset Password",
510
- comment: "@context: Password reset form submit button",
511
- })}
529
+ <button type="submit" class="btn" data-attr-disabled="$_loading">
530
+ <span data-show="!$_loading">
531
+ {t({
532
+ message: "Reset Password",
533
+ comment: "@context: Password reset form submit button",
534
+ })}
535
+ </span>
536
+ <span data-show="$_loading">
537
+ {t({
538
+ message: "Processing...",
539
+ comment:
540
+ "@context: Loading text shown on submit button while request is in progress",
541
+ })}
542
+ </span>
512
543
  </button>
513
544
  </form>
514
545
  </section>