@narrative.io/jsonforms-provider-protocols 1.1.0-beta.1 → 1.1.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 (61) hide show
  1. package/README.md +61 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +24 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/jsonforms-provider-protocols.css +0 -4
  7. package/dist/protocols/rest_api.d.ts +1 -0
  8. package/dist/protocols/rest_api.d.ts.map +1 -1
  9. package/dist/protocols/rest_api.js +6 -1
  10. package/dist/protocols/rest_api.js.map +1 -1
  11. package/dist/vue/composables/useDerive.d.ts +13 -0
  12. package/dist/vue/composables/useDerive.d.ts.map +1 -0
  13. package/dist/vue/composables/useDerive.js +71 -0
  14. package/dist/vue/composables/useDerive.js.map +1 -0
  15. package/dist/vue/index.d.ts +1 -1
  16. package/dist/vue/index.d.ts.map +1 -1
  17. package/dist/vue/index.js +6 -6
  18. package/dist/vue/index.js.map +1 -1
  19. package/dist/vue/primevue/JfBoolean.vue.d.ts +20 -32
  20. package/dist/vue/primevue/JfBoolean.vue.d.ts.map +1 -1
  21. package/dist/vue/primevue/JfBoolean.vue.js +38 -6
  22. package/dist/vue/primevue/JfBoolean.vue.js.map +1 -1
  23. package/dist/vue/primevue/JfEnum.vue.d.ts +20 -32
  24. package/dist/vue/primevue/JfEnum.vue.d.ts.map +1 -1
  25. package/dist/vue/primevue/JfEnum.vue.js +152 -5
  26. package/dist/vue/primevue/JfEnum.vue.js.map +1 -1
  27. package/dist/vue/primevue/JfEnum.vue2.js +1 -61
  28. package/dist/vue/primevue/JfEnum.vue2.js.map +1 -1
  29. package/dist/vue/primevue/JfEnumArray.vue.d.ts +20 -32
  30. package/dist/vue/primevue/JfEnumArray.vue.d.ts.map +1 -1
  31. package/dist/vue/primevue/JfEnumArray.vue.js +93 -13
  32. package/dist/vue/primevue/JfEnumArray.vue.js.map +1 -1
  33. package/dist/vue/primevue/JfNumber.vue.d.ts +20 -32
  34. package/dist/vue/primevue/JfNumber.vue.d.ts.map +1 -1
  35. package/dist/vue/primevue/JfNumber.vue.js +87 -13
  36. package/dist/vue/primevue/JfNumber.vue.js.map +1 -1
  37. package/dist/vue/primevue/JfText.vue.d.ts +20 -32
  38. package/dist/vue/primevue/JfText.vue.d.ts.map +1 -1
  39. package/dist/vue/primevue/JfText.vue.js +131 -16
  40. package/dist/vue/primevue/JfText.vue.js.map +1 -1
  41. package/dist/vue/primevue/JfTextArea.vue.d.ts +20 -32
  42. package/dist/vue/primevue/JfTextArea.vue.d.ts.map +1 -1
  43. package/dist/vue/primevue/JfTextArea.vue.js +49 -11
  44. package/dist/vue/primevue/JfTextArea.vue.js.map +1 -1
  45. package/dist/vue/primevue/index.d.ts +2 -75
  46. package/dist/vue/primevue/index.d.ts.map +1 -1
  47. package/dist/vue/primevue/index.js +46 -28
  48. package/dist/vue/primevue/index.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/index.ts +15 -2
  51. package/src/protocols/rest_api.ts +8 -1
  52. package/src/vue/composables/useDerive.ts +105 -0
  53. package/src/vue/index.ts +10 -1
  54. package/src/vue/primevue/JfBoolean.vue +42 -5
  55. package/src/vue/primevue/JfEnum.vue +131 -20
  56. package/src/vue/primevue/JfEnumArray.vue +118 -14
  57. package/src/vue/primevue/JfNumber.vue +104 -13
  58. package/src/vue/primevue/JfText.vue +156 -13
  59. package/src/vue/primevue/JfTextArea.vue +57 -10
  60. package/src/vue/primevue/index.ts +48 -37
  61. package/src/vue/styles.css +5 -0
