@palmyit/elements 0.1.7 → 0.1.8
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/dist/definitions.d.ts +23 -20
- package/dist/definitions.js +692 -686
- package/dist/elements/button/definition.d.ts +38 -0
- package/dist/elements/button/template.d.ts +2 -0
- package/dist/elements/checkbox/definition.d.ts +10 -0
- package/dist/elements/checkbox/template.d.ts +2 -0
- package/dist/elements/container/definition.d.ts +39 -0
- package/dist/elements/container/template.d.ts +2 -0
- package/dist/elements/divider/definition.d.ts +10 -0
- package/dist/elements/divider/template.d.ts +2 -0
- package/dist/elements/icon/definition.d.ts +18 -0
- package/dist/elements/icon/template.d.ts +2 -0
- package/dist/{schema/PImage/pImage.definition.d.ts → elements/image/definition.d.ts} +8 -8
- package/dist/elements/image/template.d.ts +2 -0
- package/dist/elements/list/definition.d.ts +11 -0
- package/dist/elements/list/template.d.ts +2 -0
- package/dist/elements/page/definition.d.ts +22 -0
- package/dist/elements/page/template.d.ts +2 -0
- package/dist/elements/radio/definition.d.ts +13 -0
- package/dist/elements/radio/template.d.ts +2 -0
- package/dist/elements/rich-text/definition.d.ts +8 -0
- package/dist/elements/rich-text/template.d.ts +2 -0
- package/dist/elements/section/definition.d.ts +39 -0
- package/dist/elements/section/template.d.ts +2 -0
- package/dist/elements/select/definition.d.ts +13 -0
- package/dist/elements/select/template.d.ts +2 -0
- package/dist/{schema/PTable/pTable.definition.d.ts → elements/table/definition.d.ts} +2 -2
- package/dist/elements/table/template.d.ts +2 -0
- package/dist/{schema/PText/pText.definition.d.ts → elements/text/definition.d.ts} +9 -9
- package/dist/elements/text/template.d.ts +2 -0
- package/dist/elements/text-area/definition.d.ts +10 -0
- package/dist/elements/text-area/template.d.ts +2 -0
- package/dist/elements/text-field/definition.d.ts +10 -0
- package/dist/elements/text-field/template.d.ts +2 -0
- package/dist/elements/video/definition.d.ts +10 -0
- package/dist/elements/video/template.d.ts +2 -0
- package/dist/manifest.json +2 -2
- package/dist/plmt-elements.css +2 -1
- package/dist/render/styleToClasses.d.ts +35 -0
- package/dist/render/styleTokens.d.ts +57 -0
- package/dist/render/types.d.ts +6 -0
- package/dist/schema/Fields/BackgroundField/backgroundValue.d.ts +4 -3
- package/dist/schema/backgroundStyleDefinitions.d.ts +1 -6
- package/dist/schema/elementRegistry.d.ts +14 -14
- package/dist/schema/elementStyleDefinitions.d.ts +1 -1
- package/dist/schema/style/elementStyle.d.ts +2 -2
- package/dist/schema/style/page-styles.d.ts +2 -2
- package/dist/schema/styleTokensSchema.d.ts +274 -0
- package/dist/styleToClasses-CZSWp6Ez.js +683 -0
- package/dist/templates/elementSpec.d.ts +2 -7
- package/dist/templates/helpers.d.ts +9 -1
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +252 -172
- package/package.json +3 -1
- package/dist/schema/PButton/pButton.definition.d.ts +0 -38
- package/dist/schema/PCheckbox/pCheckbox.definition.d.ts +0 -10
- package/dist/schema/PContainer/pContainer.definition.d.ts +0 -39
- package/dist/schema/PDivider/pDivider.definition.d.ts +0 -10
- package/dist/schema/PIcon/pIcon.definition.d.ts +0 -18
- package/dist/schema/PList/pList.definition.d.ts +0 -11
- package/dist/schema/PPage/pPage.definition.d.ts +0 -22
- package/dist/schema/PRadio/pRadio.definition.d.ts +0 -13
- package/dist/schema/PRichText/pRichText.definition.d.ts +0 -8
- package/dist/schema/PSection/pSection.definition.d.ts +0 -39
- package/dist/schema/PSelect/pSelect.definition.d.ts +0 -13
- package/dist/schema/PTextArea/pTextArea.definition.d.ts +0 -10
- package/dist/schema/PTextField/pTextField.definition.d.ts +0 -10
- package/dist/schema/PVideo/pVideo.definition.d.ts +0 -10
- /package/dist/{schema/PRichText → elements/rich-text}/richTextMarks.d.ts +0 -0
- /package/dist/{schema/PRichText → elements/rich-text}/richTextOptions.d.ts +0 -0
package/dist/templates.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type { ElementAttribute, CssVariables, ElementSpec, ElementSpecOptions, }
|
|
|
6
6
|
export { escapeHtml, sanitizeRichTextHtml, renderHtml } from './render/renderHtml';
|
|
7
7
|
export { toDom } from './render/toDom';
|
|
8
8
|
export { styleToCssVariables } from './render/styleToVars';
|
|
9
|
+
export { styleToClasses, styleObjectToClasses, unresolvedStyleForVars, pageTokensToVarValues, type DeviceStyleProps, } from './render/styleToClasses';
|
|
10
|
+
export { SPACING_TOKENS, TEXT_SIZE_TOKENS, COLOR_NAMES, OPACITY_STEPS, toSpacingToken, toTextSizeToken, toPaletteColor, isPaletteColor, type SpacingToken, type TextSizeToken, type ColorName, type PaletteColor, type StyleColor, } from './render/styleTokens';
|
|
9
11
|
export { tags, type ShortcodeTag } from './render/tags';
|
|
10
12
|
export { elementSpec, toElementTree, type ShortcodeNode, } from './templates/elementSpec';
|
|
11
|
-
export { spec, linked, hostAttrs, nodeId, cssPrefix } from './templates/helpers';
|
|
13
|
+
export { spec, linked, hostAttrs, withStyle, pageStyleVars, nodeId, cssPrefix } from './templates/helpers';
|
package/dist/templates.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { _ as e, c as t, d as n, g as r, h as i, i as a, m as o, n as s, o as ee, p as c, r as l, t as u, u as d } from "./styleToClasses-CZSWp6Ez.js";
|
|
1
2
|
// src/render/renderHtml.ts
|
|
2
|
-
var
|
|
3
|
+
var f = /* @__PURE__ */ new Set([
|
|
3
4
|
"img",
|
|
4
5
|
"input",
|
|
5
6
|
"hr",
|
|
@@ -7,38 +8,41 @@ var e = /* @__PURE__ */ new Set([
|
|
|
7
8
|
"meta",
|
|
8
9
|
"link"
|
|
9
10
|
]);
|
|
10
|
-
function
|
|
11
|
+
function p(e) {
|
|
11
12
|
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function m(e) {
|
|
14
15
|
return e.replaceAll(/<(script|style|iframe|object|embed)\b[^>]*>[\s\S]*?<\/\1\s*>/gi, "").replaceAll(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replaceAll(/\s+(href|src)\s*=\s*(["'])\s*javascript:[\s\S]*?\2/gi, "");
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
if (typeof
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
return
|
|
17
|
+
function h(e) {
|
|
18
|
+
if (typeof e == "string") return p(e);
|
|
19
|
+
let t = Object.entries(e.attrs).flatMap(([e, t]) => t === void 0 || t === !1 ? [] : t === !0 ? [e] : [`${e}="${p(t)}"`]), n = Object.entries(e.styleVars).flatMap(([e, t]) => t === void 0 ? [] : [`${e}:${t}`]).join(";");
|
|
20
|
+
n && t.push(`style="${p(n)}"`);
|
|
21
|
+
let r = `<${e.tag}${t.length ? ` ${t.join(" ")}` : ""}>`;
|
|
22
|
+
return f.has(e.tag) ? `${r.slice(0, -1)}>` : `${r}${Array.isArray(e.children) ? e.children.map(h).join("") : e.children?.html ?? ""}</${e.tag}>`;
|
|
22
23
|
}
|
|
23
24
|
// src/render/toDom.ts
|
|
24
|
-
function
|
|
25
|
+
function g(e) {
|
|
25
26
|
if (typeof e == "string") return document.createTextNode(e);
|
|
26
27
|
let t = document.createElement(e.tag);
|
|
27
28
|
for (let [n, r] of Object.entries(e.attrs)) r !== void 0 && r !== !1 && (r === !0 ? t.setAttribute(n, "") : t.setAttribute(n, String(r)));
|
|
28
29
|
let n = Object.entries(e.styleVars).flatMap(([e, t]) => t === void 0 ? [] : [`${e}:${t}`]).join(";");
|
|
29
|
-
if (n && t.setAttribute("style", n), Array.isArray(e.children)) for (let n of e.children) t.append(
|
|
30
|
+
if (n && t.setAttribute("style", n), Array.isArray(e.children)) for (let n of e.children) t.append(g(n));
|
|
30
31
|
else e.children?.html && (t.innerHTML = e.children.html);
|
|
31
32
|
return t;
|
|
32
33
|
}
|
|
33
34
|
// src/render/styleToVars.ts
|
|
34
|
-
var
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
if (e
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
var _ = /^#[0-9A-Fa-f]{6}$/;
|
|
36
|
+
function v(e) {
|
|
37
|
+
if (c(e)) return o(e);
|
|
38
|
+
if (!e || typeof e != "object" || !("hex" in e) || !("opacity" in e)) return;
|
|
39
|
+
let { hex: t, opacity: n } = e;
|
|
40
|
+
if (!_.test(t) || !Number.isFinite(n)) return;
|
|
41
|
+
if (n === 100) return t.toUpperCase();
|
|
42
|
+
let r = Math.min(100, Math.max(0, n)) / 100;
|
|
43
|
+
return `rgba(${Number.parseInt(t.slice(1, 3), 16)}, ${Number.parseInt(t.slice(3, 5), 16)}, ${Number.parseInt(t.slice(5, 7), 16)}, ${r})`;
|
|
44
|
+
}
|
|
45
|
+
var y = {
|
|
42
46
|
textFont: "font-family",
|
|
43
47
|
textColor: "color",
|
|
44
48
|
textSize: "font-size",
|
|
@@ -50,22 +54,22 @@ var s = {
|
|
|
50
54
|
borderRadiusBottomLeft: "border-bottom-left-radius",
|
|
51
55
|
borderRadiusBottomRight: "border-bottom-right-radius",
|
|
52
56
|
gridColumns: "grid-template-columns"
|
|
53
|
-
},
|
|
54
|
-
function
|
|
55
|
-
return t && typeof t == "object" && "hex" in t && "opacity" in t ?
|
|
57
|
+
}, b = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
58
|
+
function x(e, t) {
|
|
59
|
+
return t && typeof t == "object" && ("hex" in t || "name" in t) && "opacity" in t ? v(t) : e === "backgroundGradient" && t && typeof t == "object" && "kind" in t && "value" in t ? `${String(t.kind)}-gradient(${String(t.value)})` : e === "gridColumns" && typeof t == "number" ? `repeat(${t}, minmax(0, 1fr))` : e === "textSize" && typeof t == "number" ? Number.isFinite(t) && t > 0 ? `${t}px` : void 0 : e === "textSize" && typeof t == "string" && t.endsWith("rem") ? t : [
|
|
56
60
|
"string",
|
|
57
61
|
"number",
|
|
58
62
|
"boolean"
|
|
59
63
|
].includes(typeof t) ? String(t) : void 0;
|
|
60
64
|
}
|
|
61
|
-
function
|
|
65
|
+
function S(e, t) {
|
|
62
66
|
return e ? Object.fromEntries(Object.entries(e).flatMap(([e, n]) => {
|
|
63
|
-
let r =
|
|
64
|
-
return r === void 0 ? [] : [[`--palmyit-${t}-${
|
|
67
|
+
let r = x(e, n);
|
|
68
|
+
return r === void 0 ? [] : [[`--palmyit-${t}-${y[e] ?? b(e)}`, r]];
|
|
65
69
|
})) : {};
|
|
66
70
|
}
|
|
67
71
|
// src/render/tags.ts
|
|
68
|
-
var
|
|
72
|
+
var C = {
|
|
69
73
|
PPage: "plmt-page",
|
|
70
74
|
PSection: "plmt-section",
|
|
71
75
|
PContainer: "plmt-container",
|
|
@@ -85,7 +89,7 @@ var d = {
|
|
|
85
89
|
PSelect: "plmt-select"
|
|
86
90
|
};
|
|
87
91
|
// src/templates/helpers.ts
|
|
88
|
-
function
|
|
92
|
+
function w(e, t = {}, n, r = {}) {
|
|
89
93
|
return n === void 0 ? {
|
|
90
94
|
tag: e,
|
|
91
95
|
attrs: t,
|
|
@@ -97,173 +101,249 @@ function f(e, t = {}, n, r = {}) {
|
|
|
97
101
|
children: n
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
|
-
function
|
|
104
|
+
function T(e, t) {
|
|
101
105
|
let n = String(e.href ?? "");
|
|
102
106
|
if (!n) return t;
|
|
103
107
|
let r = String(e.target ?? "_self");
|
|
104
|
-
return [
|
|
108
|
+
return [w("a", {
|
|
105
109
|
href: n,
|
|
106
110
|
target: r,
|
|
107
111
|
rel: r === "_blank" ? "noopener noreferrer" : void 0,
|
|
108
112
|
"aria-description": String(e.description ?? "") || void 0
|
|
109
113
|
}, t)];
|
|
110
114
|
}
|
|
111
|
-
function
|
|
115
|
+
function E(e) {
|
|
112
116
|
return e.slice(1).replaceAll(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
113
117
|
}
|
|
114
|
-
function
|
|
118
|
+
function D(e) {
|
|
115
119
|
return String(e.id ?? e.pageId ?? "");
|
|
116
120
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
function O(e) {
|
|
122
|
+
return {
|
|
123
|
+
style: e.style,
|
|
124
|
+
tabletStyle: e.tabletStyle,
|
|
125
|
+
mobileStyle: e.mobileStyle,
|
|
126
|
+
tabletLandscapeStyle: e.tabletLandscapeStyle,
|
|
127
|
+
mobileLandscapeStyle: e.mobileLandscapeStyle
|
|
121
128
|
};
|
|
122
|
-
return typeof n.layout == "string" && (r["data-layout"] = n.layout), typeof n.backgroundType == "string" && (r["data-background"] = n.backgroundType), r;
|
|
123
129
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"PContainer"
|
|
129
|
-
]);
|
|
130
|
-
function v(e, t = "") {
|
|
131
|
-
let n = {
|
|
132
|
-
class: d.PIcon,
|
|
133
|
-
"data-name": e || void 0
|
|
130
|
+
function k(e, t, n) {
|
|
131
|
+
let r = e.style ?? {}, i = {
|
|
132
|
+
class: [t, ...n ? l(n, O(e)) : []].filter(Boolean).join(" "),
|
|
133
|
+
"data-plmt-id": D(e)
|
|
134
134
|
};
|
|
135
|
-
return
|
|
135
|
+
return typeof r.layout == "string" && (i["data-layout"] = r.layout), typeof r.backgroundType == "string" && (i["data-background"] = r.backgroundType), i;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function A(e, t) {
|
|
138
138
|
return {
|
|
139
|
-
attrs:
|
|
140
|
-
vars:
|
|
139
|
+
attrs: k(t, C[e], e),
|
|
140
|
+
vars: S(a(e, t.style), E(e))
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return
|
|
185
|
-
...
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let e = f("img", {
|
|
192
|
-
class: String(r.href ?? "") ? void 0 : d.PImage,
|
|
193
|
-
src: String(r.src),
|
|
194
|
-
alt: String(r.alt ?? ""),
|
|
195
|
-
...String(r.href ?? "") ? {} : {
|
|
196
|
-
"data-plmt-id": i.attrs["data-plmt-id"],
|
|
197
|
-
"data-background": i.attrs["data-background"]
|
|
198
|
-
}
|
|
199
|
-
}, void 0, String(r.href ?? "") ? {} : i.vars), t = String(r.href ?? "");
|
|
200
|
-
if (!t) return e;
|
|
201
|
-
let n = String(r.target ?? "_self");
|
|
202
|
-
return f("a", {
|
|
203
|
-
class: d.PImage,
|
|
204
|
-
"data-plmt-id": i.attrs["data-plmt-id"],
|
|
205
|
-
"data-background": i.attrs["data-background"],
|
|
206
|
-
href: t,
|
|
207
|
-
target: n,
|
|
208
|
-
rel: n === "_blank" ? "noopener noreferrer" : void 0,
|
|
209
|
-
"aria-description": String(r.description ?? "") || void 0
|
|
210
|
-
}, [f("img", {
|
|
211
|
-
src: String(r.src),
|
|
212
|
-
alt: String(r.alt ?? "")
|
|
213
|
-
})], i.vars);
|
|
143
|
+
function j(e) {
|
|
144
|
+
return S(u({
|
|
145
|
+
backgroundColor: e.backgroundColor,
|
|
146
|
+
textColor: e.textColor,
|
|
147
|
+
textSize: e.textSize
|
|
148
|
+
}), "page");
|
|
149
|
+
}
|
|
150
|
+
// src/elements/page/template.ts
|
|
151
|
+
function M(e, t) {
|
|
152
|
+
let n = e.props;
|
|
153
|
+
return w("main", {
|
|
154
|
+
class: C.PPage,
|
|
155
|
+
"data-plmt-id": String(n.pageId),
|
|
156
|
+
title: String(n.title ?? ""),
|
|
157
|
+
"data-url": String(n.url ?? "")
|
|
158
|
+
}, t?.children ?? [], j(n));
|
|
159
|
+
}
|
|
160
|
+
// src/elements/section/template.ts
|
|
161
|
+
function N(e, t) {
|
|
162
|
+
let n = A(e.type, e.props);
|
|
163
|
+
return w("section", n.attrs, t?.children ?? [], n.vars);
|
|
164
|
+
}
|
|
165
|
+
// src/elements/container/template.ts
|
|
166
|
+
function P(e, t) {
|
|
167
|
+
let n = A(e.type, e.props);
|
|
168
|
+
return w("div", n.attrs, t?.children ?? [], n.vars);
|
|
169
|
+
}
|
|
170
|
+
// src/elements/button/template.ts
|
|
171
|
+
function F(e, t = "") {
|
|
172
|
+
let n = {
|
|
173
|
+
class: C.PIcon,
|
|
174
|
+
"data-name": e || void 0
|
|
175
|
+
};
|
|
176
|
+
return t.trim() ? (n.role = "img", n["aria-label"] = t) : n["aria-hidden"] = "true", w("span", n);
|
|
177
|
+
}
|
|
178
|
+
function I(e, t) {
|
|
179
|
+
let n = e.props, r = A(e.type, n), i = [];
|
|
180
|
+
n.startIcon && i.push(F(String(n.startIcon))), i.push(String(n.name ?? "")), n.endIcon && i.push(F(String(n.endIcon)));
|
|
181
|
+
let a = String(n.href ?? "");
|
|
182
|
+
if (a) {
|
|
183
|
+
let e = String(n.target ?? "_self");
|
|
184
|
+
return w("a", {
|
|
185
|
+
...r.attrs,
|
|
186
|
+
href: a,
|
|
187
|
+
target: e,
|
|
188
|
+
rel: e === "_blank" ? "noopener noreferrer" : void 0,
|
|
189
|
+
"aria-description": String(n.description ?? "") || void 0
|
|
190
|
+
}, i, r.vars);
|
|
214
191
|
}
|
|
215
|
-
|
|
216
|
-
...
|
|
217
|
-
|
|
218
|
-
|
|
192
|
+
return w("button", {
|
|
193
|
+
...r.attrs,
|
|
194
|
+
type: "button"
|
|
195
|
+
}, i, r.vars);
|
|
196
|
+
}
|
|
197
|
+
// src/elements/text/template.ts
|
|
198
|
+
function L(e, t) {
|
|
199
|
+
let n = e.props, r = A(e.type, n);
|
|
200
|
+
return w("p", r.attrs, T(n, [String(n.text ?? "")]), r.vars);
|
|
201
|
+
}
|
|
202
|
+
// src/elements/rich-text/template.ts
|
|
203
|
+
function R(e, t) {
|
|
204
|
+
let n = e.props, r = A(e.type, n);
|
|
205
|
+
return w("div", r.attrs, { html: m(String(n.text ?? "")) }, r.vars);
|
|
206
|
+
}
|
|
207
|
+
// src/elements/icon/template.ts
|
|
208
|
+
function z(e, t) {
|
|
209
|
+
let n = e.props, r = A(e.type, n), i = String(n.label ?? ""), a = String(n.icon ?? ""), o = i.trim() ? {
|
|
210
|
+
role: "img",
|
|
211
|
+
"aria-label": i
|
|
212
|
+
} : { "aria-hidden": "true" }, s = T(n, []);
|
|
213
|
+
return w("span", {
|
|
214
|
+
...r.attrs,
|
|
215
|
+
"data-name": a || void 0,
|
|
216
|
+
...o
|
|
217
|
+
}, s.length ? s : void 0, r.vars);
|
|
218
|
+
}
|
|
219
|
+
// src/elements/image/template.ts
|
|
220
|
+
function B(e, t) {
|
|
221
|
+
let n = e.props, r = A(e.type, n), i = w("img", {
|
|
222
|
+
class: String(n.href ?? "") ? void 0 : C.PImage,
|
|
223
|
+
src: String(n.src),
|
|
224
|
+
alt: String(n.alt ?? ""),
|
|
225
|
+
...String(n.href ?? "") ? {} : {
|
|
226
|
+
"data-plmt-id": r.attrs["data-plmt-id"],
|
|
227
|
+
"data-background": r.attrs["data-background"]
|
|
228
|
+
}
|
|
229
|
+
}, void 0, String(n.href ?? "") ? {} : r.vars), a = String(n.href ?? "");
|
|
230
|
+
if (!a) return i;
|
|
231
|
+
let o = String(n.target ?? "_self");
|
|
232
|
+
return w("a", {
|
|
233
|
+
class: C.PImage,
|
|
234
|
+
"data-plmt-id": r.attrs["data-plmt-id"],
|
|
235
|
+
"data-background": r.attrs["data-background"],
|
|
236
|
+
href: a,
|
|
237
|
+
target: o,
|
|
238
|
+
rel: o === "_blank" ? "noopener noreferrer" : void 0,
|
|
239
|
+
"aria-description": String(n.description ?? "") || void 0
|
|
240
|
+
}, [w("img", {
|
|
241
|
+
src: String(n.src),
|
|
242
|
+
alt: String(n.alt ?? "")
|
|
243
|
+
})], r.vars);
|
|
244
|
+
}
|
|
245
|
+
// src/elements/video/template.ts
|
|
246
|
+
function V(e, t) {
|
|
247
|
+
let n = e.props;
|
|
248
|
+
if (!String(n.src ?? "")) return null;
|
|
249
|
+
let r = A(e.type, n);
|
|
250
|
+
return w("video", {
|
|
251
|
+
...r.attrs,
|
|
252
|
+
src: String(n.src),
|
|
253
|
+
title: String(n.title ?? ""),
|
|
219
254
|
controls: !0
|
|
220
|
-
}, void 0,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
})],
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
})],
|
|
244
|
-
|
|
255
|
+
}, void 0, r.vars);
|
|
256
|
+
}
|
|
257
|
+
// src/elements/list/template.ts
|
|
258
|
+
function H(e, t) {
|
|
259
|
+
let n = e.props, r = A(e.type, n), i = n.items.map((e) => w("li", {}, [e.text]));
|
|
260
|
+
return w("ul", r.attrs, i, r.vars);
|
|
261
|
+
}
|
|
262
|
+
// src/elements/divider/template.ts
|
|
263
|
+
function U(e, t) {
|
|
264
|
+
let n = e.props, r = A(e.type, n);
|
|
265
|
+
return w("hr", {
|
|
266
|
+
...r.attrs,
|
|
267
|
+
"data-size": String(n.size ?? "4")
|
|
268
|
+
}, void 0, r.vars);
|
|
269
|
+
}
|
|
270
|
+
// src/elements/table/template.ts
|
|
271
|
+
function W(e, t) {
|
|
272
|
+
let n = e.props, r = A(e.type, n), i = n.headers.map((e) => w("th", {}, [e.text])), a = n.rows.map((e) => w("tr", {}, e.cells.map((e) => w("td", {}, [e]))));
|
|
273
|
+
return w("div", r.attrs, [w("table", {}, [w("thead", {}, [w("tr", {}, i)]), w("tbody", {}, a)])], r.vars);
|
|
274
|
+
}
|
|
275
|
+
// src/elements/text-field/template.ts
|
|
276
|
+
function G(e, t) {
|
|
277
|
+
let n = e.props, r = A(e.type, n), i = D(n);
|
|
278
|
+
return w("div", r.attrs, [w("label", { for: i }, [String(n.label)]), w("input", {
|
|
279
|
+
id: i,
|
|
280
|
+
name: i,
|
|
281
|
+
placeholder: String(n.placeholder ?? "")
|
|
282
|
+
})], r.vars);
|
|
283
|
+
}
|
|
284
|
+
// src/elements/text-area/template.ts
|
|
285
|
+
function K(e, t) {
|
|
286
|
+
let n = e.props, r = A(e.type, n), i = D(n);
|
|
287
|
+
return w("div", r.attrs, [w("label", { for: i }, [String(n.label)]), w("textarea", {
|
|
288
|
+
id: i,
|
|
289
|
+
name: i,
|
|
290
|
+
placeholder: String(n.placeholder ?? "")
|
|
291
|
+
})], r.vars);
|
|
292
|
+
}
|
|
293
|
+
// src/elements/checkbox/template.ts
|
|
294
|
+
function q(e, t) {
|
|
295
|
+
let n = e.props, r = A(e.type, n), i = D(n);
|
|
296
|
+
return w("div", r.attrs, [w("label", {}, [w("input", {
|
|
245
297
|
type: "checkbox",
|
|
246
|
-
name:
|
|
247
|
-
checked:
|
|
248
|
-
}), String(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
298
|
+
name: i,
|
|
299
|
+
checked: n.checked === !0 || void 0
|
|
300
|
+
}), String(n.label)])], r.vars);
|
|
301
|
+
}
|
|
302
|
+
// src/elements/radio/template.ts
|
|
303
|
+
function J(e, t) {
|
|
304
|
+
let n = e.props, r = A(e.type, n), i = D(n), a = n.options.map((e) => w("label", {}, [w("input", {
|
|
305
|
+
type: "radio",
|
|
306
|
+
name: i,
|
|
307
|
+
value: e.text
|
|
308
|
+
}), e.text]));
|
|
309
|
+
return w("fieldset", r.attrs, [w("legend", {}, [String(n.legend)]), ...a], r.vars);
|
|
310
|
+
}
|
|
311
|
+
// src/elements/select/template.ts
|
|
312
|
+
function Y(e, t) {
|
|
313
|
+
let n = e.props, r = A(e.type, n), i = D(n), a = n.options.map((e) => w("option", { value: e.text }, [e.text]));
|
|
314
|
+
return w("div", r.attrs, [w("label", { for: i }, [String(n.label)]), w("select", {
|
|
315
|
+
id: i,
|
|
316
|
+
name: i
|
|
317
|
+
}, a)], r.vars);
|
|
318
|
+
}
|
|
319
|
+
// src/templates/elementSpec.ts
|
|
320
|
+
var X = /* @__PURE__ */ new Set([
|
|
321
|
+
"PPage",
|
|
322
|
+
"PSection",
|
|
323
|
+
"PContainer"
|
|
324
|
+
]), Z = {
|
|
325
|
+
PPage: M,
|
|
326
|
+
PSection: N,
|
|
327
|
+
PContainer: P,
|
|
328
|
+
PButton: I,
|
|
329
|
+
PText: L,
|
|
330
|
+
PRichText: R,
|
|
331
|
+
PImage: B,
|
|
332
|
+
PVideo: V,
|
|
333
|
+
PList: H,
|
|
334
|
+
PIcon: z,
|
|
335
|
+
PDivider: U,
|
|
336
|
+
PTable: W,
|
|
337
|
+
PTextField: G,
|
|
338
|
+
PTextArea: K,
|
|
339
|
+
PCheckbox: q,
|
|
340
|
+
PRadio: J,
|
|
341
|
+
PSelect: Y
|
|
342
|
+
};
|
|
343
|
+
function Q(e, t) {
|
|
344
|
+
return Z[e.type](e, t);
|
|
265
345
|
}
|
|
266
|
-
function
|
|
267
|
-
return
|
|
346
|
+
function $(e) {
|
|
347
|
+
return X.has(e.type) ? Q(e, { children: (e.children ?? []).map($).filter(Boolean) }) : Q(e);
|
|
268
348
|
}
|
|
269
|
-
export {
|
|
349
|
+
export { ee as COLOR_NAMES, t as OPACITY_STEPS, d as SPACING_TOKENS, n as TEXT_SIZE_TOKENS, E as cssPrefix, Q as elementSpec, p as escapeHtml, k as hostAttrs, c as isPaletteColor, T as linked, D as nodeId, j as pageStyleVars, u as pageTokensToVarValues, h as renderHtml, m as sanitizeRichTextHtml, w as spec, s as styleObjectToClasses, l as styleToClasses, S as styleToCssVariables, C as tags, g as toDom, $ as toElementTree, i as toPaletteColor, r as toSpacingToken, e as toTextSizeToken, a as unresolvedStyleForVars, A as withStyle };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palmyit/elements",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Palmyit element definitions, semantic HTML templates, and CSS for builder and published sites",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -56,8 +56,10 @@
|
|
|
56
56
|
"@storybook/addon-a11y": "^10.6.0",
|
|
57
57
|
"@storybook/addon-docs": "^10.6.0",
|
|
58
58
|
"@storybook/html-vite": "^10.6.0",
|
|
59
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
59
60
|
"happy-dom": "^20.0.10",
|
|
60
61
|
"storybook": "^10.6.0",
|
|
62
|
+
"tailwindcss": "^4.3.3",
|
|
61
63
|
"typescript": "~6.0.2",
|
|
62
64
|
"vite": "^8.3.0",
|
|
63
65
|
"vite-plugin-dts": "^5.0.2",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LinkSettings } from '../linkSettings';
|
|
2
|
-
import { LengthKey } from '../elementStyleDefinitions';
|
|
3
|
-
import { BorderLineStyle } from '../style/elementStyle';
|
|
4
|
-
import { BackgroundStyle } from '../Fields/BackgroundField/backgroundValue';
|
|
5
|
-
import { ColorValue } from '../Fields/ColorField/color-value';
|
|
6
|
-
/** Every key stays unset until the user edits it, so the button keeps its theme look. */
|
|
7
|
-
export type ButtonStyle = Partial<BackgroundStyle & Record<LengthKey, string> & {
|
|
8
|
-
borderWidth: string;
|
|
9
|
-
borderStyle: BorderLineStyle;
|
|
10
|
-
borderColor: ColorValue;
|
|
11
|
-
textColor: ColorValue;
|
|
12
|
-
textFont: string;
|
|
13
|
-
textSize: string;
|
|
14
|
-
iconGap: string;
|
|
15
|
-
}>;
|
|
16
|
-
export type PButtonDocumentProps = LinkSettings & {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
startIcon: string;
|
|
20
|
-
endIcon: string;
|
|
21
|
-
style: ButtonStyle;
|
|
22
|
-
};
|
|
23
|
-
export declare const defaultButtonProps: {
|
|
24
|
-
style: ButtonStyle;
|
|
25
|
-
href: string;
|
|
26
|
-
target: import('../linkSettings').LinkTarget;
|
|
27
|
-
description: string;
|
|
28
|
-
name: string;
|
|
29
|
-
startIcon: string;
|
|
30
|
-
endIcon: string;
|
|
31
|
-
};
|
|
32
|
-
export declare const pButtonDefinition: import('../elementConfiguration').ElementConfiguration<LinkSettings & {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
startIcon: string;
|
|
36
|
-
endIcon: string;
|
|
37
|
-
style: ButtonStyle;
|
|
38
|
-
} & Partial<import('../deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type PCheckboxDocumentProps = {
|
|
2
|
-
id: string;
|
|
3
|
-
label: string;
|
|
4
|
-
checked: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const defaultCheckboxProps: {
|
|
7
|
-
label: string;
|
|
8
|
-
checked: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const pCheckboxDefinition: import('../elementConfiguration').ElementConfiguration<PCheckboxDocumentProps & Partial<import('../deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export declare const defaultContainerStyle: {
|
|
2
|
-
layout: import('../style/elementStyle').ElementLayout;
|
|
3
|
-
gridColumns?: import('../style/elementStyle').GridColumnCount;
|
|
4
|
-
flexDirection: import('../style/elementStyle').FlexDirection;
|
|
5
|
-
flexWrap: import('../style/elementStyle').FlexWrap;
|
|
6
|
-
justifyContent: import('../style/elementStyle').FlexJustifyContent;
|
|
7
|
-
alignItems: import('../style/elementStyle').FlexAlignItems;
|
|
8
|
-
alignContent: import('../style/elementStyle').FlexAlignContent;
|
|
9
|
-
rowGap: string;
|
|
10
|
-
columnGap: string;
|
|
11
|
-
overflow: import('../style/elementStyle').ElementOverflow;
|
|
12
|
-
overflowVertical: boolean;
|
|
13
|
-
overflowHorizontal: boolean;
|
|
14
|
-
width: string;
|
|
15
|
-
height: string;
|
|
16
|
-
minWidth: string;
|
|
17
|
-
minHeight: string;
|
|
18
|
-
maxWidth: string;
|
|
19
|
-
maxHeight: string;
|
|
20
|
-
paddingTop: string;
|
|
21
|
-
paddingBottom: string;
|
|
22
|
-
paddingLeft: string;
|
|
23
|
-
paddingRight: string;
|
|
24
|
-
marginTop: string;
|
|
25
|
-
marginBottom: string;
|
|
26
|
-
marginLeft: string;
|
|
27
|
-
marginRight: string;
|
|
28
|
-
borderRadiusTopLeft: string;
|
|
29
|
-
borderRadiusTopRight: string;
|
|
30
|
-
borderRadiusBottomRight: string;
|
|
31
|
-
borderRadiusBottomLeft: string;
|
|
32
|
-
borderWidth: string;
|
|
33
|
-
borderStyle: import('../style/elementStyle').BorderLineStyle;
|
|
34
|
-
borderColor: import('../../definitions').ColorValue;
|
|
35
|
-
backgroundType: import('../Fields/BackgroundField/backgroundValue').BackgroundType;
|
|
36
|
-
backgroundColor: import('../../definitions').ColorValue;
|
|
37
|
-
backgroundGradient: import('../Fields/BackgroundField/backgroundValue').GradientValue;
|
|
38
|
-
};
|
|
39
|
-
export declare const pContainerDefinition: import('../elementConfiguration').ElementConfiguration<import('../layoutElementConfiguration').LayoutElementProps & Partial<import('../deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const dividerSizes: readonly ["1", "2", "3", "4"];
|
|
2
|
-
export type DividerSize = (typeof dividerSizes)[number];
|
|
3
|
-
export type PDividerDocumentProps = {
|
|
4
|
-
id: string;
|
|
5
|
-
size: DividerSize;
|
|
6
|
-
};
|
|
7
|
-
export declare const defaultDividerProps: {
|
|
8
|
-
size: DividerSize;
|
|
9
|
-
};
|
|
10
|
-
export declare const pDividerDefinition: import('../elementConfiguration').ElementConfiguration<PDividerDocumentProps & Partial<import('../deviceVisibility').DeviceVisibility> & Partial<Record<"tabletStyle" | "mobileStyle" | "tabletLandscapeStyle" | "mobileLandscapeStyle", Partial<Record<string, unknown>>>>>;
|