@drawbridge/components 0.1.36 → 0.1.38

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.
@@ -28,6 +28,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
28
28
  var card_connection_exports = {};
29
29
  __export(card_connection_exports, {
30
30
  CardConnectionHeader: () => CardConnectionHeader,
31
+ connectionLock: () => connectionLock,
31
32
  default: () => card_connection_default
32
33
  });
33
34
  module.exports = __toCommonJS(card_connection_exports);
@@ -120,6 +121,7 @@ const CardConnectionHeader = ({
120
121
  ]
121
122
  }
122
123
  );
124
+ const connectionLock = ({ id, locked } = {}) => !id && locked || null;
123
125
  const CardConnection = ({
124
126
  // Everything a merchant reads arrives under one key. `errors` beside it is
125
127
  // the connection DOCUMENT's own array of scope-drift entries, which is a
@@ -128,81 +130,118 @@ const CardConnection = ({
128
130
  errors,
129
131
  group,
130
132
  href,
133
+ id,
131
134
  image,
135
+ locked: planLocked,
136
+ organization,
132
137
  slug,
133
138
  status,
134
139
  title
135
140
  }) => {
141
+ const locked = connectionLock({ id, locked: planLocked });
136
142
  const errored = status === "error" || (errors == null ? void 0 : errors.length) > 0;
137
- return (
138
- // The card is the link's content: a link Button lays out as it, with no box of its own.
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
- import_button.default,
141
- {
142
- ...{
143
- "data-guide": "section-" + slug,
144
- element: import_link.default,
145
- href,
146
- variant: "link"
147
- },
148
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
143
+ const card = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
144
+ "div",
145
+ {
146
+ ...{
147
+ className: "flex flex-col justify-between space-y-6 w-full h-full text-left bg-white p-6 rounded border border-gray overflow-hidden"
148
+ },
149
+ children: [
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
151
+ "div",
152
+ {
153
+ ...{
154
+ className: "space-y-6"
155
+ },
156
+ children: [
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ CardConnectionHeader,
159
+ {
160
+ ...{
161
+ group,
162
+ image,
163
+ slug,
164
+ status,
165
+ title
166
+ }
167
+ }
168
+ ),
169
+ (content == null ? void 0 : content.excerpt) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: content.excerpt }),
170
+ errored && (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
+ import_error.default,
172
+ {
173
+ ...{
174
+ error: errors[0].message,
175
+ label: title
176
+ }
177
+ }
178
+ )
179
+ ]
180
+ }
181
+ ),
182
+ locked ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
149
183
  "div",
150
184
  {
151
185
  ...{
152
- className: "flex flex-col justify-between space-y-6 w-full h-full text-left bg-white p-6 rounded border border-gray overflow-hidden"
186
+ className: "flex items-center justify-between space-x-3"
153
187
  },
154
188
  children: [
155
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
156
- "div",
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
190
+ "p",
157
191
  {
158
192
  ...{
159
- className: "space-y-6"
193
+ className: "disabled text-sm"
160
194
  },
161
- children: [
162
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
- CardConnectionHeader,
164
- {
165
- ...{
166
- group,
167
- image,
168
- slug,
169
- status,
170
- title
171
- }
172
- }
173
- ),
174
- (content == null ? void 0 : content.excerpt) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: content.excerpt }),
175
- errored && (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
176
- import_error.default,
177
- {
178
- ...{
179
- error: errors[0].message,
180
- label: title
181
- }
182
- }
183
- )
184
- ]
195
+ children: locked
185
196
  }
186
197
  ),
187
198
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
- "div",
199
+ import_button.default,
189
200
  {
190
201
  ...{
191
- className: "flex items-center justify-end"
202
+ element: import_link.default,
203
+ href: "/organizations/" + (organization == null ? void 0 : organization.id) + "/billing",
204
+ inline: true,
205
+ size: "small",
206
+ variant: "success"
192
207
  },
193
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
194
- import_arrow_right.default,
195
- {
196
- ...{
197
- className: "w-5 h-5"
198
- }
199
- }
200
- )
208
+ children: "Upgrade"
201
209
  }
202
210
  )
203
211
  ]
204
212
  }
213
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
+ "div",
215
+ {
216
+ ...{
217
+ className: "flex items-center justify-end"
218
+ },
219
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
+ import_arrow_right.default,
221
+ {
222
+ ...{
223
+ className: "w-5 h-5"
224
+ }
225
+ }
226
+ )
227
+ }
205
228
  )
