@narrative.io/jsonforms-provider-protocols 2.11.0 → 2.12.0

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 (147) hide show
  1. package/README.md +193 -33
  2. package/dist/core/initFormData.d.ts +17 -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 +36 -0
  7. package/dist/core/projection.d.ts.map +1 -0
  8. package/dist/core/projection.js +77 -0
  9. package/dist/core/projection.js.map +1 -0
  10. package/dist/core/refs.d.ts +58 -0
  11. package/dist/core/refs.d.ts.map +1 -0
  12. package/dist/core/refs.js +70 -0
  13. package/dist/core/refs.js.map +1 -0
  14. package/dist/core/resolveScope.d.ts +17 -0
  15. package/dist/core/resolveScope.d.ts.map +1 -0
  16. package/dist/core/resolveScope.js +28 -0
  17. package/dist/core/resolveScope.js.map +1 -0
  18. package/dist/core/seedProjectionTargets.d.ts +60 -0
  19. package/dist/core/seedProjectionTargets.d.ts.map +1 -0
  20. package/dist/core/seedProjectionTargets.js +52 -0
  21. package/dist/core/seedProjectionTargets.js.map +1 -0
  22. package/dist/core/transforms.d.ts +8 -10
  23. package/dist/core/transforms.d.ts.map +1 -1
  24. package/dist/core/transforms.js +58 -13
  25. package/dist/core/transforms.js.map +1 -1
  26. package/dist/core/types.d.ts +8 -0
  27. package/dist/core/types.d.ts.map +1 -1
  28. package/dist/index.d.ts +9 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +21 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/jsonforms-provider-protocols.css +6 -2
  33. package/dist/no-eval-ajv.d.ts +70 -0
  34. package/dist/no-eval-ajv.d.ts.map +1 -0
  35. package/dist/no-eval-ajv.js +247 -0
  36. package/dist/no-eval-ajv.js.map +1 -0
  37. package/dist/vue/components/ProviderAutocomplete.vue.d.ts.map +1 -1
  38. package/dist/vue/components/ProviderAutocomplete.vue.js +12 -6
  39. package/dist/vue/components/ProviderAutocomplete.vue.js.map +1 -1
  40. package/dist/vue/components/ProviderMultiSelect.vue.d.ts.map +1 -1
  41. package/dist/vue/components/ProviderMultiSelect.vue.js +1 -1
  42. package/dist/vue/components/ProviderMultiSelect.vue2.js +21 -11
  43. package/dist/vue/components/ProviderMultiSelect.vue2.js.map +1 -1
  44. package/dist/vue/components/ProviderObjectMultiSelect.vue.d.ts +9 -0
  45. package/dist/vue/components/ProviderObjectMultiSelect.vue.d.ts.map +1 -0
  46. package/dist/vue/components/ProviderObjectMultiSelect.vue.js +8 -0
  47. package/dist/vue/components/ProviderObjectMultiSelect.vue.js.map +1 -0
  48. package/dist/vue/components/ProviderObjectMultiSelect.vue2.js +142 -0
  49. package/dist/vue/components/ProviderObjectMultiSelect.vue2.js.map +1 -0
  50. package/dist/vue/components/ProviderSelect.vue.d.ts.map +1 -1
  51. package/dist/vue/components/ProviderSelect.vue.js +1 -1
  52. package/dist/vue/components/ProviderSelect.vue2.js +22 -10
  53. package/dist/vue/components/ProviderSelect.vue2.js.map +1 -1
  54. package/dist/vue/composables/useDataLayer.d.ts +10 -0
  55. package/dist/vue/composables/useDataLayer.d.ts.map +1 -0
  56. package/dist/vue/composables/useDataLayer.js +26 -0
  57. package/dist/vue/composables/useDataLayer.js.map +1 -0
  58. package/dist/vue/composables/useDerive.d.ts +5 -2
  59. package/dist/vue/composables/useDerive.d.ts.map +1 -1
  60. package/dist/vue/composables/useDerive.js +29 -12
  61. package/dist/vue/composables/useDerive.js.map +1 -1
  62. package/dist/vue/composables/useDeriveInitialValue.d.ts +36 -0
  63. package/dist/vue/composables/useDeriveInitialValue.d.ts.map +1 -0
  64. package/dist/vue/composables/useDeriveInitialValue.js +125 -0
  65. package/dist/vue/composables/useDeriveInitialValue.js.map +1 -0
  66. package/dist/vue/composables/useDirtyValidation.d.ts +9 -0
  67. package/dist/vue/composables/useDirtyValidation.d.ts.map +1 -0
  68. package/dist/vue/composables/useDirtyValidation.js +15 -0
  69. package/dist/vue/composables/useDirtyValidation.js.map +1 -0
  70. package/dist/vue/composables/useProjection.d.ts +42 -0
  71. package/dist/vue/composables/useProjection.d.ts.map +1 -0
  72. package/dist/vue/composables/useProjection.js +116 -0
  73. package/dist/vue/composables/useProjection.js.map +1 -0
  74. package/dist/vue/composables/useProvider.d.ts +2 -2
  75. package/dist/vue/composables/useProvider.d.ts.map +1 -1
  76. package/dist/vue/composables/useProvider.js +14 -10
  77. package/dist/vue/composables/useProvider.js.map +1 -1
  78. package/dist/vue/index.d.ts +9 -1
  79. package/dist/vue/index.d.ts.map +1 -1
  80. package/dist/vue/index.js +72 -34
  81. package/dist/vue/index.js.map +1 -1
  82. package/dist/vue/primevue/JfBoolean.vue.d.ts +9 -0
  83. package/dist/vue/primevue/JfBoolean.vue.d.ts.map +1 -1
  84. package/dist/vue/primevue/JfBoolean.vue.js +44 -17
  85. package/dist/vue/primevue/JfBoolean.vue.js.map +1 -1
  86. package/dist/vue/primevue/JfEnum.vue.d.ts +9 -0
  87. package/dist/vue/primevue/JfEnum.vue.d.ts.map +1 -1
  88. package/dist/vue/primevue/JfEnum.vue.js +38 -24
  89. package/dist/vue/primevue/JfEnum.vue.js.map +1 -1
  90. package/dist/vue/primevue/JfEnumArray.vue.d.ts +9 -0
  91. package/dist/vue/primevue/JfEnumArray.vue.d.ts.map +1 -1
  92. package/dist/vue/primevue/JfEnumArray.vue.js +40 -20
  93. package/dist/vue/primevue/JfEnumArray.vue.js.map +1 -1
  94. package/dist/vue/primevue/JfNumber.vue.d.ts +9 -0
  95. package/dist/vue/primevue/JfNumber.vue.d.ts.map +1 -1
  96. package/dist/vue/primevue/JfNumber.vue.js +33 -23
  97. package/dist/vue/primevue/JfNumber.vue.js.map +1 -1
  98. package/dist/vue/primevue/JfText.vue.d.ts +9 -0
  99. package/dist/vue/primevue/JfText.vue.d.ts.map +1 -1
  100. package/dist/vue/primevue/JfText.vue.js +51 -35
  101. package/dist/vue/primevue/JfText.vue.js.map +1 -1
  102. package/dist/vue/primevue/JfTextArea.vue.d.ts +9 -0
  103. package/dist/vue/primevue/JfTextArea.vue.d.ts.map +1 -1
  104. package/dist/vue/primevue/JfTextArea.vue.js +34 -19
  105. package/dist/vue/primevue/JfTextArea.vue.js.map +1 -1
  106. package/dist/vue/primevue/index.d.ts.map +1 -1
  107. package/dist/vue/primevue/index.js +100 -8
  108. package/dist/vue/primevue/index.js.map +1 -1
  109. package/dist/vue/utils/objectMultiSelect.d.ts +68 -0
  110. package/dist/vue/utils/objectMultiSelect.d.ts.map +1 -0
  111. package/dist/vue/utils/objectMultiSelect.js +72 -0
  112. package/dist/vue/utils/objectMultiSelect.js.map +1 -0
  113. package/dist/vue/utils/placeholder.d.ts +17 -0
  114. package/dist/vue/utils/placeholder.d.ts.map +1 -0
  115. package/dist/vue/utils/placeholder.js +17 -0
  116. package/dist/vue/utils/placeholder.js.map +1 -0
  117. package/package.json +10 -2
  118. package/src/core/initFormData.ts +208 -0
  119. package/src/core/projection.ts +147 -0
  120. package/src/core/refs.ts +166 -0
  121. package/src/core/resolveScope.ts +54 -0
  122. package/src/core/seedProjectionTargets.ts +144 -0
  123. package/src/core/transforms.ts +118 -26
  124. package/src/core/types.ts +9 -0
  125. package/src/index.ts +22 -2
  126. package/src/no-eval-ajv.ts +381 -0
  127. package/src/vue/components/ProviderAutocomplete.vue +11 -7
  128. package/src/vue/components/ProviderMultiSelect.vue +22 -15
  129. package/src/vue/components/ProviderObjectMultiSelect.vue +169 -0
  130. package/src/vue/components/ProviderSelect.vue +23 -14
  131. package/src/vue/composables/useDataLayer.ts +43 -0
  132. package/src/vue/composables/useDerive.ts +62 -16
  133. package/src/vue/composables/useDeriveInitialValue.ts +195 -0
  134. package/src/vue/composables/useDirtyValidation.ts +20 -0
  135. package/src/vue/composables/useProjection.ts +245 -0
  136. package/src/vue/composables/useProvider.ts +28 -11
  137. package/src/vue/index.ts +83 -47
  138. package/src/vue/primevue/JfBoolean.vue +35 -12
  139. package/src/vue/primevue/JfEnum.vue +35 -26
  140. package/src/vue/primevue/JfEnumArray.vue +37 -20
  141. package/src/vue/primevue/JfNumber.vue +32 -24
  142. package/src/vue/primevue/JfText.vue +48 -33
  143. package/src/vue/primevue/JfTextArea.vue +32 -21
  144. package/src/vue/primevue/index.ts +114 -8
  145. package/src/vue/styles.css +26 -1
  146. package/src/vue/utils/objectMultiSelect.ts +171 -0
  147. package/src/vue/utils/placeholder.ts +42 -0
