@drawbridge/components 0.1.47 → 0.1.49

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.
@@ -848,7 +848,6 @@ const FormSubdomainSection = ({
848
848
  var _a2;
849
849
  return (0, import_entry.agreementContent)((_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]);
850
850
  };
851
- const optOutLine = (0, import_entry.termsOptOut)(values);
852
851
  const smsConsent = Boolean(last) && (values == null ? void 0 : values.sms) !== false && Boolean((_c = (_b = values == null ? void 0 : values.agreements) == null ? void 0 : _b.sms) == null ? void 0 : _c.enabled) && slugs.includes("phone");
853
852
  const marketingConsent = Boolean(last) && Boolean((_e = (_d = values == null ? void 0 : values.agreements) == null ? void 0 : _d.marketing) == null ? void 0 : _e.enabled) && (0, import_entry.agreementShown)((_f = values == null ? void 0 : values.agreements) == null ? void 0 : _f.marketing);
854
853
  const termsConsent = Boolean(last) && Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled) && (0, import_entry.agreementShown)((_i = values == null ? void 0 : values.agreements) == null ? void 0 : _i.terms);
@@ -1149,11 +1148,6 @@ const FormSubdomainSection = ({
1149
1148
  {
1150
1149
  ...{
1151
1150
  error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.message,
1152
- // @story public-entry/read-agreement
1153
- // The organizer's own rules may not say it; our document does, in Opting out.
1154
- ...key === "terms" && opens("terms") === "link" && optOutLine && {
1155
- message: optOutLine
1156
- },
1157
1151
  input: checkbox({
1158
1152
  fallback,
1159
1153
  key,
@@ -14,7 +14,7 @@ import { ageFor, ageGateSchema } from "./lib/age-gate.mjs";
14
14
  import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
15
15
  import { assertRecaptcha } from "./lib/recaptcha.mjs";
16
16
  import { submissionEndpoint } from "./lib/url.mjs";
17
- import { AFTER, agreementContent, agreementPhrase, agreementShown, agreementTitles, agreementWording, panelMissions, termsOptOut } from "./lib/entry.mjs";
17
+ import { AFTER, agreementContent, agreementPhrase, agreementShown, agreementTitles, agreementWording, panelMissions } from "./lib/entry.mjs";
18
18
  import FormSubdomainAgreement from "./form-subdomain-agreement.mjs";
19
19
  import { LOCATION_TIMEOUT, locationCopy, locationStatus } from "./lib/location.mjs";
20
20
  import { isLastList, itemCount, itemRuns, limitMessage, orderTotal, priced, refusedSection, sectionsOf } from "./lib/order.mjs";
@@ -811,7 +811,6 @@ const FormSubdomainSection = ({
811
811
  var _a2;
812
812
  return agreementContent((_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2[key]);
813
813
  };
814
- const optOutLine = termsOptOut(values);
815
814
  const smsConsent = Boolean(last) && (values == null ? void 0 : values.sms) !== false && Boolean((_c = (_b = values == null ? void 0 : values.agreements) == null ? void 0 : _b.sms) == null ? void 0 : _c.enabled) && slugs.includes("phone");
816
815
  const marketingConsent = Boolean(last) && Boolean((_e = (_d = values == null ? void 0 : values.agreements) == null ? void 0 : _d.marketing) == null ? void 0 : _e.enabled) && agreementShown((_f = values == null ? void 0 : values.agreements) == null ? void 0 : _f.marketing);
817
816
  const termsConsent = Boolean(last) && Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled) && agreementShown((_i = values == null ? void 0 : values.agreements) == null ? void 0 : _i.terms);
@@ -1112,11 +1111,6 @@ const FormSubdomainSection = ({
1112
1111
  {
1113
1112
  ...{
1114
1113
  error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.message,
1115
- // @story public-entry/read-agreement
1116
- // The organizer's own rules may not say it; our document does, in Opting out.
1117
- ...key === "terms" && opens("terms") === "link" && optOutLine && {
1118
- message: optOutLine
1119
- },
1120
1114
  input: checkbox({
1121
1115
  fallback,
1122
1116
  key,
@@ -35,7 +35,6 @@ __export(entry_exports, {
35
35
  menuAgreements: () => menuAgreements,
36
36
  panelMissions: () => panelMissions,
37
37
  previewStep: () => previewStep,
38
- termsOptOut: () => termsOptOut,
39
38
  withLocale: () => withLocale
40
39
  });
41
40
  module.exports = __toCommonJS(entry_exports);
@@ -142,7 +141,6 @@ const withLocale = (agreements = {}, locale = {}) => Object.fromEntries(
142
141
  }
143
142
  ])
144
143
  );
145
- const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If you unsubscribe" + (sms !== false ? " or reply STOP" : "") + ", you can't win and won't be told you were selected.";
146
144
  // Annotate the CommonJS export names for ESM import in node:
147
145
  0 && (module.exports = {
148
146
  AFTER,
@@ -163,6 +161,5 @@ const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If
163
161
  menuAgreements,
164
162
  panelMissions,
165
163
  previewStep,
166
- termsOptOut,
167
164
  withLocale
168
165
  });
@@ -101,7 +101,6 @@ const withLocale = (agreements = {}, locale = {}) => Object.fromEntries(
101
101
  }
102
102
  ])
103
103
  );
104
- const termsOptOut = ({ giveaway, sms } = {}) => giveaway === false ? null : "If you unsubscribe" + (sms !== false ? " or reply STOP" : "") + ", you can't win and won't be told you were selected.";
105
104
  export {
106
105
  AFTER,
107
106
  afterOrder,
@@ -121,6 +120,5 @@ export {
121
120
  menuAgreements,
122
121
  panelMissions,
123
122
  previewStep,
124
- termsOptOut,
125
123
  withLocale
126
124
  };
@@ -50,7 +50,15 @@ const mount = (dom, element) => {
50
50
  root.render(element);
51
51
  return () => setTimeout(() => root.unmount());
52
52
  };
53
+ const lockedCount = (doc, locked) => {
54
+ let count = 0;
55
+ doc.descendants((node) => {
56
+ count += node.type.name === "piece" && locked.includes(node.attrs.key) ? 1 : 0;
57
+ });
58
+ return count;
59
+ };
53
60
  const documentNodes = (options) => {
61
+ const locked = (options == null ? void 0 : options.locked) || [];
54
62
  const Piece = import_core.Node.create({
55
63
  name: "piece",
56
64
  atom: true,
@@ -88,7 +96,7 @@ const documentNodes = (options) => {
88
96
  }
89
97
  }
90
98
  ),
91
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ !locked.includes(node.attrs.key) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
100
  "span",
93
101
  {
94
102
  ...{
@@ -123,7 +131,12 @@ const documentNodes = (options) => {
123
131
  return Boolean((_b = (_a2 = event.target) == null ? void 0 : _a2.closest) == null ? void 0 : _b.call(_a2, "input, button"));
124
132
  }
125
133
  };
126
- }
134
+ },
135
+ addProseMirrorPlugins: () => locked.length ? [
136
+ new import_state.Plugin({
137
+ filterTransaction: (tr, state) => !tr.docChanged || tr.getMeta("preventUpdate") !== void 0 || lockedCount(tr.doc, locked) >= lockedCount(state.doc, locked)
138
+ })
139
+ ] : []
127
140
  });
128
141
  const Generated = import_core.Node.create({
129
142
  name: "generated",
@@ -206,7 +219,7 @@ const insertPiece = (editor, key) => {
206
219
  editor.view.dispatch(tr.scrollIntoView());
207
220
  editor.view.focus();
208
221
  };
209
- const documentBlocks = ({ data, insertable = [], onClaim }) => {
222
+ const documentBlocks = ({ data, insertable = [], locked, onClaim }) => {
210
223
  const text = ({ active, disabled, editor, tool }, title, label, on, run) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
224
  import_button.default,
212
225
  {
@@ -246,7 +259,7 @@ const documentBlocks = ({ data, insertable = [], onClaim }) => {
246
259
  return (_a2 = context.editor) == null ? void 0 : _a2.chain().focus().toggleHeading({ level: 2 }).run();
247
260
  });
248
261
  },
249
- extensions: documentNodes({ data, onClaim }),
262
+ extensions: documentNodes({ data, locked, onClaim }),
250
263
  insert: ({ disabled, editor }) => {
251
264
  const inDocument = present(editor);
252
265
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -15,7 +15,15 @@ const mount = (dom, element) => {
15
15
  root.render(element);
16
16
  return () => setTimeout(() => root.unmount());
17
17
  };
18
+ const lockedCount = (doc, locked) => {
19
+ let count = 0;
20
+ doc.descendants((node) => {
21
+ count += node.type.name === "piece" && locked.includes(node.attrs.key) ? 1 : 0;
22
+ });
23
+ return count;
24
+ };
18
25
  const documentNodes = (options) => {
26
+ const locked = (options == null ? void 0 : options.locked) || [];
19
27
  const Piece = Node.create({
20
28
  name: "piece",
21
29
  atom: true,
@@ -53,7 +61,7 @@ const documentNodes = (options) => {
53
61
  }
54
62
  }
55
63
  ),
56
- /* @__PURE__ */ jsx(
64
+ !locked.includes(node.attrs.key) && /* @__PURE__ */ jsx(
57
65
  "span",
58
66
  {
59
67
  ...{
@@ -88,7 +96,12 @@ const documentNodes = (options) => {
88
96
  return Boolean((_b = (_a2 = event.target) == null ? void 0 : _a2.closest) == null ? void 0 : _b.call(_a2, "input, button"));
89
97
  }
90
98
  };
91
- }
99
+ },
100
+ addProseMirrorPlugins: () => locked.length ? [
101
+ new Plugin({
102
+ filterTransaction: (tr, state) => !tr.docChanged || tr.getMeta("preventUpdate") !== void 0 || lockedCount(tr.doc, locked) >= lockedCount(state.doc, locked)
103
+ })
104
+ ] : []
92
105
  });
93
106
  const Generated = Node.create({
94
107
  name: "generated",
@@ -171,7 +184,7 @@ const insertPiece = (editor, key) => {
171
184
  editor.view.dispatch(tr.scrollIntoView());
172
185
  editor.view.focus();
173
186
  };
174
- const documentBlocks = ({ data, insertable = [], onClaim }) => {
187
+ const documentBlocks = ({ data, insertable = [], locked, onClaim }) => {
175
188
  const text = ({ active, disabled, editor, tool }, title, label, on, run) => /* @__PURE__ */ jsx(
176
189
  Button,
177
190
  {
@@ -211,7 +224,7 @@ const documentBlocks = ({ data, insertable = [], onClaim }) => {
211
224
  return (_a2 = context.editor) == null ? void 0 : _a2.chain().focus().toggleHeading({ level: 2 }).run();
212
225
  });
213
226
  },
214
- extensions: documentNodes({ data, onClaim }),
227
+ extensions: documentNodes({ data, locked, onClaim }),
215
228
  insert: ({ disabled, editor }) => {
216
229
  const inDocument = present(editor);
217
230
  return /* @__PURE__ */ jsx(
@@ -111,7 +111,7 @@ const FormOrganizationCampaignAgreement = ({
111
111
  readOnly
112
112
  }) => {
113
113
  var _a, _b, _c, _d;
114
- const { document: standard, types, values = {} } = agreement || {};
114
+ const { document: standard, include = [], types, values = {} } = agreement || {};
115
115
  const tabs = TABS.filter((tab) => (types || TABS).includes(tab));
116
116
  const saved = values.type || (values.link ? "link" : "document");
117
117
  const { control, formState, handleSubmit, setValue } = (0, import_form.useForm)({
@@ -148,6 +148,7 @@ const FormOrganizationCampaignAgreement = ({
148
148
  blocks.current ??= (0, import_document_blocks.default)({
149
149
  data,
150
150
  insertable: standard == null ? void 0 : standard.pieces,
151
+ locked: standard == null ? void 0 : standard.locked,
151
152
  onClaim: (days) => {
152
153
  var _a2;
153
154
  return (_a2 = claim.current) == null ? void 0 : _a2.call(claim, days);
@@ -283,111 +284,148 @@ const FormOrganizationCampaignAgreement = ({
283
284
  }
284
285
  }
285
286
  ),
286
- editing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
287
- Field,
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
288
+ "div",
288
289
  {
289
290
  ...{
290
- control,
291
- error: (_b = errors.document) == null ? void 0 : _b.message,
292
- name: "document",
293
- render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
291
+ className: "flex flex-col gap-3"
292
+ },
293
+ children: [
294
+ editing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
295
+ Field,
296
+ {
297
+ ...{
298
+ control,
299
+ error: (_b = errors.document) == null ? void 0 : _b.message,
300
+ name: "document",
301
+ render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
302
+ "div",
303
+ {
304
+ ...{
305
+ // What the screen leaves under the modal's other rows ( 38rem ), so the
306
+ // tick and Save stay in view on a laptop:
307
+ // the editor's toolbar stays and only the text scrolls.
308
+ className: "document h-[calc(100vh-38rem)] min-h-[12rem] flex flex-col [&>div]:flex-1 [&>div]:min-h-0 [&>div]:flex [&>div]:flex-col [&>div>div:has(>.ProseMirror)]:flex-1 [&>div>div:has(>.ProseMirror)]:min-h-0 [&>div>div:has(>.ProseMirror)]:overflow-y-auto",
309
+ "data-document": true
310
+ },
311
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
+ import_input_editor.default,
313
+ {
314
+ ...{
315
+ blocks: blocks.current,
316
+ disabled: readOnly,
317
+ onChange: ({ html }) => onChange(html),
318
+ value: value || ""
319
+ }
320
+ }
321
+ )
322
+ }
323
+ )
324
+ }
325
+ },
326
+ "document"
327
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
+ Field,
329
+ {
330
+ ...{
331
+ control,
332
+ error: (_c = errors.link) == null ? void 0 : _c.message,
333
+ label: "Link",
334
+ name: "link",
335
+ render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
336
+ import_input_url.default,
337
+ {
338
+ ...{
339
+ onChange,
340
+ value: value || ""
341
+ }
342
+ }
343
+ )
344
+ }
345
+ },
346
+ "link"
347
+ ),
348
+ !editing && include.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
294
349
  "div",
295
350
  {
296
351
  ...{
297
- // What the screen leaves under the modal's other rows ( 38rem ), so the
298
- // tick and Save stay in view on a laptop:
299
- // the editor's toolbar stays and only the text scrolls.
300
- className: "document h-[calc(100vh-38rem)] min-h-[12rem] flex flex-col [&>div]:flex-1 [&>div]:min-h-0 [&>div]:flex [&>div]:flex-col [&>div>div:has(>.ProseMirror)]:flex-1 [&>div>div:has(>.ProseMirror)]:min-h-0 [&>div>div:has(>.ProseMirror)]:overflow-y-auto",
301
- "data-document": true
352
+ className: "rounded bg-gray-light p-4 text-sm",
353
+ "data-include": id
302
354
  },
303
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
304
- import_input_editor.default,
305
- {
306
- ...{
307
- blocks: blocks.current,
308
- disabled: readOnly,
309
- onChange: ({ html }) => onChange(html),
310
- value: value || ""
355
+ children: [
356
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
357
+ "p",
358
+ {
359
+ ...{
360
+ className: "font-medium"
361
+ },
362
+ children: "Your page must include:"
311
363
  }
312
- }
313
- )
364
+ ),
365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
366
+ "ul",
367
+ {
368
+ ...{
369
+ className: "mt-2 list-disc pl-5 space-y-1"
370
+ },
371
+ children: include.map((line) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: line }, line))
372
+ }
373
+ )
374
+ ]
314
375
  }
315
- )
316
- }
317
- },
318
- "document"
319
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
320
- Field,
321
- {
322
- ...{
323
- control,
324
- error: (_c = errors.link) == null ? void 0 : _c.message,
325
- label: "Link",
326
- name: "link",
327
- render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
- import_input_url.default,
376
+ ),
377
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
378
+ Field,
329
379
  {
330
380
  ...{
331
- onChange,
332
- value: value || ""
381
+ control,
382
+ error: (_d = errors.confirm) == null ? void 0 : _d.message,
383
+ name: "confirm",
384
+ render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
385
+ import_input_checkbox.default,
386
+ {
387
+ ...{
388
+ id: "agreement-confirm-" + id,
389
+ label: "I confirm this is correct",
390
+ onChange,
391
+ value: Boolean(value)
392
+ }
393
+ }
394
+ )
333
395
  }
334
396
  }
335
397
  )
336
- }
337
- },
338
- "link"
398
+ ]
399
+ }
339
400
  )
340
401
  ]
341
402
  }
342
403
  ),
343
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
404
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
344
405
  import_fieldset.default,
345
406
  {
346
407
  ...{
347
- className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 pt-6 border-t border-gray",
408
+ className: "flex justify-end pt-6 border-t border-gray",
348
409
  disabled
349
410
  },
350
- children: [
351
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
352
- Field,
353
- {
354
- ...{
355
- control,
356
- error: (_d = errors.confirm) == null ? void 0 : _d.message,
357
- name: "confirm",
358
- render: ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
359
- import_input_checkbox.default,
360
- {
361
- ...{
362
- id: "agreement-confirm-" + id,
363
- label: "I confirm this is correct",
364
- onChange,
365
- value: Boolean(value)
366
- }
367
- }
368
- )
411
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
412
+ "span",
413
+ {
414
+ ...{
415
+ className: "sm:w-40 shrink-0"
416
+ },
417
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
418
+ import_button.default,
419
+ {
420
+ ...{
421
+ loading: formState == null ? void 0 : formState.isSubmitting,
422
+ type: "submit"
423
+ },
424
+ children: "Save"
369
425
  }
370
- }
371
- ),
372
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
373
- "span",
374
- {
375
- ...{
376
- className: "sm:w-40 shrink-0"
377
- },
378
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
379
- import_button.default,
380
- {
381
- ...{
382
- loading: formState == null ? void 0 : formState.isSubmitting,
383
- type: "submit"
384
- },
385
- children: "Save"
386
- }
387
- )
388
- }
389
- )
390
- ]
426
+ )
427
+ }
428
+ )
391
429
  }