229
+ ]
230
+ }
231
+ );
232
+ if (locked) return card;
233
+ return (
234
+ // The card is the link's content: a link Button lays out as it, with no box of its own.
235
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
+ import_button.default,
237
+ {
238
+ ...{
239
+ "data-guide": "section-" + slug,
240
+ element: import_link.default,
241
+ href,
242
+ variant: "link"
243
+ },
244
+ children: card
206
245
  }
207
246
  )
208
247
  );
@@ -210,5 +249,6 @@ const CardConnection = ({
210
249
  var card_connection_default = CardConnection;
211
250
  // Annotate the CommonJS export names for ESM import in node:
212
251
  0 && (module.exports = {
213
- CardConnectionHeader
252
+ CardConnectionHeader,
253
+ connectionLock
214
254
  });
@@ -87,6 +87,7 @@ const CardConnectionHeader = ({
87
87
  ]
88
88
  }
89
89
  );
90
+ const connectionLock = ({ id, locked } = {}) => !id && locked || null;
90
91
  const CardConnection = ({
91
92
  // Everything a merchant reads arrives under one key. `errors` beside it is
92
93
  // the connection DOCUMENT's own array of scope-drift entries, which is a
@@ -95,81 +96,118 @@ const CardConnection = ({
95
96
  errors,
96
97
  group,
97
98
  href,
99
+ id,
98
100
  image,
101
+ locked: planLocked,
102
+ organization,
99
103
  slug,
100
104
  status,
101
105
  title
102
106
  }) => {
107
+ const locked = connectionLock({ id, locked: planLocked });
103
108
  const errored = status === "error" || (errors == null ? void 0 : errors.length) > 0;
104
- return (
105
- // The card is the link's content: a link Button lays out as it, with no box of its own.
106
- /* @__PURE__ */ jsx(
107
- Button,
108
- {
109
- ...{
110
- "data-guide": "section-" + slug,
111
- element: Link,
112
- href,
113
- variant: "link"
114
- },
115
- children: /* @__PURE__ */ jsxs(
109
+ const card = /* @__PURE__ */ jsxs(
110
+ "div",
111
+ {
112
+ ...{
113
+ className: "flex flex-col justify-between space-y-6 w-full h-full text-left bg-white p-6 rounded border border-gray overflow-hidden"
114
+ },
115
+ children: [
116
+ /* @__PURE__ */ jsxs(
117
+ "div",
118
+ {
119
+ ...{
120
+ className: "space-y-6"
121
+ },
122
+ children: [
123
+ /* @__PURE__ */ jsx(
124
+ CardConnectionHeader,
125
+ {
126
+ ...{
127
+ group,
128
+ image,
129
+ slug,
130
+ status,
131
+ title
132
+ }
133
+ }
134
+ ),
135
+ (content == null ? void 0 : content.excerpt) && /* @__PURE__ */ jsx("p", { children: content.excerpt }),
136
+ errored && (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ jsx(
137
+ Error,
138
+ {
139
+ ...{
140
+ error: errors[0].message,
141
+ label: title
142
+ }
143
+ }
144
+ )
145
+ ]
146
+ }
147
+ ),
148
+ locked ? /* @__PURE__ */ jsxs(
116
149
  "div",
117
150
  {
118
151
  ...{
119
- className: "flex flex-col justify-between space-y-6 w-full h-full text-left bg-white p-6 rounded border border-gray overflow-hidden"
152
+ className: "flex items-center justify-between space-x-3"
120
153
  },
121
154
  children: [
122
- /* @__PURE__ */ jsxs(
123
- "div",
155
+ /* @__PURE__ */ jsx(
156
+ "p",
124
157
  {
125
158
  ...{
126
- className: "space-y-6"
159
+ className: "disabled text-sm"
127
160
  },
128
- children: [
129
- /* @__PURE__ */ jsx(
130
- CardConnectionHeader,
131
- {
132
- ...{
133
- group,
134
- image,
135
- slug,
136
- status,
137
- title
138
- }
139
- }
140
- ),
141
- (content == null ? void 0 : content.excerpt) && /* @__PURE__ */ jsx("p", { children: content.excerpt }),
142
- errored && (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ jsx(
143
- Error,
144
- {
145
- ...{
146
- error: errors[0].message,
147
- label: title
148
- }
149
- }
150
- )
151
- ]
161
+ children: locked
152
162
  }
153
163
  ),
154
164
  /* @__PURE__ */ jsx(
155
- "div",
165
+ Button,
156
166
  {
157
167
  ...{
158
- className: "flex items-center justify-end"
168
+ element: Link,
169
+ href: "/organizations/" + (organization == null ? void 0 : organization.id) + "/billing",
170
+ inline: true,
171
+ size: "small",
172
+ variant: "success"
159
173
  },
160
- children: /* @__PURE__ */ jsx(
161
- ArrowRight,
162
- {
163
- ...{
164
- className: "w-5 h-5"
165
- }
166
- }
167
- )
174
+ children: "Upgrade"
168
175
  }
169
176
  )
170
177
  ]
171
178
  }
179
+ ) : /* @__PURE__ */ jsx(
180
+ "div",
181
+ {
182
+ ...{
183
+ className: "flex items-center justify-end"
184
+ },
185
+ children: /* @__PURE__ */ jsx(
186
+ ArrowRight,
187
+ {
188
+ ...{
189
+ className: "w-5 h-5"
190
+ }
191
+ }
192
+ )
193
+ }
172
194
  )
195
+ ]
196
+ }
197
+ );
198
+ if (locked) return card;
199
+ return (
200
+ // The card is the link's content: a link Button lays out as it, with no box of its own.
201
+ /* @__PURE__ */ jsx(
202
+ Button,
203
+ {
204
+ ...{
205
+ "data-guide": "section-" + slug,
206
+ element: Link,
207
+ href,
208
+ variant: "link"
209
+ },
210
+ children: card
173
211
  }
174
212
  )
175
213
  );
@@ -177,5 +215,6 @@ const CardConnection = ({
177
215
  var card_connection_default = CardConnection;
178
216
  export {
179
217
  CardConnectionHeader,
218
+ connectionLock,
180
219
  card_connection_default as default
181
220
  };
@@ -27,7 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var form_filters_analytics_exports = {};
29
29
  __export(form_filters_analytics_exports, {
30
+ analyticsFloor: () => analyticsFloor,
30
31
  default: () => form_filters_analytics_default,
32
+ periodOptions: () => periodOptions,
31
33
  variantResource: () => variantResource
32
34
  });
33
35
  module.exports = __toCommonJS(form_filters_analytics_exports);
@@ -71,11 +73,29 @@ const variantResource = ({ endpoint, organization }) => {
71
73
  }
72
74
  };
73
75
  };
76
+ const pad = (number) => String(number).padStart(2, "0");
77
+ const analyticsFloor = (show, now = /* @__PURE__ */ new Date()) => {
78
+ if (!show) return null;
79
+ const date = new Date(now.getFullYear(), now.getMonth(), now.getDate() - show);
80
+ return {
81
+ day: date.getFullYear() + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()),
82
+ month: pad(date.getMonth() + 1),
83
+ year: date.getFullYear()
84
+ };
85
+ };
86
+ const periodOptions = ({ floor, key, now = /* @__PURE__ */ new Date(), options = [], year }) => {
87
+ const thisMonth = pad(now.getMonth() + 1);
88
+ if (key === "year") return floor ? options.filter((option) => Number(option.value) >= floor.year) : options;
89
+ if (key !== "month") return options;
90
+ const kept = options.filter((option) => !(Number(year) === now.getFullYear() && option.value > thisMonth) && !(floor && Number(year) === floor.year && option.value < floor.month));
91
+ return kept.length === options.length ? options : kept;
92
+ };
74
93
  const FormFiltersAnalytics = ({
75
94
  filters = {},
76
95
  inputs,
77
96
  onReset,
78
- onSuccess
97
+ onSuccess,
98
+ show
79
99
  }) => {
80
100
  const [dateMode, setDateMode] = (0, import_react.useState)((filters == null ? void 0 : filters.start) ? 1 : 0);
81
101
  const now = /* @__PURE__ */ new Date();
@@ -98,11 +118,14 @@ const FormFiltersAnalytics = ({
98
118
  const year = (0, import_form.useWatch)({ control, name: "filters.year", defaultValue: filters == null ? void 0 : filters.year }) || now.getFullYear();
99
119
  const month = (0, import_form.useWatch)({ control, name: "filters.month", defaultValue: filters == null ? void 0 : filters.month });
100
120
  const isThisYear = Number(year) === now.getFullYear();
121
+ const floor = analyticsFloor(show, now);
101
122
  (0, import_react.useEffect)(
102
123
  () => {
103
124
  if (isThisYear && month > thisMonth) setValue("filters.month", thisMonth);
125
+ if (floor && Number(year) < floor.year) setValue("filters.year", floor.year);
126
+ if (floor && Number(year) === floor.year && month < floor.month) setValue("filters.month", floor.month);
104
127
  },
105
- [isThisYear, month, setValue, thisMonth]
128
+ [floor == null ? void 0 : floor.month, floor == null ? void 0 : floor.year, isThisYear, month, setValue, thisMonth, year]
106
129
  );
107
130
  const dateRangeStart = (0, import_form.useWatch)({ control, name: "filters.start", defaultValue: filters == null ? void 0 : filters.start }) || "";
108
131
  const dateRangeEnd = (0, import_form.useWatch)({ control, name: "filters.end", defaultValue: filters == null ? void 0 : filters.end }) || "";
@@ -163,8 +186,7 @@ const FormFiltersAnalytics = ({
163
186
  {
164
187
  ...{
165
188
  onChange,
166
- // The list as given unless a later month has to go.
167
- options: key === "month" && isThisYear && (options || []).some((option) => option.value > thisMonth) ? options.filter((option) => option.value <= thisMonth) : options,
189
+ options: periodOptions({ floor, key, now, options, year }),
168
190
  searchable: Boolean(searchable),
169
191
  // An unset filter is undefined; the "all" option's
170
192
  // value is '' so it shows as selected by default.
@@ -299,6 +321,7 @@ const FormFiltersAnalytics = ({
299
321
  {
300
322
  ...{
301
323
  max: today,
324
+ min: floor == null ? void 0 : floor.day,
302
325
  value: {
303
326
  start: dateRangeStart,
304
327
  end: dateRangeEnd
@@ -355,5 +378,7 @@ const FormFiltersAnalytics = ({
355
378
  var form_filters_analytics_default = FormFiltersAnalytics;
356
379
  // Annotate the CommonJS export names for ESM import in node:
357
380
  0 && (module.exports = {
381
+ analyticsFloor,
382
+ periodOptions,
358
383
  variantResource
359
384
  });
@@ -38,11 +38,29 @@ const variantResource = ({ endpoint, organization }) => {
38
38
  }
39
39
  };
40
40
  };
41
+ const pad = (number) => String(number).padStart(2, "0");
42
+ const analyticsFloor = (show, now = /* @__PURE__ */ new Date()) => {
43
+ if (!show) return null;
44
+ const date = new Date(now.getFullYear(), now.getMonth(), now.getDate() - show);
45
+ return {
46
+ day: date.getFullYear() + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()),
47
+ month: pad(date.getMonth() + 1),
48
+ year: date.getFullYear()
49
+ };
50
+ };
51
+ const periodOptions = ({ floor, key, now = /* @__PURE__ */ new Date(), options = [], year }) => {
52
+ const thisMonth = pad(now.getMonth() + 1);
53
+ if (key === "year") return floor ? options.filter((option) => Number(option.value) >= floor.year) : options;
54
+ if (key !== "month") return options;
55
+ const kept = options.filter((option) => !(Number(year) === now.getFullYear() && option.value > thisMonth) && !(floor && Number(year) === floor.year && option.value < floor.month));
56
+ return kept.length === options.length ? options : kept;
57
+ };
41
58
  const FormFiltersAnalytics = ({
42
59
  filters = {},
43
60
  inputs,
44
61
  onReset,
45
- onSuccess
62
+ onSuccess,
63
+ show
46
64
  }) => {
47
65
  const [dateMode, setDateMode] = useState((filters == null ? void 0 : filters.start) ? 1 : 0);
48
66
  const now = /* @__PURE__ */ new Date();
@@ -65,11 +83,14 @@ const FormFiltersAnalytics = ({
65
83
  const year = useWatch({ control, name: "filters.year", defaultValue: filters == null ? void 0 : filters.year }) || now.getFullYear();
66
84
  const month = useWatch({ control, name: "filters.month", defaultValue: filters == null ? void 0 : filters.month });
67
85
  const isThisYear = Number(year) === now.getFullYear();
86
+ const floor = analyticsFloor(show, now);
68
87
  useEffect(
69
88
  () => {
70
89
  if (isThisYear && month > thisMonth) setValue("filters.month", thisMonth);
90
+ if (floor && Number(year) < floor.year) setValue("filters.year", floor.year);
91
+ if (floor && Number(year) === floor.year && month < floor.month) setValue("filters.month", floor.month);
71
92
  },
72
- [isThisYear, month, setValue, thisMonth]
93
+ [floor == null ? void 0 : floor.month, floor == null ? void 0 : floor.year, isThisYear, month, setValue, thisMonth, year]
73
94
  );
74
95
  const dateRangeStart = useWatch({ control, name: "filters.start", defaultValue: filters == null ? void 0 : filters.start }) || "";
75
96
  const dateRangeEnd = useWatch({ control, name: "filters.end", defaultValue: filters == null ? void 0 : filters.end }) || "";
@@ -130,8 +151,7 @@ const FormFiltersAnalytics = ({
130
151
  {
131
152
  ...{
132
153
  onChange,
133
- // The list as given unless a later month has to go.
134
- options: key === "month" && isThisYear && (options || []).some((option) => option.value > thisMonth) ? options.filter((option) => option.value <= thisMonth) : options,
154
+ options: periodOptions({ floor, key, now, options, year }),
135
155
  searchable: Boolean(searchable),
136
156
  // An unset filter is undefined; the "all" option's
137
157
  // value is '' so it shows as selected by default.
@@ -266,6 +286,7 @@ const FormFiltersAnalytics = ({
266
286
  {
267
287
  ...{
268
288
  max: today,
289
+ min: floor == null ? void 0 : floor.day,
269
290
  value: {
270
291
  start: dateRangeStart,
271
292
  end: dateRangeEnd
@@ -321,6 +342,8 @@ const FormFiltersAnalytics = ({
321
342
  };
322
343
  var form_filters_analytics_default = FormFiltersAnalytics;
323
344
  export {
345
+ analyticsFloor,
324
346
  form_filters_analytics_default as default,
347
+ periodOptions,
325
348
  variantResource
326
349
  };
@@ -34,6 +34,7 @@ __export(form_organization_workflow_exports, {
34
34
  hasStepOptions: () => hasStepOptions,
35
35
  issueRow: () => issueRow,
36
36
  listsMembers: () => listsMembers,
37
+ lockedStepOption: () => lockedStepOption,
37
38
  memberOptions: () => memberOptions,
38
39
  partToStart: () => partToStart,
39
40
  pickedCopy: () => pickedCopy,
@@ -81,6 +82,7 @@ var import_preview = __toESM(require("./preview"));
81
82
  var import_card_task = __toESM(require("./card-task"));
82
83
  var import_loader = require("../shared/loader");
83
84
  var import_sms = require("./lib/sms");
85
+ var import_lock = __toESM(require("../icons/lock"));
84
86
  var import_trash = __toESM(require("../icons/trash"));
85
87
  var import_button = __toESM(require("../shared/button"));
86
88
  var import_helpers = require("../shared/lib/helpers");
@@ -187,6 +189,15 @@ const stepReason = ({ entry, saved = [], type }) => {
187
189
  var _a, _b;
188
190
  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;
189
191
  };
192
+ const lockedStepOption = (step, current) => (step == null ? void 0 : step.locked) && step.value !== current ? {
193
+ badge: {
194
+ text: step.locked
195
+ },
196
+ disabled: true,
197
+ element: void 0,
198
+ icon: import_lock.default,
199
+ props: {}
200
+ } : {};
190
201
  const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value) && !(option == null ? void 0 : option.disabled));
191
202
  const responseStart = (number) => ({
192
203
  email: {
@@ -1022,7 +1033,7 @@ const FormOrganizationWorkflowEdit = ({
1022
1033
  return [
1023
1034
  { key: "Select a step", value: "" },
1024
1035
  ...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => {
1025
- var _a2;
1036
+ var _a2, _b2;
1026
1037
  return {
1027
1038
  ...step,
1028
1039
  // Option values must be unique per catalog entry, not per step
@@ -1088,7 +1099,8 @@ const FormOrganizationWorkflowEdit = ({
1088
1099
  text: "Owner access only"
1089
1100
  },
1090
1101
  disabled: true
1091
- } : {}
1102
+ } : {},
1103
+ ...lockedStepOption(step, (_b2 = watchedSteps == null ? void 0 : watchedSteps[index]) == null ? void 0 : _b2.type)
1092
1104
  };
1093
1105
  })
1094
1106
  ];
@@ -1719,6 +1731,7 @@ const FormOrganizationWorkflowEdit = ({
1719
1731
  hasStepOptions,
1720
1732
  issueRow,
1721
1733
  listsMembers,
1734
+ lockedStepOption,
1722
1735
  memberOptions,
1723
1736
  partToStart,
1724
1737
  pickedCopy,
@@ -28,6 +28,7 @@ import Preview, { Mail, NoPreview, SliderLayout, useCard } from "./preview.mjs";
28
28
  import CardTask from "./card-task.mjs";
29
29
  import { LoaderDynamic } from "../shared/loader.mjs";
30
30
  import { smsBrandLine, smsNumberActive } from "./lib/sms.mjs";
31
+ import Lock from "../icons/lock.mjs";
31
32
  import Trash from "../icons/trash.mjs";
32
33
  import Button from "../shared/button.mjs";
33
34
  import { hasCapability } from "../shared/lib/helpers.mjs";
@@ -134,6 +135,15 @@ const stepReason = ({ entry, saved = [], type }) => {
134
135
  var _a, _b;
135
136
  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;
136
137
  };
138
+ const lockedStepOption = (step, current) => (step == null ? void 0 : step.locked) && step.value !== current ? {
139
+ badge: {
140
+ text: step.locked
141
+ },
142
+ disabled: true,
143
+ element: void 0,
144
+ icon: Lock,
145
+ props: {}
146
+ } : {};
137
147
  const hasStepOptions = (options = []) => options.some((option) => Boolean(option == null ? void 0 : option.value) && !(option == null ? void 0 : option.disabled));
138
148
  const responseStart = (number) => ({
139
149
  email: {
@@ -969,7 +979,7 @@ const FormOrganizationWorkflowEdit = ({
969
979
  return [
970
980
  { key: "Select a step", value: "" },
971
981
  ...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => {
972
- var _a2;
982
+ var _a2, _b2;
973
983
  return {
974
984
  ...step,
975
985
  // Option values must be unique per catalog entry, not per step
@@ -1035,7 +1045,8 @@ const FormOrganizationWorkflowEdit = ({
1035
1045
  text: "Owner access only"
1036
1046
  },
1037
1047
  disabled: true
1038
- } : {}
1048
+ } : {},
1049
+ ...lockedStepOption(step, (_b2 = watchedSteps == null ? void 0 : watchedSteps[index]) == null ? void 0 : _b2.type)
1039
1050
  };
1040
1051
  })
1041
1052
  ];
@@ -1665,6 +1676,7 @@ export {
1665
1676
  hasStepOptions,
1666
1677
  issueRow,
1667
1678
  listsMembers,
1679
+ lockedStepOption,
1668
1680
  memberOptions,
1669
1681
  partToStart,
1670
1682
  pickedCopy,
@@ -78,6 +78,7 @@ const InputCombobox = ({
78
78
  disabled: disabled2,
79
79
  element: OverrideElement,
80
80
  header,
81
+ icon: Icon,
81
82
  image,
82
83
  key,
83
84
  props = {},
@@ -121,6 +122,14 @@ const InputCombobox = ({
121
122
  }
122
123
  },
123
124
  children: [
125
+ Icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ Icon,
127
+ {
128
+ ...{
129
+ className: "w-4 h-4 shrink-0"
130
+ }
131
+ }
132
+ ),
124
133
  image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
125
134
  import_card_asset.default,
126
135
  {
@@ -52,6 +52,7 @@ const InputCombobox = ({
52
52
  disabled: disabled2,
53
53
  element: OverrideElement,
54
54
  header,
55
+ icon: Icon,
55
56
  image,
56
57
  key,
57
58
  props = {},
@@ -95,6 +96,14 @@ const InputCombobox = ({
95
96
  }
96
97
  },
97
98
  children: [
99
+ Icon && /* @__PURE__ */ jsx(
100
+ Icon,
101
+ {
102
+ ...{
103
+ className: "w-4 h-4 shrink-0"
104
+ }
105
+ }
106
+ ),
98
107
  image && /* @__PURE__ */ jsx(
99
108
  CardAsset,
100
109
  {
@@ -188,6 +188,7 @@ const InputDate = ({
188
188
  const InputDateRange = ({
189
189
  className,
190
190
  max,
191
+ min,
191
192
  onChange,
192
193
  value = {}
193
194
  }) => {
@@ -218,12 +219,16 @@ const InputDateRange = ({
218
219
  classNames: DAY_PICKER_CLASS_NAMES,
219
220
  components: DAY_PICKER_COMPONENTS,
220
221
  defaultMonth: selected.from,
222
+ disabled: [
223
+ ...min ? [{ before: toDateObj(min) }] : [],
224
+ ...max ? [{ after: toDateObj(max) }] : []
225
+ ],
221
226
  ...max && {
222
- disabled: {
223
- after: toDateObj(max)
224
- },
225
227
  endMonth: toDateObj(max)
226
228
  },
229
+ ...min && {
230
+ startMonth: toDateObj(min)
231
+ },
227
232
  mode: "range",
228
233
  selected,
229
234
  onSelect: handleSelect,
@@ -155,6 +155,7 @@ const InputDate = ({
155
155
  const InputDateRange = ({
156
156
  className,
157
157
  max,
158
+ min,
158
159
  onChange,
159
160
  value = {}
160
161
  }) => {
@@ -185,12 +186,16 @@ const InputDateRange = ({
185
186
  classNames: DAY_PICKER_CLASS_NAMES,
186
187
  components: DAY_PICKER_COMPONENTS,
187
188
  defaultMonth: selected.from,
189
+ disabled: [
190
+ ...min ? [{ before: toDateObj(min) }] : [],
191
+ ...max ? [{ after: toDateObj(max) }] : []
192
+ ],
188
193
  ...max && {
189
- disabled: {
190
- after: toDateObj(max)
191
- },
192
194
  endMonth: toDateObj(max)
193
195
  },
196
+ ...min && {
197
+ startMonth: toDateObj(min)
198
+ },
194
199
  mode: "range",
195
200
  selected,
196
201
  onSelect: handleSelect,
@@ -55,6 +55,7 @@ var import_wrapper_gradient = __toESM(require("../wrapper-gradient"));
55
55
  var import_image = __toESM(require("next/image"));
56
56
  var import_link = __toESM(require("./link"));
57
57
  var import_loader2 = __toESM(require("../shared/loader"));
58
+ var import_tooltip = __toESM(require("../shared/tooltip"));
58
59
  const Refetch = ({
59
60
  invalidate = []
60
61
  }) => {
@@ -105,10 +106,11 @@ const renderButton = (props, key) => {
105
106
  indicator,
106
107
  svg,
107
108
  title,
109
+ tooltip,
108
110
  variant = "secondary",
109
111
  ...rest
110
112
  } = props;
111
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
113
+ const button = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
114
  import_button.default,
113
115
  {
114
116
  ...{
@@ -124,6 +126,17 @@ const renderButton = (props, key) => {
124
126
  },
125
127
  key
126
128
  );
129
+ if (tooltip) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
+ import_tooltip.default,
131
+ {
132
+ ...{
133
+ content: tooltip
134
+ },
135
+ children: button
136
+ },
137
+ key
138
+ );
139
+ return button;
127
140
  };
128
141
  const TemplateDashboardHeader = ({
129
142
  badges = [],
@@ -17,6 +17,7 @@ import WrapperGradient from "../wrapper-gradient.mjs";
17
17
  import Image from "next/image";
18
18
  import Link from "./link.mjs";
19
19
  import Loader from "../shared/loader.mjs";
20
+ import Tooltip from "../shared/tooltip.mjs";
20
21
  const Refetch = ({
21
22
  invalidate = []
22
23
  }) => {
@@ -67,10 +68,11 @@ const renderButton = (props, key) => {
67
68
  indicator,
68
69
  svg,
69
70
  title,
71
+ tooltip,
70
72
  variant = "secondary",
71
73
  ...rest
72
74
  } = props;
73
- return /* @__PURE__ */ jsx(
75
+ const button = /* @__PURE__ */ jsx(
74
76
  Button,
75
77
  {
76
78
  ...{
@@ -86,6 +88,17 @@ const renderButton = (props, key) => {
86
88
  },
87
89
  key
88
90
  );
91
+ if (tooltip) return /* @__PURE__ */ jsx(
92
+ Tooltip,
93
+ {
94
+ ...{
95
+ content: tooltip
96
+ },
97
+ children: button
98
+ },
99
+ key
100
+ );
101
+ return button;
89
102
  };
90
103
  const TemplateDashboardHeader = ({
91
104
  badges = [],
@@ -551,6 +551,15 @@ const TemplateSocketOrganization = ({
551
551
  queryClient.invalidateQueries({
552
552
  queryKey: ["organization-campaign-advertisement"]
553
553
  });
554
+ queryClient.invalidateQueries({
555
+ queryKey: ["organization-exports", params.organization]
556
+ });
557
+ queryClient.invalidateQueries({
558
+ queryKey: ["organization-segments", params.organization]
559
+ });
560
+ queryClient.invalidateQueries({
561
+ queryKey: ["organization-contacts", params.organization]
562
+ });
554
563
  },
555
564
  // @story workflows/list
556
565
  // Sync emits this on every workflow status change, on delete, and when
@@ -516,6 +516,15 @@ const TemplateSocketOrganization = ({
516
516
  queryClient.invalidateQueries({
517
517
  queryKey: ["organization-campaign-advertisement"]
518
518
  });
519
+ queryClient.invalidateQueries({
520
+ queryKey: ["organization-exports", params.organization]
521
+ });
522
+ queryClient.invalidateQueries({
523
+ queryKey: ["organization-segments", params.organization]
524
+ });
525
+ queryClient.invalidateQueries({
526
+ queryKey: ["organization-contacts", params.organization]
527
+ });
519
528
  },
520
529
  // @story workflows/list
521
530
  // Sync emits this on every workflow status change, on delete, and when
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -1954,7 +1954,7 @@
1954
1954
  "@analytics/google-tag-manager": "0.5.5",
1955
1955
  "@drawbridge/drawbridge-agents": "0.1.104",
1956
1956
  "@drawbridge/drawbridge-telemetry": "0.0.19",
1957
- "@drawbridge/drawbridge-utils": "0.0.234",
1957
+ "@drawbridge/drawbridge-utils": "0.0.236",
1958
1958
  "@headlessui/react": "2.2.9",
1959
1959
  "@hookform/resolvers": "3.1.1",
1960
1960
  "@sentry/nextjs": "10.58.0",
@@ -14,8 +14,16 @@ export interface CardConnectionProps extends CardConnectionHeaderProps {
14
14
  // The connection document's own error entries; the first is shown.
15
15
  errors?: { message?: string; [ key: string ]: unknown }[];
16
16
  href?: string;
17
+ // The connection document's id: a connection already held never locks.
18
+ id?: string;
19
+ // The organization whose plan decides whether the card shows Upgrade.
20
+ organization?: { id?: string; plan?: unknown; [ key: string ]: unknown };
17
21
  }
18
22
 
23
+ // The plan's reason when the organization's plan leaves this unconnected
24
+ // connection out, otherwise null.
25
+ export declare const connectionLock: ( organization?: CardConnectionProps[ 'organization' ], connection?: { id?: string; slug?: string } ) => string | null;
26
+
19
27
  export declare const CardConnectionHeader: ComponentType<CardConnectionHeaderProps>;
20
28
 
21
29
  declare const CardConnection: ComponentType<CardConnectionProps>;
@@ -33,8 +33,22 @@ export interface FormFiltersAnalyticsProps {
33
33
  onReset?: () => void;
34
34
  // Resources reduced to ids, and only the active date mode's keys.
35
35
  onSuccess: ( result: { filters: Record<string, unknown> } ) => void;
36
+ // The days a plan shows ( `organization.plan.analytics.show` ); null shows everything.
37
+ show?: number | null;
36
38
  }
37
39
 
40
+ export interface AnalyticsFloor {
41
+ day: string;
42
+ month: string;
43
+ year: number;
44
+ }
45
+
46
+ // The first day a plan shows, or null when it shows everything it keeps.
47
+ export declare const analyticsFloor: ( show?: number | null, now?: Date ) => AnalyticsFloor | null;
48
+
49
+ // The Month / Year options a filter can pick, inside the plan's window and up to this month.
50
+ export declare const periodOptions: ( args: { floor?: AnalyticsFloor | null; key: string; now?: Date; options?: FormFiltersAnalyticsInput[ 'options' ]; year?: unknown } ) => FormFiltersAnalyticsInput[ 'options' ];
51
+
38
52
  declare const FormFiltersAnalytics: ComponentType<FormFiltersAnalyticsProps>;
39
53
 
40
54
  export default FormFiltersAnalytics;
@@ -141,6 +141,10 @@ export declare const stepReason: ( options: { entry?: WorkflowCatalogEntry | nul
141
141
 
142
142
  // Whether a Step field's list holds a step to pick, beyond "Select a step";
143
143
  // false disables the field.
144
+ // The option fields that lock a step the plan leaves out ( the catalog's
145
+ // `locked` ), or {} for a step the plan includes or the row already holds.
146
+ export declare const lockedStepOption: ( step?: { locked?: string; value?: string; [ key: string ]: unknown }, current?: string ) => Record<string, unknown>;
147
+
144
148
  export declare const hasStepOptions: ( options?: Array<{ value?: string | null; [ key: string ]: unknown }> ) => boolean;
145
149
 
146
150
  // The stored type of Auto response.
@@ -8,6 +8,8 @@ export interface InputComboboxOption {
8
8
  element?: ElementType;
9
9
  // A non-selectable group label.
10
10
  header?: boolean;
11
+ // An icon before the label, e.g. a padlock.
12
+ icon?: ComponentType<{ className?: string }>;
11
13
  image?: string;
12
14
  // The label.
13
15
  key: string;
@@ -23,6 +23,8 @@ export interface InputDateRangeProps {
23
23
  className?: string;
24
24
  // The last day that can be picked, 'YYYY-MM-DD'; the calendar stops at its month.
25
25
  max?: string | Date;
26
+ // The first day that can be picked, 'YYYY-MM-DD'; the calendar starts at its month.
27
+ min?: string | Date;
26
28
  onChange: ( value: InputDateRangeValue ) => void;
27
29
  value?: InputDateRangeValue;
28
30
  }
@@ -14,6 +14,8 @@ export interface TemplateDashboardButton {
14
14
  render?: () => ReactNode;
15
15
  svg?: ComponentType<{ className?: string }>;
16
16
  title?: ReactNode;
17
+ // Shown on hover, e.g. the plan's reason on a disabled control.
18
+ tooltip?: ReactNode;
17
19
  [ key: string ]: unknown;
18
20
  }
19
21