@frontify/guideline-blocks-settings 0.0.1-alpha.0 → 0.1.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.
package/README.md CHANGED
@@ -1,17 +1,19 @@
1
1
  # Block Settings
2
+
2
3
  Provides the block settings types for the guideline-blocks.
3
4
 
4
5
  ## Example
6
+
5
7
  ```ts
6
- import { ApiBundle, ApiSettings } from '@frontify/guideline-blocks-settings';
8
+ import { Bundle, BlockSettings } from '@frontify/guideline-blocks-settings';
7
9
  import { IconEnum } from '@frontify/arcade';
8
10
 
9
- const Settings: ApiSettings = {
11
+ const Settings: BlockSettings = {
10
12
  main: [
11
13
  {
12
14
  id: 'example',
13
15
  type: 'dropdown',
14
- size: 'large',
16
+ size: 'Large',
15
17
  defaultValue: 'solid',
16
18
  choices: [
17
19
  {
@@ -25,7 +27,7 @@ const Settings: ApiSettings = {
25
27
  label: 'Line',
26
28
  },
27
29
  ],
28
- onChange: (bundle: ApiBundle): void => {
30
+ onChange: (bundle: Bundle): void => {
29
31
  const blockWidth = Number(bundle.getBlock('widthCustom')?.value);
30
32
  if (!Number.isNaN(blockWidth)) {
31
33
  bundle.setBlockValue('widthCustom', `${blockWidth}%`);
@@ -34,6 +36,3 @@ const Settings: ApiSettings = {
34
36
  },
35
37
  ],
36
38
  ```
37
-
38
- ## Publish a new version to npm
39
- Use `npm publish` from root of the monorepo to create a new version.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontify/guideline-blocks-settings",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.1.0",
4
4
  "description": "Provides the types for the block settings",
5
5
  "files": [
6
6
  "types"
@@ -10,12 +10,20 @@
10
10
  },
11
11
  "types": "types/index.d.ts",
12
12
  "author": "Frontify Developers <developers@frontify.com>",
13
+ "scripts": {
14
+ "lint": "eslint types",
15
+ "lint:fix": "eslint --fix types",
16
+ "prettier": "prettier --check types",
17
+ "prettier:fix": "prettier --write types"
18
+ },
13
19
  "devDependencies": {
14
- "typescript": "4.4.4"
20
+ "@frontify/eslint-config-typescript": "0.14.0",
21
+ "eslint": "8.5.0",
22
+ "prettier": "2.5.1",
23
+ "typescript": "4.5.4"
15
24
  },
16
25
  "dependencies": {
17
- "@frontify/app-bridge": "^2.6.0",
18
- "@frontify/arcade": "^0.12.0"
19
- },
20
- "gitHead": "1b93acd36853dba4103b56903b817816eb86f11f"
26
+ "@frontify/app-bridge": "2.11.0",
27
+ "@frontify/arcade": "0.16.2"
28
+ }
21
29
  }
@@ -1,12 +1,31 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { FileExtension } from '@frontify/app-bridge';
4
- import { AssetInputProps } from '@frontify/arcade';
3
+ import { FileExtension, AssetChooserProjectType, AssetChooserObjectType } from '@frontify/app-bridge';
5
4
  import { BaseBlock } from './base';
6
5
 
6
+ export enum AssetInputSource {
7
+ Library = 'Library',
8
+ Upload = 'Upload',
9
+ }
10
+
11
+ export enum AssetInputMode {
12
+ Both = 'Both',
13
+ UploadOnly = 'UploadOnly',
14
+ BrowseOnly = 'BrowseOnly',
15
+ }
16
+
17
+ export type AssetInputValue = {
18
+ source: AssetInputSource;
19
+ value: number;
20
+ };
21
+
7
22
  export type AssetInputBlock = {
8
23
  type: 'assetInput';
9
- asset?: AssetInputProps['asset'];
10
- value?: number;
11
- allowedExtensions: FileExtension[];
24
+ value?: AssetInputValue | AssetInputValue['value'];
25
+ defaultValue?: AssetInputValue | AssetInputValue['value'];
26
+ multiSelection?: boolean;
27
+ extensions?: FileExtension[];
28
+ projectTypes?: AssetChooserProjectType[];
29
+ objectTypes?: AssetChooserObjectType[];
30
+ mode?: AssetInputMode;
12
31
  } & BaseBlock;
@@ -1,11 +1,11 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { ApiBundle } from '../bundle';
3
+ import { Bundle } from '../bundle';
4
4
 
5
5
  export type BaseBlock = {
6
6
  id: string;
7
7
  label?: string;
8
8
  info?: string;
9
- show?: (bundle: ApiBundle) => boolean;
10
- onChange?: (bundle: ApiBundle) => void;
9
+ show?: (bundle: Bundle) => boolean;
10
+ onChange?: (bundle: Bundle) => void;
11
11
  };
@@ -1,10 +1,11 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
+ import { DropdownSize } from '@frontify/arcade';
3
4
  import { ChoicesType } from './choices';
