@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.
Files changed (70) hide show
  1. package/dist/definitions.d.ts +23 -20
  2. package/dist/definitions.js +692 -686
  3. package/dist/elements/button/definition.d.ts +38 -0
  4. package/dist/elements/button/template.d.ts +2 -0
  5. package/dist/elements/checkbox/definition.d.ts +10 -0
  6. package/dist/elements/checkbox/template.d.ts +2 -0
  7. package/dist/elements/container/definition.d.ts +39 -0
  8. package/dist/elements/container/template.d.ts +2 -0
  9. package/dist/elements/divider/definition.d.ts +10 -0
  10. package/dist/elements/divider/template.d.ts +2 -0
  11. package/dist/elements/icon/definition.d.ts +18 -0
  12. package/dist/elements/icon/template.d.ts +2 -0
  13. package/dist/{schema/PImage/pImage.definition.d.ts → elements/image/definition.d.ts} +8 -8
  14. package/dist/elements/image/template.d.ts +2 -0
  15. package/dist/elements/list/definition.d.ts +11 -0
  16. package/dist/elements/list/template.d.ts +2 -0
  17. package/dist/elements/page/definition.d.ts +22 -0
  18. package/dist/elements/page/template.d.ts +2 -0
  19. package/dist/elements/radio/definition.d.ts +13 -0
  20. package/dist/elements/radio/template.d.ts +2 -0
  21. package/dist/elements/rich-text/definition.d.ts +8 -0
  22. package/dist/elements/rich-text/template.d.ts +2 -0
  23. package/dist/elements/section/definition.d.ts +39 -0
  24. package/dist/elements/section/template.d.ts +2 -0
  25. package/dist/elements/select/definition.d.ts +13 -0
  26. package/dist/elements/select/template.d.ts +2 -0
  27. package/dist/{schema/PTable/pTable.definition.d.ts → elements/table/definition.d.ts} +2 -2
  28. package/dist/elements/table/template.d.ts +2 -0
  29. package/dist/{schema/PText/pText.definition.d.ts → elements/text/definition.d.ts} +9 -9
  30. package/dist/elements/text/template.d.ts +2 -0
  31. package/dist/elements/text-area/definition.d.ts +10 -0
  32. package/dist/elements/text-area/template.d.ts +2 -0
  33. package/dist/elements/text-field/definition.d.ts +10 -0
  34. package/dist/elements/text-field/template.d.ts +2 -0
  35. package/dist/elements/video/definition.d.ts +10 -0
  36. package/dist/elements/video/template.d.ts +2 -0
  37. package/dist/manifest.json +2 -2
  38. package/dist/plmt-elements.css +2 -1
  39. package/dist/render/styleToClasses.d.ts +35 -0
  40. package/dist/render/styleTokens.d.ts +57 -0
  41. package/dist/render/types.d.ts +6 -0
  42. package/dist/schema/Fields/BackgroundField/backgroundValue.d.ts +4 -3
  43. package/dist/schema/backgroundStyleDefinitions.d.ts +1 -6
  44. package/dist/schema/elementRegistry.d.ts +14 -14
  45. package/dist/schema/elementStyleDefinitions.d.ts +1 -1
  46. package/dist/schema/style/elementStyle.d.ts +2 -2
  47. package/dist/schema/style/page-styles.d.ts +2 -2
  48. package/dist/schema/styleTokensSchema.d.ts +274 -0
  49. package/dist/styleToClasses-CZSWp6Ez.js +683 -0
  50. package/dist/templates/elementSpec.d.ts +2 -7
  51. package/dist/templates/helpers.d.ts +9 -1
  52. package/dist/templates.d.ts +3 -1
  53. package/dist/templates.js +252 -172
  54. package/package.json +3 -1
  55. package/dist/schema/PButton/pButton.definition.d.ts +0 -38
  56. package/dist/schema/PCheckbox/pCheckbox.definition.d.ts +0 -10
  57. package/dist/schema/PContainer/pContainer.definition.d.ts +0 -39
  58. package/dist/schema/PDivider/pDivider.definition.d.ts +0 -10
  59. package/dist/schema/PIcon/pIcon.definition.d.ts +0 -18
  60. package/dist/schema/PList/pList.definition.d.ts +0 -11
  61. package/dist/schema/PPage/pPage.definition.d.ts +0 -22
  62. package/dist/schema/PRadio/pRadio.definition.d.ts +0 -13
  63. package/dist/schema/PRichText/pRichText.definition.d.ts +0 -8
  64. package/dist/schema/PSection/pSection.definition.d.ts +0 -39
  65. package/dist/schema/PSelect/pSelect.definition.d.ts +0 -13
  66. package/dist/schema/PTextArea/pTextArea.definition.d.ts +0 -10
  67. package/dist/schema/PTextField/pTextField.definition.d.ts +0 -10
  68. package/dist/schema/PVideo/pVideo.definition.d.ts +0 -10
  69. /package/dist/{schema/PRichText → elements/rich-text}/richTextMarks.d.ts +0 -0
  70. /package/dist/{schema/PRichText → elements/rich-text}/richTextOptions.d.ts +0 -0
