@witchcraft/ui 0.1.0 → 0.1.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 (138) hide show
  1. package/dist/module.json +2 -2
  2. package/dist/module.mjs +1 -1
  3. package/dist/runtime/components/Aria/Aria.vue +5 -9
  4. package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
  5. package/dist/runtime/components/Icon/Icon.vue +10 -31
  6. package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
  7. package/dist/runtime/components/LibButton/LibButton.vue +58 -77
  8. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
  9. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +48 -75
  10. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
  11. package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -108
  12. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
  13. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +271 -352
  14. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
  15. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +32 -57
  16. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
  17. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
  18. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
  19. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +53 -82
  20. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
  21. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +50 -67
  22. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
  23. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
  24. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
  25. package/dist/runtime/components/LibDebug/LibDebug.vue +42 -70
  26. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
  27. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
  28. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
  29. package/dist/runtime/components/LibFileInput/LibFileInput.vue +113 -157
  30. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
  31. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +215 -242
  32. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
  33. package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
  34. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
  35. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +44 -59
  36. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
  37. package/dist/runtime/components/LibNotifications/LibNotification.vue +32 -49
  38. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
  39. package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -84
  40. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
  41. package/dist/runtime/components/LibPagination/LibPagination.vue +67 -112
  42. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
  43. package/dist/runtime/components/LibPalette/LibPalette.vue +20 -23
  44. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
  45. package/dist/runtime/components/LibPopup/LibPopup.vue +314 -352
  46. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
  47. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +70 -92
  48. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
  49. package/dist/runtime/components/LibRecorder/LibRecorder.vue +133 -178
  50. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
  51. package/dist/runtime/components/LibRoot/LibRoot.vue +73 -100
  52. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
  53. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +49 -78
  54. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
  55. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +123 -157
  56. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
  57. package/dist/runtime/components/LibTable/LibTable.vue +63 -100
  58. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
  59. package/dist/runtime/components/Template/NAME.vue +15 -36
  60. package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
  61. package/dist/runtime/components/TestControls/TestControls.vue +6 -9
  62. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
  63. package/dist/runtime/directives/vResizableCols.js +89 -83
  64. package/dist/types.d.mts +2 -6
  65. package/package.json +11 -11
  66. package/src/runtime/components/Focus.stories.ts +3 -2
  67. package/src/runtime/components/Icon/Icon.vue +0 -1
  68. package/src/runtime/components/LibButton/LibButton.vue +0 -1
  69. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -1
  70. package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -1
  71. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +0 -1
  72. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +0 -1
  73. package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -1
  74. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -1
  75. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -1
  76. package/src/runtime/components/LibNotifications/LibNotification.vue +0 -1
  77. package/src/runtime/components/LibNotifications/LibNotifications.vue +0 -1
  78. package/src/runtime/components/LibPagination/LibPagination.vue +0 -1
  79. package/src/runtime/components/LibPopup/LibPopup.vue +0 -1
  80. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -1
  81. package/src/runtime/components/LibRecorder/LibRecorder.vue +0 -1
  82. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +0 -1
  83. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -1
  84. package/src/runtime/components/LibTable/LibTable.vue +0 -1
  85. package/src/runtime/directives/vResizableCols.ts +79 -73
  86. package/dist/module.cjs +0 -5
  87. package/dist/module.d.ts +0 -36
  88. package/dist/runtime/components/Focus.stories.d.ts +0 -11
  89. package/dist/runtime/components/Focus.stories.js +0 -53
  90. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
  91. package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
  92. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
  93. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
  94. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
  95. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
  96. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -9
  97. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
  98. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
  99. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
  100. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
  101. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
  102. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
  103. package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
  104. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
  105. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
  106. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
  107. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
  108. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
  109. package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
  110. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
  111. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -61
  112. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
  113. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
  114. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
  115. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
  116. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
  117. package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
  118. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
  119. package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
  120. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
  121. package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
  122. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
  123. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
  124. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
  125. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
  126. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
  127. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
  128. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
  129. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
  130. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
  131. package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
  132. package/dist/runtime/components/Reset.stories.d.ts +0 -5
  133. package/dist/runtime/components/Reset.stories.js +0 -19
  134. package/dist/runtime/components/Scrolling.stories.d.ts +0 -6
  135. package/dist/runtime/components/Scrolling.stories.js +0 -44
  136. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
  137. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
  138. package/dist/types.d.ts +0 -7
