@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as components from "../index.js";
|
|
2
|
+
const meta = {
|
|
3
|
+
component: components.LibSimpleInput,
|
|
4
|
+
title: "Components/Input",
|
|
5
|
+
args: {
|
|
6
|
+
modelValue: "Value",
|
|
7
|
+
placeholder: "Placeholder"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Primary = {
|
|
12
|
+
args: {
|
|
13
|
+
modelValue: "some value"
|
|
14
|
+
},
|
|
15
|
+
render: (args) => ({
|
|
16
|
+
components,
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
setup: () => ({ args, test: () => console.log("Enter") }),
|
|
19
|
+
template: `
|
|
20
|
+
<lib-simple-input
|
|
21
|
+
@keydown="test"
|
|
22
|
+
class="m-2" v-bind="args" v-model="args.modelValue" ></lib-simple-input>
|
|
23
|
+
<lib-simple-input class="m-2" v-bind="{...args, modelValue:''}" ></lib-simple-input>
|
|
24
|
+
`
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
export const InsideAFlexbox = {
|
|
28
|
+
render: (args) => ({
|
|
29
|
+
components,
|
|
30
|
+
setup: () => ({ args }),
|
|
31
|
+
template: `
|
|
32
|
+
Inside a flexbox:
|
|
33
|
+
<div class="flex flex-wrap">
|
|
34
|
+
<lib-simple-input v-bind="args" v-model="args.modelValue"></lib-simple-input>
|
|
35
|
+
<div class="border-1 border-danger-500 flex-1 whitespace-nowrap">Flex Grow: 1</div>
|
|
36
|
+
</div>
|
|
37
|
+
`
|
|
38
|
+
}),
|
|
39
|
+
args: {
|
|
40
|
+
stretch: true
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export const Disabled = {
|
|
44
|
+
...Primary,
|
|
45
|
+
args: {
|
|
46
|
+
disabled: true
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export const Readonly = {
|
|
50
|
+
...Primary,
|
|
51
|
+
args: {
|
|
52
|
+
readonly: true
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export const Invalid = {
|
|
56
|
+
...Primary,
|
|
57
|
+
args: {
|
|
58
|
+
valid: false
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const Borderless = {
|
|
62
|
+
...Primary,
|
|
63
|
+
args: {
|
|
64
|
+
border: false
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export const Numerical = {
|
|
68
|
+
...Primary,
|
|
69
|
+
args: {
|
|
70
|
+
type: "number"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
export const NumericalInsideAFlexbox = {
|
|
74
|
+
...InsideAFlexbox,
|
|
75
|
+
args: {
|
|
76
|
+
type: "number"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
:id="id ?? fallbackId"
|
|
4
|
-
:class="twMerge(
|
|
5
|
-
`
|
|
4
|
+
:class="twMerge(`
|
|
6
5
|
simple-input
|
|
7
6
|
flex-1
|
|
8
7
|
grow-[999999]
|
|
@@ -28,24 +27,24 @@
|
|
|
28
27
|
dark:disabled:bg-neutral-950
|
|
29
28
|
dark:disabled:text-neutral-500
|
|
30
29
|
`,
|
|
31
|
-
|
|
30
|
+
type === `text` && `
|
|
32
31
|
min-w-[10ch]
|
|
33
32
|
w-full
|
|
34
33
|
`,
|
|
35
|
-
|
|
34
|
+
type === `number` && `
|
|
36
35
|
w-12
|
|
37
36
|
placeholder:text-transparent
|
|
38
37
|
appearance-none
|
|
39
38
|
pr-0
|
|
40
39
|
`,
|
|
41
|
-
|
|
40
|
+
border && `
|
|
42
41
|
border
|
|
43
42
|
border-neutral-500
|
|
44
43
|
focus:border-accent-500
|
|
45
44
|
disabled:border-neutral-400
|
|
46
45
|
dark:disabled:border-neutral-600
|
|
47
46
|
`,
|
|
48
|
-
|
|
47
|
+
!valid && `
|
|
49
48
|
placeholder:text-danger-700
|
|
50
49
|
border-danger-700
|
|
51
50
|
focus:border-danger-700
|
|
@@ -55,8 +54,8 @@
|
|
|
55
54
|
dark:placeholder:text-danger-700
|
|
56
55
|
dark:border-danger-600
|
|
57
56
|
`,
|
|
58
|
-
|
|
59
|
-
)"
|
|
57
|
+
($attrs as any)?.class
|
|
58
|
+
)"
|
|
60
59
|
:data-border="border"
|
|
61
60
|
:data-invalid="!valid"
|
|
62
61
|
:type="type"
|
|
@@ -64,54 +63,83 @@
|
|
|
64
63
|
:disabled="disabled"
|
|
65
64
|
:readonly="readonly"
|
|
66
65
|
v-model="modelValue"
|
|
67
|
-
v-bind="{
|
|
66
|
+
v-bind="{...$attrs, class:undefined, ...ariaLabel}"
|
|
68
67
|
@keydown="handleKeydown"
|
|
69
|
-
@input="emit('input', $event)"
|
|
68
|
+
@input="emit('input', $event as InputEvent)"
|
|
70
69
|
>
|
|
71
70
|
</template>
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
72
|
+
|
|
73
|
+
<script lang="ts" setup generic="T">
|
|
74
|
+
import { type InputHTMLAttributes, useAttrs } from "vue"
|
|
75
|
+
|
|
76
|
+
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
77
|
+
import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js"
|
|
78
|
+
import { hasModifiers } from "../../helpers/hasModifiers.js"
|
|
79
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
80
|
+
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
81
|
+
|
|
82
|
+
|
|
80
83
|
defineOptions({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
84
|
+
name: "lib-simple-input",
|
|
85
|
+
inheritAttrs: false,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const fallbackId = getFallbackId()
|
|
89
|
+
|
|
90
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
91
|
+
id: "",
|
|
92
|
+
placeholder: "",
|
|
93
|
+
valid: true,
|
|
94
|
+
label: "",
|
|
95
|
+
type: undefined,
|
|
96
|
+
...baseInteractivePropsDefaults
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const modelValue = defineModel<T>({ required: true })
|
|
100
|
+
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
/* User presses enter.*/
|
|
103
|
+
(e: "submit", val: T): void
|
|
104
|
+
(e: "input", val: InputEvent): void
|
|
105
|
+
}>()
|
|
106
|
+
const $attrs = useAttrs()
|
|
107
|
+
const ariaLabel = useAriaLabel(props, fallbackId)
|
|
108
|
+
|
|
109
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
110
|
+
if (e.key === "Enter" && !hasModifiers(e)) {
|
|
111
|
+
emit("submit", modelValue.value)
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
|
-
usePreHydrationValue(props.id ?? fallbackId, modelValue)
|
|
114
|
+
usePreHydrationValue(props.id ?? fallbackId, modelValue)
|
|
115
|
+
|
|
113
116
|
</script>
|
|
114
117
|
|
|
115
|
-
<script>
|
|
118
|
+
<script lang="ts">
|
|
119
|
+
|
|
120
|
+
type RealProps =
|
|
121
|
+
& LinkableByIdProps
|
|
122
|
+
& LabelProps
|
|
123
|
+
& BaseInteractiveProps
|
|
124
|
+
& {
|
|
125
|
+
placeholder?: InputHTMLAttributes["placeholder"]
|
|
126
|
+
disabled?: InputHTMLAttributes["disabled"]
|
|
127
|
+
id?: InputHTMLAttributes["id"]
|
|
128
|
+
type?: InputHTMLAttributes["type"]
|
|
129
|
+
valid?: boolean
|
|
130
|
+
}
|
|
116
131
|
|
|
132
|
+
interface Props
|
|
133
|
+
extends
|
|
134
|
+
/** @vue-ignore */
|
|
135
|
+
Partial<Omit<
|
|
136
|
+
InputHTMLAttributes,
|
|
137
|
+
| "class"
|
|
138
|
+
| "readonly"
|
|
139
|
+
| "disabled"
|
|
140
|
+
| "onSubmit"
|
|
141
|
+
| "onInput"
|
|
142
|
+
> & TailwindClassProp>,
|
|
143
|
+
RealProps
|
|
144
|
+
{}
|
|
117
145
|
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/vue3";
|
|
2
|
+
import LibSuggestions from "./LibSuggestions.vue.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
component: any;
|
|
5
|
+
title: string;
|
|
6
|
+
args: {
|
|
7
|
+
id: string;
|
|
8
|
+
modelValue: string;
|
|
9
|
+
label: string;
|
|
10
|
+
border: boolean;
|
|
11
|
+
suggestions: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof LibSuggestions>;
|
|
16
|
+
/**
|
|
17
|
+
* The suggestions component is just the dropdown part.
|
|
18
|
+
*
|
|
19
|
+
* Here it is decoupled from the input.
|
|
20
|
+
*
|
|
21
|
+
* More examples can be found in the input component.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Primary: Story;
|
|
24
|
+
export declare const RestrictToSuggestions: Story;
|
|
25
|
+
export declare const AlwaysShowAllSuggestions: any;
|
|
26
|
+
export declare const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions: any;
|
|
27
|
+
export declare const CustomSuggestionsObject: any;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { computed, onMounted, ref } from "vue";
|
|
2
|
+
import LibSuggestions from "./LibSuggestions.vue";
|
|
3
|
+
import * as components from "../index.js";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: LibSuggestions,
|
|
6
|
+
title: "Components/Suggestions",
|
|
7
|
+
args: {
|
|
8
|
+
id: "some-id",
|
|
9
|
+
modelValue: "",
|
|
10
|
+
label: "Some Label",
|
|
11
|
+
border: true,
|
|
12
|
+
suggestions: ["A", "AB", "ABC", "B", "BC", "C", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Primary = {
|
|
17
|
+
render: (args) => ({
|
|
18
|
+
components: { ...components, LibSuggestions },
|
|
19
|
+
setup: () => {
|
|
20
|
+
const inputValue = ref(args.modelValue);
|
|
21
|
+
const modelValue = ref(args.modelValue);
|
|
22
|
+
const drawer = ref(null);
|
|
23
|
+
const keydownHandler = (e) => {
|
|
24
|
+
drawer.value?.inputKeydownHandler(e);
|
|
25
|
+
};
|
|
26
|
+
const suggestions = computed(() => drawer.value?.suggestions);
|
|
27
|
+
const blurHandler = (e) => {
|
|
28
|
+
drawer.value?.inputBlurHandler(e);
|
|
29
|
+
};
|
|
30
|
+
onMounted(() => {
|
|
31
|
+
drawer.value?.suggestions.open();
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
args,
|
|
35
|
+
inputValue,
|
|
36
|
+
modelValue,
|
|
37
|
+
isOpen: ref(false),
|
|
38
|
+
suggestions,
|
|
39
|
+
drawer,
|
|
40
|
+
keydownHandler,
|
|
41
|
+
blurHandler
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
template: `
|
|
45
|
+
<div class="flex flex-col gap-3">
|
|
46
|
+
Temporary Value: {{inputValue}}
|
|
47
|
+
<br/>
|
|
48
|
+
Model Value (Final Value): <span class="inline-block" data-testid="model-value">{{modelValue}}</span>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<br/>
|
|
52
|
+
Selected: {{suggestions?.filtered[suggestions.active]}}
|
|
53
|
+
<label>Some Label</label>
|
|
54
|
+
<lib-simple-input
|
|
55
|
+
:class="isOpen ? 'open' : ''"
|
|
56
|
+
v-model="inputValue"
|
|
57
|
+
@focus="suggestions.open()"
|
|
58
|
+
@blur="blurHandler"
|
|
59
|
+
@keydown="keydownHandler"
|
|
60
|
+
></lib-simple-input>
|
|
61
|
+
<lib-suggestions
|
|
62
|
+
ref="drawer"
|
|
63
|
+
v-bind="{...args}"
|
|
64
|
+
@update:isOpen="isOpen = $event"
|
|
65
|
+
v-model="modelValue"
|
|
66
|
+
v-model:inputValue="inputValue"
|
|
67
|
+
>
|
|
68
|
+
<template #item={item}>
|
|
69
|
+
{{item}}
|
|
70
|
+
</template>
|
|
71
|
+
</lib-suggestions>
|
|
72
|
+
</div>
|
|
73
|
+
`
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
export const RestrictToSuggestions = {
|
|
77
|
+
...Primary,
|
|
78
|
+
args: {
|
|
79
|
+
...Primary.args,
|
|
80
|
+
restrictToSuggestions: true
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export const AlwaysShowAllSuggestions = {
|
|
84
|
+
...Primary,
|
|
85
|
+
args: {
|
|
86
|
+
...Primary.args,
|
|
87
|
+
restrictToSuggestions: true,
|
|
88
|
+
suggestionsFilter: (_input, items) => items
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions = {
|
|
92
|
+
...Primary,
|
|
93
|
+
args: {
|
|
94
|
+
...Primary.args,
|
|
95
|
+
restrictToSuggestions: false,
|
|
96
|
+
suggestionsFilter: (_input, items) => items
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export const CustomSuggestionsObject = {
|
|
100
|
+
...Primary,
|
|
101
|
+
args: {
|
|
102
|
+
...Primary.args,
|
|
103
|
+
restrictToSuggestions: true,
|
|
104
|
+
suggestions: [
|
|
105
|
+
{ label: "A", other: "some data A" },
|
|
106
|
+
{ label: "AB", other: "some data AB" },
|
|
107
|
+
{ label: "ABC", other: "some data ABC" },
|
|
108
|
+
{ label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
|
|
109
|
+
],
|
|
110
|
+
suggestionLabel: (item) => item.label
|
|
111
|
+
}
|
|
112
|
+
};
|