@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
|
@@ -2,37 +2,35 @@
|
|
|
2
2
|
<div
|
|
3
3
|
v-if="$open"
|
|
4
4
|
:id="`suggestions-${id ?? fallbackId}`"
|
|
5
|
-
:class="twMerge(
|
|
6
|
-
`
|
|
5
|
+
:class="twMerge(`
|
|
7
6
|
suggestions
|
|
8
7
|
bg-bg
|
|
9
8
|
dark:bg-fg
|
|
10
9
|
dark:text-bg
|
|
11
10
|
`,
|
|
12
|
-
|
|
13
|
-
)"
|
|
11
|
+
($.attrs as any)?.class
|
|
12
|
+
)"
|
|
14
13
|
:data-open="$open"
|
|
15
14
|
role="listbox"
|
|
16
15
|
ref="el"
|
|
17
|
-
v-bind="{
|
|
16
|
+
v-bind="{...$.attrs, class:undefined}"
|
|
18
17
|
>
|
|
19
18
|
<!-- Click event is just in case, it should not really be triggered. We can do click selections via the blur handler. -->
|
|
20
19
|
<div :id="`suggestion-${id ?? fallbackId}-${index}`"
|
|
21
20
|
role="option"
|
|
22
|
-
:class="twMerge(
|
|
23
|
-
`
|
|
21
|
+
:class="twMerge(`
|
|
24
22
|
suggestions--item
|
|
25
23
|
user-select-none
|
|
26
24
|
cursor-pointer
|
|
27
25
|
px-2
|
|
28
26
|
`,
|
|
29
|
-
|
|
27
|
+
index=== suggestions.active && `
|
|
30
28
|
bg-accent-200
|
|
31
29
|
dark:bg-accent-800/70
|
|
32
30
|
`,
|
|
33
|
-
|
|
34
|
-
)"
|
|
35
|
-
v-bind="{
|
|
31
|
+
($.itemAttrs as any)?.class
|
|
32
|
+
)"
|
|
33
|
+
v-bind="{...$.itemAttrs, class:undefined}"
|
|
36
34
|
:aria-selected="index === suggestions.active ? true : false"
|
|
37
35
|
:aria-label="suggestions.getLabel(item)"
|
|
38
36
|
v-for="(item, index) in suggestions.filtered"
|
|
@@ -59,123 +57,158 @@
|
|
|
59
57
|
</div>
|
|
60
58
|
</template>
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
import {
|
|
66
|
-
|
|
67
|
-
import {
|
|
68
|
-
import
|
|
69
|
-
import {
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts" generic="TSuggestion extends string | object, TValue extends string|string[]">
|
|
62
|
+
|
|
63
|
+
import { type HTMLAttributes,reactive, ref } from "vue"
|
|
64
|
+
|
|
65
|
+
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
66
|
+
import { useSuggestions } from "../../composables/useSuggestions.js"
|
|
67
|
+
import { hasModifiers } from "../../helpers/hasModifiers.js"
|
|
68
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
69
|
+
import LibCheckbox from "../LibCheckbox/LibCheckbox.vue"
|
|
70
|
+
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
|
|
71
|
+
|
|
70
72
|
defineOptions({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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 } });
|
|
73
|
+
name: "lib-suggestions",
|
|
74
|
+
inheritAttrs: false,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const $ = useDivideAttrs(["item"] as const)
|
|
78
|
+
|
|
79
|
+
const emits = defineEmits<SuggestionsEmits>()
|
|
80
|
+
|
|
81
|
+
const fallbackId = getFallbackId()
|
|
82
|
+
const props = withDefaults(defineProps<Props & SuggestionsProps<TSuggestion>>(), {
|
|
83
|
+
isValid: true,
|
|
84
|
+
canOpen: true,
|
|
85
|
+
filterKeydown: undefined,
|
|
86
|
+
...baseInteractivePropsDefaults
|
|
87
|
+
})
|
|
88
|
+
/**
|
|
89
|
+
* The final valid value. This is *not* the value you want to share with the input. If `restrictToSuggestions` is true this will not update on any invalid values that `inputValue` might be set to.
|
|
90
|
+
*
|
|
91
|
+
* If suggestions are objects, this will be the string returned by the `suggestionLabel` prop.
|
|
92
|
+
*/
|
|
93
|
+
const $modelValue = defineModel<TValue>("modelValue", { required: true })
|
|
94
|
+
/**
|
|
95
|
+
* If the element is bound to an input, this is the value that the input should be sharing.
|
|
96
|
+
*
|
|
97
|
+
* It allows the component to read even invalid output, and also to reset that invalid output when either modelValue is set to a new value, or when the component is closed via cancel.
|
|
98
|
+
*/
|
|
99
|
+
const $inputValue = defineModel<string >("inputValue", { default: "" })
|
|
100
|
+
|
|
101
|
+
const $open = defineModel<boolean>("open", { default: false })
|
|
102
|
+
|
|
103
|
+
|
|
107
104
|
if (typeof props.suggestions?.[0] === "object" && !props.suggestionLabel && !props.suggestionsFilter) {
|
|
108
|
-
|
|
105
|
+
throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.")
|
|
109
106
|
}
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
107
|
+
|
|
108
|
+
const el = ref<HTMLElement | null>(null)
|
|
109
|
+
|
|
110
|
+
const suggestions = reactive(useSuggestions<TSuggestion, TValue extends string[] ? true : false>(
|
|
111
|
+
$inputValue,
|
|
112
|
+
$modelValue as any,
|
|
113
|
+
$open,
|
|
114
|
+
emits,
|
|
115
|
+
props
|
|
116
|
+
))
|
|
117
|
+
|
|
118
|
+
const inputKeydownHandler = (e: KeyboardEvent): void => {
|
|
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: MouseEvent): void => {
|
|
150
|
+
if (props.filterBlur?.(e)) return
|
|
151
|
+
|
|
152
|
+
if (!$open.value) return
|
|
153
|
+
|
|
154
|
+
if (props.restrictToSuggestions) {
|
|
155
|
+
suggestions.cancel()
|
|
156
|
+
} else {
|
|
157
|
+
if (!Array.isArray($modelValue.value)) {
|
|
158
|
+
$modelValue.value = $inputValue.value as any
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if ($open.value) {
|
|
162
|
+
suggestions.close()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const inputFocusHandler = (e: FocusEvent): void => {
|
|
166
|
+
if (props.filterFocus?.(e)) return
|
|
167
|
+
suggestions.open()
|
|
168
|
+
}
|
|
169
|
+
|
|
167
170
|
defineExpose({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
})
|
|
171
|
+
suggestions,
|
|
172
|
+
el,
|
|
173
|
+
/** A simple keydown handler that can be passed to an input to control the component while still focused inside it. */
|
|
174
|
+
inputKeydownHandler,
|
|
175
|
+
/** 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. */
|
|
176
|
+
inputBlurHandler,
|
|
177
|
+
/** A focus handler for the input that controls the component. */
|
|
178
|
+
inputFocusHandler,
|
|
179
|
+
})
|
|
180
|
+
|
|
177
181
|
</script>
|
|
178
182
|
|
|
179
|
-
<script>
|
|
183
|
+
<script lang="ts">
|
|
184
|
+
type WrapperTypes = Partial<WrapperProps<"item",HTMLAttributes, {
|
|
185
|
+
/** Tailwind classes. */
|
|
186
|
+
class?: string
|
|
187
|
+
}>>
|
|
188
|
+
|
|
189
|
+
type RealProps =
|
|
190
|
+
& LinkableByIdProps
|
|
191
|
+
& LabelProps
|
|
192
|
+
& BaseInteractiveProps
|
|
193
|
+
& {
|
|
194
|
+
/** Return true to prevent the keydown event from being handled. */
|
|
195
|
+
filterKeydown?: (e: KeyboardEvent) => boolean
|
|
196
|
+
/** Return true to prevent the blur event from being handled. */
|
|
197
|
+
filterBlur?: (e: MouseEvent) => boolean
|
|
198
|
+
/** Return true to prevent the focus event from being handled. */
|
|
199
|
+
filterFocus?: (e: FocusEvent) => boolean
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
interface Props
|
|
203
|
+
extends
|
|
204
|
+
/** @vue-ignore */
|
|
205
|
+
Partial<Omit<HTMLAttributes,"class" | "onSubmit"> & {
|
|
206
|
+
/** Tailwind classes. */
|
|
207
|
+
class?: string
|
|
208
|
+
}>,
|
|
209
|
+
/** @vue-ignore */
|
|
210
|
+
WrapperTypes,
|
|
211
|
+
RealProps
|
|
212
|
+
{}
|
|
180
213
|
|
|
181
214
|
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3";
|
|
2
|
+
import LibTable from "./LibTable.vue.js";
|
|
3
|
+
declare const meta: Meta<typeof LibTable>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof LibTable>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const NoCellBorders: Story;
|
|
8
|
+
export declare const NoBorders: Story;
|
|
9
|
+
export declare const NoCellBordersNoBorders: Story;
|
|
10
|
+
export declare const SquareBorders: Story;
|
|
11
|
+
export declare const NoHeader: Story;
|
|
12
|
+
export declare const NoHeaderNoBorders: Story;
|
|
13
|
+
export declare const NoHeaderNoCellBorders: Story;
|
|
14
|
+
export declare const FitWidthFalse: Story;
|
|
15
|
+
export declare const ThreeColSomeColsNotResizable: Story;
|
|
16
|
+
export declare const FourColSomeColsNotResizable: Story;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import LibTable from "./LibTable.vue";
|
|
2
|
+
import * as components from "../index.js";
|
|
3
|
+
const meta = {
|
|
4
|
+
component: LibTable,
|
|
5
|
+
title: "Components/Table"
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export const Primary = {
|
|
9
|
+
render: (args) => ({
|
|
10
|
+
components,
|
|
11
|
+
setup: () => ({ args }),
|
|
12
|
+
template: `
|
|
13
|
+
<div class="overflow-x-scroll scrollbar-hidden">
|
|
14
|
+
<lib-table
|
|
15
|
+
v-bind="args"
|
|
16
|
+
>
|
|
17
|
+
</lib-table>
|
|
18
|
+
</div>
|
|
19
|
+
`
|
|
20
|
+
}),
|
|
21
|
+
args: {
|
|
22
|
+
cols: ["prop1", "prop2", "prop3"],
|
|
23
|
+
values: [
|
|
24
|
+
{ prop1: "Item1 Prop 1", prop2: "Item1 Prop 2", prop3: "Item1 Prop 3" },
|
|
25
|
+
{ prop1: "Item2 Prop 1", prop2: "Item2 Prop 2", prop3: "Item2 Prop 3" },
|
|
26
|
+
{ prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" }
|
|
27
|
+
],
|
|
28
|
+
colConfig: { prop1: { name: "Header 1" }, prop2: { name: "Header 2" } },
|
|
29
|
+
itemKey: "prop1"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const NoCellBorders = {
|
|
33
|
+
...Primary,
|
|
34
|
+
args: {
|
|
35
|
+
...Primary.args,
|
|
36
|
+
cellBorder: false
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const NoBorders = {
|
|
40
|
+
...Primary,
|
|
41
|
+
args: {
|
|
42
|
+
...Primary.args,
|
|
43
|
+
border: false
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const NoCellBordersNoBorders = {
|
|
47
|
+
...Primary,
|
|
48
|
+
args: {
|
|
49
|
+
...Primary.args,
|
|
50
|
+
cellBorder: false,
|
|
51
|
+
border: false
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export const SquareBorders = {
|
|
55
|
+
...Primary,
|
|
56
|
+
args: {
|
|
57
|
+
...Primary.args,
|
|
58
|
+
rounded: false
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const NoHeader = {
|
|
62
|
+
...Primary,
|
|
63
|
+
args: {
|
|
64
|
+
...Primary.args,
|
|
65
|
+
header: false
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const NoHeaderNoBorders = {
|
|
69
|
+
...Primary,
|
|
70
|
+
args: {
|
|
71
|
+
...Primary.args,
|
|
72
|
+
header: false,
|
|
73
|
+
border: false
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export const NoHeaderNoCellBorders = {
|
|
77
|
+
...Primary,
|
|
78
|
+
args: {
|
|
79
|
+
...Primary.args,
|
|
80
|
+
header: false,
|
|
81
|
+
cellBorder: false
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export const FitWidthFalse = {
|
|
85
|
+
...Primary,
|
|
86
|
+
args: {
|
|
87
|
+
...Primary.args,
|
|
88
|
+
resizable: {
|
|
89
|
+
fitWidth: false
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export const ThreeColSomeColsNotResizable = {
|
|
94
|
+
render: (args) => ({
|
|
95
|
+
components,
|
|
96
|
+
setup: () => ({ args }),
|
|
97
|
+
template: `
|
|
98
|
+
<lib-table
|
|
99
|
+
v-bind="args"
|
|
100
|
+
>
|
|
101
|
+
</lib-table>
|
|
102
|
+
<br>
|
|
103
|
+
<lib-table
|
|
104
|
+
v-bind="{...args, colConfig:args.colConfig2}"
|
|
105
|
+
>
|
|
106
|
+
</lib-table>
|
|
107
|
+
<br>
|
|
108
|
+
<lib-table
|
|
109
|
+
v-bind="{...args, colConfig:args.colConfig3}"
|
|
110
|
+
>
|
|
111
|
+
</lib-table>
|
|
112
|
+
`
|
|
113
|
+
}),
|
|
114
|
+
args: {
|
|
115
|
+
cols: ["prop1", "prop2", "prop3"],
|
|
116
|
+
itemKey: "prop1",
|
|
117
|
+
values: [
|
|
118
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" }
|
|
119
|
+
],
|
|
120
|
+
colConfig: { prop1: { name: "No Resize", resizable: false } },
|
|
121
|
+
colConfig2: { prop2: { name: "No Resize", resizable: false } },
|
|
122
|
+
colConfig3: { prop3: { name: "No Resize", resizable: false } }
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
export const FourColSomeColsNotResizable = {
|
|
126
|
+
render: (args) => ({
|
|
127
|
+
components,
|
|
128
|
+
setup: () => ({ args }),
|
|
129
|
+
template: `
|
|
130
|
+
<lib-table
|
|
131
|
+
v-bind="args"
|
|
132
|
+
>
|
|
133
|
+
</lib-table>
|
|
134
|
+
<br>
|
|
135
|
+
<lib-table
|
|
136
|
+
v-bind="{...args, colConfig:args.colConfig2}"
|
|
137
|
+
>
|
|
138
|
+
</lib-table>
|
|
139
|
+
<br>
|
|
140
|
+
<lib-table
|
|
141
|
+
v-bind="{...args, colConfig:args.colConfig3}"
|
|
142
|
+
>
|
|
143
|
+
</lib-table>
|
|
144
|
+
`
|
|
145
|
+
}),
|
|
146
|
+
args: {
|
|
147
|
+
cols: ["prop1", "prop2", "prop3", "prop4"],
|
|
148
|
+
values: [
|
|
149
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" }
|
|
150
|
+
],
|
|
151
|
+
itemKey: "prop1",
|
|
152
|
+
colConfig: { prop1: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
153
|
+
colConfig2: { prop2: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
154
|
+
colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } }
|
|
155
|
+
}
|
|
156
|
+
};
|