@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.
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Aria/Aria.vue +5 -9
- package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
- package/dist/runtime/components/Icon/Icon.vue +10 -31
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +58 -77
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +48 -75
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -108
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +271 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +32 -57
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +53 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +50 -67
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +42 -70
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +113 -157
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +215 -242
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +44 -59
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +32 -49
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -84
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -112
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +20 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -352
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +70 -92
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +133 -178
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +73 -100
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +49 -78
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +123 -157
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -100
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
- package/dist/runtime/components/Template/NAME.vue +15 -36
- package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
- package/dist/runtime/components/TestControls/TestControls.vue +6 -9
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/directives/vResizableCols.js +89 -83
- package/dist/types.d.mts +2 -6
- package/package.json +11 -11
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +0 -1
- package/src/runtime/components/LibButton/LibButton.vue +0 -1
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -1
- package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +0 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +0 -1
- package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -1
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -1
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotification.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotifications.vue +0 -1
- package/src/runtime/components/LibPagination/LibPagination.vue +0 -1
- package/src/runtime/components/LibPopup/LibPopup.vue +0 -1
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -1
- package/src/runtime/components/LibRecorder/LibRecorder.vue +0 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +0 -1
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -1
- package/src/runtime/components/LibTable/LibTable.vue +0 -1
- package/src/runtime/directives/vResizableCols.ts +79 -73
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -36
- package/dist/runtime/components/Focus.stories.d.ts +0 -11
- package/dist/runtime/components/Focus.stories.js +0 -53
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
- package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -9
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -61
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
- package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
- package/dist/runtime/components/Reset.stories.d.ts +0 -5
- package/dist/runtime/components/Reset.stories.js +0 -19
- package/dist/runtime/components/Scrolling.stories.d.ts +0 -6
- package/dist/runtime/components/Scrolling.stories.js +0 -44
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/types.d.ts +0 -7
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="twMerge(
|
|
3
|
+
:class="twMerge(
|
|
4
|
+
`input--outer-wrapper
|
|
4
5
|
grow
|
|
5
6
|
flex
|
|
6
7
|
flex-wrap
|
|
7
8
|
`,
|
|
8
|
-
|
|
9
|
+
disabled && `
|
|
9
10
|
text-neutral-400
|
|
10
11
|
dark:text-neutral-600
|
|
11
12
|
`,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
$.wrapperAttrs?.class
|
|
14
|
+
)"
|
|
14
15
|
tabindex="-1"
|
|
15
|
-
v-bind="{...$.wrapperAttrs, class:
|
|
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:
|
|
41
|
-
:class="twMerge(
|
|
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
|
-
|
|
53
|
+
border && `
|
|
52
54
|
bg-inherit
|
|
53
55
|
border
|
|
54
56
|
border-neutral-500
|
|
55
57
|
outlined-within:border-accent-500
|
|
56
58
|
`,
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
141
|
+
!border && `
|
|
138
142
|
rounded-sm
|
|
139
143
|
`,
|
|
140
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
})
|
|
176
|
-
const $slots = useSlots()
|
|
177
|
-
const emit = defineEmits
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
$
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
const
|
|
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
|
-
|
|
211
|
-
})
|
|
212
|
-
const inputWrapperEl = ref
|
|
213
|
-
const isOpen = ref(false)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
)
|
|
262
|
+
fullId,
|
|
263
|
+
isOpen,
|
|
264
|
+
activeSuggestion,
|
|
265
|
+
suggestions
|
|
266
|
+
);
|
|
267
267
|
const inputProps = computed(() => ({
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}))
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
})
|
|
352
|
-
|
|
345
|
+
suggestionsComponent,
|
|
346
|
+
el: inputWrapperEl
|
|
347
|
+
});
|
|
353
348
|
</script>
|
|
354
|
-
<script lang="ts">
|
|
355
349
|
|
|
356
|
-
|
|
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
|
-
|