@sfxcode/formkit-primevue 2.0.5 → 2.2.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 (35) hide show
  1. package/README.md +49 -15
  2. package/dist/components/PrimeAutoComplete.vue +7 -12
  3. package/dist/components/PrimeCascadeSelect.vue +5 -11
  4. package/dist/components/PrimeCheckbox.vue +9 -11
  5. package/dist/components/PrimeColorPicker.vue +4 -4
  6. package/dist/components/PrimeDatePicker.vue +5 -11
  7. package/dist/components/PrimeEditor.vue +5 -7
  8. package/dist/components/PrimeInputMask.vue +6 -4
  9. package/dist/components/PrimeInputNumber.vue +6 -7
  10. package/dist/components/PrimeInputOtp.vue +5 -11
  11. package/dist/components/PrimeInputText.vue +5 -11
  12. package/dist/components/PrimeKnob.vue +6 -4
  13. package/dist/components/PrimeListbox.vue +5 -11
  14. package/dist/components/PrimeMultiSelect.vue +5 -11
  15. package/dist/components/PrimePassword.vue +5 -11
  16. package/dist/components/PrimeRadioButton.vue +9 -14
  17. package/dist/components/PrimeRating.vue +5 -11
  18. package/dist/components/PrimeSelect.vue +5 -9
  19. package/dist/components/PrimeSelectButton.vue +5 -11
  20. package/dist/components/PrimeSlider.vue +6 -8
  21. package/dist/components/PrimeTextarea.vue +5 -10
  22. package/dist/components/PrimeToggleButton.vue +5 -11
  23. package/dist/components/PrimeToggleSwitch.vue +7 -13
  24. package/dist/components/PrimeTreeSelect.vue +5 -11
  25. package/dist/composables/index.d.ts +2 -1
  26. package/dist/composables/index.js +7 -0
  27. package/dist/composables/index.mjs +2 -0
  28. package/dist/composables/useFormKitInput.d.ts +8 -0
  29. package/dist/composables/useFormKitInput.js +35 -0
  30. package/dist/composables/useFormKitInput.mjs +22 -0
  31. package/dist/definitions/index.js +23 -23
  32. package/dist/definitions/index.mjs +56 -25
  33. package/dist/sass/formkit-primevue.scss +1 -1
  34. package/dist/style.css +1 -1
  35. package/package.json +16 -16
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Formkit - Primevue
2
2
 
