@janbox/storefront-builder 2.0.0 → 2.0.2

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/anchor-target-CtXzdkBu.js +2918 -0
  3. package/dist/{color-picker-popover-B3AVFuei.js → color-picker-popover-XeaVfYS8.js} +104 -80
  4. package/dist/countdown-timer.node-Bh5fTSJ8.js +913 -0
  5. package/dist/date-picker-D9K6HWl-.js +157 -0
  6. package/dist/{dialog-header-DPLOS7TT.js → dialog-header-Bh3Dkw2q.js} +2440 -2122
  7. package/dist/dropzone-CF4CWXth.js +546 -0
  8. package/dist/editor/toolbars.js +171 -161
  9. package/dist/editor/ui/button-group/button-group.d.ts +1 -1
  10. package/dist/editor/ui/dialog/dialog-body/dialog-body.d.ts +1 -1
  11. package/dist/editor/ui/form-label/form-label.d.ts +1 -1
  12. package/dist/editor/ui/input/input.d.ts +1 -2
  13. package/dist/editor/ui/loading-overlay/loading-overlay.d.ts +1 -1
  14. package/dist/editor/ui/popover/popover-close.d.ts +1 -1
  15. package/dist/editor/ui/tabs/tab-content.d.ts +1 -1
  16. package/dist/editor/ui/tabs/tab-list.d.ts +2 -4
  17. package/dist/editor/ui/tabs/tab-panel.d.ts +1 -1
  18. package/dist/editor/ui/tabs/tab.d.ts +2 -5
  19. package/dist/editor/ui/tabs/tabs.d.ts +1 -1
  20. package/dist/editor/ui.js +82 -72
  21. package/dist/editor.js +822 -586
  22. package/dist/index-800HnUOi.js +4 -0
  23. package/dist/{index-CwrFnubn.js → index-CXyljfMv.js} +1729 -1584
  24. package/dist/index.js +287 -247
  25. package/dist/style.css +1 -1
  26. package/dist/templates.js +10 -12
  27. package/dist/theme/index.d.ts +293 -0
  28. package/dist/tooltip-CXOlTkGg.js +75 -0
  29. package/dist/utils/common.d.ts +0 -2
  30. package/package.json +1 -2
  31. package/dist/anchor-target-BlOvysAr.js +0 -2329
  32. package/dist/countdown-timer.node-OmDiT-pz.js +0 -825
  33. package/dist/date-picker-B4Rju7gG.js +0 -115
  34. package/dist/dropzone-Dbfed3jK.js +0 -490
  35. package/dist/index-BbiQ0n_-.js +0 -4
  36. package/dist/tooltip-KbIHELP2.js +0 -65
@@ -1,14 +1,13 @@
1
- import { isString as g } from "lodash-es";
2
- import { useCallback as v, useMemo as P, useSyncExternalStore as W, Fragment as z } from "react";
3
- import "clsx";
4
- import "tailwind-merge";
5
- import { q as M, s as F, r as V, m as j, W as R, c as T, f as U } from "./dialog-header-DPLOS7TT.js";
6
- import { useEditor as q } from "@craftjs/core";
1
+ import { isString as b } from "lodash-es";
2
+ import { useCallback as v, useMemo as P, useSyncExternalStore as z, Fragment as M } from "react";
3
+ import { t as g, q as F, s as R, r as V, l as j, W as T, e as U, z as q } from "./dialog-header-Bh3Dkw2q.js";
4
+ import { useEditor as B } from "@craftjs/core";
7
5
  import { jsxs as c, jsx as r } from "@emotion/react/jsx-runtime";
8
- import { parseColor as x, paletteVars as B, groupedColors as O } from "@janbox/storefront-ui/theme";
9
- import { flatten as $ } from "flat";
6
+ import { parseColor as k, paletteVars as D, groupedColors as G } from "@janbox/storefront-ui/theme";
7
+ import { flatten as O } from "flat";
10
8
  import "@janbox/storefront-ui/hooks";
11
9
  import "@janbox/storefront-ui/utils";
10
+ import "@emotion/react";
12
11
  import "@floating-ui/react";
13
12
  import "react-use";
14
13
  import "overlayscrollbars-react";
@@ -16,13 +15,13 @@ import "@tanstack/react-virtual";
16
15
  import "react-dropzone";
17
16
  import "react-datepicker/dist/react-datepicker.css";
18
17
  import "react-datepicker";
