@01.software/sdk 0.2.9-dev.260310.cf511cb → 0.2.9-dev.260311.926a6d4
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/components/code-block.cjs +182 -0
- package/dist/components/code-block.cjs.map +1 -0
- package/dist/components/code-block.d.cts +62 -0
- package/dist/components/code-block.d.ts +62 -0
- package/dist/components/code-block.js +152 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/{flow.cjs → components/flow.cjs} +111 -87
- package/dist/components/flow.cjs.map +1 -0
- package/dist/{flow.d.cts → components/flow.d.cts} +27 -11
- package/dist/{flow.d.ts → components/flow.d.ts} +27 -11
- package/dist/{flow.js → components/flow.js} +113 -88
- package/dist/components/flow.js.map +1 -0
- package/dist/{components.cjs → components/form.cjs} +25 -518
- package/dist/components/form.cjs.map +1 -0
- package/dist/components/form.d.cts +37 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/{components.js → components/form.js} +17 -513
- package/dist/components/form.js.map +1 -0
- package/dist/components/image.cjs +208 -0
- package/dist/components/image.cjs.map +1 -0
- package/dist/components/image.d.cts +44 -0
- package/dist/components/image.d.ts +44 -0
- package/dist/components/image.js +180 -0
- package/dist/components/image.js.map +1 -0
- package/dist/components/rich-text.cjs +258 -0
- package/dist/components/rich-text.cjs.map +1 -0
- package/dist/components/rich-text.d.cts +110 -0
- package/dist/components/rich-text.d.ts +110 -0
- package/dist/components/rich-text.js +235 -0
- package/dist/components/rich-text.js.map +1 -0
- 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/{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,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -17,18 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
17
18
|
return a;
|
|
18
19
|
};
|
|
19
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
21
|
var __async = (__this, __arguments, generator) => {
|
|
33
22
|
return new Promise((resolve, reject) => {
|
|
34
23
|
var fulfilled = (value) => {
|
|
@@ -50,206 +39,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
39
|
});
|
|
51
40
|
};
|
|
52
41
|
|
|
53
|
-
// src/components/RichTextContent/index.tsx
|
|
54
|
-
import React2 from "react";
|
|
55
|
-
import {
|
|
56
|
-
defaultJSXConverters,
|
|
57
|
-
LinkJSXConverter,
|
|
58
|
-
RichText,
|
|
59
|
-
TextJSXConverter
|
|
60
|
-
} from "@payloadcms/richtext-lexical/react";
|
|
61
|
-
|
|
62
|
-
// src/components/RichTextContent/styled.tsx
|
|
63
|
-
import React from "react";
|
|
64
|
-
function createComponentConverters(components, internalDocToHref) {
|
|
65
|
-
const converters = {};
|
|
66
|
-
if (components.Heading) {
|
|
67
|
-
const Heading = components.Heading;
|
|
68
|
-
converters.heading = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(Heading, { tag: node.tag, node }, nodesToJSX({ nodes: node.children }));
|
|
69
|
-
}
|
|
70
|
-
if (components.Paragraph) {
|
|
71
|
-
const Paragraph = components.Paragraph;
|
|
72
|
-
converters.paragraph = ({ node, nodesToJSX }) => {
|
|
73
|
-
const children = nodesToJSX({ nodes: node.children });
|
|
74
|
-
return /* @__PURE__ */ React.createElement(Paragraph, { isEmpty: !(children == null ? void 0 : children.length), node }, (children == null ? void 0 : children.length) ? children : /* @__PURE__ */ React.createElement("br", null));
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (components.Blockquote) {
|
|
78
|
-
const Blockquote = components.Blockquote;
|
|
79
|
-
converters.quote = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(Blockquote, { node }, nodesToJSX({ nodes: node.children }));
|
|
80
|
-
}
|
|
81
|
-
if (components.List) {
|
|
82
|
-
const List = components.List;
|
|
83
|
-
converters.list = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(List, { tag: node.tag, listType: node.listType, node }, nodesToJSX({ nodes: node.children }));
|
|
84
|
-
}
|
|
85
|
-
if (components.ListItem) {
|
|
86
|
-
const ListItem = components.ListItem;
|
|
87
|
-
converters.listitem = ({ node, nodesToJSX }) => {
|
|
88
|
-
const hasSubLists = node.children.some(
|
|
89
|
-
(child) => child.type === "list"
|
|
90
|
-
);
|
|
91
|
-
return /* @__PURE__ */ React.createElement(
|
|
92
|
-
ListItem,
|
|
93
|
-
{
|
|
94
|
-
hasSubLists,
|
|
95
|
-
checked: node.checked,
|
|
96
|
-
value: node.value,
|
|
97
|
-
node
|
|
98
|
-
},
|
|
99
|
-
nodesToJSX({ nodes: node.children })
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (components.Link) {
|
|
104
|
-
const Link = components.Link;
|
|
105
|
-
const resolveHref = (node) => {
|
|
106
|
-
var _a;
|
|
107
|
-
if (node.fields.linkType === "internal") {
|
|
108
|
-
return internalDocToHref ? internalDocToHref({ linkNode: node }) : "#";
|
|
109
|
-
}
|
|
110
|
-
return (_a = node.fields.url) != null ? _a : "";
|
|
111
|
-
};
|
|
112
|
-
converters.link = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(
|
|
113
|
-
Link,
|
|
114
|
-
{
|
|
115
|
-
href: resolveHref(node),
|
|
116
|
-
rel: node.fields.newTab ? "noopener noreferrer" : void 0,
|
|
117
|
-
target: node.fields.newTab ? "_blank" : void 0,
|
|
118
|
-
node
|
|
119
|
-
},
|
|
120
|
-
nodesToJSX({ nodes: node.children })
|
|
121
|
-
);
|
|
122
|
-
converters.autolink = ({ node, nodesToJSX }) => {
|
|
123
|
-
var _a;
|
|
124
|
-
return /* @__PURE__ */ React.createElement(
|
|
125
|
-
Link,
|
|
126
|
-
{
|
|
127
|
-
href: (_a = node.fields.url) != null ? _a : "",
|
|
128
|
-
rel: node.fields.newTab ? "noopener noreferrer" : void 0,
|
|
129
|
-
target: node.fields.newTab ? "_blank" : void 0,
|
|
130
|
-
node
|
|
131
|
-
},
|
|
132
|
-
nodesToJSX({ nodes: node.children })
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (components.HorizontalRule) {
|
|
137
|
-
const HorizontalRule = components.HorizontalRule;
|
|
138
|
-
converters.horizontalrule = /* @__PURE__ */ React.createElement(HorizontalRule, null);
|
|
139
|
-
}
|
|
140
|
-
if (components.Upload) {
|
|
141
|
-
const Upload = components.Upload;
|
|
142
|
-
converters.upload = ({ node }) => {
|
|
143
|
-
var _a;
|
|
144
|
-
const uploadNode = node;
|
|
145
|
-
if (typeof uploadNode.value !== "object") return null;
|
|
146
|
-
const doc = uploadNode.value;
|
|
147
|
-
return /* @__PURE__ */ React.createElement(
|
|
148
|
-
Upload,
|
|
149
|
-
{
|
|
150
|
-
src: doc.url,
|
|
151
|
-
alt: ((_a = uploadNode.fields) == null ? void 0 : _a.alt) || (doc == null ? void 0 : doc.alt) || "",
|
|
152
|
-
width: doc.width,
|
|
153
|
-
height: doc.height,
|
|
154
|
-
mimeType: doc.mimeType,
|
|
155
|
-
filename: doc.filename,
|
|
156
|
-
sizes: doc.sizes,
|
|
157
|
-
node
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
if (components.Table) {
|
|
163
|
-
const Table = components.Table;
|
|
164
|
-
converters.table = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(Table, { node }, nodesToJSX({ nodes: node.children }));
|
|
165
|
-
}
|
|
166
|
-
if (components.TableRow) {
|
|
167
|
-
const TableRow = components.TableRow;
|
|
168
|
-
converters.tablerow = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(TableRow, { node }, nodesToJSX({ nodes: node.children }));
|
|
169
|
-
}
|
|
170
|
-
if (components.TableCell) {
|
|
171
|
-
const TableCell = components.TableCell;
|
|
172
|
-
converters.tablecell = ({ node, nodesToJSX }) => /* @__PURE__ */ React.createElement(
|
|
173
|
-
TableCell,
|
|
174
|
-
{
|
|
175
|
-
tag: node.headerState > 0 ? "th" : "td",
|
|
176
|
-
colSpan: node.colSpan > 1 ? node.colSpan : void 0,
|
|
177
|
-
rowSpan: node.rowSpan > 1 ? node.rowSpan : void 0,
|
|
178
|
-
backgroundColor: node.backgroundColor || void 0,
|
|
179
|
-
node
|
|
180
|
-
},
|
|
181
|
-
nodesToJSX({ nodes: node.children })
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
return converters;
|
|
185
|
-
}
|
|
186
|
-
function StyledRichTextContent(_a) {
|
|
187
|
-
var _b = _a, {
|
|
188
|
-
components = {},
|
|
189
|
-
internalDocToHref,
|
|
190
|
-
blocks,
|
|
191
|
-
textState
|
|
192
|
-
} = _b, props = __objRest(_b, [
|
|
193
|
-
"components",
|
|
194
|
-
"internalDocToHref",
|
|
195
|
-
"blocks",
|
|
196
|
-
"textState"
|
|
197
|
-
]);
|
|
198
|
-
const converters = createComponentConverters(components, internalDocToHref);
|
|
199
|
-
return /* @__PURE__ */ React.createElement(
|
|
200
|
-
RichTextContent,
|
|
201
|
-
__spreadProps(__spreadValues({}, props), {
|
|
202
|
-
internalDocToHref,
|
|
203
|
-
converters,
|
|
204
|
-
blocks,
|
|
205
|
-
textState
|
|
206
|
-
})
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// src/components/RichTextContent/index.tsx
|
|
211
|
-
function hyphenToCamel(str) {
|
|
212
|
-
return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
213
|
-
}
|
|
214
|
-
function createTextStateConverter(state) {
|
|
215
|
-
const defaultTextConverter = TextJSXConverter.text;
|
|
216
|
-
return (_a) => {
|
|
217
|
-
var _b = _a, { node } = _b, rest = __objRest(_b, ["node"]);
|
|
218
|
-
var _a2, _b2;
|
|
219
|
-
const base = defaultTextConverter(__spreadValues({ node }, rest));
|
|
220
|
-
const nodeState = node.$;
|
|
221
|
-
if (!nodeState || typeof nodeState !== "object") return base;
|
|
222
|
-
const style = {};
|
|
223
|
-
for (const stateKey in nodeState) {
|
|
224
|
-
const stateValue = nodeState[stateKey];
|
|
225
|
-
if (!stateValue) continue;
|
|
226
|
-
const css = (_b2 = (_a2 = state[stateKey]) == null ? void 0 : _a2[stateValue]) == null ? void 0 : _b2.css;
|
|
227
|
-
if (css) {
|
|
228
|
-
for (const prop in css) {
|
|
229
|
-
const val = css[prop];
|
|
230
|
-
if (val) style[hyphenToCamel(prop)] = val;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (Object.keys(style).length === 0) return base;
|
|
235
|
-
return /* @__PURE__ */ React2.createElement("span", { style }, base);
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
function RichTextContent({
|
|
239
|
-
data,
|
|
240
|
-
className,
|
|
241
|
-
internalDocToHref,
|
|
242
|
-
converters,
|
|
243
|
-
blocks,
|
|
244
|
-
disableDefaultConverters,
|
|
245
|
-
textState
|
|
246
|
-
}) {
|
|
247
|
-
const baseConverters = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, disableDefaultConverters ? {} : defaultJSXConverters), LinkJSXConverter({ internalDocToHref })), textState ? { text: createTextStateConverter(textState) } : {}), converters), blocks ? { blocks } : {});
|
|
248
|
-
return /* @__PURE__ */ React2.createElement(RichText, { data, className, converters: baseConverters });
|
|
249
|
-
}
|
|
250
|
-
|
|
251
42
|
// src/components/FormRenderer/index.tsx
|
|
252
|
-
import
|
|
43
|
+
import React, { useState, useCallback, useEffect, useRef } from "react";
|
|
253
44
|
|
|
254
45
|
// src/components/FormRenderer/countries.ts
|
|
255
46
|
var COUNTRIES = [
|
|
@@ -620,14 +411,14 @@ function FormRenderer({
|
|
|
620
411
|
value: (_a2 = values[field.name]) != null ? _a2 : "",
|
|
621
412
|
onChange: (v) => handleChange(field.name, v)
|
|
622
413
|
};
|
|
623
|
-
const el = /* @__PURE__ */
|
|
414
|
+
const el = /* @__PURE__ */ React.createElement(
|
|
624
415
|
"div",
|
|
625
416
|
{
|
|
626
417
|
key: (_b = field.id) != null ? _b : field.name,
|
|
627
418
|
className: fieldClassName,
|
|
628
419
|
style
|
|
629
420
|
},
|
|
630
|
-
field.label && /* @__PURE__ */
|
|
421
|
+
field.label && /* @__PURE__ */ React.createElement("label", { htmlFor: field.name }, field.label),
|
|
631
422
|
input
|
|
632
423
|
);
|
|
633
424
|
return renderField ? renderField(field, context, el) : el;
|
|
@@ -637,7 +428,7 @@ function FormRenderer({
|
|
|
637
428
|
return wrapField(
|
|
638
429
|
field,
|
|
639
430
|
style,
|
|
640
|
-
/* @__PURE__ */
|
|
431
|
+
/* @__PURE__ */ React.createElement(
|
|
641
432
|
"select",
|
|
642
433
|
{
|
|
643
434
|
id: field.name,
|
|
@@ -646,8 +437,8 @@ function FormRenderer({
|
|
|
646
437
|
required: (_b = field.required) != null ? _b : false,
|
|
647
438
|
onChange: (e) => handleChange(field.name, e.target.value)
|
|
648
439
|
},
|
|
649
|
-
/* @__PURE__ */
|
|
650
|
-
options.map((opt) => /* @__PURE__ */
|
|
440
|
+
/* @__PURE__ */ React.createElement("option", { value: "" }, placeholder || "Select\u2026"),
|
|
441
|
+
options.map((opt) => /* @__PURE__ */ React.createElement("option", { key: opt.value, value: opt.value }, opt.label))
|
|
651
442
|
)
|
|
652
443
|
);
|
|
653
444
|
};
|
|
@@ -659,7 +450,7 @@ function FormRenderer({
|
|
|
659
450
|
return wrapField(
|
|
660
451
|
field,
|
|
661
452
|
style,
|
|
662
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ React.createElement(
|
|
663
454
|
"input",
|
|
664
455
|
{
|
|
665
456
|
type: "text",
|
|
@@ -676,7 +467,7 @@ function FormRenderer({
|
|
|
676
467
|
return wrapField(
|
|
677
468
|
field,
|
|
678
469
|
style,
|
|
679
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ React.createElement(
|
|
680
471
|
"input",
|
|
681
472
|
{
|
|
682
473
|
type: "email",
|
|
@@ -692,7 +483,7 @@ function FormRenderer({
|
|
|
692
483
|
return wrapField(
|
|
693
484
|
field,
|
|
694
485
|
style,
|
|
695
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ React.createElement(
|
|
696
487
|
"input",
|
|
697
488
|
{
|
|
698
489
|
type: "number",
|
|
@@ -713,7 +504,7 @@ function FormRenderer({
|
|
|
713
504
|
return wrapField(
|
|
714
505
|
field,
|
|
715
506
|
style,
|
|
716
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ React.createElement(
|
|
717
508
|
"textarea",
|
|
718
509
|
{
|
|
719
510
|
id: field.name,
|
|
@@ -729,14 +520,14 @@ function FormRenderer({
|
|
|
729
520
|
value: (_j = values[field.name]) != null ? _j : false,
|
|
730
521
|
onChange: (v) => handleChange(field.name, v)
|
|
731
522
|
};
|
|
732
|
-
const el = /* @__PURE__ */
|
|
523
|
+
const el = /* @__PURE__ */ React.createElement(
|
|
733
524
|
"div",
|
|
734
525
|
{
|
|
735
526
|
key: (_k = field.id) != null ? _k : field.name,
|
|
736
527
|
className: fieldClassName,
|
|
737
528
|
style
|
|
738
529
|
},
|
|
739
|
-
/* @__PURE__ */
|
|
530
|
+
/* @__PURE__ */ React.createElement("label", { htmlFor: field.name }, /* @__PURE__ */ React.createElement(
|
|
740
531
|
"input",
|
|
741
532
|
{
|
|
742
533
|
type: "checkbox",
|
|
@@ -746,7 +537,7 @@ function FormRenderer({
|
|
|
746
537
|
required: (_l = field.required) != null ? _l : false,
|
|
747
538
|
onChange: (e) => handleChange(field.name, e.target.checked)
|
|
748
539
|
}
|
|
749
|
-
), field.label && /* @__PURE__ */
|
|
540
|
+
), field.label && /* @__PURE__ */ React.createElement("span", null, field.label))
|
|
750
541
|
);
|
|
751
542
|
return renderField ? renderField(field, context, el) : el;
|
|
752
543
|
}
|
|
@@ -763,7 +554,7 @@ function FormRenderer({
|
|
|
763
554
|
return renderSelectField(field, style, US_STATES);
|
|
764
555
|
case "message":
|
|
765
556
|
if (renderMessage && field.message) {
|
|
766
|
-
return /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, { key: (_p = (_o = field.id) != null ? _o : field.blockName) != null ? _p : "message" }, renderMessage(field.message));
|
|
767
558
|
}
|
|
768
559
|
return null;
|
|
769
560
|
default:
|
|
@@ -771,7 +562,7 @@ function FormRenderer({
|
|
|
771
562
|
}
|
|
772
563
|
};
|
|
773
564
|
const buttonLabel = form.submitButtonLabel || "Submit";
|
|
774
|
-
return /* @__PURE__ */
|
|
565
|
+
return /* @__PURE__ */ React.createElement("form", { onSubmit: handleSubmit, className }, (_a = form.fields) == null ? void 0 : _a.map((field) => renderFieldElement(field)), renderButton ? renderButton({ isSubmitting, label: buttonLabel }) : /* @__PURE__ */ React.createElement(
|
|
775
566
|
"button",
|
|
776
567
|
{
|
|
777
568
|
type: "submit",
|
|
@@ -781,295 +572,8 @@ function FormRenderer({
|
|
|
781
572
|
buttonLabel
|
|
782
573
|
));
|
|
783
574
|
}
|
|
784
|
-
|
|
785
|
-
// src/components/Image/index.tsx
|
|
786
|
-
import React4, { useCallback as useCallback2, useRef as useRef2, useState as useState2 } from "react";
|
|
787
|
-
|
|
788
|
-
// src/utils/image.ts
|
|
789
|
-
var IMAGE_SIZES = [384, 768, 1536];
|
|
790
|
-
function getImageSrcSet(image) {
|
|
791
|
-
const parts = [];
|
|
792
|
-
const sizes = image.sizes;
|
|
793
|
-
if (sizes) {
|
|
794
|
-
for (const size of IMAGE_SIZES) {
|
|
795
|
-
const entry = sizes[String(size)];
|
|
796
|
-
if ((entry == null ? void 0 : entry.url) && entry.width) {
|
|
797
|
-
parts.push(`${entry.url} ${entry.width}w`);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
if (image.url && image.width) {
|
|
802
|
-
parts.push(`${image.url} ${image.width}w`);
|
|
803
|
-
}
|
|
804
|
-
return parts.join(", ");
|
|
805
|
-
}
|
|
806
|
-
function getImagePlaceholderStyle(image, options) {
|
|
807
|
-
var _a, _b, _c;
|
|
808
|
-
const type = (_a = options == null ? void 0 : options.type) != null ? _a : "blur";
|
|
809
|
-
const paletteColor = (_b = options == null ? void 0 : options.paletteColor) != null ? _b : "muted";
|
|
810
|
-
if (type === "none") return {};
|
|
811
|
-
const color = (_c = image.palette) == null ? void 0 : _c[paletteColor];
|
|
812
|
-
if (type === "blur") {
|
|
813
|
-
const lqip = image.lqip;
|
|
814
|
-
if (lqip) {
|
|
815
|
-
return {
|
|
816
|
-
backgroundImage: `url(${lqip})`,
|
|
817
|
-
backgroundSize: "cover",
|
|
818
|
-
backgroundPosition: "center"
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
if (color) {
|
|
822
|
-
return { backgroundColor: color };
|
|
823
|
-
}
|
|
824
|
-
return {};
|
|
825
|
-
}
|
|
826
|
-
if (color) {
|
|
827
|
-
return { backgroundColor: color };
|
|
828
|
-
}
|
|
829
|
-
return {};
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
// src/components/Image/index.tsx
|
|
833
|
-
function Image({
|
|
834
|
-
image,
|
|
835
|
-
width,
|
|
836
|
-
dpr = 1,
|
|
837
|
-
placeholder: placeholderProp,
|
|
838
|
-
className,
|
|
839
|
-
style,
|
|
840
|
-
imgClassName,
|
|
841
|
-
imgStyle,
|
|
842
|
-
sizes,
|
|
843
|
-
loading: loadingProp,
|
|
844
|
-
onLoad,
|
|
845
|
-
objectFit = "cover",
|
|
846
|
-
priority = false,
|
|
847
|
-
fill = false,
|
|
848
|
-
imageRendering
|
|
849
|
-
}) {
|
|
850
|
-
var _a, _b;
|
|
851
|
-
const [loaded, setLoaded] = useState2(false);
|
|
852
|
-
const firedRef = useRef2(false);
|
|
853
|
-
const isPixelRendering = imageRendering === "pixelated" || imageRendering === "crisp-edges";
|
|
854
|
-
const placeholder = placeholderProp != null ? placeholderProp : isPixelRendering ? "none" : "blur";
|
|
855
|
-
const loading = priority ? "eager" : loadingProp != null ? loadingProp : "lazy";
|
|
856
|
-
const aspectRatio = !fill && image.width && image.height ? `${image.width} / ${image.height}` : void 0;
|
|
857
|
-
const srcSet = getImageSrcSet(image);
|
|
858
|
-
const src = (_a = image.url) != null ? _a : void 0;
|
|
859
|
-
const hasLqip = placeholder === "blur" && !!image.lqip;
|
|
860
|
-
const placeholderStyle = getImagePlaceholderStyle(image, {
|
|
861
|
-
type: placeholder
|
|
862
|
-
});
|
|
863
|
-
const placeholderColor = !hasLqip && "backgroundColor" in placeholderStyle ? placeholderStyle.backgroundColor : void 0;
|
|
864
|
-
const fireLoad = useCallback2(() => {
|
|
865
|
-
if (firedRef.current) return;
|
|
866
|
-
firedRef.current = true;
|
|
867
|
-
setLoaded(true);
|
|
868
|
-
onLoad == null ? void 0 : onLoad();
|
|
869
|
-
}, [onLoad]);
|
|
870
|
-
const imgRef = useCallback2(
|
|
871
|
-
(node) => {
|
|
872
|
-
if (node && node.complete && node.naturalWidth > 0) {
|
|
873
|
-
fireLoad();
|
|
874
|
-
}
|
|
875
|
-
},
|
|
876
|
-
[fireLoad]
|
|
877
|
-
);
|
|
878
|
-
const containerStyle = __spreadValues(__spreadValues(__spreadValues({
|
|
879
|
-
position: "relative",
|
|
880
|
-
overflow: "hidden"
|
|
881
|
-
}, fill ? { width: "100%", height: "100%" } : {}), aspectRatio ? { aspectRatio } : {}), style);
|
|
882
|
-
const overlayBase = {
|
|
883
|
-
position: "absolute",
|
|
884
|
-
top: 0,
|
|
885
|
-
left: 0,
|
|
886
|
-
width: "100%",
|
|
887
|
-
height: "100%",
|
|
888
|
-
opacity: loaded ? 0 : 1,
|
|
889
|
-
transition: "opacity 0.3s ease",
|
|
890
|
-
pointerEvents: "none"
|
|
891
|
-
};
|
|
892
|
-
const mainImgStyle = __spreadValues(__spreadProps(__spreadValues({
|
|
893
|
-
display: "block",
|
|
894
|
-
width: "100%",
|
|
895
|
-
height: "100%",
|
|
896
|
-
objectFit
|
|
897
|
-
}, imageRendering ? { imageRendering } : {}), {
|
|
898
|
-
opacity: loaded ? 1 : 0,
|
|
899
|
-
transition: "opacity 0.3s ease"
|
|
900
|
-
}), imgStyle);
|
|
901
|
-
return /* @__PURE__ */ React4.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ React4.createElement(
|
|
902
|
-
"img",
|
|
903
|
-
{
|
|
904
|
-
"aria-hidden": true,
|
|
905
|
-
alt: "",
|
|
906
|
-
src: image.lqip,
|
|
907
|
-
style: __spreadProps(__spreadValues({}, overlayBase), {
|
|
908
|
-
display: "block",
|
|
909
|
-
objectFit,
|
|
910
|
-
filter: "blur(20px)",
|
|
911
|
-
transform: "scale(1.1)"
|
|
912
|
-
})
|
|
913
|
-
}
|
|
914
|
-
), placeholderColor && /* @__PURE__ */ React4.createElement(
|
|
915
|
-
"div",
|
|
916
|
-
{
|
|
917
|
-
"aria-hidden": true,
|
|
918
|
-
style: __spreadProps(__spreadValues({}, overlayBase), {
|
|
919
|
-
backgroundColor: placeholderColor
|
|
920
|
-
})
|
|
921
|
-
}
|
|
922
|
-
), /* @__PURE__ */ React4.createElement(
|
|
923
|
-
"img",
|
|
924
|
-
{
|
|
925
|
-
ref: imgRef,
|
|
926
|
-
alt: (_b = image.alt) != null ? _b : "",
|
|
927
|
-
src,
|
|
928
|
-
srcSet: srcSet || void 0,
|
|
929
|
-
sizes,
|
|
930
|
-
width: width ? width * dpr : void 0,
|
|
931
|
-
loading,
|
|
932
|
-
decoding: "async",
|
|
933
|
-
fetchPriority: priority ? "high" : void 0,
|
|
934
|
-
onLoad: fireLoad,
|
|
935
|
-
className: imgClassName,
|
|
936
|
-
style: mainImgStyle
|
|
937
|
-
}
|
|
938
|
-
));
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
// src/components/CodeBlock/index.tsx
|
|
942
|
-
import React5, { useEffect as useEffect2, useState as useState3 } from "react";
|
|
943
|
-
|
|
944
|
-
// src/components/CodeBlock/highlight.ts
|
|
945
|
-
import { Fragment } from "react";
|
|
946
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
947
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
948
|
-
import { codeToHast } from "shiki";
|
|
949
|
-
var LANGUAGE_ALIASES = {
|
|
950
|
-
js: "javascript",
|
|
951
|
-
ts: "typescript",
|
|
952
|
-
sh: "bash",
|
|
953
|
-
shell: "bash",
|
|
954
|
-
yml: "yaml",
|
|
955
|
-
py: "python",
|
|
956
|
-
rb: "ruby",
|
|
957
|
-
plaintext: "text"
|
|
958
|
-
};
|
|
959
|
-
function normalizeLanguage(lang) {
|
|
960
|
-
return LANGUAGE_ALIASES[lang] || lang;
|
|
961
|
-
}
|
|
962
|
-
function highlight(code, lang, theme = "github-dark") {
|
|
963
|
-
return __async(this, null, function* () {
|
|
964
|
-
const normalized = normalizeLanguage(lang);
|
|
965
|
-
try {
|
|
966
|
-
const hast = yield codeToHast(code, {
|
|
967
|
-
lang: normalized,
|
|
968
|
-
theme
|
|
969
|
-
});
|
|
970
|
-
return toJsxRuntime(hast, { Fragment, jsx, jsxs });
|
|
971
|
-
} catch (e) {
|
|
972
|
-
const hast = yield codeToHast(code, { lang: "text", theme });
|
|
973
|
-
return toJsxRuntime(hast, { Fragment, jsx, jsxs });
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// src/components/CodeBlock/index.tsx
|
|
979
|
-
function CodeBlock({
|
|
980
|
-
code,
|
|
981
|
-
language = "typescript",
|
|
982
|
-
theme = "github-dark",
|
|
983
|
-
className,
|
|
984
|
-
initial,
|
|
985
|
-
showLineNumbers = false,
|
|
986
|
-
showCopyButton = true
|
|
987
|
-
}) {
|
|
988
|
-
const [nodes, setNodes] = useState3(initial);
|
|
989
|
-
const [copied, setCopied] = useState3(false);
|
|
990
|
-
useEffect2(() => {
|
|
991
|
-
let cancelled = false;
|
|
992
|
-
void highlight(code, language, theme).then((el) => {
|
|
993
|
-
if (!cancelled) setNodes(el);
|
|
994
|
-
});
|
|
995
|
-
return () => {
|
|
996
|
-
cancelled = true;
|
|
997
|
-
};
|
|
998
|
-
}, [code, language, theme]);
|
|
999
|
-
const handleCopy = () => {
|
|
1000
|
-
void navigator.clipboard.writeText(code).then(() => {
|
|
1001
|
-
setCopied(true);
|
|
1002
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1003
|
-
}, () => {
|
|
1004
|
-
});
|
|
1005
|
-
};
|
|
1006
|
-
return /* @__PURE__ */ React5.createElement("div", { className, style: { position: "relative" } }, showCopyButton && /* @__PURE__ */ React5.createElement(
|
|
1007
|
-
"button",
|
|
1008
|
-
{
|
|
1009
|
-
type: "button",
|
|
1010
|
-
onClick: handleCopy,
|
|
1011
|
-
"aria-label": "Copy code",
|
|
1012
|
-
style: {
|
|
1013
|
-
position: "absolute",
|
|
1014
|
-
top: 8,
|
|
1015
|
-
right: 8,
|
|
1016
|
-
zIndex: 1,
|
|
1017
|
-
padding: "4px 8px",
|
|
1018
|
-
fontSize: 12,
|
|
1019
|
-
lineHeight: 1,
|
|
1020
|
-
border: "1px solid rgba(255,255,255,0.2)",
|
|
1021
|
-
borderRadius: 4,
|
|
1022
|
-
background: "rgba(0,0,0,0.3)",
|
|
1023
|
-
color: "#ccc",
|
|
1024
|
-
cursor: "pointer",
|
|
1025
|
-
opacity: 0.7,
|
|
1026
|
-
transition: "opacity 0.15s"
|
|
1027
|
-
},
|
|
1028
|
-
onMouseEnter: (e) => {
|
|
1029
|
-
e.currentTarget.style.opacity = "1";
|
|
1030
|
-
},
|
|
1031
|
-
onMouseLeave: (e) => {
|
|
1032
|
-
e.currentTarget.style.opacity = "0.7";
|
|
1033
|
-
}
|
|
1034
|
-
},
|
|
1035
|
-
copied ? "Copied!" : "Copy"
|
|
1036
|
-
), showLineNumbers && nodes ? /* @__PURE__ */ React5.createElement("div", { style: { display: "flex" } }, /* @__PURE__ */ React5.createElement(
|
|
1037
|
-
"div",
|
|
1038
|
-
{
|
|
1039
|
-
"aria-hidden": true,
|
|
1040
|
-
style: {
|
|
1041
|
-
padding: "1em 0.5em 1em 1em",
|
|
1042
|
-
textAlign: "right",
|
|
1043
|
-
userSelect: "none",
|
|
1044
|
-
color: "rgba(255,255,255,0.3)",
|
|
1045
|
-
fontFamily: "monospace",
|
|
1046
|
-
fontSize: 13,
|
|
1047
|
-
lineHeight: 1.5
|
|
1048
|
-
}
|
|
1049
|
-
},
|
|
1050
|
-
code.split("\n").map((_, i) => /* @__PURE__ */ React5.createElement("div", { key: i }, i + 1))
|
|
1051
|
-
), /* @__PURE__ */ React5.createElement("div", { style: { flex: 1, overflow: "auto" } }, nodes)) : nodes != null ? nodes : /* @__PURE__ */ React5.createElement(
|
|
1052
|
-
"pre",
|
|
1053
|
-
{
|
|
1054
|
-
style: {
|
|
1055
|
-
margin: 0,
|
|
1056
|
-
padding: "1em",
|
|
1057
|
-
overflow: "auto",
|
|
1058
|
-
fontFamily: "monospace",
|
|
1059
|
-
fontSize: 13,
|
|
1060
|
-
lineHeight: 1.5
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
/* @__PURE__ */ React5.createElement("code", null, code)
|
|
1064
|
-
));
|
|
1065
|
-
}
|
|
1066
575
|
export {
|
|
1067
|
-
CodeBlock,
|
|
1068
576
|
FormRenderer,
|
|
1069
|
-
Image,
|
|
1070
|
-
RichTextContent,
|
|
1071
|
-
StyledRichTextContent,
|
|
1072
|
-
highlight,
|
|
1073
577
|
toSubmissionData
|
|
1074
578
|
};
|
|
1075
|
-
//# sourceMappingURL=
|
|
579
|
+
//# sourceMappingURL=form.js.map
|