@janbox/storefront-builder 2.0.9 → 2.0.11

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 (61) hide show
  1. package/README.md +59 -4
  2. package/dist/{dataset-DQ21hyBo.js → countdown-timer.node-d0EtGQ4_.js} +2592 -3029
  3. package/dist/editor/components/color-picker-popover.d.ts +2 -1
  4. package/dist/editor/constants/index.d.ts +2 -3
  5. package/dist/editor/hooks/use-editor.d.ts +1 -0
  6. package/dist/editor/lib/sidebar/theme-action.d.ts +1 -0
  7. package/dist/editor/toolbars/color-variant/color-variant.d.ts +2 -2
  8. package/dist/editor/toolbars/index.d.ts +1 -1
  9. package/dist/editor/toolbars/visibility/index.d.ts +1 -0
  10. package/dist/editor/toolbars/visibility/visibility.d.ts +1 -0
  11. package/dist/editor.js +9888 -1241
  12. package/dist/hooks/use-first-mount-state.d.ts +1 -0
  13. package/dist/hooks/use-node-props.d.ts +0 -1
  14. package/dist/hooks/use-update-effect.d.ts +2 -0
  15. package/dist/index-fErSlbD2.js +206 -0
  16. package/dist/index-tISPdvwn.js +4 -0
  17. package/dist/index.js +92 -212
  18. package/dist/lib/accordion-group/index.d.ts +0 -1
  19. package/dist/lib/box/README.md +3 -10
  20. package/dist/lib/box/index.d.ts +0 -1
  21. package/dist/lib/button/README.md +2 -2
  22. package/dist/lib/button/index.d.ts +0 -1
  23. package/dist/lib/cell/index.d.ts +0 -1
  24. package/dist/lib/container/README.md +86 -0
  25. package/dist/lib/container/index.d.ts +0 -1
  26. package/dist/lib/countdown-timer/index.d.ts +0 -1
  27. package/dist/lib/flex-item/README.md +1 -0
  28. package/dist/lib/flex-item/index.d.ts +0 -1
  29. package/dist/lib/flexbox/README.md +0 -6
  30. package/dist/lib/flexbox/index.d.ts +0 -1
  31. package/dist/lib/grid/README.md +5 -4
  32. package/dist/lib/grid/index.d.ts +0 -1
  33. package/dist/lib/heading/README.md +38 -8
  34. package/dist/lib/heading/index.d.ts +0 -2
  35. package/dist/lib/icon/index.d.ts +0 -1
  36. package/dist/lib/image/index.d.ts +0 -1
  37. package/dist/lib/index.d.ts +0 -1
  38. package/dist/lib/link/index.d.ts +0 -1
  39. package/dist/lib/marquee/index.d.ts +0 -1
  40. package/dist/lib/paragraph/README.md +9 -5
  41. package/dist/lib/paragraph/index.d.ts +0 -2
  42. package/dist/lib/paragraph/paragraph.node/types.d.ts +2 -2
  43. package/dist/lib/swiper/index.d.ts +0 -1
  44. package/dist/lib/tabs/index.d.ts +0 -1
  45. package/dist/lib/unordered-list/index.d.ts +0 -1
  46. package/dist/lib/video/index.d.ts +0 -1
  47. package/dist/minus-BrRnjbhB.js +4 -0
  48. package/dist/templates.js +17 -33
  49. package/dist/{tooltip-Bi1eNiUc.js → tooltip-5WmNiI2z.js} +1 -1
  50. package/dist/types/index.d.ts +2 -3
  51. package/package.json +2 -3
  52. package/dist/countdown-timer.inspector-EFXiJ973.js +0 -8192
  53. package/dist/editor/toolbars/display-on/display-on.d.ts +0 -5
  54. package/dist/editor/toolbars/display-on/index.d.ts +0 -1
  55. package/dist/index-Cx5nImHp.js +0 -4
  56. package/dist/lib/paragraph/paragraph/paragraph.d.ts +0 -2
  57. package/dist/lib/paragraph/paragraph/types.d.ts +0 -2
  58. package/dist/lib/text/README.md +0 -90
  59. package/dist/lib/text/index.d.ts +0 -1
  60. package/dist/lib/text/text.inspector/index.d.ts +0 -1
  61. package/dist/lib/text/text.inspector/text.inspector.d.ts +0 -6
package/README.md CHANGED
@@ -60,6 +60,9 @@ export default function BuilderPage() {
60
60
  await savePage(data);
61
61
  },
