@sfxcode/formkit-primevue 1.8.6 → 1.9.1

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 (34) hide show
  1. package/README.md +16 -5
  2. package/dist/components/PrimeAutoComplete.vue +38 -12
  3. package/dist/components/PrimeCalendar.vue +110 -17
  4. package/dist/components/PrimeCascadeSelect.vue +41 -10
  5. package/dist/components/PrimeCheckbox.vue +40 -14
  6. package/dist/components/PrimeChips.vue +36 -12
  7. package/dist/components/PrimeColorPicker.vue +32 -12
  8. package/dist/components/PrimeDropdown.vue +90 -16
  9. package/dist/components/PrimeEditor.vue +32 -14
  10. package/dist/components/PrimeInputMask.vue +69 -18
  11. package/dist/components/PrimeInputNumber.vue +55 -13
  12. package/dist/components/PrimeInputSwitch.vue +40 -14
  13. package/dist/components/PrimeInputText.vue +45 -20
  14. package/dist/components/PrimeKnob.vue +47 -13
  15. package/dist/components/PrimeListbox.vue +52 -12
  16. package/dist/components/PrimeMultiSelect.vue +96 -11
  17. package/dist/components/PrimePassword.vue +48 -13
  18. package/dist/components/PrimeRadioButton.vue +33 -15
  19. package/dist/components/PrimeRating.vue +40 -14
  20. package/dist/components/PrimeSelectButton.vue +44 -11
  21. package/dist/components/PrimeSlider.vue +42 -12
  22. package/dist/components/PrimeTextarea.vue +32 -13
  23. package/dist/components/PrimeToggleButton.vue +39 -11
  24. package/dist/components/PrimeTreeSelect.vue +50 -11
  25. package/dist/components/PrimeTriStateCheckbox.vue +36 -13
  26. package/dist/composables/useFormKitSchema.d.ts +1 -1
  27. package/dist/composables/useFormKitSchema.js +6 -4
  28. package/dist/composables/useFormKitSchema.mjs +4 -4
  29. package/dist/index.d.ts +55 -56
  30. package/dist/index.js +24 -24
  31. package/dist/index.mjs +343 -24
  32. package/dist/sass/formkit-primevue.scss +4 -0
  33. package/dist/style.css +1 -1
  34. package/package.json +14 -13
@@ -1,35 +1,109 @@
1
- <script setup lang='ts'>
2
- import { computed } from 'vue'
1
+ <script setup lang="ts">
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { DropdownProps } from 'primevue/dropdown'
5
+
6
+ export interface FormKitPrimeDropdownProps {
7
+ options?: DropdownProps['options']
8
+ optionLabel?: DropdownProps['optionLabel']
9
+ optionValue?: DropdownProps['optionValue']
10
+ optionDisabled?: DropdownProps['optionDisabled']
11
+ optionGroupLabel?: DropdownProps['optionGroupLabel']
12
+ optionGroupChildren?: DropdownProps['optionGroupChildren']
13
+ scrollHeight?: DropdownProps['scrollHeight']
14
+ filter?: DropdownProps['filter']
15
+ filterPlaceholder?: DropdownProps['filterPlaceholder']
16
+ filterLocale?: DropdownProps['filterLocale']
17
+ filterMatchMode?: DropdownProps['filterMatchMode']
18
+ filterFields?: DropdownProps['filterFields']
19
+ filterInputProps?: DropdownProps['filterInputProps']
20
+ editable?: DropdownProps['editable']
21
+ placeholder?: DropdownProps['placeholder']
22
+ dataKey?: DropdownProps['dataKey']
23
+ showClear?: DropdownProps['showClear']
24
+ panelStyle?: DropdownProps['panelStyle']
25
+ panelClass?: DropdownProps['panelClass']
26
+ panelProps?: DropdownProps['panelProps']
27
+ appendTo?: DropdownProps['appendTo']
28
+ resetFilterOnHide?: DropdownProps['resetFilterOnHide']
29
+ virtualScrollerOptions?: DropdownProps['virtualScrollerOptions']
30
+ autoOptionFocus?: DropdownProps['autoOptionFocus']
31
+ selectOnFocus?: DropdownProps['selectOnFocus']
32
+ filterMessage?: DropdownProps['filterMessage']
33
+ selectionMessage?: DropdownProps['selectionMessage']
34
+ emptySelectionMessage?: DropdownProps['emptySelectionMessage']
35
+ emptyFilterMessage?: DropdownProps['emptyFilterMessage']
36
+ emptyMessage?: DropdownProps['emptyMessage']
37
+ pt?: DropdownProps['pt']
38
+ ptOptions?: DropdownProps['ptOptions']
39
+ unstyled?: DropdownProps['unstyled']
40
+ }
3
41
 