19
- const k = (e) => e.info ?? {}, y = (e) => e.data?.custom ?? {}, de = (e) => {
20
- const t = y(e);
21
- if (g(t.displayName))
18
+ const N = (e) => e.info ?? {}, I = (e) => e.data?.custom ?? {}, de = (e) => {
19
+ const t = I(e);
20
+ if (b(t.displayName))
22
21
  return t.displayName;
23
- const o = k(e);
24
- return g(o.displayName) ? o.displayName : o.displayName?.(e.data.props) ?? e.data.displayName;
25
- }, le = (e) => e.data.displayName, ce = (e) => e.related ?? {}, he = (e) => y(e).selectable ?? k(e).selectable ?? !0, ue = (e, t) => {
22
+ const o = N(e);
23
+ return b(o.displayName) ? o.displayName : o.displayName?.(e.data.props) ?? e.data.displayName;
24
+ }, le = (e) => e.data.displayName, ce = (e) => e.related ?? {}, he = (e) => I(e).selectable ?? N(e).selectable ?? !0, pe = (e, t) => {
26
25
  try {
27
26
  e.craft && (e.craft = {
28
27
  ...e.craft,
@@ -34,55 +33,55 @@ const k = (e) => e.info ?? {}, y = (e) => e.data?.custom ?? {}, de = (e) => {
34
33
  } catch (o) {
35
34
  console.error(`Error setting related for ${e.craft?.displayName}`, o);
36
35
  }
37
- }, pe = (e, t = "xs") => t === "xs" ? e : { [t]: e }, we = (e, t) => {
38
- const { resolved: o, ...i } = t;
36
+ }, ue = (e, t = "xs") => t === "xs" ? e : { [t]: e }, me = (e, t) => {
37
+ const { resolved: o, ...n } = t;
39
38
  return e.craft = {
40
39
  displayName: o,
41
- ...i,
42
- related: i.related ?? {}
40
+ ...n,
41
+ related: n.related ?? {}
43
42
  }, e;
44
- }, me = (e = () => ({})) => {
45
- const t = q(e), { query: o, actions: i } = t, h = v(
43
+ }, fe = (e = () => ({})) => {
44
+ const t = B(e), { query: o, actions: n } = t, h = v(
46
45
  (s, a, d) => {
47
- const l = o.node(s).get(), n = a ?? l.data.parent, w = n ? o.node(n).get() : null;
48
- if (!w)
46
+ const l = o.node(s).get(), i = a ?? l.data.parent, m = i ? o.node(i).get() : null;
47
+ if (!m)
49
48
  throw new Error("Parent node not found");
50
- const u = {
49
+ const p = {
51
50
  data: {
52
51
  ...l.data,
53
52
  nodes: [],
54
53
  linkedNodes: {}
55
54
  }
56
- }, f = o.parseFreshNode(u).toNode();
57
- return i.add(f, w.id, d ?? w.data.nodes.length), l.data.nodes.forEach((S, E) => {
58
- h(S, f.id, E);
59
- }), o.node(f.id).get();
55
+ }, w = o.parseFreshNode(p).toNode();
56
+ return n.add(w, m.id, d ?? m.data.nodes.length), l.data.nodes.forEach((E, W) => {
57
+ h(E, w.id, W);
58
+ }), o.node(w.id).get();
60
59
  },
61
- [i, o]
62
- ), p = v(
60
+ [n, o]
61
+ ), u = v(
63
62
  (s) => {
64
63
  const a = s.parentId ?? o.node(s.nodeId).get().data.parent;
65
64
  if (!a)
66
65
  throw new Error("Parent node not found");
67
66
  let d;
68
67
  if ("sourceIndex" in s) {
69
- const { sourceIndex: l, destinationIndex: n } = s;
70
- d = n > l ? n + 1 : n;
68
+ const { sourceIndex: l, destinationIndex: i } = s;
69
+ d = i > l ? i + 1 : i;
71
70
  } else
72
71
  d = s.moveIndex;
73
- i.move(s.nodeId, a, d);
72
+ n.move(s.nodeId, a, d);
74
73
  },
75
- [i, o]
74
+ [n, o]
76
75
  );
77
76
  return P(() => ({
78
77
  ...t,
79
78
  actions: {
80
79
  ...t.actions,
81
- move: p,
80
+ move: u,
82
81
  duplicate: h
83
82
  }
84
- }), [h, t, p]);
85
- }, A = () => {
83
+ }), [h, t, u]);
84
+ }, $ = () => {
86
85
  let e;
87
86
  const t = /* @__PURE__ */ new Set();
88
87
  return { getSnapshot: () => {
@@ -96,25 +95,25 @@ const k = (e) => e.info ?? {}, y = (e) => e.data?.custom ?? {}, de = (e) => {
96
95
  throw new Error("useEditor must be initialized before setState.");
97
96
  e = { ...e, ...s }, t.forEach((a) => a());
98
97
  } };
99
- }, m = A();
100
- let N = !1;
101
- const I = (e) => (e && !N && (N = !0, m.initialize(e)), {
102
- ...W(m.subscribe, m.getSnapshot),
103
- setState: m.setState
104
- }), b = ({ color: e, size: t = 24 }) => {
105
- const o = I(), i = x(e, o.theme.palette);
98
+ }, f = $();
99
+ let C = !1;
100
+ const S = (e) => (e && !C && (C = !0, f.initialize(e)), {
101
+ ...z(f.subscribe, f.getSnapshot),
102
+ setState: f.setState
103
+ }), x = ({ color: e, size: t = 24 }) => {
104
+ const o = S(), n = k(e, o.theme.palette);
106
105
  return /* @__PURE__ */ c(
107
106
  "div",
108
107
  {
109
108
  title: e,
110
- className: "tw:rounded-full tw:border tw:border-ic-white-3s tw:overflow-hidden",
111
- style: { backgroundColor: i?.toString(), width: t, height: t },
109
+ css: { borderRadius: 9999, overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: g.palette.white["3s"] },
110
+ style: { backgroundColor: n?.toString(), width: t, height: t },
112
111
  children: [
113
- !i && /* @__PURE__ */ c("svg", { className: "tw:w-full tw:h-full tw:text-ic-white-5s", viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", children: [
112
+ !n && /* @__PURE__ */ c("svg", { css: { width: "100%", height: "100%", color: g.palette.white["5s"] }, viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", children: [
114
113
  /* @__PURE__ */ r("defs", { children: /* @__PURE__ */ r("pattern", { id: "diagonal-stripes", patternUnits: "userSpaceOnUse", width: "8", height: "8", children: /* @__PURE__ */ r("path", { d: "M-2,2 l4,-4 M0,8 l8,-8 M6,10 l4,-4", stroke: "currentColor", strokeWidth: "1.5" }) }) }),
115
114
  /* @__PURE__ */ r("rect", { width: "32", height: "32", fill: "url(#diagonal-stripes)" })
116
115
  ] }),
117
- i?.alpha() === 0 && /* @__PURE__ */ c("svg", { className: "tw:w-full tw:h-full", xmlns: "http://www.w3.org/2000/svg", children: [
116
+ n?.alpha() === 0 && /* @__PURE__ */ c("svg", { css: { width: "100%", height: "100%" }, xmlns: "http://www.w3.org/2000/svg", children: [
118
117
  /* @__PURE__ */ r("defs", { children: /* @__PURE__ */ c("pattern", { id: "checkerboard", patternUnits: "userSpaceOnUse", width: "8", height: "8", children: [
119
118
  /* @__PURE__ */ r("rect", { width: "8", height: "8", fill: "white" }),
120
119
  /* @__PURE__ */ r("rect", { width: "4", height: "4", fill: "lightgray" }),
@@ -125,40 +124,57 @@ const I = (e) => (e && !N && (N = !0, m.initialize(e)), {
125
124
  ]
126
125
  }
127
126
  );
128
- }, D = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
127
+ }, A = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
129
128
  <path d="M11.999 8C11.861 8 11.749 8.112 11.75 8.25C11.75 8.388 11.862 8.5 12 8.5C12.138 8.5 12.25 8.388 12.25 8.25C12.25 8.112 12.138 8 11.999 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
130
129
  <path fill-rule="evenodd" clip-rule="evenodd" d="M12 21V21C7.029 21 3 16.971 3 12V12C3 7.029 7.029 3 12 3V3C16.971 3 21 7.029 21 12V12C21 16.971 16.971 21 12 21Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
131
130
  <path d="M12 12V17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
132
131
  </svg>
133
- `, C = $(B), fe = ({
132
+ `, y = O(D), ge = ({
134
133
  color: e,
135
134
  onChange: t,
136
135
  children: o,
137
- placement: i = "right-start",
136
+ placement: n = "right-start",
138
137
  ...h
139
138
  }) => {
140
- const p = (n) => {
141
- t?.(C[n.currentTarget.value]);
142
- }, s = I(), a = x(e, s.theme.palette)?.hex(), d = (n) => {
143
- n.target.select();
144
- }, l = (n) => {
145
- t?.(n.target.value);
139
+ const u = (i) => {
140
+ t?.(y[i.currentTarget.value]);
141
+ }, s = S(), a = k(e, s.theme.palette)?.hex(), d = (i) => {
142
+ i.target.select();
143
+ }, l = (i) => {
144
+ t?.(i.target.value);
146
145
  };
147
- return /* @__PURE__ */ c(M, { placement: i, ...h, children: [
148
- /* @__PURE__ */ r(F, { children: o ?? /* @__PURE__ */ r("button", { className: "tw:border tw:border-ic-white-1s tw:rounded-full tw:hover:border-ic-white-3s tw:p-0.5", children: /* @__PURE__ */ r(b, { color: e }) }) }),
149
- /* @__PURE__ */ r(V, { children: /* @__PURE__ */ c("div", { className: "tw:flex tw:flex-col tw:gap-3", children: [
150
- /* @__PURE__ */ r("div", { className: "tw:flex tw:items-center tw:gap-2", children: /* @__PURE__ */ r("div", { className: "tw:flex-1", children: /* @__PURE__ */ r(
146
+ return /* @__PURE__ */ c(F, { placement: n, ...h, children: [
147
+ /* @__PURE__ */ r(R, { children: o ?? /* @__PURE__ */ r(
148
+ "button",
149
+ {
150
+ css: {
151
+ padding: 2,
152
+ borderRadius: 9999,
153
+ borderWidth: 1,
154
+ borderStyle: "solid",
155
+ borderColor: g.palette.white["1s"],
156
+ ":hover": {
157
+ borderColor: g.palette.white["3s"]
158
+ }
159
+ },
160
+ children: /* @__PURE__ */ r(x, { color: e })
161
+ }
162
+ ) }),
163
+ /* @__PURE__ */ r(V, { children: /* @__PURE__ */ c("div", { css: { display: "flex", flexDirection: "column", gap: 12 }, children: [
164
+ /* @__PURE__ */ r("div", { css: { display: "flex", alignItems: "center", gap: 8 }, children: /* @__PURE__ */ r("div", { css: { flex: 1 }, children: /* @__PURE__ */ r(
151
165
  j,
152
166
  {
153
167
  fullWidth: !0,
154
168
  suffix: /* @__PURE__ */ r(
155
- R,
169
+ T,
156
170
  {
157
- className: T({
158
- hidden: e === a
159
- }),
171
+ css: [
172
+ e === a && {
173
+ display: "none"
174
+ }
175
+ ],
160
176
  size: 16,
161
- source: D
177
+ source: A
162
178
  }
163
179
  ),
164
180
  onChange: l,
@@ -167,35 +183,43 @@ const I = (e) => (e && !N && (N = !0, m.initialize(e)), {
167
183
  size: "32"
168
184
  }
169
185
  ) }) }),
170
- /* @__PURE__ */ r(U, { className: "tw:min-w-72", color: a, onChange: t }),
186
+ /* @__PURE__ */ r(U, { css: { minWidth: 288 }, color: a, onChange: t }),
171
187
  /* @__PURE__ */ r(
172
188
  "div",
173
189
  {
174
190
  style: {
175
191
  gridTemplateColumns: "max-content 1fr"
176
192
  },
177
- className: "tw:grid tw:items-center tw:gap-x-4 tw:gap-y-2",
178
- children: O.map((n, w) => /* @__PURE__ */ c(z, { children: [
179
- /* @__PURE__ */ r("p", { className: "tw:text-xs", children: n.name }),
180
- /* @__PURE__ */ r("div", { className: "tw:inline-flex tw:items-center tw:gap-2", children: n.colors.map((u) => /* @__PURE__ */ r("div", { className: "tw:inline-flex", children: /* @__PURE__ */ r("button", { title: u, onClick: p, type: "button", value: u, children: /* @__PURE__ */ r(b, { color: C[u] }) }) }, u)) })
181
- ] }, w))
193
+ css: { display: "grid", alignItems: "center", columnGap: 16, rowGap: 8 },
194
+ children: G.map((i, m) => /* @__PURE__ */ c(M, { children: [
195
+ /* @__PURE__ */ r(
196
+ "p",
197
+ {
198
+ css: {
199
+ ...q.xs
200
+ },
201
+ children: i.name
202
+ }
203
+ ),
204
+ /* @__PURE__ */ r("div", { css: { display: "inline-flex", alignItems: "center", gap: 8 }, children: i.colors.map((p) => /* @__PURE__ */ r("div", { css: { display: "inline-flex" }, children: /* @__PURE__ */ r("button", { title: p, onClick: u, type: "button", value: p, children: /* @__PURE__ */ r(x, { color: y[p] }) }) }, p)) })
205
+ ] }, m))
182
206
  }
183
207
  )
184
208
  ] }) })
185
209
  ] });
186
210
  };
187
211
  export {
188
- fe as C,
189
- D as I,
212
+ ge as C,
213
+ A as I,
190
214
  de as a,
191
- k as b,
215
+ N as b,
192
216
  ce as c,
193
- we as d,
217
+ me as d,
194
218
  le as e,
195
- I as f,
196
- y as g,
219
+ S as f,
220
+ I as g,
197
221
  he as i,
198
- ue as r,
199
- pe as t,
200
- me as u
222
+ pe as r,
223
+ ue as t,
224
+ fe as u
201
225
  };