@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
@@ -126,10 +126,10 @@ const FormOtcConfirm = ({
126
126
  values
127
127
  });
128
128
  const onSubmit = (0, import_react.useCallback)(async ({
129
- code
129
+ code: code2
130
130
  }) => {
131
131
  try {
132
- const response = await callback(code);
132
+ const response = await callback(code2);
133
133
  onSuccess(response);
134
134
  } catch (error) {
135
135
  setError(
@@ -141,6 +141,10 @@ const FormOtcConfirm = ({
141
141
  );
142
142
  }
143
143
  }, [callback, onSuccess, setError]);
144
+ const code = (0, import_form.useWatch)({
145
+ control,
146
+ name: "code"
147
+ });
144
148
  const autoSubmitted = (0, import_react.useRef)(false);
145
149
  (0, import_react.useEffect)(() => {
146
150
  if ((values == null ? void 0 : values.code) && !autoSubmitted.current) {
@@ -182,8 +186,6 @@ const FormOtcConfirm = ({
182
186
  ...{
183
187
  autoFocus: true,
184
188
  onChange,
185
- // The sixth digit confirms, as on the missions panel.
186
- onComplete: () => handleSubmit(onSubmit)(),
187
189
  value: value || ""
188
190
  }
189
191
  }
@@ -208,6 +210,7 @@ const FormOtcConfirm = ({
208
210
  import_button.default,
209
211
  {
210
212
  ...{
213
+ disabled: String(code || "").length !== 6,
211
214
  loading: formState == null ? void 0 : formState.isSubmitting,
212
215
  type: "submit"
213
216
  },
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { request } from "@drawbridge/drawbridge-utils/fetch";
4
- import { useForm, Controller } from "../shared/lib/form.mjs";
4
+ import { useForm, useWatch, Controller } from "../shared/lib/form.mjs";
5
5
  import yup, { resolver } from "../shared/lib/yup.mjs";
6
6
  import Form from "../shared/form.mjs";
7
7
  import Fieldset from "../shared/fieldset.mjs";
@@ -93,10 +93,10 @@ const FormOtcConfirm = ({
93
93
  values
94
94
  });
95
95
  const onSubmit = useCallback(async ({
96
- code
96
+ code: code2
97
97
  }) => {
98
98
  try {
99
- const response = await callback(code);
99
+ const response = await callback(code2);
100
100
  onSuccess(response);
101
101
  } catch (error) {
102
102
  setError(
@@ -108,6 +108,10 @@ const FormOtcConfirm = ({
108
108
  );
109
109
  }
110
110
  }, [callback, onSuccess, setError]);
111
+ const code = useWatch({
112
+ control,
113
+ name: "code"
114
+ });
111
115
  const autoSubmitted = useRef(false);
112
116
  useEffect(() => {
113
117
  if ((values == null ? void 0 : values.code) && !autoSubmitted.current) {
@@ -149,8 +153,6 @@ const FormOtcConfirm = ({
149
153
  ...{
150
154
  autoFocus: true,
151
155
  onChange,
152
- // The sixth digit confirms, as on the missions panel.
153
- onComplete: () => handleSubmit(onSubmit)(),
154
156
  value: value || ""
155
157
  }
156
158
  }
@@ -175,6 +177,7 @@ const FormOtcConfirm = ({
175
177
  Button,
176
178
  {
177
179
  ...{
180
+ disabled: String(code || "").length !== 6,
178
181
  loading: formState == null ? void 0 : formState.isSubmitting,
179
182
  type: "submit"
180
183
  },
@@ -31,7 +31,8 @@ __export(input_editor_exports, {
31
31
  EditorView: () => EditorView,
32
32
  Variable: () => Variable,
33
33
  default: () => input_editor_default,
34
- linkText: () => linkText
34
+ linkText: () => linkText,
35
+ plainContent: () => plainContent
35
36
  });
36
37
  module.exports = __toCommonJS(input_editor_exports);
37
38
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -41,6 +42,7 @@ var import_menus = require("@tiptap/react/menus");
41
42
  var import_state = require("@tiptap/pm/state");
42
43
  var import_core = require("@tiptap/core");
43
44
  var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
45
+ var import_html = require("@drawbridge/drawbridge-utils/html");
44
46
  var import_dropdown = __toESM(require("./dropdown"));
45
47
  var import_bold = __toESM(require("../icons/bold"));
46
48
  var import_italic = __toESM(require("../icons/italic"));
@@ -92,6 +94,27 @@ const extensions = [
92
94
  Variable
93
95
  ];
94
96
  const contentClass = "focus:outline-hidden [&_a]:underline";
97
+ const plainExtensions = [
98
+ import_starter_kit.default.configure({
99
+ blockquote: false,
100
+ bold: false,
101
+ bulletList: false,
102
+ code: false,
103
+ codeBlock: false,
104
+ heading: false,
105
+ horizontalRule: false,
106
+ italic: false,
107
+ link: false,
108
+ listItem: false,
109
+ orderedList: false,
110
+ strike: false,
111
+ underline: false
112
+ })
113
+ ];
114
+ const plainOptions = {
115
+ blockSeparator: "\n"
116
+ };
117
+ const plainContent = (value) => String(value || "").split("\n").map((line) => "<p>" + (0, import_html.escapeHtml)(line) + "</p>").join("");
95
118
  const EditorView = ({ value }) => {
96
119
  const editor = (0, import_react2.useEditor)({
97
120
  content: value || "",
@@ -115,7 +138,9 @@ const EditorView = ({ value }) => {
115
138
  };
116
139
  const InputEditor = ({
117
140
  disabled,
141
+ locked,
118
142
  onChange,
143
+ plain,
119
144
  value,
120
145
  variables
121
146
  }) => {
@@ -124,8 +149,8 @@ const InputEditor = ({
124
149
  const linkInput = (0, import_react.useRef)(null);
125
150
  const [draft, setDraft] = (0, import_react.useState)(null);
126
151
  const editor = (0, import_react2.useEditor)({
127
- extensions,
128
- content: value || "",
152
+ extensions: plain ? plainExtensions : extensions,
153
+ content: plain ? plainContent(value) : value || "",
129
154
  editable: !disabled,
130
155
  editorProps: {
131
156
  attributes: {
@@ -134,7 +159,7 @@ const InputEditor = ({
134
159
  },
135
160
  immediatelyRender: false,
136
161
  onUpdate: ({ editor: editor2 }) => {
137
- onChange == null ? void 0 : onChange({ html: editor2.getHTML(), text: editor2.getText({ textSerializers: { text: linkText } }) });
162
+ onChange == null ? void 0 : onChange({ html: editor2.getHTML(), text: editor2.getText(plain ? plainOptions : { textSerializers: { text: linkText } }) });
138
163
  forceUpdate((n) => n + 1);
139
164
  },
140
165
  onSelectionUpdate: () => {
@@ -192,11 +217,11 @@ const InputEditor = ({
192
217
  (0, import_react.useEffect)(
193
218
  () => {
194
219
  if (!editor) return;
195
- if (value !== editor.getHTML()) {
196
- editor.commands.setContent(value || "", { emitUpdate: false });
220
+ if (plain ? (value || "") !== editor.getText(plainOptions) : value !== editor.getHTML()) {
221
+ editor.commands.setContent(plain ? plainContent(value) : value || "", { emitUpdate: false });
197
222
  }
198
223
  },
199
- [editor, value]
224
+ [editor, plain, value]
200
225
  );
201
226
  const tool = "flex items-center justify-center w-6 h-6 rounded hover:bg-gray";
202
227
  const active = "bg-green-dark hover:bg-green-dark";
@@ -210,7 +235,7 @@ const InputEditor = ({
210
235
  className: ["w-full border border-inherit rounded overflow-hidden", disabled ? "disabled" : ""].join(" ").trim()
211
236
  },
212
237
  children: [
213
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
238
+ !plain && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
214
239
  "div",
215
240
  {
216
241
  ...{
@@ -388,7 +413,17 @@ const InputEditor = ({
388
413
  }
389
414
  }
390
415
  ),
391
- editor && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
416
+ locked && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
417
+ "div",
418
+ {
419
+ ...{
420
+ className: "px-3 pb-2 select-none",
421
+ contentEditable: false
422
+ },
423
+ children: locked
424
+ }
425
+ ),
426
+ editor && !plain && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
392
427
  import_menus.BubbleMenu,
393
428
  {
394
429
  ...{
@@ -472,5 +507,6 @@ var input_editor_default = InputEditor;
472
507
  0 && (module.exports = {
473
508
  EditorView,
474
509
  Variable,
475
- linkText
510
+ linkText,
511
+ plainContent
476
512
  });
@@ -6,6 +6,7 @@ import { BubbleMenu } from "@tiptap/react/menus";
6
6
  import { TextSelection } from "@tiptap/pm/state";
7
7
  import { Node, mergeAttributes } from "@tiptap/core";
8
8
  import StarterKit from "@tiptap/starter-kit";
9
+ import { escapeHtml } from "@drawbridge/drawbridge-utils/html";
9
10
  const Variable = Node.create({
10
11
  name: "variable",
11
12
  group: "inline",
@@ -57,6 +58,27 @@ const extensions = [
57
58
  Variable
58
59
  ];
59
60
  const contentClass = "focus:outline-hidden [&_a]:underline";
61
+ const plainExtensions = [
62
+ StarterKit.configure({
63
+ blockquote: false,
64
+ bold: false,
65
+ bulletList: false,
66
+ code: false,
67
+ codeBlock: false,
68
+ heading: false,
69
+ horizontalRule: false,
70
+ italic: false,
71
+ link: false,
72
+ listItem: false,
73
+ orderedList: false,
74
+ strike: false,
75
+ underline: false
76
+ })
77
+ ];
78
+ const plainOptions = {
79
+ blockSeparator: "\n"
80
+ };
81
+ const plainContent = (value) => String(value || "").split("\n").map((line) => "<p>" + escapeHtml(line) + "</p>").join("");
60
82
  const EditorView = ({ value }) => {
61
83
  const editor = useEditor({
62
84
  content: value || "",
@@ -80,7 +102,9 @@ const EditorView = ({ value }) => {
80
102
  };
81
103
  const InputEditor = ({
82
104
  disabled,
105
+ locked,
83
106
  onChange,
107
+ plain,
84
108
  value,
85
109
  variables
86
110
  }) => {
@@ -89,8 +113,8 @@ const InputEditor = ({
89
113
  const linkInput = useRef(null);
90
114
  const [draft, setDraft] = useState(null);
91
115
  const editor = useEditor({
92
- extensions,
93
- content: value || "",
116
+ extensions: plain ? plainExtensions : extensions,
117
+ content: plain ? plainContent(value) : value || "",
94
118
  editable: !disabled,
95
119
  editorProps: {
96
120
  attributes: {
@@ -99,7 +123,7 @@ const InputEditor = ({
99
123
  },
100
124
  immediatelyRender: false,
101
125
  onUpdate: ({ editor: editor2 }) => {
102
- onChange == null ? void 0 : onChange({ html: editor2.getHTML(), text: editor2.getText({ textSerializers: { text: linkText } }) });
126
+ onChange == null ? void 0 : onChange({ html: editor2.getHTML(), text: editor2.getText(plain ? plainOptions : { textSerializers: { text: linkText } }) });
103
127
  forceUpdate((n) => n + 1);
104
128
  },
105
129
  onSelectionUpdate: () => {
@@ -157,11 +181,11 @@ const InputEditor = ({
157
181
  useEffect(
158
182
  () => {
159
183
  if (!editor) return;
160
- if (value !== editor.getHTML()) {
161
- editor.commands.setContent(value || "", { emitUpdate: false });
184
+ if (plain ? (value || "") !== editor.getText(plainOptions) : value !== editor.getHTML()) {
185
+ editor.commands.setContent(plain ? plainContent(value) : value || "", { emitUpdate: false });
162
186
  }
163
187
  },
164
- [editor, value]
188
+ [editor, plain, value]
165
189
  );
166
190
  const tool = "flex items-center justify-center w-6 h-6 rounded hover:bg-gray";
167
191
  const active = "bg-green-dark hover:bg-green-dark";
@@ -175,7 +199,7 @@ const InputEditor = ({
175
199
  className: ["w-full border border-inherit rounded overflow-hidden", disabled ? "disabled" : ""].join(" ").trim()
176
200
  },
177
201
  children: [
178
- /* @__PURE__ */ jsxs(
202
+ !plain && /* @__PURE__ */ jsxs(
179
203
  "div",
180
204
  {
181
205
  ...{
@@ -353,7 +377,17 @@ const InputEditor = ({
353
377
  }
354
378
  }
355
379
  ),
356
- editor && /* @__PURE__ */ jsxs(
380
+ locked && /* @__PURE__ */ jsx(
381
+ "div",
382
+ {
383
+ ...{
384
+ className: "px-3 pb-2 select-none",
385
+ contentEditable: false
386
+ },
387
+ children: locked
388
+ }
389
+ ),
390
+ editor && !plain && /* @__PURE__ */ jsxs(
357
391
  BubbleMenu,
358
392
  {
359
393
  ...{
@@ -437,5 +471,6 @@ export {
437
471
  EditorView,
438
472
  Variable,
439
473
  input_editor_default as default,
440
- linkText
474
+ linkText,
475
+ plainContent
441
476
  };
@@ -0,0 +1,92 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var item_row_exports = {};
29
+ __export(item_row_exports, {
30
+ default: () => item_row_default
31
+ });
32
+ module.exports = __toCommonJS(item_row_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_card_asset = __toESM(require("../shared/card-asset"));
35
+ const ItemRow = ({
36
+ description,
37
+ handle,
38
+ image,
39
+ name,
40
+ summary
41
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
42
+ "div",
43
+ {
44
+ ...{
45
+ className: "flex items-center min-w-0 flex-1 gap-3"
46
+ },
47
+ children: [
48
+ handle,
49
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
50
+ import_card_asset.default,
51
+ {
52
+ ...{
53
+ asset: image || null,
54
+ className: "w-10 h-10",
55
+ classNameContainer: "bg-gray-light border border-gray",
56
+ sizes: "40px",
57
+ title: description || (image == null ? void 0 : image.filename) || name
58
+ }
59
+ }
60
+ ),
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
62
+ "span",
63
+ {
64
+ ...{
65
+ className: "flex flex-col min-w-0"
66
+ },
67
+ children: [
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ "span",
70
+ {
71
+ ...{
72
+ className: "truncate"
73
+ },
74
+ children: name
75
+ }
76
+ ),
77
+ summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
+ "span",
79
+ {
80
+ ...{
81
+ className: "text-sm text-gray-dark truncate"
82
+ },
83
+ children: summary
84
+ }
85
+ )
86
+ ]
87
+ }
88
+ )
89
+ ]
90
+ }
91
+ );
92
+ var item_row_default = ItemRow;
@@ -0,0 +1,63 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import CardAsset from "../shared/card-asset.mjs";
3
+ const ItemRow = ({
4
+ description,
5
+ handle,
6
+ image,
7
+ name,
8
+ summary
9
+ }) => /* @__PURE__ */ jsxs(
10
+ "div",
11
+ {
12
+ ...{
13
+ className: "flex items-center min-w-0 flex-1 gap-3"
14
+ },
15
+ children: [
16
+ handle,
17
+ /* @__PURE__ */ jsx(
18
+ CardAsset,
19
+ {
20
+ ...{
21
+ asset: image || null,
22
+ className: "w-10 h-10",
23
+ classNameContainer: "bg-gray-light border border-gray",
24
+ sizes: "40px",
25
+ title: description || (image == null ? void 0 : image.filename) || name
26
+ }
27
+ }
28
+ ),
29
+ /* @__PURE__ */ jsxs(
30
+ "span",
31
+ {
32
+ ...{
33
+ className: "flex flex-col min-w-0"
34
+ },
35
+ children: [
36
+ /* @__PURE__ */ jsx(
37
+ "span",
38
+ {
39
+ ...{
40
+ className: "truncate"
41
+ },
42
+ children: name
43
+ }
44
+ ),
45
+ summary && /* @__PURE__ */ jsx(
46
+ "span",
47
+ {
48
+ ...{
49
+ className: "text-sm text-gray-dark truncate"
50
+ },
51
+ children: summary
52
+ }
53
+ )
54
+ ]
55
+ }
56
+ )
57
+ ]
58
+ }
59
+ );
60
+ var item_row_default = ItemRow;
61
+ export {
62
+ item_row_default as default
63
+ };
@@ -17,11 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var sms_exports = {};
19
19
  __export(sms_exports, {
20
+ smsBrandLine: () => smsBrandLine,
20
21
  smsNumberActive: () => smsNumberActive
21
22
  });
22
23
  module.exports = __toCommonJS(sms_exports);
23
24
  const smsNumberActive = (organization) => ((organization == null ? void 0 : organization.identityItems) || []).some((row) => (row == null ? void 0 : row.type) === "sms" && (row == null ? void 0 : row.status) === "verified");
25
+ const smsBrandLine = (brand, message) => brand && !String(message || "").trim().toLowerCase().startsWith(String(brand).trim().toLowerCase()) ? brand : null;
24
26
  // Annotate the CommonJS export names for ESM import in node:
25
27
  0 && (module.exports = {
28
+ smsBrandLine,
26
29
  smsNumberActive
27
30
  });
@@ -1,4 +1,6 @@
1
1
  const smsNumberActive = (organization) => ((organization == null ? void 0 : organization.identityItems) || []).some((row) => (row == null ? void 0 : row.type) === "sms" && (row == null ? void 0 : row.status) === "verified");
2
+ const smsBrandLine = (brand, message) => brand && !String(message || "").trim().toLowerCase().startsWith(String(brand).trim().toLowerCase()) ? brand : null;
2
3
  export {
4
+ smsBrandLine,
3
5
  smsNumberActive
4
6
  };