4
5
 
5
6
  export type DropdownBlock = {
6
7
  type: 'dropdown';
7
8
  disabled?: boolean;
8
9
  placeholder?: string;
9
- size?: 'Small' | 'Large';
10
+ size?: DropdownSize;
10
11
  } & ChoicesType;
@@ -8,13 +8,25 @@ import { InputBlock } from './input';
8
8
  import { MultiInputBlock } from './multiInput';
9
9
  import { SliderBlock } from './slider';
10
10
  import { SwitchBlock } from './switch';
11
+ import { TemplateInputBlock } from './templateInput';
11
12
 
12
- export type ApiBlock =
13
+ export * from './assetInput';
14
+ export * from './checklist';
15
+ export * from './colorInput';
16
+ export * from './dropdown';
17
+ export * from './input';
18
+ export * from './multiInput';
19
+ export * from './slider';
20
+ export * from './switch';
21
+ export * from './templateInput';
22
+
23
+ export type SettingBlock =
13
24
  | AssetInputBlock
25
+ | ChecklistBlock
14
26
  | ColorInputBlock
15
- | SwitchBlock
16
27
  | DropdownBlock
17
- | SliderBlock
18
28
  | InputBlock
19
29
  | MultiInputBlock
20
- | ChecklistBlock;
30
+ | SliderBlock
31
+ | SwitchBlock
32
+ | TemplateInputBlock;
@@ -1,29 +1,13 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
3
  import { BaseBlock } from './base';
4
- import { AssetInputBlock } from './assetInput';
5
- import { ChecklistBlock } from './checklist';
6
- import { ColorInputBlock } from './colorInput';
7
- import { DropdownBlock } from './dropdown';
8
- import { InputBlock } from './input';
9
- import { MultiInputBlock } from './multiInput';
10
- import { SliderBlock } from './slider';
11
-
12
- export type Block =
13
- | AssetInputBlock
14
- | ChecklistBlock
15
- | ColorInputBlock
16
- | DropdownBlock
17
- | InputBlock
18
- | MultiInputBlock
19
- | SliderBlock
20
- | SwitchBlock;
4
+ import { SettingBlock } from './index';
21
5
 
22
6
  export type SwitchBlock = {
23
7
  type: 'switch';
24
8
  switchLabel?: string;
25
- on?: Block[];
26
- off?: Block[];
9
+ on?: SettingBlock[];
10
+ off?: SettingBlock[];
27
11
  value?: boolean;
28
12
  defaultValue: boolean;
29
13
  } & BaseBlock;
@@ -0,0 +1,10 @@
1
+ /* (c) Copyright Frontify Ltd., all rights reserved. */
2
+
3
+ import { BaseBlock } from './base';
4
+
5
+ export type TemplateInputBlock = {
6
+ type: 'templateInput';
7
+ value?: number;
8
+ defaultValue?: number;
9
+ multiSelection?: boolean;
10
+ } & BaseBlock;
package/types/bundle.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { ApiBlock } from './blocks';
3
+ import { SettingBlock } from './blocks';
4
4
 
5
- type ApiField = {
6
- value?: ApiBlock['value'];
5
+ export type SettingValue = {
6
+ value?: SettingBlock['value'];
7
7
  };
8
8
 
9
- export type ApiBundle = {
10
- getBlock: (id: string) => ApiField | null;
11
- setBlockValue: (key: string, value: ApiBlock['value']) => void;
9
+ export type Bundle = {
10
+ getBlock: (id: string) => SettingValue | null;
11
+ setBlockValue: (key: string, value: SettingBlock['value']) => void;
12
12
  };
package/types/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  /* (c) Copyright Frontify Ltd., all rights reserved. */
2
2
 
3
- import { ApiBlock } from './blocks';
3
+ import { SettingBlock } from './blocks';
4
4
 
5
+ export * from './blocks';
5
6
  export { BaseBlock } from './blocks/base';
6
- export { ApiBundle } from './bundle';
7
+ export { Bundle, SettingValue } from './bundle';
8
+ export { Rule } from './validation';
7
9
 
8
10
  export enum Sections {
9
11
  Main = 'main',
@@ -14,10 +16,10 @@ export enum Sections {
14
16
  Targets = 'targets',
15
17
  }
16
18
 
17
- export type ApiSettings = {
18
- [Sections.Main]?: ApiBlock[];
19
- [Sections.Content]?: ApiBlock[];
20
- [Sections.Layout]?: ApiBlock[];
21
- [Sections.Style]?: ApiBlock[];
22
- [Sections.Security]?: ApiBlock[];
19
+ export type BlockSettings = {
20
+ [Sections.Main]?: SettingBlock[];
21
+ [Sections.Content]?: SettingBlock[];
22
+ [Sections.Layout]?: SettingBlock[];
23
+ [Sections.Style]?: SettingBlock[];
24
+ [Sections.Security]?: SettingBlock[];
23
25
  };