@@ -18,14 +18,17 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
18
18
  renderers: {
19
19
  type: ArrayConstructor;
20
20
  required: false;
21
+ default: undefined;
21
22
  };
22
23
  cells: {
23
24
  type: ArrayConstructor;
24
25
  required: false;
26
+ default: undefined;
25
27
  };
26
28
  config: {
27
29
  type: ObjectConstructor;
28
30
  required: false;
31
+ default: undefined;
29
32
  };
30
33
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
34
  uischema: {
@@ -47,17 +50,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
47
50
  renderers: {
48
51
  type: ArrayConstructor;
49
52
  required: false;
53
+ default: undefined;
50
54
  };
51
55
  cells: {
52
56
  type: ArrayConstructor;
53
57
  required: false;
58
+ default: undefined;
54
59
  };
55
60
  config: {
56
61
  type: ObjectConstructor;
57
62
  required: false;
63
+ default: undefined;
58
64
  };
59
65
  }>> & Readonly<{}>, {
66
+ config: Record<string, any>;
60
67
  enabled: boolean;
68
+ renderers: unknown[];
69
+ cells: unknown[];
61
70
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
71
  export default _default;
63
72
  //# sourceMappingURL=JfNumber.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkJA,wBAmQK"}
1
+ {"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8JA,wBA0QK"}
@@ -1,15 +1,19 @@
1
- import { defineComponent, getCurrentInstance, computed, ref, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString } from "vue";
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";
5
+ import { useProjection } from "../composables/useProjection.js";
6
+ import { useDirtyValidation } from "../composables/useDirtyValidation.js";
7
+ import { resolvePlaceholder } from "../utils/placeholder.js";
4
8
  import InputNumber from "primevue/inputnumber";
5
- const _hoisted_1 = { class: "flex flex-col gap-2" };
9
+ const _hoisted_1 = { class: "jf-control" };
6
10
  const _hoisted_2 = {
7
11
  key: 0,
8
- class: "text-color text-left"
12
+ class: "jf-label"
9
13
  };
10
14
  const _hoisted_3 = {
11
15
  key: 1,
12
- class: "text-color-secondary text-left"
16
+ class: "jf-description"
13
17
  };
14
18
  const _hoisted_4 = {
15
19
  key: 2,
@@ -36,15 +40,18 @@ const __default__ = {
36
40
  },
37
41
  renderers: {
38
42
  type: Array,
39
- required: false
43
+ required: false,
44
+ default: void 0
40
45
  },
41
46
  cells: {
42
47
  type: Array,
43
- required: false
48
+ required: false,
49
+ default: void 0
44
50
  },
45
51
  config: {
46
52
  type: Object,
47
- required: false
53
+ required: false,
54
+ default: void 0
48
55
  }
49
56
  }
50
57
  };
