@witchcraft/ui 0.0.1 → 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/README.md +18 -28
- package/dist/module.d.mts +3 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +21 -12
- package/dist/runtime/assets/base.css +1 -1
- package/dist/runtime/assets/locales/en.json +2 -2
- package/dist/runtime/assets/tailwind.css +1 -1
- package/dist/runtime/assets/utils.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.js +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 +12 -28
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +93 -117
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
- 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 +50 -66
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +69 -106
- 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 +7 -10
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/index.d.ts +12 -11
- package/dist/runtime/components/index.js +12 -11
- package/dist/runtime/components/shared/props.d.ts +81 -16
- package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
- package/dist/runtime/composables/index.d.ts +5 -0
- package/dist/runtime/composables/index.js +5 -0
- package/dist/runtime/composables/useDivideAttrs.js +1 -0
- package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
- package/dist/runtime/composables/useDragWithThreshold.js +40 -0
- package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
- package/dist/runtime/composables/usePreHydrationValue.js +15 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
- package/dist/runtime/composables/useSetupI18n.js +5 -1
- package/dist/runtime/composables/useSuggestions.d.ts +7 -5
- package/dist/runtime/composables/useSuggestions.js +94 -57
- package/dist/runtime/directives/vResizableCols.js +92 -84
- package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
- package/dist/runtime/helpers/index.d.ts +3 -1
- package/dist/runtime/helpers/index.js +3 -1
- package/dist/runtime/types/index.d.ts +6 -0
- package/dist/runtime/utils/notifyIfError.d.ts +14 -0
- package/dist/runtime/utils/notifyIfError.js +29 -0
- package/dist/types.d.mts +2 -6
- package/package.json +27 -29
- package/src/module.ts +31 -12
- package/src/runtime/assets/base.css +10 -1
- package/src/runtime/assets/locales/en.json +2 -2
- package/src/runtime/assets/tailwind.css +1 -1
- package/src/runtime/assets/{style.css → utils.css} +86 -4
- package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +10 -6
- package/src/runtime/components/LibButton/LibButton.vue +41 -47
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
- package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
- package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
- package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
- package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
- package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
- package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
- package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
- package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
- package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
- package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
- package/src/runtime/components/LibTable/LibTable.vue +8 -9
- package/src/runtime/components/Scrolling.stories.ts +58 -0
- package/src/runtime/components/Template/NAME.vue +1 -1
- package/src/runtime/components/TestControls/TestControls.vue +1 -1
- package/src/runtime/components/index.ts +12 -12
- package/src/runtime/components/shared/props.ts +82 -19
- package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
- package/src/runtime/composables/index.ts +5 -0
- package/src/runtime/composables/useDarkMode.ts +2 -2
- package/src/runtime/composables/useDivideAttrs.ts +1 -0
- package/src/runtime/composables/useDragWithThreshold.ts +108 -0
- package/src/runtime/composables/usePreHydrationValue.ts +30 -0
- package/src/runtime/composables/useSetupI18n.ts +8 -2
- package/src/runtime/composables/useSuggestions.ts +92 -45
- package/src/runtime/directives/vResizableCols.ts +82 -74
- package/src/runtime/helpers/NotificationHandler.ts +5 -0
- package/src/runtime/helpers/index.ts +3 -1
- package/src/runtime/types/index.ts +5 -0
- package/src/runtime/utils/notifyIfError.ts +45 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -34
- package/dist/runtime/assets/style.css +0 -1
- 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 -7
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
- 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/LibInput/LibInput.stories.d.ts +0 -33
- package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
- 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 -60
- 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/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/runtime/helpers/addValue.d.ts +0 -1
- package/dist/runtime/helpers/addValue.js +0 -8
- package/dist/types.d.ts +0 -7
- package/src/runtime/components/LibInput/LibInput.vue +0 -372
- package/src/runtime/helpers/addValue.ts +0 -10
- /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Theme } from "metamorphosis";
|
|
2
|
+
import { NotificationHandler } from "../../helpers/NotificationHandler.js.js";
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
theme?: Theme;
|
|
5
|
+
outline?: boolean;
|
|
6
|
+
forceOutline?: boolean;
|
|
7
|
+
testWrapperMode?: boolean;
|
|
8
|
+
id?: string;
|
|
9
|
+
/** You can set a ref to the root element by passing :getRef="_ => el = _" */
|
|
10
|
+
getRef?: (el: HTMLElement | null) => void;
|
|
11
|
+
/** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
|
|
12
|
+
isClientSide?: boolean;
|
|
13
|
+
useBuiltinTranslations?: boolean;
|
|
14
|
+
useNotifications?: boolean;
|
|
15
|
+
notificationHandler?: NotificationHandler;
|
|
16
|
+
};
|
|
17
|
+
declare var __VLS_9: {};
|
|
18
|
+
type __VLS_Slots = {} & {
|
|
19
|
+
default?: (props: typeof __VLS_9) => any;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
22
|
+
darkMode: import("../../composables/useDarkMode.js.js").DarkModeState & import("../../composables/useDarkMode.js.js").DarkModeCommands;
|
|
23
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
24
|
+
theme: Theme;
|
|
25
|
+
id: string;
|
|
26
|
+
useBuiltinTranslations: boolean;
|
|
27
|
+
isClientSide: boolean;
|
|
28
|
+
outline: boolean;
|
|
29
|
+
forceOutline: boolean;
|
|
30
|
+
testWrapperMode: boolean;
|
|
31
|
+
getRef: (el: HTMLElement | null) => void;
|
|
32
|
+
useNotifications: boolean;
|
|
33
|
+
notificationHandler: NotificationHandler;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: S;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
:id="id ?? fallbackId"
|
|
4
|
-
:class="twMerge(
|
|
5
|
-
|
|
4
|
+
:class="twMerge(
|
|
5
|
+
`
|
|
6
|
+
simple-input
|
|
6
7
|
flex-1
|
|
7
8
|
grow-[999999]
|
|
8
9
|
rounded-sm
|
|
@@ -27,35 +28,35 @@
|
|
|
27
28
|
dark:disabled:bg-neutral-950
|
|
28
29
|
dark:disabled:text-neutral-500
|
|
29
30
|
`,
|
|
30
|
-
|
|
31
|
+
type === `text` && `
|
|
31
32
|
min-w-[10ch]
|
|
32
33
|
w-full
|
|
33
34
|
`,
|
|
34
|
-
|
|
35
|
+
type === `number` && `
|
|
35
36
|
w-12
|
|
36
37
|
placeholder:text-transparent
|
|
37
38
|
appearance-none
|
|
38
39
|
pr-0
|
|
39
40
|
`,
|
|
40
|
-
|
|
41
|
+
border && `
|
|
41
42
|
border
|
|
42
43
|
border-neutral-500
|
|
43
44
|
focus:border-accent-500
|
|
44
45
|
disabled:border-neutral-400
|
|
45
46
|
dark:disabled:border-neutral-600
|
|
46
47
|
`,
|
|
47
|
-
|
|
48
|
+
!valid && `
|
|
48
49
|
placeholder:text-danger-700
|
|
49
50
|
border-danger-700
|
|
50
51
|
focus:border-danger-700
|
|
51
|
-
outlined:!
|
|
52
|
+
outlined:!outline-danger-700
|
|
52
53
|
text-danger-800
|
|
53
54
|
dark:text-danger-400
|
|
54
55
|
dark:placeholder:text-danger-700
|
|
55
56
|
dark:border-danger-600
|
|
56
57
|
`,
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
$attrs?.class
|
|
59
|
+
)"
|
|
59
60
|
:data-border="border"
|
|
60
61
|
:data-invalid="!valid"
|
|
61
62
|
:type="type"
|
|
@@ -63,86 +64,54 @@
|
|
|
63
64
|
:disabled="disabled"
|
|
64
65
|
:readonly="readonly"
|
|
65
66
|
v-model="modelValue"
|
|
66
|
-
v-bind="{...$attrs, class:
|
|
67
|
+
v-bind="{ ...$attrs, class: void 0, ...ariaLabel }"
|
|
67
68
|
@keydown="handleKeydown"
|
|
68
|
-
@input="emit('input', $event
|
|
69
|
+
@input="emit('input', $event)"
|
|
69
70
|
>
|
|
70
71
|
</template>
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
|
|
80
|
-
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
81
|
-
import { hasModifiers } from "../../helpers/hasModifiers.js"
|
|
82
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
83
|
-
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
<script setup>
|
|
74
|
+
import { useAttrs } from "vue";
|
|
75
|
+
import { useAriaLabel } from "../../composables/useAriaLabel.js";
|
|
76
|
+
import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js";
|
|
77
|
+
import { hasModifiers } from "../../helpers/hasModifiers.js";
|
|
78
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
79
|
+
import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
|
|
86
80
|
defineOptions({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
function handleKeydown(e
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
81
|
+
name: "lib-simple-input",
|
|
82
|
+
inheritAttrs: false
|
|
83
|
+
});
|
|
84
|
+
const fallbackId = getFallbackId();
|
|
85
|
+
const props = defineProps(/* @__PURE__ */ _mergeDefaults({
|
|
86
|
+
id: { type: String, required: false },
|
|
87
|
+
label: { type: String, required: false },
|
|
88
|
+
disabled: { type: Boolean, required: false },
|
|
89
|
+
readonly: { type: Boolean, required: false },
|
|
90
|
+
border: { type: Boolean, required: false },
|
|
91
|
+
unstyle: { type: Boolean, required: false },
|
|
92
|
+
placeholder: { type: null, required: false },
|
|
93
|
+
type: { type: null, required: false },
|
|
94
|
+
valid: { type: Boolean, required: false }
|
|
95
|
+
}, {
|
|
96
|
+
id: "",
|
|
97
|
+
placeholder: "",
|
|
98
|
+
valid: true,
|
|
99
|
+
label: "",
|
|
100
|
+
type: void 0,
|
|
101
|
+
...baseInteractivePropsDefaults
|
|
102
|
+
}));
|
|
103
|
+
const modelValue = defineModel({ type: null, ...{ required: true } });
|
|
104
|
+
const emit = defineEmits(["submit", "input"]);
|
|
105
|
+
const $attrs = useAttrs();
|
|
106
|
+
const ariaLabel = useAriaLabel(props, fallbackId);
|
|
107
|
+
function handleKeydown(e) {
|
|
108
|
+
if (e.key === "Enter" && !hasModifiers(e)) {
|
|
109
|
+
emit("submit", modelValue.value);
|
|
110
|
+
}
|
|
117
111
|
}
|
|
118
|
-
|
|
112
|
+
usePreHydrationValue(props.id ?? fallbackId, modelValue);
|
|
119
113
|
</script>
|
|
120
114
|
|
|
121
|
-
<script
|
|
122
|
-
|
|
123
|
-
type RealProps =
|
|
124
|
-
& LinkableByIdProps
|
|
125
|
-
& LabelProps
|
|
126
|
-
& BaseInteractiveProps
|
|
127
|
-
& {
|
|
128
|
-
placeholder?: InputHTMLAttributes["placeholder"]
|
|
129
|
-
disabled?: InputHTMLAttributes["disabled"]
|
|
130
|
-
id?: InputHTMLAttributes["id"]
|
|
131
|
-
type?: InputHTMLAttributes["type"]
|
|
132
|
-
valid?: boolean
|
|
133
|
-
}
|
|
115
|
+
<script>
|
|
134
116
|
|
|
135
|
-
interface Props
|
|
136
|
-
extends
|
|
137
|
-
/** @vue-ignore */
|
|
138
|
-
Partial<Omit<
|
|
139
|
-
InputHTMLAttributes,
|
|
140
|
-
| "class"
|
|
141
|
-
| "readonly"
|
|
142
|
-
| "disabled"
|
|
143
|
-
| "onSubmit"
|
|
144
|
-
| "onInput"
|
|
145
|
-
> & TailwindClassProp>,
|
|
146
|
-
RealProps
|
|
147
|
-
{}
|
|
148
117
|
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "vue";
|
|
2
|
+
import { type BaseInteractiveProps, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
type RealProps = LinkableByIdProps & LabelProps & BaseInteractiveProps & {
|
|
4
|
+
placeholder?: InputHTMLAttributes["placeholder"];
|
|
5
|
+
disabled?: InputHTMLAttributes["disabled"];
|
|
6
|
+
id?: InputHTMLAttributes["id"];
|
|
7
|
+
type?: InputHTMLAttributes["type"];
|
|
8
|
+
valid?: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface Props extends
|
|
11
|
+
/** @vue-ignore */
|
|
12
|
+
Partial<Omit<InputHTMLAttributes, "class" | "readonly" | "disabled" | "onSubmit" | "onInput"> & TailwindClassProp>, RealProps {
|
|
13
|
+
}
|
|
14
|
+
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
15
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
16
|
+
readonly onInput?: ((val: InputEvent) => any) | undefined;
|
|
17
|
+
readonly onSubmit?: ((val: T) => any) | undefined;
|
|
18
|
+
readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
|
|
19
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onInput" | "onSubmit" | "onUpdate:modelValue"> & (Props & {
|
|
20
|
+
modelValue: T;
|
|
21
|
+
}) & Partial<{}>> & import("vue").PublicProps;
|
|
22
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
23
|
+
attrs: any;
|
|
24
|
+
slots: {};
|
|
25
|
+
emit: {
|
|
26
|
+
(e: "submit", val: T): void;
|
|
27
|
+
(e: "input", val: InputEvent): void;
|
|
28
|
+
} & ((evt: "update:modelValue", value: T) => void);
|
|
29
|
+
}>) => import("vue").VNode & {
|
|
30
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
31
|
+
};
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_PrettifyLocal<T> = {
|
|
34
|
+
[K in keyof T as K]: T[K];
|
|
35
|
+
} & {};
|
|
@@ -1,198 +1,181 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
v-if="
|
|
3
|
+
v-if="$open"
|
|
4
4
|
:id="`suggestions-${id ?? fallbackId}`"
|
|
5
|
-
:class="twMerge(
|
|
5
|
+
:class="twMerge(
|
|
6
|
+
`
|
|
6
7
|
suggestions
|
|
7
8
|
bg-bg
|
|
8
9
|
dark:bg-fg
|
|
10
|
+
dark:text-bg
|
|
9
11
|
`,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:data-open="
|
|
12
|
+
$.attrs?.class
|
|
13
|
+
)"
|
|
14
|
+
:data-open="$open"
|
|
13
15
|
role="listbox"
|
|
14
16
|
ref="el"
|
|
15
|
-
v-bind="{...$.attrs, class:
|
|
17
|
+
v-bind="{ ...$.attrs, class: void 0 }"
|
|
16
18
|
>
|
|
17
19
|
<!-- Click event is just in case, it should not really be triggered. We can do click selections via the blur handler. -->
|
|
18
20
|
<div :id="`suggestion-${id ?? fallbackId}-${index}`"
|
|
19
21
|
role="option"
|
|
20
|
-
:class="twMerge(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
:class="twMerge(
|
|
23
|
+
`
|
|
24
|
+
suggestions--item
|
|
25
|
+
user-select-none
|
|
26
|
+
cursor-pointer
|
|
27
|
+
px-2
|
|
28
|
+
`,
|
|
29
|
+
index === suggestions.active && `
|
|
30
|
+
bg-accent-200
|
|
31
|
+
dark:bg-accent-800/70
|
|
32
|
+
`,
|
|
33
|
+
$.itemAttrs?.class
|
|
34
|
+
)"
|
|
35
|
+
v-bind="{ ...$.itemAttrs, class: void 0 }"
|
|
30
36
|
:aria-selected="index === suggestions.active ? true : false"
|
|
31
37
|
:aria-label="suggestions.getLabel(item)"
|
|
32
38
|
v-for="(item, index) in suggestions.filtered"
|
|
33
39
|
:key="item"
|
|
34
40
|
@mouseover="suggestions.active = index"
|
|
35
41
|
@mousedown.prevent
|
|
36
|
-
@mouseup="suggestions.
|
|
42
|
+
@mouseup="suggestions.enterIndex(index, !Array.isArray($modelValue))"
|
|
37
43
|
>
|
|
38
|
-
<slot name="item"
|
|
39
|
-
|
|
44
|
+
<slot name="item"
|
|
45
|
+
:item="item"
|
|
46
|
+
:index="index"
|
|
47
|
+
:is-selected="Array.isArray($modelValue) ? $modelValue.includes(item) : $modelValue === item"
|
|
48
|
+
>
|
|
49
|
+
<div class="flex gap-2 nowrap">
|
|
50
|
+
<lib-checkbox
|
|
51
|
+
v-if="Array.isArray($modelValue) && showSelectedValues"
|
|
52
|
+
:model-value="$modelValue.includes(item)"
|
|
53
|
+
@mousedown.prevent
|
|
54
|
+
/>
|
|
55
|
+
<div> {{ item }} </div>
|
|
56
|
+
</div>
|
|
40
57
|
</slot>
|
|
41
58
|
</div>
|
|
42
59
|
</div>
|
|
43
60
|
</template>
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import {
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
import
|
|
52
|
-
import {
|
|
53
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
54
|
-
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type MultiValueProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
|
|
55
|
-
|
|
62
|
+
<script setup>
|
|
63
|
+
import { reactive, ref } from "vue";
|
|
64
|
+
import { useDivideAttrs } from "../../composables/useDivideAttrs.js";
|
|
65
|
+
import { useSuggestions } from "../../composables/useSuggestions.js";
|
|
66
|
+
import { hasModifiers } from "../../helpers/hasModifiers.js";
|
|
67
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
68
|
+
import LibCheckbox from "../LibCheckbox/LibCheckbox.vue";
|
|
69
|
+
import { baseInteractivePropsDefaults, getFallbackId } from "../shared/props.js";
|
|
56
70
|
defineOptions({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
name: "lib-suggestions",
|
|
72
|
+
inheritAttrs: false
|
|
73
|
+
});
|
|
74
|
+
const $ = useDivideAttrs(["item"]);
|
|
75
|
+
const emits = defineEmits(["submit", "update:isOpen", "update:activeSuggestion"]);
|
|
76
|
+
const fallbackId = getFallbackId();
|
|
77
|
+
const props = defineProps(/* @__PURE__ */ _mergeDefaults({
|
|
78
|
+
id: { type: String, required: false },
|
|
79
|
+
label: { type: String, required: false },
|
|
80
|
+
disabled: { type: Boolean, required: false },
|
|
81
|
+
readonly: { type: Boolean, required: false },
|
|
82
|
+
border: { type: Boolean, required: false },
|
|
83
|
+
unstyle: { type: Boolean, required: false },
|
|
84
|
+
filterKeydown: { type: Function, required: false },
|
|
85
|
+
filterBlur: { type: Function, required: false },
|
|
86
|
+
filterFocus: { type: Function, required: false },
|
|
87
|
+
suggestions: { type: Array, required: false },
|
|
88
|
+
suggestionLabel: { type: Function, required: false },
|
|
89
|
+
restrictToSuggestions: { type: Boolean, required: false },
|
|
90
|
+
updateOnlyOnSubmit: { type: Boolean, required: false },
|
|
91
|
+
suggestionsFilter: { type: Function, required: false },
|
|
92
|
+
allowOpenEmpty: { type: Boolean, required: false },
|
|
93
|
+
canOpen: { type: Boolean, required: false },
|
|
94
|
+
canClose: { type: Boolean, required: false },
|
|
95
|
+
isValid: { type: Boolean, required: false },
|
|
96
|
+
suggestionSelector: { type: Function, required: false },
|
|
97
|
+
showSelectedValues: { type: Boolean, required: false }
|
|
98
|
+
}, {
|
|
99
|
+
isValid: true,
|
|
100
|
+
canOpen: true,
|
|
101
|
+
filterKeydown: void 0,
|
|
102
|
+
...baseInteractivePropsDefaults
|
|
103
|
+
}));
|
|
104
|
+
const $modelValue = defineModel("modelValue", { type: null, ...{ required: true } });
|
|
105
|
+
const $inputValue = defineModel("inputValue", { type: String, ...{ default: "" } });
|
|
106
|
+
const $open = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
89
107
|
if (typeof props.suggestions?.[0] === "object" && !props.suggestionLabel && !props.suggestionsFilter) {
|
|
90
|
-
|
|
108
|
+
throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.");
|
|
91
109
|
}
|
|
92
|
-
|
|
93
|
-
const el = ref<HTMLElement | null>(null)
|
|
94
|
-
const mousedown = ref(false)
|
|
95
|
-
|
|
110
|
+
const el = ref(null);
|
|
96
111
|
const suggestions = reactive(useSuggestions(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const inputKeydownHandler = (e
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
const inputBlurHandler = (e
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
const inputFocusHandler = (e
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
112
|
+
$inputValue,
|
|
113
|
+
$modelValue,
|
|
114
|
+
$open,
|
|
115
|
+
emits,
|
|
116
|
+
props
|
|
117
|
+
));
|
|
118
|
+
const inputKeydownHandler = (e) => {
|
|
119
|
+
if (props.filterKeydown?.(e)) return;
|
|
120
|
+
if (hasModifiers(e)) return;
|
|
121
|
+
if (e.key === "Enter") {
|
|
122
|
+
suggestions.enterSelected(!Array.isArray($modelValue));
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
} else if (e.key === "Escape") {
|
|
125
|
+
suggestions.cancel();
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
} else if (!$open.value && ["ArrowDown", "ArrowUp", "PageUp", "PageDown"].includes(e.key) && suggestions.available) {
|
|
128
|
+
suggestions.open();
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
if (e.key === "PageUp") {
|
|
131
|
+
suggestions.first();
|
|
132
|
+
} else if (e.key === "PageDown") {
|
|
133
|
+
suggestions.last();
|
|
134
|
+
}
|
|
135
|
+
} else if (e.key === "ArrowUp") {
|
|
136
|
+
suggestions.prev();
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
} else if (e.key === "ArrowDown") {
|
|
139
|
+
suggestions.next();
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
} else if (e.key === "PageUp") {
|
|
142
|
+
suggestions.first();
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
} else if (e.key === "PageDown") {
|
|
145
|
+
suggestions.last();
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const inputBlurHandler = (e) => {
|
|
150
|
+
if (props.filterBlur?.(e)) return;
|
|
151
|
+
if (!$open.value) return;
|
|
152
|
+
if (props.restrictToSuggestions) {
|
|
153
|
+
suggestions.cancel();
|
|
154
|
+
} else {
|
|
155
|
+
if (!Array.isArray($modelValue.value)) {
|
|
156
|
+
$modelValue.value = $inputValue.value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if ($open.value) {
|
|
160
|
+
suggestions.close();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const inputFocusHandler = (e) => {
|
|
164
|
+
if (props.filterFocus?.(e)) return;
|
|
165
|
+
suggestions.open();
|
|
166
|
+
};
|
|
153
167
|
defineExpose({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
|
|
168
|
+
suggestions,
|
|
169
|
+
el,
|
|
170
|
+
/** A simple keydown handler that can be passed to an input to control the component while still focused inside it. */
|
|
171
|
+
inputKeydownHandler,
|
|
172
|
+
/** A blur handler for the input that controls the component. This also takes care of making clicking on a suggestion work, since otherwise if canOpen is set to false in the blur handler, no click event will fire. */
|
|
173
|
+
inputBlurHandler,
|
|
174
|
+
/** A focus handler for the input that controls the component. */
|
|
175
|
+
inputFocusHandler
|
|
176
|
+
});
|
|
164
177
|
</script>
|
|
165
178
|
|
|
166
|
-
<script
|
|
167
|
-
type WrapperTypes = Partial<WrapperProps<"item",HTMLAttributes, {
|
|
168
|
-
/** Tailwind classes. */
|
|
169
|
-
class?: string
|
|
170
|
-
}>>
|
|
171
|
-
|
|
172
|
-
type RealProps =
|
|
173
|
-
& LinkableByIdProps
|
|
174
|
-
& LabelProps
|
|
175
|
-
& BaseInteractiveProps
|
|
176
|
-
& MultiValueProps
|
|
177
|
-
& {
|
|
178
|
-
/** Return true to prevent the keydown event from being handled. */
|
|
179
|
-
filterKeydown?: (e: KeyboardEvent) => boolean
|
|
180
|
-
/** Return true to prevent the blur event from being handled. */
|
|
181
|
-
filterBlur?: (e: MouseEvent) => boolean
|
|
182
|
-
/** Return true to prevent the focus event from being handled. */
|
|
183
|
-
filterFocus?: (e: FocusEvent) => boolean
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
interface Props
|
|
187
|
-
extends
|
|
188
|
-
/** @vue-ignore */
|
|
189
|
-
Partial<Omit<HTMLAttributes,"class" | "onSubmit"> & {
|
|
190
|
-
/** Tailwind classes. */
|
|
191
|
-
class?: string
|
|
192
|
-
}>,
|
|
193
|
-
/** @vue-ignore */
|
|
194
|
-
WrapperTypes,
|
|
195
|
-
RealProps
|
|
196
|
-
{}
|
|
179
|
+
<script>
|
|
197
180
|
|
|
198
181
|
</script>
|