@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.
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],
@@ -344,6 +347,29 @@ const { id, connectors, actions } = useNode();
344
347
 
345
348
  ---
346
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
+
347
373
  ## Stylesheet
348
374
 
349
375
  Import stylesheet một lần ở entry của app:
@@ -388,7 +414,6 @@ import type {
388
414
  NodeTree, // cây node
389
415
  Resolver, // map resolvedName → component
390
416
  NodeConfig, // config truyền vào defineNode()
391
- DisplayOnValue, // responsive visibility: Partial<Record<Screen, boolean>>
392
417
  } from '@janbox/storefront-builder';
393
418
  ```
394
419
 
@@ -1,5 +1,7 @@
1
1
  import { ElementProps } from '@craftjs/core';
2
+ import { NodeCustom } from '../../types';
2
3
  export type NodeElementProps<T extends React.ElementType> = ShallowMerge<ElementProps<T>, {
3
4
  is: T;
5
+ custom?: NodeCustom;
4
6
  }>;
5
7
  export declare const NodeElement: <T extends React.ElementType>(props: NodeElementProps<T>) => React.ReactElement;
@@ -3,8 +3,9 @@ import { WbPopoverProps } from '../ui';
3
3
  type ColorPickerContentProps = {
4
4
  color?: string;
5
5
  onChange?: (color: string) => void;
6
+ hidePalette?: boolean;
6
7
  };
7
8
  export declare const ColorPickerContent: ({ color, onChange }: ColorPickerContentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
8
9
  export type ColorPickerPopoverProps = ShallowMerge<WbPopoverProps, ColorPickerContentProps>;
9
- export declare const ColorPickerPopover: ({ color, onChange, children, placement, ...props }: ColorPickerPopoverProps) => import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare const ColorPickerPopover: ({ color, onChange, hidePalette, children, placement, ...props }: ColorPickerPopoverProps) => import("@emotion/react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,8 +1,7 @@
1
1
  import { CssUnit } from '../types';
2
- import { Screen } from '@janbox/storefront-ui/theme';
3
- import { ColorVariant } from '@janbox/storefront-ui/types';
2
+ import { Screen, ColorScale } from '@janbox/storefront-ui/theme';
4
3
  export type ColorVariantOption = {
5
- value: ColorVariant;
4
+ value: ColorScale;
6
5
  label: string;
7
6
  };
8
7
  export declare const colorVariantOptions: ColorVariantOption[];
@@ -5,6 +5,7 @@ export type EditorHandlers = {
5
5
  close: () => void;
6
6
  submit: (abc: SerializedNodes) => void | Promise<void>;
7
7
  upload: (file: File) => string | Promise<string>;
8
+ saveTheme?: (theme: Theme) => void | Promise<void>;
8
9
  };
9
10
  export type EditorState = {
10
11
  theme: Theme;
@@ -0,0 +1 @@
1
+ export declare const ThemeAction: () => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { ColorVariantOption } from '../../constants';
2
2
  import { WbSelectProps } from '../../ui';
3
- import { ColorVariant } from '@janbox/storefront-ui/types';
4
- export type ColorVariantToolbarProps = Partial<WbSelectProps<ColorVariant, ColorVariantOption>>;
3
+ import { ColorScale } from '@janbox/storefront-ui/theme';
4
+ export type ColorVariantToolbarProps = Partial<WbSelectProps<ColorScale, ColorVariantOption>>;
5
5
  export declare const ColorVariantToolbar: (props: ColorVariantToolbarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -24,7 +24,7 @@ export * from './color-variant';
24
24
  export * from './flex';
25
25
  export * from './number-field';
26
26
  export * from './number-field-mix-options';
27
- export * from './display-on';
27
+ export * from './visibility';
28
28
  export * from './justify-items';
29
29
  export * from './grid-align-items';
30
30
  export * from './aspect-ratio';
@@ -0,0 +1 @@
1
+ export * from './visibility';
@@ -0,0 +1 @@
1
+ export declare const VisibilityToolbar: () => import("@emotion/react/jsx-runtime").JSX.Element;