@drawbridge/components 0.1.13 → 0.1.14

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 (236) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +20 -7
  147. package/dist/dashboard/template-socket.mjs +20 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -0,0 +1,437 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Controller, useForm, useWatch } from "../shared/lib/form.mjs";
4
+ import { request } from "@drawbridge/drawbridge-utils/fetch";
5
+ import yup, { resolver } from "../shared/lib/yup.mjs";
6
+ import { itemsBody, itemSummary } from "./lib/item-list.mjs";
7
+ import Form from "../shared/form.mjs";
8
+ import Fieldset from "../shared/fieldset.mjs";
9
+ import InputGroup from "../input-group.mjs";
10
+ import InputText from "../input-text.mjs";
11
+ import InputNumber from "../input-number.mjs";
12
+ import InputFile from "./input-file.mjs";
13
+ import { InputArrayButton, InputArraySortable } from "./input-array.mjs";
14
+ import Dropdown from "./dropdown.mjs";
15
+ import CardAsset from "../shared/card-asset.mjs";
16
+ import Ellipsis from "../icons/ellipsis.mjs";
17
+ import ArrowLeft from "../icons/arrow-left.mjs";
18
+ import Button from "../shared/button.mjs";
19
+ const number = (label) => yup.number().label(label).transform((value, original) => original === "" ? void 0 : value).nullable();
20
+ const item = yup.object({
21
+ // The Number field's attributes ( its Max value ), so the entry form checks it the same way.
22
+ attributes: yup.object({
23
+ max: number("Limit").integer().min(1)
24
+ }),
25
+ description: yup.string().label("Description").max(150).nullable(),
26
+ name: yup.string().label("Name").required().max(150),
27
+ price: number("Price").min(0).test("cents", "Price can have two decimals at most", (value) => value == null || Math.abs(Math.round(value * 100) - value * 100) < 1e-6).max(1e6)
28
+ });
29
+ const FormOrganizationCampaignFieldList = ({
30
+ disabled,
31
+ onError,
32
+ onSuccess,
33
+ values
34
+ }) => {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
36
+ const [editing, setEditing] = useState(null);
37
+ const prices = (values == null ? void 0 : values.prices) !== false;
38
+ const currency = ((values == null ? void 0 : values.currency) || "usd").toUpperCase();
39
+ const { clearErrors, control, formState, handleSubmit, setValue, trigger } = useForm({
40
+ resolver: resolver(
41
+ yup.object({
42
+ label: yup.string().label("Label").required().max(150),
43
+ settings: yup.object({
44
+ // @story fields/item-list: "Items field must have at most 50 items" (yup's own reads "less than or equal to").
45
+ items: yup.array().label("Items").required().min(1).max(50, "${path} field must have at most ${max} items").of(item)
46
+ })
47
+ })
48
+ ),
49
+ // A new list starts with no items, so Submit says "at least 1", not "required".
50
+ values: {
51
+ ...values,
52
+ settings: {
53
+ items: [],
54
+ ...values == null ? void 0 : values.settings
55
+ }
56
+ }
57
+ });
58
+ const items = useWatch({
59
+ control,
60
+ name: "settings.items"
61
+ }) || [];
62
+ const onSubmit = async ({
63
+ label,
64
+ settings = {}
65
+ }) => {
66
+ try {
67
+ const response = await request({
68
+ body: {
69
+ label,
70
+ settings: {
71
+ items: itemsBody(settings.items)
72
+ },
73
+ slug: "list",
74
+ type: "order"
75
+ },
76
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field" + ((values == null ? void 0 : values.id) ? "/" + values.id : ""),
77
+ method: (values == null ? void 0 : values.id) ? "PUT" : "POST"
78
+ });
79
+ onSuccess(response);
80
+ } catch (error) {
81
+ onError(error);
82
+ }
83
+ };
84
+ const done = async () => {
85
+ if (await trigger("settings.items." + editing)) setEditing(null);
86
+ };
87
+ const errors = ((_c = (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.settings) == null ? void 0 : _b.items) == null ? void 0 : _c[editing]) || {};
88
+ const name = (key) => `settings.items.${editing}.${key}`;
89
+ const amount = (key, label, { message, step } = {}) => /* @__PURE__ */ jsx(
90
+ Controller,
91
+ {
92
+ ...{
93
+ control,
94
+ name: name(key),
95
+ render: ({ field: { value, onChange } }) => {
96
+ var _a2;
97
+ return /* @__PURE__ */ jsx(
98
+ InputGroup,
99
+ {
100
+ ...{
101
+ error: (_a2 = key.split(".").reduce((at, part) => at == null ? void 0 : at[part], errors)) == null ? void 0 : _a2.message,
102
+ input: /* @__PURE__ */ jsx(
103
+ InputNumber,
104
+ {
105
+ ...{
106
+ min: 0,
107
+ onChange,
108
+ ...step && {
109
+ step
110
+ },
111
+ value: value ?? ""
112
+ }
113
+ }
114
+ ),
115
+ label,
116
+ message
117
+ }
118
+ }
119
+ );
120
+ }
121
+ }
122
+ },
123
+ key
124
+ );
125
+ return /* @__PURE__ */ jsxs(
126
+ Form,
127
+ {
128
+ ...{
129
+ className: "relative w-full space-y-6",
130
+ onSubmit: handleSubmit(onSubmit)
131
+ },
132
+ children: [
133
+ editing === null ? /* @__PURE__ */ jsxs(
134
+ Fieldset,
135
+ {
136
+ ...{
137
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
138
+ },
139
+ children: [
140
+ /* @__PURE__ */ jsx(
141
+ Controller,
142
+ {
143
+ ...{
144
+ control,
145
+ name: "label",
146
+ render: ({ field: { value, onChange } }) => {
147
+ var _a2, _b2;
148
+ return /* @__PURE__ */ jsx(
149
+ InputGroup,
150
+ {
151
+ ...{
152
+ error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b2.message,
153
+ input: /* @__PURE__ */ jsx(
154
+ InputText,
155
+ {
156
+ ...{
157
+ onChange,
158
+ value: value || ""
159
+ }
160
+ }
161
+ ),
162
+ label: "Field label"
163
+ }
164
+ }
165
+ );
166
+ }
167
+ }
168
+ }
169
+ ),
170
+ /* @__PURE__ */ jsx(
171
+ InputGroup,
172
+ {
173
+ ...{
174
+ // A field array's own error lands on `root`.
175
+ error: (_i = ((_f = (_e = (_d = formState == null ? void 0 : formState.errors) == null ? void 0 : _d.settings) == null ? void 0 : _e.items) == null ? void 0 : _f.root) || ((_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.settings) == null ? void 0 : _h.items)) == null ? void 0 : _i.message,
176
+ input: /* @__PURE__ */ jsx(
177
+ InputArraySortable,
178
+ {
179
+ ...{
180
+ control,
181
+ empty: "No items have been added",
182
+ name: "settings.items",
183
+ renderButton: (append) => /* @__PURE__ */ jsx(
184
+ InputArrayButton,
185
+ {
186
+ ...{
187
+ disabled,
188
+ onClick: () => {
189
+ append({
190
+ attributes: {
191
+ max: null
192
+ },
193
+ description: null,
194
+ image: null,
195
+ name: "",
196
+ price: null
197
+ });
198
+ clearErrors("settings.items");
199
+ setEditing(items.length);
200
+ },
201
+ text: "Add item"
202
+ }
203
+ }
204
+ ),
205
+ renderControls: ({ index, remove }) => {
206
+ var _a2;
207
+ return [
208
+ /* @__PURE__ */ jsx(
209
+ Dropdown,
210
+ {
211
+ ...{
212
+ button: {
213
+ "aria-label": (((_a2 = items == null ? void 0 : items[index]) == null ? void 0 : _a2.name) || "Item") + " options",
214
+ disabled,
215
+ icon: Ellipsis
216
+ },
217
+ items: [
218
+ {
219
+ element: "button",
220
+ onClick: () => setEditing(index),
221
+ title: "Edit",
222
+ type: "button"
223
+ },
224
+ {
225
+ className: "text-red-dark",
226
+ element: "button",
227
+ onClick: () => remove(index),
228
+ title: "Remove",
229
+ type: "button"
230
+ }
231
+ ]
232
+ }
233
+ },
234
+ "item-options-" + index
235
+ )
236
+ ];
237
+ }
238
+ },
239
+ children: ({ handle, index }) => {
240
+ var _a2;
241
+ const row = (items == null ? void 0 : items[index]) || {};
242
+ const summary = itemSummary(row, prices, currency);
243
+ return /* @__PURE__ */ jsxs(
244
+ "div",
245
+ {
246
+ ...{
247
+ className: "flex items-center min-w-0 flex-1 gap-3"
248
+ },
249
+ children: [
250
+ handle,
251
+ /* @__PURE__ */ jsx(
252
+ CardAsset,
253
+ {
254
+ ...{
255
+ asset: row.image || null,
256
+ className: "w-10 h-10",
257
+ classNameContainer: "bg-gray-light border border-gray",
258
+ sizes: "40px",
259
+ title: row.description || ((_a2 = row.image) == null ? void 0 : _a2.filename)
260
+ }
261
+ }
262
+ ),
263
+ /* @__PURE__ */ jsxs(
264
+ "span",
265
+ {
266
+ ...{
267
+ className: "flex flex-col min-w-0"
268
+ },
269
+ children: [
270
+ /* @__PURE__ */ jsx(
271
+ "span",
272
+ {
273
+ ...{
274
+ className: "truncate"
275
+ },
276
+ children: row.name || "Untitled item"
277
+ }
278
+ ),
279
+ summary && /* @__PURE__ */ jsx(
280
+ "span",
281
+ {
282
+ ...{
283
+ className: "text-sm text-gray-dark truncate"
284
+ },
285
+ children: summary
286
+ }
287
+ )
288
+ ]
289
+ }
290
+ )
291
+ ]
292
+ }
293
+ );
294
+ }
295
+ }
296
+ ),
297
+ label: "Items"
298
+ }
299
+ }
300
+ )
301
+ ]
302
+ }
303
+ ) : /* @__PURE__ */ jsxs(
304
+ Fieldset,
305
+ {
306
+ ...{
307
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
308
+ },
309
+ children: [
310
+ /* @__PURE__ */ jsx(
311
+ Button,
312
+ {
313
+ ...{
314
+ icon: ArrowLeft,
315
+ inline: true,
316
+ onClick: done,
317
+ reverse: true,
318
+ type: "button",
319
+ variant: "link"
320
+ },
321
+ children: "Items"
322
+ }
323
+ ),
324
+ /* @__PURE__ */ jsx(
325
+ Controller,
326
+ {
327
+ ...{
328
+ control,
329
+ name: name("name"),
330
+ render: ({ field: { value, onChange } }) => {
331
+ var _a2;
332
+ return /* @__PURE__ */ jsx(
333
+ InputGroup,
334
+ {
335
+ ...{
336
+ error: (_a2 = errors == null ? void 0 : errors.name) == null ? void 0 : _a2.message,
337
+ input: /* @__PURE__ */ jsx(
338
+ InputText,
339
+ {
340
+ ...{
341
+ onChange,
342
+ value: value ?? ""
343
+ }
344
+ }
345
+ ),
346
+ label: "Name"
347
+ }
348
+ }
349
+ );
350
+ }
351
+ }
352
+ },
353
+ "name"
354
+ ),
355
+ prices && amount("price", "Price", { message: "In " + currency + ", your organization's currency. Adds to the estimated total.", step: 0.01 }),
356
+ amount("attributes.max", "Limit", { message: "The most one order can take. Leave blank for no limit." }),
357
+ /* @__PURE__ */ jsx(
358
+ Controller,
359
+ {
360
+ ...{
361
+ control,
362
+ name: name("image"),
363
+ render: ({ field: { value, onChange } }) => {
364
+ var _a2, _b2;
365
+ return /* @__PURE__ */ jsx(
366
+ InputGroup,
367
+ {
368
+ ...{
369
+ error: (_a2 = errors == null ? void 0 : errors.description) == null ? void 0 : _a2.message,
370
+ input: /* @__PURE__ */ jsx(
371
+ InputFile,
372
+ {
373
+ ...{
374
+ button: {
375
+ text: "Select an image"
376
+ },
377
+ description: (_b2 = items == null ? void 0 : items[editing]) == null ? void 0 : _b2.description,
378
+ disabled,
379
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization),
380
+ onChange,
381
+ onDescription: (text) => setValue(name("description"), text, { shouldDirty: true }),
382
+ organization: values == null ? void 0 : values.organization,
383
+ // The api takes an image file only.
384
+ type: "image",
385
+ value: value || ""
386
+ }
387
+ }
388
+ ),
389
+ label: "Image",
390
+ message: "Once chosen, type its description: it is the image's alt text."
391
+ }
392
+ }
393
+ );
394
+ }
395
+ }
396
+ }
397
+ )
398
+ ]
399
+ }
400
+ ),
401
+ /* @__PURE__ */ jsx(
402
+ Fieldset,
403
+ {
404
+ ...{
405
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
406
+ },
407
+ children: editing === null ? /* @__PURE__ */ jsx(
408
+ Button,
409
+ {
410
+ ...{
411
+ loading: formState == null ? void 0 : formState.isSubmitting,
412
+ type: "submit"
413
+ },
414
+ children: "Submit"
415
+ },
416
+ "submit"
417
+ ) : /* @__PURE__ */ jsx(
418
+ Button,
419
+ {
420
+ ...{
421
+ onClick: done,
422
+ type: "button"
423
+ },
424
+ children: "Done"
425
+ },
426
+ "done"
427
+ )
428
+ }
429
+ )
430
+ ]
431
+ }
432
+ );
433
+ };
434
+ var form_organization_campaign_field_list_default = FormOrganizationCampaignFieldList;
435
+ export {
436
+ form_organization_campaign_field_list_default as default
437
+ };
@@ -40,7 +40,6 @@ var import_fieldset = __toESM(require("../shared/fieldset"));
40
40
  var import_input_group = __toESM(require("../input-group"));