@@ -1,18 +1,19 @@
1
1
  <template>
2
2
  <div
3
- :class="twMerge(`input--outer-wrapper
3
+ :class="twMerge(
4
+ `input--outer-wrapper
4
5
  grow
5
6
  flex
6
7
  flex-wrap
7
8
  `,
8
- disabled && `
9
+ disabled && `
9
10
  text-neutral-400
10
11
  dark:text-neutral-600
11
12
  `,
12
- ($.wrapperAttrs as any)?.class,
13
- )"
13
+ $.wrapperAttrs?.class
14
+ )"
14
15
  tabindex="-1"
15
- v-bind="{...$.wrapperAttrs, class:undefined}"
16
+ v-bind="{ ...$.wrapperAttrs, class: void 0 }"
16
17
  ref="inputWrapperEl"
17
18
  >
18
19
  <slot name="label" v-bind="{ ...slotProps, label }">
@@ -37,8 +38,9 @@
37
38
  :data-disabled="disabled"
38
39
  :data-read-only="readonly"
39
40
  :data-is-open="isOpen"
40
- v-bind="{...$['inner-wrapperAttrs'], class:undefined}"
41
- :class="twMerge(`input--inner-wrapper
41
+ v-bind="{ ...$['inner-wrapperAttrs'], class: void 0 }"
42
+ :class="twMerge(
43
+ `input--inner-wrapper
42
44
  relative
43
45
  flex
44
46
  flex-1
@@ -48,48 +50,48 @@
48
50
  gap-2
49
51
  px-2
50
52
  `,
51
- border && `
53
+ border && `
52
54
  bg-inherit
53
55
  border
54
56
  border-neutral-500
55
57
  outlined-within:border-accent-500
56
58
  `,
57
- isOpen && `rounded-b-none`,
58
- !valid && `
59
+ isOpen && `rounded-b-none`,
60
+ !valid && `
59
61
  border-danger-700
60
62
  outlined:!outline-danger-700
61
63
  text-danger-800
62
64
  dark:text-danger-400
63
65
  dark:border-danger-600
64
66
  `,
65
- readonly && `
67
+ readonly && `
66
68
  bg-neutral-50
67
69
  text-neutral-800
68
70
  dark:bg-neutral-950
69
71
  dark:text-neutral-200
70
72
  `,
71
- disabled && `
73
+ disabled && `
72
74
  bg-neutral-50
73
75
  text-neutral-400
74
76
  dark:border-neutral-600
75
77
  border-neutral-400
76
78
  `,
77
- ($['inner-wrapperAttrs'] as any)?.class,
78
- )"
79
+ $['inner-wrapperAttrs']?.class
80
+ )"
79
81
  >
80
82
  <slot name="left" v-bind="slotProps"/>
81
83
  <slot name="input" v-bind="{ ...inputProps, ...slotProps, suggestionsIndicatorClickHandler }">
82
84
  <lib-simple-input
83
85
  :class="twMerge(
84
- `input--input p-0`,
85
- !$slots.left && `-ml-2 pl-2`,
86
- !$slots.right && (!$values || $values.length === 0) && !suggestions && `-mr-2 -pr-2`,
87
- ($.attrs as any)?.class,
88
- )"
86
+ `input--input p-0`,
87
+ !$slots.left && `-ml-2 pl-2`,
88
+ !$slots.right && (!$values || $values.length === 0) && !suggestions && `-mr-2 -pr-2`,
89
+ $.attrs?.class
90
+ )"
89
91
  v-bind="inputProps"
