@witchcraft/ui 0.2.1-beta.2 → 0.2.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 +1 -1
- package/dist/module.mjs +4 -5
- package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
- package/dist/runtime/build/generateTheme.js +2 -2
- package/dist/runtime/components/Aria/Aria.vue +4 -2
- package/dist/runtime/components/Aria/Aria.vue.d.ts +1 -1
- package/dist/runtime/components/Icon/Icon.vue +3 -3
- package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
- package/dist/runtime/components/LibButton/LibButton.vue +9 -4
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +1 -1
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +3 -4
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +15 -8
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +10 -6
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +1 -1
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +5 -2
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +8 -6
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +7 -5
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
- package/dist/runtime/components/LibDebug/LibDebug.vue +9 -4
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +1 -1
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +2 -1
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +29 -13
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +2 -2
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +42 -12
- package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +3 -3
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +1 -2
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
- package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +10 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +2 -2
- package/dist/runtime/components/LibPagination/LibPagination.vue +25 -12
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
- package/dist/runtime/components/LibPalette/LibPalette.vue +6 -5
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +5 -5
- package/dist/runtime/components/LibPopup/LibPopup.vue +6 -4
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +5 -3
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +9 -9
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +1 -1
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
- package/dist/runtime/components/LibRoot/LibRoot.vue +11 -6
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +1 -1
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +1 -1
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +5 -3
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
- package/dist/runtime/components/LibTable/LibTable.vue +23 -8
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
- package/dist/runtime/components/Template/NAME.vue +2 -3
- package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
- package/dist/runtime/components/TestControls/TestControls.vue +4 -2
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +1 -1
- package/dist/runtime/composables/useDragWithThreshold.d.ts +1 -1
- package/dist/runtime/composables/useInjectedI18n.d.ts +1 -1
- package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +1 -1
- package/dist/runtime/composables/useSetupI18n.d.ts +1 -1
- package/dist/runtime/composables/useSuggestions.d.ts +2 -2
- package/dist/runtime/helpers/NotificationHandler.d.ts +1 -1
- package/dist/runtime/helpers/base64ToImg.js +2 -2
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/utils/notifyIfError.d.ts +1 -1
- package/package.json +4 -6
- package/src/module.ts +28 -32
- package/src/runtime/build/WitchcraftUiResolver.ts +3 -3
- package/src/runtime/build/generateTheme.ts +3 -2
- package/src/runtime/build/unpluginIconViteOptions.ts +1 -1
- package/src/runtime/components/Aria/Aria.vue +5 -6
- package/src/runtime/components/Focus.stories.ts +11 -12
- package/src/runtime/components/Icon/Icon.vue +5 -9
- package/src/runtime/components/LibButton/LibButton.stories.ts +21 -22
- package/src/runtime/components/LibButton/LibButton.vue +23 -21
- package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +6 -10
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +17 -19
- package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +8 -13
- package/src/runtime/components/LibColorInput/LibColorInput.vue +49 -45
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +14 -18
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +50 -52
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -2
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -2
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +1 -2
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +5 -8
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +14 -15
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +1 -2
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +13 -13
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +9 -8
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +2 -1
- package/src/runtime/components/LibDatePicker/helpers.ts +0 -2
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +11 -15
- package/src/runtime/components/LibDebug/LibDebug.vue +14 -11
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +8 -4
- package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +12 -15
- package/src/runtime/components/LibFileInput/LibFileInput.vue +65 -47
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +59 -67
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +73 -48
- package/src/runtime/components/LibLabel/LibLabel.stories.ts +4 -8
- package/src/runtime/components/LibLabel/LibLabel.vue +8 -8
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +10 -15
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +14 -18
- package/src/runtime/components/LibNotifications/LibNotification.stories.ts +30 -34
- package/src/runtime/components/LibNotifications/LibNotification.vue +27 -17
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +11 -15
- package/src/runtime/components/LibNotifications/LibNotifications.vue +21 -16
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +5 -9
- package/src/runtime/components/LibPagination/LibPagination.vue +46 -32
- package/src/runtime/components/LibPalette/LibPalette.stories.ts +3 -7
- package/src/runtime/components/LibPalette/LibPalette.vue +13 -12
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +19 -23
- package/src/runtime/components/LibPopup/LibPopup.vue +31 -35
- package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +13 -17
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +36 -33
- package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +11 -12
- package/src/runtime/components/LibRecorder/LibRecorder.vue +34 -34
- package/src/runtime/components/LibRoot/LibRoot.vue +16 -12
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +20 -24
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +17 -21
- package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +16 -19
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +27 -30
- package/src/runtime/components/LibTable/LibTable.stories.ts +30 -33
- package/src/runtime/components/LibTable/LibTable.vue +38 -24
- package/src/runtime/components/Reset.stories.ts +3 -6
- package/src/runtime/components/Scrolling.stories.ts +5 -8
- package/src/runtime/components/Template/NAME.vue +11 -11
- package/src/runtime/components/Template/TemplateStory.ts +9 -10
- package/src/runtime/components/TestControls/TestControls.vue +5 -5
- package/src/runtime/components/shared/props.ts +4 -6
- package/src/runtime/components/shared/storyHelpers/playInput.ts +2 -3
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +5 -9
- package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
- package/src/runtime/composables/useAriaLabel.ts +1 -1
- package/src/runtime/composables/useDarkMode.ts +15 -19
- package/src/runtime/composables/useDragWithThreshold.ts +6 -8
- package/src/runtime/composables/useGlobalResizeObserver.ts +0 -1
- package/src/runtime/composables/useInjectedDarkMode.ts +2 -2
- package/src/runtime/composables/useInjectedI18n.ts +1 -1
- package/src/runtime/composables/useInjectedLocale.ts +3 -4
- package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +4 -4
- package/src/runtime/composables/useScrollNearContainerEdges.ts +12 -13
- package/src/runtime/composables/useSetupI18n.ts +4 -7
- package/src/runtime/composables/useSetupLocale.ts +3 -5
- package/src/runtime/composables/useSuggestions.ts +25 -30
- package/src/runtime/directives/vDetectFlex.ts +5 -8
- package/src/runtime/directives/vExtractRootEl.ts +1 -1
- package/src/runtime/directives/vResizableCols.ts +3 -7
- package/src/runtime/directives/vResizeObserver.ts +1 -2
- package/src/runtime/globalResizeObserver.ts +0 -1
- package/src/runtime/helpers/NotificationHandler.ts +8 -12
- package/src/runtime/helpers/base64ToImg.ts +2 -3
- package/src/runtime/helpers/createNoonUtcDate.ts +0 -1
- package/src/runtime/helpers/defaultTranslationFunction.ts +0 -1
- package/src/runtime/helpers/getTimeZoneList.ts +0 -1
- package/src/runtime/helpers/readFile.ts +2 -2
- package/src/runtime/helpers/resizeObserverWrapper.ts +0 -1
- package/src/runtime/helpers/storybook.ts +2 -3
- package/src/runtime/main.lib.ts +0 -2
- package/src/runtime/nuxt/plugins/vue-plugin.ts +4 -5
- package/src/runtime/tailwind/themeConvertionOpts.ts +3 -4
- package/src/runtime/theme.ts +0 -1
- package/src/runtime/types/index.ts +3 -4
- package/src/runtime/utils/notifyIfError.ts +2 -2
- package/src/runtime/utils/twMerge.ts +2 -2
- package/src/runtime/vue/VueComponentsPlugin.ts +1 -2
- package/src/runtime/vue/registerComponents.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- todo aria errors -->
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
:class="twMerge(`file-input
|
|
4
5
|
justify-center
|
|
5
6
|
border-2
|
|
6
7
|
border-dashed
|
|
@@ -8,25 +9,26 @@
|
|
|
8
9
|
focus-outline-within
|
|
9
10
|
transition-[border-color,box-shadow]
|
|
10
11
|
ease-out`,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
compact && `rounded-sm`,
|
|
13
|
+
!compact && `flex w-full flex-col items-center gap-2 rounded-xl p-2 `,
|
|
14
|
+
errors.length > 0 && errorFlashing && `border-danger-400`,
|
|
15
|
+
($.wrapperAttrs as any).class
|
|
15
16
|
)"
|
|
16
|
-
v-bind="{...$.wrapperAttrs, class:undefined}"
|
|
17
|
+
v-bind="{ ...$.wrapperAttrs, class: undefined }"
|
|
17
18
|
>
|
|
18
|
-
<div
|
|
19
|
+
<div
|
|
20
|
+
:class="twMerge(`
|
|
19
21
|
file-input--wrapper
|
|
20
22
|
relative justify-center`,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
compact && `flex gap-2`,
|
|
24
|
+
!compact && `input-wrapper
|
|
23
25
|
flex flex-col items-center
|
|
24
26
|
`
|
|
25
|
-
|
|
27
|
+
)"
|
|
26
28
|
>
|
|
27
29
|
<label
|
|
28
30
|
:for="id ?? fallbackId"
|
|
29
|
-
:class="twMerge(
|
|
31
|
+
:class="twMerge(`
|
|
30
32
|
file-input--label
|
|
31
33
|
pointer-events-none
|
|
32
34
|
flex
|
|
@@ -35,7 +37,10 @@
|
|
|
35
37
|
whitespace-nowrap
|
|
36
38
|
`)"
|
|
37
39
|
>
|
|
38
|
-
<slot
|
|
40
|
+
<slot
|
|
41
|
+
v-if="compact || multiple || files.length === 0"
|
|
42
|
+
name="icon"
|
|
43
|
+
>
|
|
39
44
|
<icon><i-fa6-solid-arrow-up-from-bracket/></icon>
|
|
40
45
|
</slot>
|
|
41
46
|
<slot name="label">
|
|
@@ -57,7 +62,10 @@
|
|
|
57
62
|
{{ ` (${files.length})` }}
|
|
58
63
|
</span>
|
|
59
64
|
</label>
|
|
60
|
-
<label
|
|
65
|
+
<label
|
|
66
|
+
v-if="!compact && formats?.length > 0"
|
|
67
|
+
class="file-input--formats-label flex flex-col items-center text-sm"
|
|
68
|
+
>
|
|
61
69
|
<slot name="formats">{{ t("file-input.accepted-formats") }}: </slot>
|
|
62
70
|
<div class="file-input--formats-list">
|
|
63
71
|
{{ extensions.join(", ") }}
|
|
@@ -80,13 +88,14 @@
|
|
|
80
88
|
:accept="formats.join(', ')"
|
|
81
89
|
:multiple="multiple"
|
|
82
90
|
ref="el"
|
|
83
|
-
v-bind="{...$.inputAttrs, class:undefined}"
|
|
91
|
+
v-bind="{ ...$.inputAttrs, class: undefined }"
|
|
84
92
|
@input="(inputFile as any)"
|
|
85
93
|
@click="($event.target! as any).value = null"
|
|
86
94
|
>
|
|
87
95
|
<!-- click event allows event to fire even if the user picks the same file -->
|
|
88
96
|
</div>
|
|
89
|
-
<div
|
|
97
|
+
<div
|
|
98
|
+
v-if="!compact && files.length > 0"
|
|
90
99
|
:class="twMerge(`file-input--previews
|
|
91
100
|
flex items-stretch justify-center gap-2 flex-wrap
|
|
92
101
|
`,
|
|
@@ -97,7 +106,8 @@
|
|
|
97
106
|
)"
|
|
98
107
|
>
|
|
99
108
|
<div class="file-input--preview-spacer flex-1"/>
|
|
100
|
-
<div
|
|
109
|
+
<div
|
|
110
|
+
class="file-input--preview-wrapper
|
|
101
111
|
z-1
|
|
102
112
|
relative
|
|
103
113
|
flex
|
|
@@ -124,16 +134,21 @@
|
|
|
124
134
|
</div>
|
|
125
135
|
|
|
126
136
|
<div class="file-input--preview flex flex-initial basis-full justify-center">
|
|
127
|
-
<div
|
|
137
|
+
<div
|
|
138
|
+
v-if="entry.isImg"
|
|
128
139
|
class="file-input--preview-image
|
|
129
140
|
bg-transparency-squares flex
|
|
130
141
|
h-[80px] flex-wrap items-center
|
|
131
142
|
justify-center
|
|
132
143
|
"
|
|
133
144
|
>
|
|
134
|
-
<img
|
|
145
|
+
<img
|
|
146
|
+
class="max-h-full w-auto"
|
|
147
|
+
:src="getSrc(entry.file)"
|
|
148
|
+
>
|
|
135
149
|
</div>
|
|
136
|
-
<div
|
|
150
|
+
<div
|
|
151
|
+
v-if="!entry.isImg"
|
|
137
152
|
class="file-input--preview-no-image
|
|
138
153
|
flex h-[80px]
|
|
139
154
|
flex-1 basis-full flex-wrap items-center justify-center
|
|
@@ -142,7 +157,8 @@
|
|
|
142
157
|
<icon><i-fa6-regular-file class="text-4xl opacity-50"/></icon>
|
|
143
158
|
</div>
|
|
144
159
|
</div>
|
|
145
|
-
<div
|
|
160
|
+
<div
|
|
161
|
+
class="
|
|
146
162
|
file-input--preview-filename
|
|
147
163
|
min-w-0
|
|
148
164
|
flex-1
|
|
@@ -163,8 +179,9 @@
|
|
|
163
179
|
</div>
|
|
164
180
|
</div>
|
|
165
181
|
</template>
|
|
182
|
+
|
|
166
183
|
<script setup lang="ts">
|
|
167
|
-
import { computed, type HTMLAttributes, type InputHTMLAttributes,ref, shallowReactive, watch } from "vue"
|
|
184
|
+
import { computed, type HTMLAttributes, type InputHTMLAttributes, ref, shallowReactive, watch } from "vue"
|
|
168
185
|
|
|
169
186
|
import IFa6RegularFile from "~icons/fa6-regular/file"
|
|
170
187
|
import IFa6SolidArrowUpFromBracket from "~icons/fa6-solid/arrow-up-from-bracket"
|
|
@@ -172,11 +189,11 @@ import IFa6SolidXmark from "~icons/fa6-solid/xmark"
|
|
|
172
189
|
|
|
173
190
|
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
174
191
|
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
175
|
-
import {
|
|
192
|
+
import type { FileInputError } from "../../types/index.js"
|
|
176
193
|
import { twMerge } from "../../utils/twMerge.js"
|
|
177
194
|
import Icon from "../Icon/Icon.vue"
|
|
178
195
|
import LibButton from "../LibButton/LibButton.vue"
|
|
179
|
-
import { getFallbackId,type LinkableByIdProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
|
|
196
|
+
import { getFallbackId, type LinkableByIdProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
|
|
180
197
|
|
|
181
198
|
const t = useInjectedI18n()
|
|
182
199
|
const el = ref<null | HTMLInputElement>(null)
|
|
@@ -200,11 +217,11 @@ watch(errors, () => {
|
|
|
200
217
|
})
|
|
201
218
|
|
|
202
219
|
defineOptions({
|
|
203
|
-
name: "
|
|
204
|
-
inheritAttrs: false
|
|
220
|
+
name: "LibFileInput",
|
|
221
|
+
inheritAttrs: false
|
|
205
222
|
})
|
|
206
223
|
const $ = useDivideAttrs(["wrapper", "input", "previews"] as const)
|
|
207
|
-
|
|
224
|
+
|
|
208
225
|
const emits = defineEmits<{
|
|
209
226
|
(e: "input", val: File[]): void
|
|
210
227
|
(e: "errors", val: FileInputError[]): void
|
|
@@ -214,7 +231,7 @@ const fallbackId = getFallbackId()
|
|
|
214
231
|
const props = withDefaults(defineProps<Props>(), {
|
|
215
232
|
multiple: false,
|
|
216
233
|
formats: () => ["image/*", ".jpeg", ".jpg", ".png"],
|
|
217
|
-
compact: false
|
|
234
|
+
compact: false
|
|
218
235
|
})
|
|
219
236
|
|
|
220
237
|
const mimeTypes = computed(() => props.formats?.filter(_ => !_.startsWith(".")) ?? [])
|
|
@@ -230,7 +247,7 @@ const removeFile = (entry: Entry) => {
|
|
|
230
247
|
files.splice(index, 1)
|
|
231
248
|
}
|
|
232
249
|
const extensionsList = computed(() => extensions.value.join(", "))
|
|
233
|
-
const inputFile = async (e: InputEvent): Promise<
|
|
250
|
+
const inputFile = async (e: InputEvent): Promise<undefined | boolean> => {
|
|
234
251
|
e.preventDefault()
|
|
235
252
|
if (el.value!.files) {
|
|
236
253
|
const errs = []
|
|
@@ -268,34 +285,35 @@ const inputFile = async (e: InputEvent): Promise<void | boolean> => {
|
|
|
268
285
|
errors.splice(0, errors.length)
|
|
269
286
|
}
|
|
270
287
|
}
|
|
288
|
+
return undefined
|
|
271
289
|
}
|
|
272
|
-
|
|
273
290
|
</script>
|
|
291
|
+
|
|
274
292
|
<script lang="ts">
|
|
275
|
-
export default { name: "
|
|
293
|
+
export default { name: "LibFileInput" }
|
|
276
294
|
|
|
277
|
-
type WrapperTypes
|
|
278
|
-
& WrapperProps<"input", InputHTMLAttributes
|
|
279
|
-
|
|
280
|
-
|
|
295
|
+
type WrapperTypes
|
|
296
|
+
= & WrapperProps<"input", InputHTMLAttributes>
|
|
297
|
+
& WrapperProps<"wrapper", HTMLAttributes>
|
|
298
|
+
& WrapperProps<"previews", HTMLAttributes>
|
|
281
299
|
|
|
282
|
-
type RealProps
|
|
283
|
-
& LinkableByIdProps
|
|
284
|
-
& {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
300
|
+
type RealProps
|
|
301
|
+
= & LinkableByIdProps
|
|
302
|
+
& {
|
|
303
|
+
multiple?: boolean
|
|
304
|
+
/**
|
|
305
|
+
* A list of extensions or mime types to add to the input's accept. Basic validations are done so that files match an extension and mimeType, but note that a file could still be lying, all files should be validated server side.
|
|
306
|
+
*
|
|
307
|
+
* Pass an empty array to allow any filetype.
|
|
308
|
+
*/
|
|
309
|
+
formats?: string[]
|
|
310
|
+
compact?: boolean
|
|
311
|
+
}
|
|
294
312
|
|
|
295
313
|
interface Props
|
|
296
314
|
extends
|
|
297
315
|
/** @vue-ignore */
|
|
298
|
-
Partial<Omit<InputHTMLAttributes,"class" | "multiple" | "formats" | "compact"> & TailwindClassProp>,
|
|
316
|
+
Partial<Omit<InputHTMLAttributes, "class" | "multiple" | "formats" | "compact"> & TailwindClassProp>,
|
|
299
317
|
/** @vue-ignore */
|
|
300
318
|
Partial<WrapperTypes>,
|
|
301
319
|
RealProps { }
|
|
@@ -12,7 +12,6 @@ import IconFaSolidTags from "~icons/fa6-solid/tags"
|
|
|
12
12
|
import { vExtractRootEl } from "../../directives/vExtractRootEl.js"
|
|
13
13
|
import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js"
|
|
14
14
|
import Icon from "../Icon/Icon.vue"
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
16
15
|
import * as components from "../index.js"
|
|
17
16
|
import {
|
|
18
17
|
playBasicVModel,
|
|
@@ -21,7 +20,7 @@ import {
|
|
|
21
20
|
import {
|
|
22
21
|
playBasicClickSelect,
|
|
23
22
|
playBasicKeyboardSelect,
|
|
24
|
-
playBasicSelect
|
|
23
|
+
playBasicSelect
|
|
25
24
|
} from "../shared/storyHelpers/playSuggestions.js"
|
|
26
25
|
|
|
27
26
|
const meta = {
|
|
@@ -31,9 +30,9 @@ const meta = {
|
|
|
31
30
|
border: true,
|
|
32
31
|
label: "Some Label",
|
|
33
32
|
...{
|
|
34
|
-
_template: undefined
|
|
33
|
+
_template: undefined
|
|
35
34
|
} as any
|
|
36
|
-
}
|
|
35
|
+
}
|
|
37
36
|
} satisfies Meta<typeof LibInputDeprecated> & Meta<{ custom: string }>
|
|
38
37
|
|
|
39
38
|
export default meta
|
|
@@ -45,10 +44,9 @@ const allComponents = {
|
|
|
45
44
|
IconFaChevronRight,
|
|
46
45
|
IconFaChevronLeft,
|
|
47
46
|
IconFaSolidKeyboard,
|
|
48
|
-
IconFaSolidTags
|
|
47
|
+
IconFaSolidTags
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
52
50
|
const playAutosuggestSelectLike = async (context: { canvasElement: HTMLElement, args: any }) => {
|
|
53
51
|
await playBasicSelect(context)
|
|
54
52
|
await playBasicKeyboardSelect(context)
|
|
@@ -57,24 +55,24 @@ const playAutosuggestSelectLike = async (context: { canvasElement: HTMLElement,
|
|
|
57
55
|
|
|
58
56
|
const setupModelValue = (args: any) => ({
|
|
59
57
|
modelValue: ref(args.modelValue ?? ""),
|
|
60
|
-
inputValue: ref(args.inputValue ?? "")
|
|
58
|
+
inputValue: ref(args.inputValue ?? "")
|
|
61
59
|
})
|
|
62
60
|
|
|
63
61
|
const setupModelValues = (args: any) => ({
|
|
64
|
-
values: ref(args.values ?? undefined)
|
|
62
|
+
values: ref(args.values ?? undefined)
|
|
65
63
|
})
|
|
66
64
|
|
|
67
65
|
const Base: Story = {
|
|
68
66
|
render: args => ({
|
|
69
67
|
components: allComponents,
|
|
70
68
|
setup: () => ({
|
|
71
|
-
|
|
69
|
+
|
|
72
70
|
...setupModelValue(args),
|
|
73
71
|
...setupModelValues(args),
|
|
74
72
|
args: {
|
|
75
73
|
...args,
|
|
76
|
-
updateOnlyOnSubmit: args.suggestions !== undefined
|
|
77
|
-
}
|
|
74
|
+
updateOnlyOnSubmit: args.suggestions !== undefined
|
|
75
|
+
}
|
|
78
76
|
}),
|
|
79
77
|
|
|
80
78
|
template: (args as any)._template ?? `
|
|
@@ -87,8 +85,8 @@ const Base: Story = {
|
|
|
87
85
|
@submit="modelValue = $event"
|
|
88
86
|
>
|
|
89
87
|
</lib-simple-input-deprecated>
|
|
90
|
-
|
|
91
|
-
})
|
|
88
|
+
`
|
|
89
|
+
})
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
export const Primary: Story = {
|
|
@@ -99,54 +97,53 @@ export const Primary: Story = {
|
|
|
99
97
|
export const Disabled: Story = {
|
|
100
98
|
...Base,
|
|
101
99
|
args: {
|
|
102
|
-
disabled: true
|
|
103
|
-
}
|
|
100
|
+
disabled: true
|
|
101
|
+
}
|
|
104
102
|
}
|
|
105
103
|
export const Readonly: Story = {
|
|
106
104
|
...Base,
|
|
107
105
|
args: {
|
|
108
|
-
readonly: true
|
|
109
|
-
}
|
|
106
|
+
readonly: true
|
|
107
|
+
}
|
|
110
108
|
}
|
|
111
109
|
export const Invalid: Story = {
|
|
112
110
|
...Base,
|
|
113
111
|
args: {
|
|
114
|
-
valid: false
|
|
115
|
-
}
|
|
112
|
+
valid: false
|
|
113
|
+
}
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
export const AttrsPassword: Story = {
|
|
119
117
|
...Base,
|
|
120
118
|
args: {
|
|
121
|
-
type: "password"
|
|
122
|
-
} as any
|
|
119
|
+
type: "password"
|
|
120
|
+
} as any
|
|
123
121
|
}
|
|
124
122
|
export const AttrsDate: Story = {
|
|
125
123
|
...Base,
|
|
126
124
|
args: {
|
|
127
|
-
type: "date"
|
|
128
|
-
} as any
|
|
125
|
+
type: "date"
|
|
126
|
+
} as any
|
|
129
127
|
}
|
|
130
128
|
export const AttrsNumber: Story = {
|
|
131
129
|
...Base,
|
|
132
130
|
args: {
|
|
133
|
-
type: "number"
|
|
134
|
-
} as any
|
|
131
|
+
type: "number"
|
|
132
|
+
} as any
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
export const Borderless = {
|
|
138
136
|
...Base,
|
|
139
137
|
args: {
|
|
140
138
|
border: false,
|
|
141
|
-
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
142
|
-
}
|
|
139
|
+
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
140
|
+
}
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
|
|
146
143
|
export const WithAutosuggest = {
|
|
147
144
|
...Base,
|
|
148
145
|
args: {
|
|
149
|
-
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
146
|
+
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
150
147
|
},
|
|
151
148
|
play: playAutosuggestSelectLike
|
|
152
149
|
}
|
|
@@ -155,21 +152,21 @@ export const WithAutosuggestNoLabel = {
|
|
|
155
152
|
...Base,
|
|
156
153
|
args: {
|
|
157
154
|
label: undefined,
|
|
158
|
-
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
155
|
+
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
159
156
|
},
|
|
160
157
|
play: playAutosuggestSelectLike
|
|
161
158
|
}
|
|
162
159
|
export const WithInstantAutosuggest = {
|
|
163
160
|
...Base,
|
|
164
161
|
args: {
|
|
165
|
-
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
166
|
-
}
|
|
162
|
+
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
163
|
+
}
|
|
167
164
|
}
|
|
168
165
|
export const AutosuggestRestricted = {
|
|
169
166
|
...WithAutosuggest,
|
|
170
167
|
args: {
|
|
171
168
|
...WithAutosuggest.args,
|
|
172
|
-
restrictToSuggestions: true
|
|
169
|
+
restrictToSuggestions: true
|
|
173
170
|
},
|
|
174
171
|
play: playAutosuggestSelectLike
|
|
175
172
|
}
|
|
@@ -192,14 +189,14 @@ export const AutosuggestRestrictedWithClearOnClick = {
|
|
|
192
189
|
</lib-simple-input-deprecated>
|
|
193
190
|
`
|
|
194
191
|
},
|
|
195
|
-
play: null
|
|
192
|
+
play: null
|
|
196
193
|
}
|
|
197
194
|
export const AutosuggestSelectLikeShowAllUnrestricted = {
|
|
198
195
|
...WithAutosuggest,
|
|
199
196
|
args: {
|
|
200
197
|
...WithAutosuggest.args,
|
|
201
198
|
restrictToSuggestions: false,
|
|
202
|
-
suggestionsFilter: (_input: string, items: string[]) => items
|
|
199
|
+
suggestionsFilter: (_input: string, items: string[]) => items
|
|
203
200
|
},
|
|
204
201
|
play: playAutosuggestSelectLike
|
|
205
202
|
}
|
|
@@ -212,9 +209,9 @@ export const AutosuggestObjectOptions = {
|
|
|
212
209
|
{ label: "A", other: "some data A" },
|
|
213
210
|
{ label: "AB", other: "some data AB" },
|
|
214
211
|
{ label: "ABC", other: "some data ABC" },
|
|
215
|
-
{ label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
|
|
212
|
+
{ label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
|
|
216
213
|
],
|
|
217
|
-
suggestionLabel: (item: any) => item.label
|
|
214
|
+
suggestionLabel: (item: any) => item.label
|
|
218
215
|
},
|
|
219
216
|
play: playAutosuggestSelectLike
|
|
220
217
|
}
|
|
@@ -227,10 +224,9 @@ export const Slots: Story = {
|
|
|
227
224
|
...setupModelValues(args),
|
|
228
225
|
args: {
|
|
229
226
|
...args,
|
|
230
|
-
updateOnlyOnSubmit: args.suggestions !== undefined
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
,
|
|
227
|
+
updateOnlyOnSubmit: args.suggestions !== undefined
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
234
230
|
template: `
|
|
235
231
|
Model Value: <span class="inline-block" data-testid="model-value">{{modelValue}}</span>\n
|
|
236
232
|
|
|
@@ -253,8 +249,8 @@ export const Slots: Story = {
|
|
|
253
249
|
</lib-button>
|
|
254
250
|
</template>
|
|
255
251
|
</lib-simple-input-deprecated>
|
|
256
|
-
|
|
257
|
-
})
|
|
252
|
+
`
|
|
253
|
+
})
|
|
258
254
|
}
|
|
259
255
|
const MultipleValuesBase: Story = {
|
|
260
256
|
render: args => ({
|
|
@@ -262,9 +258,8 @@ const MultipleValuesBase: Story = {
|
|
|
262
258
|
setup: () => ({
|
|
263
259
|
...setupModelValue(args),
|
|
264
260
|
...setupModelValues(args),
|
|
265
|
-
args
|
|
266
|
-
})
|
|
267
|
-
,
|
|
261
|
+
args
|
|
262
|
+
}),
|
|
268
263
|
|
|
269
264
|
template: `
|
|
270
265
|
Model Value: <span class="inline-block" data-testid="model-value">{{modelValue}}</span>\n
|
|
@@ -281,12 +276,12 @@ const MultipleValuesBase: Story = {
|
|
|
281
276
|
</lib-button>
|
|
282
277
|
</template>
|
|
283
278
|
</lib-simple-input-deprecated>
|
|
284
|
-
|
|
279
|
+
`
|
|
285
280
|
}),
|
|
286
281
|
args: {
|
|
287
|
-
values: ["A", "B", "C"]
|
|
288
|
-
}
|
|
289
|
-
|
|
282
|
+
values: ["A", "B", "C"]
|
|
283
|
+
}
|
|
284
|
+
|
|
290
285
|
}
|
|
291
286
|
/** Press enter to add a value. */
|
|
292
287
|
export const WithMultipleValues: Story = {
|
|
@@ -298,7 +293,7 @@ export const WithMultipleValuesWithSuggestions = {
|
|
|
298
293
|
...MultipleValuesBase,
|
|
299
294
|
args: {
|
|
300
295
|
...MultipleValuesBase.args,
|
|
301
|
-
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
296
|
+
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
302
297
|
},
|
|
303
298
|
play: playAutosuggestSelectLike
|
|
304
299
|
}
|
|
@@ -307,7 +302,7 @@ export const WithMultipleValuesWithSuggestionsNoSelected = {
|
|
|
307
302
|
args: {
|
|
308
303
|
...MultipleValuesBase.args,
|
|
309
304
|
suggestions: ["A", "AB", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"],
|
|
310
|
-
showSelectedValues: false
|
|
305
|
+
showSelectedValues: false
|
|
311
306
|
},
|
|
312
307
|
play: playAutosuggestSelectLike
|
|
313
308
|
}
|
|
@@ -315,15 +310,15 @@ export const WithMultipleValuesDisabled = {
|
|
|
315
310
|
...MultipleValuesBase,
|
|
316
311
|
args: {
|
|
317
312
|
...MultipleValuesBase.args,
|
|
318
|
-
disabled: true
|
|
319
|
-
}
|
|
313
|
+
disabled: true
|
|
314
|
+
}
|
|
320
315
|
}
|
|
321
316
|
export const WithMultipleValuesReadonly = {
|
|
322
317
|
...MultipleValuesBase,
|
|
323
318
|
args: {
|
|
324
319
|
...MultipleValuesBase.args,
|
|
325
|
-
readonly: true
|
|
326
|
-
}
|
|
320
|
+
readonly: true
|
|
321
|
+
}
|
|
327
322
|
}
|
|
328
323
|
|
|
329
324
|
export const InputSlotReplacement: Story = {
|
|
@@ -345,10 +340,9 @@ export const InputSlotReplacement: Story = {
|
|
|
345
340
|
recorderEl,
|
|
346
341
|
modelValue,
|
|
347
342
|
values,
|
|
348
|
-
args
|
|
343
|
+
args
|
|
349
344
|
}
|
|
350
|
-
}
|
|
351
|
-
,
|
|
345
|
+
},
|
|
352
346
|
|
|
353
347
|
template: `
|
|
354
348
|
Model Value: <span class="inline-block" data-testid="model-value">{{modelValue}}</span>\n
|
|
@@ -378,21 +372,20 @@ export const InputSlotReplacement: Story = {
|
|
|
378
372
|
<icon><icon-fa-solid-keyboard/></icon>
|
|
379
373
|
</template>
|
|
380
374
|
</lib-simple-input-deprecated>
|
|
381
|
-
|
|
375
|
+
`
|
|
382
376
|
}),
|
|
383
377
|
args: {
|
|
384
|
-
values: ["A", "B", "C"]
|
|
385
|
-
}
|
|
378
|
+
values: ["A", "B", "C"]
|
|
379
|
+
}
|
|
386
380
|
}
|
|
387
381
|
|
|
388
|
-
|
|
389
382
|
export const NextToButton: Story = {
|
|
390
383
|
render: args => ({
|
|
391
384
|
components: allComponents,
|
|
392
385
|
setup: () => ({
|
|
393
386
|
...setupModelValue(args),
|
|
394
387
|
...setupModelValues(args),
|
|
395
|
-
args
|
|
388
|
+
args
|
|
396
389
|
}),
|
|
397
390
|
|
|
398
391
|
template: `
|
|
@@ -406,7 +399,6 @@ export const NextToButton: Story = {
|
|
|
406
399
|
</lib-simple-input-deprecated>
|
|
407
400
|
<lib-button>Button</lib-button>
|
|
408
401
|
</div>
|
|
409
|
-
|
|
410
|
-
})
|
|
402
|
+
`
|
|
403
|
+
})
|
|
411
404
|
}
|
|
412
|
-
|