@drawbridge/components 0.1.23 → 0.1.24

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 (79) hide show
  1. package/dist/bridge/form-subdomain-embed.js +1 -0
  2. package/dist/bridge/form-subdomain-embed.mjs +1 -0
  3. package/dist/bridge/form-subdomain.js +5 -2
  4. package/dist/bridge/form-subdomain.mjs +5 -2
  5. package/dist/bridge/template-modal.js +2 -2
  6. package/dist/bridge/template-modal.mjs +2 -2
  7. package/dist/dashboard/buttons-subscription.js +27 -66
  8. package/dist/dashboard/buttons-subscription.mjs +27 -65
  9. package/dist/dashboard/card-payment-method.js +1 -1
  10. package/dist/dashboard/card-payment-method.mjs +1 -1
  11. package/dist/dashboard/card-section.js +2 -2
  12. package/dist/dashboard/card-section.mjs +2 -2
  13. package/dist/dashboard/card-setting.js +3 -4
  14. package/dist/dashboard/card-setting.mjs +3 -4
  15. package/dist/dashboard/card-task.js +4 -22
  16. package/dist/dashboard/card-task.mjs +4 -22
  17. package/dist/dashboard/card-tile.js +6 -6
  18. package/dist/dashboard/card-tile.mjs +6 -6
  19. package/dist/dashboard/drawer.js +2 -7
  20. package/dist/dashboard/drawer.mjs +3 -8
  21. package/dist/dashboard/form-organization-campaign.js +1 -1
  22. package/dist/dashboard/form-organization-campaign.mjs +1 -1
  23. package/dist/dashboard/form-organization-identity.js +3 -3
  24. package/dist/dashboard/form-organization-identity.mjs +3 -3
  25. package/dist/dashboard/form-organization-workflow.js +9 -7
  26. package/dist/dashboard/form-organization-workflow.mjs +9 -7
  27. package/dist/dashboard/form-organization.js +40 -3
  28. package/dist/dashboard/form-organization.mjs +40 -3
  29. package/dist/dashboard/guide.js +238 -0
  30. package/dist/dashboard/guide.mjs +209 -0
  31. package/dist/dashboard/input-combobox.js +2 -7
  32. package/dist/dashboard/input-combobox.mjs +2 -7
  33. package/dist/dashboard/list.js +1 -1
  34. package/dist/dashboard/list.mjs +1 -1
  35. package/dist/dashboard/menu.js +96 -188
  36. package/dist/dashboard/menu.mjs +97 -189
  37. package/dist/dashboard/modal.js +3 -9
  38. package/dist/dashboard/modal.mjs +4 -10
  39. package/dist/dashboard/notice.js +3 -5
  40. package/dist/dashboard/notice.mjs +3 -5
  41. package/dist/dashboard/table-cell-title.js +0 -2
  42. package/dist/dashboard/table-cell-title.mjs +0 -2
  43. package/dist/dashboard/table.js +20 -61
  44. package/dist/dashboard/table.mjs +20 -61
  45. package/dist/dashboard/template-dashboard.js +133 -35
  46. package/dist/dashboard/template-dashboard.mjs +134 -36
  47. package/dist/dashboard/template-socket.js +3 -19
  48. package/dist/dashboard/template-socket.mjs +3 -19
  49. package/dist/dashboard/template-ui.js +186 -150
  50. package/dist/dashboard/template-ui.mjs +187 -151
  51. package/dist/shared/lib/helpers.js +2 -9
  52. package/dist/shared/lib/helpers.mjs +2 -9
  53. package/dist/shared/overlay.js +3 -5
  54. package/dist/shared/overlay.mjs +3 -5
  55. package/package.json +13 -28
  56. package/types/dashboard/card-task.d.ts +1 -5
  57. package/types/dashboard/guide.d.ts +23 -0
  58. package/types/dashboard/table.d.ts +1 -3
  59. package/types/dashboard/template-dashboard.d.ts +1 -4
  60. package/types/dashboard/template-ui.d.ts +2 -2
  61. package/dist/dashboard/lib/escape.js +0 -48
  62. package/dist/dashboard/lib/escape.mjs +0 -25
  63. package/dist/dashboard/lib/rail.js +0 -75
  64. package/dist/dashboard/lib/rail.mjs +0 -46
  65. package/dist/dashboard/lib/throttle.js +0 -57
  66. package/dist/dashboard/lib/throttle.mjs +0 -34
  67. package/dist/dashboard/template-rail.js +0 -674
  68. package/dist/dashboard/template-rail.mjs +0 -640
  69. package/dist/icons/book-open.js +0 -46
  70. package/dist/icons/book-open.mjs +0 -27
  71. package/dist/icons/task.js +0 -46
  72. package/dist/icons/task.mjs +0 -27
  73. package/dist/shared/lib/motion.js +0 -27
  74. package/dist/shared/lib/motion.mjs +0 -4
  75. package/types/dashboard/lib/rail.d.ts +0 -32
  76. package/types/dashboard/lib/throttle.d.ts +0 -5
  77. package/types/dashboard/template-rail.d.ts +0 -36
  78. package/types/icons/book-open.d.ts +0 -5
  79. package/types/icons/task.d.ts +0 -5
