@01.software/sdk 0.2.9-dev.260310.cf511cb → 0.2.9-dev.260311.892250f
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.
- package/README.md +21 -8
- package/dist/auth.cjs +3 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +36 -3
- package/dist/auth.d.ts +36 -3
- package/dist/auth.js +3 -1
- package/dist/auth.js.map +1 -1
- package/dist/index.cjs +214 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +321 -155
- package/dist/index.d.ts +321 -155
- package/dist/index.js +217 -231
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-Cq93wqIe.d.cts → payload-types-BjvBwB8Z.d.cts} +1601 -1373
- package/dist/{payload-types-Cq93wqIe.d.ts → payload-types-BjvBwB8Z.d.ts} +1601 -1373
- package/dist/ui/code-block.cjs +182 -0
- package/dist/ui/code-block.cjs.map +1 -0
- package/dist/ui/code-block.d.cts +62 -0
- package/dist/ui/code-block.d.ts +62 -0
- package/dist/ui/code-block.js +152 -0
- package/dist/ui/code-block.js.map +1 -0
- package/dist/{flow.cjs → ui/flow.cjs} +120 -96
- package/dist/ui/flow.cjs.map +1 -0
- package/dist/{flow.d.cts → ui/flow.d.cts} +27 -11
- package/dist/{flow.d.ts → ui/flow.d.ts} +27 -11
- package/dist/{flow.js → ui/flow.js} +119 -94
- package/dist/ui/flow.js.map +1 -0
- package/dist/{components.cjs → ui/form.cjs} +27 -520
- package/dist/ui/form.cjs.map +1 -0
- package/dist/ui/form.d.cts +37 -0
- package/dist/ui/form.d.ts +37 -0
- package/dist/{components.js → ui/form.js} +20 -516
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/image.cjs +208 -0
- package/dist/ui/image.cjs.map +1 -0
- package/dist/ui/image.d.cts +44 -0
- package/dist/ui/image.d.ts +44 -0
- package/dist/ui/image.js +180 -0
- package/dist/ui/image.js.map +1 -0
- package/dist/ui/rich-text.cjs +258 -0
- package/dist/ui/rich-text.cjs.map +1 -0
- package/dist/ui/rich-text.d.cts +110 -0
- package/dist/ui/rich-text.d.ts +110 -0
- package/dist/ui/rich-text.js +235 -0
- package/dist/ui/rich-text.js.map +1 -0
- package/dist/{webhook-NRdVwXN7.d.cts → webhook-CszIpUKn.d.cts} +2 -2
- package/dist/{webhook-C_7s0K66.d.ts → webhook-_LdLdjGa.d.ts} +2 -2
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +47 -12
- package/dist/auth-CVVo5UT5.d.ts +0 -298
- package/dist/auth-CqgrT1qd.d.cts +0 -298
- package/dist/components.cjs.map +0 -1
- package/dist/components.d.cts +0 -240
- package/dist/components.d.ts +0 -240
- package/dist/components.js.map +0 -1
- package/dist/flow.cjs.map +0 -1
- package/dist/flow.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __defProps = Object.defineProperties;
|
|
@@ -22,18 +23,6 @@ var __spreadValues = (a, b) => {
|
|
|
22
23
|
return a;
|
|
23
24
|
};
|
|
24
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
26
|
var __export = (target, all) => {
|
|
38
27
|
for (var name in all)
|
|
39
28
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -76,216 +65,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
76
65
|
});
|
|
77
66
|
};
|
|
78
67
|
|
|
79
|
-
// src/
|
|
80
|
-
var
|
|
81
|
-
__export(
|
|
82
|
-
CodeBlock: () => CodeBlock,
|
|
68
|
+
// src/ui/Form/index.tsx
|
|
69
|
+
var Form_exports = {};
|
|
70
|
+
__export(Form_exports, {
|
|
83
71
|
FormRenderer: () => FormRenderer,
|
|
84
|
-
Image: () => Image,
|
|
85
|
-
RichTextContent: () => RichTextContent,
|
|
86
|
-
StyledRichTextContent: () => StyledRichTextContent,
|
|
87
|
-
highlight: () => highlight,
|
|
88
72
|
toSubmissionData: () => toSubmissionData
|
|
89
73
|
});
|
|
90
|
-
module.exports = __toCommonJS(
|
|
91
|
-
|
|
92
|
-
// src/components/RichTextContent/index.tsx
|
|
93
|
-
var import_react2 = __toESM(require("react"), 1);
|
|
94
|
-
var import_react3 = require("@payloadcms/richtext-lexical/react");
|
|
95
|
-
|
|
96
|
-
// src/components/RichTextContent/styled.tsx
|
|
74
|
+
module.exports = __toCommonJS(Form_exports);
|
|
97
75
|
var import_react = __toESM(require("react"), 1);
|
|
98
|
-
function createComponentConverters(components, internalDocToHref) {
|
|
99
|
-
const converters = {};
|
|
100
|
-
if (components.Heading) {
|
|
101
|
-
const Heading = components.Heading;
|
|
102
|
-
converters.heading = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(Heading, { tag: node.tag, node }, nodesToJSX({ nodes: node.children }));
|
|
103
|
-
}
|
|
104
|
-
if (components.Paragraph) {
|
|
105
|
-
const Paragraph = components.Paragraph;
|
|
106
|
-
converters.paragraph = ({ node, nodesToJSX }) => {
|
|
107
|
-
const children = nodesToJSX({ nodes: node.children });
|
|
108
|
-
return /* @__PURE__ */ import_react.default.createElement(Paragraph, { isEmpty: !(children == null ? void 0 : children.length), node }, (children == null ? void 0 : children.length) ? children : /* @__PURE__ */ import_react.default.createElement("br", null));
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
if (components.Blockquote) {
|
|
112
|
-
const Blockquote = components.Blockquote;
|
|
113
|
-
converters.quote = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(Blockquote, { node }, nodesToJSX({ nodes: node.children }));
|
|
114
|
-
}
|
|
115
|
-
if (components.List) {
|
|
116
|
-
const List = components.List;
|
|
117
|
-
converters.list = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(List, { tag: node.tag, listType: node.listType, node }, nodesToJSX({ nodes: node.children }));
|
|
118
|
-
}
|
|
119
|
-
if (components.ListItem) {
|
|
120
|
-
const ListItem = components.ListItem;
|
|
121
|
-
converters.listitem = ({ node, nodesToJSX }) => {
|
|
122
|
-
const hasSubLists = node.children.some(
|
|
123
|
-
(child) => child.type === "list"
|
|
124
|
-
);
|
|
125
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
126
|
-
ListItem,
|
|
127
|
-
{
|
|
128
|
-
hasSubLists,
|
|
129
|
-
checked: node.checked,
|
|
130
|
-
value: node.value,
|
|
131
|
-
node
|
|
132
|
-
},
|
|
133
|
-
nodesToJSX({ nodes: node.children })
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
if (components.Link) {
|
|
138
|
-
const Link = components.Link;
|
|
139
|
-
const resolveHref = (node) => {
|
|
140
|
-
var _a;
|
|
141
|
-
if (node.fields.linkType === "internal") {
|
|
142
|
-
return internalDocToHref ? internalDocToHref({ linkNode: node }) : "#";
|
|
143
|
-
}
|
|
144
|
-
return (_a = node.fields.url) != null ? _a : "";
|
|
145
|
-
};
|
|
146
|
-
converters.link = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(
|
|
147
|
-
Link,
|
|
148
|
-
{
|
|
149
|
-
href: resolveHref(node),
|
|
150
|
-
rel: node.fields.newTab ? "noopener noreferrer" : void 0,
|
|
151
|
-
target: node.fields.newTab ? "_blank" : void 0,
|
|
152
|
-
node
|
|
153
|
-
},
|
|
154
|
-
nodesToJSX({ nodes: node.children })
|
|
155
|
-
);
|
|
156
|
-
converters.autolink = ({ node, nodesToJSX }) => {
|
|
157
|
-
var _a;
|
|
158
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
159
|
-
Link,
|
|
160
|
-
{
|
|
161
|
-
href: (_a = node.fields.url) != null ? _a : "",
|
|
162
|
-
rel: node.fields.newTab ? "noopener noreferrer" : void 0,
|
|
163
|
-
target: node.fields.newTab ? "_blank" : void 0,
|
|
164
|
-
node
|
|
165
|
-
},
|
|
166
|
-
nodesToJSX({ nodes: node.children })
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (components.HorizontalRule) {
|
|
171
|
-
const HorizontalRule = components.HorizontalRule;
|
|
172
|
-
converters.horizontalrule = /* @__PURE__ */ import_react.default.createElement(HorizontalRule, null);
|
|
173
|
-
}
|
|
174
|
-
if (components.Upload) {
|
|
175
|
-
const Upload = components.Upload;
|
|
176
|
-
converters.upload = ({ node }) => {
|
|
177
|
-
var _a;
|
|
178
|
-
const uploadNode = node;
|
|
179
|
-
if (typeof uploadNode.value !== "object") return null;
|
|
180
|
-
const doc = uploadNode.value;
|
|
181
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
182
|
-
Upload,
|
|
183
|
-
{
|
|
184
|
-
src: doc.url,
|
|
185
|
-
alt: ((_a = uploadNode.fields) == null ? void 0 : _a.alt) || (doc == null ? void 0 : doc.alt) || "",
|
|
186
|
-
width: doc.width,
|
|
187
|
-
height: doc.height,
|
|
188
|
-
mimeType: doc.mimeType,
|
|
189
|
-
filename: doc.filename,
|
|
190
|
-
sizes: doc.sizes,
|
|
191
|
-
node
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
if (components.Table) {
|
|
197
|
-
const Table = components.Table;
|
|
198
|
-
converters.table = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(Table, { node }, nodesToJSX({ nodes: node.children }));
|
|
199
|
-
}
|
|
200
|
-
if (components.TableRow) {
|
|
201
|
-
const TableRow = components.TableRow;
|
|
202
|
-
converters.tablerow = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(TableRow, { node }, nodesToJSX({ nodes: node.children }));
|
|
203
|
-
}
|
|
204
|
-
if (components.TableCell) {
|
|
205
|
-
const TableCell = components.TableCell;
|
|
206
|
-
converters.tablecell = ({ node, nodesToJSX }) => /* @__PURE__ */ import_react.default.createElement(
|
|
207
|
-
TableCell,
|
|
208
|
-
{
|
|
209
|
-
tag: node.headerState > 0 ? "th" : "td",
|
|
210
|
-
colSpan: node.colSpan > 1 ? node.colSpan : void 0,
|
|
211
|
-
rowSpan: node.rowSpan > 1 ? node.rowSpan : void 0,
|
|
212
|
-
backgroundColor: node.backgroundColor || void 0,
|
|
213
|
-
node
|
|
214
|
-
},
|
|
215
|
-
nodesToJSX({ nodes: node.children })
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return converters;
|
|
219
|
-
}
|
|
220
|
-
function StyledRichTextContent(_a) {
|
|
221
|
-
var _b = _a, {
|
|
222
|
-
components = {},
|
|
223
|
-
internalDocToHref,
|
|
224
|
-
blocks,
|
|
225
|
-
textState
|
|
226
|
-
} = _b, props = __objRest(_b, [
|
|
227
|
-
"components",
|
|
228
|
-
"internalDocToHref",
|
|
229
|
-
"blocks",
|
|
230
|
-
"textState"
|
|
231
|
-
]);
|
|
232
|
-
const converters = createComponentConverters(components, internalDocToHref);
|
|
233
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
234
|
-
RichTextContent,
|
|
235
|
-
__spreadProps(__spreadValues({}, props), {
|
|
236
|
-
internalDocToHref,
|
|
237
|
-
converters,
|
|
238
|
-
blocks,
|
|
239
|
-
textState
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// src/components/RichTextContent/index.tsx
|
|
245
|
-
function hyphenToCamel(str) {
|
|
246
|
-
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
247
|
-
}
|
|
248
|
-
function createTextStateConverter(state) {
|
|
249
|
-
const defaultTextConverter = import_react3.TextJSXConverter.text;
|
|
250
|
-
return (_a) => {
|
|
251
|
-
var _b = _a, { node } = _b, rest = __objRest(_b, ["node"]);
|
|
252
|
-
var _a2, _b2;
|
|
253
|
-
const base = defaultTextConverter(__spreadValues({ node }, rest));
|
|
254
|
-
const nodeState = node.$;
|
|
255
|
-
if (!nodeState || typeof nodeState !== "object") return base;
|
|
256
|
-
const style = {};
|
|
257
|
-
for (const stateKey in nodeState) {
|
|
258
|
-
const stateValue = nodeState[stateKey];
|
|
259
|
-
if (!stateValue) continue;
|
|
260
|
-
const css = (_b2 = (_a2 = state[stateKey]) == null ? void 0 : _a2[stateValue]) == null ? void 0 : _b2.css;
|
|
261
|
-
if (css) {
|
|
262
|
-
for (const prop in css) {
|
|
263
|
-
const val = css[prop];
|
|
264
|
-
if (val) style[hyphenToCamel(prop)] = val;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (Object.keys(style).length === 0) return base;
|
|
269
|
-
return /* @__PURE__ */ import_react2.default.createElement("span", { style }, base);
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function RichTextContent({
|
|
273
|
-
data,
|
|
274
|
-
className,
|
|
275
|
-
internalDocToHref,
|
|
276
|
-
converters,
|
|
277
|
-
blocks,
|
|
278
|
-
disableDefaultConverters,
|
|
279
|
-
textState
|
|
280
|
-
}) {
|
|
281
|
-
const baseConverters = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, disableDefaultConverters ? {} : import_react3.defaultJSXConverters), (0, import_react3.LinkJSXConverter)({ internalDocToHref })), textState ? { text: createTextStateConverter(textState) } : {}), converters), blocks ? { blocks } : {});
|
|
282
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react3.RichText, { data, className, converters: baseConverters });
|
|
283
|
-
}
|
|
284
76
|
|
|
285
|
-
// src/
|
|
286
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
287
|
-
|
|
288
|
-
// src/components/FormRenderer/countries.ts
|
|
77
|
+
// src/ui/Form/countries.ts
|
|
289
78
|
var COUNTRIES = [
|
|
290
79
|
{ value: "AF", label: "Afghanistan" },
|
|
291
80
|
{ value: "AX", label: "\xC5land Islands" },
|
|
@@ -588,7 +377,7 @@ var US_STATES = [
|
|
|
588
377
|
{ value: "DC", label: "District of Columbia" }
|
|
589
378
|
];
|
|
590
379
|
|
|
591
|
-
// src/
|
|
380
|
+
// src/ui/Form/index.tsx
|
|
592
381
|
function toSubmissionData(values) {
|
|
593
382
|
return Object.entries(values).map(([field, value]) => ({
|
|
594
383
|
field,
|
|
@@ -622,15 +411,15 @@ function FormRenderer({
|
|
|
622
411
|
renderButton
|
|
623
412
|
}) {
|
|
624
413
|
var _a;
|
|
625
|
-
const [values, setValues] = (0,
|
|
414
|
+
const [values, setValues] = (0, import_react.useState)(
|
|
626
415
|
() => getInitialValues(form.fields)
|
|
627
416
|
);
|
|
628
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
629
|
-
const submittingRef = (0,
|
|
630
|
-
(0,
|
|
417
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react.useState)(false);
|
|
418
|
+
const submittingRef = (0, import_react.useRef)(false);
|
|
419
|
+
(0, import_react.useEffect)(() => {
|
|
631
420
|
setValues(getInitialValues(form.fields));
|
|
632
421
|
}, [form.id]);
|
|
633
|
-
const handleChange = (0,
|
|
422
|
+
const handleChange = (0, import_react.useCallback)(
|
|
634
423
|
(name, value) => {
|
|
635
424
|
setValues((prev) => __spreadProps(__spreadValues({}, prev), { [name]: value }));
|
|
636
425
|
},
|
|
@@ -654,14 +443,14 @@ function FormRenderer({
|
|
|
654
443
|
value: (_a2 = values[field.name]) != null ? _a2 : "",
|
|
655
444
|
onChange: (v) => handleChange(field.name, v)
|
|
656
445
|
};
|
|
657
|
-
const el = /* @__PURE__ */
|
|
446
|
+
const el = /* @__PURE__ */ import_react.default.createElement(
|
|
658
447
|
"div",
|
|
659
448
|
{
|
|
660
449
|
key: (_b = field.id) != null ? _b : field.name,
|
|
661
450
|
className: fieldClassName,
|
|
662
451
|
style
|
|
663
452
|
},
|
|
664
|
-
field.label && /* @__PURE__ */
|
|
453
|
+
field.label && /* @__PURE__ */ import_react.default.createElement("label", { htmlFor: field.name }, field.label),
|
|
665
454
|
input
|
|
666
455
|
);
|
|
667
456
|
return renderField ? renderField(field, context, el) : el;
|
|
@@ -671,7 +460,7 @@ function FormRenderer({
|
|
|
671
460
|
return wrapField(
|
|
672
461
|
field,
|
|
673
462
|
style,
|
|
674
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
675
464
|
"select",
|
|
676
465
|
{
|
|
677
466
|
id: field.name,
|
|
@@ -680,8 +469,8 @@ function FormRenderer({
|
|
|
680
469
|
required: (_b = field.required) != null ? _b : false,
|
|
681
470
|
onChange: (e) => handleChange(field.name, e.target.value)
|
|
682
471
|
},
|
|
683
|
-
/* @__PURE__ */
|
|
684
|
-
options.map((opt) => /* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ import_react.default.createElement("option", { value: "" }, placeholder || "Select\u2026"),
|
|
473
|
+
options.map((opt) => /* @__PURE__ */ import_react.default.createElement("option", { key: opt.value, value: opt.value }, opt.label))
|
|
685
474
|
)
|
|
686
475
|
);
|
|
687
476
|
};
|
|
@@ -693,7 +482,7 @@ function FormRenderer({
|
|
|
693
482
|
return wrapField(
|
|
694
483
|
field,
|
|
695
484
|
style,
|
|
696
|
-
/* @__PURE__ */
|
|
485
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
697
486
|
"input",
|
|
698
487
|
{
|
|
699
488
|
type: "text",
|
|
@@ -710,7 +499,7 @@ function FormRenderer({
|
|
|
710
499
|
return wrapField(
|
|
711
500
|
field,
|
|
712
501
|
style,
|
|
713
|
-
/* @__PURE__ */
|
|
502
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
714
503
|
"input",
|
|
715
504
|
{
|
|
716
505
|
type: "email",
|
|
@@ -726,7 +515,7 @@ function FormRenderer({
|
|
|
726
515
|
return wrapField(
|
|
727
516
|
field,
|
|
728
517
|
style,
|
|
729
|
-
/* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
730
519
|
"input",
|
|
731
520
|
{
|
|
732
521
|
type: "number",
|
|
@@ -747,7 +536,7 @@ function FormRenderer({
|
|
|
747
536
|
return wrapField(
|
|
748
537
|
field,
|
|
749
538
|
style,
|
|
750
|
-
/* @__PURE__ */
|
|
539
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
751
540
|
"textarea",
|
|
752
541
|
{
|
|
753
542
|
id: field.name,
|
|
@@ -763,14 +552,14 @@ function FormRenderer({
|
|
|
763
552
|
value: (_j = values[field.name]) != null ? _j : false,
|
|
764
553
|
onChange: (v) => handleChange(field.name, v)
|
|
765
554
|
};
|
|
766
|
-
const el = /* @__PURE__ */
|
|
555
|
+
const el = /* @__PURE__ */ import_react.default.createElement(
|
|
767
556
|
"div",
|
|
768
557
|
{
|
|
769
558
|
key: (_k = field.id) != null ? _k : field.name,
|
|
770
559
|
className: fieldClassName,
|
|
771
560
|
style
|
|
772
561
|
},
|
|
773
|
-
/* @__PURE__ */
|
|
562
|
+
/* @__PURE__ */ import_react.default.createElement("label", { htmlFor: field.name }, /* @__PURE__ */ import_react.default.createElement(
|
|
774
563
|
"input",
|
|
775
564
|
{
|
|
776
565
|
type: "checkbox",
|
|
@@ -780,7 +569,7 @@ function FormRenderer({
|
|
|
780
569
|
required: (_l = field.required) != null ? _l : false,
|
|
781
570
|
onChange: (e) => handleChange(field.name, e.target.checked)
|
|
782
571
|
}
|
|
783
|
-
), field.label && /* @__PURE__ */
|
|
572
|
+
), field.label && /* @__PURE__ */ import_react.default.createElement("span", null, field.label))
|
|
784
573
|
);
|
|
785
574
|
return renderField ? renderField(field, context, el) : el;
|
|
786
575
|
}
|
|
@@ -797,7 +586,7 @@ function FormRenderer({
|
|
|
797
586
|
return renderSelectField(field, style, US_STATES);
|
|
798
587
|
case "message":
|
|
799
588
|
if (renderMessage && field.message) {
|
|
800
|
-
return /* @__PURE__ */
|
|
589
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: (_p = (_o = field.id) != null ? _o : field.blockName) != null ? _p : "message" }, renderMessage(field.message));
|
|
801
590
|
}
|
|
802
591
|
return null;
|
|
803
592
|
default:
|
|
@@ -805,7 +594,7 @@ function FormRenderer({
|
|
|
805
594
|
}
|
|
806
595
|
};
|
|
807
596
|
const buttonLabel = form.submitButtonLabel || "Submit";
|
|
808
|
-
return /* @__PURE__ */
|
|
597
|
+
return /* @__PURE__ */ import_react.default.createElement("form", { onSubmit: handleSubmit, className }, (_a = form.fields) == null ? void 0 : _a.map((field) => renderFieldElement(field)), renderButton ? renderButton({ isSubmitting, label: buttonLabel }) : /* @__PURE__ */ import_react.default.createElement(
|
|
809
598
|
"button",
|
|
810
599
|
{
|
|
811
600
|
type: "submit",
|
|
@@ -815,286 +604,4 @@ function FormRenderer({
|
|
|
815
604
|
buttonLabel
|
|
816
605
|
));
|
|
817
606
|
}
|
|
818
|
-
|
|
819
|
-
// src/components/Image/index.tsx
|
|
820
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
821
|
-
|
|
822
|
-
// src/utils/image.ts
|
|
823
|
-
var IMAGE_SIZES = [384, 768, 1536];
|
|
824
|
-
function getImageSrcSet(image) {
|
|
825
|
-
const parts = [];
|
|
826
|
-
const sizes = image.sizes;
|
|
827
|
-
if (sizes) {
|
|
828
|
-
for (const size of IMAGE_SIZES) {
|
|
829
|
-
const entry = sizes[String(size)];
|
|
830
|
-
if ((entry == null ? void 0 : entry.url) && entry.width) {
|
|
831
|
-
parts.push(`${entry.url} ${entry.width}w`);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
if (image.url && image.width) {
|
|
836
|
-
parts.push(`${image.url} ${image.width}w`);
|
|
837
|
-
}
|
|
838
|
-
return parts.join(", ");
|
|
839
|
-
}
|
|
840
|
-
function getImagePlaceholderStyle(image, options) {
|
|
841
|
-
var _a, _b, _c;
|
|
842
|
-
const type = (_a = options == null ? void 0 : options.type) != null ? _a : "blur";
|
|
843
|
-
const paletteColor = (_b = options == null ? void 0 : options.paletteColor) != null ? _b : "muted";
|
|
844
|
-
if (type === "none") return {};
|
|
845
|
-
const color = (_c = image.palette) == null ? void 0 : _c[paletteColor];
|
|
846
|
-
if (type === "blur") {
|
|
847
|
-
const lqip = image.lqip;
|
|
848
|
-
if (lqip) {
|
|
849
|
-
return {
|
|
850
|
-
backgroundImage: `url(${lqip})`,
|
|
851
|
-
backgroundSize: "cover",
|
|
852
|
-
backgroundPosition: "center"
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
if (color) {
|
|
856
|
-
return { backgroundColor: color };
|
|
857
|
-
}
|
|
858
|
-
return {};
|
|
859
|
-
}
|
|
860
|
-
if (color) {
|
|
861
|
-
return { backgroundColor: color };
|
|
862
|
-
}
|
|
863
|
-
return {};
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// src/components/Image/index.tsx
|
|
867
|
-
function Image({
|
|
868
|
-
image,
|
|
869
|
-
width,
|
|
870
|
-
dpr = 1,
|
|
871
|
-
placeholder: placeholderProp,
|
|
872
|
-
className,
|
|
873
|
-
style,
|
|
874
|
-
imgClassName,
|
|
875
|
-
imgStyle,
|
|
876
|
-
sizes,
|
|
877
|
-
loading: loadingProp,
|
|
878
|
-
onLoad,
|
|
879
|
-
objectFit = "cover",
|
|
880
|
-
priority = false,
|
|
881
|
-
fill = false,
|
|
882
|
-
imageRendering
|
|
883
|
-
}) {
|
|
884
|
-
var _a, _b;
|
|
885
|
-
const [loaded, setLoaded] = (0, import_react5.useState)(false);
|
|
886
|
-
const firedRef = (0, import_react5.useRef)(false);
|
|
887
|
-
const isPixelRendering = imageRendering === "pixelated" || imageRendering === "crisp-edges";
|
|
888
|
-
const placeholder = placeholderProp != null ? placeholderProp : isPixelRendering ? "none" : "blur";
|
|
889
|
-
const loading = priority ? "eager" : loadingProp != null ? loadingProp : "lazy";
|
|
890
|
-
const aspectRatio = !fill && image.width && image.height ? `${image.width} / ${image.height}` : void 0;
|
|
891
|
-
const srcSet = getImageSrcSet(image);
|
|
892
|
-
const src = (_a = image.url) != null ? _a : void 0;
|
|
893
|
-
const hasLqip = placeholder === "blur" && !!image.lqip;
|
|
894
|
-
const placeholderStyle = getImagePlaceholderStyle(image, {
|
|
895
|
-
type: placeholder
|
|
896
|
-
});
|
|
897
|
-
const placeholderColor = !hasLqip && "backgroundColor" in placeholderStyle ? placeholderStyle.backgroundColor : void 0;
|
|
898
|
-
const fireLoad = (0, import_react5.useCallback)(() => {
|
|
899
|
-
if (firedRef.current) return;
|
|
900
|
-
firedRef.current = true;
|
|
901
|
-
setLoaded(true);
|
|
902
|
-
onLoad == null ? void 0 : onLoad();
|
|
903
|
-
}, [onLoad]);
|
|
904
|
-
const imgRef = (0, import_react5.useCallback)(
|
|
905
|
-
(node) => {
|
|
906
|
-
if (node && node.complete && node.naturalWidth > 0) {
|
|
907
|
-
fireLoad();
|
|
908
|
-
}
|
|
909
|
-
},
|
|
910
|
-
[fireLoad]
|
|
911
|
-
);
|
|
912
|
-
const containerStyle = __spreadValues(__spreadValues(__spreadValues({
|
|
913
|
-
position: "relative",
|
|
914
|
-
overflow: "hidden"
|
|
915
|
-
}, fill ? { width: "100%", height: "100%" } : {}), aspectRatio ? { aspectRatio } : {}), style);
|
|
916
|
-
const overlayBase = {
|
|
917
|
-
position: "absolute",
|
|
918
|
-
top: 0,
|
|
919
|
-
left: 0,
|
|
920
|
-
width: "100%",
|
|
921
|
-
height: "100%",
|
|
922
|
-
opacity: loaded ? 0 : 1,
|
|
923
|
-
transition: "opacity 0.3s ease",
|
|
924
|
-
pointerEvents: "none"
|
|
925
|
-
};
|
|
926
|
-
const mainImgStyle = __spreadValues(__spreadProps(__spreadValues({
|
|
927
|
-
display: "block",
|
|
928
|
-
width: "100%",
|
|
929
|
-
height: "100%",
|
|
930
|
-
objectFit
|
|
931
|
-
}, imageRendering ? { imageRendering } : {}), {
|
|
932
|
-
opacity: loaded ? 1 : 0,
|
|
933
|
-
transition: "opacity 0.3s ease"
|
|
934
|
-
}), imgStyle);
|
|
935
|
-
return /* @__PURE__ */ import_react5.default.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ import_react5.default.createElement(
|
|
936
|
-
"img",
|
|
937
|
-
{
|
|
938
|
-
"aria-hidden": true,
|
|
939
|
-
alt: "",
|
|
940
|
-
src: image.lqip,
|
|
941
|
-
style: __spreadProps(__spreadValues({}, overlayBase), {
|
|
942
|
-
display: "block",
|
|
943
|
-
objectFit,
|
|
944
|
-
filter: "blur(20px)",
|
|
945
|
-
transform: "scale(1.1)"
|
|
946
|
-
})
|
|
947
|
-
}
|
|
948
|
-
), placeholderColor && /* @__PURE__ */ import_react5.default.createElement(
|
|
949
|
-
"div",
|
|
950
|
-
{
|
|
951
|
-
"aria-hidden": true,
|
|
952
|
-
style: __spreadProps(__spreadValues({}, overlayBase), {
|
|
953
|
-
backgroundColor: placeholderColor
|
|
954
|
-
})
|
|
955
|
-
}
|
|
956
|
-
), /* @__PURE__ */ import_react5.default.createElement(
|
|
957
|
-
"img",
|
|
958
|
-
{
|
|
959
|
-
ref: imgRef,
|
|
960
|
-
alt: (_b = image.alt) != null ? _b : "",
|
|
961
|
-
src,
|
|
962
|
-
srcSet: srcSet || void 0,
|
|
963
|
-
sizes,
|
|
964
|
-
width: width ? width * dpr : void 0,
|
|
965
|
-
loading,
|
|
966
|
-
decoding: "async",
|
|
967
|
-
fetchPriority: priority ? "high" : void 0,
|
|
968
|
-
onLoad: fireLoad,
|
|
969
|
-
className: imgClassName,
|
|
970
|
-
style: mainImgStyle
|
|
971
|
-
}
|
|
972
|
-
));
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
// src/components/CodeBlock/index.tsx
|
|
976
|
-
var import_react7 = __toESM(require("react"), 1);
|
|
977
|
-
|
|
978
|
-
// src/components/CodeBlock/highlight.ts
|
|
979
|
-
var import_react6 = require("react");
|
|
980
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
981
|
-
var import_hast_util_to_jsx_runtime = require("hast-util-to-jsx-runtime");
|
|
982
|
-
var import_shiki = require("shiki");
|
|
983
|
-
var LANGUAGE_ALIASES = {
|
|
984
|
-
js: "javascript",
|
|
985
|
-
ts: "typescript",
|
|
986
|
-
sh: "bash",
|
|
987
|
-
shell: "bash",
|
|
988
|
-
yml: "yaml",
|
|
989
|
-
py: "python",
|
|
990
|
-
rb: "ruby",
|
|
991
|
-
plaintext: "text"
|
|
992
|
-
};
|
|
993
|
-
function normalizeLanguage(lang) {
|
|
994
|
-
return LANGUAGE_ALIASES[lang] || lang;
|
|
995
|
-
}
|
|
996
|
-
function highlight(code, lang, theme = "github-dark") {
|
|
997
|
-
return __async(this, null, function* () {
|
|
998
|
-
const normalized = normalizeLanguage(lang);
|
|
999
|
-
try {
|
|
1000
|
-
const hast = yield (0, import_shiki.codeToHast)(code, {
|
|
1001
|
-
lang: normalized,
|
|
1002
|
-
theme
|
|
1003
|
-
});
|
|
1004
|
-
return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(hast, { Fragment: import_react6.Fragment, jsx: import_jsx_runtime.jsx, jsxs: import_jsx_runtime.jsxs });
|
|
1005
|
-
} catch (e) {
|
|
1006
|
-
const hast = yield (0, import_shiki.codeToHast)(code, { lang: "text", theme });
|
|
1007
|
-
return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(hast, { Fragment: import_react6.Fragment, jsx: import_jsx_runtime.jsx, jsxs: import_jsx_runtime.jsxs });
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// src/components/CodeBlock/index.tsx
|
|
1013
|
-
function CodeBlock({
|
|
1014
|
-
code,
|
|
1015
|
-
language = "typescript",
|
|
1016
|
-
theme = "github-dark",
|
|
1017
|
-
className,
|
|
1018
|
-
initial,
|
|
1019
|
-
showLineNumbers = false,
|
|
1020
|
-
showCopyButton = true
|
|
1021
|
-
}) {
|
|
1022
|
-
const [nodes, setNodes] = (0, import_react7.useState)(initial);
|
|
1023
|
-
const [copied, setCopied] = (0, import_react7.useState)(false);
|
|
1024
|
-
(0, import_react7.useEffect)(() => {
|
|
1025
|
-
let cancelled = false;
|
|
1026
|
-
void highlight(code, language, theme).then((el) => {
|
|
1027
|
-
if (!cancelled) setNodes(el);
|
|
1028
|
-
});
|
|
1029
|
-
return () => {
|
|
1030
|
-
cancelled = true;
|
|
1031
|
-
};
|
|
1032
|
-
}, [code, language, theme]);
|
|
1033
|
-
const handleCopy = () => {
|
|
1034
|
-
void navigator.clipboard.writeText(code).then(() => {
|
|
1035
|
-
setCopied(true);
|
|
1036
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1037
|
-
}, () => {
|
|
1038
|
-
});
|
|
1039
|
-
};
|
|
1040
|
-
return /* @__PURE__ */ import_react7.default.createElement("div", { className, style: { position: "relative" } }, showCopyButton && /* @__PURE__ */ import_react7.default.createElement(
|
|
1041
|
-
"button",
|
|
1042
|
-
{
|
|
1043
|
-
type: "button",
|
|
1044
|
-
onClick: handleCopy,
|
|
1045
|
-
"aria-label": "Copy code",
|
|
1046
|
-
style: {
|
|
1047
|
-
position: "absolute",
|
|
1048
|
-
top: 8,
|
|
1049
|
-
right: 8,
|
|
1050
|
-
zIndex: 1,
|
|
1051
|
-
padding: "4px 8px",
|
|
1052
|
-
fontSize: 12,
|
|
1053
|
-
lineHeight: 1,
|
|
1054
|
-
border: "1px solid rgba(255,255,255,0.2)",
|
|
1055
|
-
borderRadius: 4,
|
|
1056
|
-
background: "rgba(0,0,0,0.3)",
|
|
1057
|
-
color: "#ccc",
|
|
1058
|
-
cursor: "pointer",
|
|
1059
|
-
opacity: 0.7,
|
|
1060
|
-
transition: "opacity 0.15s"
|
|
1061
|
-
},
|
|
1062
|
-
onMouseEnter: (e) => {
|
|
1063
|
-
e.currentTarget.style.opacity = "1";
|
|
1064
|
-
},
|
|
1065
|
-
onMouseLeave: (e) => {
|
|
1066
|
-
e.currentTarget.style.opacity = "0.7";
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
copied ? "Copied!" : "Copy"
|
|
1070
|
-
), showLineNumbers && nodes ? /* @__PURE__ */ import_react7.default.createElement("div", { style: { display: "flex" } }, /* @__PURE__ */ import_react7.default.createElement(
|
|
1071
|
-
"div",
|
|
1072
|
-
{
|
|
1073
|
-
"aria-hidden": true,
|
|
1074
|
-
style: {
|
|
1075
|
-
padding: "1em 0.5em 1em 1em",
|
|
1076
|
-
textAlign: "right",
|
|
1077
|
-
userSelect: "none",
|
|
1078
|
-
color: "rgba(255,255,255,0.3)",
|
|
1079
|
-
fontFamily: "monospace",
|
|
1080
|
-
fontSize: 13,
|
|
1081
|
-
lineHeight: 1.5
|
|
1082
|
-
}
|
|
1083
|
-
},
|
|
1084
|
-
code.split("\n").map((_, i) => /* @__PURE__ */ import_react7.default.createElement("div", { key: i }, i + 1))
|
|
1085
|
-
), /* @__PURE__ */ import_react7.default.createElement("div", { style: { flex: 1, overflow: "auto" } }, nodes)) : nodes != null ? nodes : /* @__PURE__ */ import_react7.default.createElement(
|
|
1086
|
-
"pre",
|
|
1087
|
-
{
|
|
1088
|
-
style: {
|
|
1089
|
-
margin: 0,
|
|
1090
|
-
padding: "1em",
|
|
1091
|
-
overflow: "auto",
|
|
1092
|
-
fontFamily: "monospace",
|
|
1093
|
-
fontSize: 13,
|
|
1094
|
-
lineHeight: 1.5
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
/* @__PURE__ */ import_react7.default.createElement("code", null, code)
|
|
1098
|
-
));
|
|
1099
|
-
}
|
|
1100
|
-
//# sourceMappingURL=components.cjs.map
|
|
607
|
+
//# sourceMappingURL=form.cjs.map
|