@frontify/guideline-blocks-settings 0.19.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,13 +1,8 @@
1
- import type { BaseBlock } from './base';
1
+ import type { BaseBlock, ValueOrPromisedValue } from './base';
2
2
  import type { Checkbox } from './checkbox';
3
- import type { AppBridgeBlock } from '@frontify/app-bridge';
4
- declare type ChoicesFn = (props: {
5
- appBridge: AppBridgeBlock;
6
- }) => Promise<Checkbox[]>;
7
3
  export declare type ChecklistBlock = {
8
4
  type: 'checklist';
9
- choices: Checkbox[] | ChoicesFn;
5
+ choices: ValueOrPromisedValue<Checkbox[]>;
10
6
  showClearAndSelectAllButtons?: boolean;
11
7
  columns?: 1 | 2;
12
8
  } & BaseBlock<string[] | null>;
13
- 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.19.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,14 +1,11 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import type { BaseBlock } from './base';
3
+ import type { BaseBlock, ValueOrPromisedValue } from './base';
4
4
  import type { Checkbox } from './checkbox';
5
- import type { AppBridgeBlock } from '@frontify/app-bridge';
6
-
7
- type ChoicesFn = (props: { appBridge: AppBridgeBlock }) => Promise<Checkbox[]>;
8
5
 
9
6
  export type ChecklistBlock = {
10
7
  type: 'checklist';
11
- choices: Checkbox[] | ChoicesFn;
8
+ choices: ValueOrPromisedValue<Checkbox[]>;
12
9
  showClearAndSelectAllButtons?: boolean;
13
10
  columns?: 1 | 2;
14
11
  } & BaseBlock<string[] | null>;
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
  };