@ws-ui/shared 0.1.18 → 0.1.19

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,4 +1,4 @@
1
- import { FileFolderTypeWithContent, FolderRootType, IAddFolderRequest, IAddFolderResponse, IAppSettingsResponse, ICheckUpdatesRequest, ICheckUpdatesResponse, IDropFileRequest, IDropFolderRequest, IFileInfoResponse, IGetFileInfo, IGetFileRequest, IGetFolderRequest, IGetFolderResponse, IInstallUpdatesRequest, IMonacoThemeResponse, IRenameFileRequest, IRenameFileResponse, IRenameFolderRequest, IRenameFolderResponse, ISetFileContentRequest, ISharedCSSResponse, ISharedDatasourcesResponse, RemoteDebuggerMode } from '../types/api';
1
+ import { FileFolderTypeWithContent, FolderRootType, IAddFolderRequest, IAddFolderResponse, IAppSettingsResponse, ICheckUpdatesRequest, ICheckUpdatesResponse, IDropFileRequest, IDropFolderRequest, IFileInfoResponse, IGetFileInfo, IGetFileRequest, IGetFolderRequest, IGetFolderResponse, IInstallUpdatesRequest, IMonacoThemeResponse, IRenameFileRequest, IRenameFileResponse, IRenameFolderRequest, IRenameFolderResponse, ISetFileContentRequest, ISharedCSSResponse, ISharedConditionsResponse, ISharedDatasourcesResponse, RemoteDebuggerMode } from '../types/api';
2
2
  import { IComponentTemplate } from '../types/webform-editor';
3
3
  /**
4
4
  * Check updates
@@ -104,6 +104,7 @@ export interface ISetFileContentResponse {
104
104
  }
105
105
  export declare function getSharedDatasources(): Promise<ISharedDatasourcesResponse>;
106
106
  export declare function getSharedCSS(): Promise<ISharedCSSResponse>;
107
+ export declare function getSharedConditions(): Promise<ISharedConditionsResponse>;
107
108
  export declare function getMonacoTheme(): Promise<IMonacoThemeResponse>;
108
109
  export declare const setSharedSources: (datasources: {
109
110
  [key: string]: datasources.ICreateDataSource[];
@@ -4,6 +4,7 @@
4
4
  import { IEditor } from '../types/explorer';
5
5
  import { editor as MonacoEditor } from 'monaco-editor';
6
6
  import { IWebFormStyleClass } from '../types/webform-editor';
7
+ import { WebformStateCondition } from '../types/webform-state';
7
8
  export declare enum FolderRootType {
8
9
  /**
9
10
  * Represent the methods folder
@@ -538,4 +539,7 @@ export type ISharedDatasourcesResponse = {
538
539
  export type ISharedCSSResponse = {
539
540
  classes: IWebFormStyleClass[];
540
541
  };
542
+ export type ISharedConditionsResponse = {
543
+ conditions: WebformStateCondition[];
544
+ };
541
545
  export type IMonacoThemeResponse = MonacoEditor.IStandaloneThemeData | null;
@@ -1,6 +1,7 @@
1
1
  export * from './api';
2
2
  export * from './explorer';
3
3
  export * from './webform-editor';
4
+ export * from './webform-state';
4
5
  export * from './code-editor';
5
6
  export * from './utils';
6
7
  export * from './welcome-tour';
@@ -1,8 +1,5 @@
1
1
  import { SerializedNodes } from '@ws-ui/craftjs-core';
2
- export interface WebformState {
3
- id: string;
4
- label: string;
5
- }
2
+ import { WebformState } from './webform-state';
6
3
  export type IWebFormMetadata = Partial<{
7
4
  v: string;
8
5
  datasources: datasources.ICreateDataSource[];
@@ -0,0 +1,43 @@
1
+ export interface WebformState {
2
+ id: string;
3
+ label: string;
4
+ conditions?: WebformStateCondition;
5
+ }
6
+ export type BaseWebformStateCondition = {
7
+ id: string;
8
+ name: string;
9
+ };
10
+ type GenericCondition<T> = BaseWebformStateCondition & T;
11
+ type CommonOp = 'eq' | 'neq' | 'regex' | 'in' | 'nin';
12
+ type ValueType = 'datasource' | 'hardCoded';
13
+ export type DataSourceCondition = GenericCondition<{
14
+ type: 'datasource';
15
+ path: string;
16
+ value: unknown;
17
+ valueType?: ValueType;
18
+ op: CommonOp | 'gt' | 'gte' | 'lt' | 'lte';
19
+ }>;
20
+ export type PrivilegeCondition = GenericCondition<{
21
+ type: 'privilege';
22
+ value: string;
23
+ valueType?: ValueType;
24
+ op: CommonOp;
25
+ }>;
26
+ export type CombinationCondition = Omit<GenericCondition<{
27
+ type: 'combination';
28
+ op: 'and' | 'or';
29
+ conditions: WebformStateCondition[];
30
+ name?: string;
31
+ }>, 'name'>;
32
+ export type ParentStateCondition = GenericCondition<{
33
+ type: 'parentState';
34
+ value: string;
35
+ valueType?: ValueType;
36
+ op: CommonOp;
37
+ }>;
38
+ export type ReferenceCondition = GenericCondition<{
39
+ type: 'reference';
40
+ ref: string;
41
+ }>;
42
+ export type WebformStateCondition = DataSourceCondition | PrivilegeCondition | CombinationCondition | ParentStateCondition | ReferenceCondition;
43
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ws-ui/shared",
3
3
  "private": false,
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",
@@ -30,7 +30,7 @@
30
30
  "@popperjs/core": "^2.9.2",
31
31
  "@radix-ui/react-popover": "^0.1.6",
32
32
  "@ws-ui/craftjs-core": "^0.2.1-beta.3",
33
- "@ws-ui/icons": "^0.0.12",
33
+ "@ws-ui/icons": "^0.0.13",
34
34
  "classnames": "^2.3.1",
35
35
  "lodash": "^4.17.21",
36
36
  "markdown-to-jsx": "^7.1.3",