@narrative.io/jsonforms-provider-protocols 3.0.0-beta.2 → 3.0.0-beta.21
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/dist/core/initFormData.d.ts +17 -0
- package/dist/core/initFormData.d.ts.map +1 -0
- package/dist/core/initFormData.js +99 -0
- package/dist/core/initFormData.js.map +1 -0
- package/dist/core/projection.d.ts +4 -0
- package/dist/core/projection.d.ts.map +1 -1
- package/dist/core/projection.js +17 -14
- package/dist/core/projection.js.map +1 -1
- package/dist/core/refs.d.ts +58 -0
- package/dist/core/refs.d.ts.map +1 -0
- package/dist/core/refs.js +70 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/resolveScope.d.ts +6 -0
- package/dist/core/resolveScope.d.ts.map +1 -1
- package/dist/core/resolveScope.js +14 -8
- package/dist/core/resolveScope.js.map +1 -1
- package/dist/core/transforms.d.ts.map +1 -1
- package/dist/core/transforms.js +3 -1
- package/dist/core/transforms.js.map +1 -1
- package/dist/core/types.d.ts +1 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/jsonforms-provider-protocols.css +2 -2
- package/dist/no-eval-ajv.d.ts +70 -0
- package/dist/no-eval-ajv.d.ts.map +1 -0
- package/dist/no-eval-ajv.js +247 -0
- package/dist/no-eval-ajv.js.map +1 -0
- package/dist/vue/components/ProviderAutocomplete.vue.d.ts.map +1 -1
- package/dist/vue/components/ProviderAutocomplete.vue.js +10 -6
- package/dist/vue/components/ProviderAutocomplete.vue.js.map +1 -1
- package/dist/vue/components/ProviderMultiSelect.vue.d.ts.map +1 -1
- package/dist/vue/components/ProviderMultiSelect.vue.js +1 -1
- package/dist/vue/components/ProviderMultiSelect.vue2.js +17 -9
- package/dist/vue/components/ProviderMultiSelect.vue2.js.map +1 -1
- package/dist/vue/components/ProviderSelect.vue.d.ts.map +1 -1
- package/dist/vue/components/ProviderSelect.vue.js +1 -1
- package/dist/vue/components/ProviderSelect.vue2.js +19 -9
- package/dist/vue/components/ProviderSelect.vue2.js.map +1 -1
- package/dist/vue/composables/useDataLayer.d.ts +1 -0
- package/dist/vue/composables/useDataLayer.d.ts.map +1 -1
- package/dist/vue/composables/useDataLayer.js +1 -0
- package/dist/vue/composables/useDataLayer.js.map +1 -1
- package/dist/vue/composables/useDerive.d.ts +1 -1
- package/dist/vue/composables/useDerive.d.ts.map +1 -1
- package/dist/vue/composables/useDerive.js +19 -2
- package/dist/vue/composables/useDerive.js.map +1 -1
- package/dist/vue/composables/useDeriveInitialValue.d.ts +36 -0
- package/dist/vue/composables/useDeriveInitialValue.d.ts.map +1 -0
- package/dist/vue/composables/useDeriveInitialValue.js +125 -0
- package/dist/vue/composables/useDeriveInitialValue.js.map +1 -0
- package/dist/vue/composables/useDirtyValidation.d.ts +3 -3
- package/dist/vue/composables/useDirtyValidation.d.ts.map +1 -1
- package/dist/vue/composables/useDirtyValidation.js +2 -2
- package/dist/vue/composables/useDirtyValidation.js.map +1 -1
- package/dist/vue/composables/useProjection.d.ts +7 -0
- package/dist/vue/composables/useProjection.d.ts.map +1 -1
- package/dist/vue/composables/useProjection.js +87 -4
- package/dist/vue/composables/useProjection.js.map +1 -1
- package/dist/vue/composables/useProvider.d.ts +2 -2
- package/dist/vue/composables/useProvider.d.ts.map +1 -1
- package/dist/vue/composables/useProvider.js +14 -10
- package/dist/vue/composables/useProvider.js.map +1 -1
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +30 -10
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/primevue/JfBoolean.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfBoolean.vue.js +17 -6
- package/dist/vue/primevue/JfBoolean.vue.js.map +1 -1
- package/dist/vue/primevue/JfEnum.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfEnum.vue.js +22 -10
- package/dist/vue/primevue/JfEnum.vue.js.map +1 -1
- package/dist/vue/primevue/JfEnumArray.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfEnumArray.vue.js +20 -10
- package/dist/vue/primevue/JfEnumArray.vue.js.map +1 -1
- package/dist/vue/primevue/JfNumber.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfNumber.vue.js +18 -10
- package/dist/vue/primevue/JfNumber.vue.js.map +1 -1
- package/dist/vue/primevue/JfText.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfText.vue.js +27 -12
- package/dist/vue/primevue/JfText.vue.js.map +1 -1
- package/dist/vue/primevue/JfTextArea.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfTextArea.vue.js +15 -9
- package/dist/vue/primevue/JfTextArea.vue.js.map +1 -1
- package/dist/vue/primevue/index.d.ts.map +1 -1
- package/dist/vue/primevue/index.js +93 -16
- package/dist/vue/primevue/index.js.map +1 -1
- package/dist/vue/utils/autoSelect.js.map +1 -1
- package/dist/vue/utils/placeholder.d.ts +17 -0
- package/dist/vue/utils/placeholder.d.ts.map +1 -0
- package/dist/vue/utils/placeholder.js +17 -0
- package/dist/vue/utils/placeholder.js.map +1 -0
- package/package.json +10 -2
- package/src/core/initFormData.ts +208 -0
- package/src/core/projection.ts +33 -22
- package/src/core/refs.ts +166 -0
- package/src/core/resolveScope.ts +23 -8
- package/src/core/transforms.ts +33 -6
- package/src/core/types.ts +1 -0
- package/src/index.ts +14 -2
- package/src/no-eval-ajv.ts +381 -0
- package/src/vue/components/ProviderAutocomplete.vue +9 -7
- package/src/vue/components/ProviderMultiSelect.vue +20 -15
- package/src/vue/components/ProviderSelect.vue +21 -14
- package/src/vue/composables/useDataLayer.ts +1 -1
- package/src/vue/composables/useDerive.ts +46 -3
- package/src/vue/composables/useDeriveInitialValue.ts +195 -0
- package/src/vue/composables/useDirtyValidation.ts +8 -3
- package/src/vue/composables/useProjection.ts +172 -1
- package/src/vue/composables/useProvider.ts +28 -11
- package/src/vue/index.ts +28 -9
- package/src/vue/primevue/JfBoolean.vue +10 -5
- package/src/vue/primevue/JfEnum.vue +23 -14
- package/src/vue/primevue/JfEnumArray.vue +22 -17
- package/src/vue/primevue/JfNumber.vue +20 -12
- package/src/vue/primevue/JfText.vue +31 -16
- package/src/vue/primevue/JfTextArea.vue +15 -13
- package/src/vue/primevue/index.ts +104 -23
- package/src/vue/styles.css +26 -1
- package/src/vue/utils/autoSelect.ts +2 -2
- package/src/vue/utils/placeholder.ts +42 -0
|
@@ -19,13 +19,38 @@ const injectLayoutStyles = () => {
|
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-direction: column;
|
|
21
21
|
align-items: flex-start;
|
|
22
|
-
gap:
|
|
22
|
+
gap: 24px;
|
|
23
23
|
width: 100%;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.vertical-layout-item {
|
|
27
27
|
width: 100%;
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
/* Form control wrapper */
|
|
31
|
+
.jf-control {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
gap: 12px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Form control label typography */
|
|
38
|
+
.jf-label {
|
|
39
|
+
font-weight: 600;
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
line-height: 14px;
|
|
42
|
+
color: #031553;
|
|
43
|
+
text-align: left;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Form control description typography */
|
|
47
|
+
.jf-description {
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
line-height: 14px;
|
|
51
|
+
color: #415290;
|
|
52
|
+
text-align: left;
|
|
53
|
+
}
|
|
29
54
|
`;
|
|
30
55
|
document.head.appendChild(style);
|
|
31
56
|
}
|
|
@@ -102,47 +127,103 @@ export function registerPrimevueRenderers(jsonformsCore: any): unknown[] {
|
|
|
102
127
|
|
|
103
128
|
// Projection-aware schema check: when options.projection is set,
|
|
104
129
|
// resolve the projected schema and test against it instead of the original
|
|
105
|
-
|
|
106
|
-
const projectedSchemaMatches =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
|
|
131
|
+
const projectedSchemaMatches =
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
(check: (schema: any) => boolean) =>
|
|
134
|
+
(uischema: unknown, schema: unknown): boolean => {
|
|
135
|
+
const ui = uischema as {
|
|
136
|
+
type?: string;
|
|
137
|
+
scope?: string;
|
|
138
|
+
options?: { projection?: string };
|
|
139
|
+
};
|
|
140
|
+
const projection = ui?.options?.projection;
|
|
141
|
+
if (!projection || ui?.type !== "Control" || !ui?.scope) return false;
|
|
142
|
+
|
|
143
|
+
const propertySchema = resolveScopeSchema(
|
|
144
|
+
ui.scope,
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
schema as Record<string, any>,
|
|
147
|
+
);
|
|
148
|
+
if (!propertySchema) return false;
|
|
149
|
+
|
|
150
|
+
return check(getProjectedSchema(propertySchema, projection));
|
|
151
|
+
};
|
|
118
152
|
|
|
119
153
|
const isMultilineProjection = (uischema: unknown, schema: unknown) => {
|
|
120
154
|
const ui = uischema as { options?: { multi?: boolean } };
|
|
121
|
-
return
|
|
122
|
-
|
|
155
|
+
return (
|
|
156
|
+
ui?.options?.multi === true &&
|
|
157
|
+
projectedSchemaMatches((s) => s?.type === "string")(uischema, schema)
|
|
158
|
+
);
|
|
123
159
|
};
|
|
124
160
|
|
|
125
161
|
const renderers = [
|
|
126
162
|
// Multiline text has higher priority than regular text
|
|
127
|
-
{ tester: rankWith(PRIME + 4, or(isMultilineString, isMultilineProjection)), renderer: JfTextArea },
|
|
128
|
-
{ tester: rankWith(PRIME + 3, or(isStringControl, projectedSchemaMatches((s) => s?.type === "string"))), renderer: JfText },
|
|
129
163
|
{
|
|
130
|
-
tester: rankWith(PRIME +
|
|
164
|
+
tester: rankWith(PRIME + 4, or(isMultilineString, isMultilineProjection)),
|
|
165
|
+
renderer: JfTextArea,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
tester: rankWith(
|
|
169
|
+
PRIME + 3,
|
|
170
|
+
or(
|
|
171
|
+
isStringControl,
|
|
172
|
+
projectedSchemaMatches((s) => s?.type === "string"),
|
|
173
|
+
),
|
|
174
|
+
),
|
|
175
|
+
renderer: JfText,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
tester: rankWith(
|
|
179
|
+
PRIME + 6,
|
|
180
|
+
or(
|
|
181
|
+
isIntegerControl,
|
|
182
|
+
projectedSchemaMatches((s) => s?.type === "integer"),
|
|
183
|
+
),
|
|
184
|
+
),
|
|
131
185
|
renderer: JfNumber,
|
|
132
186
|
},
|
|
133
187
|
{
|
|
134
|
-
tester: rankWith(
|
|
188
|
+
tester: rankWith(
|
|
189
|
+
PRIME + 4,
|
|
190
|
+
or(
|
|
191
|
+
isNumberControl,
|
|
192
|
+
projectedSchemaMatches((s) => s?.type === "number"),
|
|
193
|
+
),
|
|
194
|
+
),
|
|
135
195
|
renderer: JfNumber,
|
|
136
196
|
},
|
|
137
197
|
{
|
|
138
|
-
tester: rankWith(
|
|
198
|
+
tester: rankWith(
|
|
199
|
+
PRIME + 7,
|
|
200
|
+
or(
|
|
201
|
+
and(isControl, schemaMatches(isScalarEnum)),
|
|
202
|
+
and(isControl, projectedSchemaMatches(isScalarEnum)),
|
|
203
|
+
),
|
|
204
|
+
),
|
|
139
205
|
renderer: JfEnum,
|
|
140
206
|
},
|
|
141
207
|
{
|
|
142
|
-
tester: rankWith(
|
|
208
|
+
tester: rankWith(
|
|
209
|
+
PRIME + 8,
|
|
210
|
+
or(
|
|
211
|
+
and(isControl, schemaMatches(isEnumArray)),
|
|
212
|
+
and(isControl, projectedSchemaMatches(isEnumArray)),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
143
215
|
renderer: JfEnumArray,
|
|
144
216
|
},
|
|
145
|
-
{
|
|
217
|
+
{
|
|
218
|
+
tester: rankWith(
|
|
219
|
+
PRIME + 3,
|
|
220
|
+
or(
|
|
221
|
+
isBooleanControl,
|
|
222
|
+
projectedSchemaMatches((s) => s?.type === "boolean"),
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
renderer: JfBoolean,
|
|
226
|
+
},
|
|
146
227
|
];
|
|
147
228
|
|
|
148
229
|
// Update the exported array
|
package/src/vue/styles.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
align-items: flex-start;
|
|
8
|
-
gap:
|
|
8
|
+
gap: 24px;
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -14,6 +14,31 @@
|
|
|
14
14
|
width: 100%;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/* Form control wrapper */
|
|
18
|
+
.jf-control {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: 12px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Form control label typography */
|
|
25
|
+
.jf-label {
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
font-size: 14px;
|
|
28
|
+
line-height: 14px;
|
|
29
|
+
color: #031553;
|
|
30
|
+
text-align: left;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Form control description typography */
|
|
34
|
+
.jf-description {
|
|
35
|
+
font-weight: 400;
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
line-height: 14px;
|
|
38
|
+
color: #415290;
|
|
39
|
+
text-align: left;
|
|
40
|
+
}
|
|
41
|
+
|
|
17
42
|
/* PrimeVue dropdown text alignment fix */
|
|
18
43
|
.p-dropdown-label {
|
|
19
44
|
text-align: left !important;
|
|
@@ -57,7 +57,7 @@ export interface AutoSelectMultiParams {
|
|
|
57
57
|
* - Current value is empty array OR current selection is not in the current options
|
|
58
58
|
*/
|
|
59
59
|
export function shouldAutoSelectMulti(
|
|
60
|
-
params: AutoSelectMultiParams
|
|
60
|
+
params: AutoSelectMultiParams,
|
|
61
61
|
): unknown[] | null {
|
|
62
62
|
const { autoSelectSingle, isLoading, items, currentValue } = params;
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@ export function shouldAutoSelectMulti(
|
|
|
73
73
|
const currentArray = Array.isArray(currentValue) ? currentValue : [];
|
|
74
74
|
const isValueEmpty = currentArray.length === 0;
|
|
75
75
|
const hasValidSelection = currentArray.some((val) =>
|
|
76
|
-
items.some((item) => item.value === val)
|
|
76
|
+
items.some((item) => item.value === val),
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
if (isValueEmpty || !hasValidSelection) {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder resolution for form controls.
|
|
3
|
+
*
|
|
4
|
+
* Precedence:
|
|
5
|
+
* 1. `uischema.options.placeholder` (explicit author intent — always wins)
|
|
6
|
+
* 2. `Select ${label}` or `Enter ${label}` when a label is resolvable
|
|
7
|
+
* 3. Kind-appropriate bare fallback
|
|
8
|
+
*
|
|
9
|
+
* Never falls back to `schema.description` — descriptions are rendered as
|
|
10
|
+
* prose above the field by our renderers, so re-using them as placeholder
|
|
11
|
+
* produces a duplicated, truncated string inside the input.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type PlaceholderKind = "select" | "input";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Strip a trailing required-indicator asterisk (" *" or "*") that `resolveLabel`
|
|
18
|
+
* appends for required fields, so composed placeholders read naturally.
|
|
19
|
+
*/
|
|
20
|
+
function stripRequiredMarker(label: string): string {
|
|
21
|
+
return label.replace(/\s*\*\s*$/, "").trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolvePlaceholder(
|
|
25
|
+
uischema: { options?: unknown } | undefined,
|
|
26
|
+
resolvedLabel: string | undefined,
|
|
27
|
+
kind: PlaceholderKind,
|
|
28
|
+
): string | undefined {
|
|
29
|
+
const options = uischema?.options;
|
|
30
|
+
const explicit =
|
|
31
|
+
options && typeof options === "object"
|
|
32
|
+
? (options as Record<string, unknown>).placeholder
|
|
33
|
+
: undefined;
|
|
34
|
+
if (typeof explicit === "string" && explicit.length > 0) return explicit;
|
|
35
|
+
|
|
36
|
+
const label = resolvedLabel ? stripRequiredMarker(resolvedLabel) : "";
|
|
37
|
+
if (label) {
|
|
38
|
+
return kind === "select" ? `Select ${label}` : `Enter ${label}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return kind === "select" ? "Select…" : undefined;
|
|
42
|
+
}
|