@@ -53,14 +60,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
60
  setup(__props) {
54
61
  const instance = getCurrentInstance();
55
62
  const props = instance.props;
56
- const { control, handleChange } = useJsonFormsControl(props);
63
+ const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
64
+ const {
65
+ projectedData,
66
+ handleProjectedChange: handleChange,
67
+ projectedErrors,
68
+ projectedLabel
69
+ } = useProjection(control, rawHandleChange);
57
70
  const options = computed(
58
71
  () => control.value.uischema?.options ?? {}
59
72
  );
60
73
  const placeholder = computed(
61
- () => options.value.placeholder ?? control.value.description
74
+ () => resolvePlaceholder(control.value.uischema, projectedLabel.value, "input")
62
75
  );
63
- useDerive({ control, handleChange });
76
+ useDerive({ control, handleChange, data: projectedData });
77
+ useDeriveInitialValue({ control, handleChange });
64
78
  const mode = computed(() => {
65
79
  if (options.value.currency) return "currency";
66
80
  if (options.value.decimal || typeof options.value.precision === "number")
@@ -88,34 +102,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
88
102
  if (mode.value === "currency") return true;
89
103
  return options.value.useGrouping === true;
90
104
  });
91
- const hasInteracted = ref(false);
92
- const showErrors = computed(() => hasInteracted.value && control.value.errors);
105
+ const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
93
106
  const onNumber = (val) => {
94
107
  handleChange(control.value.path, val ?? void 0);
95
108
  };
96
- const onBlur = () => {
97
- hasInteracted.value = true;
98
- };
99
109
  return (_ctx, _cache) => {
100
110
  return openBlock(), createElementBlock("div", _hoisted_1, [
101
- unref(control).label ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(control).label), 1)) : createCommentVNode("", true),
111
+ unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
102
112
  unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
103
113
  createVNode(unref(InputNumber), {
104
- class: "w-full!",
105
- "input-class": "w-full!",
114
+ class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
115
+ "input-class": ["w-full!", { "p-invalid": unref(showErrors) }],
106
116
  "use-grouping": useGrouping.value,
107
117
  mode: mode.value,
108
118
  currency: currency.value,
109
119
  "min-fraction-digits": minFractionDigits.value,
110
120
  "max-fraction-digits": maxFractionDigits.value,
111
- "model-value": typeof unref(control).data === "number" ? unref(control).data : null,
121
+ "model-value": typeof unref(projectedData) === "number" ? unref(projectedData) : null,
112
122
  placeholder: placeholder.value,
113
123
  disabled: !unref(control).enabled,
114
- "aria-invalid": !!showErrors.value || void 0,
124
+ "aria-invalid": unref(showErrors) || void 0,
115
125
  "onUpdate:modelValue": onNumber,
116
- onBlur
117
- }, null, 8, ["use-grouping", "mode", "currency", "min-fraction-digits", "max-fraction-digits", "model-value", "placeholder", "disabled", "aria-invalid"]),
118
- showErrors.value ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(control).errors), 1)) : createCommentVNode("", true)
126
+ onBlur: unref(markDirty)
127
+ }, null, 8, ["class", "input-class", "use-grouping", "mode", "currency", "min-fraction-digits", "max-fraction-digits", "model-value", "placeholder", "disabled", "aria-invalid", "onBlur"]),
128
+ unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
119
129
  ]);
120
130
  };
