@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,192 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Transition>
|
|
3
|
+
<div v-if="!hide"
|
|
4
|
+
:id="id ?? fallbackId"
|
|
5
|
+
:class="twMerge(`
|
|
6
|
+
w-[200px]
|
|
7
|
+
whitespace-nowrap
|
|
8
|
+
overflow-x-scroll
|
|
9
|
+
scrollbar-hidden
|
|
10
|
+
rounded-sm
|
|
11
|
+
flex
|
|
12
|
+
text-fg
|
|
13
|
+
relative
|
|
14
|
+
before:content-['']
|
|
15
|
+
text-sm
|
|
16
|
+
min-w-[50px]
|
|
17
|
+
after:shadow-inner
|
|
18
|
+
after:shadow-black/50
|
|
19
|
+
after:content-['']
|
|
20
|
+
after:absolute
|
|
21
|
+
after:inset-0
|
|
22
|
+
after:pointer-events-none
|
|
23
|
+
after:z-2
|
|
24
|
+
after:transition-all
|
|
25
|
+
before:shadow-inner
|
|
26
|
+
before:shadow-black/50
|
|
27
|
+
before:rounded-sm
|
|
28
|
+
before:bg-bars-gradient
|
|
29
|
+
before:animate-[slide_10s_linear_infinite]
|
|
30
|
+
before:[background-size:15px_15px]
|
|
31
|
+
before:absolute
|
|
32
|
+
before:w-[var(--progress)]
|
|
33
|
+
before:top-0 before:bottom-0 before:left-0
|
|
34
|
+
before:transition-all
|
|
35
|
+
before:z-1
|
|
36
|
+
before:duration-500
|
|
37
|
+
`,psuedoHide && `
|
|
38
|
+
after:opacity-0
|
|
39
|
+
before:opacity-0
|
|
40
|
+
`, ($attrs as any).class)"
|
|
41
|
+
:data-value="progress"
|
|
42
|
+
:title="label"
|
|
43
|
+
role="progressbar"
|
|
44
|
+
:aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
|
|
45
|
+
:aria-valuemin="clamp[0] ?? 0"
|
|
46
|
+
:aria-valuemax="clamp[1] ?? 100"
|
|
47
|
+
v-bind="{...$attrs, class:undefined}"
|
|
48
|
+
:style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
|
|
49
|
+
>
|
|
50
|
+
<div class="label-wrapper relative flex-1">
|
|
51
|
+
<span class="before:content-vertical-holder"/>
|
|
52
|
+
<Transition>
|
|
53
|
+
<slot>
|
|
54
|
+
<label v-if="!psuedoHide"
|
|
55
|
+
:for="id"
|
|
56
|
+
class="
|
|
57
|
+
text-bg
|
|
58
|
+
absolute inset-0 flex
|
|
59
|
+
justify-center
|
|
60
|
+
"
|
|
61
|
+
>
|
|
62
|
+
<div class="truncate">
|
|
63
|
+
{{ label ?? "" }}
|
|
64
|
+
</div>
|
|
65
|
+
</label>
|
|
66
|
+
</slot>
|
|
67
|
+
</Transition>
|
|
68
|
+
|
|
69
|
+
<Transition>
|
|
70
|
+
<slot>
|
|
71
|
+
<label
|
|
72
|
+
v-if="!psuedoHide"
|
|
73
|
+
class="
|
|
74
|
+
contrast-label
|
|
75
|
+
pointer-events-none
|
|
76
|
+
absolute
|
|
77
|
+
inset-0
|
|
78
|
+
flex justify-center transition-all
|
|
79
|
+
duration-500
|
|
80
|
+
[clip-path:inset(0_0_0_var(--progress))]
|
|
81
|
+
dark:hidden
|
|
82
|
+
"
|
|
83
|
+
>
|
|
84
|
+
<div class="truncate">
|
|
85
|
+
{{ label ?? "" }}
|
|
86
|
+
</div>
|
|
87
|
+
</label>
|
|
88
|
+
</slot>
|
|
89
|
+
</Transition>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</Transition>
|
|
93
|
+
</template>
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
import { type HTMLAttributes,type PropType, ref, watch } from "vue"
|
|
96
|
+
|
|
97
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
98
|
+
import { type BaseInteractiveProps, baseInteractivePropsDefaults,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
99
|
+
|
|
100
|
+
// TODO move to utils
|
|
101
|
+
const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
|
|
102
|
+
|
|
103
|
+
defineOptions({
|
|
104
|
+
name: "lib-progress-bar",
|
|
105
|
+
inheritAttrs: false,
|
|
106
|
+
})
|
|
107
|
+
const fallbackId = getFallbackId()
|
|
108
|
+
// eslint-disable-next-line no-use-before-define
|
|
109
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
110
|
+
autohideOnComplete: -1,
|
|
111
|
+
keepSpaceWhenHidden: false,
|
|
112
|
+
clamp: () => [0, 100],
|
|
113
|
+
...baseInteractivePropsDefaults
|
|
114
|
+
})
|
|
115
|
+
const hide = ref<boolean>(false)
|
|
116
|
+
const psuedoHide = ref<boolean>(false)
|
|
117
|
+
let timeout: number
|
|
118
|
+
let type: number
|
|
119
|
+
if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
|
|
120
|
+
if (props.keepSpaceWhenHidden) {
|
|
121
|
+
hide.value = false
|
|
122
|
+
psuedoHide.value = true
|
|
123
|
+
} else {
|
|
124
|
+
hide.value = true
|
|
125
|
+
psuedoHide.value = false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
watch([
|
|
130
|
+
() => props.progress,
|
|
131
|
+
() => props.keepSpaceWhenHidden,
|
|
132
|
+
() => props.autohideOnComplete,
|
|
133
|
+
], () => {
|
|
134
|
+
if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
|
|
135
|
+
if (props.keepSpaceWhenHidden) {
|
|
136
|
+
if (type === 1) return
|
|
137
|
+
clearTimeout(timeout)
|
|
138
|
+
type = 1
|
|
139
|
+
timeout = setTimeout(() => {
|
|
140
|
+
type = 0
|
|
141
|
+
hide.value = false
|
|
142
|
+
psuedoHide.value = true
|
|
143
|
+
}, props.autohideOnComplete) as any
|
|
144
|
+
} else {
|
|
145
|
+
if (type === 2) return
|
|
146
|
+
clearTimeout(timeout)
|
|
147
|
+
type = 2
|
|
148
|
+
timeout = setTimeout(() => {
|
|
149
|
+
type = 0
|
|
150
|
+
hide.value = true
|
|
151
|
+
psuedoHide.value = false
|
|
152
|
+
}, props.autohideOnComplete) as any
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
clearTimeout(timeout)
|
|
156
|
+
hide.value = false
|
|
157
|
+
psuedoHide.value = false
|
|
158
|
+
}
|
|
159
|
+
}, { immediate: false })
|
|
160
|
+
|
|
161
|
+
</script>
|
|
162
|
+
<script lang="ts">
|
|
163
|
+
|
|
164
|
+
type RealProps =
|
|
165
|
+
& LinkableByIdProps
|
|
166
|
+
& BaseInteractiveProps
|
|
167
|
+
& LabelProps
|
|
168
|
+
& {
|
|
169
|
+
progress: number
|
|
170
|
+
/** Will auto hide after this given time if progress is 100% or more or less than 0% until progress is set to something else. Disabled (-1) by default. */
|
|
171
|
+
autohideOnComplete?: number
|
|
172
|
+
/**
|
|
173
|
+
* Do not actually hide the element, just leave an unstyled div,
|
|
174
|
+
* so the whole layout doesn't change on completion when autohideOnComplete is set.
|
|
175
|
+
*/
|
|
176
|
+
keepSpaceWhenHidden?: boolean
|
|
177
|
+
/**
|
|
178
|
+
* By default the progress bar is visually clamped to 0-100, even if the value might be something else.
|
|
179
|
+
* You can change what it's clamped to here, to for example,
|
|
180
|
+
* show at least a small sliver of the progress bar when it's still 0.
|
|
181
|
+
*/
|
|
182
|
+
clamp?: [start:number, end:number]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface Props
|
|
186
|
+
extends
|
|
187
|
+
/** @vue-ignore */
|
|
188
|
+
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
189
|
+
RealProps
|
|
190
|
+
{ }
|
|
191
|
+
|
|
192
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3";
|
|
2
|
+
import * as components from "../index.js.js";
|
|
3
|
+
/**
|
|
4
|
+
* This is a special input component designed to record any type of event.
|
|
5
|
+
*
|
|
6
|
+
* It requires additional setup to actually work since what and how anything is recorded is up to the needs of the application.
|
|
7
|
+
*
|
|
8
|
+
* This basic implementation just lists the keys. Enter accepts the recording, escape cancels back to the initial value.
|
|
9
|
+
*/
|
|
10
|
+
declare const meta: Meta<typeof components.LibRecorder>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof components.LibRecorder>;
|
|
13
|
+
export declare const Primary: Story;
|
|
14
|
+
/** Should not be tabbable or recordable. */
|
|
15
|
+
export declare const Disabled: Story;
|
|
16
|
+
/** *Should* be tabbable but not recordable. */
|
|
17
|
+
export declare const Readonly: Story;
|
|
18
|
+
/** Height should not shrink. */
|
|
19
|
+
export declare const EmptyInitialValue: Story;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ref, watchEffect } from "vue";
|
|
2
|
+
import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js";
|
|
3
|
+
import * as components from "../index.js";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: components.LibRecorder,
|
|
6
|
+
title: "Components/Recorder",
|
|
7
|
+
args: {
|
|
8
|
+
label: "Some Label",
|
|
9
|
+
recordingTitle: "Recording. Press enter or click away to accept. Press escape to cancel.",
|
|
10
|
+
modelValue: "K E Y S"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Primary = {
|
|
15
|
+
render: (args) => ({
|
|
16
|
+
components,
|
|
17
|
+
setup: () => {
|
|
18
|
+
const recording = ref(false);
|
|
19
|
+
const recordingValue = ref("");
|
|
20
|
+
const modelValue = ref(args.modelValue);
|
|
21
|
+
const recorderEl = ref(null);
|
|
22
|
+
const recorder = createRecorderHandler(recordingValue, recording, modelValue, recorderEl);
|
|
23
|
+
watchEffect(createRecorderWatchEffect(recordingValue, recording, modelValue));
|
|
24
|
+
return {
|
|
25
|
+
args,
|
|
26
|
+
modelValue,
|
|
27
|
+
recorder,
|
|
28
|
+
recording,
|
|
29
|
+
recordingValue,
|
|
30
|
+
recorderEl
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
template: `
|
|
34
|
+
<lib-recorder
|
|
35
|
+
v-bind="args"
|
|
36
|
+
v-extract-root-el="_ => recorderEl = _"
|
|
37
|
+
:recordingValue="recordingValue"
|
|
38
|
+
:recorder="recorder"
|
|
39
|
+
v-model:recording="recording"
|
|
40
|
+
v-model="modelValue"
|
|
41
|
+
@recorder:click="recording = !recording"
|
|
42
|
+
/>
|
|
43
|
+
`
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
export const Disabled = {
|
|
47
|
+
...Primary,
|
|
48
|
+
args: {
|
|
49
|
+
disabled: true
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const Readonly = {
|
|
53
|
+
...Primary,
|
|
54
|
+
args: {
|
|
55
|
+
readonly: true
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export const EmptyInitialValue = {
|
|
59
|
+
...Primary,
|
|
60
|
+
args: {
|
|
61
|
+
modelValue: ""
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
We use a custom element for the recorder so we don't have to deal with the input event.
|
|
4
|
+
contenteditable=false is because of storybook, it's shortcuts interfere when not using real input elements
|
|
5
|
+
-->
|
|
6
|
+
<div
|
|
7
|
+
:id="id?? fallbackId"
|
|
8
|
+
:class="twMerge(`recorder
|
|
9
|
+
flex items-center
|
|
10
|
+
gap-2
|
|
11
|
+
px-2
|
|
12
|
+
grow-[999999]
|
|
13
|
+
focus-outline-no-offset
|
|
14
|
+
rounded-sm
|
|
15
|
+
`,
|
|
16
|
+
border &&`
|
|
17
|
+
border
|
|
18
|
+
border-neutral-500
|
|
19
|
+
focus:border-accent-500
|
|
20
|
+
`,
|
|
21
|
+
|
|
22
|
+
(disabled || readonly) && `
|
|
23
|
+
text-neutral-400
|
|
24
|
+
dark:text-neutral-600
|
|
25
|
+
`,
|
|
26
|
+
(disabled || readonly) && border && `
|
|
27
|
+
bg-neutral-50
|
|
28
|
+
dark:bg-neutral-950
|
|
29
|
+
border-neutral-400
|
|
30
|
+
dark:border-neutral-600
|
|
31
|
+
`
|
|
32
|
+
, ($attrs as any).class)"
|
|
33
|
+
:aria-disabled="disabled"
|
|
34
|
+
:aria-readonly="readonly"
|
|
35
|
+
:tabindex="disabled ? -1 : 0"
|
|
36
|
+
:title="recording ? recordingTitle : tempValue"
|
|
37
|
+
contenteditable="false"
|
|
38
|
+
ref="recorderEl"
|
|
39
|
+
v-bind="{...ariaLabel, ...$attrs, class:undefined}"
|
|
40
|
+
@blur="handleBlurRecorder($event)"
|
|
41
|
+
@click="handleClickRecorder($event)"
|
|
42
|
+
@keydown.space.prevent="handleClickRecorder($event, true)"
|
|
43
|
+
>
|
|
44
|
+
<!-- :aria-description="recording ? recordingTitle : ''" -->
|
|
45
|
+
<div
|
|
46
|
+
:class="twMerge(`recorder-indicator
|
|
47
|
+
inline-block
|
|
48
|
+
bg-red-700
|
|
49
|
+
rounded-full
|
|
50
|
+
w-[1em]
|
|
51
|
+
h-[1em]
|
|
52
|
+
shrink-0
|
|
53
|
+
hover:bg-red-500
|
|
54
|
+
`,
|
|
55
|
+
recording && `
|
|
56
|
+
animate-[blink_1s_infinite]
|
|
57
|
+
bg-red-500
|
|
58
|
+
`,
|
|
59
|
+
(disabled || readonly) && `
|
|
60
|
+
bg-neutral-500
|
|
61
|
+
`
|
|
62
|
+
)"
|
|
63
|
+
ref="recorderIndicatorEl"
|
|
64
|
+
/>
|
|
65
|
+
<div class="recorder-value before:content-vertical-holder truncate">
|
|
66
|
+
{{ recording
|
|
67
|
+
? recordingValue ?? t("recorder.recording")
|
|
68
|
+
: tempValue }}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { keys } from "@alanscodelog/utils/keys.js"
|
|
74
|
+
import { computed, type HTMLAttributes ,onBeforeUnmount, onMounted, type PropType, ref, watch, watchPostEffect } from "vue"
|
|
75
|
+
|
|
76
|
+
import { useAriaLabel } from "../../composables/useAriaLabel.js"
|
|
77
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
78
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
79
|
+
import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId, type LabelProps, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
|
|
80
|
+
|
|
81
|
+
defineOptions({
|
|
82
|
+
name: "lib-recorder",
|
|
83
|
+
inheritAttrs: false,
|
|
84
|
+
})
|
|
85
|
+
const t = useInjectedI18n()
|
|
86
|
+
|
|
87
|
+
const emits = defineEmits<{
|
|
88
|
+
/** Recorder is blurred */
|
|
89
|
+
(e: "recorder:blur", $event: FocusEvent): void
|
|
90
|
+
/** Recorder is clicked. The component's indicator and recorder elements are passed to help filter out those clicks. */
|
|
91
|
+
(e: "recorder:click", { event, indicator, input }: { event: MouseEvent | KeyboardEvent, indicator: HTMLElement, input: HTMLInputElement }): void
|
|
92
|
+
/* User presses enter. Not emitted when multiple values are used. */
|
|
93
|
+
(e: "focus:parent"): void
|
|
94
|
+
}>()
|
|
95
|
+
const fallbackId = getFallbackId()
|
|
96
|
+
// eslint-disable-next-line no-use-before-define
|
|
97
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
98
|
+
recordingTitle: "",
|
|
99
|
+
id: undefined,
|
|
100
|
+
binders: undefined,
|
|
101
|
+
recorder: undefined,
|
|
102
|
+
...baseInteractivePropsDefaults
|
|
103
|
+
})
|
|
104
|
+
/**
|
|
105
|
+
* Puts the element into recording mode if true. See {@link props.recorder}.
|
|
106
|
+
*/
|
|
107
|
+
const recording = defineModel<boolean>("recording", { required: false, default: false })
|
|
108
|
+
|
|
109
|
+
/** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
|
|
110
|
+
const modelValue = defineModel<string>({ required: true })
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
const recorderEl = ref<HTMLInputElement | null>(null)
|
|
114
|
+
const recorderIndicatorEl = ref<HTMLElement | null>(null)
|
|
115
|
+
const canEdit = computed(() => !props.disabled && !props.readonly)
|
|
116
|
+
const tempValue = ref(modelValue.value)
|
|
117
|
+
|
|
118
|
+
watch([() => props.binders, () => props.binders], () => {
|
|
119
|
+
if (recording.value) {
|
|
120
|
+
throw new Error("Component was not designed to allow swapping out of binders/recorders while recording")
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
watch(modelValue, () => {
|
|
125
|
+
tempValue.value = modelValue.value
|
|
126
|
+
})
|
|
127
|
+
const ariaLabel = useAriaLabel(props)
|
|
128
|
+
|
|
129
|
+
const boundListeners: Record<string, any> = {}
|
|
130
|
+
let isBound = false
|
|
131
|
+
|
|
132
|
+
const unbindListeners = (): void => {
|
|
133
|
+
if (!isBound) return
|
|
134
|
+
isBound = false
|
|
135
|
+
if (props.recorder) {
|
|
136
|
+
for (const key of keys(boundListeners)) {
|
|
137
|
+
recorderEl.value?.removeEventListener(key, boundListeners[key])
|
|
138
|
+
delete boundListeners[key]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (props.binders && recorderEl.value) {
|
|
142
|
+
props.binders.unbind(recorderEl.value as HTMLInputElement)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const bindListeners = (): void => {
|
|
146
|
+
if (!props.recorder && !props.binders) {
|
|
147
|
+
throw new Error("Record is true but no recorder or binders props was passed")
|
|
148
|
+
}
|
|
149
|
+
if (props.recorder && props.binders) {
|
|
150
|
+
throw new Error("Recording is true and was passed both a recorder and a binders prop. Both cannot be used at the same time.")
|
|
151
|
+
}
|
|
152
|
+
isBound = true
|
|
153
|
+
if (props.recorder) {
|
|
154
|
+
for (const key of keys(props.recorder)) {
|
|
155
|
+
recorderEl.value?.addEventListener(key, props.recorder[key], { passive: false })
|
|
156
|
+
boundListeners[key] = props.recorder[key]
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (props.binders && recorderEl.value) {
|
|
160
|
+
props.binders.bind(recorderEl.value as HTMLInputElement)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
watchPostEffect(() => {
|
|
165
|
+
if (!canEdit.value) {
|
|
166
|
+
unbindListeners()
|
|
167
|
+
recording.value = false
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
if (recording.value) {
|
|
171
|
+
bindListeners()
|
|
172
|
+
} else {
|
|
173
|
+
if ((props.recorder || props.binders) && isBound) {
|
|
174
|
+
unbindListeners()
|
|
175
|
+
// if we just blur the input then we can't shift+tab backwards
|
|
176
|
+
// this way we can go forwards or backwards without actually focusing since parentEl is not focusable
|
|
177
|
+
// parentEl.value?.focus()
|
|
178
|
+
emits("focus:parent")
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
onBeforeUnmount(() => {
|
|
184
|
+
unbindListeners()
|
|
185
|
+
})
|
|
186
|
+
onMounted(() => {
|
|
187
|
+
if (recording.value) {
|
|
188
|
+
bindListeners()
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
const handleBlurRecorder = (e: FocusEvent): void => {
|
|
193
|
+
if (!canEdit.value) return
|
|
194
|
+
if (props.recorder || props.binders) {
|
|
195
|
+
emits("recorder:blur", e)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const handleClickRecorder = (e: MouseEvent | KeyboardEvent, isSpaceKey: boolean = false): void => {
|
|
200
|
+
if (!canEdit.value) return
|
|
201
|
+
if (!recording.value) {
|
|
202
|
+
recorderEl.value?.focus()
|
|
203
|
+
}
|
|
204
|
+
// toggle if clicking on the recording indicator, otherwise only allow starting recording, so if needed, clicks can be recorded
|
|
205
|
+
if (props.recorder || props.binders) {
|
|
206
|
+
if (isSpaceKey) { return }
|
|
207
|
+
emits("recorder:click", { event: e as MouseEvent, indicator: recorderIndicatorEl.value! as HTMLElement, input: recorderEl.value! as HTMLInputElement })
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
</script>
|
|
212
|
+
<script lang="ts">
|
|
213
|
+
type RealProps =
|
|
214
|
+
& LinkableByIdProps
|
|
215
|
+
& BaseInteractiveProps
|
|
216
|
+
& LabelProps
|
|
217
|
+
& {
|
|
218
|
+
border?: boolean
|
|
219
|
+
/** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
|
|
220
|
+
recordingValue?: string
|
|
221
|
+
/** A title to display on the input div while recording. Is also used as the aria-description. */
|
|
222
|
+
recordingTitle?: string
|
|
223
|
+
/**
|
|
224
|
+
* The recorder object is a series of event listeners to attach to the input div while recording is started. If you need to bind directly to the element, see the `binders` prop.
|
|
225
|
+
*
|
|
226
|
+
* The listeners are then unbound when recording is set to false again.
|
|
227
|
+
*
|
|
228
|
+
* Note that the component does not handle the setting of `recording` (unless the component is disabled), `modelValue`, or `recordingValue` at all and has no mechanism for cancelling a recording. It is left to the recorder listeners and any `recorder:*` handlers to determine what to do.
|
|
229
|
+
*/
|
|
230
|
+
recorder?: undefined | Record<string, any>
|
|
231
|
+
/** This provides a way to manually attach/remove event listeners to/from the element. It is an alternative to the `recorder` prop, see it for more details. Both cannot be specified at the same time.*/
|
|
232
|
+
binders?: undefined | { bind: (el: HTMLElement) => void, unbind: (el: HTMLElement) => void }
|
|
233
|
+
/** The id of the element. If not provided, the id will be generated automatically. */
|
|
234
|
+
id?: string
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
interface Props
|
|
238
|
+
extends
|
|
239
|
+
/** @vue-ignore */
|
|
240
|
+
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
241
|
+
RealProps
|
|
242
|
+
{ }
|
|
243
|
+
</script>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :id="id"
|
|
3
|
+
tabindex="-1"
|
|
4
|
+
:class="twMerge(
|
|
5
|
+
(showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden'),
|
|
6
|
+
darkMode && ' dark',
|
|
7
|
+
($attrs['wrapperAttrs'] as any)?.class
|
|
8
|
+
)"
|
|
9
|
+
v-bind="{ ...($attrs['wrapperAttrs']), attrs:undefined, class: undefined }"
|
|
10
|
+
:ref="handleRef"
|
|
11
|
+
>
|
|
12
|
+
<!-- id root is useful for teleports, so they are at the topmost level where they can still be styled -->
|
|
13
|
+
<!-- See TestControls for why the margins here -->
|
|
14
|
+
<div
|
|
15
|
+
id="root"
|
|
16
|
+
v-bind="{ ...$attrs.attrs, class: undefined, wrapperAttrs: undefined }"
|
|
17
|
+
:class="twMerge( `
|
|
18
|
+
dark:bg-fg
|
|
19
|
+
dark:text-bg
|
|
20
|
+
bg-bg
|
|
21
|
+
text-fg
|
|
22
|
+
`,
|
|
23
|
+
testWrapperMode && `
|
|
24
|
+
px-10
|
|
25
|
+
pb-10
|
|
26
|
+
`,
|
|
27
|
+
!testWrapperMode && `
|
|
28
|
+
min-h-dvh
|
|
29
|
+
flex
|
|
30
|
+
flex-col
|
|
31
|
+
`,
|
|
32
|
+
($attrs as any).attrs?.class)"
|
|
33
|
+
>
|
|
34
|
+
<TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
|
|
35
|
+
<slot/>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { unreachable } from "@alanscodelog/utils/unreachable.js"
|
|
42
|
+
import { type Theme } from "metamorphosis"
|
|
43
|
+
import { type ComponentPublicInstance, computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue"
|
|
44
|
+
|
|
45
|
+
import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js"
|
|
46
|
+
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
47
|
+
import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js"
|
|
48
|
+
import { useSetupI18n } from "../../composables/useSetupI18n.js"
|
|
49
|
+
import { useSetupLocale } from "../../composables/useSetupLocale.js"
|
|
50
|
+
import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js"
|
|
51
|
+
import { theme as defaultTheme } from "../../theme.js"
|
|
52
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
53
|
+
import TestControls from "../TestControls/TestControls.vue"
|
|
54
|
+
|
|
55
|
+
const $attrs = useDivideAttrs(["wrapper"])
|
|
56
|
+
|
|
57
|
+
defineOptions({ name: "root", inheritAttrs: false, suspensible: false })
|
|
58
|
+
const props = withDefaults(defineProps<{
|
|
59
|
+
theme?: Theme
|
|
60
|
+
outline?: boolean
|
|
61
|
+
forceOutline?: boolean
|
|
62
|
+
testWrapperMode?: boolean
|
|
63
|
+
id?: string
|
|
64
|
+
/** You can set a ref to the root element by passing :getRef="_ => el = _" */
|
|
65
|
+
getRef?: (el: HTMLElement | null) => void
|
|
66
|
+
/** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
|
|
67
|
+
isClientSide?: boolean
|
|
68
|
+
useBuiltinTranslations?: boolean
|
|
69
|
+
}>(), {
|
|
70
|
+
theme: undefined,
|
|
71
|
+
testWrapperMode: false,
|
|
72
|
+
outline: true,
|
|
73
|
+
forceOutline: false,
|
|
74
|
+
id: "app",
|
|
75
|
+
getRef: undefined,
|
|
76
|
+
isClientSide: true,
|
|
77
|
+
useBuiltinTranslations: true
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const el = ref<HTMLElement | null>(null)
|
|
81
|
+
|
|
82
|
+
function handleRef(_: Element | ComponentPublicInstance | null): void {
|
|
83
|
+
if (_ !== null && !(_ instanceof HTMLElement)) unreachable()
|
|
84
|
+
el.value = _
|
|
85
|
+
props.getRef?.(_)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const autoOutline = useAccesibilityOutline(el).outline
|
|
89
|
+
|
|
90
|
+
const showOutline = computed(() => (props.outline && autoOutline.value) || props.forceOutline)
|
|
91
|
+
|
|
92
|
+
const theme = computed(() => props.theme ?? defaultTheme)
|
|
93
|
+
const themeCb = (): void => {
|
|
94
|
+
toRaw(theme.value).attach(el.value!)
|
|
95
|
+
}
|
|
96
|
+
if (props.isClientSide) {
|
|
97
|
+
onMounted(() => {
|
|
98
|
+
toRaw(theme.value).on("change", themeCb)
|
|
99
|
+
themeCb()
|
|
100
|
+
})
|
|
101
|
+
onBeforeUnmount(() => {
|
|
102
|
+
toRaw(theme.value).off("change", themeCb)
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const darkModeSetup = useSetupDarkMode({ isClientSide: props.isClientSide })
|
|
107
|
+
|
|
108
|
+
const darkMode = darkModeSetup.darkMode
|
|
109
|
+
|
|
110
|
+
useShowDevOnlyKey()
|
|
111
|
+
|
|
112
|
+
defineExpose({
|
|
113
|
+
darkMode: darkModeSetup,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
if (props.useBuiltinTranslations) {
|
|
117
|
+
const { languageLocale } = useSetupLocale()
|
|
118
|
+
void useSetupI18n({
|
|
119
|
+
locale: languageLocale,
|
|
120
|
+
useBuiltinTranslations: true,
|
|
121
|
+
useDummyMessageSetWhileLoading: true,
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
</script>
|
|
126
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/vue3";
|
|
2
|
+
import * as components from "../index.js.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
component: any;
|
|
5
|
+
title: string;
|
|
6
|
+
args: {
|
|
7
|
+
modelValue: string;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof components.LibSimpleInput>;
|
|
13
|
+
/** Input */
|
|
14
|
+
export declare const Primary: Story;
|
|
15
|
+
/** Has more reasonable min-width inside a flexbox. */
|
|
16
|
+
export declare const InsideAFlexbox: Story;
|
|
17
|
+
export declare const Disabled: any;
|
|
18
|
+
export declare const Readonly: any;
|
|
19
|
+
export declare const Invalid: any;
|
|
20
|
+
/**
|
|
21
|
+
* Intended for being wrapped.
|
|
22
|
+
* Should not have any border or focus outline styles.
|
|
23
|
+
*/
|
|
24
|
+
export declare const Borderless: any;
|
|
25
|
+
export declare const Numerical: any;
|
|
26
|
+
export declare const NumericalInsideAFlexbox: any;
|