@drawbridge/components 0.1.18 → 0.1.20

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.
@@ -32,6 +32,7 @@ __export(form_organization_workflow_exports, {
32
32
  SAMPLE: () => SAMPLE,
33
33
  TextPreview: () => TextPreview,
34
34
  firstEntryOnly: () => firstEntryOnly,
35
+ hasStepOptions: () => hasStepOptions,
35
36
  issueRow: () => issueRow,
36
37
  memberOptions: () => memberOptions,
37
38
  partToStart: () => partToStart,
@@ -168,6 +169,7 @@ const stepReason = ({ entry, saved = [], type }) => {
168
169
  var _a, _b;
169
170
  return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((step) => (step == null ? void 0 : step.value) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _a.reason) || ((_b = saved.find((step) => (step == null ? void 0 : step.type) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _b.reason) || null;
170
171
  };
172
+ const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value));
171
173
  const responseStart = (number) => ({
172
174
  email: {
173
175
  enabled: true,
@@ -377,6 +379,7 @@ const workflowSchema = import_yup.default.object({
377
379
  const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
378
380
  const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
379
381
  const [settled, setSettled] = (0, import_react.useState)(asked);
382
+ const last = (0, import_react.useRef)();
380
383
  (0, import_react.useEffect)(() => {
381
384
  const timer = setTimeout(() => setSettled(asked), 400);
382
385
  return () => clearTimeout(timer);
@@ -394,7 +397,8 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
394
397
  },
395
398
  queryKey: ["workflow-email-preview", organization, campaign, event, settled]
396
399
  });
397
- return preview.data;
400
+ if (preview.data) last.current = preview.data;
401
+ return last.current;
398
402
  };
399
403
  const EmailStepCard = ({
400
404
  card,
@@ -1195,6 +1199,7 @@ const FormOrganizationWorkflowEdit = ({
1195
1199
  organization: values == null ? void 0 : values.organization,
1196
1200
  settings: step.settings
1197
1201
  });
1202
+ const stepOptions = getStepOptions(index);
1198
1203
  return (
1199
1204
  // @story workflows/edit
1200
1205
  // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
@@ -1350,8 +1355,10 @@ const FormOrganizationWorkflowEdit = ({
1350
1355
  setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1351
1356
  if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1352
1357
  },
1353
- disabled: lockedStep(index),
1354
- options: getStepOptions(index),
1358
+ // Locked for a member on the owner's step; disabled
1359
+ // with nothing left to pick.
1360
+ disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1361
+ options: stepOptions,
1355
1362
  // Resolved from the WHOLE ROW, not from this path: the
1356
1363
  // option value carries a connection the type alone cannot
1357
1364
  // name.
@@ -1612,6 +1619,7 @@ const FormOrganizationWorkflowEdit = ({
1612
1619
  SAMPLE,
1613
1620
  TextPreview,
1614
1621
  firstEntryOnly,
1622
+ hasStepOptions,
1615
1623
  issueRow,
1616
1624
  memberOptions,
1617
1625
  partToStart,
@@ -117,6 +117,7 @@ const stepReason = ({ entry, saved = [], type }) => {
117
117
  var _a, _b;
118
118
  return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((step) => (step == null ? void 0 : step.value) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _a.reason) || ((_b = saved.find((step) => (step == null ? void 0 : step.type) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _b.reason) || null;
119
119
  };
120
+ const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value));
120
121
  const responseStart = (number) => ({
121
122
  email: {
122
123
  enabled: true,
@@ -326,6 +327,7 @@ const workflowSchema = yup.object({
326
327
  const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
327
328
  const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
328
329
  const [settled, setSettled] = useState(asked);
330
+ const last = useRef();
329
331
  useEffect(() => {
330
332
  const timer = setTimeout(() => setSettled(asked), 400);
331
333
  return () => clearTimeout(timer);
@@ -343,7 +345,8 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
343
345
  },
344
346
  queryKey: ["workflow-email-preview", organization, campaign, event, settled]
345
347
  });
346
- return preview.data;
348
+ if (preview.data) last.current = preview.data;
349
+ return last.current;
347
350
  };
348
351
  const EmailStepCard = ({
349
352
  card,
@@ -1144,6 +1147,7 @@ const FormOrganizationWorkflowEdit = ({
1144
1147
  organization: values == null ? void 0 : values.organization,
1145
1148
  settings: step.settings
1146
1149
  });
1150
+ const stepOptions = getStepOptions(index);
1147
1151
  return (
1148
1152
  // @story workflows/edit
1149
1153
  // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
@@ -1299,8 +1303,10 @@ const FormOrganizationWorkflowEdit = ({
1299
1303
  setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1300
1304
  if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1301
1305
  },
1302
- disabled: lockedStep(index),
1303
- options: getStepOptions(index),
1306
+ // Locked for a member on the owner's step; disabled
1307
+ // with nothing left to pick.
1308
+ disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1309
+ options: stepOptions,
1304
1310
  // Resolved from the WHOLE ROW, not from this path: the
1305
1311
  // option value carries a connection the type alone cannot
1306
1312
  // name.
@@ -1560,6 +1566,7 @@ export {
1560
1566
  SAMPLE,
1561
1567
  TextPreview,
1562
1568
  firstEntryOnly,
1569
+ hasStepOptions,
1563
1570
  issueRow,
1564
1571
  memberOptions,
1565
1572
  partToStart,
@@ -49,6 +49,7 @@ const ProviderUi = ({
49
49
  }) => {
50
50
  var _a, _b, _c, _d, _e, _f;
51
51
  const queryClient = (0, import_react_query.useQueryClient)();
52
+ queryClient.setQueryDefaults(["socket"], { structuralSharing: false });
52
53
  const tokenRef = (0, import_react.useRef)(token);
53
54
  (0, import_react.useEffect)(
54
55
  () => {
@@ -17,6 +17,7 @@ const ProviderUi = ({
17
17
  }) => {
18
18
  var _a, _b, _c, _d, _e, _f;
19
19
  const queryClient = useQueryClient();
20
+ queryClient.setQueryDefaults(["socket"], { structuralSharing: false });
20
21
  const tokenRef = useRef(token);
21
22
  useEffect(
22
23
  () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -136,6 +136,10 @@ export declare const prefillRow: ( options: { entry?: WorkflowCatalogEntry | nul
136
136
  // from the catalog entry or the saved steps; null when the step can run.
137
137
  export declare const stepReason: ( options: { entry?: WorkflowCatalogEntry | null; saved?: Array<{ reason?: string; type?: string; [ key: string ]: unknown }>; type?: string } ) => string | null;
138
138
 
139
+ // Whether a Step field's list holds a step to pick, beyond "Select a step";
140
+ // false disables the field.
141
+ export declare const hasStepOptions: ( options?: Array<{ value?: string | null; [ key: string ]: unknown }> ) => boolean;
142
+
139
143
  // The stored type of Auto response.
140
144
  export declare const RESPONSE: 'step.response.send';
141
145
  // Auto response's settings as on a new campaign: `number` is the number's status.