121
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JfNumber.vue.js","sources":["../../../src/vue/primevue/JfNumber.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfNumber\",\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 },\n cells: {\n type: Array,\n required: false,\n },\n config: {\n type: Object,\n required: false,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed, ref, getCurrentInstance } from \"vue\";\nimport { useDerive } from \"../composables/useDerive\";\nimport InputNumber from \"primevue/inputnumber\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange } = useJsonFormsControl(props);\n\nconst options = computed(\n () =>\n (control.value.uischema as { options?: Record<string, unknown> })\n ?.options ?? {},\n);\n\nconst placeholder = computed<string | undefined>(\n () => (options.value.placeholder as string) ?? control.value.description,\n);\n\n// Add derive functionality\nuseDerive({ control, handleChange });\n\n// Currency and decimal configuration\nconst mode = computed(() => {\n if (options.value.currency) return \"currency\";\n if (options.value.decimal || typeof options.value.precision === \"number\")\n return \"decimal\";\n return undefined;\n});\n\nconst currency = computed(() =>\n typeof options.value.currency === \"string\" ? options.value.currency : \"USD\",\n);\n\nconst minFractionDigits = computed(() => {\n // For integer types, no fractional digits\n if (control.value.schema?.type === \"integer\") return 0;\n if (mode.value === \"currency\") return 2;\n if (typeof options.value.precision === \"number\")\n return options.value.precision;\n return undefined;\n});\n\nconst maxFractionDigits = computed(() => {\n // For integer types, no fractional digits\n if (control.value.schema?.type === \"integer\") return 0;\n if (mode.value === \"currency\") return 2;\n if (typeof options.value.precision === \"number\")\n return options.value.precision;\n return undefined;\n});\n\nconst useGrouping = computed(() => {\n // Enable grouping for currency by default, or if explicitly set\n if (mode.value === \"currency\") return true;\n return options.value.useGrouping === true;\n});\n\n// Track user interaction\nconst hasInteracted = ref(false);\n\nconst showErrors = computed(() => hasInteracted.value && control.value.errors);\n\nconst onNumber = (val: number | null) => {\n handleChange(control.value.path, val ?? undefined);\n};\n\nconst onBlur = () => {\n hasInteracted.value = true;\n};\n</script>\n\n<template>\n <div class=\"flex flex-col 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 <InputNumber\n class=\"w-full!\"\n input-class=\"w-full!\"\n :use-grouping=\"useGrouping\"\n :mode=\"mode\"\n :currency=\"currency\"\n :min-fraction-digits=\"minFractionDigits\"\n :max-fraction-digits=\"maxFractionDigits\"\n :model-value=\"typeof control.data === 'number' ? control.data : null\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"!!showErrors || undefined\"\n @update:model-value=\"onNumber\"\n @blur=\"onBlur\"\n />\n <small v-if=\"showErrors\" class=\"p-error\">{{ control.errors }}</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,IAAA;AAAA,IAEZ,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EACZ;AAEJ;;;;AAWA,UAAM,WAAW,mBAAA;AACjB,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,SAAS,iBAAiB,oBAAoB,KAAK;AAE3D,UAAM,UAAU;AAAA,MACd,MACG,QAAQ,MAAM,UACX,WAAW,CAAA;AAAA,IAAC;AAGpB,UAAM,cAAc;AAAA,MAClB,MAAO,QAAQ,MAAM,eAA0B,QAAQ,MAAM;AAAA,IAAA;AAI/D,cAAU,EAAE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EJA,MAAA,OAAA,EAAQ,eAAnBF,UAAA,GAAAC,mBAEM,OAFN,YAEME,gBADDD,MAAA,OAAA,EAAQ,WAAW,GAAA,CAAA;QAExBE,YAcEF,MAAA,WAAA,GAAA;AAAA,UAbA,OAAM;AAAA,UACN,eAAY;AAAA,UACX,gBAAc,YAAA;AAAA,UACd,MAAM,KAAA;AAAA,UACN,UAAU,SAAA;AAAA,UACV,uBAAqB,kBAAA;AAAA,UACrB,uBAAqB,kBAAA;AAAA,UACrB,sBAAoBA,MAAA,OAAA,EAAQ,SAAI,WAAgBA,MAAA,OAAA,EAAQ,OAAI;AAAA,UAC5D,aAAa,YAAA;AAAA,UACb,UAAQ,CAAGA,MAAA,OAAA,EAAQ;AAAA,UACnB,gBAAY,CAAA,CAAI,WAAA,SAAc;AAAA,UAC9B,uBAAoB;AAAA,UACpB;AAAA,QAAA;QAEU,WAAA,SAAbF,UAAA,GAAAC,mBAAqE,SAArE,YAAqEE,gBAAzBD,MAAA,OAAA,EAAQ,MAAM,GAAA,CAAA;;;;;"}
1
+ {"version":3,"file":"JfNumber.vue.js","sources":["../../../src/vue/primevue/JfNumber.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfNumber\",\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 { computed, getCurrentInstance } from \"vue\";\nimport { useDerive } from \"../composables/useDerive\";\nimport { useDeriveInitialValue } from \"../composables/useDeriveInitialValue\";\nimport { useProjection } from \"../composables/useProjection\";\nimport { useDirtyValidation } from \"../composables/useDirtyValidation\";\nimport { resolvePlaceholder } from \"../utils/placeholder\";\nimport InputNumber from \"primevue/inputnumber\";\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\nconst options = computed(\n () =>\n (control.value.uischema as { options?: Record<string, unknown> })\n ?.options ?? {},\n);\n\nconst placeholder = computed<string | undefined>(() =>\n resolvePlaceholder(control.value.uischema, projectedLabel.value, \"input\"),\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// Currency and decimal configuration\nconst mode = computed(() => {\n if (options.value.currency) return \"currency\";\n if (options.value.decimal || typeof options.value.precision === \"number\")\n return \"decimal\";\n return undefined;\n});\n\nconst currency = computed(() =>\n typeof options.value.currency === \"string\" ? options.value.currency : \"USD\",\n);\n\nconst minFractionDigits = computed(() => {\n // For integer types, no fractional digits\n if (control.value.schema?.type === \"integer\") return 0;\n if (mode.value === \"currency\") return 2;\n if (typeof options.value.precision === \"number\")\n return options.value.precision;\n return undefined;\n});\n\nconst maxFractionDigits = computed(() => {\n // For integer types, no fractional digits\n if (control.value.schema?.type === \"integer\") return 0;\n if (mode.value === \"currency\") return 2;\n if (typeof options.value.precision === \"number\")\n return options.value.precision;\n return undefined;\n});\n\nconst useGrouping = computed(() => {\n // Enable grouping for currency by default, or if explicitly set\n if (mode.value === \"currency\") return true;\n return options.value.useGrouping === true;\n});\n\n// Track user interaction errors only show after blur\nconst { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);\n\nconst onNumber = (val: number | null) => {\n handleChange(control.value.path, val ?? undefined);\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 <InputNumber\n :class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :input-class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :use-grouping=\"useGrouping\"\n :mode=\"mode\"\n :currency=\"currency\"\n :min-fraction-digits=\"minFractionDigits\"\n :max-fraction-digits=\"maxFractionDigits\"\n :model-value=\"typeof projectedData === 'number' ? projectedData : null\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"showErrors || undefined\"\n @update:model-value=\"onNumber\"\n @blur=\"markDirty\"\n />\n <small v-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,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;AAA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AACvC,mBAAa,QAAQ,MAAM,MAAM,OAAO,MAAS;AAAA,IACnD;;AAIE,aAAAA,UAAA,GAAAC,mBAqBM,OArBN,YAqBM;AAAA,QApBSC,MAAA,cAAA,kBAAbD,mBAA0E,SAA1E,YAA0EE,gBAAzBD,MAAA,cAAA,CAAc,GAAA,CAAA;QACpDA,MAAA,OAAA,EAAQ,eAAnBF,UAAA,GAAAC,mBAEM,OAFN,YAEME,gBADDD,MAAA,OAAA,EAAQ,WAAW,GAAA,CAAA;QAExBE,YAcEF,MAAA,WAAA,GAAA;AAAA,UAbC,iDAAkCA,MAAA,UAAA,EAAA,CAAU,CAAA;AAAA,UAC5C,0CAAwCA,MAAA,UAAA,GAAU;AAAA,UAClD,gBAAc,YAAA;AAAA,UACd,MAAM,KAAA;AAAA,UACN,UAAU,SAAA;AAAA,UACV,uBAAqB,kBAAA;AAAA,UACrB,uBAAqB,kBAAA;AAAA,UACrB,eAAW,OAASA,MAAA,aAAA,MAAa,WAAgBA,MAAA,aAAA,IAAa;AAAA,UAC9D,aAAa,YAAA;AAAA,UACb,UAAQ,CAAGA,MAAA,OAAA,EAAQ;AAAA,UACnB,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B,uBAAoB;AAAA,UACpB,QAAMA,MAAA,SAAA;AAAA,QAAA;QAEIA,MAAA,UAAA,kBAAbD,mBAAsE,SAAtE,YAAsEE,gBAA1BD,MAAA,eAAA,CAAe,GAAA,CAAA;;;;;"}
@@ -18,14 +18,17 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
18
18
  renderers: {
19
19
  type: ArrayConstructor;
20
20
  required: false;
21
+ default: undefined;
21
22
  };
22
23
  cells: {
23
24
  type: ArrayConstructor;
24
25
  required: false;
26
+ default: undefined;
25
27
  };
26
28
  config: {
27
29
  type: ObjectConstructor;
28
30
  required: false;
31
+ default: undefined;
29
32
  };
30
33
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
34
  uischema: {
@@ -47,17 +50,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
47
50
  renderers: {
48
51
  type: ArrayConstructor;
49
52
  required: false;
53
+ default: undefined;
50
54
  };
51
55
  cells: {
52
56
  type: ArrayConstructor;
53
57
  required: false;
58
+ default: undefined;
54
59
  };
55
60
  config: {
56
61
  type: ObjectConstructor;
57
62
  required: false;
63
+ default: undefined;
58
64
  };
59
65
  }>> & Readonly<{}>, {
66
+ config: Record<string, any>;
60
67
  enabled: boolean;
68
+ renderers: unknown[];
69
+ cells: unknown[];
61
70
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
71
  export default _default;
63
72
  //# sourceMappingURL=JfText.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JfText.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfText.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyMA,wBAgXK"}
1
+ {"version":3,"file":"JfText.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfText.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4NA,wBAsXK"}
@@ -1,17 +1,21 @@
1
- import { defineComponent, getCurrentInstance, computed, inject, ref, watch, createElementBlock, openBlock, createCommentVNode, createBlock, unref, toDisplayString } from "vue";
1
+ import { defineComponent, getCurrentInstance, computed, inject, ref, watch, createElementBlock, openBlock, createCommentVNode, createBlock, 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";
6
+ import { useProjection } from "../composables/useProjection.js";
7
+ import { useDirtyValidation } from "../composables/useDirtyValidation.js";
8
+ import { resolvePlaceholder } from "../utils/placeholder.js";
5
9
  import InputText from "primevue/inputtext";
6
10
  import AutoComplete from "primevue/autocomplete";
7
- const _hoisted_1 = { class: "flex flex-col gap-2" };
11
+ const _hoisted_1 = { class: "jf-control" };
8
12
  const _hoisted_2 = {
9
13
  key: 0,
10
- class: "text-color text-left"
14
+ class: "jf-label"
11
15
  };
12
16
  const _hoisted_3 = {
13
17
  key: 1,
14
- class: "text-color-secondary text-left"
18
+ class: "jf-description"
15
19
  };
16
20
  const _hoisted_4 = {
17
21
  key: 4,
@@ -43,15 +47,18 @@ const __default__ = {
43
47
  },
44
48
  renderers: {
45
49
  type: Array,
46
- required: false
50
+ required: false,
51
+ default: void 0
47
52
  },
48
53
  cells: {
49
54
  type: Array,
50
- required: false
55
+ required: false,
56
+ default: void 0
51
57
  },
52
58
  config: {
53
59
  type: Object,
54
- required: false
60
+ required: false,
61
+ default: void 0
55
62
  }
56
63
  }
57
64
  };
@@ -60,7 +67,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
60
67
  setup(__props) {
61
68
  const instance = getCurrentInstance();
62
69
  const props = instance.props;
63
- const { control, handleChange } = useJsonFormsControl(props);
70
+ const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
71
+ const {
72
+ projectedData,
73
+ handleProjectedChange: handleChange,
74
+ projectedErrors,
75
+ projectedLabel
76
+ } = useProjection(control, rawHandleChange);
64
77
  const binding = computed(() => {
65
78
  const provider = control.value.uischema?.options?.provider;
66
79
  if (provider && typeof provider === "object" && !provider.load) {
@@ -93,34 +106,39 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
93
106
  data: rootData,
94
107
  path: control.value.path,
95
108
  uiQuery: query.value,
96
- dependsOnValues: depValues.value
109
+ dependsOnValues: depValues
97
110
  });
98
111
  watch(query, () => {
99
112
  if (binding.value?.load === "query") reload();
100
113
  });
114
+ const isAutocomplete = computed(() => !!binding.value);
101
115
  const placeholder = computed(() => {
102
116
  if (loading.value) return "Loading…";
103
- return control.value.uischema?.options?.placeholder ?? control.value.description;
117
+ const explicit = control.value.uischema?.options?.placeholder;
118
+ if (explicit) return explicit;
119
+ if (isAutocomplete.value) return "Type to search…";
120
+ return resolvePlaceholder(
121
+ control.value.uischema,
122
+ projectedLabel.value,
123
+ "input"
124
+ );
104
125
  });
105
- const isAutocomplete = computed(() => !!binding.value);
106
- useDerive({ control, handleChange });
107
- const hasInteracted = ref(false);
108
- const hasFocused = ref(false);
109
- const showErrors = computed(() => hasInteracted.value && control.value.errors);
126
+ useDerive({ control, handleChange, data: projectedData });
127
+ useDeriveInitialValue({ control, handleChange });
128
+ const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
110
129
  function onInput(val) {
111
130
  const newValue = val && val.trim() !== "" ? val : void 0;
112
- if (control.value.data !== newValue) {
131
+ if (projectedData.value !== newValue) {
113
132
  handleChange(control.value.path, newValue);
114
133
  }
115
134
  }
116
135
  function onBlur() {
117
- if (hasFocused.value) {
118
- hasInteracted.value = true;
136
+ markDirty();
137
+ const val = projectedData.value;
138
+ if (typeof val === "string" && val.trim() === "") {
139
+ handleChange(control.value.path, void 0);
119
140
  }
120
141
  }
121
- function onFocus() {
122
- hasFocused.value = true;
123
- }
124
142
  const onComplete = (event) => {
125
143
  query.value = event.query;
126
144
  };
@@ -130,37 +148,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
130
148
  };
131
149
  return (_ctx, _cache) => {
132
150
  return openBlock(), createElementBlock("div", _hoisted_1, [
133
- unref(control).label ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(control).label), 1)) : createCommentVNode("", true),
151
+ unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
134
152
  unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
135
153
  isAutocomplete.value ? (openBlock(), createBlock(unref(AutoComplete), {
136
154
  key: 2,
137
- class: "w-full!",
138
- "model-value": unref(control).data ?? "",
155
+ class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
156
+ "model-value": unref(projectedData) ?? "",
139
157
  suggestions: unref(items),
140
158
  "option-label": "label",
141
159
  placeholder: placeholder.value,
142
160
  disabled: !unref(control).enabled,
143
- "aria-invalid": !!showErrors.value || void 0,
161
+ "aria-invalid": unref(showErrors) || void 0,
144
162
  onComplete,
145
163
  onItemSelect: onSelect,
146
164
  "onUpdate:modelValue": onInput,
147
- onBlur,
148
- onFocus
149
- }, null, 8, ["model-value", "suggestions", "placeholder", "disabled", "aria-invalid"])) : (openBlock(), createBlock(unref(InputText), {
165
+ onBlur
166
+ }, null, 8, ["class", "model-value", "suggestions", "placeholder", "disabled", "aria-invalid"])) : (openBlock(), createBlock(unref(InputText), {
150
167
  key: 3,
151
- class: "w-full!",
152
- "model-value": unref(control).data ?? "",
168
+ class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
169
+ "model-value": unref(projectedData) ?? "",
153
170
  disabled: !unref(control).enabled,
154
- "aria-invalid": !!showErrors.value || void 0,
171
+ "aria-invalid": unref(showErrors) || void 0,
155
172
  placeholder: placeholder.value,
156
173
  autocapitalize: "off",
157
174
  autocomplete: "off",
158
175
  spellcheck: "false",
159
176
  "onUpdate:modelValue": onInput,
160
- onBlur,
161
- onFocus
162
- }, null, 8, ["model-value", "disabled", "aria-invalid", "placeholder"])),
163
- unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed: " + toDisplayString(unref(error)), 1)) : showErrors.value ? (openBlock(), createElementBlock("small", _hoisted_5, toDisplayString(unref(control).errors), 1)) : createCommentVNode("", true)
177
+ onBlur
178
+ }, null, 8, ["class", "model-value", "disabled", "aria-invalid", "placeholder"])),
179
+ unref(error) ? (openBlock(), createElementBlock("small", _hoisted_4, "Failed: " + toDisplayString(unref(error)), 1)) : unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_5, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
164
180
  ]);
