@genesislcap/foundation-forms 14.116.1 → 14.117.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
@@ -356,7 +356,7 @@ const arrayUISchema = {
356
356
  type: "VerticalLayout",
357
357
  elements: [
358
358
  {
359
- type: "array",
359
+ type: "Control",
360
360
  scope: "#/properties/users",
361
361
  options: {
362
362
  childUiSchema: {
@@ -421,7 +421,7 @@ const categoryUISchema = {
421
421
  type: "Categorization",
422
422
  elements: [
423
423
  {
424
- type: "Category",
424
+ type: "Control",
425
425
  scope: "#/properties/basic",
426
426
  label: "Personal information",
427
427
  options: {
@@ -443,7 +443,7 @@ const categoryUISchema = {
443
443
  },
444
444
  },
445
445
  {
446
- type: "Category",
446
+ type: "Control",
447
447
  label: "Address",
448
448
  scope: "#/properties/address",
449
449
  options: {
@@ -540,7 +540,7 @@ const uiSchemaStepper = {
540
540
  type: 'Stepper',
541
541
  elements: [
542
542
  {
543
- type: 'Step',
543
+ type: 'Control',
544
544
  scope: '#/properties/person',
545
545
  label: 'Entity',
546
546
  options: {
@@ -575,7 +575,7 @@ const uiSchemaStepper = {
575
575
  },
576
576
  },
577
577
  {
578
- type: 'Step',
578
+ type: 'Control',
579
579
  label: 'Doc',
580
580
  scope: '#/properties/address',
581
581
  options: {
@@ -610,7 +610,7 @@ const uiSchemaStepper = {
610
610
  },
611
611
  },
612
612
  {
613
- type: 'Step',
613
+ type: 'Control',
614
614
  label: 'Primary doc',
615
615
  scope: '#/properties/vegetarianOptions',
616
616
  options: {
@@ -1 +1 @@
1
- {"version":3,"file":"StringControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/StringControlRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,gCAAgC,YAAY,MAAM,0EAwB9D,CAAC;AACF,eAAO,MAAM,6BAA6B,uEAEzC,CAAC"}
1
+ {"version":3,"file":"StringControlRenderer.d.ts","sourceRoot":"","sources":["../../../../src/jsonforms/renderers/StringControlRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AASvD,eAAO,MAAM,gCAAgC,YAAY,MAAM,0EAsC9D,CAAC;AACF,eAAO,MAAM,6BAA6B,uEAEzC,CAAC"}
@@ -3,43 +3,195 @@ import { JsonFormsState, OwnPropsOfControl, RankedTester, StatePropsOfControl }
3
3
  import { ViewTemplate } from '@microsoft/fast-element';
4
4
  import { ErrorObject } from 'ajv';
5
5
  import { DispatchRenderer } from './jsonforms/renderers/dispatch-renderer';
6
- /** @public */
7
- export type UiSchemaElementType = 'Control' | 'VerticalLayout' | any;
8
- /** @public */
6
+ /**
7
+ * The layouts and control types, which allow you to customize the arrangement of forms.
8
+ * @public
9
+ * */
10
+ export type UiSchemaElementType = 'Control' | 'VerticalLayout' | 'LayoutVertical2Columns' | 'Categorization' | 'Group' | 'Stepper' | 'HorizontalLayout';
11
+ /**
12
+ * Available orientation for stepper renderer.
13
+ * @public
14
+ */
9
15
  export type StepperOrientationType = 'vertical' | 'horizontal';
10
- /** @public */
11
- export type UiSchemaElementOptions = {
16
+ /**
17
+ * Available configuration options for connected combobox/multiselect.
18
+ * @public
19
+ */
20
+ export type ConnectedRenderersOptions = {
21
+ /**
22
+ * Activates the async search by changing the criteria based on the value from the search-bar.
23
+ * @public
24
+ */
12
25
  async?: boolean;
13
- orientation?: StepperOrientationType;
26
+ /**
27
+ * The name of the target Data Server query or Request Server requestReply.
28
+ * @public
29
+ */
14
30
  allOptionsResourceName?: string;
31
+ /**
32
+ * A property that is set to configure the resource to which combobox/multiselect is connected.
33
+ * @public
34
+ */
15
35
  datasourceConfig?: DatasourceOptions;
16
- hidden?: boolean;
17
- isPassword?: boolean;
18
- validateFn?: (data: any, path: string, label: string) => ErrorObject[];
36
+ /**
37
+ * Specifies which field should be used as underlying data used when changing selection.
38
+ * @public
39
+ */
19
40
  valueField?: string;
41
+ /**
42
+ * Field used to display label for the component.
43
+ * @public
44
+ */
20
45
  labelField?: string;
21
- textarea?: boolean;
46
+ /**
47
+ * Property to which we can provide the data to be used instead of data from the server.
48
+ * @public
49
+ */
22
50
  data?: any[];
51
+ };
52
+ /**
53
+ * Configuration options available for array renderer.
54
+ * @public
55
+ */
56
+ export type ArrayRendererOptions = {
57
+ /**
58
+ * ChildUiSchema allows you to pass a UiSchema for a particular element,
59
+ * which can then be multiplied many times by the renderer.
60
+ * @public
61
+ */
23
62
  childUiSchema?: UiSchema;
63
+ };
64
+ /**
65
+ * Orientation options available for stepper renderer.
66
+ * @public
67
+ */
68
+ export type StepperOrientationOptions = {
69
+ /**
70
+ * Configuration options available for the stepper renderer which set the renderer horizontally or vertically.
71
+ * @public
72
+ */
73
+ orientation?: StepperOrientationType;
74
+ };
75
+ /**
76
+ * Configuration options available for categorization renderer.
77
+ * @public
78
+ */
79
+ export type CategorizationRendererOptions = {
80
+ /**
81
+ * childElements allows you to pass the UiSchema array in which the renderers groups will be located
82
+ * @public
83
+ */
24
84
  childElements?: UiSchema[];
85
+ };
86
+ /**
87
+ * Configuration options available for group renderer.
88
+ * @public
89
+ */
90
+ export type GroupRendererOptions = CategorizationRendererOptions;
91
+ /**
92
+ * Configuration options available for stepper renderer.
93
+ * @public
94
+ */
95
+ export type StepperRendererOptions = CategorizationRendererOptions;
96
+ /**
97
+ * Configuration options available for string renderer.
98
+ * @public
99
+ */
100
+ export type StringRendererOptions = {
101
+ /**
102
+ * Changes the type attribute in the string renderer from text to password.
103
+ * @public
104
+ */
105
+ isPassword?: boolean;
106
+ /**
107
+ * Setting this property enables text-area instead of text-field.
108
+ * @public
109
+ */
110
+ textarea?: boolean;
111
+ };
112
+ /**
113
+ * Standard configuration options available for all renderers.
114
+ * @public
115
+ */
116
+ export type StandardRendererOptions = {
117
+ /**
118
+ * Setting this property allows you to hide the renderer.
119
+ * @public
120
+ */
121
+ hidden?: boolean;
122
+ /**
123
+ * Setting this property enables client-side validation.
124
+ * @public
125
+ */
126
+ validateFn?: (data: any, path: string, label: string) => ErrorObject[];
25
127
  i18n?: {
26
128
  [key: string]: any;
27
129
  };
28
130
  };
29
- /** @public */
131
+ /**
132
+ * All configuration options that are available.
133
+ * @public
134
+ */
135
+ export type UiSchemaElementOptions = ConnectedRenderersOptions | ArrayRendererOptions | CategorizationRendererOptions | GroupRendererOptions | StepperRendererOptions | StringRendererOptions | StandardRendererOptions;
136
+ /**
137
+ * A UiSchemaElement that displays property values in a user interface element.
138
+ * @public
139
+ */
30
140
  export type UiSchemaElement = {
141
+ /**
142
+ * The layouts and control types, which allow you to customize the arrangement of forms.
143
+ * @public
144
+ * */
31
145
  type: UiSchemaElementType;
146
+ /**
147
+ * The mandatory scope property, which expects a JSON schema reference value, defines to which property of the data the control should be bound to.
148
+ * @public
149
+ */
32
150
  scope: string;
151
+ /**
152
+ * By default, controls use the name of property they point to as a label.
153
+ * Setting this property allows you to change the label.
154
+ * @public
155
+ */
33
156
  label?: string;
157
+ /**
158
+ * Setting this property allows you to change the placeholder in input renderers.
159
+ * @public
160
+ */
34
161
  placeholder?: string;
162
+ /**
163
+ * Optional attribute options that determine how the control is rendered.
164
+ * @public
165
+ */
35
166
  options?: UiSchemaElementOptions;
36
167
  };
37
- /** @public */
168
+ /**
169
+ * The UI schema, which is passed to JSON Forms, describes the general layout of a form and is just a regular JSON object.
170
+ * It describes the form by means of different UI schema elements, which can often be categorized into either Controls or Layouts.
171
+ * @public
172
+ */
38
173
  export type UiSchema = {
174
+ /**
175
+ * The layouts and control types, which allow you to customize the arrangement of forms.
176
+ * @public
177
+ * */
39
178
  type: UiSchemaElementType;
179
+ /**
180
+ * All layouts need to declare an elements property which contains the children which are to be arranged by the layout.
181
+ * It is expected to be an array of UI Schema elements, e.g. controls or other layouts.
182
+ * @public
183
+ */
40
184
  elements: UiSchemaElement[];
185
+ /**
186
+ * Allows changing the design-system for renderers.
187
+ * @public
188
+ */
41
189
  dsPrefix?: string;
42
- options?: UiSchemaElementOptions;
190
+ /**
191
+ * Options for changing the orientation for the stepper renderer.
192
+ * @public
193
+ */
194
+ options?: StepperOrientationOptions;
43
195
  };
44
196
  /** @public */
45
197
  export type RendererEntry = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,cAAc;AACd,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,gBAAgB,GAAG,GAAG,CAAC;AAErE,cAAc;AACd,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,YAAY,CAAC;AAE/D,cAAc;AACd,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,EAAE,CAAC;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;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enElse } from '@genesislcap/foundation-utils';
1
2
  import { html } from '@microsoft/fast-element';
2
3
  // <pre>${(x) => JSON.stringify(x.control, null, 2)}</pre>
4
+ function changeHandler(x, c) {
5
+ const inputValue = c.event.target.value;
6
+ x.control.handleChange(x.control.path, inputValue === '' ? null : inputValue);
7
+ }
3
8
  export const getStringControlRendererTemplate = (prefix = 'zero') => html `
4
9
  <template>
5
10
  <control-wrapper
@@ -7,21 +12,31 @@ export const getStringControlRendererTemplate = (prefix = 'zero') => html `
7
12
  :touched=${(x) => x.touched}
8
13
  ?submitted=${(x) => x.submitted}
9
14
  >
10
- <${prefix}-text-field
11
- type=${(x) => { var _a, _b; return (((_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.isPassword) ? 'password' : 'text'); }}
12
- :value=${(x) => x.control.data || ''}
13
- @change=${(x, c) => {
14
- const inputValue = c.event.target.value;
15
- x.control.handleChange(x.control.path, inputValue === '' ? null : inputValue);
16
- }}
17
- placeholder=${(x) => x.control.uischema.placeholder || x.control.label}
18
- id=${(x) => x.control.path}
19
- data-test-id=${(x) => x.control.path}
20
- ?required=${(x) => x.control.required}
21
- ?disabled=${(x) => !x.control.enabled}
22
- style="width: 100%"
23
- @blur=${(x) => x.onBlur()}
24
- ></${prefix}-text-field>
15
+ ${whenElse((x) => { var _a, _b; return !((_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.textarea); }, html `
16
+ <${prefix}-text-field
17
+ type=${(x) => { var _a, _b; return (((_b = (_a = x.control.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.isPassword) ? 'password' : 'text'); }}
18
+ :value=${(x) => x.control.data || ''}
19
+ @change=${changeHandler}
20
+ placeholder=${(x) => x.control.uischema.placeholder || x.control.label}
21
+ id=${(x) => x.control.path}
22
+ data-test-id=${(x) => x.control.path}
23
+ ?required=${(x) => x.control.required}
24
+ ?disabled=${(x) => !x.control.enabled}
25
+ style="width: 100%"
26
+ @blur=${(x) => x.onBlur()}
27
+ ></${prefix}-text-field>`, html `
28
+ <${prefix}-text-area
29
+ :value=${(x) => x.control.data || ''}
30
+ @change=${changeHandler}
31
+ placeholder=${(x) => x.control.uischema.placeholder || x.control.label}
32
+ id=${(x) => x.control.path}
33
+ data-test-id=${(x) => x.control.path}
34
+ ?required=${(x) => x.control.required}
35
+ ?disabled=${(x) => !x.control.enabled}
36
+ style="width: 100%"
37
+ @blur=${(x) => x.onBlur()}
38
+ ></${prefix}-text-area>
39
+ `)}
25
40
  </control-wrapper>
26
41
  </template>
27
42
  `;