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