90
92
  />
91
93
  </slot>
92
- <slot name="indicator" v-bind="{isOpen, suggestionsIndicatorClickHandler }">
94
+ <slot name="indicator" v-bind="{ isOpen, suggestionsIndicatorClickHandler }">
93
95
  <!-- todo, convert to button for accessibility ? -->
94
96
  <div
95
97
  v-if="suggestions"
@@ -102,29 +104,31 @@
102
104
  </slot>
103
105
  <slot
104
106
  name="values"
105
- v-bind="{...multivaluesProps, ...slotProps}"
107
+ v-bind="{ ...multivaluesProps, ...slotProps }"
106
108
  >
107
109
  <template v-if="$values && $values.length > 0">
108
110
  <lib-multi-values
109
- :class="twMerge(`
111
+ :class="twMerge(
112
+ `
110
113
  input--multivalues
111
114
  grow-[9000]
112
115
  justify-space-between
113
116
  py-1
114
117
  `,
115
- !$slots.right && `-mr-1`,
116
- ($.multivaluesAttrs as any)?.class,
117
- )"
118
+ !$slots.right && `-mr-1`,
119
+ $.multivaluesAttrs?.class
120
+ )"
118
121
  v-bind="multivaluesProps"
119
122
  />
120
123
  </template>
121
124
  </slot>
122
125
  <slot name="right" v-bind="slotProps"/>
123
126
 
124
- <slot v-if="suggestions" name="suggestions" v-bind="{...suggestionProps, ...slotProps}">
127
+ <slot v-if="suggestions" name="suggestions" v-bind="{ ...suggestionProps, ...slotProps }">
125
128
  <!-- todo 1px needs to be abstracted to var -->
126
129
  <lib-suggestions
127
- :class="twMerge(`
130
+ :class="twMerge(
131
+ `
128
132
  input--suggestions
129
133
  absolute
130
134
  -inset-x-px
@@ -134,11 +138,11 @@
134
138
  border
135
139
  top-full
136
140
  `,
137
- !border && `
141
+ !border && `
138
142
  rounded-sm
