@witchcraft/ui 0.0.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 +236 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +34 -0
- package/dist/module.d.ts +34 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +124 -0
- package/dist/runtime/assets/base.css +1 -0
- package/dist/runtime/assets/locales/en.json +33 -0
- package/dist/runtime/assets/style.css +1 -0
- package/dist/runtime/assets/tailwind.css +1 -0
- package/dist/runtime/assets/theme.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.d.ts +5 -0
- package/dist/runtime/build/WitchcraftUiResolver.js +17 -0
- package/dist/runtime/build/generateTheme.d.ts +1 -0
- package/dist/runtime/build/generateTheme.js +14 -0
- package/dist/runtime/build/unpluginIconViteOptions.d.ts +2 -0
- package/dist/runtime/build/unpluginIconViteOptions.js +10 -0
- package/dist/runtime/components/Aria/Aria.vue +18 -0
- 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 +39 -0
- 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 +247 -0
- 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 +132 -0
- 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 +125 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +7 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +51 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
- 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 +95 -0
- 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 +67 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
- package/dist/runtime/components/LibDatePicker/helpers.d.ts +25 -0
- package/dist/runtime/components/LibDatePicker/helpers.js +28 -0
- 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 +91 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
- 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 +273 -0
- package/dist/runtime/components/LibInput/LibInput.stories.d.ts +33 -0
- package/dist/runtime/components/LibInput/LibInput.stories.js +339 -0
- package/dist/runtime/components/LibInput/LibInput.vue +372 -0
- 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 +66 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +23 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +60 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
- 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 +121 -0
- 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 +133 -0
- 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 +261 -0
- 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 +49 -0
- 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 +441 -0
- 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 +192 -0
- 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 +243 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +126 -0
- 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 +148 -0
- 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 +198 -0
- 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 +177 -0
- package/dist/runtime/components/Template/NAME.vue +49 -0
- package/dist/runtime/components/Template/TemplateStory.d.ts +7 -0
- package/dist/runtime/components/Template/TemplateStory.js +22 -0
- package/dist/runtime/components/TestControls/TestControls.vue +19 -0
- package/dist/runtime/components/index.d.ts +19 -0
- package/dist/runtime/components/index.js +19 -0
- package/dist/runtime/components/reset.stories.d.ts +5 -0
- package/dist/runtime/components/reset.stories.js +19 -0
- package/dist/runtime/components/shared/props.d.ts +135 -0
- package/dist/runtime/components/shared/props.js +14 -0
- package/dist/runtime/components/shared/storyHelpers/playInput.d.ts +8 -0
- package/dist/runtime/components/shared/storyHelpers/playInput.js +26 -0
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.d.ts +12 -0
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +83 -0
- package/dist/runtime/composables/index.d.ts +11 -0
- package/dist/runtime/composables/index.js +11 -0
- package/dist/runtime/composables/useAccesibilityOutline.d.ts +41 -0
- package/dist/runtime/composables/useAccesibilityOutline.js +58 -0
- package/dist/runtime/composables/useAriaLabel.d.ts +6 -0
- package/dist/runtime/composables/useAriaLabel.js +15 -0
- package/dist/runtime/composables/useDarkMode.d.ts +38 -0
- package/dist/runtime/composables/useDarkMode.js +79 -0
- package/dist/runtime/composables/useDivideAttrs.d.ts +27 -0
- package/dist/runtime/composables/useDivideAttrs.js +26 -0
- package/dist/runtime/composables/useGlobalResizeObserver.d.ts +3 -0
- package/dist/runtime/composables/useGlobalResizeObserver.js +28 -0
- package/dist/runtime/composables/useInjectedDarkMode.d.ts +2 -0
- package/dist/runtime/composables/useInjectedDarkMode.js +13 -0
- package/dist/runtime/composables/useInjectedI18n.d.ts +2 -0
- package/dist/runtime/composables/useInjectedI18n.js +7 -0
- package/dist/runtime/composables/useInjectedLocale.d.ts +2 -0
- package/dist/runtime/composables/useInjectedLocale.js +21 -0
- package/dist/runtime/composables/useNotificationHandler.d.ts +4 -0
- package/dist/runtime/composables/useNotificationHandler.js +21 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +68 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.js +116 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +7 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +85 -0
- package/dist/runtime/composables/useSetupDarkMode.d.ts +12 -0
- package/dist/runtime/composables/useSetupDarkMode.js +4 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +20 -0
- package/dist/runtime/composables/useSetupI18n.js +50 -0
- package/dist/runtime/composables/useSetupLocale.d.ts +9 -0
- package/dist/runtime/composables/useSetupLocale.js +21 -0
- package/dist/runtime/composables/useShowDevOnlyKey.d.ts +7 -0
- package/dist/runtime/composables/useShowDevOnlyKey.js +20 -0
- package/dist/runtime/composables/useSuggestions.d.ts +38 -0
- package/dist/runtime/composables/useSuggestions.js +226 -0
- package/dist/runtime/directives/index.d.ts +4 -0
- package/dist/runtime/directives/index.js +4 -0
- package/dist/runtime/directives/vDetectFlex.d.ts +2 -0
- package/dist/runtime/directives/vDetectFlex.js +109 -0
- package/dist/runtime/directives/vExtractRootEl.d.ts +22 -0
- package/dist/runtime/directives/vExtractRootEl.js +13 -0
- package/dist/runtime/directives/vResizableCols.d.ts +60 -0
- package/dist/runtime/directives/vResizableCols.js +252 -0
- package/dist/runtime/directives/vResizeObserver.d.ts +2 -0
- package/dist/runtime/directives/vResizeObserver.js +34 -0
- package/dist/runtime/globalResizeObserver.d.ts +5 -0
- package/dist/runtime/globalResizeObserver.js +5 -0
- package/dist/runtime/helpers/NotificationHandler.d.ts +48 -0
- package/dist/runtime/helpers/NotificationHandler.js +162 -0
- package/dist/runtime/helpers/addValue.d.ts +1 -0
- package/dist/runtime/helpers/addValue.js +8 -0
- package/dist/runtime/helpers/base64ToImg.d.ts +1 -0
- package/dist/runtime/helpers/base64ToImg.js +11 -0
- package/dist/runtime/helpers/copy.d.ts +1 -0
- package/dist/runtime/helpers/copy.js +10 -0
- package/dist/runtime/helpers/createNoonUtcDate.d.ts +7 -0
- package/dist/runtime/helpers/createNoonUtcDate.js +14 -0
- package/dist/runtime/helpers/defaultTranslationFunction.d.ts +16 -0
- package/dist/runtime/helpers/defaultTranslationFunction.js +14 -0
- package/dist/runtime/helpers/getTimeZoneList.d.ts +1 -0
- package/dist/runtime/helpers/getTimeZoneList.js +3 -0
- package/dist/runtime/helpers/hasModifiers.d.ts +1 -0
- package/dist/runtime/helpers/hasModifiers.js +1 -0
- package/dist/runtime/helpers/index.d.ts +8 -0
- package/dist/runtime/helpers/index.js +8 -0
- package/dist/runtime/helpers/readFile.d.ts +1 -0
- package/dist/runtime/helpers/readFile.js +13 -0
- package/dist/runtime/helpers/resizeObserverWrapper.d.ts +8 -0
- package/dist/runtime/helpers/resizeObserverWrapper.js +37 -0
- package/dist/runtime/helpers/storybook.d.ts +7 -0
- package/dist/runtime/helpers/storybook.js +42 -0
- package/dist/runtime/main.lib.d.ts +26 -0
- package/dist/runtime/main.lib.js +8 -0
- package/dist/runtime/nuxt/plugins/vue-plugin.d.ts +2 -0
- package/dist/runtime/nuxt/plugins/vue-plugin.js +12 -0
- package/dist/runtime/tailwind/index.d.ts +1 -0
- package/dist/runtime/tailwind/index.js +1 -0
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +2 -0
- package/dist/runtime/tailwind/themeConvertionOpts.js +12 -0
- package/dist/runtime/theme.d.ts +2 -0
- package/dist/runtime/theme.js +2 -0
- package/dist/runtime/types/index.d.ts +119 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/utils/twMerge.d.ts +10 -0
- package/dist/runtime/utils/twMerge.js +10 -0
- package/dist/runtime/vue/VueComponentsPlugin.d.ts +2 -0
- package/dist/runtime/vue/VueComponentsPlugin.js +10 -0
- package/dist/runtime/vue/registerComponents.d.ts +19 -0
- package/dist/runtime/vue/registerComponents.js +10 -0
- package/dist/runtime/vue/registerDirectives.d.ts +3 -0
- package/dist/runtime/vue/registerDirectives.js +9 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +207 -0
- package/src/module.ts +176 -0
- package/src/runtime/assets/base.css +67 -0
- package/src/runtime/assets/locales/en.json +33 -0
- package/src/runtime/assets/style.css +144 -0
- package/src/runtime/assets/tailwind.css +5 -0
- package/src/runtime/assets/theme.css +65 -0
- package/src/runtime/build/WitchcraftUiResolver.ts +27 -0
- package/src/runtime/build/generateTheme.ts +16 -0
- package/src/runtime/build/unpluginIconViteOptions.ts +11 -0
- package/src/runtime/components/Aria/Aria.vue +27 -0
- package/src/runtime/components/Focus.stories.ts +67 -0
- package/src/runtime/components/Icon/Icon.vue +39 -0
- package/src/runtime/components/LibButton/LibButton.stories.ts +107 -0
- package/src/runtime/components/LibButton/LibButton.vue +247 -0
- package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +41 -0
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +132 -0
- package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +69 -0
- package/src/runtime/components/LibColorInput/LibColorInput.vue +125 -0
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +60 -0
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +51 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +95 -0
- package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +114 -0
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +67 -0
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
- package/src/runtime/components/LibDatePicker/helpers.ts +55 -0
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +58 -0
- package/src/runtime/components/LibDebug/LibDebug.vue +91 -0
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
- package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +79 -0
- package/src/runtime/components/LibFileInput/LibFileInput.vue +273 -0
- package/src/runtime/components/LibInput/LibInput.stories.ts +367 -0
- package/src/runtime/components/LibInput/LibInput.vue +372 -0
- package/src/runtime/components/LibLabel/LibLabel.stories.ts +37 -0
- package/src/runtime/components/LibLabel/LibLabel.vue +66 -0
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +83 -0
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
- package/src/runtime/components/LibNotifications/LibNotification.stories.ts +142 -0
- package/src/runtime/components/LibNotifications/LibNotification.vue +121 -0
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +124 -0
- package/src/runtime/components/LibNotifications/LibNotifications.vue +133 -0
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +53 -0
- package/src/runtime/components/LibPagination/LibPagination.vue +261 -0
- package/src/runtime/components/LibPalette/LibPalette.stories.ts +32 -0
- package/src/runtime/components/LibPalette/LibPalette.vue +49 -0
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +157 -0
- package/src/runtime/components/LibPopup/LibPopup.vue +441 -0
- package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +94 -0
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +192 -0
- package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +81 -0
- package/src/runtime/components/LibRecorder/LibRecorder.vue +243 -0
- package/src/runtime/components/LibRoot/LibRoot.vue +126 -0
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +98 -0
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +148 -0
- package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +137 -0
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +198 -0
- package/src/runtime/components/LibTable/LibTable.stories.ts +170 -0
- package/src/runtime/components/LibTable/LibTable.vue +177 -0
- package/src/runtime/components/Template/NAME.vue +49 -0
- package/src/runtime/components/Template/TemplateStory.ts +38 -0
- package/src/runtime/components/TestControls/TestControls.vue +19 -0
- package/src/runtime/components/index.ts +22 -0
- package/src/runtime/components/reset.stories.ts +32 -0
- package/src/runtime/components/shared/props.ts +142 -0
- package/src/runtime/components/shared/storyHelpers/playInput.ts +35 -0
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +105 -0
- package/src/runtime/composables/index.ts +13 -0
- package/src/runtime/composables/useAccesibilityOutline.ts +104 -0
- package/src/runtime/composables/useAriaLabel.ts +23 -0
- package/src/runtime/composables/useDarkMode.ts +146 -0
- package/src/runtime/composables/useDivideAttrs.ts +52 -0
- package/src/runtime/composables/useGlobalResizeObserver.ts +33 -0
- package/src/runtime/composables/useInjectedDarkMode.ts +15 -0
- package/src/runtime/composables/useInjectedI18n.ts +10 -0
- package/src/runtime/composables/useInjectedLocale.ts +24 -0
- package/src/runtime/composables/useNotificationHandler.ts +32 -0
- package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +93 -0
- package/src/runtime/composables/useScrollNearContainerEdges.ts +205 -0
- package/src/runtime/composables/useSetupDarkMode.ts +14 -0
- package/src/runtime/composables/useSetupI18n.ts +77 -0
- package/src/runtime/composables/useSetupLocale.ts +32 -0
- package/src/runtime/composables/useShowDevOnlyKey.ts +28 -0
- package/src/runtime/composables/useSuggestions.ts +297 -0
- package/src/runtime/directives/index.ts +6 -0
- package/src/runtime/directives/vDetectFlex.ts +159 -0
- package/src/runtime/directives/vExtractRootEl.ts +38 -0
- package/src/runtime/directives/vResizableCols.ts +378 -0
- package/src/runtime/directives/vResizeObserver.ts +45 -0
- package/src/runtime/globalResizeObserver.ts +12 -0
- package/src/runtime/helpers/NotificationHandler.ts +227 -0
- package/src/runtime/helpers/addValue.ts +10 -0
- package/src/runtime/helpers/base64ToImg.ts +14 -0
- package/src/runtime/helpers/copy.ts +11 -0
- package/src/runtime/helpers/createNoonUtcDate.ts +21 -0
- package/src/runtime/helpers/defaultTranslationFunction.ts +33 -0
- package/src/runtime/helpers/getTimeZoneList.ts +4 -0
- package/src/runtime/helpers/hasModifiers.ts +1 -0
- package/src/runtime/helpers/index.ts +10 -0
- package/src/runtime/helpers/readFile.ts +22 -0
- package/src/runtime/helpers/resizeObserverWrapper.ts +45 -0
- package/src/runtime/helpers/storybook.ts +52 -0
- package/src/runtime/main.lib.ts +31 -0
- package/src/runtime/nuxt/plugins/vue-plugin.ts +19 -0
- package/src/runtime/tailwind/index.ts +3 -0
- package/src/runtime/tailwind/themeConvertionOpts.ts +15 -0
- package/src/runtime/theme.ts +5 -0
- package/src/runtime/types/index.ts +116 -0
- package/src/runtime/utils/twMerge.ts +13 -0
- package/src/runtime/vue/VueComponentsPlugin.ts +16 -0
- package/src/runtime/vue/registerComponents.ts +31 -0
- package/src/runtime/vue/registerDirectives.ts +12 -0
- package/types/components.d.ts +27 -0
- package/types/global.d.ts +16 -0
- package/types/index.d.ts +5 -0
- package/types/vite.d.ts +2 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
|
+
|
|
4
|
+
import LibTable from "./LibTable.vue"
|
|
5
|
+
|
|
6
|
+
// todo
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
|
+
import * as components from "../index.js"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof LibTable> = {
|
|
12
|
+
component: LibTable,
|
|
13
|
+
title: "Components/Table",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default meta
|
|
17
|
+
type Story = StoryObj<typeof LibTable>
|
|
18
|
+
export const Primary: Story = {
|
|
19
|
+
render: args => ({
|
|
20
|
+
components,
|
|
21
|
+
setup: () => ({ args }),
|
|
22
|
+
template: `
|
|
23
|
+
<div class="overflow-x-scroll scrollbar-hidden">
|
|
24
|
+
<lib-table
|
|
25
|
+
v-bind="args"
|
|
26
|
+
>
|
|
27
|
+
</lib-table>
|
|
28
|
+
</div>
|
|
29
|
+
`,
|
|
30
|
+
}),
|
|
31
|
+
args: {
|
|
32
|
+
cols: ["prop1", "prop2", "prop3"],
|
|
33
|
+
values: [
|
|
34
|
+
{ prop1: "Item1 Prop 1", prop2: "Item1 Prop 2", prop3: "Item1 Prop 3" },
|
|
35
|
+
{ prop1: "Item2 Prop 1", prop2: "Item2 Prop 2", prop3: "Item2 Prop 3" },
|
|
36
|
+
{ prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" },
|
|
37
|
+
],
|
|
38
|
+
colConfig: { prop1: { name: "Header 1" }, prop2: { name: "Header 2" } },
|
|
39
|
+
itemKey: "prop1",
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const NoCellBorders: Story = {
|
|
44
|
+
...Primary,
|
|
45
|
+
args: {
|
|
46
|
+
...Primary.args,
|
|
47
|
+
cellBorder: false,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
export const NoBorders: Story = {
|
|
51
|
+
...Primary,
|
|
52
|
+
args: {
|
|
53
|
+
...Primary.args,
|
|
54
|
+
border: false,
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
export const NoCellBordersNoBorders: Story = {
|
|
58
|
+
...Primary,
|
|
59
|
+
args: {
|
|
60
|
+
...Primary.args,
|
|
61
|
+
cellBorder: false,
|
|
62
|
+
border: false,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const SquareBorders: Story = {
|
|
67
|
+
...Primary,
|
|
68
|
+
args: {
|
|
69
|
+
...Primary.args,
|
|
70
|
+
rounded: false,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
export const NoHeader: Story = {
|
|
74
|
+
...Primary,
|
|
75
|
+
args: {
|
|
76
|
+
...Primary.args,
|
|
77
|
+
header: false,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
export const NoHeaderNoBorders: Story = {
|
|
81
|
+
...Primary,
|
|
82
|
+
args: {
|
|
83
|
+
...Primary.args,
|
|
84
|
+
header: false,
|
|
85
|
+
border: false,
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
export const NoHeaderNoCellBorders: Story = {
|
|
89
|
+
...Primary,
|
|
90
|
+
args: {
|
|
91
|
+
...Primary.args,
|
|
92
|
+
header: false,
|
|
93
|
+
cellBorder: false,
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
export const FitWidthFalse: Story = {
|
|
97
|
+
...Primary,
|
|
98
|
+
args: {
|
|
99
|
+
...Primary.args,
|
|
100
|
+
resizable: {
|
|
101
|
+
fitWidth: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const ThreeColSomeColsNotResizable: Story = {
|
|
107
|
+
render: args => ({
|
|
108
|
+
components,
|
|
109
|
+
setup: () => ({ args }),
|
|
110
|
+
template: `
|
|
111
|
+
<lib-table
|
|
112
|
+
v-bind="args"
|
|
113
|
+
>
|
|
114
|
+
</lib-table>
|
|
115
|
+
<br>
|
|
116
|
+
<lib-table
|
|
117
|
+
v-bind="{...args, colConfig:args.colConfig2}"
|
|
118
|
+
>
|
|
119
|
+
</lib-table>
|
|
120
|
+
<br>
|
|
121
|
+
<lib-table
|
|
122
|
+
v-bind="{...args, colConfig:args.colConfig3}"
|
|
123
|
+
>
|
|
124
|
+
</lib-table>
|
|
125
|
+
`,
|
|
126
|
+
}),
|
|
127
|
+
args: {
|
|
128
|
+
cols: ["prop1", "prop2", "prop3"],
|
|
129
|
+
itemKey: "prop1",
|
|
130
|
+
values: [
|
|
131
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" },
|
|
132
|
+
],
|
|
133
|
+
colConfig: { prop1: { name: "No Resize", resizable: false } },
|
|
134
|
+
colConfig2: { prop2: { name: "No Resize", resizable: false } },
|
|
135
|
+
colConfig3: { prop3: { name: "No Resize", resizable: false } },
|
|
136
|
+
} as any,
|
|
137
|
+
}
|
|
138
|
+
export const FourColSomeColsNotResizable: Story = {
|
|
139
|
+
render: args => ({
|
|
140
|
+
components,
|
|
141
|
+
setup: () => ({ args }),
|
|
142
|
+
template: `
|
|
143
|
+
<lib-table
|
|
144
|
+
v-bind="args"
|
|
145
|
+
>
|
|
146
|
+
</lib-table>
|
|
147
|
+
<br>
|
|
148
|
+
<lib-table
|
|
149
|
+
v-bind="{...args, colConfig:args.colConfig2}"
|
|
150
|
+
>
|
|
151
|
+
</lib-table>
|
|
152
|
+
<br>
|
|
153
|
+
<lib-table
|
|
154
|
+
v-bind="{...args, colConfig:args.colConfig3}"
|
|
155
|
+
>
|
|
156
|
+
</lib-table>
|
|
157
|
+
`,
|
|
158
|
+
}),
|
|
159
|
+
args: {
|
|
160
|
+
cols: ["prop1", "prop2", "prop3", "prop4"],
|
|
161
|
+
values: [
|
|
162
|
+
{ prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" },
|
|
163
|
+
],
|
|
164
|
+
itemKey: "prop1",
|
|
165
|
+
colConfig: { prop1: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
166
|
+
colConfig2: { prop2: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
|
|
167
|
+
colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } },
|
|
168
|
+
} as any,
|
|
169
|
+
}
|
|
170
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Assumes no scrollbars on children -->
|
|
3
|
+
<table :class="twMerge(`table
|
|
4
|
+
table-fixed
|
|
5
|
+
border-separate
|
|
6
|
+
border-spacing-0
|
|
7
|
+
overflow-x-scroll
|
|
8
|
+
scrollbar-hidden
|
|
9
|
+
[&_.grip]:w-[5px]
|
|
10
|
+
relative
|
|
11
|
+
w-full
|
|
12
|
+
box-content
|
|
13
|
+
[&_thead]:font-bold
|
|
14
|
+
[&_td]:p-1
|
|
15
|
+
[&_td]:overflow-x-hidden
|
|
16
|
+
[&.resizable-cols-error]:cursor-not-allowed
|
|
17
|
+
[&.resizable-cols-error]:user-select-none
|
|
18
|
+
`,
|
|
19
|
+
cellBorder && `
|
|
20
|
+
[&_td]:border-neutral-500
|
|
21
|
+
[&_td:not(.last-row)]:border-b
|
|
22
|
+
[&_td:not(.first-col)]:border-l
|
|
23
|
+
`,
|
|
24
|
+
border && `
|
|
25
|
+
[&_thead_td]:bg-neutral-200
|
|
26
|
+
[&_td]:border-neutral-500
|
|
27
|
+
dark:[&_thead_td]:bg-neutral-800
|
|
28
|
+
dark:[&_td]:border-neutral-500
|
|
29
|
+
[&_td.first-row]:border-t
|
|
30
|
+
[&_td.last-row]:border-b
|
|
31
|
+
[&_td.last-col]:border-r
|
|
32
|
+
[&_td.first-col]:border-l
|
|
33
|
+
`,
|
|
34
|
+
rounded &&`
|
|
35
|
+
[&_td.br]:rounded-br-sm
|
|
36
|
+
[&_td.bl]:rounded-bl-sm
|
|
37
|
+
[&_td.tr]:rounded-tr-sm
|
|
38
|
+
[&_td.tl]:rounded-tl-sm
|
|
39
|
+
`
|
|
40
|
+
, ($attrs as any).class)"
|
|
41
|
+
v-resizable-cols="resizableOptions"
|
|
42
|
+
>
|
|
43
|
+
<thead v-if="header">
|
|
44
|
+
<tr>
|
|
45
|
+
<template v-for="col,i of cols" :key="col">
|
|
46
|
+
<slot :name="`header-${col.toString()}`"
|
|
47
|
+
:class="[
|
|
48
|
+
extraClasses[`-1-${i}`],
|
|
49
|
+
'cell',
|
|
50
|
+
(colConfig as any)[col]?.resizable === false
|
|
51
|
+
? 'no-resize'
|
|
52
|
+
: ''
|
|
53
|
+
].join(' ')"
|
|
54
|
+
:style="`width:${widths.length > 0 ? widths[i] : ``}; `"
|
|
55
|
+
:col-key="col"
|
|
56
|
+
>
|
|
57
|
+
<td :class="[
|
|
58
|
+
extraClasses[`-1-${i}`] ,
|
|
59
|
+
'cell',
|
|
60
|
+
(colConfig as any)[col]?.resizable === false
|
|
61
|
+
? 'no-resize'
|
|
62
|
+
: ''
|
|
63
|
+
].join(' ')"
|
|
64
|
+
:style="`width:${widths.length > 0 ? widths[i] : ``}; `"
|
|
65
|
+
>
|
|
66
|
+
{{ (colConfig as any)[col]?.name ?? col }}
|
|
67
|
+
</td>
|
|
68
|
+
</slot>
|
|
69
|
+
</template>
|
|
70
|
+
</tr>
|
|
71
|
+
</thead>
|
|
72
|
+
<tbody>
|
|
73
|
+
<template v-for="item, i of values" :key="typeof itemKey === 'function' ? itemKey(item) : item[itemKey]">
|
|
74
|
+
<tr>
|
|
75
|
+
<template v-for="col, j of cols" :key="(typeof itemKey === 'function' ? itemKey(item) : item[itemKey]) + col.toString()">
|
|
76
|
+
<slot
|
|
77
|
+
:name="col"
|
|
78
|
+
:item="item"
|
|
79
|
+
:value="item[col]"
|
|
80
|
+
:class="extraClasses[`${i}-${j}`] + ' cell'"
|
|
81
|
+
>
|
|
82
|
+
<td :class="extraClasses[`${i}-${j}`] + ' cell'">
|
|
83
|
+
{{ item[col] }}
|
|
84
|
+
</td>
|
|
85
|
+
</slot>
|
|
86
|
+
</template>
|
|
87
|
+
</tr>
|
|
88
|
+
</template>
|
|
89
|
+
</tbody>
|
|
90
|
+
</table>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<!-- generic="T extends Record<string, any> -->"
|
|
94
|
+
<script setup lang="ts" generic="T">
|
|
95
|
+
import type { MakeRequired } from "@alanscodelog/utils"
|
|
96
|
+
import { keys } from "@alanscodelog/utils/keys.js"
|
|
97
|
+
import { computed, type PropType, ref, type TableHTMLAttributes } from "vue"
|
|
98
|
+
|
|
99
|
+
import { vResizableCols } from "../../directives/vResizableCols.js"
|
|
100
|
+
import type { ResizableOptions, TableColConfig } from "../../types/index.js"
|
|
101
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
102
|
+
import type { TailwindClassProp } from "../shared/props.js"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
defineOptions({
|
|
106
|
+
name: "lib-table",
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// eslint-disable-next-line no-use-before-define
|
|
110
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
111
|
+
resizable: () => ({}),
|
|
112
|
+
values: () => [] as T[],
|
|
113
|
+
itemKey: "",
|
|
114
|
+
cols: () => [] as (keyof T)[],
|
|
115
|
+
rounded: true,
|
|
116
|
+
border: true,
|
|
117
|
+
cellBorder: true,
|
|
118
|
+
header: true,
|
|
119
|
+
colConfig: () => ({}) ,
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const widths = ref([])
|
|
123
|
+
const resizableOptions = computed<MakeRequired<Partial<ResizableOptions>, "colCount" | "widths">>(() => ({
|
|
124
|
+
colCount: props.cols.length,
|
|
125
|
+
widths,
|
|
126
|
+
selector: ".cell",
|
|
127
|
+
...props.resizable,
|
|
128
|
+
}))
|
|
129
|
+
|
|
130
|
+
/* props.values.length instead of `props.values.length - 1` because we're creating an artificial first row for the header */
|
|
131
|
+
const getExtraClasses = (row: number, col: number, isHeader: boolean): string[] => {
|
|
132
|
+
const res = {
|
|
133
|
+
bl: !isHeader && row === props.values.length - 1 && col === 0,
|
|
134
|
+
br: !isHeader && row === props.values.length - 1 && col === props.cols.length - 1,
|
|
135
|
+
tr: (isHeader || !props.header) && row === 0 && col === props.cols.length - 1,
|
|
136
|
+
tl: (isHeader || !props.header) && row === 0 && col === 0,
|
|
137
|
+
"first-row": (isHeader || !props.header) && row === 0,
|
|
138
|
+
"last-row": row === props.values.length - 1,
|
|
139
|
+
"first-col": col === 0,
|
|
140
|
+
"last-col": col === props.cols.length - 1,
|
|
141
|
+
}
|
|
142
|
+
return keys(res).filter(key => res[key])
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const extraClasses = computed(() => Object.fromEntries([...Array(props.values.length + 1).keys()]
|
|
146
|
+
.map(row => [...Array(props.cols.length).keys()]
|
|
147
|
+
.map(col =>
|
|
148
|
+
[
|
|
149
|
+
`${row - 1}-${col}`,
|
|
150
|
+
getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" "),
|
|
151
|
+
]))
|
|
152
|
+
.flat(),
|
|
153
|
+
))
|
|
154
|
+
|
|
155
|
+
</script>
|
|
156
|
+
<script lang="ts">
|
|
157
|
+
// generic isn't working here :/
|
|
158
|
+
type T = any
|
|
159
|
+
|
|
160
|
+
type RealProps = {
|
|
161
|
+
resizable?: Partial<ResizableOptions>
|
|
162
|
+
values?: T[]
|
|
163
|
+
itemKey?: keyof T | ((item: T) => string)
|
|
164
|
+
/** Let's the table know the shape of the data since values might be empty. */
|
|
165
|
+
cols?: (keyof T)[]
|
|
166
|
+
rounded?: boolean
|
|
167
|
+
border?: boolean
|
|
168
|
+
cellBorder?: boolean
|
|
169
|
+
header?: boolean
|
|
170
|
+
colConfig?: TableColConfig<T>
|
|
171
|
+
}
|
|
172
|
+
interface Props
|
|
173
|
+
extends
|
|
174
|
+
/** @vue-ignore */
|
|
175
|
+
Partial<Omit<TableHTMLAttributes,"class" | "readonly" | "disabled"> & TailwindClassProp>,
|
|
176
|
+
RealProps { }
|
|
177
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- eslint-disable -->
|
|
2
|
+
<template>
|
|
3
|
+
<div :class="twMerge(`
|
|
4
|
+
|
|
5
|
+
`, ($attrs as any).class)"
|
|
6
|
+
v-bind="{...$attrs, class:undefined}"
|
|
7
|
+
>
|
|
8
|
+
<slot/>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
|
|
13
|
+
import { computed, getCurrentInstance, type HTMLAttributes, onBeforeUnmount, onMounted, type PropType, reactive, type Ref, ref, watch } from "vue"
|
|
14
|
+
|
|
15
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
16
|
+
import { baseInteractiveProps, type TailwindClassProp } from "../shared/props.js"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
defineOptions({
|
|
20
|
+
name: "lib-name", /* todo */
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// const props = defineProps<{}>({ })
|
|
26
|
+
|
|
27
|
+
const el = ref<null | HTMLElement>(null)
|
|
28
|
+
|
|
29
|
+
const modelValue = defineModel<string>({ required: true })
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts">
|
|
35
|
+
export default {
|
|
36
|
+
name: "lib-name",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type RealProps = {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface Props
|
|
43
|
+
extends
|
|
44
|
+
/** @vue-ignore */
|
|
45
|
+
Partial<Omit<HTMLAttributes, "class">
|
|
46
|
+
& TailwindClassProp
|
|
47
|
+
& RealProps
|
|
48
|
+
> { }
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @ts-nocheck remove when copying
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
4
|
+
|
|
5
|
+
import NAME from "./NAME.vue"
|
|
6
|
+
|
|
7
|
+
// todo, maybe don't do this for perf reasons
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
|
+
import * as components from "../index.js"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof NAME> = {
|
|
13
|
+
component: NAME,
|
|
14
|
+
args: {
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default meta
|
|
20
|
+
type Story = StoryObj<typeof NAME>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const Primary: Story = {
|
|
24
|
+
render: args => ({
|
|
25
|
+
components,
|
|
26
|
+
setup: () => ({ args }),
|
|
27
|
+
template: `
|
|
28
|
+
<NAME v-bind="{...args}">{{args.value}}</NAME>
|
|
29
|
+
`,
|
|
30
|
+
}),
|
|
31
|
+
}
|
|
32
|
+
export const Secondary: Story = {
|
|
33
|
+
...Primary,
|
|
34
|
+
args: {
|
|
35
|
+
...Primary.args,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Width 100% + 2xmargin in combination with the margins in LibRoot is a bit of a hack so that it looks like there's padding around the content in test mode (for storybook). We can't just absolutely position these controls or they make the container scroll. -->
|
|
3
|
+
<div class="flex gap-2 p-1 pb-10 -ml-10 w-[calc(100%_+_var(--spacing)*20)]">
|
|
4
|
+
<div class="flex-grow"/>
|
|
5
|
+
<div class="outline-indicator">{{ showOutline ? "Outline Enabled" : "Outline Disabled" }}</div>
|
|
6
|
+
<lib-dark-mode-switcher/>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import LibDarkModeSwitcher from "../LibDarkModeSwitcher/LibDarkModeSwitcher.vue"
|
|
12
|
+
|
|
13
|
+
defineOptions({ name: "test-controls" })
|
|
14
|
+
defineProps< {
|
|
15
|
+
showOutline: boolean
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
</script>
|
|
19
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { default as LibTimeZonePicker } from "./LibDatePicker/LibTimeZonePicker.vue"
|
|
2
|
+
/* Manually Generated Index */
|
|
3
|
+
|
|
4
|
+
export { default as aria } from "./Aria/Aria.vue"
|
|
5
|
+
export { default as LibButton } from "./LibButton/LibButton.vue"
|
|
6
|
+
export { default as LibDatePicker } from "./LibDatePicker/LibDatePicker.vue"
|
|
7
|
+
export { default as LibDebug } from "./LibDebug/LibDebug.vue"
|
|
8
|
+
export { default as LibDarkModeSwitcher } from "./LibDarkModeSwitcher/LibDarkModeSwitcher.vue"
|
|
9
|
+
export { default as LibInput } from "./LibInput/LibInput.vue"
|
|
10
|
+
export { default as LibNotifications } from "./LibNotifications/LibNotifications.vue"
|
|
11
|
+
export { default as LibPagination } from "./LibPagination/LibPagination.vue"
|
|
12
|
+
export { default as LibTable } from "./LibTable/LibTable.vue"
|
|
13
|
+
export { default as LibColorPicker } from "./LibColorPicker/LibColorPicker.vue"
|
|
14
|
+
export { default as LibColorInput } from "./LibColorInput/LibColorInput.vue"
|
|
15
|
+
export { default as LibPopup } from "./LibPopup/LibPopup.vue"
|
|
16
|
+
export { default as LibSimpleInput } from "./LibSimpleInput/LibSimpleInput.vue"
|
|
17
|
+
export { default as LibRecorder } from "./LibRecorder/LibRecorder.vue"
|
|
18
|
+
export { default as LibLabel } from "./LibLabel/LibLabel.vue"
|
|
19
|
+
export { default as LibCheckbox } from "./LibCheckbox/LibCheckbox.vue"
|
|
20
|
+
export { default as LibFileInput } from "./LibFileInput/LibFileInput.vue"
|
|
21
|
+
export { default as LibProgressBar } from "./LibProgressBar/LibProgressBar.vue"
|
|
22
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
6
|
+
const meta: Meta<{}> = {
|
|
7
|
+
title: "Other/Reset",
|
|
8
|
+
args: {
|
|
9
|
+
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default meta
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
|
+
type Story = StoryObj<{}>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export const Primary: Story = {
|
|
19
|
+
render: args => ({
|
|
20
|
+
setup: () => ({ args }),
|
|
21
|
+
template: `
|
|
22
|
+
<h1>h1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h1>
|
|
23
|
+
<h2>h2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h2>
|
|
24
|
+
<h3>h3 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h3>
|
|
25
|
+
<h4>h4 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h4>
|
|
26
|
+
<h5>h5 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h5>
|
|
27
|
+
<h6>h6 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</h6>
|
|
28
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ullamcorper est at dui eleifend, et egestas libero gravida. Phasellus non erat pretium, commodo massa sit amet, accumsan nisl.</p>
|
|
29
|
+
`,
|
|
30
|
+
}),
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type PropType,useId } from "vue"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface LinkableByIdProps {
|
|
5
|
+
/**
|
|
6
|
+
* The id for the input. Uses vue's useId if none provided.
|
|
7
|
+
*
|
|
8
|
+
* For components that are not inputs, the id passed to inputs should be shared with the corresponding label/suggestions/etc component to connect them.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
id?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getFallbackId = (): string => useId()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export interface LabelProps {
|
|
18
|
+
/** For the label. Note the component might or might not support an actual label element. If none is supported, this is used for the `aria-label`. */
|
|
19
|
+
label?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SuggestionsProps<T = any> = {
|
|
23
|
+
/**
|
|
24
|
+
* A list of autocomplete suggestions. Can be a simple list of strings, or more complicated, like a list of objects. In the case of objects, you'll want to specify `suggestionsLabel`.
|
|
25
|
+
*
|
|
26
|
+
* Each item is passed to the suggestion slot via the `items` prop. You can access it like:
|
|
27
|
+
* ```
|
|
28
|
+
* <div #item={item}>
|
|
29
|
+
* {{item}}
|
|
30
|
+
* </div>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
suggestions?: T[]
|
|
34
|
+
/** A function that specifies how to extract the label from a suggestion when it's an object, e.g. `(item) => item.label`. By default, if none is passed, it's assumed suggestions is a list of strings. */
|
|
35
|
+
suggestionLabel?: (item: T) => string
|
|
36
|
+
/**
|
|
37
|
+
* Whether to restrict the value to the suggestions list or merely use it to suggest values. Default is false.
|
|
38
|
+
*
|
|
39
|
+
* This stops v-modeling of what the user is typing when there is a value that does not match any values in the suggestions list. `update:modelValue` will only be emitted when they type/select/click a valid option.
|
|
40
|
+
*
|
|
41
|
+
* When the input is partially valid (it partially matches an option in the suggestions list), if the user presses enter or focuses away, the last selected suggestion is set as the value.
|
|
42
|
+
*
|
|
43
|
+
* When the input is completely invalid, the `errored` class is added to the component and the input goes red. If the user focuses away or tries to press enter anyways, the value is reset to the last valid value.
|
|
44
|
+
*
|
|
45
|
+
* Additionally when the input is invalid, the user can open the dropdown menu (it won't auto open) to view all the suggestions.
|
|
46
|
+
*/
|
|
47
|
+
restrictToSuggestions?: boolean
|
|
48
|
+
/**
|
|
49
|
+
* Usually when using autosuggest, we only want to update the modelValue when the user submits the input.
|
|
50
|
+
* This happens by default if using `restrictToSuggestions`, but not if not restricting them.
|
|
51
|
+
*
|
|
52
|
+
* This can be worked around by listening a bit differently to events, but this is a common use case so there's now an option that automatically does this.
|
|
53
|
+
*
|
|
54
|
+
* By default it's false.
|
|
55
|
+
*/
|
|
56
|
+
updateOnlyOnSubmit?: boolean
|
|
57
|
+
/** A function to filter the suggestions based on the current input. If none is given, will attempt to filter by the label using a basic case insensitive `includes` search. */
|
|
58
|
+
suggestionsFilter?: (input: string | number, items: T[]) => any[]
|
|
59
|
+
/** Allows opening the input dropdown when it's empty. Default is true. */
|
|
60
|
+
allowOpenEmpty?: boolean
|
|
61
|
+
/** Whether the suggestions dropdown can be opened. Default is true. */
|
|
62
|
+
canOpen?: boolean
|
|
63
|
+
/** Whether the input is valid. Default is true. */
|
|
64
|
+
isValid?: boolean
|
|
65
|
+
/**
|
|
66
|
+
* A function to determine which selection to auto select. By default, the start of the string must match and the longest match is used. If the input is 0 length, the first element is selected.
|
|
67
|
+
*
|
|
68
|
+
* You can implement custom behavior here like fuzzy matching. Note that an exactly matching selection is always picked (the function will not be called).
|
|
69
|
+
*/
|
|
70
|
+
suggestionSelector?: (suggestions: T[], input: string) => number
|
|
71
|
+
}
|
|
72
|
+
export type SuggestionsOptions<T> = SuggestionsProps<T> & MultiValueProps
|
|
73
|
+
|
|
74
|
+
export interface SuggestionsEmits {
|
|
75
|
+
(e: "submit", val: string, suggestion?: any): void
|
|
76
|
+
(e: "update:isOpen", val: boolean): void
|
|
77
|
+
(e: "update:activeSuggestion", val: number): void
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export const baseInteractiveProps = {
|
|
82
|
+
unstyle: { type: Boolean as Function as PropType<boolean>, required: false, default: false },
|
|
83
|
+
disabled: { type: Boolean as Function as PropType<boolean>, required: false, default: false },
|
|
84
|
+
readonly: { type: Boolean as Function as PropType<boolean>, required: false, default: false },
|
|
85
|
+
border: { type: Boolean as Function as PropType<boolean>, required: false, default: true },
|
|
86
|
+
} as const
|
|
87
|
+
|
|
88
|
+
export type BaseInteractiveProps = {
|
|
89
|
+
/** Default is false. */
|
|
90
|
+
disabled?: boolean
|
|
91
|
+
/** Default is false. */
|
|
92
|
+
readonly?: boolean
|
|
93
|
+
/** Default is true. */
|
|
94
|
+
border?: boolean
|
|
95
|
+
/** Removes styles from the component. Default is false. */
|
|
96
|
+
unstyle?: boolean
|
|
97
|
+
}
|
|
98
|
+
export const baseInteractivePropsDefaults = {
|
|
99
|
+
disabled: false,
|
|
100
|
+
readonly: false,
|
|
101
|
+
border: true,
|
|
102
|
+
unstyle: false,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export type MultiValueProps = {
|
|
107
|
+
/**
|
|
108
|
+
* If values is used, for components that handle multiple values, prevents adding of duplicate values.
|
|
109
|
+
*
|
|
110
|
+
* For other components, it prevents suggesting values that have already been added.
|
|
111
|
+
*
|
|
112
|
+
* Default is true.
|
|
113
|
+
*/
|
|
114
|
+
preventDuplicateValues?: boolean
|
|
115
|
+
/** The selected values.*/
|
|
116
|
+
values?: string[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @internal
|
|
121
|
+
* For easily typing attributes created by useDivideAttrs. See readme.
|
|
122
|
+
*
|
|
123
|
+
* By default overrides the `class` prop to only take a string (to pass to tailwing).
|
|
124
|
+
*/
|
|
125
|
+
export type WrapperProps<TPrefix extends string, T, TOverrides extends Record<string, any> | never = TailwindClassProp> = {
|
|
126
|
+
[P in keyof T as P extends keyof TOverrides
|
|
127
|
+
? never
|
|
128
|
+
: P extends string
|
|
129
|
+
? `${TPrefix}${Capitalize<P>}`
|
|
130
|
+
: never
|
|
131
|
+
]: T[P];
|
|
132
|
+
} & {
|
|
133
|
+
[P in keyof TOverrides as P extends string
|
|
134
|
+
? `${TPrefix}${Capitalize<P>}`
|
|
135
|
+
: never
|
|
136
|
+
]: TOverrides[P];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type TailwindClassProp = {
|
|
140
|
+
/** Tailwind classes. */
|
|
141
|
+
class?: string | false
|
|
142
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
2
|
+
import { expect, userEvent, within } from "@storybook/test"
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
|
+
export const playBasicVModel = async ({ canvasElement, args }: { canvasElement: HTMLElement, args: any }) => {
|
|
6
|
+
const canvas = within(canvasElement)
|
|
7
|
+
const input = canvas.getByLabelText(args.label ?? "", { selector: "input" })
|
|
8
|
+
await userEvent.type(input, "A")
|
|
9
|
+
await expect(canvas.getByTestId("model-value").textContent).toBe("A")
|
|
10
|
+
await userEvent.clear(input)
|
|
11
|
+
await expect(canvas.getByTestId("model-value").textContent).toBe("")
|
|
12
|
+
}
|
|
13
|
+
export const playMultipleValues = async ({ canvasElement, args }: { canvasElement: HTMLElement, args: any }) => {
|
|
14
|
+
const initialValues = [...(args.values ?? [])]
|
|
15
|
+
const canvas = within(canvasElement)
|
|
16
|
+
const input = canvas.getByLabelText(args.label ?? "", { selector: "input" })
|
|
17
|
+
await userEvent.type(input, "A")
|
|
18
|
+
await expect(canvas.getByTestId("model-value")).toHaveTextContent("A")
|
|
19
|
+
await userEvent.keyboard("{Enter}")
|
|
20
|
+
await expect(canvas.getByTestId("values").textContent)
|
|
21
|
+
.toBe([...initialValues, "A"].join(", "))
|
|
22
|
+
// expect input to get cleared
|
|
23
|
+
await expect(canvas.getByTestId("model-value")).toBeEmptyDOMElement()
|
|
24
|
+
|
|
25
|
+
await userEvent.type(input, "B")
|
|
26
|
+
await expect(canvas.getByTestId("model-value")).toHaveTextContent("B")
|
|
27
|
+
await userEvent.keyboard("{Enter}")
|
|
28
|
+
await expect(canvas.getByTestId("values").textContent)
|
|
29
|
+
.toBe([ ...initialValues, "A", "B" ].join(", "))
|
|
30
|
+
// empty input does nothing
|
|
31
|
+
await userEvent.clear(input)
|
|
32
|
+
await userEvent.keyboard("{Enter}")
|
|
33
|
+
await expect(canvas.getByTestId("values").textContent)
|
|
34
|
+
.toBe([ ...initialValues, "A", "B" ].join(", "))
|
|
35
|
+
}
|