@bpmn-io/form-js-viewer 1.1.0 → 1.3.0-alpha.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.
Files changed (32) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +164 -164
  3. package/dist/assets/form-js-base.css +985 -932
  4. package/dist/assets/form-js.css +54 -1
  5. package/dist/index.cjs +1151 -745
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.es.js +1147 -744
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/types/Form.d.ts +4 -0
  10. package/dist/types/core/FieldFactory.d.ts +19 -0
  11. package/dist/types/core/FormFieldRegistry.d.ts +0 -1
  12. package/dist/types/core/Importer.d.ts +56 -0
  13. package/dist/types/core/PathRegistry.d.ts +71 -0
  14. package/dist/types/core/index.d.ts +9 -5
  15. package/dist/types/features/expression-language/ConditionChecker.d.ts +3 -2
  16. package/dist/types/index.d.ts +2 -2
  17. package/dist/types/render/components/form-fields/Checklist.d.ts +2 -6
  18. package/dist/types/render/components/form-fields/Default.d.ts +3 -3
  19. package/dist/types/render/components/form-fields/Group.d.ts +14 -0
  20. package/dist/types/render/components/form-fields/Radio.d.ts +2 -6
  21. package/dist/types/render/components/form-fields/Select.d.ts +2 -6
  22. package/dist/types/render/components/form-fields/Taglist.d.ts +2 -6
  23. package/dist/types/render/components/form-fields/parts/Grid.d.ts +1 -0
  24. package/dist/types/render/components/index.d.ts +3 -2
  25. package/dist/types/render/components/util/localisationUtil.d.ts +24 -0
  26. package/dist/types/render/components/util/valuesUtil.d.ts +6 -0
  27. package/dist/types/render/context/FormRenderContext.d.ts +3 -0
  28. package/dist/types/types.d.ts +35 -35
  29. package/dist/types/util/index.d.ts +1 -2
  30. package/package.json +3 -2
  31. package/dist/types/import/Importer.d.ts +0 -45
  32. package/dist/types/import/index.d.ts +0 -5
@@ -139,6 +139,10 @@ export default class Form {
139
139
  * @internal
140
140
  */
141
141
  _applyConditions(toFilter: any, data: any): any;
142
+ /**
143
+ * @internal
144
+ */
145
+ _initializeFieldData(data: any): any;
142
146
  }
143
147
  export type Injector = import('./types').Injector;
144
148
  export type Data = import('./types').Data;