@@ -1,17 +1,17 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { isValidElement, useEffect, useState } from "react";
2
+ import { isValidElement, useEffect, useRef, useState } from "react";
3
3
  import { keepPreviousData, useIsFetching, useQueryClient } from "@tanstack/react-query";
4
4
  import { notFound } from "next/navigation";
5
+ import { useDrawer } from "./lib/hooks.mjs";
5
6
  import { iconLabel } from "../shared/lib/icon-labels.mjs";
6
7
  import ProviderResource from "./provider-resource.mjs";
7
- import { railFirst } from "./lib/rail.mjs";
8
- import { useRail } from "./template-rail.mjs";
9
8
  import ArrowRight from "../icons/arrow-right.mjs";
10
9
  import LoaderIcon from "../icons/loader.mjs";
11
10
  import Refresh from "../icons/refresh.mjs";
12
11
  import Empty from "../shared/empty.mjs";
13
12
  import Badge from "../shared/badge.mjs";
14
13
  import Button from "../shared/button.mjs";
14
+ import List from "./list.mjs";
15
15
  import LinkBack from "./link-back.mjs";
16
16
  import WrapperGradient from "../wrapper-gradient.mjs";
17
17
  import Image from "next/image";
@@ -340,45 +340,143 @@ const TemplateDashboardError = ({
340
340
  const TemplateDashboardTasks = ({
341
341
  items = []
342
342
  }) => {
343
- const { set } = useRail();
344
- const first = railFirst(items);
345
- if (!first) return null;
346
- return /* @__PURE__ */ jsx(
347
- "div",
348
- {
349
- ...{
350
- className: "px-6 md:px-12"
351
- },
352
- children: /* @__PURE__ */ jsx(
353
- "div",
354
- {
355
- ...{
356
- className: "bg-white border border-gray rounded px-4 py-3"
357
- },
358
- children: /* @__PURE__ */ jsx(
359
- Button,
343
+ const queryClient = useQueryClient();
344
+ const { close, open } = useDrawer({
345
+ queryClient
346
+ });
347
+ const array = [...items];
348
+ const first = array.shift();
349
+ const nextSteps = () => ({
350
+ title: /* @__PURE__ */ jsxs(
351
+ "span",
352
+ {
353
+ ...{
354
+ className: "flex items-center space-x-3"
355
+ },
356
+ children: [
357
+ /* @__PURE__ */ jsx("span", { children: "Next steps" }),
358
+ /* @__PURE__ */ jsx(
359
+ Badge,
360
360
  {
361
361
  ...{
362
- icon: ArrowRight,
363
- justify: "between",
364
- onClick: () => set("next"),
365
- variant: "link"
362
+ type: "warning"
366
363
  },
367
- children: /* @__PURE__ */ jsx(
368
- "span",
369
- {
370
- ...{
371
- className: "flex-1 min-w-0 text-left whitespace-normal hover:underline"
372
- },
373
- children: first.title
374
- }
375
- )
364
+ children: array.length + 1
376
365
  }
377
366
  )
378
- }
379
- )
380
- }
367
+ ]
368
+ }
369
+ ),
370
+ children: /* @__PURE__ */ jsx(
371
+ "div",
372
+ {
373
+ ...{
374
+ className: "p-6"
375
+ },
376
+ children: /* @__PURE__ */ jsx(
377
+ List,
378
+ {
379
+ ...{
380
+ items: [
381
+ {
382
+ ...first,
383
+ onClick: () => close()
384
+ },
385
+ ...array.map((props) => ({
386
+ ...props,
387
+ onClick: () => close()
388
+ }))
389
+ ]
390
+ }
391
+ }
392
+ )
393
+ }
394
+ )
395
+ });
396
+ const shown = useRef(null);
397
+ const openAll = () => {
398
+ const props = nextSteps();
399
+ shown.current = props.children;
400
+ open(props);
401
+ };
402
+ useEffect(
403
+ () => {
404
+ const drawer = queryClient.getQueryData(["drawer"]);
405
+ if (!shown.current || !(drawer == null ? void 0 : drawer.active) || drawer.children !== shown.current) return;
406
+ if (!first) {
407
+ shown.current = null;
408
+ close();
409
+ return;
410
+ }
411
+ openAll();
412
+ },
413
+ // The tasks are the trigger; the rest follows them.
414
+ // eslint-disable-next-line react-hooks/exhaustive-deps
415
+ [items]
381
416
  );
417
+ if (first) {
418
+ return /* @__PURE__ */ jsx(
419
+ "div",
420
+ {
421
+ ...{
422
+ className: "px-6 md:px-12"
423
+ },
424
+ children: /* @__PURE__ */ jsx(
425
+ "div",
426
+ {
427
+ ...{
428
+ className: "bg-white border border-gray rounded px-4 py-3"
429
+ },
430
+ children: /* @__PURE__ */ jsxs(
431
+ "div",
432
+ {
433
+ ...{
434
+ className: "flex items-center justify-between space-x-6"
435
+ },
436
+ children: [
437
+ first && /* @__PURE__ */ jsx(
438
+ List,
439
+ {
440
+ ...{
441
+ items: [
442
+ {
443
+ ...first,
444
+ onClick: () => close()
445
+ }
446
+ ],
447
+ svg: false
448
+ }
449
+ }
450
+ ),
451
+ (array == null ? void 0 : array.length) > 0 && /* @__PURE__ */ jsx(
452
+ Button,
453
+ {
454
+ ...{
455
+ icon: ArrowRight,
456
+ inline: true,
457
+ onClick: openAll,
458
+ variant: "link"
459
+ },
460
+ children: /* @__PURE__ */ jsx(
461
+ Badge,
462
+ {
463
+ ...{
464
+ type: "warning"
465
+ },
466
+ children: array.length + 1
467
+ }
468
+ )
469
+ }
470
+ )
471
+ ]
472
+ }
473
+ )
474
+ }
475
+ )
476
+ }
477
+ );
478
+ }
479
+ return null;
382
480
  };
383
481
  const SETTLE_QUIET = 50;
384
482
  const SETTLE_CAP = 3e3;
@@ -35,11 +35,9 @@ __export(template_socket_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(template_socket_exports);
37
37
  var import_jsx_runtime = require("react/jsx-runtime");
38
- var import_react = require("react");
39
38
  var import_navigation = require("next/navigation");
40
39
  var import_react_query = require("@tanstack/react-query");
41
40
  var import_hooks = require("./lib/hooks");
42
- var import_throttle = require("./lib/throttle");
43
41
  var import_helpers = require("../shared/lib/helpers");
44
42
  var import_template_suspended = __toESM(require("./template-suspended"));
45
43
  const TemplateSocketAccount = ({
@@ -238,15 +236,6 @@ const TemplateSocketOrganization = ({
238
236
  }) => {
239
237
  const params = (0, import_navigation.useParams)();
240
238
  const queryClient = (0, import_react_query.useQueryClient)();
241
- const [refetchNextSteps] = (0, import_react.useState)(() => (0, import_throttle.trailingThrottle)({
242
- wait: 1e4
243
- }));
244
- const refetchOrganization = () => refetchNextSteps(
245
- "organization." + params.organization,
246
- () => queryClient.invalidateQueries({
247
- queryKey: ["organization", params.organization]
248
- })
249
- );
250
239
  const { data: organization } = (0, import_react_query.useQuery)({
251
240
  enabled: false,
252
241
  queryKey: ["organization", params == null ? void 0 : params.organization]
@@ -314,13 +303,6 @@ const TemplateSocketOrganization = ({
314
303
  queryClient.invalidateQueries({
315
304
  queryKey: ["menu", "campaign", params.organization]
316
305
  });
317
- refetchOrganization();
318
- refetchNextSteps(
319
- "menu." + params.organization,
320
- () => queryClient.invalidateQueries({
321
- queryKey: ["menu", "organization", params.organization]
322
- })
323
- );
324
306
  queryClient.invalidateQueries({
325
307
  queryKey: ["organization-affiliate-campaigns"]
326
308
  });
@@ -472,7 +454,9 @@ const TemplateSocketOrganization = ({
472
454
  // emits this whenever a count changes. Refetch the authoritative org doc
473
455
  // + the usage page / dashboard that display those counts.
474
456
  "organization.totals": () => {
475
- refetchOrganization();
457
+ queryClient.invalidateQueries({
458
+ queryKey: ["organization", params.organization]
459
+ });
476
460
  queryClient.invalidateQueries({
477
461
  queryKey: ["organization-usage-chart", params.organization]
478
462
  });
@@ -1,10 +1,8 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useState } from "react";
4
3
  import { useParams } from "next/navigation";
5
4
  import { useQuery, useQueryClient } from "@tanstack/react-query";
6
5
  import { useSocketRoom } from "./lib/hooks.mjs";
7
- import { trailingThrottle } from "./lib/throttle.mjs";
8
6
  import { isAdmin } from "../shared/lib/helpers.mjs";
9
7
  import TemplateSuspended from "./template-suspended.mjs";
10
8
  const TemplateSocketAccount = ({
@@ -203,15 +201,6 @@ const TemplateSocketOrganization = ({
203
201
  }) => {
204
202
  const params = useParams();
205
203
  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
- );
215
204
  const { data: organization } = useQuery({
216
205
  enabled: false,
217
206
  queryKey: ["organization", params == null ? void 0 : params.organization]
@@ -279,13 +268,6 @@ const TemplateSocketOrganization = ({
279
268
  queryClient.invalidateQueries({
280
269
  queryKey: ["menu", "campaign", params.organization]
281
270
  });
282
- refetchOrganization();
283
- refetchNextSteps(
284
- "menu." + params.organization,
285
- () => queryClient.invalidateQueries({
286
- queryKey: ["menu", "organization", params.organization]
287
- })
288
- );
289
271
  queryClient.invalidateQueries({
290
272
  queryKey: ["organization-affiliate-campaigns"]
291
273
  });
@@ -437,7 +419,9 @@ const TemplateSocketOrganization = ({
437
419
  // emits this whenever a count changes. Refetch the authoritative org doc
438
420
  // + the usage page / dashboard that display those counts.
439
421
  "organization.totals": () => {
440
- refetchOrganization();
422
+ queryClient.invalidateQueries({
423
+ queryKey: ["organization", params.organization]
424
+ });
441
425
  queryClient.invalidateQueries({
442
426
  queryKey: ["organization-usage-chart", params.organization]
443
427
  });