@narrative.io/jsonforms-provider-protocols 1.1.0-beta.1 → 1.1.0-beta.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HtD,wBAEG"}
1
+ {"version":3,"file":"JfNumber.vue.d.ts","sourceRoot":"","sources":["../../../src/vue/primevue/JfNumber.vue"],"names":[],"mappings":"AAoFA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8KtD,wBAEG"}
@@ -21,9 +21,37 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
21
21
  setup(__props) {
22
22
  const props = __props;
23
23
  const { control, handleChange } = useJsonFormsControl(props);
24
+ const options = computed(
25
+ () => control.value.uischema?.options ?? {}
26
+ );
24
27
  const placeholder = computed(
25
- () => control.value.uischema?.options?.placeholder ?? control.value.description
28
+ () => options.value.placeholder ?? control.value.description
29
+ );
30
+ const mode = computed(() => {
31
+ if (options.value.currency) return "currency";
32
+ if (options.value.decimal || typeof options.value.precision === "number")
33
+ return "decimal";
34
+ return void 0;
35
+ });
36
+ const currency = computed(
37
+ () => typeof options.value.currency === "string" ? options.value.currency : "USD"
26
38
  );
39
+ const minFractionDigits = computed(() => {
40
+ if (mode.value === "currency") return 2;
41
+ if (typeof options.value.precision === "number")
42
+ return options.value.precision;
43
+ return void 0;
44
+ });
45
+ const maxFractionDigits = computed(() => {
46
+ if (mode.value === "currency") return 2;
47
+ if (typeof options.value.precision === "number")
48
+ return options.value.precision;
49
+ return void 0;
50
+ });
51
+ const useGrouping = computed(() => {
52
+ if (mode.value === "currency") return true;
53
+ return options.value.useGrouping === true;
54
+ });
27
55
  const onNumber = (val) => handleChange(control.value.path, val ?? void 0);
28
56
  return (_ctx, _cache) => {
29
57
  return openBlock(), createElementBlock("div", _hoisted_1, [
@@ -32,13 +60,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
32
60
  createVNode(unref(InputNumber), {
33
61
  class: "w-full",
34
62
  "input-class": "w-full",
35
- "use-grouping": false,
63
+ "use-grouping": useGrouping.value,
64
+ mode: mode.value,
65
+ currency: currency.value,
66
+ "min-fraction-digits": minFractionDigits.value,
67
+ "max-fraction-digits": maxFractionDigits.value,
36
68
  "model-value": typeof unref(control).data === "number" ? unref(control).data : null,
37
69
  placeholder: placeholder.value,
38
70
  disabled: !unref(control).enabled,
39
71
  "aria-invalid": !!unref(control).errors || void 0,
40
72
  "onUpdate:modelValue": onNumber
41
- }, null, 8, ["model-value", "placeholder", "disabled", "aria-invalid"]),
73
+ }, null, 8, ["use-grouping", "mode", "currency", "min-fraction-digits", "max-fraction-digits", "model-value", "placeholder", "disabled", "aria-invalid"]),
42
74
  unref(control).errors ? (openBlock(), createElementBlock("small", _hoisted_4, toDisplayString(unref(control).errors), 1)) : createCommentVNode("", true)
43
75
  ]);