392
430
  )
393
431
  ]
@@ -77,7 +77,7 @@ const FormOrganizationCampaignAgreement = ({
77
77
  readOnly
78
78
  }) => {
79
79
  var _a, _b, _c, _d;
80
- const { document: standard, types, values = {} } = agreement || {};
80
+ const { document: standard, include = [], types, values = {} } = agreement || {};
81
81
  const tabs = TABS.filter((tab) => (types || TABS).includes(tab));
82
82
  const saved = values.type || (values.link ? "link" : "document");
83
83
  const { control, formState, handleSubmit, setValue } = useForm({
@@ -114,6 +114,7 @@ const FormOrganizationCampaignAgreement = ({
114
114
  blocks.current ??= documentBlocks({
115
115
  data,
116
116
  insertable: standard == null ? void 0 : standard.pieces,
117
+ locked: standard == null ? void 0 : standard.locked,
117
118
  onClaim: (days) => {
118
119
  var _a2;
119
120
  return (_a2 = claim.current) == null ? void 0 : _a2.call(claim, days);
@@ -249,111 +250,148 @@ const FormOrganizationCampaignAgreement = ({
249
250
  }
250
251
  }
251
252
  ),
252
- editing ? /* @__PURE__ */ jsx(
253
- Field,
253
+ /* @__PURE__ */ jsxs(
254
+ "div",
254
255
  {
255
256
  ...{
256
- control,
257
- error: (_b = errors.document) == null ? void 0 : _b.message,
258
- name: "document",
259
- render: ({ onChange, value }) => /* @__PURE__ */ jsx(
257
+ className: "flex flex-col gap-3"
258
+ },
259
+ children: [
260
+ editing ? /* @__PURE__ */ jsx(
261
+ Field,
262
+ {
263
+ ...{
264
+ control,
265
+ error: (_b = errors.document) == null ? void 0 : _b.message,
266
+ name: "document",
267
+ render: ({ onChange, value }) => /* @__PURE__ */ jsx(
268
+ "div",
269
+ {
270
+ ...{
271
+ // What the screen leaves under the modal's other rows ( 38rem ), so the
272
+ // tick and Save stay in view on a laptop:
273
+ // the editor's toolbar stays and only the text scrolls.
274
+ className: "document h-[calc(100vh-38rem)] min-h-[12rem] flex flex-col [&>div]:flex-1 [&>div]:min-h-0 [&>div]:flex [&>div]:flex-col [&>div>div:has(>.ProseMirror)]:flex-1 [&>div>div:has(>.ProseMirror)]:min-h-0 [&>div>div:has(>.ProseMirror)]:overflow-y-auto",
275
+ "data-document": true
276
+ },
277
+ children: /* @__PURE__ */ jsx(
278
+ InputEditor,
279
+ {
280
+ ...{
281
+ blocks: blocks.current,
282
+ disabled: readOnly,
283
+ onChange: ({ html }) => onChange(html),
284
+ value: value || ""
285
+ }
286
+ }
287
+ )
288
+ }
289
+ )
290
+ }
291
+ },
292
+ "document"
293
+ ) : /* @__PURE__ */ jsx(
294
+ Field,
295
+ {
296
+ ...{
297
+ control,
298
+ error: (_c = errors.link) == null ? void 0 : _c.message,
299
+ label: "Link",
300
+ name: "link",
301
+ render: ({ onChange, value }) => /* @__PURE__ */ jsx(
302
+ InputUrl,
303
+ {
304
+ ...{
305
+ onChange,
306
+ value: value || ""
307
+ }
308
+ }
309
+ )
310
+ }
311
+ },
312
+ "link"
313
+ ),
314
+ !editing && include.length > 0 && /* @__PURE__ */ jsxs(
260
315
  "div",
261
316
  {
262
317
  ...{
263
- // What the screen leaves under the modal's other rows ( 38rem ), so the
264
- // tick and Save stay in view on a laptop:
265
- // the editor's toolbar stays and only the text scrolls.
266
- className: "document h-[calc(100vh-38rem)] min-h-[12rem] flex flex-col [&>div]:flex-1 [&>div]:min-h-0 [&>div]:flex [&>div]:flex-col [&>div>div:has(>.ProseMirror)]:flex-1 [&>div>div:has(>.ProseMirror)]:min-h-0 [&>div>div:has(>.ProseMirror)]:overflow-y-auto",
267
- "data-document": true
318
+ className: "rounded bg-gray-light p-4 text-sm",
319
+ "data-include": id
268
320
  },
269
- children: /* @__PURE__ */ jsx(
270
- InputEditor,
271
- {
272
- ...{
273
- blocks: blocks.current,
274
- disabled: readOnly,
275
- onChange: ({ html }) => onChange(html),
276
- value: value || ""
321
+ children: [
322
+ /* @__PURE__ */ jsx(
323
+ "p",
324
+ {
325
+ ...{
326
+ className: "font-medium"
327
+ },
328
+ children: "Your page must include:"
277
329
  }
278
- }
279
- )
330
+ ),
331
+ /* @__PURE__ */ jsx(
332
+ "ul",
333
+ {
334
+ ...{
335
+ className: "mt-2 list-disc pl-5 space-y-1"
336
+ },
337
+ children: include.map((line) => /* @__PURE__ */ jsx("li", { children: line }, line))
338
+ }
339
+ )
340
+ ]
280
341
  }
281
- )
282
- }
283
- },
284
- "document"
285
- ) : /* @__PURE__ */ jsx(
286
- Field,
287
- {
288
- ...{
289
- control,
290
- error: (_c = errors.link) == null ? void 0 : _c.message,
291
- label: "Link",
292
- name: "link",
293
- render: ({ onChange, value }) => /* @__PURE__ */ jsx(
294
- InputUrl,
342
+ ),
343
+ !readOnly && /* @__PURE__ */ jsx(
344
+ Field,
295
345
  {
296
346
  ...{
297
- onChange,
298
- value: value || ""
347
+ control,
348
+ error: (_d = errors.confirm) == null ? void 0 : _d.message,
349
+ name: "confirm",
350
+ render: ({ onChange, value }) => /* @__PURE__ */ jsx(
351
+ InputCheckbox,
352
+ {
353
+ ...{
354
+ id: "agreement-confirm-" + id,
355
+ label: "I confirm this is correct",
356
+ onChange,
357
+ value: Boolean(value)
358
+ }
359
+ }
360
+ )
299
361
  }
300
362
  }
301
363
  )
302
- }
303
- },
304
- "link"
364
+ ]
365
+ }
305
366
  )
306
367
  ]
307
368
  }
308
369
  ),
309
- !readOnly && /* @__PURE__ */ jsxs(
370
+ !readOnly && /* @__PURE__ */ jsx(
310
371
  Fieldset,
311
372
  {
312
373
  ...{
313
- className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 pt-6 border-t border-gray",
374
+ className: "flex justify-end pt-6 border-t border-gray",
314
375
  disabled
315
376
  },
316
- children: [
317
- /* @__PURE__ */ jsx(
318
- Field,
319
- {
320
- ...{
321
- control,
322
- error: (_d = errors.confirm) == null ? void 0 : _d.message,
323
- name: "confirm",
324
- render: ({ onChange, value }) => /* @__PURE__ */ jsx(
325
- InputCheckbox,
326
- {
327
- ...{
328
- id: "agreement-confirm-" + id,
329
- label: "I confirm this is correct",
330
- onChange,
331
- value: Boolean(value)
332
- }
333
- }
334
- )
377
+ children: /* @__PURE__ */ jsx(
378
+ "span",
379
+ {
380
+ ...{
381
+ className: "sm:w-40 shrink-0"
382
+ },
383
+ children: /* @__PURE__ */ jsx(
384
+ Button,
385
+ {
386
+ ...{
387
+ loading: formState == null ? void 0 : formState.isSubmitting,
388
+ type: "submit"
389
+ },
390
+ children: "Save"
335
391
  }
336
- }
337
- ),
338
- /* @__PURE__ */ jsx(
339
- "span",
340
- {
341
- ...{
342
- className: "sm:w-40 shrink-0"
343
- },
344
- children: /* @__PURE__ */ jsx(
345
- Button,
346
- {
347
- ...{
348
- loading: formState == null ? void 0 : formState.isSubmitting,
349
- type: "submit"
350
- },
351
- children: "Save"
352
- }
353
- )
354
- }
355
- )
356
- ]
392
+ )
393
+ }
394
+ )
357
395
  }
358
396
  )
359
397
  ]
@@ -175,12 +175,20 @@ const TemplateUIHeaderSettings = ({
175
175
  }
176
176
  ),
177
177
  error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
- import_indicator.default,
178
+ "span",
179
179
  {
180
180
  ...{
181
- className: "absolute top-1.5 right-1.5 w-2 h-2",
182
- type: "warning"
183
- }
181
+ className: "absolute top-1.5 right-1.5 flex pointer-events-none"
182
+ },
183
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
184
+ import_indicator.default,
185
+ {
186
+ ...{
187
+ className: "w-2 h-2",
188
+ type: "warning"
189
+ }
190
+ }
191
+ )
184
192
  }
185
193
  )
186
194
  ]
@@ -143,12 +143,20 @@ const TemplateUIHeaderSettings = ({
143
143
  }
144
144
  ),
145
145
  error && /* @__PURE__ */ jsx(
146
- Indicator,
146
+ "span",
147
147
  {
148
148
  ...{
149
- className: "absolute top-1.5 right-1.5 w-2 h-2",
150
- type: "warning"
151
- }
149
+ className: "absolute top-1.5 right-1.5 flex pointer-events-none"
150
+ },
151
+ children: /* @__PURE__ */ jsx(
152
+ Indicator,
153
+ {
154
+ ...{
155
+ className: "w-2 h-2",
156
+ type: "warning"
157
+ }
158
+ }
159
+ )
152
160
  }
153
161
  )
154
162
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -68,6 +68,3 @@ export declare const menuAgreements: ( data?: { agreements?: Record<string, any>
68
68
 
69
69
  // The payload's agreements with the locale endpoint's content over them.
70
70
  export declare const withLocale: ( agreements?: Record<string, any>, locale?: Record<string, any> ) => Record<string, any>;
71
-
72
- // The line under a linked Terms checkbox; null while the giveaway is off.
73
- export declare const termsOptOut: ( values?: { giveaway?: boolean; sms?: boolean } ) => string | null;
@@ -2,13 +2,14 @@ import { Node } from '@tiptap/core';
2
2
  import { DocumentData } from '../shared/document-pieces';
3
3
  import { InputEditorBlocks } from './input-editor';
4
4
 
5
- export declare const documentNodes: ( options: { data?: DocumentData; onClaim?: ( days: number ) => void } ) => Node[];
5
+ // `locked`: piece keys with no close button, which no edit removes.
6
+ export declare const documentNodes: ( options: { data?: DocumentData; locked?: string[]; onClaim?: ( days: number ) => void } ) => Node[];
6
7
 
7
8
  export declare const present: ( editor: any ) => Set<string>;
8
9
 
9
10
  export declare const insertPiece: ( editor: any, key: string ) => void;
10
11
 
11
12
  // What InputEditor takes as `blocks`: the grey blocks, H1 to H3, List and Insert.
12
- declare const documentBlocks: ( options: { data?: DocumentData; insertable?: string[]; onClaim?: ( days: number ) => void } ) => InputEditorBlocks;
13
+ declare const documentBlocks: ( options: { data?: DocumentData; insertable?: string[]; locked?: string[]; onClaim?: ( days: number ) => void } ) => InputEditorBlocks;
13
14
 
14
15
  export default documentBlocks;
@@ -21,9 +21,12 @@ export interface Agreement {
21
21
  active?: boolean;
22
22
  // The one line under its title.
23
23
  description?: string;
24
- // Our standard document: its name, the pieces Insert lists, its text.
25
- document?: { name: string; pieces: string[]; standard: string };
24
+ // Our standard document: its name, the pieces Insert lists, its text, and the
25
+ // pieces no edit removes ( Opting out while the giveaway is on ).
26
+ document?: { locked?: string[]; name: string; pieces: string[]; standard: string };
26
27
  enforceLink?: boolean;
28
+ // What a linked page must include, as the api lists it: shown in a gray box under Link.
29
+ include?: string[];
27
30
  title: string;
28
31
  // What it may be saved as: Document and Link, or Link alone while documents are switched off.
29
32
  types?: ( 'document' | 'link' )[];