@narrative.io/jsonforms-provider-protocols 3.0.0-beta.1 → 3.0.0-beta.11
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 +10 -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.map +1 -1
- package/dist/core/projection.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonforms-provider-protocols.css +2 -2
- package/dist/vue/components/ProviderAutocomplete.vue.d.ts.map +1 -1
- package/dist/vue/components/ProviderAutocomplete.vue.js +8 -5
- 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 +9 -6
- 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 +11 -6
- 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 +9 -0
- package/dist/vue/composables/useDirtyValidation.d.ts.map +1 -0
- package/dist/vue/composables/useDirtyValidation.js +15 -0
- package/dist/vue/composables/useDirtyValidation.js.map +1 -0
- package/dist/vue/composables/useProjection.d.ts +6 -0
- package/dist/vue/composables/useProjection.d.ts.map +1 -1
- package/dist/vue/composables/useProjection.js +54 -3
- 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 +3 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +32 -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 +26 -9
- 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 +21 -17
- 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 +22 -12
- 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 +21 -17
- 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 +29 -26
- 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 +22 -13
- 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/package.json +3 -1
- package/src/core/initFormData.ts +189 -0
- package/src/core/projection.ts +5 -5
- package/src/core/transforms.ts +33 -6
- package/src/core/types.ts +1 -0
- package/src/index.ts +1 -0
- package/src/vue/components/ProviderAutocomplete.vue +8 -5
- package/src/vue/components/ProviderMultiSelect.vue +13 -8
- package/src/vue/components/ProviderSelect.vue +14 -7
- 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 +20 -0
- package/src/vue/composables/useProjection.ts +108 -1
- package/src/vue/composables/useProvider.ts +28 -11
- package/src/vue/index.ts +29 -9
- package/src/vue/primevue/JfBoolean.vue +19 -6
- package/src/vue/primevue/JfEnum.vue +23 -21
- package/src/vue/primevue/JfEnumArray.vue +25 -15
- package/src/vue/primevue/JfNumber.vue +22 -20
- package/src/vue/primevue/JfText.vue +26 -24
- package/src/vue/primevue/JfTextArea.vue +22 -15
- package/src/vue/primevue/index.ts +104 -23
- package/src/vue/styles.css +26 -1
- package/src/vue/utils/autoSelect.ts +2 -2
package/dist/vue/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rankWith, and, or, isStringControl, isNumberControl, isControl } from "@jsonforms/core";
|
|
1
|
+
import { rankWith, and, or, isStringControl, isNumberControl, isIntegerControl, isControl } from "@jsonforms/core";
|
|
2
2
|
import { resolveScopeSchema } from "../core/resolveScope.js";
|
|
3
3
|
import _sfc_main from "./components/ProviderAutocomplete.vue.js";
|
|
4
4
|
import ProviderSelect from "./components/ProviderSelect.vue.js";
|
|
@@ -7,6 +7,8 @@ import { primevueRenderers, registerPrimevueRenderers } from "./primevue/index.j
|
|
|
7
7
|
import { useProvider } from "./composables/useProvider.js";
|
|
8
8
|
import { useProjection } from "./composables/useProjection.js";
|
|
9
9
|
import { createDataLayer, useDataLayer } from "./composables/useDataLayer.js";
|
|
10
|
+
import { useDeriveInitialValue } from "./composables/useDeriveInitialValue.js";
|
|
11
|
+
import { useDirtyValidation } from "./composables/useDirtyValidation.js";
|
|
10
12
|
import { providerTester } from "./testers.js";
|
|
11
13
|
import { default as default2 } from "./primevue/JfText.vue.js";
|
|
12
14
|
import { default as default3 } from "./primevue/JfTextArea.vue.js";
|
|
@@ -20,23 +22,37 @@ const hasProvider = (uischema) => {
|
|
|
20
22
|
const isIntegerScope = (uischema, schema) => {
|
|
21
23
|
const ui = uischema;
|
|
22
24
|
if (ui?.type !== "Control" || !ui?.scope) return false;
|
|
23
|
-
const propertySchema = resolveScopeSchema(
|
|
25
|
+
const propertySchema = resolveScopeSchema(
|
|
26
|
+
ui.scope,
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
schema
|
|
29
|
+
);
|
|
24
30
|
return propertySchema?.type === "integer";
|
|
25
31
|
};
|
|
26
32
|
const providerSelectTester = rankWith(
|
|
27
|
-
|
|
28
|
-
// Higher than PrimeVue
|
|
33
|
+
107,
|
|
34
|
+
// Higher than PrimeVue JfNumber integer renderer (106) so provider wins
|
|
29
35
|
and(
|
|
30
|
-
or(
|
|
36
|
+
or(
|
|
37
|
+
isStringControl,
|
|
38
|
+
isNumberControl,
|
|
39
|
+
isIntegerControl,
|
|
40
|
+
and(isControl, isIntegerScope)
|
|
41
|
+
),
|
|
31
42
|
hasProvider,
|
|
32
43
|
(uischema) => !uischema?.options?.autocomplete
|
|
33
44
|
)
|
|
34
45
|
);
|
|
35
46
|
const providerAutocompleteTester = rankWith(
|
|
36
|
-
|
|
37
|
-
// Higher than
|
|
47
|
+
108,
|
|
48
|
+
// Higher than providerSelectTester so autocomplete variant wins when flagged
|
|
38
49
|
and(
|
|
39
|
-
or(
|
|
50
|
+
or(
|
|
51
|
+
isStringControl,
|
|
52
|
+
isNumberControl,
|
|
53
|
+
isIntegerControl,
|
|
54
|
+
and(isControl, isIntegerScope)
|
|
55
|
+
),
|
|
40
56
|
hasProvider,
|
|
41
57
|
(uischema) => uischema?.options?.autocomplete === true
|
|
42
58
|
)
|
|
@@ -46,11 +62,15 @@ const isArrayControl = (uischema, schema) => {
|
|
|
46
62
|
if (controlSchema.type !== "Control" || !controlSchema.scope) {
|
|
47
63
|
return false;
|
|
48
64
|
}
|
|
49
|
-
const propertySchema = resolveScopeSchema(
|
|
65
|
+
const propertySchema = resolveScopeSchema(
|
|
66
|
+
controlSchema.scope,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
schema
|
|
69
|
+
);
|
|
50
70
|
return propertySchema?.type === "array";
|
|
51
71
|
};
|
|
52
72
|
const providerMultiSelectTester = rankWith(
|
|
53
|
-
|
|
73
|
+
109,
|
|
54
74
|
// Highest priority for array controls with providers
|
|
55
75
|
and(isArrayControl, hasProvider)
|
|
56
76
|
);
|
|
@@ -75,6 +95,8 @@ export {
|
|
|
75
95
|
providerTester,
|
|
76
96
|
registerPrimevueRenderers,
|
|
77
97
|
useDataLayer,
|
|
98
|
+
useDeriveInitialValue,
|
|
99
|
+
useDirtyValidation,
|
|
78
100
|
useProjection,
|
|
79
101
|
useProvider
|
|
80
102
|
};
|
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/vue/index.ts"],"sourcesContent":["import type { UISchemaElement } from \"@jsonforms/core\";\nimport {\n and,\n isNumberControl,\n isStringControl,\n or,\n rankWith,\n isControl,\n} from \"@jsonforms/core\";\nimport { resolveScopeSchema } from \"../core/resolveScope\";\nimport ProviderAutocomplete from \"./components/ProviderAutocomplete.vue\";\nimport ProviderSelect from \"./components/ProviderSelect.vue\";\nimport ProviderMultiSelect from \"./components/ProviderMultiSelect.vue\";\n\n// Custom tester that checks if provider option exists (as object or boolean)\nconst hasProvider = (uischema: UISchemaElement) => {\n return uischema?.options?.provider !== undefined;\n};\n\n// Integer fallback tester — handles nested scopes like #/properties/parent/properties/child\nconst isIntegerScope = (uischema: unknown, schema: unknown) => {\n const ui = uischema as { type?: string; scope?: string };\n if (ui?.type !== \"Control\" || !ui?.scope) return false;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vue/index.ts"],"sourcesContent":["import type { UISchemaElement } from \"@jsonforms/core\";\nimport {\n and,\n isIntegerControl,\n isNumberControl,\n isStringControl,\n or,\n rankWith,\n isControl,\n} from \"@jsonforms/core\";\nimport { resolveScopeSchema } from \"../core/resolveScope\";\nimport ProviderAutocomplete from \"./components/ProviderAutocomplete.vue\";\nimport ProviderSelect from \"./components/ProviderSelect.vue\";\nimport ProviderMultiSelect from \"./components/ProviderMultiSelect.vue\";\n\n// Custom tester that checks if provider option exists (as object or boolean)\nconst hasProvider = (uischema: UISchemaElement) => {\n return uischema?.options?.provider !== undefined;\n};\n\n// Integer fallback tester — handles nested scopes like #/properties/parent/properties/child\nconst isIntegerScope = (uischema: unknown, schema: unknown) => {\n const ui = uischema as { type?: string; scope?: string };\n if (ui?.type !== \"Control\" || !ui?.scope) return false;\n\n const propertySchema = resolveScopeSchema(\n ui.scope,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema as Record<string, any>,\n );\n return propertySchema?.type === \"integer\";\n};\n\n// Create specific testers for each component type\nconst providerSelectTester = rankWith(\n 107, // Higher than PrimeVue JfNumber integer renderer (106) so provider wins\n and(\n or(\n isStringControl,\n isNumberControl,\n isIntegerControl,\n and(isControl, isIntegerScope),\n ),\n hasProvider,\n (uischema) => !uischema?.options?.autocomplete,\n ),\n);\n\nconst providerAutocompleteTester = rankWith(\n 108, // Higher than providerSelectTester so autocomplete variant wins when flagged\n and(\n or(\n isStringControl,\n isNumberControl,\n isIntegerControl,\n and(isControl, isIntegerScope),\n ),\n hasProvider,\n (uischema) => uischema?.options?.autocomplete === true,\n ),\n);\n\n// Custom array tester - supports nested scope paths\nconst isArrayControl = (uischema: UISchemaElement, schema: unknown) => {\n const controlSchema = uischema as { type: string; scope?: string };\n if (controlSchema.type !== \"Control\" || !controlSchema.scope) {\n return false;\n }\n\n const propertySchema = resolveScopeSchema(\n controlSchema.scope,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema as Record<string, any>,\n );\n return propertySchema?.type === \"array\";\n};\n\nconst providerMultiSelectTester = rankWith(\n 109, // Highest priority for array controls with providers\n and(isArrayControl, hasProvider),\n);\n\nexport const providerRenderers = [\n { tester: providerMultiSelectTester, renderer: ProviderMultiSelect },\n { tester: providerAutocompleteTester, renderer: ProviderAutocomplete },\n { tester: providerSelectTester, renderer: ProviderSelect },\n];\n\n// Export PrimeVue renderers (styles are auto-injected)\nexport { primevueRenderers, registerPrimevueRenderers } from \"./primevue\";\n\n// Export individual components\nexport { ProviderAutocomplete, ProviderSelect, ProviderMultiSelect };\nexport { useProvider } from \"./composables/useProvider\";\nexport { useProjection } from \"./composables/useProjection\";\nexport type { ProjectionResult } from \"./composables/useProjection\";\nexport { createDataLayer, useDataLayer } from \"./composables/useDataLayer\";\nexport type { DataLayer } from \"./composables/useDataLayer\";\nexport { useDeriveInitialValue } from \"./composables/useDeriveInitialValue\";\nexport type { DeriveInitialValueCfg } from \"./composables/useDeriveInitialValue\";\nexport { useDirtyValidation } from \"./composables/useDirtyValidation\";\nexport * from \"./testers\";\n\n// Export individual PrimeVue components using lazy evaluation to avoid circular deps\nexport {\n JfText,\n JfTextArea,\n JfNumber,\n JfEnum,\n JfEnumArray,\n JfBoolean,\n} from \"./primevue\";\n"],"names":["ProviderAutocomplete"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAM,cAAc,C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Root":"","sources":["../../../src/vue/primevue/JfBoolean.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"JfBoolean.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfBoolean.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,wBAoLK"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, createElementBlock, openBlock, createVNode, createCommentVNode, unref, toDisplayString } from "vue";
|
|
1
|
+
import { defineComponent, getCurrentInstance, createElementBlock, openBlock, createVNode, createCommentVNode, unref, normalizeClass, toDisplayString } from "vue";
|
|
2
2
|
import { useJsonFormsControl } from "@jsonforms/vue";
|
|
3
3
|
import { useProjection } from "../composables/useProjection.js";
|
|
4
|
+
import { useDirtyValidation } from "../composables/useDirtyValidation.js";
|
|
4
5
|
import Checkbox from "primevue/checkbox";
|
|
5
|
-
const _hoisted_1 = {
|
|
6
|
-
|
|
6
|
+
const _hoisted_1 = {
|
|
7
|
+
class: "jf-control",
|
|
8
|
+
style: { "flex-direction": "row", "align-items": "center" }
|
|
9
|
+
};
|
|
10
|
+
const _hoisted_2 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "jf-label"
|
|
13
|
+
};
|
|
7
14
|
const _hoisted_3 = {
|
|
8
15
|
key: 1,
|
|
9
16
|
class: "p-error"
|
|
@@ -50,19 +57,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
50
57
|
const instance = getCurrentInstance();
|
|
51
58
|
const props = instance.props;
|
|
52
59
|
const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
|
|
53
|
-
const {
|
|
54
|
-
|
|
60
|
+
const {
|
|
61
|
+
projectedData,
|
|
62
|
+
handleProjectedChange: handleChange,
|
|
63
|
+
projectedErrors,
|
|
64
|
+
projectedLabel
|
|
65
|
+
} = useProjection(control, rawHandleChange);
|
|
66
|
+
const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
|
|
67
|
+
const onToggle = (val) => {
|
|
68
|
+
markDirty();
|
|
69
|
+
handleChange(control.value.path, val);
|
|
70
|
+
};
|
|
55
71
|
return (_ctx, _cache) => {
|
|
56
72
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
57
73
|
createVNode(unref(Checkbox), {
|
|
58
74
|
binary: true,
|
|
59
75
|
"model-value": !!unref(projectedData),
|
|
60
76
|
disabled: !unref(control).enabled,
|
|
61
|
-
"
|
|
77
|
+
class: normalizeClass({ "p-invalid": unref(showErrors) }),
|
|
78
|
+
"aria-invalid": unref(showErrors) || void 0,
|
|
62
79
|
"onUpdate:modelValue": onToggle
|
|
63
|
-
}, null, 8, ["model-value", "disabled", "aria-invalid"]),
|
|
64
|
-
unref(
|
|
65
|
-
unref(
|
|
80
|
+
}, null, 8, ["model-value", "disabled", "class", "aria-invalid"]),
|
|
81
|
+
unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
|
|
82
|
+
unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_3, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
|
|
66
83
|
]);
|
|
67
84
|
};
|
|
68
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfBoolean.vue.js","sources":["../../../src/vue/primevue/JfBoolean.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfBoolean\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { getCurrentInstance } from \"vue\";\nimport { useProjection } from \"../composables/useProjection\";\nimport Checkbox from \"primevue/checkbox\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange: rawHandleChange } = useJsonFormsControl(props);\nconst {
|
|
1
|
+
{"version":3,"file":"JfBoolean.vue.js","sources":["../../../src/vue/primevue/JfBoolean.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfBoolean\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { getCurrentInstance } from \"vue\";\nimport { useProjection } from \"../composables/useProjection\";\nimport { useDirtyValidation } from \"../composables/useDirtyValidation\";\nimport Checkbox from \"primevue/checkbox\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange: rawHandleChange } = useJsonFormsControl(props);\nconst {\n projectedData,\n handleProjectedChange: handleChange,\n projectedErrors,\n projectedLabel,\n} = useProjection(control, rawHandleChange);\n\n// Track user interaction — errors only show after first toggle\nconst { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);\n\nconst onToggle = (val: boolean) => {\n markDirty();\n handleChange(control.value.path, val);\n};\n</script>\n\n<template>\n <div class=\"jf-control\" style=\"flex-direction: row; align-items: center\">\n <Checkbox\n :binary=\"true\"\n :model-value=\"!!projectedData\"\n :disabled=\"!control.enabled\"\n :class=\"{ 'p-invalid': showErrors }\"\n :aria-invalid=\"showErrors || undefined\"\n @update:model-value=\"onToggle\"\n />\n <label v-if=\"projectedLabel\" class=\"jf-label\">{{ projectedLabel }}</label>\n <small v-if=\"showErrors\" class=\"p-error\">{{ projectedErrors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_createVNode","_unref","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;AACA,MAAA,cAAe;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,IACL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;;;;AAYA,UAAM,WAAW,mBAAA;AACjB,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,SAAS,cAAc,gBAAA,IAAoB,oBAAoB,KAAK;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,uBAAuB;AAAA,MACvB;AAAA,MACA;AAAA,IAAA,IACE,cAAc,SAAS,eAAe;AAG1C,UAAM,EAAE,YAAY,UAAA,IAAc,mBAAmB,SAAS,eAAe;AAE7E,UAAM,WAAW,CAAC,QAAiB;AACjC,gBAAA;AACA,mBAAa,QAAQ,MAAM,MAAM,GAAG;AAAA,IACtC;;AAIE,aAAAA,UAAA,GAAAC,mBAWM,OAXN,YAWM;AAAA,QAVJC,YAOEC,MAAA,QAAA,GAAA;AAAA,UANC,QAAQ;AAAA,UACR,iBAAeA,MAAA,aAAA;AAAA,UACf,UAAQ,CAAGA,MAAA,OAAA,EAAQ;AAAA,UACnB,qCAAsBA,MAAA,UAAA,GAAU;AAAA,UAChC,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B,uBAAoB;AAAA,QAAA;QAEVA,MAAA,cAAA,kBAAbF,mBAA0E,SAA1E,YAA0EG,gBAAzBD,MAAA,cAAA,CAAc,GAAA,CAAA;QAClDA,MAAA,UAAA,kBAAbF,mBAAsE,SAAtE,YAAsEG,gBAA1BD,MAAA,eAAA,CAAe,GAAA,CAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfEnum.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfEnum.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"JfEnum.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfEnum.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6NA,wBAwUK"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, computed, inject, watch,
|
|
1
|
+
import { defineComponent, getCurrentInstance, computed, inject, watch, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString, normalizeClass } from "vue";
|
|
2
2
|
import { useJsonFormsControl } from "@jsonforms/vue";
|
|
3
3
|
import { useProvider } from "../composables/useProvider.js";
|
|
4
4
|
import { useDerive } from "../composables/useDerive.js";
|
|
5
|
+
import { useDeriveInitialValue } from "../composables/useDeriveInitialValue.js";
|
|
5
6
|
import { useProjection } from "../composables/useProjection.js";
|
|
7
|
+
import { useDirtyValidation } from "../composables/useDirtyValidation.js";
|
|
6
8
|
import { shouldAutoSelect } from "../utils/autoSelect.js";
|
|
7
9
|
import Dropdown from "primevue/dropdown";
|
|
8
|
-
const _hoisted_1 = { class: "
|
|
10
|
+
const _hoisted_1 = { class: "jf-control" };
|
|
9
11
|
const _hoisted_2 = {
|
|
10
12
|
key: 0,
|
|
11
|
-
class: "
|
|
13
|
+
class: "jf-label"
|
|
12
14
|
};
|
|
13
15
|
const _hoisted_3 = {
|
|
14
16
|
key: 1,
|
|
15
|
-
class: "
|
|
17
|
+
class: "jf-description"
|
|
16
18
|
};
|
|
17
19
|
const _hoisted_4 = {
|
|
18
20
|
key: 2,
|
|
@@ -65,7 +67,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
65
67
|
const instance = getCurrentInstance();
|
|
66
68
|
const props = instance.props;
|
|
67
69
|
const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
|
|
68
|
-
const {
|
|
70
|
+
const {
|
|
71
|
+
projectedData,
|
|
72
|
+
handleProjectedChange: handleChange,
|
|
73
|
+
projectedErrors,
|
|
74
|
+
projectedLabel
|
|
75
|
+
} = useProjection(control, rawHandleChange);
|
|
69
76
|
const toOptions = (schema) => {
|
|
70
77
|
if (!schema) return [];
|
|
71
78
|
const s = schema;
|
|
@@ -112,7 +119,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
112
119
|
} = useProvider(binding, {
|
|
113
120
|
data: rootData,
|
|
114
121
|
path: control.value.path,
|
|
115
|
-
dependsOnValues: depValues
|
|
122
|
+
dependsOnValues: depValues
|
|
116
123
|
});
|
|
117
124
|
const placeholder = computed(() => {
|
|
118
125
|
if (loading.value) return "Loading…";
|
|
@@ -125,6 +132,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
125
132
|
return toOptions(control.value.schema);
|
|
126
133
|
});
|
|
127
134
|
useDerive({ control, handleChange, data: projectedData });
|
|
135
|
+
useDeriveInitialValue({ control, handleChange });
|
|
128
136
|
watch(
|
|
129
137
|
[providerItems, loading],
|
|
130
138
|
([items, isLoading]) => {
|
|
@@ -140,32 +148,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
140
148
|
},
|
|
141
149
|
{ immediate: true }
|
|
142
150
|
);
|
|
143
|
-
const
|
|
144
|
-
const showErrors = computed(() => hasInteracted.value && control.value.errors);
|
|
151
|
+
const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
|
|
145
152
|
const onSelect = (val) => {
|
|
146
153
|
handleChange(control.value.path, val);
|
|
147
154
|
};
|
|
148
|
-
const onBlur = () => {
|
|
149
|
-
hasInteracted.value = true;
|
|
150
|
-
};
|
|
151
155
|
return (_ctx, _cache) => {
|
|
152
156
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
153
|
-
unref(
|
|
157
|
+
unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
|
|
154
158
|
unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
|
|
155
159
|
createVNode(unref(Dropdown), {
|
|
156
|
-
class: "w-full",
|
|
160
|
+
class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
|
|
157
161
|
options: options.value,
|
|
158
162
|
"option-label": "label",
|
|
159
163
|
"option-value": "value",
|
|
160
164
|
"model-value": unref(projectedData) ?? null,
|
|
161
165
|
placeholder: placeholder.value,
|
|
162
166
|
disabled: !unref(control).enabled || unref(loading),
|
|
163
|
-
"aria-invalid":
|
|
167
|
+
"aria-invalid": unref(showErrors) || void 0,
|
|
164
168
|
"show-clear": true,
|
|
165
169
|
"onUpdate:modelValue": onSelect,
|
|
166
|
-
onBlur
|
|
167
|
-
}, null, 8, ["options", "model-value", "placeholder", "disabled", "aria-invalid"]),
|
|
168
|
-
unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed to load: " + toDisplayString(unref(error)), 1)) : showErrors
|
|
170
|
+
onBlur: unref(markDirty)
|
|
171
|
+
}, null, 8, ["class", "options", "model-value", "placeholder", "disabled", "aria-invalid", "onBlur"]),
|
|
172
|
+
unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed to load: " + toDisplayString(unref(error)), 1)) : unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_5, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
|
|
169
173
|
]);
|
|
170
174
|
};
|
|
171
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfEnum.vue.js","sources":["../../../src/vue/primevue/JfEnum.vue"],"sourcesContent":["<script lang=\"ts\">\n// Define props manually to avoid any potential circular dependency issues\nexport default {\n name: \"JfEnum\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { JsonSchema } from \"@jsonforms/core\";\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed,
|
|
1
|
+
{"version":3,"file":"JfEnum.vue.js","sources":["../../../src/vue/primevue/JfEnum.vue"],"sourcesContent":["<script lang=\"ts\">\n// Define props manually to avoid any potential circular dependency issues\nexport default {\n name: \"JfEnum\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { JsonSchema } from \"@jsonforms/core\";\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed, inject, getCurrentInstance, watch } from \"vue\";\nimport { useProvider } from \"../composables/useProvider\";\nimport { useDerive } from \"../composables/useDerive\";\nimport { useDeriveInitialValue } from \"../composables/useDeriveInitialValue\";\nimport { useProjection } from \"../composables/useProjection\";\nimport { useDirtyValidation } from \"../composables/useDirtyValidation\";\nimport { shouldAutoSelect } from \"../utils/autoSelect\";\nimport Dropdown from \"primevue/dropdown\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange: rawHandleChange } = useJsonFormsControl(props);\nconst {\n projectedData,\n handleProjectedChange: handleChange,\n projectedErrors,\n projectedLabel,\n} = useProjection(control, rawHandleChange);\n\ntype Opt = { label: string; value: unknown };\nconst toOptions = (schema?: JsonSchema): Opt[] => {\n if (!schema) return [];\n const s = schema as {\n enum?: unknown[];\n oneOf?: Array<{ title?: string; const: unknown }>;\n };\n if (Array.isArray(s.enum))\n return s.enum.map((v: unknown) => ({ label: String(v), value: v }));\n if (Array.isArray(s.oneOf))\n return s.oneOf.map((o) => ({\n label: o.title ?? String(o.const),\n value: o.const,\n }));\n return [];\n};\n\n// Provider support\nconst binding = computed(() => {\n const provider = control.value.uischema?.options?.provider;\n // Ensure load property is set to 'mount' by default\n if (provider && typeof provider === \"object\" && !provider.load) {\n return { ...provider, load: \"mount\" };\n }\n return provider;\n});\n\nconst deps = computed(\n () =>\n ((\n (control.value.schema as Record<string, unknown>)?.[\n \"x-provider\"\n ] as Record<string, unknown>\n )?.dependsOn as string[]) ?? [],\n);\nconst depValues = computed(() => {\n return deps.value.map((dep) => {\n // Resolve dependency value from form data using JSON pointer-like path\n const path = dep.startsWith(\"#/\") ? dep.slice(2) : dep;\n const keys = path.replace(/\\//g, \".\").split(\".\");\n let value: unknown = rootData.value;\n for (const key of keys) {\n if (value && typeof value === \"object\" && key in value) {\n value = (value as Record<string, unknown>)[key];\n } else {\n return null;\n }\n }\n return value;\n });\n});\n\n// Get the root form data from JSONForms context for template URL resolution\nconst injectedFormData = inject<{ value: unknown }>(\"formData\", { value: {} });\nconst rootData = computed(() => injectedFormData.value || {});\n\n// Use provider if available, otherwise fall back to schema enum/oneOf\nconst {\n items: providerItems,\n loading,\n error,\n} = useProvider(binding, {\n data: rootData,\n path: control.value.path,\n dependsOnValues: depValues,\n});\n\nconst placeholder = computed<string | undefined>(() => {\n if (loading.value) return \"Loading…\";\n return (\n (control.value.uischema as { options?: { placeholder?: string } })?.options\n ?.placeholder ?? control.value.description\n );\n});\n\nconst options = computed(() => {\n // Use provider items if available, otherwise fall back to schema enum/oneOf\n if (binding.value && providerItems.value.length > 0) {\n return providerItems.value;\n }\n return toOptions(control.value.schema);\n});\n\n// Add derive functionality\nuseDerive({ control, handleChange, data: projectedData });\n\n// Add deriveInitialValue — async API-based initial value seeding\nuseDeriveInitialValue({ control, handleChange });\n\n// Auto-select when provider returns only one item (enabled by default)\nwatch(\n [providerItems, loading],\n ([items, isLoading]) => {\n const valueToSelect = shouldAutoSelect({\n autoSelectSingle:\n control.value.uischema?.options?.autoSelectSingle !== false,\n isLoading,\n items,\n currentValue: projectedData.value,\n });\n\n if (valueToSelect !== null) {\n handleChange(control.value.path, valueToSelect);\n }\n },\n { immediate: true },\n);\n\n// Track user interaction — errors only show after blur\nconst { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);\n\nconst onSelect = (val: unknown) => {\n handleChange(control.value.path, val);\n};\n</script>\n\n<template>\n <div class=\"jf-control\">\n <label v-if=\"projectedLabel\" class=\"jf-label\">{{ projectedLabel }}</label>\n <div v-if=\"control.description\" class=\"jf-description\">\n {{ control.description }}\n </div>\n <Dropdown\n :class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :options=\"options\"\n option-label=\"label\"\n option-value=\"value\"\n :model-value=\"projectedData ?? null\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled || loading\"\n :aria-invalid=\"showErrors || undefined\"\n :show-clear=\"true\"\n @update:model-value=\"onSelect\"\n @blur=\"markDirty\"\n />\n <small v-if=\"error\" class=\"p-error\" role=\"alert\"\n >Failed to load: {{ error }}</small\n >\n <small v-else-if=\"showErrors\" class=\"p-error\">{{ projectedErrors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAA,cAAe;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,IACL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;;;;AAiBA,UAAM,WAAW,mBAAA;AACjB,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,SAAS,cAAc,gBAAA,IAAoB,oBAAoB,KAAK;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,uBAAuB;AAAA,MACvB;AAAA,MACA;AAAA,IAAA,IACE,cAAc,SAAS,eAAe;A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Q,eAAnBF,UAAA,GAAAC,mBAEM,OAFN,YAEME,gBADDD,MAAA,OAAA,EAAQ,WAAW,GAAA,CAAA;QAExBE,YAYEF,MAAA,QAAA,GAAA;AAAA,UAXC,iDAAkCA,MAAA,UAAA,EAAA,CAAU,CAAA;AAAA,UAC5C,SAAS,QAAA;AAAA,UACV,gBAAa;AAAA,UACb,gBAAa;AAAA,UACZ,eAAaA,MAAA,aAAA,KAAa;AAAA,UAC1B,aAAa,YAAA;AAAA,UACb,UAAQ,CAAGA,MAAA,OAAA,EAAQ,WAAWA,MAAA,OAAA;AAAA,UAC9B,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B,cAAY;AAAA,UACZ,uBAAoB;AAAA,UACpB,QAAMA,MAAA,SAAA;AAAA,QAAA;QAEIA,MAAA,KAAA,KAAbF,UAAA,GAAAC,mBAEC,SAFD,YACG,qCAAmBC,MAAA,KAAA,CAAK,GAAA,CAAA,KAETA,MAAA,UAAA,kBAAlBD,mBAA2E,SAA3E,YAA2EE,gBAA1BD,MAAA,eAAA,CAAe,GAAA,CAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfEnumArray.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfEnumArray.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"JfEnumArray.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfEnumArray.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,wBA+UK"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, computed, inject, watch, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString } from "vue";
|
|
1
|
+
import { defineComponent, getCurrentInstance, computed, inject, watch, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString, normalizeClass } from "vue";
|
|
2
2
|
import { useJsonFormsControl } from "@jsonforms/vue";
|
|
3
3
|
import { useProvider } from "../composables/useProvider.js";
|
|
4
4
|
import { useDerive } from "../composables/useDerive.js";
|
|
5
5
|
import { useProjection } from "../composables/useProjection.js";
|
|
6
|
+
import { useDirtyValidation } from "../composables/useDirtyValidation.js";
|
|
6
7
|
import { shouldAutoSelectMulti } from "../utils/autoSelect.js";
|
|
7
8
|
import MultiSelect from "primevue/multiselect";
|
|
8
|
-
const _hoisted_1 = { class: "
|
|
9
|
+
const _hoisted_1 = { class: "jf-control" };
|
|
9
10
|
const _hoisted_2 = {
|
|
10
11
|
key: 0,
|
|
11
|
-
class: "
|
|
12
|
+
class: "jf-label"
|
|
12
13
|
};
|
|
13
14
|
const _hoisted_3 = {
|
|
14
15
|
key: 1,
|
|
15
|
-
class: "
|
|
16
|
+
class: "jf-description"
|
|
16
17
|
};
|
|
17
18
|
const _hoisted_4 = {
|
|
18
19
|
key: 2,
|
|
@@ -65,7 +66,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
65
66
|
const instance = getCurrentInstance();
|
|
66
67
|
const props = instance.props;
|
|
67
68
|
const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
|
|
68
|
-
const {
|
|
69
|
+
const {
|
|
70
|
+
projectedData,
|
|
71
|
+
handleProjectedChange: handleChange,
|
|
72
|
+
projectedErrors,
|
|
73
|
+
projectedLabel
|
|
74
|
+
} = useProjection(control, rawHandleChange);
|
|
69
75
|
const toOptions = (schema) => {
|
|
70
76
|
if (!schema) return [];
|
|
71
77
|
const s = schema;
|
|
@@ -112,7 +118,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
112
118
|
} = useProvider(binding, {
|
|
113
119
|
data: rootData,
|
|
114
120
|
path: control.value.path,
|
|
115
|
-
dependsOnValues: depValues
|
|
121
|
+
dependsOnValues: depValues
|
|
116
122
|
});
|
|
117
123
|
const options = computed(() => {
|
|
118
124
|
if (binding.value && providerItems.value.length > 0) {
|
|
@@ -121,6 +127,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
121
127
|
return toOptions(control.value.schema?.items);
|
|
122
128
|
});
|
|
123
129
|
useDerive({ control, handleChange, data: projectedData });
|
|
130
|
+
const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
|
|
124
131
|
watch(
|
|
125
132
|
[providerItems, loading],
|
|
126
133
|
([items, isLoading]) => {
|
|
@@ -154,27 +161,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
154
161
|
set(val) {
|
|
155
162
|
const next = Array.isArray(val) ? [...val] : [];
|
|
156
163
|
const curr = Array.isArray(projectedData.value) ? projectedData.value : [];
|
|
157
|
-
if (!sameSet(curr, next))
|
|
164
|
+
if (!sameSet(curr, next)) {
|
|
165
|
+
markDirty();
|
|
166
|
+
handleChange(control.value.path, next);
|
|
167
|
+
}
|
|
158
168
|
}
|
|
159
169
|
});
|
|
160
170
|
return (_ctx, _cache) => {
|
|
161
171
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
162
|
-
unref(
|
|
172
|
+
unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
|
|
163
173
|
unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
|
|
164
174
|
createVNode(unref(MultiSelect), {
|
|
165
175
|
modelValue: model.value,
|
|
166
176
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
167
|
-
class: "w-full",
|
|
177
|
+
class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
|
|
168
178
|
options: options.value,
|
|
169
179
|
"option-label": "label",
|
|
170
180
|
"option-value": "value",
|
|
171
181
|
"data-key": "value",
|
|
172
182
|
display: "chip",
|
|
173
183
|
disabled: !unref(control).enabled || unref(loading),
|
|
174
|
-
"aria-invalid":
|
|
184
|
+
"aria-invalid": unref(showErrors) || void 0,
|
|
175
185
|
placeholder: placeholder.value
|
|
176
|
-
}, null, 8, ["modelValue", "options", "disabled", "aria-invalid", "placeholder"]),
|
|
177
|
-
unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed to load: " + toDisplayString(unref(error)), 1)) : unref(
|
|
186
|
+
}, null, 8, ["modelValue", "class", "options", "disabled", "aria-invalid", "placeholder"]),
|
|
187
|
+
unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed to load: " + toDisplayString(unref(error)), 1)) : unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_5, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
|
|
178
188
|
]);
|
|
179
189
|
};
|
|
180
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfEnumArray.vue.js","sources":["../../../src/vue/primevue/JfEnumArray.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfEnumArray\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { JsonSchema } from \"@jsonforms/core\";\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed, inject, getCurrentInstance, watch } from \"vue\";\nimport { useProvider } from \"../composables/useProvider\";\nimport { useDerive } from \"../composables/useDerive\";\nimport { useProjection } from \"../composables/useProjection\";\nimport { shouldAutoSelectMulti } from \"../utils/autoSelect\";\nimport MultiSelect from \"primevue/multiselect\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange: rawHandleChange } = useJsonFormsControl(props);\nconst { projectedData, handleProjectedChange: handleChange } = useProjection(control, rawHandleChange);\n\ntype Opt = { label: string; value: unknown };\nconst toOptions = (schema?: JsonSchema): Opt[] => {\n if (!schema) return [];\n const s = schema as {\n enum?: unknown[];\n oneOf?: Array<{ title?: string; const: unknown }>;\n };\n if (Array.isArray(s.enum))\n return s.enum.map((v: unknown) => ({ label: String(v), value: v }));\n if (Array.isArray(s.oneOf))\n return s.oneOf.map((o) => ({\n label: o.title ?? String(o.const),\n value: o.const,\n }));\n return [];\n};\n\n// Provider support\nconst binding = computed(() => {\n const provider = control.value.uischema?.options?.provider;\n // Ensure load property is set to 'mount' by default\n if (provider && typeof provider === \"object\" && !provider.load) {\n return { ...provider, load: \"mount\" };\n }\n return provider;\n});\n\nconst deps = computed(\n () =>\n ((\n (control.value.schema as Record<string, unknown>)?.[\n \"x-provider\"\n ] as Record<string, unknown>\n )?.dependsOn as string[]) ?? [],\n);\nconst depValues = computed(() => {\n return deps.value.map((dep) => {\n // Resolve dependency value from form data using JSON pointer-like path\n const path = dep.startsWith(\"#/\") ? dep.slice(2) : dep;\n const keys = path.replace(/\\//g, \".\").split(\".\");\n let value: unknown = rootData.value;\n for (const key of keys) {\n if (value && typeof value === \"object\" && key in value) {\n value = (value as Record<string, unknown>)[key];\n } else {\n return null;\n }\n }\n return value;\n });\n});\n\n// Get the root form data from JSONForms context for template URL resolution\nconst injectedFormData = inject<{ value: unknown }>(\"formData\", { value: {} });\nconst rootData = computed(() => injectedFormData.value || {});\n\n// Use provider if available, otherwise fall back to schema enum/oneOf\nconst {\n items: providerItems,\n loading,\n error,\n} = useProvider(binding, {\n data: rootData,\n path: control.value.path,\n dependsOnValues: depValues.value,\n});\n\nconst options = computed(() => {\n // Use provider items if available, otherwise fall back to schema enum/oneOf\n if (binding.value && providerItems.value.length > 0) {\n return providerItems.value;\n }\n return toOptions((control.value.schema as { items?: JsonSchema })?.items);\n});\n\n// Add derive functionality\nuseDerive({ control, handleChange, data: projectedData });\n\n// Auto-select when provider returns only one item (opt-in for multiselect)\nwatch(\n [providerItems, loading],\n ([items, isLoading]) => {\n const valueToSelect = shouldAutoSelectMulti({\n autoSelectSingle:\n control.value.uischema?.options?.autoSelectSingle === true,\n isLoading,\n items,\n currentValue: Array.isArray(projectedData.value) ? projectedData.value : [],\n });\n\n if (valueToSelect !== null) {\n handleChange(control.value.path, valueToSelect);\n }\n },\n { immediate: true }\n);\n\nconst placeholder = computed<string | undefined>(() => {\n if (loading.value) return \"Loading…\";\n return (\n (control.value.uischema as { options?: { placeholder?: string } })?.options\n ?.placeholder ?? control.value.description\n );\n});\n\n// order-insensitive shallow equality for primitive enums\nconst sameSet = (a: unknown[], b: unknown[]) => {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n const s = new Set(b);\n return a.every((v) => s.has(v));\n};\n\n// v-model with guard to avoid recursive updates\nconst model = computed<unknown[]>({\n get() {\n const curr = Array.isArray(projectedData.value) ? projectedData.value : [];\n // return a fresh copy so PrimeMultiSelect can't mutate JSONForms' array in place\n return [...curr];\n },\n set(val) {\n const next = Array.isArray(val) ? [...val] : [];\n const curr = Array.isArray(projectedData.value) ? projectedData.value : [];\n if (!sameSet(curr, next)) handleChange(control.value.path, next);\n },\n});\n</script>\n\n<template>\n <div class=\"flex flex-column gap-2\">\n <label v-if=\"control.label\" class=\"text-color text-left\">{{\n control.label\n }}</label>\n <div v-if=\"control.description\" class=\"text-color-secondary text-left\">\n {{ control.description }}\n </div>\n\n <MultiSelect\n v-model=\"model\"\n class=\"w-full\"\n :options=\"options\"\n option-label=\"label\"\n option-value=\"value\"\n data-key=\"value\"\n display=\"chip\"\n :disabled=\"!control.enabled || loading\"\n :aria-invalid=\"!!control.errors || undefined\"\n :placeholder=\"placeholder\"\n />\n\n <small v-if=\"error\" class=\"p-error\" role=\"alert\"\n >Failed to load: {{ error }}</small\n >\n <small v-else-if=\"control.errors\" class=\"p-error\">{{\n control.errors\n }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,MAAA,cAAe;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,IACL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;;;;AAeA,UAAM,WAAW,mBAAA;AACjB,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,SAAS,cAAc,gBAAA,IAAoB,oBAAoB,KAAK;AAC5E,UAAM,EAAE,eAAe,uBAAuB,iBAAiB,cAAc,SAAS,eAAe;AAGrG,UAAM,YAAY,CAAC,WAA+B;AAChD,UAAI,CAAC,OAAQ,QAAO,CAAA;AACpB,YAAM,IAAI;AAIV,UAAI,MAAM,QAAQ,EAAE,IAAI;AACtB,eAAO,EAAE,KAAK,IAAI,CAAC,OAAgB,EAAE,OAAO,OAAO,CAAC,GAAG,OAAO,EAAA,EAAI;AACpE,UAAI,MAAM,QAAQ,EAAE,KAAK;AACvB,eAAO,EAAE,MAAM,IAAI,CAAC,OAAO;AAAA,UACzB,O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QAAQ,MAAM,IAAI,EAAG,cAAa,QAAQ,MAAM,MAAM,IAAI;AAAA,MACjE;AAAA,IAAA,CACD;;AAIC,aAAAA,UAAA,GAAAC,mBA2BM,OA3BN,YA2BM;AAAA,QA1BSC,MAAA,OAAA,EAAQ,SAArBF,UAAA,GAAAC,mBAEU,SAFV,YAEUE,gBADRD,MAAA,OAAA,EAAQ,KAAK,GAAA,CAAA;QAEJA,MAAA,OAAA,EAAQ,eAAnBF,UAAA,GAAAC,mBAEM,OAFN,YAEME,gBADDD,MAAA,OAAA,EAAQ,WAAW,GAAA,CAAA;QAGxBE,YAWEF,MAAA,WAAA,GAAA;AAAA,sBAVS,MAAA;AAAA,uEAAA,MAAK,QAAA;AAAA,UACd,OAAM;AAAA,UACL,SAAS,QAAA;AAAA,UACV,gBAAa;AAAA,UACb,gBAAa;AAAA,UACb,YAAS;AAAA,UACT,SAAQ;AAAA,UACP,UAAQ,CAAGA,MAAA,OAAA,EAAQ,WAAWA,MAAA,OAAA;AAAA,UAC9B,gBAAY,CAAA,CAAIA,MAAA,OAAA,EAAQ,UAAU;AAAA,UAClC,aAAa,YAAA;AAAA,QAAA;QAGHA,MAAA,KAAA,KAAbF,UAAA,GAAAC,mBAEC,SAFD,YACG,qCAAmBC,MAAA,KAAA,CAAK,GAAA,CAAA,KAETA,MAAA,OAAA,EAAQ,UAA1BF,UAAA,GAAAC,mBAEU,SAFV,YAEUE,gBADRD,MAAA,OAAA,EAAQ,MAAM,GAAA,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"JfEnumArray.vue.js","sources":["../../../src/vue/primevue/JfEnumArray.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfEnumArray\",\n props: {\n uischema: {\n type: Object,\n required: true,\n },\n schema: {\n type: Object,\n required: true,\n },\n path: {\n type: String,\n required: true,\n },\n enabled: {\n type: Boolean,\n default: undefined,\n },\n renderers: {\n type: Array,\n required: false,\n default: undefined,\n },\n cells: {\n type: Array,\n required: false,\n default: undefined,\n },\n config: {\n type: Object,\n required: false,\n default: undefined,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { JsonSchema } from \"@jsonforms/core\";\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed, inject, getCurrentInstance, watch } from \"vue\";\nimport { useProvider } from \"../composables/useProvider\";\nimport { useDerive } from \"../composables/useDerive\";\nimport { useProjection } from \"../composables/useProjection\";\nimport { useDirtyValidation } from \"../composables/useDirtyValidation\";\nimport { shouldAutoSelectMulti } from \"../utils/autoSelect\";\nimport MultiSelect from \"primevue/multiselect\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange: rawHandleChange } = useJsonFormsControl(props);\nconst {\n projectedData,\n handleProjectedChange: handleChange,\n projectedErrors,\n projectedLabel,\n} = useProjection(control, rawHandleChange);\n\ntype Opt = { label: string; value: unknown };\nconst toOptions = (schema?: JsonSchema): Opt[] => {\n if (!schema) return [];\n const s = schema as {\n enum?: unknown[];\n oneOf?: Array<{ title?: string; const: unknown }>;\n };\n if (Array.isArray(s.enum))\n return s.enum.map((v: unknown) => ({ label: String(v), value: v }));\n if (Array.isArray(s.oneOf))\n return s.oneOf.map((o) => ({\n label: o.title ?? String(o.const),\n value: o.const,\n }));\n return [];\n};\n\n// Provider support\nconst binding = computed(() => {\n const provider = control.value.uischema?.options?.provider;\n // Ensure load property is set to 'mount' by default\n if (provider && typeof provider === \"object\" && !provider.load) {\n return { ...provider, load: \"mount\" };\n }\n return provider;\n});\n\nconst deps = computed(\n () =>\n ((\n (control.value.schema as Record<string, unknown>)?.[\n \"x-provider\"\n ] as Record<string, unknown>\n )?.dependsOn as string[]) ?? [],\n);\nconst depValues = computed(() => {\n return deps.value.map((dep) => {\n // Resolve dependency value from form data using JSON pointer-like path\n const path = dep.startsWith(\"#/\") ? dep.slice(2) : dep;\n const keys = path.replace(/\\//g, \".\").split(\".\");\n let value: unknown = rootData.value;\n for (const key of keys) {\n if (value && typeof value === \"object\" && key in value) {\n value = (value as Record<string, unknown>)[key];\n } else {\n return null;\n }\n }\n return value;\n });\n});\n\n// Get the root form data from JSONForms context for template URL resolution\nconst injectedFormData = inject<{ value: unknown }>(\"formData\", { value: {} });\nconst rootData = computed(() => injectedFormData.value || {});\n\n// Use provider if available, otherwise fall back to schema enum/oneOf\nconst {\n items: providerItems,\n loading,\n error,\n} = useProvider(binding, {\n data: rootData,\n path: control.value.path,\n dependsOnValues: depValues,\n});\n\nconst options = computed(() => {\n // Use provider items if available, otherwise fall back to schema enum/oneOf\n if (binding.value && providerItems.value.length > 0) {\n return providerItems.value;\n }\n return toOptions((control.value.schema as { items?: JsonSchema })?.items);\n});\n\n// Add derive functionality\nuseDerive({ control, handleChange, data: projectedData });\n\n// Track user interaction — errors only show after first change\nconst { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);\n\n// Auto-select when provider returns only one item (opt-in for multiselect)\nwatch(\n [providerItems, loading],\n ([items, isLoading]) => {\n const valueToSelect = shouldAutoSelectMulti({\n autoSelectSingle:\n control.value.uischema?.options?.autoSelectSingle === true,\n isLoading,\n items,\n currentValue: Array.isArray(projectedData.value)\n ? projectedData.value\n : [],\n });\n\n if (valueToSelect !== null) {\n handleChange(control.value.path, valueToSelect);\n }\n },\n { immediate: true },\n);\n\nconst placeholder = computed<string | undefined>(() => {\n if (loading.value) return \"Loading…\";\n return (\n (control.value.uischema as { options?: { placeholder?: string } })?.options\n ?.placeholder ?? control.value.description\n );\n});\n\n// order-insensitive shallow equality for primitive enums\nconst sameSet = (a: unknown[], b: unknown[]) => {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n const s = new Set(b);\n return a.every((v) => s.has(v));\n};\n\n// v-model with guard to avoid recursive updates\nconst model = computed<unknown[]>({\n get() {\n const curr = Array.isArray(projectedData.value) ? projectedData.value : [];\n // return a fresh copy so PrimeMultiSelect can't mutate JSONForms' array in place\n return [...curr];\n },\n set(val) {\n const next = Array.isArray(val) ? [...val] : [];\n const curr = Array.isArray(projectedData.value) ? projectedData.value : [];\n if (!sameSet(curr, next)) {\n markDirty();\n handleChange(control.value.path, next);\n }\n },\n});\n</script>\n\n<template>\n <div class=\"jf-control\">\n <label v-if=\"projectedLabel\" class=\"jf-label\">{{ projectedLabel }}</label>\n <div v-if=\"control.description\" class=\"jf-description\">\n {{ control.description }}\n </div>\n\n <MultiSelect\n v-model=\"model\"\n :class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :options=\"options\"\n option-label=\"label\"\n option-value=\"value\"\n data-key=\"value\"\n display=\"chip\"\n :disabled=\"!control.enabled || loading\"\n :aria-invalid=\"showErrors || undefined\"\n :placeholder=\"placeholder\"\n />\n\n <small v-if=\"error\" class=\"p-error\" role=\"alert\"\n >Failed to load: {{ error }}</small\n >\n <small v-else-if=\"showErrors\" class=\"p-error\">{{ projectedErrors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,MAAA,cAAe;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,IACL,UAAU;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX,WAAW;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,IAEX,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,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GA,MAAA,OAAA,EAAQ,WAAWA,MAAA,OAAA;AAAA,UAC9B,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B,aAAa,YAAA;AAAA,QAAA;QAGHA,MAAA,KAAA,KAAbF,UAAA,GAAAC,mBAEC,SAFD,YACG,qCAAmBC,MAAA,KAAA,CAAK,GAAA,CAAA,KAETA,MAAA,UAAA,kBAAlBD,mBAA2E,SAA3E,YAA2EE,gBAA1BD,MAAA,eAAA,CAAe,GAAA,CAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4JA,wBA0QK"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { defineComponent, getCurrentInstance, computed,
|
|
1
|
+
import { defineComponent, getCurrentInstance, computed, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString, normalizeClass } from "vue";
|
|
2
2
|
import { useJsonFormsControl } from "@jsonforms/vue";
|
|
3
3
|
import { useDerive } from "../composables/useDerive.js";
|
|
4
|
+
import { useDeriveInitialValue } from "../composables/useDeriveInitialValue.js";
|
|
4
5
|
import { useProjection } from "../composables/useProjection.js";
|
|
6
|
+
import { useDirtyValidation } from "../composables/useDirtyValidation.js";
|
|
5
7
|
import InputNumber from "primevue/inputnumber";
|
|
6
|
-
const _hoisted_1 = { class: "
|
|
8
|
+
const _hoisted_1 = { class: "jf-control" };
|
|
7
9
|
const _hoisted_2 = {
|
|
8
10
|
key: 0,
|
|
9
|
-
class: "
|
|
11
|
+
class: "jf-label"
|
|
10
12
|
};
|
|
11
13
|
const _hoisted_3 = {
|
|
12
14
|
key: 1,
|
|
13
|
-
class: "
|
|
15
|
+
class: "jf-description"
|
|
14
16
|
};
|
|
15
17
|
const _hoisted_4 = {
|
|
16
18
|
key: 2,
|
|
@@ -58,7 +60,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
58
60
|
const instance = getCurrentInstance();
|
|
59
61
|
const props = instance.props;
|
|
60
62
|
const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
|
|
61
|
-
const {
|
|
63
|
+
const {
|
|
64
|
+
projectedData,
|
|
65
|
+
handleProjectedChange: handleChange,
|
|
66
|
+
projectedErrors,
|
|
67
|
+
projectedLabel
|
|
68
|
+
} = useProjection(control, rawHandleChange);
|
|
62
69
|
const options = computed(
|
|
63
70
|
() => control.value.uischema?.options ?? {}
|
|
64
71
|
);
|
|
@@ -66,6 +73,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
66
73
|
() => options.value.placeholder ?? control.value.description
|
|
67
74
|
);
|
|
68
75
|
useDerive({ control, handleChange, data: projectedData });
|
|
76
|
+
useDeriveInitialValue({ control, handleChange });
|
|
69
77
|
const mode = computed(() => {
|
|
70
78
|
if (options.value.currency) return "currency";
|
|
71
79
|
if (options.value.decimal || typeof options.value.precision === "number")
|
|
@@ -93,21 +101,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
93
101
|
if (mode.value === "currency") return true;
|
|
94
102
|
return options.value.useGrouping === true;
|
|
95
103
|
});
|
|
96
|
-
const
|
|
97
|
-
const showErrors = computed(() => hasInteracted.value && control.value.errors);
|
|
104
|
+
const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
|
|
98
105
|
const onNumber = (val) => {
|
|
99
106
|
handleChange(control.value.path, val ?? void 0);
|
|
100
107
|
};
|
|
101
|
-
const onBlur = () => {
|
|
102
|
-
hasInteracted.value = true;
|
|
103
|
-
};
|
|
104
108
|
return (_ctx, _cache) => {
|
|
105
109
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
106
|
-
unref(
|
|
110
|
+
unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
|
|
107
111
|
unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
|
|
108
112
|
createVNode(unref(InputNumber), {
|
|
109
|
-
class: "w-full",
|
|
110
|
-
"input-class": "w-full",
|
|
113
|
+
class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
|
|
114
|
+
"input-class": ["w-full!", { "p-invalid": unref(showErrors) }],
|
|
111
115
|
"use-grouping": useGrouping.value,
|
|
112
116
|
mode: mode.value,
|
|
113
117
|
currency: currency.value,
|
|
@@ -116,11 +120,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
116
120
|
"model-value": typeof unref(projectedData) === "number" ? unref(projectedData) : null,
|
|
117
121
|
placeholder: placeholder.value,
|
|
118
122
|
disabled: !unref(control).enabled,
|
|
119
|
-
"aria-invalid":
|
|
123
|
+
"aria-invalid": unref(showErrors) || void 0,
|
|
120
124
|
"onUpdate:modelValue": onNumber,
|
|
121
|
-
onBlur
|
|
122
|
-
}, null, 8, ["use-grouping", "mode", "currency", "min-fraction-digits", "max-fraction-digits", "model-value", "placeholder", "disabled", "aria-invalid"]),
|
|
123
|
-
showErrors
|
|
125
|
+
onBlur: unref(markDirty)
|
|
126
|
+
}, null, 8, ["class", "input-class", "use-grouping", "mode", "currency", "min-fraction-digits", "max-fraction-digits", "model-value", "placeholder", "disabled", "aria-invalid", "onBlur"]),
|
|
127
|
+
unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
|
|
124
128
|
]);
|
|
125
129
|
};
|
|
126
130
|
}
|