@narrative.io/jsonforms-provider-protocols 2.11.0 → 3.0.0-beta.10

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 (110) hide show
  1. package/README.md +101 -29
  2. package/dist/core/initFormData.d.ts +10 -0
  3. package/dist/core/initFormData.d.ts.map +1 -0
  4. package/dist/core/initFormData.js +99 -0
  5. package/dist/core/initFormData.js.map +1 -0
  6. package/dist/core/projection.d.ts +32 -0
  7. package/dist/core/projection.d.ts.map +1 -0
  8. package/dist/core/projection.js +74 -0
  9. package/dist/core/projection.js.map +1 -0
  10. package/dist/core/resolveScope.d.ts +11 -0
  11. package/dist/core/resolveScope.d.ts.map +1 -0
  12. package/dist/core/resolveScope.js +22 -0
  13. package/dist/core/resolveScope.js.map +1 -0
  14. package/dist/core/transforms.d.ts +8 -10
  15. package/dist/core/transforms.d.ts.map +1 -1
  16. package/dist/core/transforms.js +58 -13
  17. package/dist/core/transforms.js.map +1 -1
  18. package/dist/core/types.d.ts +8 -0
  19. package/dist/core/types.d.ts.map +1 -1
  20. package/dist/index.d.ts +5 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +14 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/jsonforms-provider-protocols.css +2 -2
  25. package/dist/vue/components/ProviderAutocomplete.vue.d.ts.map +1 -1
  26. package/dist/vue/components/ProviderAutocomplete.vue.js +10 -5
  27. package/dist/vue/components/ProviderAutocomplete.vue.js.map +1 -1
  28. package/dist/vue/components/ProviderMultiSelect.vue.d.ts.map +1 -1
  29. package/dist/vue/components/ProviderMultiSelect.vue.js +1 -1
  30. package/dist/vue/components/ProviderMultiSelect.vue2.js +12 -7
  31. package/dist/vue/components/ProviderMultiSelect.vue2.js.map +1 -1
  32. package/dist/vue/components/ProviderSelect.vue.d.ts.map +1 -1
  33. package/dist/vue/components/ProviderSelect.vue.js +1 -1
  34. package/dist/vue/components/ProviderSelect.vue2.js +13 -6
  35. package/dist/vue/components/ProviderSelect.vue2.js.map +1 -1
  36. package/dist/vue/composables/useDataLayer.d.ts +10 -0
  37. package/dist/vue/composables/useDataLayer.d.ts.map +1 -0
  38. package/dist/vue/composables/useDataLayer.js +26 -0
  39. package/dist/vue/composables/useDataLayer.js.map +1 -0
  40. package/dist/vue/composables/useDerive.d.ts +5 -2
  41. package/dist/vue/composables/useDerive.d.ts.map +1 -1
  42. package/dist/vue/composables/useDerive.js +29 -12
  43. package/dist/vue/composables/useDerive.js.map +1 -1
  44. package/dist/vue/composables/useDeriveInitialValue.d.ts +36 -0
  45. package/dist/vue/composables/useDeriveInitialValue.d.ts.map +1 -0
  46. package/dist/vue/composables/useDeriveInitialValue.js +125 -0
  47. package/dist/vue/composables/useDeriveInitialValue.js.map +1 -0
  48. package/dist/vue/composables/useDirtyValidation.d.ts +9 -0
  49. package/dist/vue/composables/useDirtyValidation.d.ts.map +1 -0
  50. package/dist/vue/composables/useDirtyValidation.js +15 -0
  51. package/dist/vue/composables/useDirtyValidation.js.map +1 -0
  52. package/dist/vue/composables/useProjection.d.ts +41 -0
  53. package/dist/vue/composables/useProjection.d.ts.map +1 -0
  54. package/dist/vue/composables/useProjection.js +84 -0
  55. package/dist/vue/composables/useProjection.js.map +1 -0
  56. package/dist/vue/index.d.ts +7 -0
  57. package/dist/vue/index.d.ts.map +1 -1
  58. package/dist/vue/index.js +35 -27
  59. package/dist/vue/index.js.map +1 -1
  60. package/dist/vue/primevue/JfBoolean.vue.d.ts +9 -0
  61. package/dist/vue/primevue/JfBoolean.vue.d.ts.map +1 -1
  62. package/dist/vue/primevue/JfBoolean.vue.js +35 -13
  63. package/dist/vue/primevue/JfBoolean.vue.js.map +1 -1
  64. package/dist/vue/primevue/JfEnum.vue.d.ts +9 -0
  65. package/dist/vue/primevue/JfEnum.vue.d.ts.map +1 -1
  66. package/dist/vue/primevue/JfEnum.vue.js +31 -22
  67. package/dist/vue/primevue/JfEnum.vue.js.map +1 -1
  68. package/dist/vue/primevue/JfEnumArray.vue.d.ts +9 -0
  69. package/dist/vue/primevue/JfEnumArray.vue.d.ts.map +1 -1
  70. package/dist/vue/primevue/JfEnumArray.vue.js +33 -18
  71. package/dist/vue/primevue/JfEnumArray.vue.js.map +1 -1
  72. package/dist/vue/primevue/JfNumber.vue.d.ts +9 -0
  73. package/dist/vue/primevue/JfNumber.vue.d.ts.map +1 -1
  74. package/dist/vue/primevue/JfNumber.vue.js +31 -22
  75. package/dist/vue/primevue/JfNumber.vue.js.map +1 -1
  76. package/dist/vue/primevue/JfText.vue.d.ts +9 -0
  77. package/dist/vue/primevue/JfText.vue.d.ts.map +1 -1
  78. package/dist/vue/primevue/JfText.vue.js +40 -32
  79. package/dist/vue/primevue/JfText.vue.js.map +1 -1
  80. package/dist/vue/primevue/JfTextArea.vue.d.ts +9 -0
  81. package/dist/vue/primevue/JfTextArea.vue.d.ts.map +1 -1
  82. package/dist/vue/primevue/JfTextArea.vue.js +32 -18
  83. package/dist/vue/primevue/JfTextArea.vue.js.map +1 -1
  84. package/dist/vue/primevue/index.d.ts.map +1 -1
  85. package/dist/vue/primevue/index.js +100 -8
  86. package/dist/vue/primevue/index.js.map +1 -1
  87. package/package.json +3 -1
  88. package/src/core/initFormData.ts +189 -0
  89. package/src/core/projection.ts +136 -0
  90. package/src/core/resolveScope.ts +39 -0
  91. package/src/core/transforms.ts +118 -26
  92. package/src/core/types.ts +9 -0
  93. package/src/index.ts +7 -1
  94. package/src/vue/components/ProviderAutocomplete.vue +10 -5
  95. package/src/vue/components/ProviderMultiSelect.vue +14 -7
  96. package/src/vue/components/ProviderSelect.vue +15 -6
  97. package/src/vue/composables/useDataLayer.ts +43 -0
  98. package/src/vue/composables/useDerive.ts +62 -16
  99. package/src/vue/composables/useDeriveInitialValue.ts +195 -0
  100. package/src/vue/composables/useDirtyValidation.ts +20 -0
  101. package/src/vue/composables/useProjection.ts +181 -0
  102. package/src/vue/index.ts +35 -41
  103. package/src/vue/primevue/JfBoolean.vue +25 -7
  104. package/src/vue/primevue/JfEnum.vue +29 -22
  105. package/src/vue/primevue/JfEnumArray.vue +31 -16
  106. package/src/vue/primevue/JfNumber.vue +29 -22
  107. package/src/vue/primevue/JfText.vue +34 -27
  108. package/src/vue/primevue/JfTextArea.vue +29 -17
  109. package/src/vue/primevue/index.ts +114 -8
  110. package/src/vue/styles.css +26 -1