165
181
  };
166
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JfText.vue.js","sources":["../../../src/vue/primevue/JfText.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfText\",\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 },\n cells: {\n type: Array,\n required: false,\n },\n config: {\n type: Object,\n required: false,\n },\n },\n};\n</script>\n\n<script setup lang=\"ts\">\nimport type { ControlProps } from \"@jsonforms/vue\";\nimport { useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed, ref, inject, watch, getCurrentInstance } from \"vue\";\nimport { useProvider } from \"../composables/useProvider\";\nimport { useDerive } from \"../composables/useDerive\";\nimport InputText from \"primevue/inputtext\";\nimport AutoComplete from \"primevue/autocomplete\";\n\n// Access props from the component instance\nconst instance = getCurrentInstance()!;\nconst props = instance.props as unknown as ControlProps;\nconst { control, handleChange } = useJsonFormsControl(props);\n\n// Provider support for autocomplete functionality\nconst binding = computed(() => {\n const provider = control.value.uischema?.options?.provider;\n // Ensure load property is set to 'query' by default for autocomplete\n if (provider && typeof provider === \"object\" && !provider.load) {\n return { ...provider, load: \"query\" };\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\nconst query = ref(\"\");\nconst { items, loading, error, reload } = useProvider(binding, {\n data: rootData,\n path: control.value.path,\n uiQuery: query.value,\n dependsOnValues: depValues.value,\n});\n\nwatch(query, () => {\n if (binding.value?.load === \"query\") reload();\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 isAutocomplete = computed(() => !!binding.value);\n\n// Add derive functionality\nuseDerive({ control, handleChange });\n\n// Track user interaction\nconst hasInteracted = ref(false);\nconst hasFocused = ref(false);\n\nconst showErrors = computed(() => hasInteracted.value && control.value.errors);\n\nfunction onInput(val: string | undefined) {\n // Convert empty strings to undefined for proper required field validation\n const newValue = val && val.trim() !== \"\" ? val : undefined;\n if (control.value.data !== newValue) {\n handleChange(control.value.path, newValue);\n }\n}\n\nfunction onBlur() {\n if (hasFocused.value) {\n hasInteracted.value = true;\n }\n}\n\nfunction onFocus() {\n hasFocused.value = true;\n}\n\n// Autocomplete specific handlers\nconst onComplete = (event: { query: string }) => {\n query.value = event.query;\n};\n\nconst onSelect = (event: { value?: { value?: unknown } | unknown }) => {\n const newValue = (event.value as { value?: unknown })?.value ?? event.value;\n handleChange(control.value.path, newValue);\n};\n</script>\n\n<template>\n <div class=\"flex flex-col 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 <AutoComplete\n v-if=\"isAutocomplete\"\n class=\"w-full!\"\n :model-value=\"control.data ?? ''\"\n :suggestions=\"items\"\n option-label=\"label\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"!!showErrors || undefined\"\n @complete=\"onComplete\"\n @item-select=\"onSelect\"\n @update:model-value=\"onInput\"\n @blur=\"onBlur\"\n @focus=\"onFocus\"\n />\n <InputText\n v-else\n class=\"w-full!\"\n :model-value=\"control.data ?? ''\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"!!showErrors || undefined\"\n :placeholder=\"placeholder\"\n autocapitalize=\"off\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n @update:model-value=\"onInput\"\n @blur=\"onBlur\"\n @focus=\"onFocus\"\n />\n <small v-if=\"error\" class=\"p-error\" role=\"alert\">Failed: {{ error }}</small>\n <small v-else-if=\"showErrors\" class=\"p-error\">{{ control.errors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createBlock"],"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,IAAA;AAAA,IAEZ,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,IAEZ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EACZ;AAEJ;;;;AAaA,UAAM,WAAW,mBAAA;AACjB,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,SAAS,iBAAiB,oBAAoB,KAAK;AAG3D,UAAM,UAAU,SAAS,MAAM;AAC7B,YAAM,WAAW,QAAQ,MAAM,UAAU,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AA,CAAI,WAAA,SAAc;AAAA,UAC9B;AAAA,UACA,cAAa;AAAA,UACb,uBAAoB;AAAA,UACpB;AAAA,UACA;AAAA,QAAA,wGAEHE,YAaEF,MAAA,SAAA,GAAA;AAAA;UAXA,OAAM;AAAA,UACL,eAAaA,MAAA,OAAA,EAAQ,QAAI;AAAA,UACzB,UAAQ,CAAGA,MAAA,OAAA,EAAQ;AAAA,UACnB,gBAAY,CAAA,CAAI,WAAA,SAAc;AAAA,UAC9B,aAAa,YAAA;AAAA,UACd,gBAAe;AAAA,UACf,cAAa;AAAA,UACb,YAAW;AAAA,UACV,uBAAoB;AAAA,UACpB;AAAA,UACA;AAAA,QAAA;QAEUA,MAAA,KAAA,KAAbF,UAAA,GAAAC,mBAA4E,SAA5E,YAAiD,6BAAWC,MAAA,KAAA,CAAK,GAAA,CAAA,KAC/C,WAAA,SAAlBF,UAAA,GAAAC,mBAA0E,SAA1E,YAA0EE,gBAAzBD,MAAA,OAAA,EAAQ,MAAM,GAAA,CAAA;;;;;"}
1
+ {"version":3,"file":"JfText.vue.js","sources":["../../../src/vue/primevue/JfText.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"JfText\",\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 { computed, ref, inject, watch, getCurrentInstance } 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 { resolvePlaceholder } from \"../utils/placeholder\";\nimport InputText from \"primevue/inputtext\";\nimport AutoComplete from \"primevue/autocomplete\";\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// Provider support for autocomplete functionality\nconst binding = computed(() => {\n const provider = control.value.uischema?.options?.provider;\n // Ensure load property is set to 'query' by default for autocomplete\n if (provider && typeof provider === \"object\" && !provider.load) {\n return { ...provider, load: \"query\" };\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\nconst query = ref(\"\");\nconst { items, loading, error, reload } = useProvider(binding, {\n data: rootData,\n path: control.value.path,\n uiQuery: query.value,\n dependsOnValues: depValues,\n});\n\nwatch(query, () => {\n if (binding.value?.load === \"query\") reload();\n});\n\nconst isAutocomplete = computed(() => !!binding.value);\n\nconst placeholder = computed<string | undefined>(() => {\n if (loading.value) return \"Loading…\";\n const explicit = (\n control.value.uischema as { options?: { placeholder?: string } }\n )?.options?.placeholder;\n if (explicit) return explicit;\n // In autocomplete mode the input is really a search box — use matching UX.\n if (isAutocomplete.value) return \"Type to search…\";\n return resolvePlaceholder(\n control.value.uischema,\n projectedLabel.value,\n \"input\",\n );\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// Track user interaction — errors only show after blur\nconst { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);\n\nfunction onInput(val: string | undefined) {\n // Convert empty strings to undefined for proper required field validation\n const newValue = val && val.trim() !== \"\" ? val : undefined;\n if (projectedData.value !== newValue) {\n handleChange(control.value.path, newValue);\n }\n}\n\nfunction onBlur() {\n markDirty();\n // Normalize empty strings to undefined so required validation fires\n const val = projectedData.value;\n if (typeof val === \"string\" && val.trim() === \"\") {\n handleChange(control.value.path, undefined);\n }\n}\n\n// Autocomplete specific handlers\nconst onComplete = (event: { query: string }) => {\n query.value = event.query;\n};\n\nconst onSelect = (event: { value?: { value?: unknown } | unknown }) => {\n const newValue = (event.value as { value?: unknown })?.value ?? event.value;\n handleChange(control.value.path, newValue);\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 <AutoComplete\n v-if=\"isAutocomplete\"\n :class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :model-value=\"projectedData ?? ''\"\n :suggestions=\"items\"\n option-label=\"label\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"showErrors || undefined\"\n @complete=\"onComplete\"\n @item-select=\"onSelect\"\n @update:model-value=\"onInput\"\n @blur=\"onBlur\"\n />\n <InputText\n v-else\n :class=\"['w-full!', { 'p-invalid': showErrors }]\"\n :model-value=\"(projectedData as string) ?? ''\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"showErrors || undefined\"\n :placeholder=\"placeholder\"\n autocapitalize=\"off\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n @update:model-value=\"onInput\"\n @blur=\"onBlur\"\n />\n <small v-if=\"error\" class=\"p-error\" role=\"alert\">Failed: {{ error }}</small>\n <small v-else-if=\"showErrors\" class=\"p-error\">{{ projectedErrors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createBlock"],"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;;;;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;AAG1C,UAAM,UAAU,SAAS,MAAM;AAC7B,YAAM,WAAW,QAAQ,MAAM,UAAU,SAAS;AAElD,UAAI,YAAY,OAAO,aAAa,YAAY,CAAC,SAAS,MAAM;AAC9D,eAAO,EAAE,GAAG,UAAU,MAAM,QAA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AQ;AAAA,UACnB,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B;AAAA,UACA,cAAa;AAAA,UACb,uBAAoB;AAAA,UACpB;AAAA,QAAA,iHAEHE,YAYEF,MAAA,SAAA,GAAA;AAAA;UAVC,iDAAkCA,MAAA,UAAA,EAAA,CAAU,CAAA;AAAA,UAC5C,eAAcA,MAAA,aAAA,KAAa;AAAA,UAC3B,UAAQ,CAAGA,MAAA,OAAA,EAAQ;AAAA,UACnB,gBAAcA,MAAA,UAAA,KAAc;AAAA,UAC5B,aAAa,YAAA;AAAA,UACd,gBAAe;AAAA,UACf,cAAa;AAAA,UACb,YAAW;AAAA,UACV,uBAAoB;AAAA,UACpB;AAAA,QAAA;QAEUA,MAAA,KAAA,KAAbF,UAAA,GAAAC,mBAA4E,SAA5E,YAAiD,6BAAWC,MAAA,KAAA,CAAK,GAAA,CAAA,KAC/CA,MAAA,UAAA,kBAAlBD,mBAA2E,SAA3E,YAA2EE,gBAA1BD,MAAA,eAAA,CAAe,GAAA,CAAA;;;;;"}
@@ -18,14 +18,17 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
18
18
  renderers: {
19
19
  type: ArrayConstructor;
20
20
  required: false;
21
+ default: undefined;
21
22
  };