41
41
  var import_input_text = __toESM(require("../input-text"));
42
42
  var import_input_checkbox_list = __toESM(require("../shared/input-checkbox-list"));
43
- var import_input_switch = __toESM(require("../shared/input-switch"));
44
43
  var import_button = __toESM(require("../shared/button"));
45
44
  const FormOrganizationCampaignFieldPhone = ({
46
45
  disabled,
@@ -66,14 +65,12 @@ const FormOrganizationCampaignFieldPhone = ({
66
65
  });
67
66
  const onSubmit = async ({
68
67
  label,
69
- primary,
70
68
  settings = {}
71
69
  }) => {
72
70
  try {
73
71
  const args = {
74
72
  body: {
75
73
  label,
76
- primary,
77
74
  settings,
78
75
  slug: values == null ? void 0 : values.slug,
79
76
  type: values == null ? void 0 : values.type
@@ -137,37 +134,6 @@ const FormOrganizationCampaignFieldPhone = ({
137
134
  }
138
135
  }
139
136
  ),
140
- (values == null ? void 0 : values.id) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
- import_form.Controller,
142
- {
143
- ...{
144
- control,
145
- name: "primary",
146
- render: ({ field: { value, onChange } }) => {
147
- var _a, _b;
148
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
- import_input_group.default,
150
- {
151
- ...{
152
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.primary) == null ? void 0 : _b.message,
153
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
- import_input_switch.default,
155
- {
156
- ...{
157
- disabled: Boolean(values.primary) || !inputs.includes("primary"),
158
- onChange,
159
- value: value || false
160
- }
161
- }
162
- ),
163
- label: "Primary"
164
- }
165
- }
166
- );
167
- }
168
- }
169
- }
170
- ),
171
137
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
138
  import_form.Controller,
173
139
  {
@@ -8,7 +8,6 @@ import Fieldset from "../shared/fieldset.mjs";
8
8
  import InputGroup from "../input-group.mjs";
9
9
  import InputText from "../input-text.mjs";
10
10
  import InputCheckboxList from "../shared/input-checkbox-list.mjs";
11
- import InputSwitch from "../shared/input-switch.mjs";
12
11
  import Button from "../shared/button.mjs";
13
12
  const FormOrganizationCampaignFieldPhone = ({
14
13
  disabled,
@@ -34,14 +33,12 @@ const FormOrganizationCampaignFieldPhone = ({
34
33
  });
35
34
  const onSubmit = async ({
36
35
  label,
37
- primary,
38
36
  settings = {}
39
37
  }) => {
40
38
  try {
41
39
  const args = {
42
40
  body: {
43
41
  label,
44
- primary,
45
42
  settings,
46
43
  slug: values == null ? void 0 : values.slug,
47
44
  type: values == null ? void 0 : values.type
@@ -105,37 +102,6 @@ const FormOrganizationCampaignFieldPhone = ({
105
102
  }
106
103
  }
107
104
  ),
108
- (values == null ? void 0 : values.id) && /* @__PURE__ */ jsx(
109
- Controller,
110
- {
111
- ...{
112
- control,
113
- name: "primary",
114
- render: ({ field: { value, onChange } }) => {
115
- var _a, _b;
116
- return /* @__PURE__ */ jsx(
117
- InputGroup,
118
- {
119
- ...{
120
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.primary) == null ? void 0 : _b.message,
121
- input: /* @__PURE__ */ jsx(
122
- InputSwitch,
123
- {
124
- ...{
125
- disabled: Boolean(values.primary) || !inputs.includes("primary"),
126
- onChange,
127
- value: value || false
128
- }
129
- }
130
- ),
131
- label: "Primary"
132
- }
133
- }
134
- );
135
- }
136
- }
137
- }
138
- ),
139
105
  /* @__PURE__ */ jsx(
140
106
  Controller,
141
107
  {
@@ -0,0 +1,66 @@
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 form_organization_campaign_field_remove_exports = {};
29
+ __export(form_organization_campaign_field_remove_exports, {
30
+ default: () => form_organization_campaign_field_remove_default,
31
+ fieldRemoveWarnings: () => fieldRemoveWarnings
32
+ });
33
+ module.exports = __toCommonJS(form_organization_campaign_field_remove_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_form_action = __toESM(require("./form-action"));
36
+ var import_card_task = __toESM(require("./card-task"));
37
+ const fieldRemoveWarnings = (field) => ((field == null ? void 0 : field.workflows) || []).map(
38
+ ({ chain, step }) => step + " in " + chain + " uses this field. It won't run until you add " + ((field == null ? void 0 : field.slug) === "email" ? "an email" : "a phone") + " field again."
39
+ );
40
+ const FormOrganizationCampaignFieldRemove = ({
41
+ field,
42
+ ...rest
43
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
44
+ import_form_action.default,
45
+ {
46
+ ...rest,
47
+ children: [
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Are you sure you want to remove this field?" }),
49
+ fieldRemoveWarnings(field).map((message) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
50
+ import_card_task.default,
51
+ {
52
+ ...{
53
+ message,
54
+ type: "warning"
55
+ }
56
+ },
57
+ message
58
+ ))
59
+ ]
60
+ }
61
+ );
62
+ var form_organization_campaign_field_remove_default = FormOrganizationCampaignFieldRemove;
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ fieldRemoveWarnings
66
+ });
@@ -0,0 +1,33 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import FormAction from "./form-action.mjs";
3
+ import CardTask from "./card-task.mjs";
4
+ const fieldRemoveWarnings = (field) => ((field == null ? void 0 : field.workflows) || []).map(
5
+ ({ chain, step }) => step + " in " + chain + " uses this field. It won't run until you add " + ((field == null ? void 0 : field.slug) === "email" ? "an email" : "a phone") + " field again."
6
+ );
7
+ const FormOrganizationCampaignFieldRemove = ({
8
+ field,
9
+ ...rest
10
+ }) => /* @__PURE__ */ jsxs(
11
+ FormAction,
12
+ {
13
+ ...rest,
14
+ children: [
15
+ /* @__PURE__ */ jsx("p", { children: "Are you sure you want to remove this field?" }),
16
+ fieldRemoveWarnings(field).map((message) => /* @__PURE__ */ jsx(
17
+ CardTask,
18
+ {
19
+ ...{
20
+ message,
21
+ type: "warning"
22
+ }
23
+ },
24
+ message
25
+ ))
26
+ ]
27
+ }
28
+ );
29
+ var form_organization_campaign_field_remove_default = FormOrganizationCampaignFieldRemove;
30
+ export {
31
+ form_organization_campaign_field_remove_default as default,
32
+ fieldRemoveWarnings
33
+ };