@@ -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 e = /* @__PURE__ */ new Set([
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 t(e) {
11
+ function p(e) {
11
12
  return String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
12
13
  }
13
- function n(e) {
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 r(n) {
17
- if (typeof n == "string") return t(n);
18
- let i = Object.entries(n.attrs).flatMap(([e, n]) => n === void 0 || n === !1 ? [] : n === !0 ? [e] : [`${e}="${t(n)}"`]), a = Object.entries(n.styleVars).flatMap(([e, t]) => t === void 0 ? [] : [`${e}:${t}`]).join(";");
19
- a && i.push(`style="${t(a)}"`);
20
- let o = `<${n.tag}${i.length ? ` ${i.join(" ")}` : ""}>`;
21
- return e.has(n.tag) ? `${o.slice(0, -1)}>` : `${o}${Array.isArray(n.children) ? n.children.map(r).join("") : n.children?.html ?? ""}</${n.tag}>`;
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 i(e) {
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(i(n));
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 a = /^#[0-9A-Fa-f]{6}$/;
35
- function o(e) {
36
- if (!a.test(e.hex) || !Number.isFinite(e.opacity)) return;
37
- if (e.opacity === 100) return e.hex.toUpperCase();
38
- let t = Math.min(100, Math.max(0, e.opacity)) / 100;
39
- return `rgba(${Number.parseInt(e.hex.slice(1, 3), 16)}, ${Number.parseInt(e.hex.slice(3, 5), 16)}, ${Number.parseInt(e.hex.slice(5, 7), 16)}, ${t})`;
40
- }
41
- var s = {
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
- }, c = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
54
- function l(e, t) {
55
- return t && typeof t == "object" && "hex" in t && "opacity" in t ? o(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 : [
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 u(e, t) {
65
+ function S(e, t) {
62
66
  return e ? Object.fromEntries(Object.entries(e).flatMap(([e, n]) => {
63
- let r = l(e, n);
64
- return r === void 0 ? [] : [[`--palmyit-${t}-${s[e] ?? c(e)}`, r]];
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 d = {
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 f(e, t = {}, n, r = {}) {
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 p(e, t) {
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 [f("a", {
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 m(e) {
115
+ function E(e) {
112
116
  return e.slice(1).replaceAll(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
113
117
  }
114
- function h(e) {
118
+ function D(e) {
115
119
  return String(e.id ?? e.pageId ?? "");
116
120
  }
117
- function g(e, t) {
118
- let n = e.style ?? {}, r = {
119
- class: t,
120
- "data-plmt-id": h(e)
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
- // src/templates/elementSpec.ts
125
- var _ = /* @__PURE__ */ new Set([
126
- "PPage",
127
- "PSection",
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 t.trim() ? (n.role = "img", n["aria-label"] = t) : n["aria-hidden"] = "true", f("span", n);
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 y(e, t) {
137
+ function A(e, t) {
138
138
  return {
139
- attrs: g(t, d[e]),
140
- vars: u(t.style, m(e))
139
+ attrs: k(t, C[e], e),
140
+ vars: S(a(e, t.style), E(e))
141
141
  };
142
142
  }
143
- function b(e, t) {
144
- let r = e.props, i = y(e.type, r);
145
- if (e.type === "PVideo" && !String(r.src ?? "")) return null;
146
- if (e.type === "PPage") return f("main", {
147
- class: d.PPage,
148
- "data-plmt-id": String(r.pageId),
149
- title: String(r.title ?? ""),
150
- "data-url": String(r.url ?? "")
151
- }, t?.children ?? [], u({
152
- backgroundColor: r.backgroundColor,
153
- textColor: r.textColor,
154
- textSize: r.textSize
155
- }, "page"));
156
- if (e.type === "PSection") return f("section", i.attrs, t?.children ?? [], i.vars);
157
- if (e.type === "PContainer") return f("div", i.attrs, t?.children ?? [], i.vars);
158
- if (e.type === "PButton") {
159
- let e = [];
160
- r.startIcon && e.push(v(String(r.startIcon))), e.push(String(r.name ?? "")), r.endIcon && e.push(v(String(r.endIcon)));
161
- let t = String(r.href ?? "");
162
- if (t) {
163
- let n = String(r.target ?? "_self");
164
- return f("a", {
165
- ...i.attrs,
166
- href: t,
167
- target: n,
168
- rel: n === "_blank" ? "noopener noreferrer" : void 0,
169
- "aria-description": String(r.description ?? "") || void 0
170
- }, e, i.vars);
171
- }
172
- return f("button", {
173
- ...i.attrs,
174
- type: "button"
175
- }, e, i.vars);
176
- }
177
- if (e.type === "PText") return f("p", i.attrs, p(r, [String(r.text ?? "")]), i.vars);
178
- if (e.type === "PRichText") return f("div", i.attrs, { html: n(String(r.text ?? "")) }, i.vars);
179
- if (e.type === "PIcon") {
180
- let e = String(r.label ?? ""), t = String(r.icon ?? ""), n = e.trim() ? {
181
- role: "img",
182
- "aria-label": e
183
- } : { "aria-hidden": "true" }, a = p(r, []);
184
- return f("span", {
185
- ...i.attrs,
186
- "data-name": t || void 0,
187
- ...n
188
- }, a.length ? a : void 0, i.vars);
189
- }
190
- if (e.type === "PImage") {
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
- if (e.type === "PVideo") return f("video", {
216
- ...i.attrs,
217
- src: String(r.src),
218
- title: String(r.title ?? ""),
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, i.vars);
221
- if (e.type === "PList") {
222
- let e = r.items.map((e) => f("li", {}, [e.text]));
223
- return f("ul", i.attrs, e, i.vars);
224
- }
225
- if (e.type === "PDivider") return f("hr", {
226
- ...i.attrs,
227
- "data-size": String(r.size ?? "4")
228
- }, void 0, i.vars);
229
- if (e.type === "PTable") {
230
- let e = r.headers.map((e) => f("th", {}, [e.text])), t = r.rows.map((e) => f("tr", {}, e.cells.map((e) => f("td", {}, [e]))));
231
- return f("div", i.attrs, [f("table", {}, [f("thead", {}, [f("tr", {}, e)]), f("tbody", {}, t)])], i.vars);
232
- }
233
- let a = h(r);
234
- if (e.type === "PTextField") return f("div", i.attrs, [f("label", { for: a }, [String(r.label)]), f("input", {
235
- id: a,
236
- name: a,
237
- placeholder: String(r.placeholder ?? "")
238
- })], i.vars);
239
- if (e.type === "PTextArea") return f("div", i.attrs, [f("label", { for: a }, [String(r.label)]), f("textarea", {
240
- id: a,
241
- name: a,
242
- placeholder: String(r.placeholder ?? "")
243
- })], i.vars);
244
- if (e.type === "PCheckbox") return f("div", i.attrs, [f("label", {}, [f("input", {
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: a,
247
- checked: r.checked === !0 || void 0
248
- }), String(r.label)])], i.vars);
249
- if (e.type === "PRadio") {
250
- let e = r.options.map((e) => f("label", {}, [f("input", {
251
- type: "radio",
252
- name: a,
253
- value: e.text
254
- }), e.text]));
255
- return f("fieldset", i.attrs, [f("legend", {}, [String(r.legend)]), ...e], i.vars);
256
- }
257
- if (e.type === "PSelect") {
258
- let e = r.options.map((e) => f("option", { value: e.text }, [e.text]));
259
- return f("div", i.attrs, [f("label", { for: a }, [String(r.label)]), f("select", {
260
- id: a,
261
- name: a
262
- }, e)], i.vars);
263
- }
264
- return f("div", i.attrs, void 0, i.vars);
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 x(e) {
267
- return _.has(e.type) ? b(e, { children: (e.children ?? []).map(x).filter(Boolean) }) : b(e);
346
+ function $(e) {
347
+ return X.has(e.type) ? Q(e, { children: (e.children ?? []).map($).filter(Boolean) }) : Q(e);
268
348
  }
269
- export { m as cssPrefix, b as elementSpec, t as escapeHtml, g as hostAttrs, p as linked, h as nodeId, r as renderHtml, n as sanitizeRichTextHtml, f as spec, u as styleToCssVariables, d as tags, i as toDom, x as toElementTree };
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.7",
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>>>>>;