@sfxcode/formkit-primevue 2.9.3 → 2.9.5

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.
@@ -16,6 +16,9 @@ export interface FormKitPrimeAutoCompleteProps {
16
16
  optionLabel?: AutoCompleteProps['optionLabel']
17
17
  options?: any[] | undefined
18
18
  size?: AutoCompleteProps['size']
19
+ minLength?: AutoCompleteProps['minLength']
20
+ placeholder?: AutoCompleteProps['placeholder']
21
+ fluid?: AutoCompleteProps['fluid']
19
22
  }
20
23
 
21
24
  const props = defineProps({
@@ -29,15 +32,26 @@ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur } = useForm
29
32
 
30
33
  const suggestions = ref(['', {}])
31
34
  suggestions.value = []
35
+ const loading = ref(false)
32
36
 
33
- function search(event: AutoCompleteCompleteEvent) {
37
+ async function search(event: AutoCompleteCompleteEvent) {
34
38
  if (props.context?.options && props.context?.optionLabel) {
35
39
  suggestions.value = props.context.options.filter((option) => {
36
40
  return option[`${props.context.optionLabel}`].toString().toLowerCase().includes(event.query.toLowerCase())
37
41
  })
38
42
  }
39
43
  else {
40
- suggestions.value = props.context?.attrs.complete(event.query)
44
+ loading.value = true
45
+ try {
46
+ suggestions.value = await props.context?.attrs.complete(event.query)
47
+ }
48
+ catch (error) {
49
+ console.error('Error fetching suggestions:', error)
50
+ suggestions.value = []
51
+ }
52
+ finally {
53
+ loading.value = false
54
+ }
41
55
  }
42
56
  }
43
57
  </script>
@@ -60,9 +74,13 @@ function search(event: AutoCompleteCompleteEvent) {
60
74
  :dropdown="context?.dropdown ?? false"
61
75
  :multiple="context?.multiple ?? false"
62
76
  :typeahead="context?.typeahead ?? true"
77
+ :min-length="context?.minLength ?? undefined"
78
+ :placeholder="context?.placeholder ?? undefined"
79
+ :fluid="context?.fluid ?? undefined"
63
80
  :pt="context?.pt"
64
81
  :pt-options="context?.ptOptions"
65
82
  :unstyled="unstyled"
83
+ :loading="loading"
66
84
  @keydown.enter.prevent
67
85
  @complete="search"
68
86
  @change="handleInput"
@@ -8,10 +8,10 @@ var _config = require("primevue/config");
8
8
  var _vue = require("vue");
9
9
  function useFormKitInput(context) {
10
10
  const isInvalid = (0, _vue.computed)(() => {
11
- return context?.state.validationVisible && !context?.state.valid;
11
+ return context?.state?.validationVisible && !context?.state?.valid;
12
12
  });
13
13
  const styleClass = (0, _vue.computed)(() => {
14
- return context?.state.validationVisible && !context?.state.valid ? `${context?.attrs?.class} p-invalid` : context?.attrs?.class;
14
+ return context?.state?.validationVisible && !context?.state?.valid ? `${context?.attrs?.class || ""} p-invalid` : context?.attrs?.class || "";
15
15
  });
16
16
  function isGlobalUnstyledMode() {
17
17
  let result = false;
@@ -25,18 +25,18 @@ function useFormKitInput(context) {
25
25
  return context?.unstyled ?? isGlobalUnstyledMode();
26
26
  });
27
27
  const formKitCreateInputSlots = /* @__PURE__ */new Set(["label", "help", "messages", "message", "input"]);
28
- const validSlotNames = (0, _vue.computed)(() => Object.keys(context?.slots).filter(slotName => !formKitCreateInputSlots.has(slotName)));
28
+ const validSlotNames = (0, _vue.computed)(() => Object.keys(context?.slots || {}).filter(slotName => !formKitCreateInputSlots.has(slotName)));
29
29
  function handleBlur(event) {
30
- context?.handlers.blur(event);
30
+ context?.handlers?.blur?.(event);
31
31
  }
32
32
  function handleChange(_) {
33
- context?.node.input(context?._value);
33
+ context?.node?.input?.(context?._value);
34
34
  }
35
35
  function handleInput(_) {
36
- context?.node.input(context?._value);
36
+ context?.node?.input?.(context?._value);
37
37
  }
38
38
  function handleSelect(e) {
39
- context?.node.input(e);
39
+ context?.node?.input?.(e);
40
40
  }
41
41
  return {
42
42
  isInvalid,
@@ -2,10 +2,10 @@ import { usePrimeVue } from "primevue/config";
2
2
  import { computed } from "vue";
3
3
  export function useFormKitInput(context) {
4
4
  const isInvalid = computed(() => {
5
- return context?.state.validationVisible && !context?.state.valid;
5
+ return context?.state?.validationVisible && !context?.state?.valid;
6
6
  });
7
7
  const styleClass = computed(() => {
8
- return context?.state.validationVisible && !context?.state.valid ? `${context?.attrs?.class} p-invalid` : context?.attrs?.class;
8
+ return context?.state?.validationVisible && !context?.state?.valid ? `${context?.attrs?.class || ""} p-invalid` : context?.attrs?.class || "";
9
9
  });
10
10
  function isGlobalUnstyledMode() {
11
11
  let result = false;
@@ -21,19 +21,19 @@ export function useFormKitInput(context) {
21
21
  });
22
22
  const formKitCreateInputSlots = /* @__PURE__ */ new Set(["label", "help", "messages", "message", "input"]);
23
23
  const validSlotNames = computed(
24
- () => Object.keys(context?.slots).filter((slotName) => !formKitCreateInputSlots.has(slotName))
24
+ () => Object.keys(context?.slots || {}).filter((slotName) => !formKitCreateInputSlots.has(slotName))
25
25
  );
26
26
  function handleBlur(event) {
27
- context?.handlers.blur(event);
27
+ context?.handlers?.blur?.(event);
28
28
  }
29
29
  function handleChange(_) {
30
- context?.node.input(context?._value);
30
+ context?.node?.input?.(context?._value);
31
31
  }
32
32
  function handleInput(_) {
33
- context?.node.input(context?._value);
33
+ context?.node?.input?.(context?._value);
34
34
  }
35
35
  function handleSelect(e) {
36
- context?.node.input(e);
36
+ context?.node?.input?.(e);
37
37
  }
38
38
  return { isInvalid, validSlotNames, styleClass, unstyled, handleBlur, handleChange, handleInput, handleSelect };
39
39
  }
@@ -1,7 +1,7 @@
1
1
  export declare function useFormKitSection(context: any): {
2
2
  generateId: () => string;
3
- hasPrefix: import("vue").ComputedRef<any>;
4
- hasPrefixIcon: import("vue").ComputedRef<any>;
5
- hasSuffix: import("vue").ComputedRef<any>;
6
- hasSuffixIcon: import("vue").ComputedRef<any>;
3
+ hasPrefix: import("vue").ComputedRef<boolean>;
4
+ hasPrefixIcon: import("vue").ComputedRef<boolean>;
5
+ hasSuffix: import("vue").ComputedRef<boolean>;
6
+ hasSuffixIcon: import("vue").ComputedRef<boolean>;
7
7
  };
@@ -8,16 +8,16 @@ var _uuid = require("uuid");
8
8
  var _vue = require("vue");
9
9
  function useFormKitSection(context) {
10
10
  const hasPrefix = (0, _vue.computed)(() => {
11
- return context?.prefix && context?.prefix.length > 0;
11
+ return Boolean(context?.prefix?.length > 0);
12
12
  });
13
13
  const hasPrefixIcon = (0, _vue.computed)(() => {
14
- return context?.iconPrefix && context?.iconPrefix.length > 0;
14
+ return Boolean(context?.iconPrefix?.length > 0);
15
15
  });
16
16
  const hasSuffixIcon = (0, _vue.computed)(() => {
17
- return context?.iconSuffix && context?.iconSuffix.length > 0;
17
+ return Boolean(context?.iconSuffix?.length > 0);
18
18
  });
19
19
  const hasSuffix = (0, _vue.computed)(() => {
20
- return context?.suffix && context?.suffix.length > 0;
20
+ return Boolean(context?.suffix?.length > 0);
21
21
  });
22
22
  function generateId() {
23
23
  return (0, _uuid.v4)();
@@ -2,16 +2,16 @@ import { v4 as uuidv4 } from "uuid";
2
2
  import { computed } from "vue";
3
3
  export function useFormKitSection(context) {
4
4
  const hasPrefix = computed(() => {
5
- return context?.prefix && context?.prefix.length > 0;
5
+ return Boolean(context?.prefix?.length > 0);
6
6
  });
7
7
  const hasPrefixIcon = computed(() => {
8
- return context?.iconPrefix && context?.iconPrefix.length > 0;
8
+ return Boolean(context?.iconPrefix?.length > 0);
9
9
  });
10
10
  const hasSuffixIcon = computed(() => {
11
- return context?.iconSuffix && context?.iconSuffix.length > 0;
11
+ return Boolean(context?.iconSuffix?.length > 0);
12
12
  });
13
13
  const hasSuffix = computed(() => {
14
- return context?.suffix && context?.suffix.length > 0;
14
+ return Boolean(context?.suffix?.length > 0);
15
15
  });
16
16
  function generateId() {
17
17
  return uuidv4();
@@ -12,12 +12,12 @@ function useInputEditor() {
12
12
  if (!data) return {};
13
13
  const formkitInput = data?._dollar_formkit;
14
14
  let tempData = {};
15
- if (data.prime && data.prime.length > 0) {
16
- const mapped = data.prime.map(entry => {
17
- const key = entry.prime_key;
15
+ if (data.prime && Array.isArray(data.prime) && data.prime.length > 0) {
16
+ const mapped = data.prime.filter(entry => entry && typeof entry === "object" && "prime_key" in entry && "prime_value" in entry).map(entry => {
17
+ const key = entry.prime_key || "";
18
18
  let value = entry.prime_value;
19
- if (formkitInput === "primeInputOtp" && key === "length") {
20
- value = +value;
19
+ if (formkitInput === "primeInputOtp" && key === "length" && value !== void 0) {
20
+ value = Number(value);
21
21
  }
22
22
  return [key, value];
23
23
  });
@@ -25,9 +25,9 @@ function useInputEditor() {
25
25
  [key]: val
26
26
  })));
27
27
  }
28
- const readonlyValue = data.readonly ? true : void 0;
29
- const disabledValue = data.disabled ? true : void 0;
30
- const preserveValue = data.preserve ? true : void 0;
28
+ const readonlyValue = data.readonly === true ? true : void 0;
29
+ const disabledValue = data.disabled === true ? true : void 0;
30
+ const preserveValue = data.preserve === true ? true : void 0;
31
31
  const defaultObject = {
32
32
  readonly: readonlyValue,
33
33
  disabled: disabledValue,
@@ -46,42 +46,47 @@ function useInputEditor() {
46
46
  slots: void 0,
47
47
  selectButton: void 0
48
48
  };
49
- const useOptions = primeInputWithOptionNames.map(s => `prime${s}`).includes(formkitInput);
49
+ const useOptions = formkitInput ? primeInputWithOptionNames.map(s => `prime${s}`).includes(formkitInput) : false;
50
50
  let result = {};
51
- if (useOptions) result = {
52
- ...data,
53
- $formkit: formkitInput,
54
- ...tempData,
55
- ...undefinedObject,
56
- ...defaultObject,
57
- outerClass,
58
- wrapperClass,
59
- innerClass,
60
- optionLabel: "label",
61
- optionValue: "value"
62
- };else result = {
63
- ...data,
64
- $formkit: formkitInput,
65
- ...tempData,
66
- ...undefinedObject,
67
- ...defaultObject,
68
- outerClass,
69
- wrapperClass,
70
- innerClass,
71
- options: void 0
72
- };
51
+ if (useOptions) {
52
+ result = {
53
+ ...data,
54
+ $formkit: formkitInput,
55
+ ...tempData,
56
+ ...undefinedObject,
57
+ ...defaultObject,
58
+ outerClass,
59
+ wrapperClass,
60
+ innerClass,
61
+ optionLabel: "label",
62
+ optionValue: "value"
63
+ };
64
+ } else {
65
+ result = {
66
+ ...data,
67
+ $formkit: formkitInput,
68
+ ...tempData,
69
+ ...undefinedObject,
70
+ ...defaultObject,
71
+ outerClass,
72
+ wrapperClass,
73
+ innerClass,
74
+ options: void 0
75
+ };
76
+ }
73
77
  for (const key in result) {
74
78
  const value = result[key];
75
- if (typeof value === "string" || typeof value === "string") {
79
+ if (value !== null && value !== void 0 && typeof value === "string") {
76
80
  if (value.trim().length === 0) result[key] = void 0;
77
81
  }
78
82
  }
79
83
  return result;
80
84
  }
81
85
  function dataToSchema(data) {
86
+ if (!data) return {};
82
87
  const schema = editorDataToSchema(data);
83
- if (schema.options) {
84
- const options = schema.options.map(o => JSON.parse(JSON.stringify(o)));
88
+ if (schema?.options && Array.isArray(schema.options)) {
89
+ const options = schema.options.map(o => o ? JSON.parse(JSON.stringify(o)) : {});
85
90
  return {
86
91
  ...schema,
87
92
  options
@@ -91,13 +96,19 @@ function useInputEditor() {
91
96
  }
92
97
  }
93
98
  function editorDataToJson(data) {
99
+ if (!data) return "{}";
94
100
  return JSON.stringify(dataToSchema(data));
95
101
  }
96
102
  function objectToString(data) {
103
+ if (!data) return "{}";
97
104
  return `{${Object.entries(data).map(([key, value]) => {
98
105
  if (key === "options" && Array.isArray(value) && value.length > 0) {
99
106
  let result = "[";
100
- value.forEach(o => result = `${result + objectToString(o)}, `);
107
+ value.forEach(o => {
108
+ if (o && typeof o === "object") {
109
+ result = `${result + objectToString(o)}, `;
110
+ }
111
+ });
101
112
  return `${key}: ${result.substring(0, result.length - 2)}]`;
102
113
  } else if (key === "primeInputOtp") {
103
114
  return `${key}: ${value}`;
@@ -107,9 +118,17 @@ function useInputEditor() {
107
118
  }).join()}}`;
108
119
  }
109
120
  function editorDataToObject(data) {
110
- return objectToString(JSON.parse(editorDataToJson(data)));
121
+ if (!data) return "{}";
122
+ try {
123
+ const jsonData = editorDataToJson(data);
124
+ return objectToString(JSON.parse(jsonData));
125
+ } catch (error) {
126
+ console.error("Error in editorDataToObject:", error);
127
+ return "{}";
128
+ }
111
129
  }
112
130
  function schemaToEditorData(schema) {
131
+ if (!schema) return {};
113
132
  const formkitInput = schema?.$formkit;
114
133
  return {
115
134
  ...schema,
@@ -7,21 +7,25 @@ export function useInputEditor() {
7
7
  return {};
8
8
  const formkitInput = data?._dollar_formkit;
9
9
  let tempData = {};
10
- if (data.prime && data.prime.length > 0) {
11
- const mapped = data.prime.map((entry) => {
12
- const key = entry.prime_key;
10
+ if (data.prime && Array.isArray(data.prime) && data.prime.length > 0) {
11
+ const mapped = data.prime.filter((entry) => entry && typeof entry === "object" && "prime_key" in entry && "prime_value" in entry).map((entry) => {
12
+ const key = entry.prime_key || "";
13
13
  let value = entry.prime_value;
14
- if (formkitInput === "primeInputOtp" && key === "length") {
15
- value = +value;
14
+ if (formkitInput === "primeInputOtp" && key === "length" && value !== void 0) {
15
+ value = Number(value);
16
16
  }
17
17
  return [key, value];
18
18
  });
19
19
  tempData = Object.assign({}, ...mapped.map(([key, val]) => ({ [key]: val })));
20
20
  }
21
- const readonlyValue = data.readonly ? true : void 0;
22
- const disabledValue = data.disabled ? true : void 0;
23
- const preserveValue = data.preserve ? true : void 0;
24
- const defaultObject = { readonly: readonlyValue, disabled: disabledValue, preserve: preserveValue };
21
+ const readonlyValue = data.readonly === true ? true : void 0;
22
+ const disabledValue = data.disabled === true ? true : void 0;
23
+ const preserveValue = data.preserve === true ? true : void 0;
24
+ const defaultObject = {
25
+ readonly: readonlyValue,
26
+ disabled: disabledValue,
27
+ preserve: preserveValue
28
+ };
25
29
  let outerClass = "";
26
30
  if (data.outerClass)
27
31
  outerClass = `${outerClass} ${data.outerClass}`.trim();
@@ -31,16 +35,44 @@ export function useInputEditor() {
31
35
  let innerClass = "";
32
36
  if (data.innerClass)
33
37
  innerClass = `${innerClass} ${data.innerClass}`.trim();
34
- const undefinedObject = { prime: void 0, schemaResultFormKey: void 0, _dollar_formkit: void 0, slots: void 0, selectButton: void 0 };
35
- const useOptions = primeInputWithOptionNames.map((s) => `prime${s}`).includes(formkitInput);
38
+ const undefinedObject = {
39
+ prime: void 0,
40
+ schemaResultFormKey: void 0,
41
+ _dollar_formkit: void 0,
42
+ slots: void 0,
43
+ selectButton: void 0
44
+ };
45
+ const useOptions = formkitInput ? primeInputWithOptionNames.map((s) => `prime${s}`).includes(formkitInput) : false;
36
46
  let result = {};
37
- if (useOptions)
38
- result = { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, outerClass, wrapperClass, innerClass, optionLabel: "label", optionValue: "value" };
39
- else
40
- result = { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, outerClass, wrapperClass, innerClass, options: void 0 };
47
+ if (useOptions) {
48
+ result = {
49
+ ...data,
50
+ $formkit: formkitInput,
51
+ ...tempData,
52
+ ...undefinedObject,
53
+ ...defaultObject,
54
+ outerClass,
55
+ wrapperClass,
56
+ innerClass,
57
+ optionLabel: "label",
58
+ optionValue: "value"
59
+ };
60
+ } else {
61
+ result = {
62
+ ...data,
63
+ $formkit: formkitInput,
64
+ ...tempData,
65
+ ...undefinedObject,
66
+ ...defaultObject,
67
+ outerClass,
68
+ wrapperClass,
69
+ innerClass,
70
+ options: void 0
71
+ };
72
+ }
41
73
  for (const key in result) {
42
74
  const value = result[key];
43
- if (typeof value === "string" || typeof value === "string") {
75
+ if (value !== null && value !== void 0 && typeof value === "string") {
44
76
  if (value.trim().length === 0)
45
77
  result[key] = void 0;
46
78
  }
@@ -48,22 +80,32 @@ export function useInputEditor() {
48
80
  return result;
49
81
  }
50
82
  function dataToSchema(data) {
83
+ if (!data)
84
+ return {};
51
85
  const schema = editorDataToSchema(data);
52
- if (schema.options) {
53
- const options = schema.options.map((o) => JSON.parse(JSON.stringify(o)));
86
+ if (schema?.options && Array.isArray(schema.options)) {
87
+ const options = schema.options.map((o) => o ? JSON.parse(JSON.stringify(o)) : {});
54
88
  return { ...schema, options };
55
89
  } else {
56
90
  return schema;
57
91
  }
58
92
  }
59
93
  function editorDataToJson(data) {
94
+ if (!data)
95
+ return "{}";
60
96
  return JSON.stringify(dataToSchema(data));
61
97
  }
62
98
  function objectToString(data) {
99
+ if (!data)
100
+ return "{}";
63
101
  return `{${Object.entries(data).map(([key, value]) => {
64
102
  if (key === "options" && Array.isArray(value) && value.length > 0) {
65
103
  let result = "[";
66
- value.forEach((o) => result = `${result + objectToString(o)}, `);
104
+ value.forEach((o) => {
105
+ if (o && typeof o === "object") {
106
+ result = `${result + objectToString(o)}, `;
107
+ }
108
+ });
67
109
  return `${key}: ${result.substring(0, result.length - 2)}]`;
68
110
  } else if (key === "primeInputOtp") {
69
111
  return `${key}: ${value}`;
@@ -73,11 +115,28 @@ export function useInputEditor() {
73
115
  }).join()}}`;
74
116
  }
75
117
  function editorDataToObject(data) {
76
- return objectToString(JSON.parse(editorDataToJson(data)));
118
+ if (!data)
119
+ return "{}";
120
+ try {
121
+ const jsonData = editorDataToJson(data);
122
+ return objectToString(JSON.parse(jsonData));
123
+ } catch (error) {
124
+ console.error("Error in editorDataToObject:", error);
125
+ return "{}";
126
+ }
77
127
  }
78
128
  function schemaToEditorData(schema) {
129
+ if (!schema)
130
+ return {};
79
131
  const formkitInput = schema?.$formkit;
80
132
  return { ...schema, _dollar_formkit: formkitInput };
81
133
  }
82
- return { primeInputNames, primeOutputNames, editorDataToSchema, editorDataToJson, editorDataToCode: editorDataToObject, schemaToEditorData };
134
+ return {
135
+ primeInputNames,
136
+ primeOutputNames,
137
+ editorDataToSchema,
138
+ editorDataToJson,
139
+ editorDataToCode: editorDataToObject,
140
+ schemaToEditorData
141
+ };
83
142
  }
@@ -8,30 +8,28 @@ function useOutputDuration() {
8
8
  function durationToMinutes(duration) {
9
9
  let hours = 0;
10
10
  let minutes = 0;
11
- if (duration.includes(":")) {
12
- hours = +duration.substring(0, duration.indexOf(":")).trim();
13
- minutes = +duration.substring(duration.indexOf(":") + 1).trim();
11
+ const lowerDuration = duration.toLowerCase();
12
+ if (lowerDuration.includes(":")) {
13
+ [hours, minutes] = lowerDuration.split(":").map(part => +part.trim());
14
14
  } else {
15
- let durationString = duration;
16
- if (duration.includes("h")) {
17
- hours = +duration.substring(0, duration.indexOf("h")).trim();
18
- durationString = duration.substring(duration.indexOf("h") + 1);
15
+ if (lowerDuration.includes("h")) {
16
+ hours = +lowerDuration.split("h")[0].trim();
17
+ const remainder = lowerDuration.split("h")[1] || "";
18
+ if (remainder.includes("m")) minutes = +remainder.split("m")[0].trim();else if (/^\d+$/.test(remainder)) minutes = +remainder;
19
+ } else if (lowerDuration.includes("m")) {
20
+ minutes = +lowerDuration.split("m")[0].trim();
21
+ } else if (/^\d+$/.test(lowerDuration)) {
22
+ minutes = +lowerDuration;
19
23
  }
20
- if (durationString.includes("m")) minutes = +durationString.substring(0, durationString.indexOf("m")).trim();
21
- if (durationString === durationString.replace(/\D/g, "")) minutes = +durationString;
22
24
  }
23
25
  return hours * 60 + minutes;
24
26
  }
25
27
  function formattedDuration(duration) {
26
28
  const minutes = durationToMinutes(duration);
27
- const stunden = Math.trunc(minutes / 60);
28
- const minuten = minutes % 60;
29
- let result = "";
30
- if (stunden > 0) result = `${result} ${stunden}h`;
31
- if (minuten > 0) result = `${result} ${minuten}m`;
32
- if (minutes === 0) result = "0";
33
- if (result.length === 0) result = duration;
34
- return result.trim();
29
+ const hours = Math.trunc(minutes / 60);
30
+ const remainingMinutes = minutes % 60;
31
+ if (minutes === 0) return "0";
32
+ return `${hours > 0 ? `${hours}h` : ""}${hours > 0 && remainingMinutes > 0 ? " " : ""}${remainingMinutes > 0 ? `${remainingMinutes}m` : ""}`;
35
33
  }
36
34
  return {
37
35
  durationToMinutes,
@@ -2,36 +2,32 @@ export function useOutputDuration() {
2
2
  function durationToMinutes(duration) {
3
3
  let hours = 0;
4
4
  let minutes = 0;
5
- if (duration.includes(":")) {
6
- hours = +duration.substring(0, duration.indexOf(":")).trim();
7
- minutes = +duration.substring(duration.indexOf(":") + 1).trim();
5
+ const lowerDuration = duration.toLowerCase();
6
+ if (lowerDuration.includes(":")) {
7
+ [hours, minutes] = lowerDuration.split(":").map((part) => +part.trim());
8
8
  } else {
9
- let durationString = duration;
10
- if (duration.includes("h")) {
11
- hours = +duration.substring(0, duration.indexOf("h")).trim();
12
- durationString = duration.substring(duration.indexOf("h") + 1);
9
+ if (lowerDuration.includes("h")) {
10
+ hours = +lowerDuration.split("h")[0].trim();
11
+ const remainder = lowerDuration.split("h")[1] || "";
12
+ if (remainder.includes("m"))
13
+ minutes = +remainder.split("m")[0].trim();
14
+ else if (/^\d+$/.test(remainder))
15
+ minutes = +remainder;
16
+ } else if (lowerDuration.includes("m")) {
17
+ minutes = +lowerDuration.split("m")[0].trim();
18
+ } else if (/^\d+$/.test(lowerDuration)) {
19
+ minutes = +lowerDuration;
13
20
  }
14
- if (durationString.includes("m"))
15
- minutes = +durationString.substring(0, durationString.indexOf("m")).trim();
16
- if (durationString === durationString.replace(/\D/g, ""))
17
- minutes = +durationString;
18
21
  }
19
22
  return hours * 60 + minutes;
20
23
  }
21
24
  function formattedDuration(duration) {
22
25
  const minutes = durationToMinutes(duration);
23
- const stunden = Math.trunc(minutes / 60);
24
- const minuten = minutes % 60;
25
- let result = "";
26
- if (stunden > 0)
27
- result = `${result} ${stunden}h`;
28
- if (minuten > 0)
29
- result = `${result} ${minuten}m`;
26
+ const hours = Math.trunc(minutes / 60);
27
+ const remainingMinutes = minutes % 60;
30
28
  if (minutes === 0)
31
- result = "0";
32
- if (result.length === 0)
33
- result = duration;
34
- return result.trim();
29
+ return "0";
30
+ return `${hours > 0 ? `${hours}h` : ""}${hours > 0 && remainingMinutes > 0 ? " " : ""}${remainingMinutes > 0 ? `${remainingMinutes}m` : ""}`;
35
31
  }
36
32
  return { durationToMinutes, formattedDuration };
37
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sfxcode/formkit-primevue",
3
3
  "type": "module",
4
- "version": "2.9.3",
4
+ "version": "2.9.5",
5
5
  "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
6
6
  "author": {
7
7
  "name": "Tom",
@@ -91,41 +91,41 @@
91
91
  "@formkit/i18n": "^1.6.9",
92
92
  "@formkit/inputs": "^1.6.9",
93
93
  "@formkit/vue": "^1.6.9",
94
- "@intlify/core": "^11.1.4",
94
+ "@intlify/core": "^11.1.5",
95
95
  "primeicons": "^7.0.0",
96
- "primevue": "^4.3.4",
96
+ "primevue": "^4.3.5",
97
97
  "uuid": "^11.1.0",
98
- "vue-i18n": "^11.1.4"
98
+ "vue-i18n": "^11.1.5"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@antfu/eslint-config": "^4.13.2",
102
102
  "@formkit/core": "^1.6.9",
103
103
  "@formkit/drag-and-drop": "^0.5.3",
104
104
  "@primeuix/themes": "^1.1.1",
105
- "@types/node": "^22.15.21",
105
+ "@types/node": "^22.15.29",
106
106
  "@types/uuid": "^10.0.0",
107
107
  "@unocss/preset-icons": "66.1.2",
108
108
  "@unocss/preset-uno": "66.1.2",
109
109
  "@vitejs/plugin-vue": "^5.2.4",
110
- "@vitest/coverage-v8": "^3.1.4",
111
- "@vitest/ui": "^3.1.4",
112
- "@vue/compiler-sfc": "^3.5.15",
113
- "@vue/server-renderer": "^3.5.15",
110
+ "@vitest/coverage-v8": "^3.2.1",
111
+ "@vitest/ui": "^3.2.1",
112
+ "@vue/compiler-sfc": "^3.5.16",
113
+ "@vue/server-renderer": "^3.5.16",
114
114
  "@vue/test-utils": "^2.4.6",
115
115
  "@vue/tsconfig": "^0.7.0",
116
- "@vueuse/core": "^13.2.0",
116
+ "@vueuse/core": "^13.3.0",
117
117
  "@vueuse/head": "^2.0.0",
118
118
  "changelogen": "^0.6.1",
119
119
  "chart.js": "^4.4.9",
120
120
  "consola": "^3.4.2",
121
121
  "cookie": "^1.0.2",
122
- "esbuild": "^0.25.4",
123
- "eslint": "^9.27.0",
124
- "happy-dom": "^17.4.7",
122
+ "esbuild": "^0.25.5",
123
+ "eslint": "^9.28.0",
124
+ "happy-dom": "^17.6.1",
125
125
  "json-editor-vue": "^0.18.1",
126
126
  "mkdist": "^2.3.0",
127
127
  "quill": "^2.0.3",
128
- "sass": "^1.89.0",
128
+ "sass": "^1.89.1",
129
129
  "tslib": "^2.8.1",
130
130
  "typescript": "^5.8.3",
131
131
  "unbuild": "^3.5.0",
@@ -138,8 +138,8 @@
138
138
  "vite-plugin-pages": "^0.33.0",
139
139
  "vite-ssg": "^27.0.1",
140
140
  "vitepress": "^1.6.3",
141
- "vitest": "^3.1.4",
142
- "vue": "^3.5.15",
141
+ "vitest": "^3.2.1",
142
+ "vue": "^3.5.16",
143
143
  "vue-demi": "^0.14.10",
144
144
  "vue-router": "^4.5.1",
145
145
  "vue-tsc": "^2.2.10"