22
23
  cells: {
23
24
  type: ArrayConstructor;
24
25
  required: false;
26
+ default: undefined;
25
27
  };
26
28
  config: {
27
29
  type: ObjectConstructor;
28
30
  required: false;
31
+ default: undefined;
29
32
  };
30
33
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
34
  uischema: {
@@ -47,17 +50,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
47
50
  renderers: {
48
51
  type: ArrayConstructor;
49
52
  required: false;
53
+ default: undefined;
50
54
  };
51
55
  cells: {
52
56
  type: ArrayConstructor;
53
57
  required: false;
58
+ default: undefined;
54
59
  };
55
60
  config: {
56
61
  type: ObjectConstructor;
57
62
  required: false;
63
+ default: undefined;
58
64
  };
59
65
  }>> & Readonly<{}>, {
66
+ config: Record<string, any>;
60
67
  enabled: boolean;
68
+ renderers: unknown[];
69
+ cells: unknown[];
61
70
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
71
  export default _default;
63
72
  //# sourceMappingURL=JfTextArea.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JfTextArea.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfTextArea.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,wBA+MK"}
1
+ {"version":3,"file":"JfTextArea.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfTextArea.vue"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,wBA0NK"}
@@ -1,14 +1,17 @@
1
- import { defineComponent, getCurrentInstance, computed, ref, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString } from "vue";
1
+ import { defineComponent, getCurrentInstance, computed, createElementBlock, openBlock, createCommentVNode, createVNode, unref, toDisplayString, normalizeClass } from "vue";
2
2
  import { useJsonFormsControl } from "@jsonforms/vue";
3
+ import { useProjection } from "../composables/useProjection.js";
4
+ import { useDirtyValidation } from "../composables/useDirtyValidation.js";
5
+ import { resolvePlaceholder } from "../utils/placeholder.js";
3
6
  import Textarea from "primevue/textarea";
4
- const _hoisted_1 = { class: "flex flex-col gap-2" };
7
+ const _hoisted_1 = { class: "jf-control" };
5
8
  const _hoisted_2 = {
6
9
  key: 0,
7
- class: "text-color text-left"
10
+ class: "jf-label"
8
11
  };
9
12
  const _hoisted_3 = {
10
13
  key: 1,
11
- class: "text-color-secondary text-left"
14
+ class: "jf-description"
12
15
  };
13
16
  const _hoisted_4 = {
14
17
  key: 2,
@@ -35,15 +38,18 @@ const __default__ = {
35
38
  },
36
39
  renderers: {
37
40
  type: Array,
38
- required: false
41
+ required: false,
42
+ default: void 0
39
43
  },
40
44
  cells: {
41
45
  type: Array,
42
- required: false
46
+ required: false,
47
+ default: void 0
43
48
  },
44
49
  config: {
45
50
  type: Object,
46
- required: false
51
+ required: false,
52
+ default: void 0
47
53
  }
48
54
  }
49
55
  };
@@ -52,37 +58,46 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
52
58
  setup(__props) {
53
59
  const instance = getCurrentInstance();
54
60
  const props = instance.props;
55
- const { control, handleChange } = useJsonFormsControl(props);
61
+ const { control, handleChange: rawHandleChange } = useJsonFormsControl(props);
62
+ const {
63
+ projectedData,
64
+ handleProjectedChange: handleChange,
65
+ projectedErrors,
66
+ projectedLabel
67
+ } = useProjection(control, rawHandleChange);
56
68
  const placeholder = computed(
57
- () => control.value.uischema?.options?.placeholder ?? control.value.description
69
+ () => resolvePlaceholder(control.value.uischema, projectedLabel.value, "input")
58
70
  );
59
- const hasInteracted = ref(false);
60
- const showErrors = computed(() => hasInteracted.value && control.value.errors);
71
+ const { showErrors, markDirty } = useDirtyValidation(control, projectedErrors);
61
72
  function onInput(val) {
62
73
  const newValue = val && val.trim() !== "" ? val : void 0;
63
- if (control.value.data !== newValue) {
74
+ if (projectedData.value !== newValue) {
64
75
  handleChange(control.value.path, newValue);
65
76
  }
66
77
  }
67
78
  function onBlur() {
68
- hasInteracted.value = true;
79
+ markDirty();
80
+ const val = projectedData.value;
81
+ if (typeof val === "string" && val.trim() === "") {
82
+ handleChange(control.value.path, void 0);
83
+ }
69
84
  }
70
85
  return (_ctx, _cache) => {
71
86
  return openBlock(), createElementBlock("div", _hoisted_1, [
72
- unref(control).label ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(control).label), 1)) : createCommentVNode("", true),
87
+ unref(projectedLabel) ? (openBlock(), createElementBlock("label", _hoisted_2, toDisplayString(unref(projectedLabel)), 1)) : createCommentVNode("", true),
73
88
  unref(control).description ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(unref(control).description), 1)) : createCommentVNode("", true),
74
89
  createVNode(unref(Textarea), {
75
- class: "w-full!",
76
- "model-value": unref(control).data ?? "",
90
+ class: normalizeClass(["w-full!", { "p-invalid": unref(showErrors) }]),
91
+ "model-value": unref(projectedData) ?? "",
77
92
  disabled: !unref(control).enabled,
78
- "aria-invalid": !!showErrors.value || void 0,
93
+ "aria-invalid": unref(showErrors) || void 0,
79
94
  placeholder: placeholder.value,
80
95
  rows: 4,
81
96
  "auto-resize": true,
82
97
  "onUpdate:modelValue": onInput,
83
98
  onBlur
84
- }, null, 8, ["model-value", "disabled", "aria-invalid", "placeholder"]),
85
- showErrors.value ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(control).errors), 1)) : createCommentVNode("", true)
99
+ }, null, 8, ["class", "model-value", "disabled", "aria-invalid", "placeholder"]),
100
+ unref(showErrors) ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(projectedErrors)), 1)) : createCommentVNode("", true)
86
101
  ]);
87
102
  };
88
103
  }