@oakjs/react-renderer 0.0.0-stage → 4.0.0-alpha.0
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 +137 -2
- package/dist/index.cjs +460 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +438 -0
- package/dist/index.js.map +1 -0
- package/dist/oak-renderer.css +5 -0
- package/dist/oak-renderer.css.map +1 -0
- package/dist/server.cjs +331 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.js +312 -0
- package/dist/server.js.map +1 -0
- package/dist/types/components/Button/index.d.ts +7 -0
- package/dist/types/components/Button/index.d.ts.map +1 -0
- package/dist/types/components/Clickable/index.d.ts +7 -0
- package/dist/types/components/Clickable/index.d.ts.map +1 -0
- package/dist/types/components/Col/index.d.ts +8 -0
- package/dist/types/components/Col/index.d.ts.map +1 -0
- package/dist/types/components/EmptySpace/index.d.ts +7 -0
- package/dist/types/components/EmptySpace/index.d.ts.map +1 -0
- package/dist/types/components/Foldable/index.d.ts +7 -0
- package/dist/types/components/Foldable/index.d.ts.map +1 -0
- package/dist/types/components/HTMLContent.d.ts +14 -0
- package/dist/types/components/HTMLContent.d.ts.map +1 -0
- package/dist/types/components/Image/index.d.ts +7 -0
- package/dist/types/components/Image/index.d.ts.map +1 -0
- package/dist/types/components/Row/index.d.ts +7 -0
- package/dist/types/components/Row/index.d.ts.map +1 -0
- package/dist/types/components/Text/index.d.ts +7 -0
- package/dist/types/components/Text/index.d.ts.map +1 -0
- package/dist/types/components/Title/index.d.ts +7 -0
- package/dist/types/components/Title/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +17 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/server.d.ts +30 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/types.d.ts +81 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +62 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/lib/tailwind.css +49 -0
- package/package.json +65 -4
package/dist/server.js
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { classNames } from "@junipero/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
// lib/utils.ts
|
|
5
|
+
const BREAKPOINTS = [
|
|
6
|
+
"xs",
|
|
7
|
+
"sm",
|
|
8
|
+
"md",
|
|
9
|
+
"lg",
|
|
10
|
+
"xl"
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Container widths (in px) at which each breakpoint starts.
|
|
14
|
+
* Responsive rules use container queries (not media queries) so that the
|
|
15
|
+
* content adapts to its container width: this allows builders to preview
|
|
16
|
+
* any screen size without resizing the window.
|
|
17
|
+
*/
|
|
18
|
+
const BREAKPOINT_WIDTHS = {
|
|
19
|
+
xs: 0,
|
|
20
|
+
sm: 576,
|
|
21
|
+
md: 768,
|
|
22
|
+
lg: 992,
|
|
23
|
+
xl: 1200
|
|
24
|
+
};
|
|
25
|
+
const HIDDEN_CLASSES = {
|
|
26
|
+
xs: "oak:@max-[575.98px]:hidden",
|
|
27
|
+
sm: "oak:@min-[576px]:@max-[767.98px]:hidden",
|
|
28
|
+
md: "oak:@min-[768px]:@max-[991.98px]:hidden",
|
|
29
|
+
lg: "oak:@min-[992px]:@max-[1199.98px]:hidden",
|
|
30
|
+
xl: "oak:@min-[1200px]:hidden"
|
|
31
|
+
};
|
|
32
|
+
const COL_VARIANTS = {
|
|
33
|
+
xs: "oak:",
|
|
34
|
+
sm: "oak:@min-[576px]:",
|
|
35
|
+
md: "oak:@min-[768px]:",
|
|
36
|
+
lg: "oak:@min-[992px]:",
|
|
37
|
+
xl: "oak:@min-[1200px]:"
|
|
38
|
+
};
|
|
39
|
+
const COL_VALUES = [
|
|
40
|
+
"fluid",
|
|
41
|
+
"auto",
|
|
42
|
+
"hide",
|
|
43
|
+
...Array.from({ length: 12 }, (_, i) => i + 1)
|
|
44
|
+
];
|
|
45
|
+
const isNumeric = (value) => typeof value === "number" || typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value.trim());
|
|
46
|
+
/**
|
|
47
|
+
* Appends `px` to unitless numeric values, and returns undefined for empty
|
|
48
|
+
* values so they are omitted from the style object.
|
|
49
|
+
*/
|
|
50
|
+
const toCSSUnit = (value) => {
|
|
51
|
+
if (value === void 0 || value === null || value === "") return;
|
|
52
|
+
if (isNumeric(value)) return Number(value) === 0 ? "0" : `${value}px`.replace(/\s/g, "");
|
|
53
|
+
return String(value);
|
|
54
|
+
};
|
|
55
|
+
const SIDES = [
|
|
56
|
+
"Top",
|
|
57
|
+
"Right",
|
|
58
|
+
"Bottom",
|
|
59
|
+
"Left"
|
|
60
|
+
];
|
|
61
|
+
const CORNERS = [
|
|
62
|
+
"TopLeft",
|
|
63
|
+
"TopRight",
|
|
64
|
+
"BottomRight",
|
|
65
|
+
"BottomLeft"
|
|
66
|
+
];
|
|
67
|
+
const assignIfDefined = (target, key, value) => {
|
|
68
|
+
if (value !== void 0 && value !== null && value !== "") target[key] = value;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Converts oak's element styling settings (`element.styles`) into a react
|
|
72
|
+
* style object.
|
|
73
|
+
*/
|
|
74
|
+
const getElementStyle = (styles) => {
|
|
75
|
+
if (!styles || typeof styles !== "object") return {};
|
|
76
|
+
const style = {};
|
|
77
|
+
SIDES.forEach((side) => {
|
|
78
|
+
assignIfDefined(style, `padding${side}`, toCSSUnit(styles[`padding${side}`]));
|
|
79
|
+
assignIfDefined(style, `margin${side}`, toCSSUnit(styles[`margin${side}`]));
|
|
80
|
+
const borderWidth = toCSSUnit(styles[`border${side}`]);
|
|
81
|
+
if (borderWidth) {
|
|
82
|
+
style[`border${side}Width`] = borderWidth;
|
|
83
|
+
style[`border${side}Style`] = styles[`border${side}Style`] || "solid";
|
|
84
|
+
} else assignIfDefined(style, `border${side}Style`, styles[`border${side}Style`]);
|
|
85
|
+
assignIfDefined(style, `border${side}Color`, styles[`border${side}Color`]);
|
|
86
|
+
});
|
|
87
|
+
CORNERS.forEach((corner) => {
|
|
88
|
+
assignIfDefined(style, `border${corner}Radius`, toCSSUnit(styles[`border${corner}Radius`]));
|
|
89
|
+
});
|
|
90
|
+
assignIfDefined(style, "backgroundColor", styles.backgroundColor);
|
|
91
|
+
const backgroundImage = typeof styles.backgroundImage === "string" ? styles.backgroundImage : styles.backgroundImage?.url;
|
|
92
|
+
if (backgroundImage) {
|
|
93
|
+
style.backgroundImage = `url("${String(backgroundImage).replace(/"/g, "\\\"")}")`;
|
|
94
|
+
style.backgroundSize = styles.backgroundSize && styles.backgroundSize !== "default" ? styles.backgroundSize : void 0;
|
|
95
|
+
assignIfDefined(style, "backgroundPosition", styles.backgroundPosition);
|
|
96
|
+
assignIfDefined(style, "backgroundRepeat", styles.backgroundRepeat);
|
|
97
|
+
}
|
|
98
|
+
if ([
|
|
99
|
+
styles.boxShadowX,
|
|
100
|
+
styles.boxShadowY,
|
|
101
|
+
styles.boxShadowBlur,
|
|
102
|
+
styles.boxShadowSpread
|
|
103
|
+
].some((v) => v !== void 0 && v !== null && v !== "")) style.boxShadow = [
|
|
104
|
+
toCSSUnit(styles.boxShadowX) || "0",
|
|
105
|
+
toCSSUnit(styles.boxShadowY) || "0",
|
|
106
|
+
toCSSUnit(styles.boxShadowBlur) || "0",
|
|
107
|
+
toCSSUnit(styles.boxShadowSpread) || "0",
|
|
108
|
+
styles.boxShadowColor || "rgba(0, 0, 0, 0.25)"
|
|
109
|
+
].join(" ");
|
|
110
|
+
Object.keys(style).forEach((k) => style[k] === void 0 && delete style[k]);
|
|
111
|
+
return style;
|
|
112
|
+
};
|
|
113
|
+
const toKebabCase = (str) => str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
114
|
+
const escapeAttribute = (value) => String(value).replace(/["\\]/g, "\\$&");
|
|
115
|
+
/**
|
|
116
|
+
* Generates the css rules for interactive states (hover, active) that cannot
|
|
117
|
+
* be expressed through inline styles.
|
|
118
|
+
*/
|
|
119
|
+
const getElementStatesCSS = (element, { dark = false } = {}) => {
|
|
120
|
+
const rules = [];
|
|
121
|
+
["hover", "active"].forEach((state) => {
|
|
122
|
+
const style = {
|
|
123
|
+
...getElementStyle(element.styles?.[state]),
|
|
124
|
+
...dark && getElementStyle(element.styles?.dark?.[state])
|
|
125
|
+
};
|
|
126
|
+
const declarations = Object.entries(style).map(([k, v]) => `${toKebabCase(k)}:${v} !important`).join(";");
|
|
127
|
+
if (declarations) rules.push(`[data-oak-id="${escapeAttribute(String(element.id))}"]:${state}{${declarations}}`);
|
|
128
|
+
});
|
|
129
|
+
return rules.join("");
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Returns classes hiding the element on the breakpoints where it was set as
|
|
133
|
+
* hidden (`element.responsive[breakpoint] === 'hide'`).
|
|
134
|
+
*/
|
|
135
|
+
const getVisibilityClasses = (element) => classNames(BREAKPOINTS.filter((bp) => element.responsive?.[bp] === "hide").map((bp) => HIDDEN_CLASSES[bp]));
|
|
136
|
+
/**
|
|
137
|
+
* Returns the size classes of a column, for every breakpoint.
|
|
138
|
+
* The base size (`element.size`) is used for every breakpoint that doesn't
|
|
139
|
+
* declare a specific size in `element.responsive`.
|
|
140
|
+
*/
|
|
141
|
+
const getColClasses = (element) => {
|
|
142
|
+
const base = COL_VALUES.includes(element.size) ? element.size : "fluid";
|
|
143
|
+
const classes = [];
|
|
144
|
+
let previous = null;
|
|
145
|
+
BREAKPOINTS.forEach((bp) => {
|
|
146
|
+
const value = COL_VALUES.includes(element.responsive?.[bp]) ? element.responsive[bp] : base;
|
|
147
|
+
if (value !== previous) {
|
|
148
|
+
classes.push(`${COL_VARIANTS[bp]}colsize-${value}`);
|
|
149
|
+
previous = value;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return classNames(classes);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Merges additional attributes into the attributes given by the renderer,
|
|
156
|
+
* concatenating classNames & merging styles.
|
|
157
|
+
*/
|
|
158
|
+
const mergeAttributes = (attributes, ...others) => others.reduce((res, other) => {
|
|
159
|
+
if (!other) return res;
|
|
160
|
+
return {
|
|
161
|
+
...res,
|
|
162
|
+
...other,
|
|
163
|
+
className: classNames(res.className, other.className) || void 0,
|
|
164
|
+
style: {
|
|
165
|
+
...other.style,
|
|
166
|
+
...res.style
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}, { ...attributes });
|
|
170
|
+
/**
|
|
171
|
+
* DOM event dispatched (bubbling) by builders on an element that is hidden
|
|
172
|
+
* by one of its ancestors (e.g. inside a collapsed foldable) and needs to be
|
|
173
|
+
* displayed. Components hiding their children should listen to it on their
|
|
174
|
+
* root node and display the section containing `event.target`.
|
|
175
|
+
*/
|
|
176
|
+
const REVEAL_EVENT = "oak:reveal";
|
|
177
|
+
/**
|
|
178
|
+
* Attributes to put on the DOM node that directly wraps a list of child
|
|
179
|
+
* elements. Builders rely on them to know where elements can be dropped.
|
|
180
|
+
*/
|
|
181
|
+
const containerAttributes = (key) => ({ "data-oak-container": key });
|
|
182
|
+
/**
|
|
183
|
+
* Computes the attributes every rendered element should receive (see
|
|
184
|
+
* `RendererComponentProps.attributes`): data attributes, className (custom
|
|
185
|
+
* class & responsive visibility), style (from styling settings), dir & role.
|
|
186
|
+
*/
|
|
187
|
+
const getElementAttributes = (element, component, { dark = false } = {}) => {
|
|
188
|
+
const style = {
|
|
189
|
+
...getElementStyle(element?.styles),
|
|
190
|
+
...dark && getElementStyle(element?.styles?.dark)
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
"data-oak-id": element?.id !== void 0 ? String(element.id) : void 0,
|
|
194
|
+
"data-oak-type": element?.type,
|
|
195
|
+
className: classNames(element?.settings?.className, dark && element?.settings?.dark?.className, !component?.oakHandlesResponsive && getVisibilityClasses(element)) || void 0,
|
|
196
|
+
...element?.settings?.dir && { dir: element.settings.dir },
|
|
197
|
+
...element?.settings?.role && { role: element.settings.role },
|
|
198
|
+
...Object.keys(style).length > 0 && { style }
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
// lib/components/Col/index.tsx
|
|
202
|
+
const Col = ({ element, attributes, renderContainer }) => /* @__PURE__ */ jsx("div", {
|
|
203
|
+
...mergeAttributes(attributes, { className: getColClasses(element) }),
|
|
204
|
+
...containerAttributes("content"),
|
|
205
|
+
children: renderContainer("content")
|
|
206
|
+
});
|
|
207
|
+
Col.displayName = "ColRenderer";
|
|
208
|
+
Col.oakHandlesResponsive = true;
|
|
209
|
+
// lib/components/EmptySpace/index.tsx
|
|
210
|
+
const EmptySpace = ({ element, attributes }) => /* @__PURE__ */ jsx("div", { ...mergeAttributes(attributes, { style: { height: toCSSUnit(element.settings?.height) || "32px" } }) });
|
|
211
|
+
EmptySpace.displayName = "EmptySpaceRenderer";
|
|
212
|
+
// lib/components/Image/index.tsx
|
|
213
|
+
const Image = ({ element, attributes, editing, dark }) => {
|
|
214
|
+
const size = element.settings?.size || "auto";
|
|
215
|
+
const imageStyle = size === "custom" ? {
|
|
216
|
+
width: toCSSUnit(element.settings?.width),
|
|
217
|
+
height: toCSSUnit(element.settings?.height),
|
|
218
|
+
maxWidth: "100%"
|
|
219
|
+
} : size === "full" ? { maxWidth: "none" } : {
|
|
220
|
+
maxWidth: "100%",
|
|
221
|
+
height: "auto"
|
|
222
|
+
};
|
|
223
|
+
return /* @__PURE__ */ jsx("div", {
|
|
224
|
+
...mergeAttributes(attributes, { style: { textAlign: element.settings?.textAlign || "left" } }),
|
|
225
|
+
children: element.url ? /* @__PURE__ */ jsx("img", {
|
|
226
|
+
className: "oak:inline-block oak:align-middle",
|
|
227
|
+
src: element.url,
|
|
228
|
+
alt: element.settings?.alt || "",
|
|
229
|
+
title: element.settings?.description || void 0,
|
|
230
|
+
style: imageStyle,
|
|
231
|
+
draggable: editing ? false : void 0
|
|
232
|
+
}) : editing ? /* @__PURE__ */ jsx("div", {
|
|
233
|
+
className: "oak:inline-flex oak:items-center oak:justify-center oak:w-full oak:h-32 oak:text-sm " + (dark ? "oak:bg-[#262626] oak:text-[#9097A3]" : "oak:bg-[#F3F3F3] oak:text-[#6B778C]"),
|
|
234
|
+
children: "No image"
|
|
235
|
+
}) : null
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
Image.displayName = "ImageRenderer";
|
|
239
|
+
// lib/components/Row/index.tsx
|
|
240
|
+
const Row = ({ element, attributes, renderContainer }) => {
|
|
241
|
+
const gap = toCSSUnit(element.settings?.gap);
|
|
242
|
+
const direction = element.settings?.flexDirection || "row";
|
|
243
|
+
return /* @__PURE__ */ jsx("div", {
|
|
244
|
+
...mergeAttributes(attributes, {
|
|
245
|
+
className: "oak:flex oak:flex-wrap oak:w-full",
|
|
246
|
+
style: {
|
|
247
|
+
flexDirection: direction,
|
|
248
|
+
justifyContent: element.settings?.justifyContent,
|
|
249
|
+
alignItems: element.settings?.alignItems || (/column/.test(direction) ? "stretch" : "flex-start"),
|
|
250
|
+
...gap && {
|
|
251
|
+
gap,
|
|
252
|
+
["--oak-col-gap"]: gap
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}),
|
|
256
|
+
...containerAttributes("cols"),
|
|
257
|
+
children: renderContainer("cols")
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
Row.displayName = "RowRenderer";
|
|
261
|
+
// lib/components/HTMLContent.tsx
|
|
262
|
+
/**
|
|
263
|
+
* Renders a raw html string (usually coming from a rich text field), using
|
|
264
|
+
* the given sanitizer if any.
|
|
265
|
+
*/
|
|
266
|
+
const HTMLContent = ({ tag: Tag = "div", html, sanitizeHTML, ...rest }) => {
|
|
267
|
+
const content = useMemo(() => sanitizeHTML ? sanitizeHTML(html || "") : html || "", [html, sanitizeHTML]);
|
|
268
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
269
|
+
...rest,
|
|
270
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
HTMLContent.displayName = "HTMLContent";
|
|
274
|
+
// lib/components/Text/index.tsx
|
|
275
|
+
const Text = ({ element, attributes, sanitizeHTML }) => /* @__PURE__ */ jsx(HTMLContent, {
|
|
276
|
+
...attributes,
|
|
277
|
+
html: element.content,
|
|
278
|
+
sanitizeHTML
|
|
279
|
+
});
|
|
280
|
+
Text.displayName = "TextRenderer";
|
|
281
|
+
// lib/components/Title/index.tsx
|
|
282
|
+
const HEADINGS = [
|
|
283
|
+
"h1",
|
|
284
|
+
"h2",
|
|
285
|
+
"h3",
|
|
286
|
+
"h4",
|
|
287
|
+
"h5",
|
|
288
|
+
"h6"
|
|
289
|
+
];
|
|
290
|
+
const Title = ({ element, attributes, sanitizeHTML }) => /* @__PURE__ */ jsx(HTMLContent, {
|
|
291
|
+
...attributes,
|
|
292
|
+
tag: HEADINGS.includes(element.headingLevel) ? element.headingLevel : "h1",
|
|
293
|
+
html: element.content,
|
|
294
|
+
sanitizeHTML
|
|
295
|
+
});
|
|
296
|
+
Title.displayName = "TitleRenderer";
|
|
297
|
+
// lib/server.ts
|
|
298
|
+
/**
|
|
299
|
+
* Server-capable renderers of oak's base components, keyed by component id
|
|
300
|
+
* (see `baseComponents()` for every renderer, including interactive ones)
|
|
301
|
+
*/
|
|
302
|
+
const serverComponents = () => ({
|
|
303
|
+
row: Row,
|
|
304
|
+
col: Col,
|
|
305
|
+
"empty-space": EmptySpace,
|
|
306
|
+
title: Title,
|
|
307
|
+
text: Text,
|
|
308
|
+
image: Image
|
|
309
|
+
});
|
|
310
|
+
export { BREAKPOINTS, BREAKPOINT_WIDTHS, Col, EmptySpace, HTMLContent, Image, REVEAL_EVENT, Row, Text, Title, containerAttributes, getColClasses, getElementAttributes, getElementStatesCSS, getElementStyle, getVisibilityClasses, mergeAttributes, serverComponents, toCSSUnit };
|
|
311
|
+
|
|
312
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../lib/utils.ts","../lib/components/Col/index.tsx","../lib/components/EmptySpace/index.tsx","../lib/components/Image/index.tsx","../lib/components/Row/index.tsx","../lib/components/HTMLContent.tsx","../lib/components/Text/index.tsx","../lib/components/Title/index.tsx","../lib/server.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport { classNames } from '@junipero/core';\n\nimport type {\n Breakpoint,\n ElementObject,\n ElementAttributes,\n ElementRenderOptions,\n ElementStyles,\n RendererComponent,\n} from './types';\n\nexport const BREAKPOINTS: Breakpoint[] = ['xs', 'sm', 'md', 'lg', 'xl'];\n\n/**\n * Container widths (in px) at which each breakpoint starts.\n * Responsive rules use container queries (not media queries) so that the\n * content adapts to its container width: this allows builders to preview\n * any screen size without resizing the window.\n */\nexport const BREAKPOINT_WIDTHS: Record<Breakpoint, number> = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n};\n\n// Class names must be written in full so that tailwind can find them\nconst HIDDEN_CLASSES: Record<Breakpoint, string> = {\n xs: 'oak:@max-[575.98px]:hidden',\n sm: 'oak:@min-[576px]:@max-[767.98px]:hidden',\n md: 'oak:@min-[768px]:@max-[991.98px]:hidden',\n lg: 'oak:@min-[992px]:@max-[1199.98px]:hidden',\n xl: 'oak:@min-[1200px]:hidden',\n};\n\n// Generated through @source inline() in tailwind.css\nconst COL_VARIANTS: Record<Breakpoint, string> = {\n xs: 'oak:',\n sm: 'oak:@min-[576px]:',\n md: 'oak:@min-[768px]:',\n lg: 'oak:@min-[992px]:',\n xl: 'oak:@min-[1200px]:',\n};\n\nconst COL_VALUES = [\n 'fluid', 'auto', 'hide', ...Array.from({ length: 12 }, (_, i) => i + 1),\n];\n\nconst isNumeric = (value: unknown) =>\n typeof value === 'number' ||\n (typeof value === 'string' && /^-?\\d+(\\.\\d+)?$/.test(value.trim()));\n\n/**\n * Appends `px` to unitless numeric values, and returns undefined for empty\n * values so they are omitted from the style object.\n */\nexport const toCSSUnit = (value: unknown): string | undefined => {\n if (value === undefined || value === null || value === '') {\n return undefined;\n }\n\n if (isNumeric(value)) {\n return Number(value) === 0 ? '0' : `${value}px`.replace(/\\s/g, '');\n }\n\n return String(value);\n};\n\nconst SIDES = ['Top', 'Right', 'Bottom', 'Left'] as const;\nconst CORNERS = ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'] as const;\n\nconst assignIfDefined = (\n target: Record<string, any>,\n key: string,\n value: unknown,\n) => {\n if (value !== undefined && value !== null && value !== '') {\n target[key] = value;\n }\n};\n\n/**\n * Converts oak's element styling settings (`element.styles`) into a react\n * style object.\n */\nexport const getElementStyle = (styles?: ElementStyles): CSSProperties => {\n if (!styles || typeof styles !== 'object') {\n return {};\n }\n\n const style: Record<string, any> = {};\n\n SIDES.forEach(side => {\n assignIfDefined(style, `padding${side}`, toCSSUnit(styles[`padding${side}`]));\n assignIfDefined(style, `margin${side}`, toCSSUnit(styles[`margin${side}`]));\n\n const borderWidth = toCSSUnit(styles[`border${side}`]);\n\n if (borderWidth) {\n style[`border${side}Width`] = borderWidth;\n // A border width without style would be invisible\n style[`border${side}Style`] = styles[`border${side}Style`] || 'solid';\n } else {\n assignIfDefined(style, `border${side}Style`, styles[`border${side}Style`]);\n }\n\n assignIfDefined(style, `border${side}Color`, styles[`border${side}Color`]);\n });\n\n CORNERS.forEach(corner => {\n assignIfDefined(\n style,\n `border${corner}Radius`,\n toCSSUnit(styles[`border${corner}Radius`]),\n );\n });\n\n assignIfDefined(style, 'backgroundColor', styles.backgroundColor);\n\n const backgroundImage = typeof styles.backgroundImage === 'string'\n ? styles.backgroundImage\n : styles.backgroundImage?.url;\n\n if (backgroundImage) {\n style.backgroundImage = `url(\"${String(backgroundImage)\n .replace(/\"/g, '\\\\\"')}\")`;\n style.backgroundSize = styles.backgroundSize &&\n styles.backgroundSize !== 'default' ? styles.backgroundSize : undefined;\n assignIfDefined(style, 'backgroundPosition', styles.backgroundPosition);\n assignIfDefined(style, 'backgroundRepeat', styles.backgroundRepeat);\n }\n\n if (\n [\n styles.boxShadowX, styles.boxShadowY,\n styles.boxShadowBlur, styles.boxShadowSpread,\n ].some(v => v !== undefined && v !== null && v !== '')\n ) {\n style.boxShadow = [\n toCSSUnit(styles.boxShadowX) || '0',\n toCSSUnit(styles.boxShadowY) || '0',\n toCSSUnit(styles.boxShadowBlur) || '0',\n toCSSUnit(styles.boxShadowSpread) || '0',\n styles.boxShadowColor || 'rgba(0, 0, 0, 0.25)',\n ].join(' ');\n }\n\n Object.keys(style).forEach(k => style[k] === undefined && delete style[k]);\n\n return style;\n};\n\nconst toKebabCase = (str: string) =>\n str.replace(/[A-Z]/g, m => '-' + m.toLowerCase());\n\nconst escapeAttribute = (value: string) =>\n String(value).replace(/[\"\\\\]/g, '\\\\$&');\n\n/**\n * Generates the css rules for interactive states (hover, active) that cannot\n * be expressed through inline styles.\n */\nexport const getElementStatesCSS = (\n element: ElementObject,\n { dark = false }: ElementRenderOptions = {},\n): string => {\n const rules: string[] = [];\n\n (['hover', 'active'] as const).forEach(state => {\n const style = {\n ...getElementStyle(element.styles?.[state]),\n ...dark && getElementStyle(element.styles?.dark?.[state]),\n };\n const declarations = Object.entries(style)\n .map(([k, v]) => `${toKebabCase(k)}:${v} !important`)\n .join(';');\n\n if (declarations) {\n rules.push(\n `[data-oak-id=\"${escapeAttribute(String(element.id))}\"]:${state}` +\n `{${declarations}}`\n );\n }\n });\n\n return rules.join('');\n};\n\n/**\n * Returns classes hiding the element on the breakpoints where it was set as\n * hidden (`element.responsive[breakpoint] === 'hide'`).\n */\nexport const getVisibilityClasses = (element: ElementObject): string =>\n classNames(\n BREAKPOINTS\n .filter(bp => element.responsive?.[bp] === 'hide')\n .map(bp => HIDDEN_CLASSES[bp])\n );\n\n/**\n * Returns the size classes of a column, for every breakpoint.\n * The base size (`element.size`) is used for every breakpoint that doesn't\n * declare a specific size in `element.responsive`.\n */\nexport const getColClasses = (element: ElementObject): string => {\n const base = COL_VALUES.includes(element.size) ? element.size : 'fluid';\n const classes: string[] = [];\n let previous: string | number = null;\n\n BREAKPOINTS.forEach(bp => {\n const value = COL_VALUES.includes(element.responsive?.[bp])\n ? element.responsive[bp]\n : base;\n\n if (value !== previous) {\n classes.push(`${COL_VARIANTS[bp]}colsize-${value}`);\n previous = value;\n }\n });\n\n return classNames(classes);\n};\n\n/**\n * Merges additional attributes into the attributes given by the renderer,\n * concatenating classNames & merging styles.\n */\nexport const mergeAttributes = (\n attributes: ElementAttributes,\n ...others: (ElementAttributes | null | undefined | false)[]\n): ElementAttributes =>\n others.reduce<ElementAttributes>((res, other) => {\n if (!other) {\n return res;\n }\n\n return {\n ...res,\n ...other,\n className: classNames(res.className, other.className) || undefined,\n style: { ...other.style, ...res.style },\n };\n }, { ...attributes });\n\n/**\n * DOM event dispatched (bubbling) by builders on an element that is hidden\n * by one of its ancestors (e.g. inside a collapsed foldable) and needs to be\n * displayed. Components hiding their children should listen to it on their\n * root node and display the section containing `event.target`.\n */\nexport const REVEAL_EVENT = 'oak:reveal';\n\n/**\n * Attributes to put on the DOM node that directly wraps a list of child\n * elements. Builders rely on them to know where elements can be dropped.\n */\nexport const containerAttributes = (key: string) => ({\n 'data-oak-container': key,\n});\n\n/**\n * Computes the attributes every rendered element should receive (see\n * `RendererComponentProps.attributes`): data attributes, className (custom\n * class & responsive visibility), style (from styling settings), dir & role.\n */\nexport const getElementAttributes = (\n element: ElementObject,\n component?: RendererComponent,\n { dark = false }: ElementRenderOptions = {},\n): ElementAttributes => {\n const style = {\n ...getElementStyle(element?.styles),\n ...dark && getElementStyle(element?.styles?.dark),\n };\n\n return {\n 'data-oak-id': element?.id !== undefined ? String(element.id) : undefined,\n 'data-oak-type': element?.type,\n className: classNames(\n element?.settings?.className,\n dark && element?.settings?.dark?.className,\n !component?.oakHandlesResponsive && getVisibilityClasses(element),\n ) || undefined,\n ...element?.settings?.dir && { dir: element.settings.dir },\n ...element?.settings?.role && { role: element.settings.role },\n ...Object.keys(style).length > 0 && { style },\n };\n};\n","import type { RendererComponentProps } from '../../types';\nimport {\n containerAttributes,\n getColClasses,\n mergeAttributes,\n} from '../../utils';\n\nconst Col = ({ element, attributes, renderContainer }: RendererComponentProps) => (\n <div\n { ...mergeAttributes(attributes, {\n className: getColClasses(element),\n }) }\n { ...containerAttributes('content') }\n >\n { renderContainer('content') }\n </div>\n);\n\nCol.displayName = 'ColRenderer';\nCol.oakHandlesResponsive = true;\n\nexport default Col;\n","import type { RendererComponentProps } from '../../types';\nimport { mergeAttributes, toCSSUnit } from '../../utils';\n\nconst EmptySpace = ({ element, attributes }: RendererComponentProps) => (\n <div\n { ...mergeAttributes(attributes, {\n style: { height: toCSSUnit(element.settings?.height) || '32px' },\n }) }\n />\n);\n\nEmptySpace.displayName = 'EmptySpaceRenderer';\n\nexport default EmptySpace;\n","import type { CSSProperties } from 'react';\n\nimport type { RendererComponentProps } from '../../types';\nimport { mergeAttributes, toCSSUnit } from '../../utils';\n\nconst Image = ({\n element,\n attributes,\n editing,\n dark,\n}: RendererComponentProps) => {\n const size = element.settings?.size || 'auto';\n const imageStyle: CSSProperties = size === 'custom'\n ? {\n width: toCSSUnit(element.settings?.width),\n height: toCSSUnit(element.settings?.height),\n maxWidth: '100%',\n }\n : size === 'full'\n ? { maxWidth: 'none' }\n : { maxWidth: '100%', height: 'auto' };\n\n return (\n <div\n { ...mergeAttributes(attributes, {\n style: { textAlign: element.settings?.textAlign || 'left' },\n }) }\n >\n { element.url ? (\n <img\n className=\"oak:inline-block oak:align-middle\"\n src={element.url}\n alt={element.settings?.alt || ''}\n title={element.settings?.description || undefined}\n style={imageStyle}\n draggable={editing ? false : undefined}\n />\n ) : editing ? (\n <div\n className={\n 'oak:inline-flex oak:items-center oak:justify-center ' +\n 'oak:w-full oak:h-32 oak:text-sm ' +\n (dark\n ? 'oak:bg-[#262626] oak:text-[#9097A3]'\n : 'oak:bg-[#F3F3F3] oak:text-[#6B778C]')\n }\n >\n No image\n </div>\n ) : null }\n </div>\n );\n};\n\nImage.displayName = 'ImageRenderer';\n\nexport default Image;\n","import type { RendererComponentProps } from '../../types';\nimport { containerAttributes, mergeAttributes, toCSSUnit } from '../../utils';\n\nconst Row = ({ element, attributes, renderContainer }: RendererComponentProps) => {\n const gap = toCSSUnit(element.settings?.gap);\n const direction = element.settings?.flexDirection || 'row';\n\n return (\n <div\n { ...mergeAttributes(attributes, {\n className: 'oak:flex oak:flex-wrap oak:w-full',\n style: {\n flexDirection: direction,\n justifyContent: element.settings?.justifyContent,\n alignItems: element.settings?.alignItems ||\n (/column/.test(direction) ? 'stretch' : 'flex-start'),\n ...gap && {\n gap,\n ['--oak-col-gap' as string]: gap,\n },\n },\n }) }\n { ...containerAttributes('cols') }\n >\n { renderContainer('cols') }\n </div>\n );\n};\n\nRow.displayName = 'RowRenderer';\n\nexport default Row;\n","import { type ElementType, type HTMLAttributes, useMemo } from 'react';\n\nimport type { SanitizeHTMLCallback } from '../types';\n\nexport declare interface HTMLContentProps extends HTMLAttributes<HTMLElement> {\n tag?: ElementType;\n html: string;\n sanitizeHTML?: SanitizeHTMLCallback;\n [key: string]: any;\n}\n\n/**\n * Renders a raw html string (usually coming from a rich text field), using\n * the given sanitizer if any.\n */\nconst HTMLContent = ({\n tag: Tag = 'div',\n html,\n sanitizeHTML,\n ...rest\n}: HTMLContentProps) => {\n const content = useMemo(() => (\n sanitizeHTML ? sanitizeHTML(html || '') : html || ''\n ), [html, sanitizeHTML]);\n\n return <Tag { ...rest } dangerouslySetInnerHTML={{ __html: content }} />;\n};\n\nHTMLContent.displayName = 'HTMLContent';\n\nexport default HTMLContent;\n","import type { RendererComponentProps } from '../../types';\nimport HTMLContent from '../HTMLContent';\n\nconst Text = ({ element, attributes, sanitizeHTML }: RendererComponentProps) => (\n <HTMLContent\n { ...attributes }\n html={element.content as string}\n sanitizeHTML={sanitizeHTML}\n />\n);\n\nText.displayName = 'TextRenderer';\n\nexport default Text;\n","import type { RendererComponentProps } from '../../types';\nimport HTMLContent from '../HTMLContent';\n\nconst HEADINGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n\nconst Title = ({ element, attributes, sanitizeHTML }: RendererComponentProps) => (\n <HTMLContent\n { ...attributes }\n tag={HEADINGS.includes(element.headingLevel) ? element.headingLevel : 'h1'}\n html={element.content as string}\n sanitizeHTML={sanitizeHTML}\n />\n);\n\nTitle.displayName = 'TitleRenderer';\n\nexport default Title;\n","/**\n * Server-capable entrypoint (`@oakjs/react-renderer/server`).\n *\n * Contains the renderers that don't use state, effects or event handlers, as\n * well as every helper, so that they can be used inside React Server\n * Components. Unlike the main entrypoint, this one is NOT marked with\n * `'use client'`.\n *\n * Interactive renderers (button, foldable, clickable) are only exported by\n * the main entrypoint (`@oakjs/react-renderer`, marked with `'use client'`).\n * From a server component, render their children first and pass them to a\n * client component of your own, which gives `renderContainer` to them.\n */\nimport type { RendererComponentsMap } from './types';\nimport Col from './components/Col';\nimport EmptySpace from './components/EmptySpace';\nimport Image from './components/Image';\nimport Row from './components/Row';\nimport Text from './components/Text';\nimport Title from './components/Title';\n\nexport {\n Col,\n EmptySpace,\n Image,\n Row,\n Text,\n Title,\n};\n\nexport {\n default as HTMLContent,\n type HTMLContentProps,\n} from './components/HTMLContent';\n\n/**\n * Server-capable renderers of oak's base components, keyed by component id\n * (see `baseComponents()` for every renderer, including interactive ones)\n */\nexport const serverComponents = (): RendererComponentsMap => ({\n row: Row,\n col: Col,\n 'empty-space': EmptySpace,\n title: Title,\n text: Text,\n image: Image,\n});\n\nexport * from './utils';\n\nexport type * from './types';\n"],"mappings":";;;;AAYA,MAAa,cAA4B;CAAC;CAAM;CAAM;CAAM;CAAM;AAAI;;;;;;;AAQtE,MAAa,oBAAgD;CAC3D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAGA,MAAM,iBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAGA,MAAM,eAA2C;CAC/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cAAc;;ACzB1B,MAAM,QAAQ,EAAE,SAAS,YAAY,mBACnC,oBAAC,aAAD;CACE,GAAK;CACL,MAAM,QAAQ;CACA;AACf,CAAA;AAGH,KAAK,cAAc;;ACRnB,MAAM,WAAW;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;AAEpD,MAAM,SAAS,EAAE,SAAS,YAAY,mBACpC,oBAAC,aAAD;CACE,GAAK;CACL,KAAK,SAAS,SAAS,QAAQ,YAAY,IAAI,QAAQ,eAAe;CACtE,MAAM,QAAQ;CACA;AACf,CAAA;AAGH,MAAM,cAAc;;;;;;ACyBpB,MAAa,0BAAiD;CAC5D,KAAK;CACL,KAAK;CACL,eAAe;CACf,OAAO;CACP,MAAM;CACN,OAAO;AACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Button({ element, attributes, sanitizeHTML, onEvent, dark, }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Button {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Button;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Button/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;wBAI1C,EACd,OAAO,EACP,UAAU,EACV,YAAY,EACZ,OAAO,EACP,IAAI,GACL,EAAE,sBAAsB;;;;eA0DV,MAAM"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Clickable({ element, attributes, renderContainer, onEvent, }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Clickable {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Clickable;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Clickable/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;2BAGvC,EACjB,OAAO,EACP,UAAU,EACV,eAAe,EACf,OAAO,GACR,EAAE,sBAAsB;;;;eAsCV,SAAS"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Col({ element, attributes, renderContainer }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Col {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
var oakHandlesResponsive: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default Col;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Col/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;qBAO7C,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,sBAAsB;;;;;eAc9D,GAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function EmptySpace({ element, attributes }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace EmptySpace {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default EmptySpace;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/EmptySpace/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;4BAGtC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,sBAAsB;;;;eAUpD,UAAU"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Foldable({ element, attributes, renderContainer, }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Foldable {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Foldable;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Foldable/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;0BASxC,EAChB,OAAO,EACP,UAAU,EACV,eAAe,GAChB,EAAE,sBAAsB;;;;eA0DV,QAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ElementType, type HTMLAttributes } from 'react';
|
|
2
|
+
import type { SanitizeHTMLCallback } from '../types';
|
|
3
|
+
export declare interface HTMLContentProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
tag?: ElementType;
|
|
5
|
+
html: string;
|
|
6
|
+
sanitizeHTML?: SanitizeHTMLCallback;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
declare function HTMLContent({ tag: Tag, html, sanitizeHTML, ...rest }: HTMLContentProps): import("react").JSX.Element;
|
|
10
|
+
declare namespace HTMLContent {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
13
|
+
export default HTMLContent;
|
|
14
|
+
//# sourceMappingURL=HTMLContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTMLContent.d.ts","sourceRoot":"","sources":["../../../lib/components/HTMLContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAW,MAAM,OAAO,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,CAAC,OAAO,WAAW,gBAAiB,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC3E,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;6BAMoB,EACnB,GAAG,EAAE,GAAW,EAChB,IAAI,EACJ,YAAY,EACZ,GAAG,IAAI,EACR,EAAE,gBAAgB;;;;eAUJ,WAAW"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Image({ element, attributes, editing, dark, }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Image {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Image;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Image/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;uBAG3C,EACb,OAAO,EACP,UAAU,EACV,OAAO,EACP,IAAI,GACL,EAAE,sBAAsB;;;;eA8CV,KAAK"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Row({ element, attributes, renderContainer }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Row {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Row;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Row/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;qBAG7C,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,sBAAsB;;;;eA4B9D,GAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Text({ element, attributes, sanitizeHTML }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Text {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Text;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Text/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;sBAG5C,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,sBAAsB;;;;eAU5D,IAAI"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RendererComponentProps } from '../../types';
|
|
2
|
+
declare function Title({ element, attributes, sanitizeHTML }: RendererComponentProps): import("react").JSX.Element;
|
|
3
|
+
declare namespace Title {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default Title;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Title/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;uBAK3C,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,sBAAsB;;;;eAW7D,KAAK"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RendererComponentsMap } from '../types';
|
|
2
|
+
import Button from './Button';
|
|
3
|
+
import Clickable from './Clickable';
|
|
4
|
+
import Col from './Col';
|
|
5
|
+
import EmptySpace from './EmptySpace';
|
|
6
|
+
import Foldable from './Foldable';
|
|
7
|
+
import Image from './Image';
|
|
8
|
+
import Row from './Row';
|
|
9
|
+
import Text from './Text';
|
|
10
|
+
import Title from './Title';
|
|
11
|
+
export { Button, Clickable, Col, EmptySpace, Foldable, Image, Row, Text, Title, };
|
|
12
|
+
export { default as HTMLContent, type HTMLContentProps } from './HTMLContent';
|
|
13
|
+
/**
|
|
14
|
+
* Renderers for oak's base components, keyed by component id
|
|
15
|
+
*/
|
|
16
|
+
export declare const baseComponents: () => RendererComponentsMap;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EACL,MAAM,EACN,SAAS,EACT,GAAG,EACH,UAAU,EACV,QAAQ,EACR,KAAK,EACL,GAAG,EACH,IAAI,EACJ,KAAK,GACN,CAAC;AAEF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,qBAUhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,mBAAmB,SAAS,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-capable entrypoint (`@oakjs/react-renderer/server`).
|
|
3
|
+
*
|
|
4
|
+
* Contains the renderers that don't use state, effects or event handlers, as
|
|
5
|
+
* well as every helper, so that they can be used inside React Server
|
|
6
|
+
* Components. Unlike the main entrypoint, this one is NOT marked with
|
|
7
|
+
* `'use client'`.
|
|
8
|
+
*
|
|
9
|
+
* Interactive renderers (button, foldable, clickable) are only exported by
|
|
10
|
+
* the main entrypoint (`@oakjs/react-renderer`, marked with `'use client'`).
|
|
11
|
+
* From a server component, render their children first and pass them to a
|
|
12
|
+
* client component of your own, which gives `renderContainer` to them.
|
|
13
|
+
*/
|
|
14
|
+
import type { RendererComponentsMap } from './types';
|
|
15
|
+
import Col from './components/Col';
|
|
16
|
+
import EmptySpace from './components/EmptySpace';
|
|
17
|
+
import Image from './components/Image';
|
|
18
|
+
import Row from './components/Row';
|
|
19
|
+
import Text from './components/Text';
|
|
20
|
+
import Title from './components/Title';
|
|
21
|
+
export { Col, EmptySpace, Image, Row, Text, Title, };
|
|
22
|
+
export { default as HTMLContent, type HTMLContentProps, } from './components/HTMLContent';
|
|
23
|
+
/**
|
|
24
|
+
* Server-capable renderers of oak's base components, keyed by component id
|
|
25
|
+
* (see `baseComponents()` for every renderer, including interactive ones)
|
|
26
|
+
*/
|
|
27
|
+
export declare const serverComponents: () => RendererComponentsMap;
|
|
28
|
+
export * from './utils';
|
|
29
|
+
export type * from './types';
|
|
30
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../lib/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAEvC,OAAO,EACL,GAAG,EACH,UAAU,EACV,KAAK,EACL,GAAG,EACH,IAAI,EACJ,KAAK,GACN,CAAC;AAEF,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,qBAOlC,CAAC;AAEH,cAAc,SAAS,CAAC;AAExB,mBAAmB,SAAS,CAAC"}
|