@drawbridge/components 0.1.15 → 0.1.17

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 (49) hide show
  1. package/dist/bridge/form-subdomain-missions.js +43 -34
  2. package/dist/bridge/form-subdomain-missions.mjs +43 -34
  3. package/dist/bridge/lib/url.js +3 -3
  4. package/dist/bridge/lib/url.mjs +3 -3
  5. package/dist/bridge/share-button.js +12 -2
  6. package/dist/bridge/share-button.mjs +12 -2
  7. package/dist/bridge/template-layout.js +1 -1
  8. package/dist/bridge/template-layout.mjs +1 -1
  9. package/dist/dashboard/answer-rows.js +77 -0
  10. package/dist/dashboard/answer-rows.mjs +41 -0
  11. package/dist/dashboard/card-order.js +186 -243
  12. package/dist/dashboard/card-order.mjs +186 -243
  13. package/dist/dashboard/form-organization-campaign-agreement.js +2 -2
  14. package/dist/dashboard/form-organization-campaign-agreement.mjs +2 -2
  15. package/dist/dashboard/form-organization-campaign-field-list.js +8 -49
  16. package/dist/dashboard/form-organization-campaign-field-list.mjs +8 -49
  17. package/dist/dashboard/form-organization-workflow.js +588 -157
  18. package/dist/dashboard/form-organization-workflow.mjs +578 -157
  19. package/dist/dashboard/form-otc.js +7 -4
  20. package/dist/dashboard/form-otc.mjs +8 -5
  21. package/dist/dashboard/input-editor.js +46 -10
  22. package/dist/dashboard/input-editor.mjs +44 -9
  23. package/dist/dashboard/item-row.js +92 -0
  24. package/dist/dashboard/item-row.mjs +63 -0
  25. package/dist/dashboard/lib/sms.js +3 -0
  26. package/dist/dashboard/lib/sms.mjs +2 -0
  27. package/dist/dashboard/order-sections.js +231 -0
  28. package/dist/dashboard/order-sections.mjs +196 -0
  29. package/dist/dashboard/preview.js +29 -2
  30. package/dist/dashboard/preview.mjs +28 -2
  31. package/dist/dashboard/steps.js +5 -0
  32. package/dist/dashboard/steps.mjs +5 -0
  33. package/dist/dashboard/template-socket.js +6 -0
  34. package/dist/dashboard/template-socket.mjs +6 -0
  35. package/dist/input-code.js +2 -8
  36. package/dist/input-code.mjs +2 -8
  37. package/dist/shared/lib/helpers.js +7 -0
  38. package/dist/shared/lib/helpers.mjs +7 -0
  39. package/package.json +19 -4
  40. package/types/bridge/lib/url.d.ts +5 -4
  41. package/types/dashboard/answer-rows.d.ts +30 -0
  42. package/types/dashboard/card-order.d.ts +16 -14
  43. package/types/dashboard/form-organization-workflow.d.ts +46 -0
  44. package/types/dashboard/input-editor.d.ts +7 -1
  45. package/types/dashboard/item-row.d.ts +25 -0
  46. package/types/dashboard/order-sections.d.ts +36 -0
  47. package/types/dashboard/steps.d.ts +2 -0
  48. package/types/input-code.d.ts +0 -2
  49. package/types/shared/lib/helpers.d.ts +1 -1
@@ -261,6 +261,13 @@ const statuses = {
261
261
  member: {
262
262
  pending: { text: "Invited", type: "warning" }
263
263
  },
264
+ // @story campaigns/manage-order
265
+ // A form order's badge beside its customer on Orders: only a closed order
266
+ // shows one, Canceled red as a canceled subscription is.
267
+ order: {
268
+ canceled: { text: "Canceled", type: "error" },
269
+ completed: { text: "Completed", type: "success" }
270
+ },
264
271
  organization: Object.fromEntries(organizationStatuses.map((status) => [status, { text: capitalize(status.replace("_", " ")), type: ["active", "unsubscribed"].includes(status) ? "success" : status === "paused" ? "warning" : "error" }])),
265
272
  page: published,
266
273
  prize: published,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -172,6 +172,11 @@
172
172
  "import": "./dist/dashboard/accordion.mjs",
173
173
  "default": "./dist/dashboard/accordion.js"
174
174
  },
