@frontify/guideline-blocks-settings 0.17.0 → 0.20.0

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.
@@ -1,10 +1,11 @@
1
1
  import { Bundle } from '../bundle';
2
+ export declare type ValueOrPromisedValue<FieldType> = FieldType | ((bundle: Bundle) => Promise<FieldType>);
2
3
  export declare type BaseBlock<T = undefined> = {
3
4
  id: string;
4
- label?: string;
5
- info?: string;
5
+ label?: ValueOrPromisedValue<string>;
6
+ info?: ValueOrPromisedValue<string>;
6
7
  value?: T;
7
- defaultValue?: T;
8
+ defaultValue?: ValueOrPromisedValue<T>;
8
9
  showForTranslations?: boolean;
9
10
  show?: (bundle: Bundle) => boolean;
10
11
  onChange?: (bundle: Bundle) => void;
@@ -1,8 +1,8 @@
1
- import { BaseBlock } from './base';
2
- import { Checkbox } from './checkbox';
1
+ import type { BaseBlock, ValueOrPromisedValue } from './base';
2
+ import type { Checkbox } from './checkbox';
3
3
  export declare type ChecklistBlock = {
4
4
  type: 'checklist';
5
- choices: Checkbox[];
5
+ choices: ValueOrPromisedValue<Checkbox[]>;
6
6
  showClearAndSelectAllButtons?: boolean;
7
7
  columns?: 1 | 2;
8
8
  } & BaseBlock<string[] | null>;
@@ -1,5 +1,7 @@
1
- import { Color } from '@frontify/fondue';
1
+ import { Color, ColorRgb } from '@frontify/fondue';
2
2
  import { BaseBlock } from './base';
3
+ declare type ColorFormats = Color | ColorRgb;
3
4
  export declare type ColorInputBlock = {
4
5
  type: 'colorInput';
5
- } & BaseBlock<Color>;
6
+ } & BaseBlock<ColorFormats>;
7
+ export {};
package/dist/bundle.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { AppBridgeBlock } from '@frontify/app-bridge';
1
2
  import { SettingBlock } from './blocks';
2
3
  export declare type SettingValue = {
3
4
  value?: SettingBlock['value'];
4
5
  };
5
6
  export declare type Bundle = {
6
7
  getBlock: (id: string) => SettingValue | null;
8
+ getAppBridge: () => AppBridgeBlock;
7
9
  setBlockValue: (key: string, value: SettingBlock['value']) => void;
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontify/guideline-blocks-settings",
3
- "version": "0.17.0",
3
+ "version": "0.20.0",
4
4
  "description": "Provides the types for the block settings",
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.umd.js",
@@ -2,12 +2,14 @@
2
2
 
3
3
  import { Bundle } from '../bundle';
4
4
 
5
+ export type ValueOrPromisedValue<FieldType> = FieldType | ((bundle: Bundle) => Promise<FieldType>);
6
+
5
7
  export type BaseBlock<T = undefined> = {
6
8
  id: string;
7
- label?: string;
8
- info?: string;
9
+ label?: ValueOrPromisedValue<string>;
10
+ info?: ValueOrPromisedValue<string>;
9
11
  value?: T;
10
- defaultValue?: T;
12
+ defaultValue?: ValueOrPromisedValue<T>;
11
13
  showForTranslations?: boolean;
12
14
  show?: (bundle: Bundle) => boolean;
13
15
  onChange?: (bundle: Bundle) => void;
@@ -1,11 +1,11 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { BaseBlock } from './base';
4
- import { Checkbox } from './checkbox';
3
+ import type { BaseBlock, ValueOrPromisedValue } from './base';
4
+ import type { Checkbox } from './checkbox';
5
5
 
6
6
  export type ChecklistBlock = {
7
7
  type: 'checklist';
8
- choices: Checkbox[];
8
+ choices: ValueOrPromisedValue<Checkbox[]>;
9
9
  showClearAndSelectAllButtons?: boolean;
10
10
  columns?: 1 | 2;
11
11
  } & BaseBlock<string[] | null>;
@@ -1,8 +1,10 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { Color } from '@frontify/fondue';
3
+ import { Color, ColorRgb } from '@frontify/fondue';
4
4
  import { BaseBlock } from './base';
5
5
 
6
+ type ColorFormats = Color | ColorRgb;
7
+
6
8
  export type ColorInputBlock = {
7
9
  type: 'colorInput';
8
- } & BaseBlock<Color>;
10
+ } & BaseBlock<ColorFormats>;
package/types/bundle.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
+ import { AppBridgeBlock } from '@frontify/app-bridge';
3
4
  import { SettingBlock } from './blocks';
4
5
 
5
6
  export type SettingValue = {
@@ -8,5 +9,6 @@ export type SettingValue = {
8
9
 
9
10
  export type Bundle = {
10
11
  getBlock: (id: string) => SettingValue | null;
12
+ getAppBridge: () => AppBridgeBlock;
11
13
  setBlockValue: (key: string, value: SettingBlock['value']) => void;
12
14
  };