139
143
  `,
140
- ($.suggestionsAttrs as any)?.class,
141
- )"
144
+ $.suggestionsAttrs?.class
145
+ )"
142
146
  ref="suggestionsComponent"
143
147
  v-bind="suggestionProps"
144
148
  >
@@ -150,230 +154,199 @@
150
154
  </div>
151
155
  </div>
152
156
  </template>
153
- <script setup lang="ts">
154
- import { isBlank } from "@alanscodelog/utils/isBlank.js"
155
- import { isObject } from "@alanscodelog/utils/isObject.js"
156
- import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn.js"
157
- import { computed,type HTMLAttributes,type InputHTMLAttributes, nextTick, onBeforeMount, ref, toRef, useSlots, watch } from "vue"
158
- import type { ComponentExposed } from "vue-component-type-helpers"
159
-
160
- import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
161
- import { useSuggestionsInputAria } from "../../composables/useSuggestions.js"
162
- import { twMerge } from "../../utils/twMerge.js"
163
- import Icon from "../Icon/Icon.vue"
164
- import LibLabel from "../LibLabel/LibLabel.vue"
165
- import LibMultiValues from "../LibMultiValues/LibMultiValues.vue"
166
- import LibSimpleInput from "../LibSimpleInput/LibSimpleInput.vue"
167
- import LibSuggestions from "../LibSuggestions/LibSuggestions.vue"
168
- import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId, type LabelProps, type LinkableByIdProps, type SuggestionsProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
169
157
 
170
-
171
- /* #region base */
158
+ <script setup>
159
+ import { isBlank } from "@alanscodelog/utils/isBlank.js";
160
+ import { isObject } from "@alanscodelog/utils/isObject.js";
161
+ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn.js";
162
+ import { computed, nextTick, onBeforeMount, ref, toRef, useSlots, watch } from "vue";
163
+ import { useDivideAttrs } from "../../composables/useDivideAttrs.js";
164
+ import { useSuggestionsInputAria } from "../../composables/useSuggestions.js";
165
+ import { twMerge } from "../../utils/twMerge.js";
166
+ import Icon from "../Icon/Icon.vue";
167
+ import LibLabel from "../LibLabel/LibLabel.vue";
168
+ import LibMultiValues from "../LibMultiValues/LibMultiValues.vue";
169
+ import LibSimpleInput from "../LibSimpleInput/LibSimpleInput.vue";
170
+ import LibSuggestions from "../LibSuggestions/LibSuggestions.vue";
171
+ import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
172
172
  defineOptions({
173
- name: "lib-simple-input-deprecated",
174
- inheritAttrs: false,
175
- })
176
- const $slots = useSlots()
177
- const emit = defineEmits<{
178
- (e: "input", val: InputEvent): void
179
- (e: "submit", val: string, suggestion?: any): void
180
- (e: "keydown", val: KeyboardEvent): void
181
- (e: "blur", val: FocusEvent): void
182
- (e: "focus", val: FocusEvent): void
183
- (e: "indicatorClick", val: MouseEvent): void
184
- }>()
185
-
186
- const fallbackId = getFallbackId()
187
-
188
- // eslint-disable-next-line no-use-before-define
189
- const props = withDefaults(defineProps<Props>(), {
190
- valid: true,
191
- suggestions: undefined,
192
- updateOnlyOnSubmit: false,
193
- ...baseInteractivePropsDefaults,
194
- })
195
-
196
- const $ = useDivideAttrs(["wrapper", "inner-wrapper", "suggestions", "multivalues"] as const)
197
-
198
- const $values = defineModel<string[] | undefined>("values", { default: undefined })
199
- const $modelValue = defineModel<string>({ required: true })
200
-
201
- const fullId = computed(() => props.id ?? fallbackId)
202
-
203
- const $inputValue = defineModel<string>("inputValue", { default: "" })
204
- $inputValue.value = $modelValue.value ?? ""
205
-
206
- const canEdit = computed(() => !props.disabled && !props.readonly)
207
- const suggestionsComponent = ref<ComponentExposed<typeof LibSuggestions> | null>(null)
208
- const activeSuggestion = ref(0)
173
+ name: "lib-simple-input-deprecated",
174
+ inheritAttrs: false
175
+ });
176
+ const $slots = useSlots();
177
+ const emit = defineEmits(["input", "submit", "keydown", "blur", "focus", "indicatorClick"]);
178
+ const fallbackId = getFallbackId();
179
+ const props = defineProps(/* @__PURE__ */ _mergeDefaults({
180
+ suggestions: { type: Array, required: false },
181
+ suggestionLabel: { type: Function, required: false },
182
+ restrictToSuggestions: { type: Boolean, required: false },
183
+ updateOnlyOnSubmit: { type: Boolean, required: false },
184
+ suggestionsFilter: { type: Function, required: false },
185
+ allowOpenEmpty: { type: Boolean, required: false },
186
+ canOpen: { type: Boolean, required: false },
187
+ canClose: { type: Boolean, required: false },
188
+ isValid: { type: Boolean, required: false },
189
+ suggestionSelector: { type: Function, required: false },
190
+ showSelectedValues: { type: Boolean, required: false },
191
+ id: { type: String, required: false },
192
+ label: { type: String, required: false },
193
+ disabled: { type: Boolean, required: false },
194
+ readonly: { type: Boolean, required: false },
195
+ border: { type: Boolean, required: false },
196
+ unstyle: { type: Boolean, required: false },
197
+ valid: { type: Boolean, required: false }
198
+ }, {
199
+ valid: true,
200
+ suggestions: void 0,
201
+ updateOnlyOnSubmit: false,
202
+ ...baseInteractivePropsDefaults
203
+ }));
204
+ const $ = useDivideAttrs(["wrapper", "inner-wrapper", "suggestions", "multivalues"]);
205
+ const $values = defineModel("values", { type: null, ...{ default: void 0 } });
206
+ const $modelValue = defineModel({ type: String, ...{ required: true } });
207
+ const fullId = computed(() => props.id ?? fallbackId);
208
+ const $inputValue = defineModel("inputValue", { type: String, ...{ default: "" } });
209
+ $inputValue.value = $modelValue.value ?? "";
210
+ const canEdit = computed(() => !props.disabled && !props.readonly);
211
+ const suggestionsComponent = ref(null);
212
+ const activeSuggestion = ref(0);
209
213
  watch($modelValue, () => {
210
- $inputValue.value = $modelValue.value
211
- })
212
- const inputWrapperEl = ref<HTMLElement | null>(null)
213
- const isOpen = ref(false)
214
-
215
- const suggestionsIndicatorClickHandler = (e: MouseEvent) => {
216
- nextTick(() => {
217
- if (props.suggestions) {
218
- (suggestionsComponent.value as any)?.suggestions.toggle()
219
- }
220
- })
221
- emit("indicatorClick", e)
222
- }
223
-
224
-
225
- const handleKeydown = (e: KeyboardEvent) => {
226
- if (props.suggestions) {
227
- if (e.key === "Enter" && activeSuggestion.value === -1 && $values.value) {
228
- pushIfNotIn($values.value, [$inputValue.value])
229
- $inputValue.value = ""
230
- $modelValue.value = ""
231
- } else {
232
- (suggestionsComponent.value as any)?.inputKeydownHandler?.(e)
233
- if ($values.value) {
234
- $modelValue.value = ""
235
- }
236
- }
237
- }
238
- emit("keydown", e)
214
+ $inputValue.value = $modelValue.value;
215
+ });
216
+ const inputWrapperEl = ref(null);
217
+ const isOpen = ref(false);
218
+ const suggestionsIndicatorClickHandler = (e) => {
219
+ nextTick(() => {
220
+ if (props.suggestions) {
221
+ suggestionsComponent.value?.suggestions.toggle();
222
+ }
223
+ });
224
+ emit("indicatorClick", e);
225
+ };
226
+ const handleKeydown = (e) => {
227
+ if (props.suggestions) {
228
+ if (e.key === "Enter" && activeSuggestion.value === -1 && $values.value) {
229
+ pushIfNotIn($values.value, [$inputValue.value]);
230
+ $inputValue.value = "";
231
+ $modelValue.value = "";
232
+ } else {
233
+ suggestionsComponent.value?.inputKeydownHandler?.(e);
234
+ if ($values.value) {
235
+ $modelValue.value = "";
236
+ }
237
+ }
238
+ }
239
+ emit("keydown", e);
240
+ };
241
+ const handleBlur = (e) => {
242
+ if (props.suggestions) {
243
+ suggestionsComponent.value?.inputBlurHandler?.(e);
244
+ }
245
+ emit("blur", e);
246
+ };
247
+ const handleFocus = (e) => {
248
+ if (props.suggestions) {
249
+ suggestionsComponent.value?.inputFocusHandler?.(e);
250
+ }
251
+ emit("focus", e);
252
+ };
253
+ function addValue(val) {
254
+ if ($values.value === void 0) return;
255
+ if (isBlank(val)) return;
256
+ pushIfNotIn($values.value, [val]);
257
+ $inputValue.value = "";
258
+ $modelValue.value = "";
239
259
  }
240
- const handleBlur = (e: FocusEvent) => {
241
- if (props.suggestions) {
242
- (suggestionsComponent.value as any)?.inputBlurHandler?.(e)
243
- }
244
- emit("blur", e)
245
- }
246
- const handleFocus = (e: FocusEvent) => {
247
- if (props.suggestions) {
248
- (suggestionsComponent.value as any)?.inputFocusHandler?.(e)
249
- }
250
- emit("focus", e)
251
- }
252
-
253
- function addValue(val: string) {
254
- if ($values.value === undefined) return
255
- if (isBlank(val)) return
256
- pushIfNotIn($values.value, [val])
257
- $inputValue.value = ""
258
- $modelValue.value = ""
259
- }
260
- const suggestions = toRef(props, "suggestions")
260
+ const suggestions = toRef(props, "suggestions");
261
261
  const inputAriaProps = useSuggestionsInputAria(
262
- fullId,
263
- isOpen,
264
- activeSuggestion,
265
- suggestions,
266
- )
262
+ fullId,
263
+ isOpen,
264
+ activeSuggestion,
265
+ suggestions
266
+ );
267
267
  const inputProps = computed(() => ({
268
- id: fullId.value,
269
- border: false,
270
- disabled: props.disabled,
271
- readonly: props.readonly,
272
- isValid: props.valid,
273
- onKeydown: handleKeydown,
274
- onBlur: handleBlur,
275
- onFocus: handleFocus,
276
- modelValue: $inputValue.value,
277
- "onUpdate:modelValue": (e: string) => {
278
- $inputValue.value = e
279
- if (!props.suggestions && !props.updateOnlyOnSubmit && !props.restrictToSuggestions) {
280
- $modelValue.value = e
281
- }
282
- },
283
- onSubmit: (e: string) => {
284
- if (!props.suggestions) {
285
- $modelValue.value = $values.value ? "" : e
286
- emit("submit", e)
287
- if ($values.value) {
288
- addValue(e)
289
- }
290
- }
291
- },
292
- ...inputAriaProps.value,
293
- canEdit: canEdit.value,
294
- ...$.value.attrs,
295
- class: undefined,
296
- }))
297
-
298
- function slotSubmit(val: any, _wasRemoved: boolean): void {
299
- emit("submit", val)
268
+ id: fullId.value,
269
+ border: false,
270
+ disabled: props.disabled,
271
+ readonly: props.readonly,
272
+ isValid: props.valid,
273
+ onKeydown: handleKeydown,
274
+ onBlur: handleBlur,
275
+ onFocus: handleFocus,
276
+ modelValue: $inputValue.value,
277
+ "onUpdate:modelValue": (e) => {
278
+ $inputValue.value = e;
279
+ if (!props.suggestions && !props.updateOnlyOnSubmit && !props.restrictToSuggestions) {
280
+ $modelValue.value = e;
281
+ }
282
+ },
283
+ onSubmit: (e) => {
284
+ if (!props.suggestions) {
285
+ $modelValue.value = $values.value ? "" : e;
286
+ emit("submit", e);
287
+ if ($values.value) {
288
+ addValue(e);
289
+ }
290
+ }
291
+ },
292
+ ...inputAriaProps.value,
293
+ canEdit: canEdit.value,
294
+ ...$.value.attrs,
295
+ class: void 0
296
+ }));
297
+ function slotSubmit(val, _wasRemoved) {
298
+ emit("submit", val);
300
299
  }
301
300
  const slotProps = computed(() => ({
302
- id: fullId.value,
303
- isOpen: isOpen.value,
304
- valid: props.valid,
305
- disabled: props.disabled,
306
- readonly: props.readonly,
307
- emitSubmit: slotSubmit
308
- }))
309
-
310
-
301
+ id: fullId.value,
302
+ isOpen: isOpen.value,
303
+ valid: props.valid,
304
+ disabled: props.disabled,
305
+ readonly: props.readonly,
306
+ emitSubmit: slotSubmit
307
+ }));
311
308
  const suggestionProps = computed(() => ({
312
- id: fullId.value,
313
- suggestions: props.suggestions,
314
- allowOpenEmpty: props.allowOpenEmpty,
315
- restrictToSuggestions: props.restrictToSuggestions,
316
- suggestionLabel: props.suggestionLabel,
317
- suggestionsFilter: props.suggestionsFilter,
318
- modelValue: $values.value ?? $modelValue.value.toString(),
319
- inputValue: $inputValue.value,
320
- isValid: props.isValid,
321
- "onUpdate:inputValue": (e: string) => $inputValue.value = e,
322
- onSubmit: (e: string, suggestion?: any, wasRemoved?: boolean) => {
323
- $modelValue.value = wasRemoved ? "" : e
324
- emit("submit", e, suggestion)
325
- },
326
- "onUpdate:modelValue": (e: string | string[]) => {
327
- $values.value &&= e as string[]
328
- },
329
- "onUpdate:isOpen": (e: boolean) => { isOpen.value = e },
330
- "onUpdate:activeSuggestion": (e: number) => activeSuggestion.value = e,
331
- ...$.value.suggestionsAttrs,
332
- class: undefined,
333
- }))
334
-
309
+ id: fullId.value,
310
+ suggestions: props.suggestions,
311
+ allowOpenEmpty: props.allowOpenEmpty,
312
+ restrictToSuggestions: props.restrictToSuggestions,
313
+ suggestionLabel: props.suggestionLabel,
314
+ suggestionsFilter: props.suggestionsFilter,
315
+ modelValue: $values.value ?? $modelValue.value.toString(),
316
+ inputValue: $inputValue.value,
317
+ isValid: props.isValid,
318
+ "onUpdate:inputValue": (e) => $inputValue.value = e,
319
+ onSubmit: (e, suggestion, wasRemoved) => {
320
+ $modelValue.value = wasRemoved ? "" : e;
321
+ emit("submit", e, suggestion);
322
+ },
323
+ "onUpdate:modelValue": (e) => {
324
+ $values.value &&= e;
325
+ },
326
+ "onUpdate:isOpen": (e) => {
327
+ isOpen.value = e;
328
+ },
329
+ "onUpdate:activeSuggestion": (e) => activeSuggestion.value = e,
330
+ ...$.value.suggestionsAttrs,
331
+ class: void 0
332
+ }));
335
333
  const multivaluesProps = computed(() => ({
336
- hasSlotRight: !$slots.right,
337
- label: props.label,
338
- border: props.border,
339
- disabled: props.disabled,
340
- readonly: props.readonly,
341
- modelValue: $values.value,
342
- "onUpdate:modelValue": (e: string[]) => $values.value = e,
343
- ...$.value.multivaluesAttrs,
344
- class: undefined,
345
- }))
346
-
347
-
334
+ hasSlotRight: !$slots.right,
335
+ label: props.label,
336
+ border: props.border,
337
+ disabled: props.disabled,
338
+ readonly: props.readonly,
339
+ modelValue: $values.value,
340
+ "onUpdate:modelValue": (e) => $values.value = e,
341
+ ...$.value.multivaluesAttrs,
342
+ class: void 0
343
+ }));
348
344
  defineExpose({
349
- suggestionsComponent,
350
- el: inputWrapperEl,
351
- })
352
-
345
+ suggestionsComponent,
346
+ el: inputWrapperEl
347
+ });
353
348
  </script>
354
- <script lang="ts">
355
349
 
356
- type WrapperTypes =
357
- & WrapperProps<"suggestions",HTMLAttributes >
358
- & WrapperProps<"wrapper", HTMLAttributes >
359
- & WrapperProps<"inner-wrapper",HTMLAttributes>
350
+ <script>
360
351
 
361
- type RealProps =
362
- SuggestionsProps
363
- & LinkableByIdProps
364
- & LabelProps
365
- & BaseInteractiveProps
366
- & {
367
- suggestions?: SuggestionsProps["suggestions"]
368
- valid?: boolean
369
- }
370
-
371
- interface Props
372
- extends
373
- /** @vue-ignore */
374
- Partial<Omit<InputHTMLAttributes,"class" | "readonly" | "disabled" | "onSubmit"> & TailwindClassProp>,
375
- /** @vue-ignore */
376
- Partial<WrapperTypes>,
377
- RealProps { }
378
352
  </script>
379
-