@genesislcap/foundation-forms 14.488.1-FUI-2571.1 → 14.488.1

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 (37) hide show
  1. package/dist/custom-elements.json +2 -630
  2. package/dist/dts/form.d.ts +0 -77
  3. package/dist/dts/form.d.ts.map +1 -1
  4. package/dist/dts/form.styles.d.ts.map +1 -1
  5. package/dist/dts/form.template.d.ts.map +1 -1
  6. package/dist/dts/index.d.ts +0 -3
  7. package/dist/dts/index.d.ts.map +1 -1
  8. package/dist/dts/jsonforms/renderers/CategorizationWrapperRenderer.d.ts.map +1 -1
  9. package/dist/dts/react.d.ts +0 -10
  10. package/dist/dts/utils/index.d.ts +0 -1
  11. package/dist/dts/utils/index.d.ts.map +1 -1
  12. package/dist/dts/utils/schema-utils.d.ts +0 -12
  13. package/dist/dts/utils/schema-utils.d.ts.map +1 -1
  14. package/dist/esm/form.js +1 -120
  15. package/dist/esm/form.styles.js +2 -9
  16. package/dist/esm/form.template.js +24 -58
  17. package/dist/esm/index.js +0 -3
  18. package/dist/esm/jsonforms/renderers/CategorizationWrapperRenderer.js +45 -1
  19. package/dist/esm/utils/index.js +0 -1
  20. package/dist/esm/utils/schema-utils.js +0 -48
  21. package/dist/foundation-forms.api.json +13 -1044
  22. package/dist/foundation-forms.d.ts +0 -181
  23. package/dist/react.cjs +0 -7
  24. package/dist/react.mjs +0 -6
  25. package/package.json +15 -15
  26. package/dist/dts/review.d.ts +0 -34
  27. package/dist/dts/review.d.ts.map +0 -1
  28. package/dist/dts/review.styles.d.ts +0 -3
  29. package/dist/dts/review.styles.d.ts.map +0 -1
  30. package/dist/dts/review.template.d.ts +0 -6
  31. package/dist/dts/review.template.d.ts.map +0 -1
  32. package/dist/dts/utils/review-utils.d.ts +0 -55
  33. package/dist/dts/utils/review-utils.d.ts.map +0 -1
  34. package/dist/esm/review.js +0 -63
  35. package/dist/esm/review.styles.js +0 -93
  36. package/dist/esm/review.template.js +0 -38
  37. package/dist/esm/utils/review-utils.js +0 -205
