@drawbridge/components 0.1.22 → 0.1.23

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 (69) hide show
  1. package/dist/bridge/template-modal.js +2 -1
  2. package/dist/bridge/template-modal.mjs +2 -1
  3. package/dist/dashboard/buttons-subscription.js +65 -20
  4. package/dist/dashboard/buttons-subscription.mjs +64 -20
  5. package/dist/dashboard/card-payment-method.js +1 -1
  6. package/dist/dashboard/card-payment-method.mjs +1 -1
  7. package/dist/dashboard/card-section.js +2 -2
  8. package/dist/dashboard/card-section.mjs +2 -2
  9. package/dist/dashboard/card-setting.js +4 -3
  10. package/dist/dashboard/card-setting.mjs +4 -3
  11. package/dist/dashboard/card-task.js +22 -4
  12. package/dist/dashboard/card-task.mjs +22 -4
  13. package/dist/dashboard/card-tile.js +6 -6
  14. package/dist/dashboard/card-tile.mjs +6 -6
  15. package/dist/dashboard/drawer.js +7 -2
  16. package/dist/dashboard/drawer.mjs +8 -3
  17. package/dist/dashboard/form-organization-workflow.js +2 -2
  18. package/dist/dashboard/form-organization-workflow.mjs +2 -2
  19. package/dist/dashboard/input-combobox.js +7 -2
  20. package/dist/dashboard/input-combobox.mjs +7 -2
  21. package/dist/dashboard/lib/escape.js +48 -0
  22. package/dist/dashboard/lib/escape.mjs +25 -0
  23. package/dist/dashboard/lib/rail.js +75 -0
  24. package/dist/dashboard/lib/rail.mjs +46 -0
  25. package/dist/dashboard/lib/throttle.js +57 -0
  26. package/dist/dashboard/lib/throttle.mjs +34 -0
  27. package/dist/dashboard/list.js +1 -1
  28. package/dist/dashboard/list.mjs +1 -1
  29. package/dist/dashboard/menu.js +188 -96
  30. package/dist/dashboard/menu.mjs +189 -97
  31. package/dist/dashboard/modal.js +9 -3
  32. package/dist/dashboard/modal.mjs +10 -4
  33. package/dist/dashboard/notice.js +5 -3
  34. package/dist/dashboard/notice.mjs +5 -3
  35. package/dist/dashboard/table-cell-title.js +2 -0
  36. package/dist/dashboard/table-cell-title.mjs +2 -0
  37. package/dist/dashboard/table.js +61 -20
  38. package/dist/dashboard/table.mjs +61 -20
  39. package/dist/dashboard/template-dashboard.js +35 -133
  40. package/dist/dashboard/template-dashboard.mjs +36 -134
  41. package/dist/dashboard/template-rail.js +674 -0
  42. package/dist/dashboard/template-rail.mjs +640 -0
  43. package/dist/dashboard/template-socket.js +19 -3
  44. package/dist/dashboard/template-socket.mjs +19 -3
  45. package/dist/dashboard/template-ui.js +150 -186
  46. package/dist/dashboard/template-ui.mjs +151 -187
  47. package/dist/icons/book-open.js +46 -0
  48. package/dist/icons/book-open.mjs +27 -0
  49. package/dist/icons/task.js +46 -0
  50. package/dist/icons/task.mjs +27 -0
  51. package/dist/shared/lib/helpers.js +9 -2
  52. package/dist/shared/lib/helpers.mjs +9 -2
  53. package/dist/shared/lib/motion.js +27 -0
  54. package/dist/shared/lib/motion.mjs +4 -0
  55. package/dist/shared/overlay.js +5 -3
  56. package/dist/shared/overlay.mjs +5 -3
  57. package/package.json +27 -12
  58. package/types/dashboard/card-task.d.ts +5 -1
  59. package/types/dashboard/lib/rail.d.ts +32 -0
  60. package/types/dashboard/lib/throttle.d.ts +5 -0
  61. package/types/dashboard/table.d.ts +3 -1
  62. package/types/dashboard/template-dashboard.d.ts +4 -1
  63. package/types/dashboard/template-rail.d.ts +36 -0
  64. package/types/dashboard/template-ui.d.ts +2 -2
  65. package/types/icons/book-open.d.ts +5 -0
  66. package/types/icons/task.d.ts +5 -0
  67. package/dist/dashboard/guide.js +0 -238
  68. package/dist/dashboard/guide.mjs +0 -209
  69. package/types/dashboard/guide.d.ts +0 -23
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
+ import { useState } from "react";
3
4
  import { useParams } from "next/navigation";