@@ -1,12 +1,48 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: "JfTextArea",
4
+ props: {
5
+ uischema: {
6
+ type: Object,
7
+ required: true,
8
+ },
9
+ schema: {
10
+ type: Object,
11
+ required: true,
12
+ },
13
+ path: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ enabled: {
18
+ type: Boolean,
19
+ default: undefined,
20
+ },
21
+ renderers: {
22
+ type: Array,
23
+ required: false,
24
+ },
25
+ cells: {
26
+ type: Array,
27
+ required: false,
28
+ },
29
+ config: {
30
+ type: Object,
31
+ required: false,
32
+ },
33
+ },
34
+ };
35
+ </script>
36
+
1
37
  <script setup lang="ts">
2
- import type { ControlElement } from "@jsonforms/core";
3
- import { rendererProps, useJsonFormsControl } from "@jsonforms/vue";
4
- import { computed } from "vue";
38
+ import type { ControlProps } from "@jsonforms/vue";
39
+ import { useJsonFormsControl } from "@jsonforms/vue";
40
+ import { computed, ref, getCurrentInstance } from "vue";
5
41
  import Textarea from "primevue/textarea";
6
42
 
7
- defineOptions({ name: "JfTextArea" });
8
-
9
- const props = defineProps(rendererProps<ControlElement>());
43
+ // Access props from the component instance
44
+ const instance = getCurrentInstance()!;
45
+ const props = instance.props as unknown as ControlProps;
10
46
  const { control, handleChange } = useJsonFormsControl(props);
11
47
 