@@ -1,38 +0,0 @@
1
- import { sync } from '@genesislcap/foundation-utils';
2
- import { html, repeat, when } from '@microsoft/fast-element';
3
- /** @internal */
4
- export const getPrefixedReview = (prefix) => html `
5
- <template>
6
- <div class="review-header">
7
- <span class="review-title">${(x) => x.heading}</span>
8
- ${when((x) => x.recordId, html `
9
- <span class="review-id">${(x) => x.recordId}</span>
10
- `)}
11
- </div>
12
- <div class="review-filter">
13
- <${prefix}-text-field
14
- value=${sync((x) => x.filterText, 'string', 'input')}
15
- placeholder="Filter fields..."
16
- class="review-filter-input"
17
- data-test-id="review-filter-input"
18
- ></${prefix}-text-field>
19
- </div>
20
- <div class="review-body">
21
- ${repeat((x) => x.filteredSections, html `
22
- ${when((section) => section.fields.length > 0, html `
23
- <div class="review-section-header">${(section) => { var _a; return (_a = section.title) !== null && _a !== void 0 ? _a : '—'; }}</div>
24
- ${repeat((section) => section.fields, html `
25
- <div class="review-field">
26
- <span class="review-field-label">${(field) => field.label}</span>
27
- <span class="review-field-value">${(field) => field.value}</span>
28
- </div>
29
- `)}
30
- `)}
31
- `)}
32
- </div>
33
- </template>
34
- `;
35
- /** @internal */
36
- export const foundationFormReviewTemplate = html `
37
- ${(x) => getPrefixedReview(x.prefix)}
38
- `;
@@ -1,205 +0,0 @@
1
- import { capitalCase } from 'change-case';
2
- /**
3
- * Flattens `buildReviewSections` output into a single ordered list.
4
- * Section titles are prepended to field labels as "Title — Field".
5
- */
6
- export function buildReviewFields(data, uiSchema, schema) {
7
- return buildReviewSections(data, uiSchema, schema).flatMap((section) => section.fields.map((field) => ({
8
- label: section.title ? `${section.title} — ${field.label}` : field.label,
9
- value: field.value,
10
- })));
11
- }
12
- /**
13
- * Builds the review panel's fields grouped into sections by their nearest `Group` layout.
14
- * Ungrouped fields are collected into a single section with a `null` title (rendered with
15
- * a placeholder heading). Falls back to a flat, single ungrouped section when no UI schema
16
- * is available.
17
- */
18
- export function buildReviewSections(data, uiSchema, schema) {
19
- const sections = [];
20
- const sectionsByTitle = new Map();
21
- const addField = (title, field) => {
22
- let section = sectionsByTitle.get(title);
23
- if (!section) {
24
- section = { title, fields: [] };
25
- sectionsByTitle.set(title, section);
26
- sections.push(section);
27
- }
28
- section.fields.push(field);
29
- };
30
- const walk = (element, groupTitle) => {
31
- var _a, _b, _c, _d, _e;
32
- if (!element)
33
- return;
34
- if (element.type === 'Control' && element.scope) {
35
- if ((_a = element.options) === null || _a === void 0 ? void 0 : _a.hidden)
36
- return;
37
- const match = element.scope.match(/^#\/properties\/(.+)$/);
38
- if (!match)
39
- return;
40
- const fieldName = match[1];
41
- const raw = getDataValueAtPath(data, fieldName);
42
- if (raw === undefined ||
43
- raw === null ||
44
- raw === '' ||
45
- (Array.isArray(raw) && raw.length === 0))
46
- return;
47
- const shortName = fieldName.split('/properties/').pop();
48
- const fieldLabel = element.label || capitalCase(shortName);
49
- const displayValue = (_c = (_b = resolveOptionLabel(raw, element.options)) !== null && _b !== void 0 ? _b : resolveEnumLabel(raw, fieldName, schema)) !== null && _c !== void 0 ? _c : raw;
50
- addField(groupTitle, { label: fieldLabel, value: formatValueForReview(displayValue) });
51
- return;
52
- }
53
- const nextGroup = element.type === 'Group' && element.label ? element.label : groupTitle;
54
- const children = (_d = element.elements) !== null && _d !== void 0 ? _d : (_e = element.options) === null || _e === void 0 ? void 0 : _e.childElements;
55
- if (children) {
56
- for (const child of children) {
57
- walk(child, nextGroup);
58
- }
59
- }
60
- };
61
- if (uiSchema) {
62
- walk(uiSchema, null);
63
- }
64
- else {
65
- for (const [key, raw] of Object.entries(data !== null && data !== void 0 ? data : {})) {
66
- if (raw === undefined || raw === null || raw === '')
67
- continue;
68
- addField(null, { label: capitalCase(key), value: formatValueForReview(raw) });
69
- }
70
- }
71
- return sections;
72
- }
73
- /**
74
- * Filters review sections down to fields whose label or value contains `query`
75
- * (case-insensitive). Sections left with no matching fields are dropped entirely.
76
- * Returns `sections` unchanged when `query` is blank.
77
- */
78
- export function filterReviewSections(sections, query) {
79
- const normalized = query.trim().toLowerCase();
80
- if (!normalized)
81
- return sections;
82
- return sections
83
- .map((section) => ({
84
- title: section.title,
85
- fields: section.fields.filter((field) => field.label.toLowerCase().includes(normalized) ||
86
- field.value.toLowerCase().includes(normalized)),
87
- }))
88
- .filter((section) => section.fields.length > 0);
89
- }
90
- /**
91
- * Recursively walks a UI schema element, collecting visible Control fields into `out`.
92
- * Passes the nearest Group label down so children are labelled "Group — Field".
93
- */
94
- export function collectReviewFields(element, data, out, groupLabel, schema) {
95
- var _a, _b, _c, _d, _e;
96
- if (element.type === 'Control' && element.scope) {
97
- if ((_a = element.options) === null || _a === void 0 ? void 0 : _a.hidden)
98
- return;
99
- const match = element.scope.match(/^#\/properties\/(.+)$/);
100
- if (!match)
101
- return;
102
- const fieldName = match[1];
103
- const raw = getDataValueAtPath(data, fieldName);
104
- if (raw === undefined || raw === null || raw === '' || (Array.isArray(raw) && raw.length === 0))
105
- return;
106
- const shortName = fieldName.split('/properties/').pop();
107
- const fieldLabel = element.label || capitalCase(shortName);
108
- const displayValue = (_c = (_b = resolveOptionLabel(raw, element.options)) !== null && _b !== void 0 ? _b : resolveEnumLabel(raw, fieldName, schema)) !== null && _c !== void 0 ? _c : raw;
109
- out.push({
110
- label: groupLabel ? `${groupLabel} — ${fieldLabel}` : fieldLabel,
111
- value: formatValueForReview(displayValue),
112
- });
113
- return;
114
- }
115
- const nextGroup = element.type === 'Group' && element.label ? element.label : groupLabel;
116
- const children = (_d = element.elements) !== null && _d !== void 0 ? _d : (_e = element.options) === null || _e === void 0 ? void 0 : _e.childElements;
117
- if (children) {
118
- for (const child of children) {
119
- collectReviewFields(child, data, out, nextGroup, schema);
120
- }
121
- }
122
- }
123
- /**
124
- * Looks up the display label for a raw value from `options.data` (used by segmented,
125
- * radio group, and enum-with-explicit-data renderers). Returns `null` when no match found.
126
- */
127
- export function resolveOptionLabel(raw, options) {
128
- var _a;
129
- if (!Array.isArray(options === null || options === void 0 ? void 0 : options.data))
130
- return null;
131
- const entry = options.data.find((item) => item.value === raw);
132
- return (_a = entry === null || entry === void 0 ? void 0 : entry.label) !== null && _a !== void 0 ? _a : null;
133
- }
134
- /**
135
- * For plain enum combobox fields (no options.data), applies the same `capitalCase`
136
- * transform the renderer uses — e.g. `SEMI_ANNUAL` → `Semi Annual`.
137
- * Navigates the JSON schema via the fieldName path to confirm the field is an enum
138
- * before transforming. Returns `null` for non-enum fields.
139
- */
140
- export function resolveEnumLabel(raw, fieldName, schema) {
141
- var _a, _b, _c, _d;
142
- if (typeof raw !== 'string')
143
- return null;
144
- if (!(schema === null || schema === void 0 ? void 0 : schema.properties))
145
- return null;
146
- let fieldSchema = schema;
147
- for (const part of fieldName.split('/properties/')) {
148
- fieldSchema = (_a = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.properties) === null || _a === void 0 ? void 0 : _a[part];
149
- }
150
- if (!fieldSchema)
151
- return null;
152
- // Matches plain `enum: [...]` or nullable `oneOf: [{ enum: [...] }, { type: 'null' }]`
153
- const enumValues = (_b = fieldSchema.enum) !== null && _b !== void 0 ? _b : (_d = (_c = fieldSchema.oneOf) === null || _c === void 0 ? void 0 : _c.find((x) => x.enum)) === null || _d === void 0 ? void 0 : _d.enum;
154
- if (Array.isArray(enumValues) && enumValues.includes(raw)) {
155
- return capitalCase(raw);
156
- }
157
- return null;
158
- }
159
- /**
160
- * Navigates a `/properties/`-separated path in data to support nested object scopes
161
- * such as `ADDRESS/properties/STREET` produced by Group layout UI schemas.
162
- */
163
- export function getDataValueAtPath(data, fieldName) {
164
- return navigateSegments(data, fieldName.split('/properties/'));
165
- }
166
- /** Core traversal — walks `data` one property key at a time. */
167
- function navigateSegments(data, segments) {
168
- let value = data;
169
- for (const segment of segments) {
170
- if (value == null)
171
- return undefined;
172
- value = value[segment];
173
- }
174
- return value;
175
- }
176
- /**
177
- * Converts a raw field value to a display string for the review panel.
178
- * Arrays of primitives are comma-joined; arrays of objects and plain objects
179
- * are rendered as readable `key: value` lines.
180
- */
181
- export function formatValueForReview(value) {
182
- if (Array.isArray(value)) {
183
- if (value.length === 0)
184
- return '';
185
- if (value.every((v) => v === null || typeof v !== 'object')) {
186
- return value.join(', ');
187
- }
188
- return value
189
- .map((item, i) => {
190
- const pairs = Object.entries(item !== null && item !== void 0 ? item : {})
191
- .filter(([, v]) => v !== null && v !== undefined && v !== '')
192
- .map(([k, v]) => `${k}: ${v}`)
193
- .join(', ');
194
- return `[${i + 1}] ${pairs}`;
195
- })
196
- .join('\n');
197
- }
198
- if (typeof value === 'object') {
199
- return Object.entries(value)
200
- .filter(([, v]) => v !== null && v !== undefined && v !== '')
201
- .map(([k, v]) => `${k}: ${v}`)
202
- .join(', ');
203
- }
204
- return String(value);
205
- }