@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,162 @@
|
|
|
1
|
+
import { castType } from "@alanscodelog/utils/castType.js";
|
|
2
|
+
import { crop } from "@alanscodelog/utils/crop.js";
|
|
3
|
+
import { indent } from "@alanscodelog/utils/indent.js";
|
|
4
|
+
import { isBlank } from "@alanscodelog/utils/isBlank.js";
|
|
5
|
+
import { pretty } from "@alanscodelog/utils/pretty.js";
|
|
6
|
+
import { setReadOnly } from "@alanscodelog/utils/setReadOnly.js";
|
|
7
|
+
export class NotificationHandler {
|
|
8
|
+
timeout = 5e3;
|
|
9
|
+
debug = false;
|
|
10
|
+
id = 0;
|
|
11
|
+
queue = [];
|
|
12
|
+
history = [];
|
|
13
|
+
maxHistory = 100;
|
|
14
|
+
listeners = [];
|
|
15
|
+
stringifier;
|
|
16
|
+
constructor({
|
|
17
|
+
timeout,
|
|
18
|
+
stringifier,
|
|
19
|
+
maxHistory
|
|
20
|
+
} = {}) {
|
|
21
|
+
if (timeout) this.timeout = timeout;
|
|
22
|
+
if (maxHistory) this.maxHistory = maxHistory;
|
|
23
|
+
if (stringifier) this.stringifier = stringifier;
|
|
24
|
+
}
|
|
25
|
+
_checkEntry(entry) {
|
|
26
|
+
if (entry.cancellable !== void 0 && isBlank(entry.cancellable)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
crop`Cancellable cannot be a blank string:
|
|
29
|
+
${indent(pretty(entry), 5)}
|
|
30
|
+
`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (!entry.options.includes(entry.default)) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
crop`Entry options does not include default option "${entry.default}":
|
|
36
|
+
${indent(pretty(entry), 5)}
|
|
37
|
+
`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (entry.cancellable) {
|
|
41
|
+
if (typeof entry.cancellable === "string" && !entry.options.includes(entry.cancellable)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
crop`Entry options does not include cancellable option "${entry.cancellable}":
|
|
44
|
+
${indent(pretty(entry), 6)}
|
|
45
|
+
`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
if (entry.options.includes("Cancel")) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
crop`You specified that the entry should not be cancellable, but the options include the "Cancel" option:
|
|
52
|
+
${indent(pretty(entry), 6)}
|
|
53
|
+
`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (entry.timeout !== void 0 && !entry.cancellable) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
crop`Cannot timeout notification that is not cancellable:
|
|
60
|
+
${indent(pretty(entry), 5)}
|
|
61
|
+
`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (entry.timeout !== void 0 && entry.requiresAction) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
crop`Cannot timeout notification that requires action:
|
|
67
|
+
${indent(pretty(entry), 5)}
|
|
68
|
+
`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const missingDangerousOption = entry.dangerous.find((option) => !entry.options.includes(option));
|
|
72
|
+
if (entry.dangerous !== void 0 && missingDangerousOption) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
crop`Dangerous options list contains an unknown option "${missingDangerousOption}":
|
|
75
|
+
${indent(pretty(entry), 5)}
|
|
76
|
+
`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
_createEntry(rawEntry) {
|
|
81
|
+
const entry = {
|
|
82
|
+
requiresAction: false,
|
|
83
|
+
options: ["Ok", "Cancel"],
|
|
84
|
+
default: "Ok",
|
|
85
|
+
cancellable: rawEntry.cancellable,
|
|
86
|
+
...rawEntry,
|
|
87
|
+
dangerous: rawEntry.dangerous ?? [],
|
|
88
|
+
timeout: rawEntry.timeout === true ? this.timeout : rawEntry.timeout !== void 0 && rawEntry.timeout !== false ? rawEntry.timeout : void 0
|
|
89
|
+
};
|
|
90
|
+
if (rawEntry.cancellable === true || rawEntry.cancellable === void 0 && entry.options?.includes("Cancel")) {
|
|
91
|
+
entry.cancellable = "Cancel";
|
|
92
|
+
}
|
|
93
|
+
this._checkEntry(entry);
|
|
94
|
+
castType(entry);
|
|
95
|
+
this.id++;
|
|
96
|
+
entry.id = this.id;
|
|
97
|
+
return entry;
|
|
98
|
+
}
|
|
99
|
+
async notify(rawEntry) {
|
|
100
|
+
const entry = this._createEntry(rawEntry);
|
|
101
|
+
entry.promise = new Promise((_resolve) => {
|
|
102
|
+
entry.resolve = _resolve;
|
|
103
|
+
});
|
|
104
|
+
if (entry.timeout !== void 0) {
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
entry.resolve(entry.cancellable);
|
|
107
|
+
}, entry.timeout);
|
|
108
|
+
}
|
|
109
|
+
this.queue.push(entry);
|
|
110
|
+
for (const listener of this.listeners) {
|
|
111
|
+
listener(entry, "added");
|
|
112
|
+
}
|
|
113
|
+
return entry.promise.then((res) => {
|
|
114
|
+
entry.resolution = res;
|
|
115
|
+
for (const listener of this.listeners) {
|
|
116
|
+
listener(entry, "resolved");
|
|
117
|
+
}
|
|
118
|
+
this.history.push(entry);
|
|
119
|
+
if (this.history.length > this.maxHistory) {
|
|
120
|
+
this.history.splice(0, 1);
|
|
121
|
+
for (const listener of this.listeners) {
|
|
122
|
+
listener(entry, "deleted");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.queue.splice(this.queue.indexOf(entry), 1);
|
|
126
|
+
return res;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
static resolveToDefault(notification) {
|
|
130
|
+
notification.resolve(notification.default);
|
|
131
|
+
}
|
|
132
|
+
static dismiss(notification) {
|
|
133
|
+
if (notification.cancellable) {
|
|
134
|
+
notification.resolve(notification.cancellable);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
stringify(notification) {
|
|
138
|
+
if (this.stringifier) return this.stringifier(notification);
|
|
139
|
+
let str = "";
|
|
140
|
+
if (notification.title) str += `${notification.title}
|
|
141
|
+
`;
|
|
142
|
+
str += `${notification.message}
|
|
143
|
+
`;
|
|
144
|
+
if (notification.code) str += `code:${notification.code}
|
|
145
|
+
`;
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
149
|
+
setReadOnly(this, "history", []);
|
|
150
|
+
}
|
|
151
|
+
addNotificationListener(cb) {
|
|
152
|
+
this.listeners.push(cb);
|
|
153
|
+
}
|
|
154
|
+
removeNotificationListener(cb) {
|
|
155
|
+
const exists = this.listeners.indexOf(cb);
|
|
156
|
+
if (exists > -1) {
|
|
157
|
+
this.listeners.splice(exists, 1);
|
|
158
|
+
} else {
|
|
159
|
+
throw new Error(`Listener does not exist: ${cb.toString()}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const addValue: <T>(value: T, values: T[], preventDuplicateValues: boolean) => T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const base64ToImg: (imageSrc: string) => Promise<HTMLImageElement>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const copy: (text: string) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const copy = (text) => {
|
|
2
|
+
if (navigator.clipboard) {
|
|
3
|
+
navigator.clipboard.writeText(text).catch((err) => {
|
|
4
|
+
console.warn(`There was an error copying to the clipboard, please file a bug report.
|
|
5
|
+
${err}`);
|
|
6
|
+
});
|
|
7
|
+
} else {
|
|
8
|
+
console.warn("Could not copy to clipboard, your browser is not supported.");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CalendarDate, ZonedDateTime } from "@internationalized/date";
|
|
2
|
+
/**
|
|
3
|
+
* Takes the given local DATE (ignores the time), and converts it to a UTC (0 offset) date at noon.
|
|
4
|
+
*
|
|
5
|
+
* This should be used to wrap fallback dates for timeless dates, so that the date never changes regardless of the timezone it's converted too.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createNoonUtcDate(date: CalendarDate): ZonedDateTime;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ZonedDateTime } from "@internationalized/date";
|
|
2
|
+
export function createNoonUtcDate(date) {
|
|
3
|
+
const noon = [12, 0, 0];
|
|
4
|
+
const timeZoneOffset = 0;
|
|
5
|
+
const d = new ZonedDateTime(
|
|
6
|
+
date.year,
|
|
7
|
+
date.month,
|
|
8
|
+
date.day,
|
|
9
|
+
"UTC",
|
|
10
|
+
timeZoneOffset,
|
|
11
|
+
...noon
|
|
12
|
+
);
|
|
13
|
+
return d;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A default translation function to use with `useSetupI18n`. Requires at least one set of translation message sets (or a dummy) be loaded (the useSetupI18n function takes care of setting up a temporary dummy if you set `useBuiltinTranslations: true`).
|
|
3
|
+
*
|
|
4
|
+
* It can take a simple replacement object as the second argument, it's keys in the form `{key}` will be replace with the given value.
|
|
5
|
+
*
|
|
6
|
+
* For example:
|
|
7
|
+
* ```js
|
|
8
|
+
* const messages = {
|
|
9
|
+
* "some-message": "This is a {key}",
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* t("some-message", { key: "message" })
|
|
13
|
+
* ```
|
|
14
|
+
* Would return "This is a message".
|
|
15
|
+
*/
|
|
16
|
+
export declare function defaultTranslationFunction(key: string, replacements?: Record<string, any>): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { inject } from "vue";
|
|
2
|
+
import { translationMessagesInjectionKey } from "../composables/useSetupI18n.js";
|
|
3
|
+
export function defaultTranslationFunction(key, replacements) {
|
|
4
|
+
const messages = inject(translationMessagesInjectionKey);
|
|
5
|
+
if (messages === void 0) throw new Error("witchcraft/ui: The default translation function requires the useSetupI18n `useBuiltinTranslations` options to be true. Did you set it?");
|
|
6
|
+
let value = messages.value["witchcraft-ui"][key];
|
|
7
|
+
if (value === void 0) throw new Error(`No translation for key ${key}.`);
|
|
8
|
+
if (replacements !== void 0) {
|
|
9
|
+
for (const [k, val] of Object.entries(replacements)) {
|
|
10
|
+
value = value.replaceAll(`{${k}}`, val);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTimeZoneList(): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasModifiers: (e: KeyboardEvent) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const hasModifiers = (e) => e.ctrlKey || e.altKey || e.shiftKey || e.metaKey;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { addValue } from "./addValue.js.js";
|
|
2
|
+
export { base64ToImg } from "./base64ToImg.js.js";
|
|
3
|
+
export { copy } from "./copy.js.js";
|
|
4
|
+
export { createRecorderHandler } from "./storybook.js.js";
|
|
5
|
+
export { hasModifiers } from "./hasModifiers.js.js";
|
|
6
|
+
export { NotificationHandler } from "./NotificationHandler.js.js";
|
|
7
|
+
export { readFile } from "./readFile.js.js";
|
|
8
|
+
export { ResizeObserverWrapper } from "./resizeObserverWrapper.js.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { addValue } from "./addValue.js";
|
|
2
|
+
export { base64ToImg } from "./base64ToImg.js";
|
|
3
|
+
export { copy } from "./copy.js";
|
|
4
|
+
export { createRecorderHandler } from "./storybook.js";
|
|
5
|
+
export { hasModifiers } from "./hasModifiers.js";
|
|
6
|
+
export { NotificationHandler } from "./NotificationHandler.js";
|
|
7
|
+
export { readFile } from "./readFile.js";
|
|
8
|
+
export { ResizeObserverWrapper } from "./resizeObserverWrapper.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readFile: <TType extends "DataUrl" | "ArrayBuffer" | "BinaryString" | "text" = "DataUrl">(file?: File | Blob, type?: TType) => Promise<TType extends "ArrayBuffer" ? ArrayBuffer : string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const readFile = async (file, type = "DataUrl") => new Promise((resolve, reject) => {
|
|
2
|
+
const reader = new FileReader();
|
|
3
|
+
reader.addEventListener("load", () => {
|
|
4
|
+
resolve(reader.result);
|
|
5
|
+
}, false);
|
|
6
|
+
reader.addEventListener("error", () => {
|
|
7
|
+
reject(new Error(reader.result));
|
|
8
|
+
}, false);
|
|
9
|
+
if (type === "DataUrl") reader.readAsDataURL(file);
|
|
10
|
+
if (type === "ArrayBuffer") reader.readAsArrayBuffer(file);
|
|
11
|
+
if (type === "BinaryString") reader.readAsBinaryString(file);
|
|
12
|
+
if (type === "text") reader.readAsText(file);
|
|
13
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResizeCallback } from "../types/index.js.js";
|
|
2
|
+
export declare class ResizeObserverWrapper {
|
|
3
|
+
observers: WeakMap<Element, Set<ResizeCallback>>;
|
|
4
|
+
observer: ResizeObserver;
|
|
5
|
+
constructor();
|
|
6
|
+
observe(element: Element, callback: ResizeCallback): void;
|
|
7
|
+
unobserve(element: Element, callback: ResizeCallback): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ResizeObserverWrapper {
|
|
2
|
+
observers = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
observer;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.observers = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
this.observer = new ResizeObserver((elements) => {
|
|
7
|
+
for (const element of elements) {
|
|
8
|
+
const { target, contentRect } = element;
|
|
9
|
+
const callbacks = this.observers.get(target);
|
|
10
|
+
if (callbacks) {
|
|
11
|
+
for (const cb of callbacks) {
|
|
12
|
+
cb(contentRect, target);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
observe(element, callback) {
|
|
19
|
+
const entry = this.observers.get(element);
|
|
20
|
+
if (!entry) {
|
|
21
|
+
this.observers.set(element, /* @__PURE__ */ new Set());
|
|
22
|
+
}
|
|
23
|
+
this.observer.observe(element);
|
|
24
|
+
const callbacks = this.observers.get(element);
|
|
25
|
+
callbacks.add(callback);
|
|
26
|
+
}
|
|
27
|
+
unobserve(element, callback) {
|
|
28
|
+
const entry = this.observers.get(element);
|
|
29
|
+
if (!entry) return;
|
|
30
|
+
const callbacks = this.observers.get(element);
|
|
31
|
+
callbacks.delete(callback);
|
|
32
|
+
if (callbacks.size === 0) {
|
|
33
|
+
this.observer.unobserve(element);
|
|
34
|
+
this.observers.delete(element);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
export declare const createRecorderHandler: (recordingValue: Ref<string>, recording: Ref<boolean>, modelValue: Ref<string>, recordingEl: Ref<null | HTMLElement>) => {
|
|
3
|
+
keydown(e: KeyboardEvent): void;
|
|
4
|
+
mousedown(e: MouseEvent): void;
|
|
5
|
+
wheel(e: WheelEvent): void;
|
|
6
|
+
};
|
|
7
|
+
export declare const createRecorderWatchEffect: (recordingValue: Ref<string>, recording: Ref<boolean>, modelValue: Ref<string>, values?: Ref<string[]>) => () => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { hasModifiers } from "./hasModifiers.js";
|
|
2
|
+
export const createRecorderHandler = (recordingValue, recording, modelValue, recordingEl) => ({
|
|
3
|
+
keydown(e) {
|
|
4
|
+
e.preventDefault();
|
|
5
|
+
if (!hasModifiers(e) && e.key === "Escape") {
|
|
6
|
+
recordingValue.value = modelValue.value;
|
|
7
|
+
recording.value = false;
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (!hasModifiers(e) && e.key === "Enter") {
|
|
11
|
+
recording.value = false;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
recordingValue.value += ` ${e.key}`;
|
|
15
|
+
},
|
|
16
|
+
mousedown(e) {
|
|
17
|
+
const target = e.target;
|
|
18
|
+
const el = recordingEl.value;
|
|
19
|
+
if (target === el || el?.contains(target)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
recordingValue.value += ` ${e.button}`;
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
},
|
|
25
|
+
wheel(e) {
|
|
26
|
+
recordingValue.value += ` ${e.deltaY > 0 ? "\u2193" : "\u2191"}`;
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const createRecorderWatchEffect = (recordingValue, recording, modelValue, values) => () => {
|
|
31
|
+
if (!recording.value) {
|
|
32
|
+
if (recordingValue.value) {
|
|
33
|
+
if (values?.value) {
|
|
34
|
+
values.value.push(recordingValue.value);
|
|
35
|
+
modelValue.value = "";
|
|
36
|
+
} else {
|
|
37
|
+
modelValue.value = recordingValue.value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
recordingValue.value = "";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from "./types/index.js.js";
|
|
2
|
+
export * as components from "./components/index.js.js";
|
|
3
|
+
export * as helpers from "./helpers/index.js.js";
|
|
4
|
+
export * as composables from "./composables/index.js.js";
|
|
5
|
+
export * as directives from "./directives/index.js.js";
|
|
6
|
+
export { registerDirectives } from "./vue/registerDirectives.js.js";
|
|
7
|
+
export { registerComponents } from "./vue/registerComponents.js.js";
|
|
8
|
+
export { VueComponentsPlugin } from "./vue/VueComponentsPlugin.js.js";
|
|
9
|
+
import type * as components from "./components/index.js.js";
|
|
10
|
+
type Components = typeof components;
|
|
11
|
+
/**
|
|
12
|
+
* To get global typings, in a global declaration file (e.g. global.d.ts) do:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { GlobalComponentTypes } from "@witchcraft/ui"
|
|
16
|
+
*
|
|
17
|
+
* declare module "@vue/runtime-core" {
|
|
18
|
+
* export interface GlobalComponents extends GlobalComponentTypes { }
|
|
19
|
+
* }
|
|
20
|
+
* export {}
|
|
21
|
+
* ```
|
|
22
|
+
* To be able to pass extra attributes you will have to have a global declaration file like the one the library has ({@link ./global.d.ts}), see https://github.com/vuejs/language-tools/issues/1077#issuecomment-1145960878
|
|
23
|
+
*/
|
|
24
|
+
export type GlobalComponentTypes = {
|
|
25
|
+
[key in keyof Components]: Components[key];
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types/index.js";
|
|
2
|
+
export * as components from "./components/index.js";
|
|
3
|
+
export * as helpers from "./helpers/index.js";
|
|
4
|
+
export * as composables from "./composables/index.js";
|
|
5
|
+
export * as directives from "./directives/index.js";
|
|
6
|
+
export { registerDirectives } from "./vue/registerDirectives.js";
|
|
7
|
+
export { registerComponents } from "./vue/registerComponents.js";
|
|
8
|
+
export { VueComponentsPlugin } from "./vue/VueComponentsPlugin.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isArray } from "@alanscodelog/utils/isArray.js";
|
|
2
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
|
|
3
|
+
import { registerDirectives } from "../../vue/registerDirectives.js";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "components-plugin",
|
|
6
|
+
async setup(nuxtApp) {
|
|
7
|
+
const config = useRuntimeConfig().public.witchcraftUi;
|
|
8
|
+
const app = nuxtApp.vueApp;
|
|
9
|
+
const directives = isArray(config?.directives) ? (await Promise.all(config.directives.map(async (name) => import(`../../directives/${name}.ts`)))).map((_) => Object.values(_)[0]) : await import("../../directives/index.ts");
|
|
10
|
+
registerDirectives(app, Object.values(directives));
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { themeConvertionOpts } from "./themeConvertionOpts.js.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { themeConvertionOpts } from "./themeConvertionOpts.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const themeConvertionOpts = {
|
|
2
|
+
topLevel: ["number-spacing"],
|
|
3
|
+
twTypeMap: { color: "colors" },
|
|
4
|
+
// note, not available yet
|
|
5
|
+
defaultsMap: {
|
|
6
|
+
"color-neutral": "50",
|
|
7
|
+
"color-warning": "500",
|
|
8
|
+
"color-ok": "500",
|
|
9
|
+
"color-error": "500",
|
|
10
|
+
"color-accent": "500"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ErrorW } from "@alanscodelog/utils";
|
|
2
|
+
import { type Ref } from "vue";
|
|
3
|
+
export type ResizableOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Defaults to true.
|
|
6
|
+
*
|
|
7
|
+
* ### true
|
|
8
|
+
* The directive will shrink/expand the columns when the table is resized and will use percentage widths on the table cells. This disables resizing of the last column (from the right handle).
|
|
9
|
+
*
|
|
10
|
+
* Additionally because of the way `table-layout:fixed` works, a min-width cannot be set on the elements via css, so instead, if the table shrinks past `opts.margin * col #`, `min-width` is set on the table until it's resized larger.
|
|
11
|
+
*
|
|
12
|
+
* Note that by definition, the columns are not resizable when this happens.
|
|
13
|
+
*
|
|
14
|
+
* ### false
|
|
15
|
+
*
|
|
16
|
+
* The table can be resized past it's normal width and uses pixel widths on the table cells. You might want to set `overscroll-x: scroll` on a parent wrapping element.
|
|
17
|
+
*
|
|
18
|
+
* This will set the table width to `min-content`, else it doesn't work. Note that it does this after the initial reading/setting of sizes so you can, for example, layout the table with `width: 100%`.
|
|
19
|
+
*/
|
|
20
|
+
fitWidth: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The minimum width a column can have.
|
|
23
|
+
*
|
|
24
|
+
* Can be a number, or "dynamic". When dynamic, the directive attempts to get the width of `.grip` and multiplies it times 3.
|
|
25
|
+
*/
|
|
26
|
+
margin: "dynamic" | number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether resizing is enabled.
|
|
29
|
+
*
|
|
30
|
+
* Can be turned off and all listeners, grips, etc, will be removed.
|
|
31
|
+
*
|
|
32
|
+
* Note that element styles set are not removed.
|
|
33
|
+
*/
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
/** The number of columns. It will be assumed the first colCount elements are the initial widths of the table columns. */
|
|
36
|
+
colCount: number;
|
|
37
|
+
/**
|
|
38
|
+
* A ref that gets filled in with the element width string values by the directive.
|
|
39
|
+
*
|
|
40
|
+
* It can then be used as needed by the component.
|
|
41
|
+
*/
|
|
42
|
+
widths: Ref<string[]>;
|
|
43
|
+
/** The selector to use for the cells. "tr > td" by default. */
|
|
44
|
+
selector: string;
|
|
45
|
+
};
|
|
46
|
+
export type TableColConfig<T = {}> = Record<keyof T, {
|
|
47
|
+
name?: string;
|
|
48
|
+
resizable?: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
export type ResizeCallback = (_rect: DOMRectReadOnly, el: Element) => void;
|
|
51
|
+
export type FileInputError = ErrorW<{
|
|
52
|
+
file: File;
|
|
53
|
+
isValidMimeType: boolean;
|
|
54
|
+
isValidExtension: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
export type HsvaColor = {
|
|
57
|
+
h: number;
|
|
58
|
+
s: number;
|
|
59
|
+
v: number;
|
|
60
|
+
a?: number;
|
|
61
|
+
};
|
|
62
|
+
export type RgbaColor = {
|
|
63
|
+
r: number;
|
|
64
|
+
g: number;
|
|
65
|
+
b: number;
|
|
66
|
+
a?: number;
|
|
67
|
+
};
|
|
68
|
+
export type ScrollNearContainerEdgesOptions = {
|
|
69
|
+
containerEl: Ref<HTMLElement | null>;
|
|
70
|
+
/** Margin inside contianer that allows scrolling. 10 by default. */
|
|
71
|
+
scrollMargin?: number;
|
|
72
|
+
/** Margin around container that still allows scrolling. 0 by defualt. */
|
|
73
|
+
outerScrollMargin?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Controls the scrolling speed.
|
|
76
|
+
*
|
|
77
|
+
* Scroll happens faster the nearer to the outer edge the cursor.
|
|
78
|
+
*
|
|
79
|
+
* This is calculated as a percent (0 near the inner edge, and 1 near the outer edge), which is then multiplied by this multiplier, since moving by less than 1 pixel is quite slow. The default is 4.
|
|
80
|
+
*/
|
|
81
|
+
fastPixelMultiplier?: number;
|
|
82
|
+
/** @deprecated Use fastPixelMultiplier instead. */
|
|
83
|
+
fastPixelAmount?: number;
|
|
84
|
+
useTimer?: boolean;
|
|
85
|
+
timerInterval?: number;
|
|
86
|
+
};
|
|
87
|
+
export type SimpleDOMRect = Omit<DOMRect, "toJSON">;
|
|
88
|
+
export interface IPopupReference {
|
|
89
|
+
getBoundingClientRect: () => SimpleDOMRect;
|
|
90
|
+
}
|
|
91
|
+
export type PopupPosition = {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
maxWidth?: number;
|
|
95
|
+
maxHeight?: number;
|
|
96
|
+
};
|
|
97
|
+
export type PopupSpaceInfo = {
|
|
98
|
+
left: number;
|
|
99
|
+
right: number;
|
|
100
|
+
leftLeft: number;
|
|
101
|
+
rightRight: number;
|
|
102
|
+
leftFromCenter: number;
|
|
103
|
+
rightFromCenter: number;
|
|
104
|
+
topFromCenter: number;
|
|
105
|
+
bottomFromCenter: number;
|
|
106
|
+
top: number;
|
|
107
|
+
bottom: number;
|
|
108
|
+
};
|
|
109
|
+
export type PopupPositioner = (
|
|
110
|
+
/** Reference is only undefined, if you did not specify a button element or use the exposed setReference. The function is still called, because there are other ways you might want to still position the popup (e.g. center-screen or some similar variation). */
|
|
111
|
+
reference: SimpleDOMRect | undefined, popup: SimpleDOMRect | DOMRect, bg: SimpleDOMRect | DOMRect, space: PopupSpaceInfo) => number;
|
|
112
|
+
export type PopupPositionModifier = (pos: PopupPosition,
|
|
113
|
+
/** This will only be called with the reference element as undefined when one of the preferred positions is center-screen or it's a function. */
|
|
114
|
+
reference: SimpleDOMRect | undefined, popup: SimpleDOMRect | DOMRect, bg: SimpleDOMRect | DOMRect, space: PopupSpaceInfo) => PopupPosition;
|
|
115
|
+
export type SingleDate = Date | undefined;
|
|
116
|
+
export type RangeDate = {
|
|
117
|
+
start?: SingleDate;
|
|
118
|
+
end?: SingleDate;
|
|
119
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
2
|
+
const _twMergeExtend = {
|
|
3
|
+
extend: {
|
|
4
|
+
classGroups: {
|
|
5
|
+
"focus-outline": [{ "focus-outline": ["", "no-offset", "none"] }]
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export const twMerge = extendTailwindMerge(_twMergeExtend);
|
|
10
|
+
export const twMergeExtend = _twMergeExtend;
|