@@ -0,0 +1,19 @@
1
+ declare class FieldFactory {
2
+ /**
3
+ * @constructor
4
+ *
5
+ * @param formFieldRegistry
6
+ * @param formFields
7
+ */
8
+ constructor(formFieldRegistry: any, pathRegistry: any, formFields: any);
9
+ _formFieldRegistry: any;
10
+ _pathRegistry: any;
11
+ _formFields: any;
12
+ create(attrs: any, applyDefaults?: boolean): any;
13
+ _ensureId(field: any): void;
14
+ _ensureKey(field: any): void;
15
+ }
16
+ declare namespace FieldFactory {
17
+ const $inject: string[];
18
+ }
19
+ export default FieldFactory;
@@ -3,7 +3,6 @@ declare class FormFieldRegistry {
3
3
  _eventBus: any;
4
4
  _formFields: {};
5
5
  _ids: any;
6
- _keys: any;
7
6
  add(formField: any): void;
8
7
  remove(formField: any): void;
9
8
  get(id: any): any;
@@ -0,0 +1,56 @@
1
+ declare class Importer {
2
+ /**
3
+ * @constructor
4
+ * @param { import('./FormFieldRegistry').default } formFieldRegistry
5
+ * @param { import('./PathRegistry').default } pathRegistry
6
+ * @param { import('./FieldFactory').default } fieldFactory
7
+ * @param { import('./FormLayouter').default } formLayouter
8
+ */
9
+ constructor(formFieldRegistry: import('./FormFieldRegistry').default, pathRegistry: import('./PathRegistry').default, fieldFactory: import('./FieldFactory').default, formLayouter: import('./FormLayouter').default);
10
+ _formFieldRegistry: import("./FormFieldRegistry").default;
11
+ _pathRegistry: import("./PathRegistry").default;
12
+ _fieldFactory: import("./FieldFactory").default;
13
+ _formLayouter: import("./FormLayouter").default;
14
+ /**
15
+ * Import schema creating rows, fields, attaching additional
16
+ * information to each field and adding fields to the
17
+ * field registry.
18
+ *
19
+ * Additional information attached:
20
+ *
21
+ * * `id` (unless present)
22
+ * * `_parent`
23
+ * * `_path`
24
+ *
25
+ * @param {any} schema
26
+ *
27
+ * @typedef {{ warnings: Error[], schema: any }} ImportResult
28
+ * @returns {ImportResult}
29
+ */
30
+ importSchema(schema: any): {
31
+ warnings: Error[];
32
+ schema: any;
33
+ };
34
+ _cleanup(): void;
35
+ /**
36
+ * @param {{[x: string]: any}} fieldAttrs
37
+ * @param {String} [parentId]
38
+ * @param {number} [index]
39
+ *
40
+ * @return {any} field
41
+ */
42
+ importFormField(fieldAttrs: {
43
+ [x: string]: any;
44
+ }, parentId?: string, index?: number): any;
45
+ /**
46
+ * @param {Array<any>} components
47
+ * @param {string} parentId
48
+ *
49
+ * @return {Array<any>} imported components
50
+ */
51
+ importFormFields(components: Array<any>, parentId: string): Array<any>;
52
+ }
53
+ declare namespace Importer {
54
+ const $inject: string[];
55
+ }
56
+ export default Importer;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The PathRegistry class manages a hierarchical structure of paths associated with form fields.
3
+ * It enables claiming, unclaiming, and validating paths within this structure.
4
+ *
5
+ * Example Tree Structure:
6
+ *
7
+ * [
8
+ * {
9
+ * segment: 'root',
10
+ * claimCount: 1,
11
+ * children: [
12
+ * {
13
+ * segment: 'child1',
14
+ * claimCount: 2,
15
+ * children: null // A leaf node (closed path)
16
+ * },
17
+ * {
18
+ * segment: 'child2',
19
+ * claimCount: 1,
20
+ * children: [
21
+ * {
22
+ * segment: 'subChild1',
23
+ * claimCount: 1,
24
+ * children: [] // An open node (open path)
25
+ * }
26
+ * ]
27
+ * }
28
+ * ]
29
+ * }
30
+ * ]
31
+ */
32
+ declare class PathRegistry {
33
+ constructor(formFieldRegistry: any, formFields: any);
34
+ _formFieldRegistry: any;
35
+ _formFields: any;
36
+ _dataPaths: any[];
37
+ canClaimPath(path: any, closed?: boolean): boolean;
38
+ claimPath(path: any, closed?: boolean): void;
39
+ unclaimPath(path: any): void;
40
+ /**
41
+ * Applies a function (fn) recursively on a given field and its children.
42
+ *
43
+ * - `field`: Starting field object.
44
+ * - `fn`: Function to apply.
45
+ * - `context`: Optional object for passing data between calls.
46
+ *
47
+ * Stops early if `fn` returns `false`. Useful for traversing the form field tree.
48
+ *
49
+ * @returns {boolean} Success status based on function execution.
50
+ */
51
+ executeRecursivelyOnFields(field: any, fn: any, context?: {}): boolean;
52
+ /**
53
+ * Generates an array representing the binding path to an underlying data object for a form field.
54
+ *
55
+ * @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
56
+ * @param {Object} [options={}] - Configuration options.
57
+ * @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
58
+ * @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
59
+ *
60
+ * @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
61
+ */
62
+ getValuePath(field: any, options?: {
63
+ replacements?: any;
64
+ cutoffNode?: any;
65
+ }): (Array<string> | undefined);
66
+ clear(): void;
67
+ }
68
+ declare namespace PathRegistry {
69
+ const $inject: string[];
70
+ }
71
+ export default PathRegistry;
@@ -1,19 +1,23 @@
1
1
  declare namespace _default {
2
- const __depends__: ({
3
- importer: (string | typeof import("../import/Importer").default)[];
4
- } | {
2
+ const __depends__: {
5
3
  __init__: string[];
6
4
  formFields: (string | typeof import("../render").FormFields)[];
7
5
  renderer: (string | typeof import("../render/Renderer").default)[];
8
- })[];
6
+ }[];
9
7
  const eventBus: (string | typeof EventBus)[];
8
+ const importer: (string | typeof Importer)[];
9
+ const fieldFactory: (string | typeof FieldFactory)[];
10
10
  const formFieldRegistry: (string | typeof FormFieldRegistry)[];
11
+ const pathRegistry: (string | typeof PathRegistry)[];
11
12
  const formLayouter: (string | typeof FormLayouter)[];
12
13
  const validator: (string | typeof Validator)[];
13
14
  }
14
15
  export default _default;
16
+ import Importer from './Importer';
17
+ import FieldFactory from './FieldFactory';
15
18
  import FormFieldRegistry from './FormFieldRegistry';
19
+ import PathRegistry from './PathRegistry';
16
20
  import FormLayouter from './FormLayouter';
17
21
  import EventBus from './EventBus';
18
22
  import Validator from './Validator';
19
- export { FormFieldRegistry, FormLayouter };
23
+ export { Importer, FieldFactory, FormFieldRegistry, PathRegistry, FormLayouter };
@@ -3,8 +3,9 @@
3
3
  * @property {string} [hide]
4
4
  */
5
5
  declare class ConditionChecker {
6
- constructor(formFieldRegistry: any, eventBus: any);
6
+ constructor(formFieldRegistry: any, pathRegistry: any, eventBus: any);
7
7
  _formFieldRegistry: any;
8
+ _pathRegistry: any;
8
9
  _eventBus: any;
9
10
  /**
10
11
  * For given data, remove properties based on condition.
@@ -38,7 +39,7 @@ declare class ConditionChecker {
38
39
  _checkHideCondition(condition: Condition, data: {
39
40
  [x: string]: any;
40
41
  }): boolean;
41
- _getConditions(): any;
42
+ _clearObjectValueRecursively(valuePath: any, obj: any): void;
42
43
  }
43
44
  declare namespace ConditionChecker {
44
45
  const $inject: string[];
@@ -14,6 +14,6 @@ export * from "./util";
14
14
  export * from "./features";
15
15
  export type CreateFormOptions = import('./types').CreateFormOptions;
16
16
  import Form from './Form';
17
- export const schemaVersion: 10;
17
+ export const schemaVersion: 11;
18
18
  export { Form };
19
- export { FormFieldRegistry, FormLayouter } from "./core";
19
+ export { FormFieldRegistry, FormLayouter, Importer, FieldFactory, PathRegistry } from "./core";
@@ -7,14 +7,10 @@ declare namespace Checklist {
7
7
  export const group: string;
8
8
  export const emptyValue: any[];
9
9
  export { sanitizeMultiSelectValue as sanitizeValue };
10
- export function create(options?: {}): {
11
- values: {
12
- label: string;
13
- value: string;
14
- }[];
15
- };
10
+ export { createEmptyOptions as create };
16
11
  }
17
12
  }
18
13
  export default Checklist;
19
14
  declare const type: "checklist";
20
15
  import { sanitizeMultiSelectValue } from '../util/sanitizerUtil';
16
+ import { createEmptyOptions } from '../util/valuesUtil';
@@ -1,5 +1,5 @@
1
- declare function Default(props: any): import("preact").JSX.Element;
2
- declare namespace Default {
1
+ declare function FormComponent(props: any): import("preact").JSX.Element;
2
+ declare namespace FormComponent {
3
3
  namespace config {
4
4
  const type: string;
5
5
  const keyed: boolean;
@@ -10,4 +10,4 @@ declare namespace Default {
10
10
  };
11
11
  }
12
12
  }
13
- export default Default;
13
+ export default FormComponent;
@@ -0,0 +1,14 @@
1
+ declare function Group(props: any): import("preact").JSX.Element;
2
+ declare namespace Group {
3
+ namespace config {
4
+ const type: string;
5
+ const pathed: boolean;
6
+ const label: string;
7
+ const group: string;
8
+ function create(options?: {}): {
9
+ components: any[];
10
+ showOutline: boolean;
11
+ };
12
+ }
13
+ }
14
+ export default Group;
@@ -7,14 +7,10 @@ declare namespace Radio {
7
7
  export const group: string;
8
8
  export const emptyValue: any;
9
9
  export { sanitizeSingleSelectValue as sanitizeValue };
10
- export function create(options?: {}): {
11
- values: {
12
- label: string;
13
- value: string;
14
- }[];
15
- };
10
+ export { createEmptyOptions as create };
16
11
  }
17
12
  }
18
13
  export default Radio;
19
14
  declare const type: "radio";
20
15
  import { sanitizeSingleSelectValue } from '../util/sanitizerUtil';
16
+ import { createEmptyOptions } from '../util/valuesUtil';
@@ -7,14 +7,10 @@ declare namespace Select {
7
7
  export const group: string;
8
8
  export const emptyValue: any;
9
9
  export { sanitizeSingleSelectValue as sanitizeValue };
10
- export function create(options?: {}): {
11
- values: {
12
- label: string;
13
- value: string;
14
- }[];
15
- };
10
+ export { createEmptyOptions as create };
16
11
  }
17
12
  }
18
13
  export default Select;
19
14
  declare const type: "select";
20
15
  import { sanitizeSingleSelectValue } from '../util/sanitizerUtil';
16
+ import { createEmptyOptions } from '../util/valuesUtil';
@@ -7,14 +7,10 @@ declare namespace Taglist {
7
7
  export const group: string;
8
8
  export const emptyValue: any[];
9
9
  export { sanitizeMultiSelectValue as sanitizeValue };
10
- export function create(options?: {}): {
11
- values: {
12
- label: string;
13
- value: string;
14
- }[];
15
- };
10
+ export { createEmptyOptions as create };
16
11
  }
17
12
  }
18
13
  export default Taglist;
19
14
  declare const type: "taglist";
20
15
  import { sanitizeMultiSelectValue } from '../util/sanitizerUtil';
16
+ import { createEmptyOptions } from '../util/valuesUtil';
@@ -0,0 +1 @@
1
+ export default function Grid(props: any): import("preact").JSX.Element;
@@ -1,4 +1,4 @@
1
- export const formFields: (typeof Default | typeof Image)[];
1
+ export const formFields: (typeof Default | typeof Group | typeof Image)[];
2
2
  export * from "./icons";
3
3
  import Button from './form-fields/Button';
4
4
  import Checkbox from './form-fields/Checkbox';
@@ -6,6 +6,7 @@ import Checklist from './form-fields/Checklist';
6
6
  import Default from './form-fields/Default';
7
7
  import Datetime from './form-fields/Datetime';
8
8
  import FormComponent from './FormComponent';
9
+ import Group from './form-fields/Group';
9
10
  import Image from './form-fields/Image';
10
11
  import Numberfield from './form-fields/Number';
11
12
  import Radio from './form-fields/Radio';
@@ -15,4 +16,4 @@ import Taglist from './form-fields/Taglist';
15
16
  import Text from './form-fields/Text';
16
17
  import Textfield from './form-fields/Textfield';
17
18
  import Textarea from './form-fields/Textarea';
18
- export { Button, Checkbox, Checklist, Default, Datetime, FormComponent, Image, Numberfield, Radio, Select, Spacer, Taglist, Text, Textfield, Textarea };
19
+ export { Button, Checkbox, Checklist, Default, Datetime, FormComponent, Group, Image, Numberfield, Radio, Select, Spacer, Taglist, Text, Textfield, Textarea };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Returns date format for the provided locale.
3
+ * If the locale is not provided, uses the browser's locale.
4
+ *
5
+ * @param {string} [locale] - The locale to get date format for.
6
+ * @returns {string} The date format for the locale.
7
+ */
8
+ export function getLocaleDateFormat(locale?: string): string;
9
+ /**
10
+ * Returns readable date format for the provided locale.
11
+ * If the locale is not provided, uses the browser's locale.
12
+ *
13
+ * @param {string} [locale] - The locale to get readable date format for.
14
+ * @returns {string} The readable date format for the locale.
15
+ */
16
+ export function getLocaleReadableDateFormat(locale?: string): string;
17
+ /**
18
+ * Returns flatpickr config for the provided locale.
19
+ * If the locale is not provided, uses the browser's locale.
20
+ *
21
+ * @param {string} [locale] - The locale to get flatpickr config for.
22
+ * @returns {object} The flatpickr config for the locale.
23
+ */
24
+ export function getLocaleDateFlatpickrConfig(locale?: string): object;
@@ -1,2 +1,8 @@
1
1
  export function getValuesData(formField: any, formData: any): any;
2
2
  export function normalizeValuesData(valuesData: any): any;
3
+ export function createEmptyOptions(options?: {}): {
4
+ values: {
5
+ label: string;
6
+ value: string;
7
+ }[];
8
+ };
@@ -1,8 +1,11 @@
1
1
  export default FormRenderContext;
2
2
  declare const FormRenderContext: import("preact").Context<{
3
+ EmptyRoot: (props: any) => any;
3
4
  Empty: (props: any) => any;
4
5
  Children: (props: any) => import("preact").JSX.Element;
5
6
  Element: (props: any) => import("preact").JSX.Element;
6
7
  Row: (props: any) => import("preact").JSX.Element;
7
8
  Column: (props: any) => any;
9
+ hoveredId: any[];
10
+ setHoveredId: (newValue: any) => void;
8
11
  }>;
@@ -1,36 +1,36 @@
1
- import { Injector } from 'didi';
2
-
3
- export type Module = any;
4
- export type Schema = any;
5
-
6
- export interface Data {
7
- [x: string]: any;
8
- }
9
-
10
- export interface Errors {
11
- [x: string]: string[];
12
- }
13
-
14
- export type FormProperty = ('readOnly' | 'disabled' | string);
15
- export type FormEvent = ('submit' | 'changed' | string);
16
-
17
- export interface FormProperties {
18
- [x: string]: any;
19
- }
20
-
21
- export interface FormOptions {
22
- additionalModules?: Module[];
23
- container?: Element | null | string;
24
- injector?: Injector;
25
- modules?: Module[];
26
- properties?: FormProperties;
27
- }
28
-
29
- export interface CreateFormOptions extends FormOptions {
30
- data?: Data;
31
- schema: Schema;
32
- }
33
-
34
- export {
35
- Injector
1
+ import { Injector } from 'didi';
2
+
3
+ export type Module = any;
4
+ export type Schema = any;
5
+
6
+ export interface Data {
7
+ [x: string]: any;
8
+ }
9
+
10
+ export interface Errors {
11
+ [x: string]: string[];
12
+ }
13
+
14
+ export type FormProperty = ('readOnly' | 'disabled' | string);
15
+ export type FormEvent = ('submit' | 'changed' | string);
16
+
17
+ export interface FormProperties {
18
+ [x: string]: any;
19
+ }
20
+
21
+ export interface FormOptions {
22
+ additionalModules?: Module[];
23
+ container?: Element | null | string;
24
+ injector?: Injector;
25
+ modules?: Module[];
26
+ properties?: FormProperties;
27
+ }
28
+
29
+ export interface CreateFormOptions extends FormOptions {
30
+ data?: Data;
31
+ schema: Schema;
32
+ }
33
+
34
+ export {
35
+ Injector
36
36
  };
@@ -1,8 +1,6 @@
1
- export function findErrors(errors: any, path: any): any;
2
1
  export function isRequired(field: any): any;
3
2
  export function pathParse(path: any): any;
4
3
  export function pathsEqual(a: any, b: any): any;
5
- export function pathStringify(path: any): any;
6
4
  export function generateIndexForType(type: any): any;
7
5
  export function generateIdForType(type: any): string;
8
6
  /**
@@ -20,6 +18,7 @@ export function clone<T>(data: T, replacer?: (this: any, key: string, value: any
20
18
  * @return {string[]}
21
19
  */
22
20
  export function getSchemaVariables(schema: any, options?: {}): string[];
21
+ export function runRecursively(formField: any, fn: any): void;
23
22
  export * from "./constants";
24
23
  export * from "./injector";
25
24
  export * from "./form";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmn-io/form-js-viewer",
3
- "version": "1.1.0",
3
+ "version": "1.3.0-alpha.0",
4
4
  "description": "View forms - powered by bpmn.io",
5
5
  "exports": {
6
6
  ".": {
@@ -22,6 +22,7 @@
22
22
  "all": "run-s test build",
23
23
  "build": "run-p bundle bundle:scss generate-types",
24
24
  "start": "SINGLE_START=basic npm run dev",
25
+ "start:groups": "SINGLE_START=groups npm run dev",
25
26
  "bundle": "rollup -c --failAfterWarnings --bundleConfigAsCjs",
26
27
  "bundle:scss": "sass --no-source-map --load-path=\"../../node_modules\" assets/index.scss dist/assets/form-js.css",
27
28
  "bundle:watch": "run-p bundle:watch-js bundle:watch-scss",
@@ -62,5 +63,5 @@
62
63
  "files": [
63
64
  "dist"
64
65
  ],
65
- "gitHead": "6bfb194e07fe44d3309744507f9f874cf8e94169"
66
+ "gitHead": "dd5504e512c13945767159900dc8cf884834b937"
66
67
  }
@@ -1,45 +0,0 @@
1
- declare class Importer {
2
- /**
3
- * @constructor
4
- * @param { import('../core').FormFieldRegistry } formFieldRegistry
5
- * @param { import('../render/FormFields').default } formFields
6
- * @param { import('../core').FormLayouter } formLayouter
7
- */
8
- constructor(formFieldRegistry: import('../core').FormFieldRegistry, formFields: import('../render/FormFields').default, formLayouter: import('../core').FormLayouter);
9
- _formFieldRegistry: import("../core").FormFieldRegistry;
10
- _formFields: import("../render/FormFields").default;
11
- _formLayouter: import("../core").FormLayouter;
12
- /**
13
- * Import schema adding `id`, `_parent` and `_path`
14
- * information to each field and adding it to the
15
- * form field registry.
16
- *
17
- * @param {any} schema
18
- * @param {any} [data]
19
- *
20
- * @return { { warnings: Array<any>, schema: any, data: any } }
21
- */
22
- importSchema(schema: any, data?: any): {
23
- warnings: Array<any>;
24
- schema: any;
25
- data: any;
26
- };
27
- /**
28
- * @param {any} formField
29
- * @param {string} [parentId]
30
- *
31
- * @return {any} importedField
32
- */
33
- importFormField(formField: any, parentId?: string): any;
34
- importFormFields(components: any, parentId: any): void;
35
- /**
36
- * @param {Object} data
37
- *
38
- * @return {Object} initializedData
39
- */
40
- initializeFieldValues(data: any): any;
41
- }
42
- declare namespace Importer {
43
- const $inject: string[];
44
- }
45
- export default Importer;
@@ -1,5 +0,0 @@
1
- declare namespace _default {
2
- const importer: (string | typeof Importer)[];
3
- }
4
- export default _default;
5
- import Importer from './Importer';