@janbox/storefront-builder 2.0.10 → 2.0.12

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.
@@ -8,7 +8,6 @@ export declare const useNodeProps: <P extends object = object, K = P extends ToR
8
8
  transform?: (current: P) => P;
9
9
  nodeId?: string;
10
10
  }) => {
11
- id: string;
12
11
  nodeProps: P;
13
12
  setNodeProps: (next: DeepPartial<P> | ((prev: P) => void), setPropOptions?: SetPropOptions) => void;
14
13
  setNodeResponsiveProps: (props: DeepPartial<K>, screen: Screen, options?: SetPropOptions) => void;
@@ -0,0 +1,206 @@
1
+ import { useNode as b, Element as T, Frame as h, Editor as I, DefaultEventHandlers as v } from "@craftjs/core";
2
+ import { isFunction as x, merge as A, set as w, isNil as C, isString as f } from "lodash-es";
3
+ import { useMemo as S, useEffect as E } from "react";
4
+ import { N as l, W as e, g as L, A as y, c as k, b as B, a as F, p as M, T as q, o as G, n as R, q as U, M as H, l as D, m as j, S as O, k as V, r as _, L as $, I as z, V as J, j as W, f as X, B as Y, F as K, h as Q, e as Z, G as ee, i as oe, P as re, d as se, U as ne, R as te, u as ae, y as de, X as ie, Y as g } from "./countdown-timer.node-d0EtGQ4_.js";
5
+ import { getGridProps as ue, getCellProps as ce, getLinkProps as pe, getButtonProps as le, getFlexboxProps as me, getFlexItemProps as Ne, getImageProps as Pe, getMarqueeProps as fe, getTabsProps as ge, getSwiperProps as be, getUnorderedListProps as Ce, getIconProps as Te, getAccordionProps as he, getAccordionGroupProps as Ie, getVideoProps as ve, getBoxProps as xe, getContainerProps as Ae, Primitive as we } from "@janbox/storefront-ui";
6
+ import { flatten as Se } from "flat";
7
+ import { jsx as m } from "@emotion/react/jsx-runtime";
8
+ const o = (n = {}) => {
9
+ const { id: r } = b(), s = n?.nodeId ?? r, { nodeProps: a, actions: i } = l((d) => ({
10
+ nodeProps: d.nodes[s ?? r]?.data.props ?? {}
11
+ })), t = (d, c) => x(d) ? i.setProp(s, d) : i.setProp(s, (p) => {
12
+ if (c?.merge) {
13
+ A(p, d);
14
+ return;
15
+ }
16
+ const N = Se(d);
17
+ Object.keys(N).forEach((P) => {
18
+ w(p, P, N[P]);
19
+ });
20
+ }), u = (d, c, p) => t(
21
+ c === "xs" ? d : {
22
+ [c]: d
23
+ },
24
+ p
25
+ );
26
+ return {
27
+ nodeProps: n?.transform?.(a) ?? a,
28
+ setNodeProps: t,
29
+ setNodeResponsiveProps: u
30
+ };
31
+ }, Ue = () => o({
32
+ transform: ue
33
+ }), He = () => o({
34
+ transform: ce
35
+ }), De = () => o({
36
+ transform: pe
37
+ }), je = () => o({
38
+ transform: le
39
+ }), Oe = () => o({
40
+ transform: me
41
+ }), Ve = () => o({
42
+ transform: Ne
43
+ }), _e = () => o({
44
+ transform: Pe
45
+ }), $e = () => o({
46
+ transform: fe
47
+ }), ze = (n) => o({
48
+ transform: ge,
49
+ nodeId: n
50
+ }), Je = (n) => o({
51
+ nodeId: n
52
+ }), We = () => o({
53
+ transform: be
54
+ }), Xe = () => o({
55
+ transform: Ce
56
+ }), Ye = () => o({
57
+ transform: Te
58
+ }), Ke = (n) => o({
59
+ transform: he,
60
+ nodeId: n
61
+ }), Qe = () => o({
62
+ transform: Ie
63
+ }), Ze = () => o({
64
+ transform: ve
65
+ }), eo = () => o({
66
+ transform: xe
67
+ }), oo = () => o({
68
+ transform: Ae
69
+ }), ro = () => o(), so = T, no = ({ children: n, data: r }) => {
70
+ const { resolver: s } = l((i) => ({
71
+ resolver: i.options.resolver
72
+ })), a = S(() => {
73
+ if (C(r)) return r;
74
+ const i = f(r) ? JSON.parse(r) : r;
75
+ return Object.entries(i).forEach(([, t]) => {
76
+ const u = f(t.type) ? t.type : t.type.resolvedName;
77
+ s[u] || (console.error(`Unknown node: ${u}`), t.type = {
78
+ resolvedName: e.Unknown
79
+ });
80
+ }), i;
81
+ }, [r, s]);
82
+ return /* @__PURE__ */ m(h, { data: a, children: n });
83
+ }, Ee = {
84
+ // Root
85
+ [e.Root]: te,
86
+ // Unknown
87
+ [e.Unknown]: ne,
88
+ // Button
89
+ [e.Button]: se,
90
+ // Text
91
+ [e.Paragraph]: re,
92
+ [e.Heading]: oe,
93
+ // Layout
94
+ [e.Grid]: ee,
95
+ [e.Cell]: Z,
96
+ [e.Flexbox]: Q,
97
+ [e.FlexItem]: K,
98
+ [e.Box]: Y,
99
+ [e.Container]: X,
100
+ // Media
101
+ [e.Image]: W,
102
+ [e.Video]: J,
103
+ [e.Icon]: z,
104
+ // Navigation
105
+ [e.Link]: $,
106
+ // List
107
+ [e.UnorderedList]: _,
108
+ [e.ListItem]: V,
109
+ // Carousel
110
+ [e.Swiper]: O,
111
+ [e.SwiperSlide]: j,
112
+ [e.Marquee]: D,
113
+ [e.MarqueeItem]: H,
114
+ // Tabs
115
+ [e.Tabs]: U,
116
+ [e.TabList]: R,
117
+ [e.Tab]: G,
118
+ [e.TabContent]: q,
119
+ [e.TabPanel]: M,
120
+ // Accordion
121
+ [e.AccordionGroup]: F,
122
+ [e.Accordion]: B,
123
+ [e.AccordionSummary]: k,
124
+ [e.AccordionContent]: y,
125
+ // Timer
126
+ [e.CountdownTimer]: L
127
+ }, to = ({ resolver: n, children: r, ...s }) => /* @__PURE__ */ m(
128
+ I,
129
+ {
130
+ enabled: !1,
131
+ onRender: Le,
132
+ handlers: (a) => new ye({
133
+ store: a,
134
+ removeHoverOnMouseleave: !0,
135
+ isMultiSelectEnabled: () => !1
136
+ }),
137
+ resolver: { ...Ee, ...n },
138
+ ...s,
139
+ children: r
140
+ }
141
+ ), Le = ({ render: n }) => {
142
+ const { id: r, hidden: s } = b((t) => ({
143
+ hidden: ae(t).hidden ?? {}
144
+ })), { query: a } = l();
145
+ return E(() => {
146
+ const t = a.node(r).get(), u = de(t);
147
+ if (C(u))
148
+ throw new Error(
149
+ `The node with id "${t.data.displayName}" does not have a resolved ID. Please check your node configuration.`
150
+ );
151
+ }, [r, a]), Object.values(s).some((t) => t === !0) ? /* @__PURE__ */ m(
152
+ we,
153
+ {
154
+ sx: {
155
+ display: s.xs ? "none" : "contents",
156
+ sm: {
157
+ display: s.sm ? "none" : "contents"
158
+ },
159
+ md: {
160
+ display: s.md ? "none" : "contents"
161
+ },
162
+ lg: {
163
+ display: s.lg ? "none" : "contents"
164
+ }
165
+ },
166
+ children: n
167
+ }
168
+ ) : n;
169
+ };
170
+ class ye extends v {
171
+ handlers() {
172
+ const r = super.handlers();
173
+ return {
174
+ ...r,
175
+ select(s, a) {
176
+ return (s.getAttribute(ie.DATA_NODE_SELECTABLE) ?? g.True) === g.True ? r.select(s, a) : () => {
177
+ };
178
+ }
179
+ };
180
+ }
181
+ }
182
+ export {
183
+ no as C,
184
+ so as N,
185
+ to as a,
186
+ Qe as b,
187
+ Ke as c,
188
+ eo as d,
189
+ je as e,
190
+ He as f,
191
+ oo as g,
192
+ ro as h,
193
+ Ve as i,
194
+ Oe as j,
195
+ Ue as k,
196
+ Ye as l,
197
+ _e as m,
198
+ De as n,
199
+ $e as o,
200
+ We as p,
201
+ Je as q,
202
+ ze as r,
203
+ Xe as s,
204
+ Ze as t,
205
+ o as u
206
+ };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { A as c, a as g, b, c as C, B as x, d as f, C as T, e as I, f as L, g as S, F as A, h as v, G as w, H as R, i as h, I as k, j as q, L as B, k as F, M as G, l as H, P as M, R as U, S as y, m as D, T as V, n as j, o as E, p as z, q as J, U as K, r as O, V as Q, s as W, u as X, v as Y, w as Z, x as _, y as $, z as ee, D as oe, E as se, J as ae, K as re, N as de, O as Ne } from "./countdown-timer.node-d0EtGQ4_.js";
2
- import { u as e } from "./index-3PtMdwiC.js";
3
- import { C as ne, a as pe, N as ue, b as ie, c as Pe, d as me, e as le, f as ce, g as ge, h as be, i as Ce, j as xe, k as fe, l as Te, m as Ie, n as Le, o as Se, p as Ae, q as ve, r as we, s as Re, t as he } from "./index-3PtMdwiC.js";
2
+ import { u as e } from "./index-fErSlbD2.js";
3
+ import { C as ne, a as pe, N as ue, b as ie, c as Pe, d as me, e as le, f as ce, g as ge, h as be, i as Ce, j as xe, k as fe, l as Te, m as Ie, n as Le, o as Se, p as Ae, q as ve, r as we, s as Re, t as he } from "./index-fErSlbD2.js";
4
4
  import { getTextProps as s, getTabPanelProps as a, getListItemProps as r } from "@janbox/storefront-ui";
5
5
  import { useNode as qe } from "@craftjs/core";
6
6
  import "lodash-es";
@@ -13,7 +13,7 @@ CTA button node dùng component `Button` từ `@janbox/storefront-ui`. Có thể
13
13
  | Prop | Type | Description |
14
14
  | --- | --- | --- |
15
15
  | `dangerouslySetInnerHTML.__html` | `string` | Text hiển thị trong button |
16
- | `color` | `ColorVariant` | Màu theme của button |
16
+ | `color` | `ColorScale` | Màu theme của button |
17
17
  | `variant` | `ButtonVariant` | Kiểu hiển thị của button |
18
18
  | `size` | `ButtonSizeVariant` | Kích thước button |
19
19
  | `anchor.to` | `string \| { pathname: string }` | Link destination |
@@ -21,7 +21,7 @@ CTA button node dùng component `Button` từ `@janbox/storefront-ui`. Có thể
21
21
 
22
22
  `size` hỗ trợ responsive: `size="sm"` xs, `md={{ size: 'lg' }}` desktop.
23
23
 
24
- **`ColorVariant`:** `'primary' | 'secondary' | 'green' | 'red' | 'orange' | 'blue' | 'neutral'`
24
+ **`ColorScale`:** `'primary' | 'secondary' | 'green' | 'red' | 'orange' | 'blue' | 'neutral' | 'yellow' | 'violet'`
25
25
 
26
26
  **`ButtonVariant`:** `'contained' | 'outlined' | 'text'`
27
27
 
@@ -14,15 +14,14 @@ export type NodeCustom = {
14
14
  displayName?: string;
15
15
  selectable?: boolean;
16
16
  deletable?: boolean;
17
- dropzone?: boolean;
17
+ hidden?: Partial<Record<Screen, boolean>>;
18
18
  };
19
19
  export type NodeRelated = {
20
- inspector?: React.ComponentType<any>;
20
+ inspector?: React.ComponentType;
21
21
  renderer?: React.ComponentType<{
22
22
  render: React.ReactElement;
23
23
  }>;
24
24
  };
25
- export type DisplayOnValue = Partial<Record<Screen, boolean>>;
26
25
  export type NodeConfig<T = object> = ShallowMerge<Partial<UserComponentConfig<T>>, {
27
26
  info: NodeInfo;
28
27
  custom?: NodeCustom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-builder",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Standalone storefront builder library extracted from craft-layers-portal",
5
5
  "type": "module",
6
6
  "files": [
@@ -59,7 +59,7 @@
59
59
  "@types/react-dom": "^19.1.6",
60
60
  "@types/react-frame-component": "^4.1.6",
61
61
  "type-fest": "^5.5.0",
62
- "@janbox/storefront-ui": "latest"
62
+ "@janbox/storefront-ui": "^4.0.0"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public"
@@ -1,5 +0,0 @@
1
- interface DisplayOnToolbarProps {
2
- propertyPath?: string;
3
- }
4
- export declare const DisplayOnToolbar: ({ propertyPath }: DisplayOnToolbarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
- export {};
@@ -1 +0,0 @@
1
- export * from './display-on';
@@ -1,188 +0,0 @@
1
- import { useNode as T, Element as C, Frame as I, Editor as v, DefaultEventHandlers as A } from "@craftjs/core";
2
- import { isFunction as w, merge as x, set as h, isNil as g, isString as P } from "lodash-es";
3
- import { useMemo as E, useEffect as L } from "react";
4
- import { N, W as e, g as S, A as k, c as B, b as F, a as y, p as M, T as q, o as G, n as R, q as U, M as D, l as H, m as j, S as O, k as V, r as _, L as $, I as z, V as J, j as W, f as X, B as Y, F as K, h as Q, e as Z, G as ee, i as oe, P as re, d as se, U as te, R as ne, y as ae, X as de, Y as f } from "./countdown-timer.node-d0EtGQ4_.js";
5
- import { getGridProps as ue, getCellProps as ie, getLinkProps as ce, getButtonProps as pe, getFlexboxProps as Ne, getFlexItemProps as me, getImageProps as le, getMarqueeProps as Pe, getTabsProps as fe, getSwiperProps as ge, getUnorderedListProps as be, getIconProps as Te, getAccordionProps as Ce, getAccordionGroupProps as Ie, getVideoProps as ve, getBoxProps as Ae, getContainerProps as we } from "@janbox/storefront-ui";
6
- import { jsx as b } from "@emotion/react/jsx-runtime";
7
- import { flatten as xe } from "flat";
8
- const o = (s = {}) => {
9
- const { id: r } = T(), t = s?.nodeId ?? r, { nodeProps: n, actions: a } = N((d) => ({
10
- nodeProps: d.nodes[t ?? r]?.data.props ?? {}
11
- })), u = (d, c) => w(d) ? a.setProp(t, d) : a.setProp(t, (p) => {
12
- if (c?.merge) {
13
- x(p, d);
14
- return;
15
- }
16
- const m = xe(d);
17
- Object.keys(m).forEach((l) => {
18
- h(p, l, m[l]);
19
- });
20
- }), i = (d, c, p) => u(
21
- c === "xs" ? d : {
22
- [c]: d
23
- },
24
- p
25
- );
26
- return {
27
- id: t,
28
- nodeProps: s?.transform?.(n) ?? n,
29
- setNodeProps: u,
30
- setNodeResponsiveProps: i
31
- };
32
- }, Ge = () => o({
33
- transform: ue
34
- }), Re = () => o({
35
- transform: ie
36
- }), Ue = () => o({
37
- transform: ce
38
- }), De = () => o({
39
- transform: pe
40
- }), He = () => o({
41
- transform: Ne
42
- }), je = () => o({
43
- transform: me
44
- }), Oe = () => o({
45
- transform: le
46
- }), Ve = () => o({
47
- transform: Pe
48
- }), _e = (s) => o({
49
- transform: fe,
50
- nodeId: s
51
- }), $e = (s) => o({
52
- nodeId: s
53
- }), ze = () => o({
54
- transform: ge
55
- }), Je = () => o({
56
- transform: be
57
- }), We = () => o({
58
- transform: Te
59
- }), Xe = (s) => o({
60
- transform: Ce,
61
- nodeId: s
62
- }), Ye = () => o({
63
- transform: Ie
64
- }), Ke = () => o({
65
- transform: ve
66
- }), Qe = () => o({
67
- transform: Ae
68
- }), Ze = () => o({
69
- transform: we
70
- }), eo = () => o(), oo = C, ro = ({ children: s, data: r }) => {
71
- const { resolver: t } = N((a) => ({
72
- resolver: a.options.resolver
73
- })), n = E(() => {
74
- if (g(r)) return r;
75
- const a = P(r) ? JSON.parse(r) : r;
76
- return Object.entries(a).forEach(([, u]) => {
77
- const i = P(u.type) ? u.type : u.type.resolvedName;
78
- t[i] || (console.error(`Unknown node: ${i}`), u.type = {
79
- resolvedName: e.Unknown
80
- });
81
- }), a;
82
- }, [r, t]);
83
- return /* @__PURE__ */ b(I, { data: n, children: s });
84
- }, he = {
85
- // Root
86
- [e.Root]: ne,
87
- // Unknown
88
- [e.Unknown]: te,
89
- // Button
90
- [e.Button]: se,
91
- // Text
92
- [e.Paragraph]: re,
93
- [e.Heading]: oe,
94
- // Layout
95
- [e.Grid]: ee,
96
- [e.Cell]: Z,
97
- [e.Flexbox]: Q,
98
- [e.FlexItem]: K,
99
- [e.Box]: Y,
100
- [e.Container]: X,
101
- // Media
102
- [e.Image]: W,
103
- [e.Video]: J,
104
- [e.Icon]: z,
105
- // Navigation
106
- [e.Link]: $,
107
- // List
108
- [e.UnorderedList]: _,
109
- [e.ListItem]: V,
110
- // Carousel
111
- [e.Swiper]: O,
112
- [e.SwiperSlide]: j,
113
- [e.Marquee]: H,
114
- [e.MarqueeItem]: D,
115
- // Tabs
116
- [e.Tabs]: U,
117
- [e.TabList]: R,
118
- [e.Tab]: G,
119
- [e.TabContent]: q,
120
- [e.TabPanel]: M,
121
- // Accordion
122
- [e.AccordionGroup]: y,
123
- [e.Accordion]: F,
124
- [e.AccordionSummary]: B,
125
- [e.AccordionContent]: k,
126
- // Timer
127
- [e.CountdownTimer]: S
128
- }, so = ({ resolver: s, children: r, ...t }) => /* @__PURE__ */ b(
129
- v,
130
- {
131
- enabled: !1,
132
- onRender: Ee,
133
- handlers: (n) => new Le({
134
- store: n,
135
- removeHoverOnMouseleave: !0,
136
- isMultiSelectEnabled: () => !1
137
- }),
138
- resolver: { ...he, ...s },
139
- ...t,
140
- children: r
141
- }
142
- ), Ee = ({ render: s }) => {
143
- const { id: r } = o(), { query: t } = N();
144
- return L(() => {
145
- const n = t.node(r).get(), a = ae(n);
146
- if (g(a))
147
- throw new Error(
148
- `The node with id "${n.data.displayName}" does not have a resolved ID. Please check your node configuration.`
149
- );
150
- }, [r, t]), s;
151
- };
152
- class Le extends A {
153
- handlers() {
154
- const r = super.handlers();
155
- return {
156
- ...r,
157
- select(t, n) {
158
- return (t.getAttribute(de.DATA_NODE_SELECTABLE) ?? f.True) === f.True ? r.select(t, n) : () => {
159
- };
160
- }
161
- };
162
- }
163
- }
164
- export {
165
- ro as C,
166
- oo as N,
167
- so as a,
168
- Ye as b,
169
- Xe as c,
170
- Qe as d,
171
- De as e,
172
- Re as f,
173
- Ze as g,
174
- eo as h,
175
- je as i,
176
- He as j,
177
- Ge as k,
178
- We as l,
179
- Oe as m,
180
- Ue as n,
181
- Ve as o,
182
- ze as p,
183
- $e as q,
184
- _e as r,
185
- Je as s,
186
- Ke as t,
187
- o as u
188
- };