@drawbridge/components 0.1.19 → 0.1.21

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,
@@ -959,7 +961,7 @@ const FormOrganizationWorkflowEdit = ({
959
961
  if (row) setValue("steps", [...getValues("steps"), row], { shouldDirty: true });
960
962
  }, [catalog, disabled, getValues, loading, setValue, values == null ? void 0 : values.step]);
961
963
  const getStepOptions = (index) => {
962
- const usedTypes = watchedSteps.map((s, i) => i !== index ? s.type : null).filter(Boolean);
964
+ const usedTypes = (watchedSteps || []).map((s, i) => i !== index ? s.type : null).filter(Boolean);
963
965
  return [
964
966
  { key: "Select a step", value: "" },
965
967
  ...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).filter((step) => {
@@ -1028,6 +1030,7 @@ const FormOrganizationWorkflowEdit = ({
1028
1030
  var _a2;
1029
1031
  return s.ownerOnly && s.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
1030
1032
  });
1033
+ const canAddStep = hasStepOptions(getStepOptions((watchedSteps || []).length));
1031
1034
  const getStepValue = (field, index) => {
1032
1035
  if (!field.type) return "";
1033
1036
  const options = getStepOptions(index);
@@ -1182,6 +1185,7 @@ const FormOrganizationWorkflowEdit = ({
1182
1185
  import_input_array.InputArrayButton,
1183
1186
  {
1184
1187
  ...{
1188
+ disabled: !canAddStep,
1185
1189
  onClick: () => append(stepRow()),
1186
1190
  text: "Add step"
1187
1191
  }
@@ -1197,6 +1201,7 @@ const FormOrganizationWorkflowEdit = ({
1197
1201
  organization: values == null ? void 0 : values.organization,
1198
1202
  settings: step.settings
1199
1203
  });
1204
+ const stepOptions = getStepOptions(index);
1200
1205
  return (
1201
1206
  // @story workflows/edit
1202
1207
  // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
@@ -1352,8 +1357,10 @@ const FormOrganizationWorkflowEdit = ({
1352
1357
  setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1353
1358
  if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1354
1359
  },
1355
- disabled: lockedStep(index),
1356
- options: getStepOptions(index),
1360
+ // Locked for a member on the owner's step; disabled
1361
+ // with nothing left to pick.
1362
+ disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1363
+ options: stepOptions,
1357
1364
  // Resolved from the WHOLE ROW, not from this path: the
1358
1365
  // option value carries a connection the type alone cannot
1359
1366
  // name.
@@ -1614,6 +1621,7 @@ const FormOrganizationWorkflowEdit = ({
1614
1621
  SAMPLE,
1615
1622
  TextPreview,
1616
1623
  firstEntryOnly,
1624
+ hasStepOptions,
1617
1625
  issueRow,
1618
1626
  memberOptions,
1619
1627
  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,
@@ -908,7 +909,7 @@ const FormOrganizationWorkflowEdit = ({
908
909
  if (row) setValue("steps", [...getValues("steps"), row], { shouldDirty: true });
909
910
  }, [catalog, disabled, getValues, loading, setValue, values == null ? void 0 : values.step]);
910
911
  const getStepOptions = (index) => {
911
- const usedTypes = watchedSteps.map((s, i) => i !== index ? s.type : null).filter(Boolean);
912
+ const usedTypes = (watchedSteps || []).map((s, i) => i !== index ? s.type : null).filter(Boolean);
912
913
  return [
913
914
  { key: "Select a step", value: "" },
914
915
  ...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).filter((step) => {
@@ -977,6 +978,7 @@ const FormOrganizationWorkflowEdit = ({
977
978
  var _a2;
978
979
  return s.ownerOnly && s.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
979
980
  });
981
+ const canAddStep = hasStepOptions(getStepOptions((watchedSteps || []).length));
980
982
  const getStepValue = (field, index) => {
981
983
  if (!field.type) return "";
982
984
  const options = getStepOptions(index);
@@ -1131,6 +1133,7 @@ const FormOrganizationWorkflowEdit = ({
1131
1133
  InputArrayButton,
1132
1134
  {
1133
1135
  ...{
1136
+ disabled: !canAddStep,
1134
1137
  onClick: () => append(stepRow()),
1135
1138
  text: "Add step"
1136
1139
  }
@@ -1146,6 +1149,7 @@ const FormOrganizationWorkflowEdit = ({
1146
1149
  organization: values == null ? void 0 : values.organization,
1147
1150
  settings: step.settings
1148
1151
  });
1152
+ const stepOptions = getStepOptions(index);
1149
1153
  return (
1150
1154
  // @story workflows/edit
1151
1155
  // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
@@ -1301,8 +1305,10 @@ const FormOrganizationWorkflowEdit = ({
1301
1305
  setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1302
1306
  if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1303
1307
  },
1304
- disabled: lockedStep(index),
1305
- options: getStepOptions(index),
1308
+ // Locked for a member on the owner's step; disabled
1309
+ // with nothing left to pick.
1310
+ disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1311
+ options: stepOptions,
1306
1312
  // Resolved from the WHOLE ROW, not from this path: the
1307
1313
  // option value carries a connection the type alone cannot
1308
1314
  // name.
@@ -1562,6 +1568,7 @@ export {
1562
1568
  SAMPLE,
1563
1569
  TextPreview,
1564
1570
  firstEntryOnly,
1571
+ hasStepOptions,
1565
1572
  issueRow,
1566
1573
  memberOptions,
1567
1574
  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.19",
3
+ "version": "0.1.21",
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.