4
42
  const props = defineProps({
5
- context: Object,
43
+ context: {
44
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeDropdownProps>,
45
+ required: true,
46
+ },
6
47
  })
7
48
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
10
-
11
- function handleBlur(e: any) {
12
- context?.handlers.blur(e.value)
49
+ function handleBlur(e: Event) {
50
+ props.context?.handlers.blur(e)
13
51
  }
14
52
  function handleInput(e: any) {
15
- context?.node.input(e.value)
53
+ props.context?.node.input(e.value)
16
54
  }
17
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
55
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
18
56
  </script>
19
57
 
20
58
  <template>
21
59
  <div class="p-formkit">
22
60
  <Dropdown
23
61
  v-model="context._value"
24
- v-bind="attrs"
62
+ v-bind="context?.attrs"
25
63
  :input-id="context.id"
26
- :disabled="attrs._disabled ?? !!context?.disabled"
27
- :readonly="attrs._readonly ?? false"
28
- :style="attrs.style"
64
+ :disabled="!!context?.disabled"
65
+ :readonly="context?.attrs._readonly ?? false"
66
+ :style="context?.attrs.style"
29
67
  :class="styleClass"
30
- :input-style="attrs.style"
68
+ :input-style="context?.attrs.style"
31
69
  :input-class="styleClass"
32
- :input-props="attrs.inputProps"
70
+ :input-props="context?.attrs.inputProps"
71
+ :tabindex="context?.attrs.tabindex"
72
+ :aria-label="context?.attrs.ariaLabel"
73
+ :aria-labelledby="context?.attrs.ariaLabelledby"
74
+ :options="context.options"
75
+ :option-label="context.optionLabel"
76
+ :option-value="context.optionValue"
77
+ :option-disabled="context.optionDisabled"
78
+ :option-group-label="context.optionGroupLabel"
79
+ :option-group-children="context.optionGroupChildren"
80
+ :scroll-height="context.scrollHeight"
81
+ :filter="context.filter ?? false"
82
+ :filter-placeholder="context.filterPlaceholder"
83
+ :filter-locale="context.filterLocale"
84
+ :filter-match-mode="context.filterMatchMode"
85
+ :fitler-fields="context.filterFields"
86
+ :filter-input-props="context.filterInputProps"
87
+ :editable="context.editable"
88
+ :placeholder="context.placeholder"
89
+ :data-key="context.dataKey"
90
+ :show-clear="context.showClear ?? false"
91
+ :panel-style="context.panelStyle"
92
+ :panel-class="context.panelClass"
93
+ :panel-props="context.panelProps"
94
+ :append-to="context.appendTo"
95
+ :reset-filter-on-hide="context.resetFilterOnHide"
96
+ :virtual-scroller-options="context.virtualScrollerOptions"
97
+ :auto-option-focus="context.autoOptionFocus"
98
+ :select-on-focus="context.selectOnFocus"
99
+ :filter-message="context.filterMessage"
100
+ :selection-message="context.selectionMessage"
101
+ :empty-selection-message="context.emptySelectionMessage"
102
+ :empty-filter-message="context.emptyFilterMessage"
103
+ :empty-message="context.emptyMessage"
104
+ :pt="context.pt"
105
+ :pt-options="context.ptOptions"
106
+ :unstyled="context.unstyled ?? false"
33
107
  @change="handleInput"
34
108
  @blur="handleBlur"
35
109
  />
@@ -1,25 +1,34 @@
1
- <script setup lang='ts'>
2
- import { computed } from 'vue'
1
+ <script setup lang="ts">
2
+ import type { EditorProps, EditorSelectionChangeEvent } from 'primevue/editor'
3
+ import { type PropType, computed } from 'vue'
4
+ import type { FormKitFrameworkContext } from '@formkit/core'
3
5
 
4
- import type { EditorSelectionChangeEvent } from 'primevue/editor'
6
+ export interface FormKitPrimeEditorProps {
7
+ placeholder?: EditorProps['placeholder']
8
+ formats?: EditorProps['formats']
9
+ modules?: EditorProps['modules']
10
+ pt?: EditorProps['pt']
11
+ ptOptions?: EditorProps['ptOptions']
12
+ unstyled?: EditorProps['unstyled']
13
+ }
5
14
 
6
15
  const props = defineProps({
7
- context: Object,
16
+ context: {
17
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeEditorProps>,
18
+ required: true,
19
+ },
8
20
  })
9
21
 
10
- const context = props.context
11
- const attrs = computed(() => context?.attrs)
12
-
13
22
  function handleInput(e: any) {
14
- context?.node.input(e.htmlValue)
23
+ props.context?.node.input(e.htmlValue)
15
24
  }
16
25
 
17
26
  function handleSelection(e: EditorSelectionChangeEvent) {
18
27
  if (e.range === null)
19
- context?.handlers.blur(e.htmlValue)
28
+ props.context?.handlers.blur(e.htmlValue)
20
29
  }
21
30
 
22
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
31
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
23
32
  </script>
24
33
 
25
34
  <template>
@@ -27,11 +36,20 @@ const styleClass = computed(() => (context?.state.validationVisible && !context?
27
36
  <Editor
28
37
  :id="context.id"
29
38
  v-model="context._value"
30
- v-bind="attrs"
31
- :disabled="attrs._disabled ?? !!context?.disabled"
32
- :readonly="attrs._readonly ?? false"
33
- :editor-style="attrs.style"
39
+ v-bind="context?.attrs"
40
+ :disabled="!!context?.disabled"
41
+ :readonly="context?.attrs._readonly ?? false"
42
+ :editor-style="context?.attrs.style"
34
43
  :class="styleClass"
44
+ :tabindex="context?.attrs.tabindex"
45
+ :aria-label="context?.attrs.ariaLabel"
46
+ :aria-labelledby="context?.attrs.ariaLabelledby"
47
+ :placeholder="context.placeholder"
48
+ :formats="context.formats"
49
+ :modules="context.modules"
50
+ :pt="context.pt"
51
+ :pt-options="context.ptOptions"
52
+ :unstyled="context.unstyled ?? false"
35
53
  @text-change="handleInput"
36
54
  @selection-change="handleSelection"
37
55
  />
@@ -1,31 +1,82 @@
1
1
  <script setup lang='ts'>
2
- import { computed } from 'vue'
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { InputMaskProps } from 'primevue/inputmask'
5
+
6
+ export interface FormKitPrimeInputMaskProps {
7
+ mask?: InputMaskProps['mask']
8
+ slotChar?: InputMaskProps['slotChar']
9
+ autoClear?: InputMaskProps['autoClear']
10
+ unmask?: InputMaskProps['unmask']
11
+ pt?: InputMaskProps['pt']
12
+ ptOptions?: InputMaskProps['ptOptions']
13
+ unstyled?: InputMaskProps['unstyled']
14
+ invalid?: InputMaskProps['invalid']
15
+ variant?: InputMaskProps['variant']
16
+ iconLeft?: string
17
+ iconRight?: string
18
+ }
3
19
 
4
20
  const props = defineProps({
5
- context: Object,
21
+ context: {
22
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeInputMaskProps>,
23
+ required: true,
24
+ },
6
25
  })
7
26
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
27
+ function handleInput(e: FocusEvent) {
28
+ props.context?.node.input(props.context?._value)
29
+ props.context?.handlers.blur(e)
30
+ }
31
+
32
+ function hasLeftIcon() {
33
+ return props.context?.iconLeft && props.context?.iconLeft.length > 0
34
+ }
35
+
36
+ function hasRightIcon() {
37
+ return props.context?.iconRight && props.context?.iconRight.length > 0
38
+ }
10
39
 
11
- function handleInput(e: any) {
12
- context?.node.input(props.context?._value)
13
- context?.handlers.blur(props.context?._value)
40
+ function spanClass() {
41
+ let result = ''
42
+ if (hasLeftIcon())
43
+ result = `${result}p-input-icon-left `
44
+ if (hasRightIcon())
45
+ result = `${result}p-input-icon-right `
46
+ return result
14
47
  }
15
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
48
+
49
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
16
50
  </script>
17
51
 
18
52
  <template>
19
53
  <div class="p-formkit">
20
- <InputMask
21
- :id="context.id"
22
- v-model="context._value"
23
- v-bind="attrs"
24
- :disabled="attrs._disabled ?? !!context?.disabled"
25
- :readonly="attrs._readonly ?? false"
26
- :editor-style="attrs.style"
27
- :class="styleClass"
28
- @blur="handleInput"
29
- />
54
+ <span :class="spanClass()">
55
+ <i v-if="hasLeftIcon()" :class="context.iconLeft" />
56
+
57
+ <InputMask
58
+ :id="context.id"
59
+ v-model="context._value"
60
+ v-bind="context?.attrs"
61
+ :disabled="!!context?.disabled"
62
+ :readonly="context?.attrs._readonly ?? false"
63
+ :class="styleClass"
64
+ :tabindex="context?.attrs.tabindex"
65
+ :aria-label="context?.attrs.ariaLabel"
66
+ :aria-labelledby="context?.attrs.ariaLabelledby"
67
+ :mask="context.mask ?? undefined"
68
+ :slot-char="context.slotChar ?? '_'"
69
+ :auto-clear="context.autoClear ?? true"
70
+ :unmask="context.unmask ?? false"
71
+ :pt="context.pt"
72
+ :invalid="context.invalid"
73
+ :variant="context.variant"
74
+ :pt-options="context.ptOptions"
75
+ :unstyled="context.unstyled ?? false"
76
+ @blur="handleInput"
77
+ />
78
+
79
+ <i v-if="hasRightIcon" :class="context.iconRight" />
80
+ </span>
30
81
  </div>
31
82
  </template>
@@ -1,33 +1,75 @@
1
1
  <script setup lang='ts'>
2
- import { computed } from 'vue'
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { InputNumberBlurEvent, InputNumberProps } from 'primevue/inputnumber'
5
+
6
+ export interface FormKitPrimeInputNumberProps {
7
+ useGrouping?: InputNumberProps['useGrouping']
8
+ min?: InputNumberProps['min']
9
+ max?: InputNumberProps['max']
10
+ minFractionDigits?: InputNumberProps['minFractionDigits']
11
+ maxFractionDigits?: InputNumberProps['maxFractionDigits']
12
+ locale?: InputNumberProps['locale']
13
+ mode?: InputNumberProps['mode']
14
+ currency?: InputNumberProps['currency']
15
+ prefix?: InputNumberProps['prefix']
16
+ suffix?: InputNumberProps['suffix']
17
+ showButtons?: InputNumberProps['showButtons']
18
+ buttonLayout?: InputNumberProps['buttonLayout']
19
+ step?: InputNumberProps['step']
20
+ pt?: InputNumberProps['pt']
21
+ ptOptions?: InputNumberProps['ptOptions']
22
+ unstyled?: InputNumberProps['unstyled']
23
+ placeholder?: InputNumberProps['placeholder']
24
+ }
3
25
 
4
26
  const props = defineProps({
5
- context: Object,
27
+ context: {
28
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeInputNumberProps>,
29
+ required: true,
30
+ },
6
31
  })
7
32
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
10
-
11
- function handleBlur(e: any) {
12
- context?.handlers.blur(e.value)
33
+ function handleBlur(e: InputNumberBlurEvent) {
34
+ props.context?.handlers.blur(e.originalEvent)
13
35
  }
14
36
 
15
37
  function handleInput(e: any) {
16
- context?.node.input(e.value)
38
+ props.context?.node.input(e.value)
17
39
  }
18
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
40
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
19
41
  </script>
20
42
 
21
43
  <template>
22
44
  <div class="p-formkit">
23
45
  <InputNumber
24
46
  v-model="context._value"
25
- v-bind="attrs"
47
+ v-bind="context?.attrs"
26
48
  :input-id="context.id"
27
- :disabled="attrs._disabled ?? !!context?.disabled"
28
- :readonly="attrs._readonly ?? false"
29
- :input-style="attrs.style"
49
+ :disabled="!!context?.disabled"
50
+ :readonly="context?.attrs._readonly ?? false"
51
+ :input-style="context?.attrs.style"
30
52
  :input-class="styleClass"
53
+ :tabindex="context?.attrs.tabindex"
54
+ :aria-label="context?.attrs.ariaLabel"
55
+ :aria-labelledby="context?.attrs.ariaLabelledby"
56
+ :placeholder="context.placeholder"
57
+ :use-grouping="context.useGrouping ?? true"
58
+ :min="context.min ?? undefined"
59
+ :max="context.max ?? undefined"
60
+ :min-fraction-digits="context.minFractionDigits ?? undefined"
61
+ :max-fraction-digits="context.maxFractionDigits ?? undefined"
62
+ :locale="context.locale ?? undefined"
63
+ :mode="context.mode ?? undefined"
64
+ :currency="context.currency ?? undefined"
65
+ :prefix="context.prefix ?? undefined"
66
+ :suffix="context.suffix ?? undefined"
67
+ :show-buttons="context.showButtons ?? undefined"
68
+ :button-layout="context.buttonLayout ?? 'stacked'"
69
+ :step="context.step ?? undefined"
70
+ :pt="context.pt"
71
+ :pt-options="context.ptOptions"
72
+ :unstyled="context.unstyled ?? false"
31
73
  @input="handleInput"
32
74
  @blur="handleBlur"
33
75
  />
@@ -1,32 +1,58 @@
1
1
  <script setup lang='ts'>
2
- import { computed } from 'vue'
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { InputSwitchProps } from 'primevue/inputswitch'
5
+
6
+ export interface FormKitPrimeInputSwitchProps {
7
+ trueValue?: InputSwitchProps['trueValue']
8
+ falseValue?: InputSwitchProps['falseValue']
9
+ pt?: InputSwitchProps['pt']
10
+ ptOptions?: InputSwitchProps['ptOptions']
11
+ unstyled?: InputSwitchProps['unstyled']
12
+ labelLeft?: string
13
+ labelRight?: string
14
+ }
3
15
 
4
16
  const props = defineProps({
5
- context: Object,
17
+ context: {
18
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeInputSwitchProps>,
19
+ required: true,
20
+ },
6
21
  })
7
22
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
23
+ function handleInput(_: any) {
24
+ props.context?.node.input(props.context?._value)
25
+ }
10
26
 
11
- function handleInput(e: any) {
12
- context?.node.input(props.context?._value)
27
+ function handleBlur(e: Event) {
28
+ props.context?.handlers.blur(e)
13
29
  }
14
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
30
+
31
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
15
32
  </script>
16
33
 
17
34
  <template>
18
- <div :class="attrs.option_class" class="p-formkit">
19
- <span v-if="context.attrs.labelLeft" class="formkit-prime-left">{{ context.attrs.labelLeft }}</span>
35
+ <div :class="context?.attrs.option_class" class="p-formkit">
36
+ <span v-if="context.attrs.labelLeft" class="formkit-prime-left">{{ context.labelLeft }}</span>
20
37
  <InputSwitch
21
38
  v-model="context._value"
22
- v-bind="attrs"
39
+ v-bind="context?.attrs"
23
40
  :input-id="context.id"
24
- :disabled="attrs._disabled ?? !!context?.disabled"
25
- :readonly="attrs._readonly ?? false"
26
- :input-style="attrs.style"
41
+ :disabled="!!context?.disabled"
42
+ :readonly="context?.attrs._readonly ?? false"
43
+ :input-style="context?.attrs.style"
27
44
  :input-class="styleClass"
45
+ :tabindex="context?.attrs.tabindex"
46
+ :aria-label="context?.attrs.ariaLabel"
47
+ :aria-labelledby="context?.attrs.ariaLabelledby"
48
+ :true-value="context.trueValue ?? undefined"
49
+ :false-value="context.falseValue ?? undefined"
50
+ :pt="context.pt"
51
+ :pt-options="context.ptOptions"
52
+ :unstyled="context.unstyled ?? false"
28
53
  @change="handleInput"
54
+ @blur="handleBlur"
29
55
  />
30
- <span v-if="context.attrs.labelRight" class="formkit-prime-right">{{ context.attrs.labelRight }}</span>
56
+ <span v-if="context.attrs.labelRight" class="formkit-prime-right">{{ context.labelRight }}</span>
31
57
  </div>
32
58
  </template>
@@ -1,40 +1,58 @@
1
1
  <script setup lang='ts'>
2
- import { computed } from 'vue'
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { InputTextProps } from 'primevue/inputtext'
5
+
6
+ export interface FormKitPrimeInputTextProps {
7
+ pt?: InputTextProps['pt']
8
+ ptOptions?: InputTextProps['ptOptions']
9
+ unstyled?: InputTextProps['unstyled']
10
+ placeholder?: InputTextProps['placeholder']
11
+ icon?: string
12
+ }
3
13
 
4
14
  const props = defineProps({
5
- context: Object,
15
+ context: {
16
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeInputTextProps>,
17
+ required: true,
18
+ },
6
19
  })
7
20
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
10
-
11
21
  function hasIcon() {
12
- return context?.icon && context?.icon.length > 0
22
+ return props.context?.attrs?.icon && props.context?.attrs?.icon.length > 0
13
23
  }
14
24
 
15
- function handleBlur(e: any) {
16
- context?.handlers.blur(e.target.value)
25
+ function handleBlur(e: Event) {
26
+ props.context?.handlers.blur(e)
17
27
  }
18
28
 
19
29
  function handleInput(e: any) {
20
- context?.node.input(e.target.value)
30
+ props.context?.node.input(e.target.value)
21
31
  }
22
32
 
23
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
33
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
24
34
  </script>
25
35
 
26
36
  <template>
27
37
  <div class="p-formkit">
28
- <IconField v-if="hasIcon()" :icon-position="attrs.iconPosition">
29
- <InputIcon :class="context.icon" />
38
+ {{ context.attrs.icon }}
39
+ <IconField v-if="hasIcon()" :icon-position="context?.attrs.iconPosition">
40
+ <InputIcon :class="context.attrs.icon" />
30
41
  <InputText
31
42
  :id="context.id"
32
43
  v-model="context._value"
33
- v-bind="attrs"
34
- :disabled="attrs._disabled ?? !!context?.disabled"
35
- :readonly="attrs._readonly ?? false"
36
- :style="attrs.style"
44
+ v-bind="context?.attrs"
45
+ :disabled="!!context?.disabled"
46
+ :readonly="context?.attrs._readonly ?? false"
47
+ :style="context?.attrs.style"
37
48
  :class="styleClass"
49
+ :tabindex="context?.attrs.tabindex"
50
+ :aria-label="context?.attrs.ariaLabel"
51
+ :aria-labelledby="context?.attrs.ariaLabelledby"
52
+ :placeholder="context.placeholder"
53
+ :pt="context.pt"
54
+ :pt-options="context.ptOptions"
55
+ :unstyled="context.unstyled ?? false"
38
56
  @input="handleInput"
39
57
  @blur="handleBlur"
40
58
  />
@@ -43,11 +61,18 @@ const styleClass = computed(() => (context?.state.validationVisible && !context?
43
61
  v-else
44
62
  :id="context.id"
45
63
  v-model="context._value"
46
- v-bind="attrs"
47
- :disabled="attrs._disabled ?? !!context?.disabled"
48
- :readonly="attrs._readonly ?? false"
49
- :style="attrs.style"
64
+ v-bind="context?.attrs"
65
+ :disabled="!!context?.disabled"
66
+ :readonly="context?.attrs._readonly ?? false"
67
+ :style="context?.attrs.style"
50
68
  :class="styleClass"
69
+ :tabindex="context?.attrs.tabindex"
70
+ :aria-label="context?.attrs.ariaLabel"
71
+ :aria-labelledby="context?.attrs.ariaLabelledby"
72
+ :placeholder="context.placeholder"
73
+ :pt="context.pt"
74
+ :pt-options="context.ptOptions"
75
+ :unstyled="context.unstyled ?? false"
51
76
  @input="handleInput"
52
77
  @blur="handleBlur"
53
78
  />
@@ -1,23 +1,41 @@
1
1
  <script setup lang='ts'>
2
- import { computed } from 'vue'
2
+ import { type PropType, computed } from 'vue'
3
+ import type { FormKitFrameworkContext } from '@formkit/core'
4
+ import type { KnobProps } from 'primevue/knob'
5
+
6
+ export interface FormKitPrimeKnobProps {
7
+ pt?: KnobProps['pt']
8
+ ptOptions?: KnobProps['ptOptions']
9
+ unstyled?: KnobProps['unstyled']
10
+ min?: KnobProps['min']
11
+ max?: KnobProps['max']
12
+ step?: KnobProps['step']
13
+ size?: KnobProps['size']
14
+ strokeWidth?: KnobProps['strokeWidth']
15
+ showValue?: KnobProps['showValue']
16
+ valueColor?: KnobProps['valueColor']
17
+ rangeColor?: KnobProps['rangeColor']
18
+ textColor?: KnobProps['textColor']
19
+ valueTemplate?: KnobProps['valueTemplate']
20
+ }
3
21
 
4
22
  const props = defineProps({
5
- context: Object,
23
+ context: {
24
+ type: Object as PropType<FormKitFrameworkContext & FormKitPrimeKnobProps>,
25
+ required: true,
26
+ },
6
27
  })
7
28
 
8
- const context = props.context
9
- const attrs = computed(() => context?.attrs)
10
-
11
29
  function handleInput(e: any) {
12
- context?.node.input(e)
13
- context?.handlers.blur(e)
30
+ props.context?.node.input(e)
31
+ props.context?.handlers.blur(e)
14
32
  }
15
33
 
16
34
  function updateValue(n: number) {
17
- context?.node.input(n)
35
+ props.context?.node.input(n)
18
36
  }
19
37
 
20
- const styleClass = computed(() => (context?.state.validationVisible && !context?.state.valid) ? `${attrs.value?.class} p-invalid` : attrs.value?.class)
38
+ const styleClass = computed(() => (props.context?.state.validationVisible && !props.context?.state.valid) ? `${props.context?.attrs?.class} p-invalid` : props.context?.attrs?.class)
21
39
  </script>
22
40
 
23
41
  <template>
@@ -25,11 +43,27 @@ const styleClass = computed(() => (context?.state.validationVisible && !context?
25
43
  <Knob
26
44
  :id="context.id"
27
45
  v-model="context._value"
28
- v-bind="attrs"
29
- :disabled="attrs._disabled ?? !!context?.disabled"
30
- :readonly="attrs._readonly ?? false"
31
- :style="attrs.style"
46
+ v-bind="context?.attrs"
47
+ :disabled="!!context?.disabled"
48
+ :readonly="context?.attrs._readonly ?? false"
49
+ :style="context?.attrs.style"
32
50
  :class="styleClass"
51
+ :tabindex="context?.attrs.tabindex"
52
+ :aria-label="context?.attrs.ariaLabel"
53
+ :aria-labelledby="context?.attrs.ariaLabelledby"
54
+ :min="context.min ?? 0"
55
+ :max="context.max ?? 100"
56
+ :step="context.step ?? undefined"
57
+ :size="context.size ?? 100"
58
+ :stroke-width="context.strokeWidth ?? 14"
59
+ :show-value="context.showValue ?? true"
60
+ :value-color="context.valueColor ?? undefined"
61
+ :range-color="context.rangeColor ?? undefined"
62
+ :text-color="context.textColor ?? undefined"
63
+ :value-template="context.valueTemplate ?? undefined"
64
+ :pt="context.pt"
65
+ :pt-options="context.ptOptions"
66
+ :unstyled="context.unstyled ?? false"
33
67
  @change="handleInput"
34
68
  @update:model-value="updateValue"
35
69
  />