62
62
  close: () => navigateBack(),
63
+ saveTheme: async (theme) => {
64
+ await api.saveTheme(theme); // optional: enables theme editing
65
+ },
63
66
  }}
64
67
  insert={{
65
68
  groups: [HERO_SECTION_GROUP, FAQS_SECTION_GROUP],
@@ -79,9 +82,16 @@ export default function BuilderPage() {
79
82
 
80
83
  Dùng `Composer` + `Canvas` để render một trang đã lưu, không cần giao diện editor. Đây là cách dùng cho phía storefront hiển thị cho người mua.
81
84
 
85
+ `Canvas` hỗ trợ hai chế độ render:
86
+
87
+ 1. **Truyền `data`** — ưu tiên render từ serialized data (JSON từ editor)
88
+ 2. **Truyền `children`** — nếu không truyền `data`, Canvas sẽ render children như JSX thông thường
89
+
90
+ ### Render từ serialized data
91
+
82
92
  ```tsx
83
93
  import '@janbox/storefront-builder/style.css';
84
- import { Composer, Canvas, RootNode } from '@janbox/storefront-builder';
94
+ import { Composer, Canvas } from '@janbox/storefront-builder';
85
95
  import type { SerializedNodes } from '@janbox/storefront-builder';
86
96
 
87
97
  const savedData: SerializedNodes = { /* JSON từ editor */ };
@@ -89,14 +99,37 @@ const savedData: SerializedNodes = { /* JSON từ editor */ };
89
99
  export default function StorefrontPage() {
90
100
  return (
91
101
  <Composer>
92
- <Canvas data={savedData}>
93
- <RootNode />
102
+ <Canvas data={savedData} />
103
+ </Composer>
104
+ );
105
+ }
106
+ ```
107
+
108
+ `data` nhận `SerializedNodes` object hoặc JSON string. Khi truyền `data`, Canvas sẽ bỏ qua children và render hoàn toàn từ dữ liệu đã serialize.
109
+
110
+ ### Render từ children (không có data)
111
+
112
+ ```tsx
113
+ import '@janbox/storefront-builder/style.css';
114
+ import { Composer, Canvas, RootNode, BoxNode, HeadingNode } from '@janbox/storefront-builder';
115
+
116
+ export default function StorefrontPage() {
117
+ return (
118
+ <Composer>
119
+ <Canvas>
120
+ <RootNode>
121
+ <BoxNode>
122
+ <HeadingNode text="Hello World" />
123
+ </BoxNode>
124
+ </RootNode>
94
125
  </Canvas>
95
126
  </Composer>
96
127
  );
97
128
  }
98
129
  ```
99
130
 
131
+ Khi không truyền `data`, Canvas sử dụng children làm cây node mặc định để render.
132
+
100
133
  ---
101
134
 
102
135
  ## Khái niệm cơ bản
@@ -314,6 +347,29 @@ const { id, connectors, actions } = useNode();
314
347
 
315
348
  ---
316
349
 
350
+ ## Theme Editor
351
+
352
+ Sidebar tích hợp sẵn tab Theme cho phép xem và chỉnh sửa palette. Tính năng chỉnh sửa được kích hoạt khi truyền `handlers.saveTheme`:
353
+
354
+ ```tsx
355
+ <Editor
356
+ theme={myTheme}
357
+ handlers={{
358
+ // ...
359
+ saveTheme: async (theme) => {
360
+ await api.updateTheme(theme);
361
+ },
362
+ }}
363
+ />
364
+ ```
365
+
366
+ - Không truyền `saveTheme` → tab Theme chỉ hiển thị palette (view only)
367
+ - Truyền `saveTheme` → hiện color picker cho primary/secondary + nút Save/Cancel
368
+ - Cancel hoặc rời tab → reset về theme ban đầu
369
+ - Save → gọi `saveTheme(theme)` async, có loading state
370
+
371
+ ---
372
+
317
373
  ## Stylesheet
318
374
 
319
375
  Import stylesheet một lần ở entry của app:
@@ -358,7 +414,6 @@ import type {
358
414
  NodeTree, // cây node
359
415
  Resolver, // map resolvedName → component
360
416
  NodeConfig, // config truyền vào defineNode()
361
- DisplayOnValue, // responsive visibility: Partial<Record<Screen, boolean>>
362
417
  } from '@janbox/storefront-builder';
363
418
  ```
364
419