175
+ "./dashboard/answer-rows": {
176
+ "types": "./types/dashboard/answer-rows.d.ts",
177
+ "import": "./dist/dashboard/answer-rows.mjs",
178
+ "default": "./dist/dashboard/answer-rows.js"
179
+ },
175
180
  "./dashboard/avatar": {
176
181
  "types": "./types/dashboard/avatar.d.ts",
177
182
  "import": "./dist/dashboard/avatar.mjs",
@@ -747,6 +752,11 @@
747
752
  "import": "./dist/dashboard/input-time.mjs",
748
753
  "default": "./dist/dashboard/input-time.js"
749
754
  },
755
+ "./dashboard/item-row": {
756
+ "types": "./types/dashboard/item-row.d.ts",
757
+ "import": "./dist/dashboard/item-row.mjs",
758
+ "default": "./dist/dashboard/item-row.js"
759
+ },
750
760
  "./dashboard/lib/confetti": {
751
761
  "types": "./types/dashboard/lib/confetti.d.ts",
752
762
  "import": "./dist/dashboard/lib/confetti.mjs",
@@ -882,6 +892,11 @@
882
892
  "import": "./dist/dashboard/notice.mjs",
883
893
  "default": "./dist/dashboard/notice.js"
884
894
  },
895
+ "./dashboard/order-sections": {
896
+ "types": "./types/dashboard/order-sections.d.ts",
897
+ "import": "./dist/dashboard/order-sections.mjs",
898
+ "default": "./dist/dashboard/order-sections.js"
899
+ },
885
900
  "./dashboard/paged": {
886
901
  "types": "./types/dashboard/paged.d.ts",
887
902
  "import": "./dist/dashboard/paged.mjs",
@@ -1648,7 +1663,7 @@
1648
1663
  "peerDependencies": {
1649
1664
  "@analytics/google-tag-manager": ">=0.5.5",
1650
1665
  "@drawbridge/drawbridge-telemetry": ">=0.0.19",
1651
- "@drawbridge/drawbridge-utils": ">=0.0.225",
1666
+ "@drawbridge/drawbridge-utils": ">=0.0.229",
1652
1667
  "@headlessui/react": ">=2.1.2",
1653
1668
  "@hookform/resolvers": ">=3.1.1",
1654
1669
  "@sentry/nextjs": ">=10.58.0",
@@ -1766,9 +1781,9 @@
1766
1781
  },
1767
1782
  "devDependencies": {
1768
1783
  "@analytics/google-tag-manager": "0.5.5",
1769
- "@drawbridge/drawbridge-agents": "0.1.98",
1784
+ "@drawbridge/drawbridge-agents": "0.1.102",
1770
1785
  "@drawbridge/drawbridge-telemetry": "0.0.19",
1771
- "@drawbridge/drawbridge-utils": "0.0.225",
1786
+ "@drawbridge/drawbridge-utils": "0.0.229",
1772
1787
  "@headlessui/react": "2.2.9",
1773
1788
  "@hookform/resolvers": "3.1.1",
1774
1789
  "@sentry/nextjs": "10.58.0",
@@ -20,10 +20,10 @@ export declare const submissionEndpoint: ( props: {
20
20
  token?: string;
21
21
  } ) => string | null;
22
22
 
23
- // Where a lead's own link (`?lead=<token>`) asks for their entries, or null
24
- // when `lead` is not a lead token. `token` is the owner's preview token.
23
+ // Where a lead's own link (`?m=<code>`) asks for their entries, or null
24
+ // when `code` is not a missions code. `token` is the owner's preview token.
25
25
  export declare const leadEndpoint: ( props: {
26
- lead: string | null | undefined;
26
+ code: string | null | undefined;
27
27
  slug: string;
28
28
  subdomain: string;
29
29
  token?: string | null;
@@ -31,7 +31,8 @@ export declare const leadEndpoint: ( props: {
31
31
 
32
32
  // Where the missions panel takes a mission's action: one route for every
33
33
  // mission, the action one its completion declares (a code mission sends and
34
- // confirms). The lead's own token goes in the request body, not the path.
34
+ // confirms). The lead's missions code goes in the request body as `token`,
35
+ // not the path.
35
36
  export declare const missionEndpoint: ( props: {
36
37
  action: string;
37
38
  slug: string;
@@ -0,0 +1,30 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+
3
+ export interface AnswerField {
4
+ deleted?: boolean;
5
+ id: string;
6
+ label?: string;
7
+ slug?: string;
8
+ type?: 'additional' | 'lead' | 'order' | string;
9
+ }
10
+
11
+ export interface Answer {
12
+ reference: string;
13
+ value?: unknown;
14
+ }
15
+
16
+ export interface AnswerRow {
17
+ label?: string;
18
+ value: ReactNode;
19
+ }
20
+
21
+ export declare const blank: ( value: unknown ) => boolean;
22
+
23
+ // An answer as it reads: an em dash for none, an object's values joined.
24
+ export declare const display: ( value: unknown ) => string;
25
+
26
+ // A removed field's answer: struck through, with a small Removed badge.
27
+ export declare const Removed: ComponentType<{ children?: ReactNode }>;
28
+
29
+ // One type of field's rows, in the Form page's order; a removed field only where it was answered.
30
+ export declare const answerRows: ( fields?: AnswerField[], answers?: Answer[] ) => ( type: string ) => AnswerRow[];
@@ -1,6 +1,10 @@
1
- import { ComponentType } from 'react';
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { Answer, AnswerField } from './answer-rows';
3
+ import { ItemRowFile } from './item-row';
2
4
 
3
5
  export interface CardOrderLine {
6
+ // A form line's item file, or a store line's product image url.
7
+ image?: ItemRowFile | string | null;
4
8
  price?: number;
5
9
  quantity?: number;
6
10
  title?: string;
@@ -16,31 +20,29 @@ export interface CardOrderProvider {
16
20
  slug?: string;
17
21
  }
18
22
 
19
- export interface CardOrderCustomer {
20
- email?: string | null;
21
- firstName?: string | null;
22
- lastName?: string | null;
23
- phone?: string | null;
24
- }
25
-
26
23
  export interface CardOrderProps {
24
+ // A form order's submission answers.
25
+ answers?: Answer[];
26
+ // A form order: drawn under its Status row ( the page's Fulfillment section ).
27
+ children?: ReactNode;
28
+ // A form order: drawn at the Status row's right ( the page's three dots ).
29
+ cta?: ReactNode;
27
30
  // ISO code, lower or upper case; defaults to usd.
28
31
  currency?: string;
29
- // A form order's customer, shown in its drawer.
30
- customer?: CardOrderCustomer | null;
31
32
  fee?: number;
33
+ // A form order: the campaign's fields, removed ones included.
34
+ fields?: AnswerField[];
32
35
  gross?: number;
33
36
  lines?: CardOrderLine[];
34
37
  net?: number;
35
- // A form order's note and pickup.
36
- note?: string | null;
37
- pickup?: string | null;
38
38
  provider?: CardOrderProvider;
39
39
  purchasedAt?: string | number | Date;
40
40
  // Fee rate in percent; not shown for a redemption.
41
41
  rate?: number | null;
42
+ // A form order's status.
43
+ status?: 'canceled' | 'completed' | 'open' | string;
42
44
  // Picks the attribution sentence; anything but 'redemption' reads as a campaign
43
- // order. 'form' shows a form order: who ordered, pickup, note, no fee.
45
+ // order. 'form' shows a form order: its status, items and answers.
44
46
  type?: 'conversion' | 'form' | 'redemption' | string;
45
47
  }
46
48
 
@@ -9,6 +9,9 @@ export interface FormOrganizationWorkflowStep {
9
9
  enabled?: boolean;
10
10
  settings?: {
11
11
  discount?: { id: string; title?: string; [ key: string ]: unknown } | null;
12
+ // Auto response's two parts ( step.response.send ).
13
+ email?: { enabled: boolean; message?: string; score?: Record<string, unknown> | null; subject?: string; text?: string };
14
+ sms?: { enabled: boolean; message?: string };
12
15
  // Member ids; the owner is always a recipient and is never stored.
13
16
  members?: string[];
14
17
  message?: string;
@@ -24,6 +27,27 @@ export interface FormOrganizationWorkflowStep {
24
27
  type?: string;
25
28
  }
26
29
 
30
+ // Auto response's two parts, as a row holds them.
31
+ export interface ResponseSettings {
32
+ email: { enabled: boolean; message: string; score: Record<string, unknown> | null; subject: string; text: string };
33
+ sms: { enabled: boolean; message: string };
34
+ }
35
+
36
+ // What the trigger page's read carries for the Auto response card, on When a lead enters.
37
+ export interface AutoResponseFacts {
38
+ fields: { email: boolean; phone: boolean };
39
+ number: null | 'pending' | 'verifying' | 'verified' | 'error';
40
+ placeholders: null | { missions?: string; order?: string };
41
+ }
42
+
43
+ // What one part can do on this campaign, and the card under its switch.
44
+ export interface ResponsePart {
45
+ can: boolean;
46
+ hidden: boolean;
47
+ on: boolean;
48
+ task: { button?: { href: string; text: string }; message: string; type?: 'warning' | 'error' } | null;
49
+ }
50
+
27
51
  // The row shape the editor seeds each step with.
28
52
  export interface FormOrganizationWorkflowRow {
29
53
  confirmation: boolean;
@@ -33,6 +57,8 @@ export interface FormOrganizationWorkflowRow {
33
57
  members: Record<string, unknown>[];
34
58
  message: string;
35
59
  score: Record<string, unknown> | null;
60
+ // Auto response's parts; null on every other row.
61
+ settings: ResponseSettings | null;
36
62
  slug: string;
37
63
  subject: string;
38
64
  text: string;
@@ -73,6 +99,7 @@ export interface FormOrganizationWorkflowEditProps extends Callbacks {
73
99
  // The trigger page read's `catalog`: the steps this trigger offers.
74
100
  catalog?: WorkflowCatalogEntry | null;
75
101
  values: {
102
+ autoResponse?: AutoResponseFacts;
76
103
  campaign: string;
77
104
  // Sync's run-time issue, shown on the first step of `step`'s type.
78
105
  issue?: { message?: string; step?: string } | null;
@@ -109,9 +136,28 @@ export declare const prefillRow: ( options: { entry?: WorkflowCatalogEntry | nul
109
136
  // from the catalog entry or the saved steps; null when the step can run.
110
137
  export declare const stepReason: ( options: { entry?: WorkflowCatalogEntry | null; saved?: Array<{ reason?: string; type?: string; [ key: string ]: unknown }>; type?: string } ) => string | null;
111
138
 
139
+ // The stored type of Auto response.
140
+ export declare const RESPONSE: 'step.response.send';
141
+ // Auto response's settings as on a new campaign: `number` is the number's status.
142
+ export declare const responseStart: ( number?: AutoResponseFacts[ 'number' ] ) => ResponseSettings;
143
+ // What each part can do on this campaign, and whether any can.
144
+ export declare const responseParts: ( options: { autoResponse?: AutoResponseFacts; campaign: string; organization: string; settings?: ResponseSettings | null } ) => { can: boolean; email: ResponsePart; sms: ResponsePart };
145
+ // What the save sends for an Auto response: both parts whole.
146
+ export declare const responseSave: ( settings: ResponseSettings ) => FormOrganizationWorkflowStep[ 'settings' ];
147
+ // The plain text as editor html, a bracketed line as the variable chip.
148
+ export declare const plainHtml: ( text?: string ) => string;
149
+ // The step's own switch after a part's switch moves.
150
+ export declare const stepAfterPart: ( args: { enabled?: boolean; next: boolean; other?: boolean } ) => boolean;
151
+ // The part the step's own switch turns on, or null when a part already sends.
152
+ export declare const partToStart: ( parts: ReturnType<typeof responseParts> ) => 'email' | 'sms' | null;
153
+ // The row a run-time issue sits under, or -1.
154
+ export declare const issueRow: ( args: { issue?: { step?: string } | null; steps?: Array<{ type?: string }> } ) => number;
155
+
112
156
  // The sample lead every step preview draws from.
113
157
  export declare const SAMPLE: { email: string; name: string; order: string; phone: string };
114
158
  // The JSON a Send webhook posts, for the sample lead.
115
159
  export declare const webhookSample: ( args: { campaign?: { id?: string; title?: string } | null } ) => string;
160
+ // A text as a phone shows it: who it is from, then the bubble holding `children`.
161
+ export declare const TextPreview: ComponentType<{ children?: import( 'react' ).ReactNode; from?: string | null }>;
116
162
  // The team email's title and lines, for a new entry or an order.
117
163
  export declare const teamSample: ( args: { campaign?: { title?: string } | null; event?: string; organization?: { title?: string } | null } ) => { lines: string[]; title: string };
@@ -1,4 +1,4 @@
1
- import { ComponentType } from 'react';
1
+ import { ComponentType, ReactNode } from 'react';
2
2
  import { Node } from '@tiptap/core';
3
3
 
4
4
  export interface InputEditorVariable {
@@ -9,6 +9,10 @@ export interface InputEditorVariable {
9
9
 
10
10
  export interface InputEditorProps {
11
11
  disabled?: boolean;
12
+ // Sits under what is typed, outside the document, so it cannot be removed.
13
+ locked?: ReactNode;
14
+ // No toolbar; `value` and the emitted `text` are plain text.
15
+ plain?: boolean;
12
16
  // Both renderings; pass `html` to a react-hook-form field, not the object.
13
17
  onChange?: ( value: { html: string; text: string } ) => void;
14
18
  // HTML.
@@ -25,6 +29,8 @@ export declare const Variable: Node;
25
29
  // The text serializer that keeps a link's address in the plain rendering.
26
30
  export declare const linkText: ( props: { node: any; parent: any; index: number } ) => string;
27
31
 
32
+ export declare const plainContent: ( value?: string ) => string;
33
+
28
34
  export declare const EditorView: ComponentType<EditorViewProps>;
29
35
 
30
36
  declare const InputEditor: ComponentType<InputEditorProps>;
@@ -0,0 +1,25 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+
3
+ export interface ItemRowFile {
4
+ filename?: string;
5
+ id?: string;
6
+ mimetype?: string;
7
+ sizes?: Record<string, string>;
8
+ updatedAt?: string | number | Date;
9
+ }
10
+
11
+ export interface ItemRowProps {
12
+ // The image's alt text; falls back to the file's name, then the item's name.
13
+ description?: string | null;
14
+ // A sortable list's drag handle, drawn first.
15
+ handle?: ReactNode;
16
+ // An uploaded file, or a store's image url; a grey square without one.
17
+ image?: ItemRowFile | string | null;
18
+ name?: ReactNode;
19
+ // The grey line under the name.
20
+ summary?: ReactNode;
21
+ }
22
+
23
+ declare const ItemRow: ComponentType<ItemRowProps>;
24
+
25
+ export default ItemRow;
@@ -0,0 +1,36 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ export interface ConfirmOptions {
4
+ // The dialog's title and its button.
5
+ action: string;
6
+ body?: Record<string, unknown>;
7
+ endpoint: string;
8
+ // The one sentence saying what happens.
9
+ message?: string;
10
+ method?: 'DELETE' | 'POST' | 'PUT';
11
+ onSuccess?: ( response: unknown ) => void;
12
+ // Why the action is blocked: shown as a warning, the button disabled.
13
+ task?: string;
14
+ }
15
+
16
+ export declare const useConfirm: () => ( options: ConfirmOptions ) => void;
17
+
18
+ export interface FulfillmentOrder {
19
+ fulfillment?: { status?: 'fulfilled' | 'unfulfilled' | string } | null;
20
+ id?: string;
21
+ status?: 'canceled' | 'completed' | 'open' | string;
22
+ }
23
+
24
+ export declare const fulfillmentControls: ( options: { manage?: boolean; order?: FulfillmentOrder | null } ) => { add: boolean; cancel: boolean };
25
+
26
+ export interface OrderFulfillmentProps {
27
+ // The organization's order: /organization/:organization/order/:order.
28
+ endpoint: string;
29
+ // Manage access to Leads.
30
+ manage?: boolean;
31
+ // Gets the saved order after a confirmed change.
32
+ onSuccess?: ( response: unknown ) => void;
33
+ order: FulfillmentOrder;
34
+ }
35
+
36
+ export declare const OrderFulfillment: ComponentType<OrderFulfillmentProps>;
@@ -5,6 +5,8 @@ export type StepStatus = 'cancelled' | 'failed' | 'partial' | 'processing' | 'sk
5
5
  export interface StepRow {
6
6
  error?: string | null;
7
7
  message?: string | null;
8
+ // An Auto response's part: its row names the part.
9
+ part?: 'email' | 'sms' | null;
8
10
  request?: unknown;
9
11
  response?: unknown;
10
12
  slug?: string;
@@ -10,8 +10,6 @@ export interface InputCodeProps {
10
10
  name?: string;
11
11
  // The digits typed so far, never anything but digits.
12
12
  onChange?: ( value: string ) => void;
13
- // Called with the code when its last digit lands.
14
- onComplete?: ( value: string ) => void;
15
13
  style?: BrandStyle;
16
14
  value?: string;
17
15
  }
@@ -127,7 +127,7 @@ export declare const usageBadge: ( allowance: Allowance | null | undefined ) =>
127
127
  // @story admin/organizations-list
128
128
  export declare const acceptingBadge: ( accepting: Accepting | null | undefined ) => Badge | null;
129
129
 
130
- export type StatusKind = 'advertisement' | 'campaign' | 'connection' | 'draw' | 'invoice' | 'member' | 'organization' | 'page' | 'prize' | 'range' | 'subscription' | 'workflow';
130
+ export type StatusKind = 'advertisement' | 'campaign' | 'connection' | 'draw' | 'invoice' | 'member' | 'order' | 'organization' | 'page' | 'prize' | 'range' | 'subscription' | 'workflow';
131
131
 
132
132
  // The badge beside a table title: each kind says which of its statuses get one; null for the rest.
133
133
  export declare const statusBadge: ( kind: StatusKind, status: string | null | undefined ) => Badge | null;