44
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"JfNumber.vue.js","sources":["../../../src/vue/primevue/JfNumber.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ControlElement } from \"@jsonforms/core\";\nimport { rendererProps, useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed } from \"vue\";\nimport InputNumber from \"primevue/inputnumber\";\n\ndefineOptions({ name: \"JfNumber\" });\n\nconst props = defineProps(rendererProps<ControlElement>());\nconst { control, handleChange } = useJsonFormsControl(props);\n\nconst placeholder = computed<string | undefined>(\n () =>\n (control.value.uischema as { options?: { placeholder?: string } })?.options\n ?.placeholder ?? control.value.description,\n);\n\nconst onNumber = (val: number | null) =>\n handleChange(control.value.path, val ?? undefined);\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 <InputNumber\n class=\"w-full\"\n input-class=\"w-full\"\n :use-grouping=\"false\"\n :model-value=\"typeof control.data === 'number' ? control.data : null\"\n :placeholder=\"placeholder\"\n :disabled=\"!control.enabled\"\n :aria-invalid=\"!!control.errors || undefined\"\n @update:model-value=\"onNumber\"\n />\n <small v-if=\"control.errors\" class=\"p-error\">{{ control.errors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,UAAM,QAAQ;AACd,UAAM,EAAE,SAAS,iBAAiB,oBAAoB,KAAK;AAE3D,UAAM,cAAc;AAAA,MAClB,MACG,QAAQ,MAAM,UAAqD,SAChE,eAAe,QAAQ,MAAM;AAAA,IAAA;AAGrC,UAAM,WAAW,CAAC,QAChB,aAAa,QAAQ,MAAM,MAAM,OAAO,MAAS;;AAIjD,aAAAA,UAAA,GAAAC,mBAkBM,OAlBN,YAkBM;AAAA,QAjBSC,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;QAExBE,YASEF,MAAA,WAAA,GAAA;AAAA,UARA,OAAM;AAAA,UACN,eAAY;AAAA,UACX,gBAAc;AAAA,UACd,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,CAAIA,MAAA,OAAA,EAAQ,UAAU;AAAA,UAClC,uBAAoB;AAAA,QAAA;QAEVA,MAAA,OAAA,EAAQ,UAArBF,UAAA,GAAAC,mBAAyE,SAAzE,YAAyEE,gBAAzBD,MAAA,OAAA,EAAQ,MAAM,GAAA,CAAA;;;;;"}
1
+ {"version":3,"file":"JfNumber.vue.js","sources":["../../../src/vue/primevue/JfNumber.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ControlElement } from \"@jsonforms/core\";\nimport { rendererProps, useJsonFormsControl } from \"@jsonforms/vue\";\nimport { computed } from \"vue\";\nimport InputNumber from \"primevue/inputnumber\";\n\ndefineOptions({ name: \"JfNumber\" });\n\nconst props = defineProps(rendererProps<ControlElement>());\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// 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 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 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\nconst onNumber = (val: number | null) =>\n handleChange(control.value.path, val ?? undefined);\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 <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=\"!!control.errors || undefined\"\n @update:model-value=\"onNumber\"\n />\n <small v-if=\"control.errors\" class=\"p-error\">{{ control.errors }}</small>\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_unref","_toDisplayString","_createVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,UAAM,QAAQ;AACd,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,UAAM,OAAO,SAAS,MAAM;AAC1B,UAAI,QAAQ,MAAM,SAAU,QAAO;AACnC,UAAI,QAAQ,MAAM,WAAW,OAAO,QAAQ,MAAM,cAAc;AAC9D,eAAO;AACT,aAAO;AAAA,IACT,CAAC;AAED,UAAM,WAAW;AAAA,MAAS,MACxB,OAAO,QAAQ,MAAM,aAAa,WAAW,QAAQ,MAAM,WAAW;AAAA,IAAA;AAGxE,UAAM,oBAAoB,SAAS,MAAM;AACvC,UAAI,KAAK,UAAU,WAAY,QAAO;AACtC,UAAI,OAAO,QAAQ,MAAM,cAAc;AACrC,eAAO,QAAQ,MAAM;AACvB,aAAO;AAAA,IACT,CAAC;AAED,UAAM,oBAAoB,SAAS,MAAM;AACvC,UAAI,KAAK,UAAU,WAAY,QAAO;AAC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.2",
4
4
  "description": "Dynamic data provider capabilities for JSONForms with Vue 3 integration",
5
5
  "type": "module",
6
6
  "author": "Narrative I/O",
@@ -9,12 +9,48 @@ defineOptions({ name: "JfNumber" });
9
9
  const props = defineProps(rendererProps<ControlElement>());
10
10
  const { control, handleChange } = useJsonFormsControl(props);
11
11
 
12
- const placeholder = computed<string | undefined>(
12
+ const options = computed(
13
13
  () =>
14
- (control.value.uischema as { options?: { placeholder?: string } })?.options
15
- ?.placeholder ?? control.value.description,
14
+ (control.value.uischema as { options?: Record<string, unknown> })
15
+ ?.options ?? {},
16
+ );
17
+
18
+ const placeholder = computed<string | undefined>(
19
+ () => (options.value.placeholder as string) ?? control.value.description,
20
+ );
21
+
22
+ // Currency and decimal configuration
23
+ const mode = computed(() => {
24
+ if (options.value.currency) return "currency";
25
+ if (options.value.decimal || typeof options.value.precision === "number")
26
+ return "decimal";
27
+ return undefined;
28
+ });
29
+
30
+ const currency = computed(() =>
31
+ typeof options.value.currency === "string" ? options.value.currency : "USD",
16
32
  );
17
33
 
34
+ const minFractionDigits = computed(() => {
35
+ if (mode.value === "currency") return 2;
36
+ if (typeof options.value.precision === "number")
37
+ return options.value.precision;
38
+ return undefined;
39
+ });
40
+
41
+ const maxFractionDigits = computed(() => {
42
+ if (mode.value === "currency") return 2;
43
+ if (typeof options.value.precision === "number")
44
+ return options.value.precision;
45
+ return undefined;
46
+ });
47
+
48
+ const useGrouping = computed(() => {
49
+ // Enable grouping for currency by default, or if explicitly set
50
+ if (mode.value === "currency") return true;
51
+ return options.value.useGrouping === true;
52
+ });
53
+
18
54
  const onNumber = (val: number | null) =>
19
55
  handleChange(control.value.path, val ?? undefined);
20
56
  </script>
@@ -30,7 +66,11 @@ const onNumber = (val: number | null) =>
30
66
  <InputNumber
31
67
  class="w-full"
32
68
  input-class="w-full"
33
- :use-grouping="false"
69
+ :use-grouping="useGrouping"
70
+ :mode="mode"
71
+ :currency="currency"
72
+ :min-fraction-digits="minFractionDigits"
73
+ :max-fraction-digits="maxFractionDigits"
34
74
  :model-value="typeof control.data === 'number' ? control.data : null"
35
75
  :placeholder="placeholder"
36
76
  :disabled="!control.enabled"