@@ -4,6 +4,8 @@ import JfNumber from "./JfNumber.vue";
4
4
  import JfEnum from "./JfEnum.vue";
5
5
  import JfEnumArray from "./JfEnumArray.vue";
6
6
  import JfBoolean from "./JfBoolean.vue";
7
+ import { getProjectedSchema } from "../../core/projection";
8
+ import { resolveScopeSchema } from "../../core/resolveScope";
7
9
 
8
10
  // Auto-inject layout styles
9
11
  const injectLayoutStyles = () => {
@@ -17,13 +19,38 @@ const injectLayoutStyles = () => {
17
19
  display: flex;
18
20
  flex-direction: column;
19
21
  align-items: flex-start;
20
- gap: 1rem;
22
+ gap: 24px;
21
23
  width: 100%;
22
24
  }
23
25
 
24
26
  .vertical-layout-item {
25
27
  width: 100%;
26
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
+ }
27
54
  `;
28
55
  document.head.appendChild(style);
29
56
  }
@@ -54,6 +81,7 @@ export function registerPrimevueRenderers(jsonformsCore: any): unknown[] {
54
81
  isNumberControl,
55
82
  isIntegerControl,
56
83
  and,
84
+ or,
57
85
  isControl,
58
86
  schemaMatches,
59
87
  isBooleanControl,
@@ -97,27 +125,105 @@ export function registerPrimevueRenderers(jsonformsCore: any): unknown[] {
97
125
  );
98
126
  };
99
127
 
128
+ // Projection-aware schema check: when options.projection is set,
129
+ // resolve the projected schema and test against it instead of the original
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
+ };
152
+
153
+ const isMultilineProjection = (uischema: unknown, schema: unknown) => {
154
+ const ui = uischema as { options?: { multi?: boolean } };
155
+ return (
156
+ ui?.options?.multi === true &&
157
+ projectedSchemaMatches((s) => s?.type === "string")(uischema, schema)
158
+ );
159
+ };
160
+
100
161
  const renderers = [
101
162
  // Multiline text has higher priority than regular text
102
- { tester: rankWith(PRIME + 4, isMultilineString), renderer: JfTextArea },
103
- { tester: rankWith(PRIME + 3, isStringControl), renderer: JfText },
104
163
  {
105
- tester: rankWith(PRIME + 6, isIntegerControl),
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
+ ),
106
185
  renderer: JfNumber,
107
186
  },
108
187
  {
109
- tester: rankWith(PRIME + 4, isNumberControl),
188
+ tester: rankWith(
189
+ PRIME + 4,
190
+ or(
191
+ isNumberControl,
192
+ projectedSchemaMatches((s) => s?.type === "number"),
193
+ ),
194
+ ),
110
195
  renderer: JfNumber,
111
196
  },
112
197
  {
113
- tester: rankWith(PRIME + 7, and(isControl, schemaMatches(isScalarEnum))),
198
+ tester: rankWith(
199
+ PRIME + 7,
200
+ or(
201
+ and(isControl, schemaMatches(isScalarEnum)),
202
+ and(isControl, projectedSchemaMatches(isScalarEnum)),
203
+ ),
204
+ ),
114
205
  renderer: JfEnum,
115
206
  },
116
207
  {
117
- tester: rankWith(PRIME + 8, and(isControl, schemaMatches(isEnumArray))),
208
+ tester: rankWith(
209
+ PRIME + 8,
210
+ or(
211
+ and(isControl, schemaMatches(isEnumArray)),
212
+ and(isControl, projectedSchemaMatches(isEnumArray)),
213
+ ),
214
+ ),
118
215
  renderer: JfEnumArray,
119
216
  },
120
- { tester: rankWith(PRIME + 3, isBooleanControl), renderer: JfBoolean },
217
+ {
218
+ tester: rankWith(
219
+ PRIME + 3,
220
+ or(
221
+ isBooleanControl,
222
+ projectedSchemaMatches((s) => s?.type === "boolean"),
223
+ ),
224
+ ),
225
+ renderer: JfBoolean,
226
+ },
121
227
  ];
122
228
 
123
229
  // Update the exported array
@@ -5,7 +5,7 @@
5
5
  display: flex;
6
6
  flex-direction: column;
7
7
  align-items: flex-start;
8
- gap: 1rem;
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;