4
5
  import { useQuery, useQueryClient } from "@tanstack/react-query";
5
6
  import { useSocketRoom } from "./lib/hooks.mjs";
7
+ import { trailingThrottle } from "./lib/throttle.mjs";
6
8
  import { isAdmin } from "../shared/lib/helpers.mjs";
7
9
  import TemplateSuspended from "./template-suspended.mjs";
8
10
  const TemplateSocketAccount = ({
@@ -201,6 +203,15 @@ const TemplateSocketOrganization = ({
201
203
  }) => {
202
204
  const params = useParams();
203
205
  const queryClient = useQueryClient();
206
+ const [refetchNextSteps] = useState(() => trailingThrottle({
207
+ wait: 1e4
208
+ }));
209
+ const refetchOrganization = () => refetchNextSteps(
210
+ "organization." + params.organization,
211
+ () => queryClient.invalidateQueries({
212
+ queryKey: ["organization", params.organization]
213
+ })
214
+ );
204
215
  const { data: organization } = useQuery({
205
216
  enabled: false,
206
217
  queryKey: ["organization", params == null ? void 0 : params.organization]
@@ -268,6 +279,13 @@ const TemplateSocketOrganization = ({
268
279
  queryClient.invalidateQueries({
269
280
  queryKey: ["menu", "campaign", params.organization]
270
281
  });
282
+ refetchOrganization();
283
+ refetchNextSteps(
284
+ "menu." + params.organization,
285
+ () => queryClient.invalidateQueries({
286
+ queryKey: ["menu", "organization", params.organization]
287
+ })
288
+ );
271
289
  queryClient.invalidateQueries({
272
290
  queryKey: ["organization-affiliate-campaigns"]
273
291
  });
@@ -419,9 +437,7 @@ const TemplateSocketOrganization = ({
419
437
  // emits this whenever a count changes. Refetch the authoritative org doc
420
438
  // + the usage page / dashboard that display those counts.
421
439
  "organization.totals": () => {
422
- queryClient.invalidateQueries({
423
- queryKey: ["organization", params.organization]
424
- });
440
+ refetchOrganization();
425
441
  queryClient.invalidateQueries({
426
442
  queryKey: ["organization-usage-chart", params.organization]
427
443
  });
@@ -37,7 +37,7 @@ var import_navigation = require("next/navigation");
37
37
  var import_react_query = require("@tanstack/react-query");
38
38
  var import_hooks = require("./lib/hooks");
39
39
  var import_wrapper_gradient = __toESM(require("../wrapper-gradient"));
40
- var import_guide = __toESM(require("./guide"));
40
+ var import_template_rail = __toESM(require("./template-rail"));
41
41
  var import_menu = require("./menu");
42
42
  var import_menu2 = __toESM(require("../icons/menu"));
43
43
  var import_switch = __toESM(require("../icons/switch"));
@@ -52,7 +52,6 @@ const offsets = {
52
52
  paddingTop: "pt-16 md:pt-0"
53
53
  };
54
54
  const isAccountPath = (path) => path === "/account" || path.startsWith("/account/");
55
- let timeout;
56
55
  const TemplateUIHeaderBack = ({
57
56
  href,
58
57
  icon: Icon = import_arrow_left.default,
@@ -124,6 +123,7 @@ const TemplateUiHeader = ({
124
123
  active,
125
124
  campaign = {},
126
125
  className,
126
+ guide,
127
127
  organization = {},
128
128
  params,
129
129
  path
@@ -187,6 +187,14 @@ const TemplateUiHeader = ({
187
187
  }
188
188
  }
189
189
  ),
190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
+ import_template_rail.TemplateRailBook,
192
+ {
193
+ ...{
194
+ guide
195
+ }
196
+ }
197
+ ),
190
198
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
199
  "div",
192
200
  {
@@ -287,21 +295,11 @@ const TemplateUi = ({
287
295
  queryKey: ["campaign", params.campaign]
288
296
  });
289
297
  const guide = (_b = (_a = account == null ? void 0 : account.data) == null ? void 0 : _a.guide) == null ? void 0 : _b[guideId];
290
- const [run, setRun] = (0, import_react.useState)(false);
291
298
  const modal = (0, import_hooks.useModal)({
292
299
  queryClient
293
300
  });
294
301
  const actions = (0, import_react.useMemo)(
295
302
  () => {
296
- const reset = () => {
297
- modal.close();
298
- queryClient.setQueryData(
299
- ["menu"],
300
- {
301
- active: false
302
- }
303
- );
304
- };
305
303
  const menu2 = () => {
306
304
  queryClient.setQueryData(
307
305
  ["menu"],
@@ -311,10 +309,6 @@ const TemplateUi = ({
311
309
  );
312
310
  };
313
311
  return {
314
- guide: () => {
315
- reset();
316
- setRun(true);
317
- },
318
312
  signout: () => {
319
313
  modal.open({
320
314
  message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -351,188 +345,158 @@ const TemplateUi = ({
351
345
  },
352
346
  [queryClient, modal]
353
347
  );
354
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
355
- guide && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
356
- import_guide.default,
357
- {
358
- ...{
359
- ...guide,
360
- callback: async ({ action, step, type }) => {
361
- var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j;
362
- const key = action + "." + type;
363
- if ((_a2 = step == null ? void 0 : step.data) == null ? void 0 : _a2[key]) {
364
- clearTimeout(timeout);
365
- setRun(false);
366
- if (Array.isArray((_c2 = (_b2 = step == null ? void 0 : step.data) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.state) && ((_f = (_e2 = (_d2 = step == null ? void 0 : step.data) == null ? void 0 : _d2[key]) == null ? void 0 : _e2.state) == null ? void 0 : _f.length) > 0) {
367
- const promises = [];
368
- (_h = (_g = step == null ? void 0 : step.data) == null ? void 0 : _g[key]) == null ? void 0 : _h.state.map((args) => promises.push(queryClient.setQueryData(...args)));
369
- await Promise.all(promises);
370
- }
371
- if ((_j = (_i = step == null ? void 0 : step.data) == null ? void 0 : _i[key]) == null ? void 0 : _j.timeout) {
372
- timeout = setTimeout(
373
- () => {
374
- setRun(true);
375
- },
376
- step.data[key].timeout
377
- );
378
- }
379
- }
380
- if (type === "tour:end") {
381
- setRun(false);
382
- }
383
- },
384
- run
385
- }
386
- }
387
- ),
388
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
389
- "div",
390
- {
391
- ...{
392
- className: "flex flex-col h-dvh overflow-hidden md:flex-row " + offsets.paddingTop
393
- },
394
- children: [
395
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
396
- TemplateUiHeader,
397
- {
398
- ...{
399
- actions,
400
- active: (_c = menu == null ? void 0 : menu.data) == null ? void 0 : _c.active,
401
- campaign: campaign == null ? void 0 : campaign.data,
402
- className: "z-30 fixed top-0 left-0 md:hidden",
403
- organization: organization == null ? void 0 : organization.data,
404
- params,
405
- path
406
- }
348
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
349
+ "div",
350
+ {
351
+ ...{
352
+ className: "flex flex-col h-dvh overflow-hidden md:flex-row " + offsets.paddingTop
353
+ },
354
+ children: [
355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
356
+ TemplateUiHeader,
357
+ {
358
+ ...{
359
+ actions,
360
+ active: (_c = menu == null ? void 0 : menu.data) == null ? void 0 : _c.active,
361
+ campaign: campaign == null ? void 0 : campaign.data,
362
+ className: "z-30 fixed top-0 left-0 md:hidden",
363
+ guide,
364
+ organization: organization == null ? void 0 : organization.data,
365
+ params,
366
+ path
407
367
  }
408
- ),
409
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
410
- "div",
411
- {
412
- ...{
413
- className: "z-[25] fixed top-0 left-0 w-full flex flex-col justify-between bg-black h-full transition duration-200 ease-in md:z-0 md:relative md:w-1/3 lg:w-1/4 xl:w-1/5 " + (((_d = menu == null ? void 0 : menu.data) == null ? void 0 : _d.active) ? "translate-y-0 " + offsets.paddingTop : "-translate-y-full md:translate-y-0")
414
- },
415
- children: [
416
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
417
- TemplateUiHeader,
418
- {
419
- ...{
420
- actions,
421
- active: (_e = menu == null ? void 0 : menu.data) == null ? void 0 : _e.active,
422
- campaign: campaign == null ? void 0 : campaign.data,
423
- className: "hidden md:flex border-b border-gray-dark relative z-[3]",
424
- organization: organization == null ? void 0 : organization.data,
425
- params,
426
- path
427
- }
368
+ }
369
+ ),
370
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
371
+ "div",
372
+ {
373
+ ...{
374
+ className: "z-[25] fixed top-0 left-0 w-full flex flex-col justify-between bg-black h-full transition duration-200 ease-out motion-reduce:transition-none md:z-0 md:relative md:w-1/3 lg:w-1/4 xl:w-1/5 " + (((_d = menu == null ? void 0 : menu.data) == null ? void 0 : _d.active) ? "translate-y-0 " + offsets.paddingTop : "-translate-y-full md:translate-y-0")
375
+ },
376
+ children: [
377
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
378
+ TemplateUiHeader,
379
+ {
380
+ ...{
381
+ actions,
382
+ active: (_e = menu == null ? void 0 : menu.data) == null ? void 0 : _e.active,
383
+ campaign: campaign == null ? void 0 : campaign.data,
384
+ className: "hidden md:flex border-b border-gray-dark relative z-[3]",
385
+ organization: organization == null ? void 0 : organization.data,
386
+ params,
387
+ path
428
388
  }
429
- ),
430
- (params == null ? void 0 : params.organization) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
431
- TemplateUiBand,
432
- {
433
- ...{
434
- record: params.campaign ? campaign == null ? void 0 : campaign.data : organization == null ? void 0 : organization.data
435
- }
389
+ }
390
+ ),
391
+ (params == null ? void 0 : params.organization) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
392
+ TemplateUiBand,
393
+ {
394
+ ...{
395
+ record: params.campaign ? campaign == null ? void 0 : campaign.data : organization == null ? void 0 : organization.data
436
396
  }
437
- ),
438
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
439
- import_wrapper_gradient.default,
440
- {
441
- ...{
442
- className: "flex-1 min-h-0",
443
- classNameGradient: "from-black to-transparent h-10",
444
- classNameScroll: "h-full"
445
- },
446
- children: [
447
- (params == null ? void 0 : params.organization) && !(organization == null ? void 0 : organization.isLoading) && (organization == null ? void 0 : organization.data) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: params.organization && params.campaign ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
448
- import_menu.MenuCampaign,
449
- {
450
- ...{
451
- campaign: params.campaign,
452
- onClick: actions.menu,
453
- organization: params.organization,
454
- path
455
- }
456
- },
457
- params.organization + "-" + params.campaign
458
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
459
- import_menu.MenuOrganization,
460
- {
461
- ...{
462
- onClick: actions.menu,
463
- organization: params.organization,
464
- path
465
- }
466
- },
467
- params.organization
468
- ) }),
469
- !(params == null ? void 0 : params.organization) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
470
- import_menu.MenuApp,
471
- {
472
- ...{
473
- onClick: actions.menu,
474
- path
475
- }
397
+ }
398
+ ),
399
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
400
+ import_wrapper_gradient.default,
401
+ {
402
+ ...{
403
+ className: "flex-1 min-h-0",
404
+ classNameGradient: "from-black to-transparent h-10",
405
+ classNameScroll: "h-full"
406
+ },
407
+ children: [
408
+ (params == null ? void 0 : params.organization) && !(organization == null ? void 0 : organization.isLoading) && (organization == null ? void 0 : organization.data) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: params.organization && params.campaign ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
409
+ import_menu.MenuCampaign,
410
+ {
411
+ ...{
412
+ campaign: params.campaign,
413
+ onClick: actions.menu,
414
+ organization: params.organization,
415
+ path
476
416
  }
477
- ),
478
- path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
479
- import_menu.MenuAdmin,
480
- {
481
- ...{
482
- onClick: actions.menu,
483
- path
484
- }
417
+ },
418
+ params.organization + "-" + params.campaign
419
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
420
+ import_menu.MenuOrganization,
421
+ {
422
+ ...{
423
+ onClick: actions.menu,
424
+ organization: params.organization,
425
+ path
485
426
  }
486
- ),
487
- isAccountPath(path) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
488
- import_menu.MenuAccount,
489
- {
490
- ...{
491
- onClick: actions.menu,
492
- path
493
- }
427
+ },
428
+ params.organization
429
+ ) }),
430
+ !(params == null ? void 0 : params.organization) && !isAccountPath(path) && !path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
431
+ import_menu.MenuApp,
432
+ {
433
+ ...{
434
+ onClick: actions.menu,
435
+ path
494
436
  }
495
- )
496
- ]
497
- }
498
- ),
499
- !isAccountPath(path) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
500
- "div",
501
- {
502
- ...{
503
- className: "relative z-[3]"
504
- },
505
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
506
- import_menu.MenuAccountDropdown,
437
+ }
438
+ ),
439
+ path.includes("/admin") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
440
+ import_menu.MenuAdmin,
441
+ {
442
+ ...{
443
+ onClick: actions.menu,
444
+ path
445
+ }
446
+ }
447
+ ),
448
+ isAccountPath(path) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
449
+ import_menu.MenuAccount,
507
450
  {
508
451
  ...{
509
- actions,
510
- account,
511
- balance,
512
- guide,
513
- modal,
514
452
  onClick: actions.menu,
515
453
  path
516
454
  }
517
455
  }
518
456
  )
519
- }
520
- )
521
- ]
522
- }
523
- ),
524
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
525
- "div",
526
- {
527
- ...{
528
- className: "flex flex-col h-full w-full md:w-3/4 lg:w-4/5"
529
- },
530
- children
531
- }
532
- )
533
- ]
534
- }
535
- )
536
- ] });
457
+ ]
458
+ }
459
+ ),
460
+ !isAccountPath(path) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
461
+ "div",
462
+ {
463
+ ...{
464
+ className: "relative z-[3]"
465
+ },
466
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
467
+ import_menu.MenuAccountDropdown,
468
+ {
469
+ ...{
470
+ actions,
471
+ account,
472
+ balance,
473
+ modal,
474
+ onClick: actions.menu,
475
+ path
476
+ }
477
+ }
478
+ )
479
+ }
480
+ )
481
+ ]
482
+ }
483
+ ),
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
485
+ import_template_rail.default,
486
+ {
487
+ ...{
488
+ account: account == null ? void 0 : account.data,
489
+ campaign: campaign == null ? void 0 : campaign.data,
490
+ guide,
491
+ organization: organization == null ? void 0 : organization.data,
492
+ params,
493
+ path
494
+ },
495
+ children
496
+ }
497
+ )
498
+ ]
499
+ }
500
+ );
537
501
  };
538
502
  var template_ui_default = TemplateUi;