12
48
  const placeholder = computed<string | undefined>(
@@ -15,12 +51,22 @@ const placeholder = computed<string | undefined>(
15
51
  ?.placeholder ?? control.value.description,
16
52
  );
17
53
 
54
+ // Track user interaction
55
+ const hasInteracted = ref(false);
56
+
57
+ const showErrors = computed(() => hasInteracted.value && control.value.errors);
58
+
18
59
  function onInput(val: string | undefined) {
19
- const newValue = val ?? "";
20
- if ((control.value.data ?? "") !== newValue) {
60
+ // Convert empty strings to undefined for proper required field validation
61
+ const newValue = val && val.trim() !== "" ? val : undefined;
62
+ if (control.value.data !== newValue) {
21
63
  handleChange(control.value.path, newValue);
22
64
  }
23
65
  }
66
+
67
+ function onBlur() {
68
+ hasInteracted.value = true;
69
+ }
24
70
  </script>
25
71
 
26
72
  <template>
@@ -35,12 +81,13 @@ function onInput(val: string | undefined) {
35
81
  class="w-full"
36
82
  :model-value="control.data ?? ''"
37
83
  :disabled="!control.enabled"
38
- :aria-invalid="!!control.errors || undefined"
84
+ :aria-invalid="!!showErrors || undefined"
39
85
  :placeholder="placeholder"
40
86
  :rows="4"
41
87
  :auto-resize="true"
42
88
  @update:model-value="onInput"
89
+ @blur="onBlur"
43
90
  />
44
- <small v-if="control.errors" class="p-error">{{ control.errors }}</small>
91
+ <small v-if="showErrors" class="p-error">{{ control.errors }}</small>
45
92
  </div>
46
93
  </template>
@@ -33,17 +33,8 @@ const injectLayoutStyles = () => {
33
33
  // Inject styles when this module is imported
34
34
  injectLayoutStyles();
35
35
 
36
- import {
37
- rankWith,
38
- isStringControl,
39
- or,
40
- isNumberControl,
41
- isIntegerControl,
42
- and,
43
- isControl,
44
- schemaMatches,
45
- isBooleanControl,
46
- } from "@jsonforms/core";
36
+ // Import types only to avoid circular dependencies
37
+ import type { JsonFormsRendererRegistryEntry } from "@jsonforms/core";
47
38
 
48
39
  // helpers for enum detection
49
40
  const isScalarEnum = (s?: object) => {
@@ -66,34 +57,54 @@ const isEnumArray = (s?: object) => {
66
57
  );
67
58
  };
68
59
 
69
- // helper for multiline detection
70
- const isMultilineString = (uischema: unknown, schema: unknown) => {
71
- return (
72
- isStringControl(uischema as never, schema as never, {} as never) &&
73
- (uischema as { options?: { multi?: boolean } })?.options?.multi === true
74
- );
75
- };
76
-
77
60
  // Give PrimeVue renderers a high base rank; vanilla commonly uses small ranks (2–5)
78
61
  const PRIME = 100;
79
62
 
80
- export const primevueRenderers = [
81
- // Multiline text has higher priority than regular text
82
- { tester: rankWith(PRIME + 4, isMultilineString), renderer: JfTextArea },
83
- { tester: rankWith(PRIME + 3, isStringControl), renderer: JfText },
84
- {
85
- tester: rankWith(PRIME + 4, or(isNumberControl, isIntegerControl)),
86
- renderer: JfNumber,
87
- },
88
- {
89
- tester: rankWith(PRIME + 5, and(isControl, schemaMatches(isScalarEnum))),
90
- renderer: JfEnum,
91
- },
92
- {
93
- tester: rankWith(PRIME + 6, and(isControl, schemaMatches(isEnumArray))),
94
- renderer: JfEnumArray,
95
- },
96
- { tester: rankWith(PRIME + 3, isBooleanControl), renderer: JfBoolean },
97
- ];
63
+ // Create empty array first, populate it after module initialization to avoid circular deps
64
+ export const primevueRenderers: JsonFormsRendererRegistryEntry[] = [];
65
+
66
+ // Populate the renderers array after a microtask delay to avoid circular dependency
67
+ Promise.resolve().then(async () => {
68
+ const {
69
+ rankWith,
70
+ isStringControl,
71
+ or,
72
+ isNumberControl,
73
+ isIntegerControl,
74
+ and,
75
+ isControl,
76
+ schemaMatches,
77
+ isBooleanControl,
78
+ } = await import("@jsonforms/core");
79
+
80
+ // helper for multiline detection moved inside async block
81
+ const isMultilineString = (uischema: unknown, schema: unknown) => {
82
+ const controlUischema = uischema as { options?: { multi?: boolean } };
83
+ return and(isStringControl, () => controlUischema?.options?.multi === true)(
84
+ uischema as Parameters<typeof isStringControl>[0],
85
+ schema as Parameters<typeof isStringControl>[1],
86
+ {} as Parameters<typeof isStringControl>[2],
87
+ );
88
+ };
89
+
90
+ primevueRenderers.push(
91
+ // Multiline text has higher priority than regular text
92
+ { tester: rankWith(PRIME + 4, isMultilineString), renderer: JfTextArea },
93
+ { tester: rankWith(PRIME + 3, isStringControl), renderer: JfText },
94
+ {
95
+ tester: rankWith(PRIME + 4, or(isNumberControl, isIntegerControl)),
96
+ renderer: JfNumber,
97
+ },
98
+ {
99
+ tester: rankWith(PRIME + 5, and(isControl, schemaMatches(isScalarEnum))),
100
+ renderer: JfEnum,
101
+ },
102
+ {
103
+ tester: rankWith(PRIME + 6, and(isControl, schemaMatches(isEnumArray))),
104
+ renderer: JfEnumArray,
105
+ },
106
+ { tester: rankWith(PRIME + 3, isBooleanControl), renderer: JfBoolean },
107
+ );
108
+ });
98
109
 
99
110
  export { JfText, JfTextArea, JfNumber, JfEnum, JfEnumArray, JfBoolean };
@@ -13,3 +13,8 @@
13
13
  .vertical-layout-item {
14
14
  width: 100%;
15
15
  }
16
+
17
+ /* PrimeVue dropdown text alignment fix */
18
+ .p-dropdown-label {
19
+ text-align: left !important;
20
+ }