@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.
- package/README.md +61 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/dist/jsonforms-provider-protocols.css +0 -4
- package/dist/protocols/rest_api.d.ts +1 -0
- package/dist/protocols/rest_api.d.ts.map +1 -1
- package/dist/protocols/rest_api.js +6 -1
- package/dist/protocols/rest_api.js.map +1 -1
- package/dist/vue/composables/useDerive.d.ts +13 -0
- package/dist/vue/composables/useDerive.d.ts.map +1 -0
- package/dist/vue/composables/useDerive.js +71 -0
- package/dist/vue/composables/useDerive.js.map +1 -0
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +6 -6
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/primevue/JfBoolean.vue.d.ts +20 -32
- package/dist/vue/primevue/JfBoolean.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfBoolean.vue.js +38 -6
- package/dist/vue/primevue/JfBoolean.vue.js.map +1 -1
- package/dist/vue/primevue/JfEnum.vue.d.ts +20 -32
- package/dist/vue/primevue/JfEnum.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfEnum.vue.js +152 -5
- package/dist/vue/primevue/JfEnum.vue.js.map +1 -1
- package/dist/vue/primevue/JfEnum.vue2.js +1 -61
- package/dist/vue/primevue/JfEnum.vue2.js.map +1 -1
- package/dist/vue/primevue/JfEnumArray.vue.d.ts +20 -32
- package/dist/vue/primevue/JfEnumArray.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfEnumArray.vue.js +93 -13
- package/dist/vue/primevue/JfEnumArray.vue.js.map +1 -1
- package/dist/vue/primevue/JfNumber.vue.d.ts +20 -32
- package/dist/vue/primevue/JfNumber.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfNumber.vue.js +87 -13
- package/dist/vue/primevue/JfNumber.vue.js.map +1 -1
- package/dist/vue/primevue/JfText.vue.d.ts +20 -32
- package/dist/vue/primevue/JfText.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfText.vue.js +131 -16
- package/dist/vue/primevue/JfText.vue.js.map +1 -1
- package/dist/vue/primevue/JfTextArea.vue.d.ts +20 -32
- package/dist/vue/primevue/JfTextArea.vue.d.ts.map +1 -1
- package/dist/vue/primevue/JfTextArea.vue.js +49 -11
- package/dist/vue/primevue/JfTextArea.vue.js.map +1 -1
- package/dist/vue/primevue/index.d.ts +2 -75
- package/dist/vue/primevue/index.d.ts.map +1 -1
- package/dist/vue/primevue/index.js +46 -28
- package/dist/vue/primevue/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -2
- package/src/protocols/rest_api.ts +8 -1
- package/src/vue/composables/useDerive.ts +105 -0
- package/src/vue/index.ts +10 -1
- package/src/vue/primevue/JfBoolean.vue +42 -5
- package/src/vue/primevue/JfEnum.vue +131 -20
- package/src/vue/primevue/JfEnumArray.vue +118 -14
- package/src/vue/primevue/JfNumber.vue +104 -13
- package/src/vue/primevue/JfText.vue +156 -13
- package/src/vue/primevue/JfTextArea.vue +57 -10
- package/src/vue/primevue/index.ts +48 -37
- 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 {
|
|
3
|
-
import {
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
const props =
|
|
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
|
-
|
|
20
|
-
|
|
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="!!
|
|
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="
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
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 };
|