3
- Helper classes for using [FormKit](https://formkit.com/) with the [PrimeVue UI Framework](https://www.primefaces.org/primevue/#/)
3
+ PrimeVue based formkit inputs for using [FormKit](https://formkit.com/) with the [PrimeVue UI Framework](https://www.primefaces.org/primevue/#/).
4
+
5
+ Main focus of this project is to provide configuration based forms with validation.
4
6
 
5
7
  ## PrimeVue Versions
6
8
 
7
- Actual PrimeVue Version in the main branch is 4.x.
9
+ Actual PrimeVue Version in the main branch is *4.x.*
8
10
 
9
11
  PrimeVue 3 is in the prime3 branch.
10
12
 
@@ -16,6 +18,11 @@ PrimeVue 3 is in the prime3 branch.
16
18
 
17
19
  ## Usage
18
20
 
21
+ ### Configuration
22
+
23
+ Add *formkit.config.ts*
24
+
25
+
19
26
  ```typescript
20
27
  import { defaultConfig, plugin } from '@formkit/vue'
21
28
  import { primeInputs } from '@sfxcode/formkit-primevue'
@@ -28,6 +35,32 @@ app.use(plugin, defaultConfig({
28
35
  }))
29
36
  ```
30
37
 
38
+ ### Nuxt
39
+
40
+ Important: use *autoimport: false* if using primevue formkit validation and include or
41
+ exclude not needed components as usual.
42
+
43
+ Autoimport true prevents elements lookup correctly.
44
+
45
+ Example:
46
+ ```typescript
47
+ primevue: {
48
+ autoImport: false,
49
+ components: {
50
+ exclude: ['Chart', 'Editor'],
51
+ },
52
+ options: {
53
+ theme: {
54
+ preset: Aura,
55
+ options: {
56
+ darkModeSelector: '.dark',
57
+ },
58
+ },
59
+ ripple: true,
60
+ },
61
+ },
62
+ ```
63
+
31
64
  ## Limitations
32
65
 
33
66
  Prefixing of the PrimeVue component names is not supported.
@@ -53,6 +86,8 @@ You can use it or take it as base for your own styling.
53
86
  ### Extended Styling
54
87
 
55
88
  - All inputs are wrapped in a div with a **p-formkit** class
89
+ - Use *wrapperClass* to add additional styleclasses to wrapper div
90
+ - Most Prime Components have access to class / styles attributes
56
91
  - Most Prime Components have access to class / styles attributes
57
92
  - PT and PTOptions are available ([https://primevue.org/passthrough/](https://primevue.org/passthrough/))
58
93
  - [Styling](https://formkit-primevue.netlify.app/styling/base) and [PT](https://formkit-primevue.netlify.app/styling/passThrough) demo available
@@ -71,31 +106,30 @@ Some samples for common tasks are available
71
106
 
72
107
  [Nuxt 3 PrimeVue Starter](https://github.com/sfxcode/nuxt3-primevue-starter) and [Vite PrimeVue Starter](https://github.com/sfxcode/vite-primevue-starter) with Formkit support available.
73
108
 
74
- ## Supported Inputs
109
+ ## Supported Inputs for PrimeVue 4
75
110
 
76
111
  - AutoComplete
77
- - Calendar
78
112
  - CascadeSelect
79
113
  - Checkbox
80
- - Chips
81
- - Dropdown
114
+ - ColorPicker
115
+ - DatePicker
82
116
  - Editor (HTML Editor)
83
117
  - InputMask
84
118
  - InputNumber
85
119
  - InputOtp
86
- - InputSwitch
87
120
  - InputText
88
- - InputTextarea
89
- - MultiSelect
90
- - Password
91
- - Ranking
92
121
  - Knob
93
- - ColorPicker
94
122
  - Listbox
95
- - ToggleButton
96
- - SelectButton
97
- - TriStateCheckbox
123
+ - MultiSelect
124
+ - Password
98
125
  - RadioButton
126
+ - Rating
127
+ - Select
128
+ - SelectButton
129
+ - Slider
130
+ - Textarea
131
+ - ToggleButton
132
+ - ToggleSwitch
99
133
  - TreeSelect
100
134
 
101
135
  ## Demo
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed, ref } from 'vue'
2
+ import { type PropType, ref } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { AutoCompleteCompleteEvent, AutoCompleteProps } from 'primevue/autocomplete'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeAutoCompleteProps {
8
9
  pt?: AutoCompleteProps['pt']
@@ -11,6 +12,7 @@ export interface FormKitPrimeAutoCompleteProps {
11
12
  dropdown?: AutoCompleteProps['dropdown']
12
13
  multiple?: AutoCompleteProps['multiple']
13
14
  typeahead?: AutoCompleteProps['typeahead']
15
+ wrapperClass?: string
14
16
  }
15
17
 
16
18
  const props = defineProps({
@@ -20,25 +22,17 @@ const props = defineProps({
20
22
  },
21
23
  })
22
24
 
25
+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput(props.context)
26
+
23
27
  const suggestions = ref([])
24
28
 
25
29
  function search(event: AutoCompleteCompleteEvent) {
26
30
  suggestions.value = props.context?.attrs.complete(event.query)
27
31
  }
28
-
29
- function handleInput(_: any) {
30
- props.context?.node.input(props.context?._value)
31
- }
32
-
33
- function handleBlur(event: Event) {
34
- props.context?.handlers.blur(event)
35
- }
36
-
37
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
38
32
  </script>
39
33
 
40
34
  <template>
41
- <div class="p-formkit">
35
+ <div :class="wrapperClass">
42
36
  <AutoComplete
43
37
  :id="context.id"
44
38
  v-model="context._value"
@@ -55,6 +49,7 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
55
49
  :pt="context?.pt"
56
50
  :pt-options="context?.ptOptions"
57
51
  :unstyled="context?.unstyled ?? false"
52
+ @keydown.enter.prevent
58
53
  @complete="search"
59
54
  @change="handleInput"
60
55
  @blur="handleBlur"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { CascadeSelectProps } from 'primevue/cascadeselect'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeCascadeSelectProps {
8
9
  options?: CascadeSelectProps['options']
@@ -14,6 +15,7 @@ export interface FormKitPrimeCascadeSelectProps {
14
15
  pt?: CascadeSelectProps['pt']
15
16
  ptOptions?: CascadeSelectProps['ptOptions']
16
17
  unstyled?: CascadeSelectProps['unstyled']
18
+ wrapperClass?: string
17
19
  }
18
20
 
19
21
  const props = defineProps({
@@ -23,19 +25,11 @@ const props = defineProps({
23
25
  },
24
26
  })
25
27
 
26
- function handleInput(_: any) {
27
- props.context?.node.input(props.context?._value)
28
- }
29
-
30
- function handleBlur(e: Event) {
31
- props.context?.handlers.blur(e)
32
- }
33
-
34
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
28
+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput(props.context)
35
29
  </script>
36
30
 
37
31
  <template>
38
- <div class="p-formkit">
32
+ <div :class="wrapperClass">
39
33
  <CascadeSelect
40
34
  :id="context.id"
41
35
  v-model="context._value"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { CheckboxProps } from 'primevue/checkbox'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeCheckboxProps {
8
9
  binary?: CheckboxProps['binary']
@@ -11,8 +12,11 @@ export interface FormKitPrimeCheckboxProps {
11
12
  pt?: CheckboxProps['pt']
12
13
  ptOptions?: CheckboxProps['ptOptions']
13
14
  unstyled?: CheckboxProps['unstyled']
15
+ indeterminate?: CheckboxProps['indeterminate']
16
+ variant?: CheckboxProps['variant']
14
17
  labelLeft?: string
15
18
  labelRight?: string
19
+ wrapperClass?: string
16
20
  }
17
21
 
18
22
  const props = defineProps({
@@ -22,19 +26,11 @@ const props = defineProps({
22
26
  },
23
27
  })
24
28
 
25
- function handleInput(_: any) {
26
- props.context?.node.input(props.context?._value)
27
- }
28
-
29
- function handleBlur(e: Event) {
30
- props.context?.handlers.blur(e)
31
- }
32
-
33
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
29
+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput(props.context)
34
30
  </script>
35
31
 
36
32
  <template>
37
- <div class="p-formkit">
33
+ <div :class="wrapperClass">
38
34
  <span v-if="context.labelLeft" class="formkit-prime-left">{{ context.labelLeft }}</span>
39
35
  <Checkbox
40
36
  v-model="context._value"
@@ -47,7 +43,9 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
47
43
  :tabindex="context?.attrs.tabindex"
48
44
  :aria-label="context?.attrs.ariaLabel"
49
45
  :aria-labelledby="context?.attrs.ariaLabelledby"
46
+ :indeterminate="context.indeterminate ?? null"
50
47
  :binary="context.binary ?? true"
48
+ :variant="context.variant ?? 'outlined'"
51
49
  :true-value="context.trueValue ?? undefined"
52
50
  :false-value="context.falseValue ?? undefined"
53
51
  :pt="context.pt"
@@ -3,6 +3,7 @@ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { ColorPickerProps } from 'primevue/colorpicker'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeColorPickerProps {
8
9
  defaultColor?: ColorPickerProps['defaultColor']
@@ -11,6 +12,7 @@ export interface FormKitPrimeColorPickerProps {
11
12
  pt?: ColorPickerProps['pt']
12
13
  ptOptions?: ColorPickerProps['ptOptions']
13
14
  unstyled?: ColorPickerProps['unstyled']
15
+ wrapperClass?: string
14
16
  }
15
17
 
16
18
  const props = defineProps({
@@ -20,13 +22,11 @@ const props = defineProps({
20
22
  },
21
23
  })
22
24
 
23
- function handleChange(_: any) {
24
- props.context?.node.input(props.context?._value)
25
- }
25
+ const { wrapperClass, handleChange } = useFormKitInput(props.context)
26
26
  </script>
27
27
 
28
28
  <template>
29
- <div class="p-formkit">
29
+ <div :class="wrapperClass">
30
30
  <ColorPicker
31
31
  v-model="context._value"
32
32
  v-bind="context?.attrs"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { DatePickerBlurEvent, DatePickerProps } from 'primevue/datepicker'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeDatePickerProps {
8
9
  dateFormat?: DatePickerProps['dateFormat']
@@ -48,6 +49,7 @@ export interface FormKitPrimeDatePickerProps {
48
49
  pt?: DatePickerProps['pt']
49
50
  ptOptions?: DatePickerProps['ptOptions']
50
51
  unstyled?: DatePickerProps['unstyled']
52
+ wrapperClass?: string
51
53
  }
52
54
 
53
55
  const props = defineProps({
@@ -57,13 +59,7 @@ const props = defineProps({
57
59
  },
58
60
  })
59
61
 
60
- function handleInput(_: any) {
61
- props.context?.node.input(props.context?._value)
62
- }
63
-
64
- function handleSelect(e: any) {
65
- props.context?.node.input(e)
66
- }
62
+ const { styleClass, wrapperClass, handleInput, handleSelect } = useFormKitInput(props.context)
67
63
 
68
64
  function handleBlur(e: DatePickerBlurEvent) {
69
65
  props.context?.handlers.blur(e.originalEvent)
@@ -72,12 +68,10 @@ function handleBlur(e: DatePickerBlurEvent) {
72
68
  function handleClearClick() {
73
69
  props.context?.node.input(null)
74
70
  }
75
-
76
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
77
71
  </script>
78
72
 
79
73
  <template>
80
- <div class="p-formkit">
74
+ <div :class="wrapperClass">
81
75
  <DatePicker
82
76
  v-model="context._value"
83
77
  v-bind="context?.attrs"
@@ -1,8 +1,9 @@
1
1
  <script setup lang="ts">
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { EditorProps, EditorSelectionChangeEvent } from 'primevue/editor'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeEditorProps {
8
9
  placeholder?: EditorProps['placeholder']
@@ -11,6 +12,7 @@ export interface FormKitPrimeEditorProps {
11
12
  pt?: EditorProps['pt']
12
13
  ptOptions?: EditorProps['ptOptions']
13
14
  unstyled?: EditorProps['unstyled']
15
+ wrapperClass?: string
14
16
  }
15
17
 
16
18
  const props = defineProps({
@@ -20,20 +22,16 @@ const props = defineProps({
20
22
  },
21
23
  })
22
24
 
23
- function handleInput(e: any) {
24
- props.context?.node.input(e.htmlValue)
25
- }
25
+ const { styleClass, wrapperClass, handleInput } = useFormKitInput(props.context)
26
26
 
27
27
  function handleSelection(e: EditorSelectionChangeEvent) {
28
28
  if (e.range === null)
29
29
  props.context?.handlers.blur(e.htmlValue)
30
30
  }
31
-
32
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
33
31
  </script>
34
32
 
35
33
  <template>
36
- <div class="p-formkit">
34
+ <div :class="wrapperClass">
37
35
  <Editor
38
36
  :id="context.id"
39
37
  v-model="context._value"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { InputMaskProps } from 'primevue/inputmask'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeInputMaskProps {
8
9
  mask?: InputMaskProps['mask']
@@ -16,6 +17,7 @@ export interface FormKitPrimeInputMaskProps {
16
17
  variant?: InputMaskProps['variant']
17
18
  iconLeft?: string
18
19
  iconRight?: string
20
+ wrapperClass?: string
19
21
  }
20
22
 
21
23
  const props = defineProps({
@@ -25,6 +27,8 @@ const props = defineProps({
25
27
  },
26
28
  })
27
29
 
30
+ const { styleClass, wrapperClass } = useFormKitInput(props.context)
31
+
28
32
  function handleInput(e: FocusEvent) {
29
33
  props.context?.node.input(props.context?._value)
30
34
  props.context?.handlers.blur(e)
@@ -46,12 +50,10 @@ function spanClass() {
46
50
  result = `${result}p-input-icon-right `
47
51
  return result
48
52
  }
49
-
50
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
51
53
  </script>
52
54
 
53
55
  <template>
54
- <div class="p-formkit">
56
+ <div :class="wrapperClass">
55
57
  <span :class="spanClass()">
56
58
  <i v-if="hasLeftIcon()" :class="context.iconLeft" />
57
59
 
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { InputNumberBlurEvent, InputNumberProps } from 'primevue/inputnumber'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeInputNumberProps {
8
9
  useGrouping?: InputNumberProps['useGrouping']
@@ -22,6 +23,7 @@ export interface FormKitPrimeInputNumberProps {
22
23
  ptOptions?: InputNumberProps['ptOptions']
23
24
  unstyled?: InputNumberProps['unstyled']
24
25
  placeholder?: InputNumberProps['placeholder']
26
+ wrapperClass?: string
25
27
  }
26
28
 
27
29
  const props = defineProps({
@@ -31,18 +33,15 @@ const props = defineProps({
31
33
  },
32
34
  })
33
35
 
36
+ const { styleClass, wrapperClass, handleInput } = useFormKitInput(props.context)
37
+
34
38
  function handleBlur(e: InputNumberBlurEvent) {
35
39
  props.context?.handlers.blur(e.originalEvent)
36
40
  }
37
-
38
- function handleInput(e: any) {
39
- props.context?.node.input(e.value)
40
- }
41
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
42
41
  </script>
43
42
 
44
43
  <template>
45
- <div class="p-formkit">
44
+ <div :class="wrapperClass">
46
45
  <InputNumber
47
46
  v-model="context._value"
48
47
  v-bind="context?.attrs"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { InputOtpProps } from 'primevue/inputotp'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeInputOtpProps {
8
9
  unstyled?: InputOtpProps['unstyled']
@@ -12,6 +13,7 @@ export interface FormKitPrimeInputOtpProps {
12
13
  variant?: InputOtpProps['variant']
13
14
  mask?: InputOtpProps['mask']
14
15
  integerOnly?: InputOtpProps['integerOnly']
16
+ wrapperClass?: string
15
17
  }
16
18
 
17
19
  const props = defineProps({
@@ -21,19 +23,11 @@ const props = defineProps({
21
23
  },
22
24
  })
23
25
 
24
- function handleInput(_: any) {
25
- props.context?.node.input(props.context?._value)
26
- }
27
-
28
- function handleBlur(e: Event) {
29
- props.context?.handlers.blur(e)
30
- }
31
-
32
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
26
+ const { styleClass, wrapperClass, handleBlur, handleInput } = useFormKitInput(props.context)
33
27
  </script>
34
28
 
35
29
  <template>
36
- <div class="p-formkit">
30
+ <div :class="wrapperClass">
37
31
  <InputOtp
38
32
  :id="context.id"
39
33
  v-model="context._value"
@@ -5,6 +5,7 @@ import type { FormKitFrameworkContext } from '@formkit/core'
5
5
  import IconField from 'primevue/iconfield'
6
6
  import InputIcon from 'primevue/inputicon'
7
7
  import type { InputTextProps } from 'primevue/inputtext'
8
+ import { useFormKitInput } from '../composables'
8
9
 
9
10
  export interface FormKitPrimeInputTextProps {
10
11
  pt?: InputTextProps['pt']
@@ -12,6 +13,7 @@ export interface FormKitPrimeInputTextProps {
12
13
  unstyled?: InputTextProps['unstyled']
13
14
  placeholder?: InputTextProps['placeholder']
14
15
  icon?: string
16
+ wrapperClass?: string
15
17
  }
16
18
 
17
19
  const props = defineProps({
@@ -21,6 +23,8 @@ const props = defineProps({
21
23
  },
22
24
  })
23
25
 
26
+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput(props.context)
27
+
24
28
  const hasIcon = computed(() => {
25
29
  if (props.context?.icon && props.context?.icon.length > 0)
26
30
  return true
@@ -35,20 +39,10 @@ const icon = computed(() => {
35
39
  const iconPosition = computed(() => {
36
40
  return props.context?.attrs?.iconPosition ?? undefined
37
41
  })
38
-
39
- function handleBlur(e: Event) {
40
- props.context?.handlers.blur(e)
41
- }
42
-
43
- function handleInput(e: any) {
44
- props.context?.node.input(e.target.value)
45
- }
46
-
47
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
48
42
  </script>
49
43
 
50
44
  <template>
51
- <div class="p-formkit">
45
+ <div :class="wrapperClass">
52
46
  <IconField v-if="hasIcon" :icon-position="iconPosition">
53
47
  <InputIcon :class="icon" />
54
48
  <InputText
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { KnobProps } from 'primevue/knob'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeKnobProps {
8
9
  pt?: KnobProps['pt']
@@ -18,6 +19,7 @@ export interface FormKitPrimeKnobProps {
18
19
  rangeColor?: KnobProps['rangeColor']
19
20
  textColor?: KnobProps['textColor']
20
21
  valueTemplate?: KnobProps['valueTemplate']
22
+ wrapperClass?: string
21
23
  }
22
24
 
23
25
  const props = defineProps({
@@ -27,6 +29,8 @@ const props = defineProps({
27
29
  },
28
30
  })
29
31
 
32
+ const { styleClass, wrapperClass } = useFormKitInput(props.context)
33
+
30
34
  function handleInput(e: any) {
31
35
  props.context?.node.input(e)
32
36
  props.context?.handlers.blur(e)
@@ -35,12 +39,10 @@ function handleInput(e: any) {
35
39
  function updateValue(n: number) {
36
40
  props.context?.node.input(n)
37
41
  }
38
-
39
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
40
42
  </script>
41
43
 
42
44
  <template>
43
- <div class="p-formkit">
45
+ <div :class="wrapperClass">
44
46
  <Knob
45
47
  :id="context.id"
46
48
  v-model="context._value"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { ListboxProps } from 'primevue/listbox'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeListboxProps {
8
9
  pt?: ListboxProps['pt']
@@ -19,6 +20,7 @@ export interface FormKitPrimeListboxProps {
19
20
  filterMatchMode?: ListboxProps['filterMatchMode']
20
21
  autoOptionFocus?: ListboxProps['autoOptionFocus']
21
22
  selectOnFocus?: ListboxProps['selectOnFocus']
23
+ wrapperClass?: string
22
24
  }
23
25
 
24
26
  const props = defineProps({
@@ -28,19 +30,11 @@ const props = defineProps({
28
30
  },
29
31
  })
30
32
 
31
- function handleInput(_: any) {
32
- props.context?.node.input(props.context?._value)
33
- }
34
-
35
- function handleBlur(e: Event) {
36
- props.context?.handlers.blur(e)
37
- }
38
-
39
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
33
+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput(props.context)
40
34
  </script>
41
35
 
42
36
  <template>
43
- <div class="p-formkit">
37
+ <div :class="wrapperClass">
44
38
  <Listbox
45
39
  :id="context.id"
46
40
  v-model="context._value"
@@ -1,8 +1,9 @@
1
1
  <script setup lang='ts'>
2
- import { type PropType, computed } from 'vue'
2
+ import type { PropType } from 'vue'
3
3
  import type { FormKitFrameworkContext } from '@formkit/core'
4
4
 
5
5
  import type { MultiSelectProps } from 'primevue/multiselect'
6
+ import { useFormKitInput } from '../composables'
6
7
 
7
8
  export interface FormKitPrimeMultiSelectProps {
8
9
  options?: MultiSelectProps['options']
@@ -40,6 +41,7 @@ export interface FormKitPrimeMultiSelectProps {
40
41
  placeholder?: MultiSelectProps['placeholder']
41
42
  ptOptions?: MultiSelectProps['ptOptions']
42
43
  unstyled?: MultiSelectProps['unstyled']
44
+ wrapperClass?: string
43
45
  }
44
46
 
45
47
  const props = defineProps({
@@ -49,19 +51,11 @@ const props = defineProps({
49
51
  },
50
52
  })
51
53
 
52
- function handleChange(_: any) {
53
- props.context?.node.input(props.context?._value)
54
- }
55
-
56
- function handleBlur(e: Event) {
57
- props.context?.handlers.blur(e)
58
- }
59
-
60
- const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
54
+ const { styleClass, wrapperClass, handleBlur, handleChange } = useFormKitInput(props.context)
61
55
  </script>
62
56
 
63
57
  <template>
64
- <div class="p-formkit">
58
+ <div :class="wrapperClass">
65
59
  <MultiSelect
66
60
  v-model="context._value"
67
61
  v-bind="context?.attrs"