@witchcraft/ui 0.0.1 → 0.1.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 +18 -28
- package/dist/module.d.mts +3 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +21 -12
- package/dist/runtime/assets/base.css +1 -1
- package/dist/runtime/assets/locales/en.json +2 -2
- package/dist/runtime/assets/tailwind.css +1 -1
- package/dist/runtime/assets/utils.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.js +1 -1
- package/dist/runtime/components/Aria/Aria.vue +5 -9
- package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
- package/dist/runtime/components/Icon/Icon.vue +12 -28
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +93 -117
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +50 -66
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +69 -106
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
- package/dist/runtime/components/Template/NAME.vue +15 -36
- package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
- package/dist/runtime/components/TestControls/TestControls.vue +7 -10
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/index.d.ts +12 -11
- package/dist/runtime/components/index.js +12 -11
- package/dist/runtime/components/shared/props.d.ts +81 -16
- package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
- package/dist/runtime/composables/index.d.ts +5 -0
- package/dist/runtime/composables/index.js +5 -0
- package/dist/runtime/composables/useDivideAttrs.js +1 -0
- package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
- package/dist/runtime/composables/useDragWithThreshold.js +40 -0
- package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
- package/dist/runtime/composables/usePreHydrationValue.js +15 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
- package/dist/runtime/composables/useSetupI18n.js +5 -1
- package/dist/runtime/composables/useSuggestions.d.ts +7 -5
- package/dist/runtime/composables/useSuggestions.js +94 -57
- package/dist/runtime/directives/vResizableCols.js +92 -84
- package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
- package/dist/runtime/helpers/index.d.ts +3 -1
- package/dist/runtime/helpers/index.js +3 -1
- package/dist/runtime/types/index.d.ts +6 -0
- package/dist/runtime/utils/notifyIfError.d.ts +14 -0
- package/dist/runtime/utils/notifyIfError.js +29 -0
- package/dist/types.d.mts +2 -6
- package/package.json +27 -29
- package/src/module.ts +31 -12
- package/src/runtime/assets/base.css +10 -1
- package/src/runtime/assets/locales/en.json +2 -2
- package/src/runtime/assets/tailwind.css +1 -1
- package/src/runtime/assets/{style.css → utils.css} +86 -4
- package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +10 -6
- package/src/runtime/components/LibButton/LibButton.vue +41 -47
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
- package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
- package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
- package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
- package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
- package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
- package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
- package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
- package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
- package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
- package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
- package/src/runtime/components/LibTable/LibTable.vue +8 -9
- package/src/runtime/components/Scrolling.stories.ts +58 -0
- package/src/runtime/components/Template/NAME.vue +1 -1
- package/src/runtime/components/TestControls/TestControls.vue +1 -1
- package/src/runtime/components/index.ts +12 -12
- package/src/runtime/components/shared/props.ts +82 -19
- package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
- package/src/runtime/composables/index.ts +5 -0
- package/src/runtime/composables/useDarkMode.ts +2 -2
- package/src/runtime/composables/useDivideAttrs.ts +1 -0
- package/src/runtime/composables/useDragWithThreshold.ts +108 -0
- package/src/runtime/composables/usePreHydrationValue.ts +30 -0
- package/src/runtime/composables/useSetupI18n.ts +8 -2
- package/src/runtime/composables/useSuggestions.ts +92 -45
- package/src/runtime/directives/vResizableCols.ts +82 -74
- package/src/runtime/helpers/NotificationHandler.ts +5 -0
- package/src/runtime/helpers/index.ts +3 -1
- package/src/runtime/types/index.ts +5 -0
- package/src/runtime/utils/notifyIfError.ts +45 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -34
- package/dist/runtime/assets/style.css +0 -1
- package/dist/runtime/components/Focus.stories.d.ts +0 -11
- package/dist/runtime/components/Focus.stories.js +0 -53
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
- package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
- package/dist/runtime/components/LibInput/LibInput.stories.d.ts +0 -33
- package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -60
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
- package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
- package/dist/runtime/components/reset.stories.d.ts +0 -5
- package/dist/runtime/components/reset.stories.js +0 -19
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/runtime/helpers/addValue.d.ts +0 -1
- package/dist/runtime/helpers/addValue.js +0 -8
- package/dist/types.d.ts +0 -7
- package/src/runtime/components/LibInput/LibInput.vue +0 -372
- package/src/runtime/helpers/addValue.ts +0 -10
- /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HsvaColor, RgbaColor } from "../../types/index.js.js";
|
|
2
|
+
import { type LabelProps, type LinkableByIdProps } from "../shared/props.js.js";
|
|
3
|
+
type __VLS_Props = LabelProps & LinkableByIdProps & {
|
|
4
|
+
allowAlpha?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The precision of the rgba string representation of the color. Defaults to 3. Extra trailing zeros are removed for a prettier number.
|
|
7
|
+
*
|
|
8
|
+
* Does not affect the number saved unless the user manually edits the color.
|
|
9
|
+
*
|
|
10
|
+
* Ignored if `customRepresentation` is set.
|
|
11
|
+
*/
|
|
12
|
+
stringPrecision?: number;
|
|
13
|
+
/** Allows overriding the string representation of the color. Useful for using a different representation than rgba (e.g. hex). The fromStringToHsva part is rarely needed as the colorjs.io library can normally parse the color. Returning undefined signals an error. */
|
|
14
|
+
customRepresentation?: {
|
|
15
|
+
fromHsvaToString: (hsva: HsvaColor, includeAlpha: boolean) => string;
|
|
16
|
+
fromStringToHsva?: (string: string) => HsvaColor | undefined;
|
|
17
|
+
};
|
|
18
|
+
border?: boolean;
|
|
19
|
+
/** Modify what the user copies to the clipboard. */
|
|
20
|
+
copyTransform?: (val: HsvaColor, stringVal: string) => any;
|
|
21
|
+
valid?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
24
|
+
modelValue?: RgbaColor;
|
|
25
|
+
"tempValue"?: RgbaColor | undefined;
|
|
26
|
+
};
|
|
27
|
+
declare var __VLS_1: {}, __VLS_27: {};
|
|
28
|
+
type __VLS_Slots = {} & {
|
|
29
|
+
input?: (props: typeof __VLS_1) => any;
|
|
30
|
+
} & {
|
|
31
|
+
buttons?: (props: typeof __VLS_27) => any;
|
|
32
|
+
};
|
|
33
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
34
|
+
"update:modelValue": (value: RgbaColor) => any;
|
|
35
|
+
"update:tempValue": (value: RgbaColor | undefined) => any;
|
|
36
|
+
} & {
|
|
37
|
+
cancel: () => any;
|
|
38
|
+
save: (val: RgbaColor) => any;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
40
|
+
"onUpdate:modelValue"?: ((value: RgbaColor) => any) | undefined;
|
|
41
|
+
onCancel?: (() => any) | undefined;
|
|
42
|
+
onSave?: ((val: RgbaColor) => any) | undefined;
|
|
43
|
+
"onUpdate:tempValue"?: ((value: RgbaColor | undefined) => any) | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
border: boolean;
|
|
46
|
+
valid: boolean;
|
|
47
|
+
allowAlpha: boolean;
|
|
48
|
+
stringPrecision: number;
|
|
49
|
+
customRepresentation: {
|
|
50
|
+
fromHsvaToString: (hsva: HsvaColor, includeAlpha: boolean) => string;
|
|
51
|
+
fromStringToHsva?: (string: string) => HsvaColor | undefined;
|
|
52
|
+
};
|
|
53
|
+
copyTransform: (val: HsvaColor, stringVal: string) => any;
|
|
54
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
55
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
56
|
+
export default _default;
|
|
57
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
58
|
+
new (): {
|
|
59
|
+
$slots: S;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { clampNumber } from "@alanscodelog/utils/clampNumber.js";
|
|
2
|
+
import Color from "colorjs.io";
|
|
3
|
+
export function safeConvertToHsva(val, allowAlpha) {
|
|
4
|
+
try {
|
|
5
|
+
const color = typeof val === "string" ? new Color(val) : new Color("srgb", [val.r / 255, val.g / 255, val.b / 255], allowAlpha ? val.a : 1);
|
|
6
|
+
const hsv = color.hsv;
|
|
7
|
+
if (!hsv || hsv[1] === void 0 || hsv[2] === void 0) return void 0;
|
|
8
|
+
const final = {
|
|
9
|
+
h: clampNumber(hsv[0] ?? 0, 0, Number.MAX_SAFE_INTEGER),
|
|
10
|
+
s: clampNumber(hsv[1], 0, 100),
|
|
11
|
+
v: clampNumber(hsv[2], 0, 100),
|
|
12
|
+
a: clampNumber(allowAlpha ? color.alpha : 1, 0, 1)
|
|
13
|
+
};
|
|
14
|
+
return final;
|
|
15
|
+
} catch {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { clampNumber } from "@alanscodelog/utils/clampNumber.js";
|
|
2
|
+
import Color from "colorjs.io";
|
|
3
|
+
export function safeConvertToRgba(val, allowAlpha) {
|
|
4
|
+
try {
|
|
5
|
+
const color = typeof val === "string" ? new Color(val) : new Color("hsv", [val.h, val.s, val.v], allowAlpha ? val.a : 1);
|
|
6
|
+
const rgb = color.srgb;
|
|
7
|
+
if (!rgb || rgb[0] === void 0 || rgb[1] === void 0 || rgb[2] === void 0) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
r: clampNumber(rgb[0] / 1 * 255, 0, 255),
|
|
10
|
+
g: clampNumber(rgb[1] / 1 * 255, 0, 255),
|
|
11
|
+
b: clampNumber(rgb[2] / 1 * 255, 0, 255),
|
|
12
|
+
a: clampNumber(allowAlpha ? color.alpha : 1, 0, 1)
|
|
13
|
+
};
|
|
14
|
+
} catch {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { truncate } from "./truncate.js";
|
|
2
|
+
export function toLowPrecisionRgbaString(rgba, withAlpha, precision) {
|
|
3
|
+
const r = truncate(rgba.r, precision);
|
|
4
|
+
const g = truncate(rgba.g, precision);
|
|
5
|
+
const b = truncate(rgba.b, precision);
|
|
6
|
+
const a = rgba.a !== void 0 ? truncate(rgba.a, precision) : void 0;
|
|
7
|
+
return withAlpha ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function truncate(val: number, precision: number): string;
|
|
@@ -1,95 +1,73 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<lib-button
|
|
3
|
-
v-bind="{...$attrs, class:
|
|
4
|
-
:class="
|
|
3
|
+
v-bind="{ ...$attrs, class: void 0 }"
|
|
4
|
+
:class="!$attrs.unstyle && twMerge(
|
|
5
|
+
`
|
|
6
|
+
dark-mode-switcher
|
|
5
7
|
rounded-full
|
|
6
8
|
after:rounded-full
|
|
7
9
|
`,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
$attrs?.class
|
|
11
|
+
)"
|
|
10
12
|
:title="`${t('dark-mode-switcher.title')}${t(`dark-mode-switcher.${darkModeState}`)}`"
|
|
11
|
-
:label="showLabel
|
|
12
|
-
? t(`dark-mode-switcher.${darkModeState}`)
|
|
13
|
-
: ''
|
|
14
|
-
"
|
|
15
13
|
@click="cycleDarkMode"
|
|
16
14
|
>
|
|
15
|
+
<!-- content-vertical-holder will keep the icon the height of a text line regardless of the svg used -->
|
|
17
16
|
<template #icon>
|
|
18
17
|
<icon
|
|
19
|
-
v-if="darkModeState==='dark'"
|
|
20
|
-
class="w-[1em] flex items-center"
|
|
18
|
+
v-if="darkModeState === 'dark'"
|
|
19
|
+
class="w-[1em] flex items-center content-vertical-holder"
|
|
21
20
|
>
|
|
22
21
|
<i-fa-solid-moon/>
|
|
23
22
|
</icon>
|
|
24
23
|
<icon
|
|
25
|
-
v-else-if="darkModeState==='light'"
|
|
26
|
-
class="w-[1em]"
|
|
24
|
+
v-else-if="darkModeState === 'light'"
|
|
25
|
+
class="w-[1em] content-vertical-holder"
|
|
27
26
|
>
|
|
28
27
|
<i-ph-sun-bold/>
|
|
29
28
|
</icon>
|
|
30
29
|
<icon
|
|
31
30
|
v-else
|
|
32
|
-
class="w-[1em]"
|
|
31
|
+
class="w-[1em] content-vertical-holder"
|
|
33
32
|
>
|
|
34
33
|
<i-fa6-solid-circle-half-stroke/>
|
|
35
34
|
</icon>
|
|
36
35
|
</template>
|
|
36
|
+
<template #default v-if="showLabel">
|
|
37
|
+
<div class="dark-mode-switcher--label pr-[2px]">
|
|
38
|
+
{{ t(`dark-mode-switcher.${darkModeState}`) }}
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
37
41
|
</lib-button>
|
|
38
42
|
</template>
|
|
39
|
-
<script lang="ts" setup>
|
|
40
|
-
import { type ButtonHTMLAttributes,onMounted,useAttrs, watch } from "vue"
|
|
41
|
-
|
|
42
|
-
import { useInjectedDarkMode } from "../../composables/useInjectedDarkMode.js"
|
|
43
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
44
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
45
|
-
import Icon from "../Icon/Icon.vue"
|
|
46
|
-
import LibButton from "../LibButton/LibButton.vue"
|
|
47
|
-
import type { TailwindClassProp } from "../shared/props.js"
|
|
48
|
-
|
|
49
|
-
const t = useInjectedI18n()
|
|
50
|
-
|
|
51
|
-
const emit = defineEmits<{
|
|
52
|
-
/** Emits whether dark mode should be enabled. */
|
|
53
|
-
(e: "update:darkMode", value: boolean): void
|
|
54
|
-
/** Emits the change, but as a state string (dark, light, system) */
|
|
55
|
-
(e: "update:darkModeState", value: "dark" | "light" | "system"): void
|
|
56
|
-
}>()
|
|
57
|
-
const $attrs = useAttrs()
|
|
58
|
-
|
|
59
|
-
// eslint-disable-next-line no-use-before-define
|
|
60
|
-
withDefaults(defineProps<Props>(), { })
|
|
61
|
-
|
|
62
43
|
|
|
44
|
+
<script setup>
|
|
45
|
+
import { onMounted, useAttrs, watch } from "vue";
|
|
46
|
+
import { useInjectedDarkMode } from "../../composables/useInjectedDarkMode.js";
|
|
47
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js";
|
|
48
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
49
|
+
import Icon from "../Icon/Icon.vue";
|
|
50
|
+
import LibButton from "../LibButton/LibButton.vue";
|
|
51
|
+
const t = useInjectedI18n();
|
|
52
|
+
const emit = defineEmits(["update:darkMode", "update:darkModeState"]);
|
|
53
|
+
const $attrs = useAttrs();
|
|
54
|
+
defineProps({
|
|
55
|
+
showLabel: { type: Boolean, required: false, default: true }
|
|
56
|
+
});
|
|
63
57
|
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} = useInjectedDarkMode()
|
|
68
|
-
|
|
69
|
-
watch(
|
|
70
|
-
watch(darkModeState, value => emit("update:darkModeState", value))
|
|
71
|
-
|
|
58
|
+
darkMode,
|
|
59
|
+
cycleDarkMode,
|
|
60
|
+
darkModeState
|
|
61
|
+
} = useInjectedDarkMode();
|
|
62
|
+
watch(darkMode, (value) => emit("update:darkMode", value));
|
|
63
|
+
watch(darkModeState, (value) => emit("update:darkModeState", value));
|
|
72
64
|
onMounted(() => {
|
|
73
|
-
|
|
74
|
-
})
|
|
65
|
+
emit("update:darkMode", darkMode.value);
|
|
66
|
+
});
|
|
75
67
|
</script>
|
|
76
|
-
<script lang="ts">
|
|
77
|
-
export default {
|
|
78
|
-
name: "lib-dark-mode-switcher"
|
|
79
|
-
}
|
|
80
|
-
type RealProps = {
|
|
81
|
-
showLabel?: boolean
|
|
82
|
-
}
|
|
83
68
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
& TailwindClassProp
|
|
89
|
-
& {
|
|
90
|
-
disabled?: boolean
|
|
91
|
-
unstyle?: boolean
|
|
92
|
-
}>,
|
|
93
|
-
RealProps
|
|
94
|
-
{ }
|
|
69
|
+
<script>
|
|
70
|
+
export default {
|
|
71
|
+
name: "lib-dark-mode-switcher"
|
|
72
|
+
};
|
|
95
73
|
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes } from "vue";
|
|
2
|
+
import type { TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:darkMode": (value: boolean) => any;
|
|
5
|
+
"update:darkModeState": (value: "system" | "dark" | "light") => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
7
|
+
"onUpdate:darkMode"?: ((value: boolean) => any) | undefined;
|
|
8
|
+
"onUpdate:darkModeState"?: ((value: "system" | "dark" | "light") => any) | undefined;
|
|
9
|
+
}>, {
|
|
10
|
+
showLabel: boolean;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type RealProps = {
|
|
14
|
+
showLabel?: boolean;
|
|
15
|
+
};
|
|
16
|
+
interface Props extends
|
|
17
|
+
/** @vue-ignore */
|
|
18
|
+
Partial<Omit<ButtonHTMLAttributes, "class" | "color" | "disabled"> & TailwindClassProp & {
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
unstyle?: boolean;
|
|
21
|
+
}>, RealProps {
|
|
22
|
+
}
|
|
@@ -1,67 +1,33 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import { getLocalTimeZone } from "@internationalized/date"
|
|
3
|
-
import { computed, useAttrs } from "vue"
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fallbackDate?: Date
|
|
18
|
-
/** The local user's timezone, defaults to @internationalized/date's getLocalTimeZone(). */
|
|
19
|
-
timeZone?: string
|
|
20
|
-
}>(), {
|
|
21
|
-
showTime: false,
|
|
22
|
-
id: undefined,
|
|
23
|
-
fallbackDate: () => new Date(),
|
|
24
|
-
timeZone: getLocalTimeZone()
|
|
25
|
-
})
|
|
26
|
-
const fallbackId = getFallbackId()
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* modelValue can be undefined or an object with start/end undefined, but it must be passed, otherwise we can't tell the difference between a single date and a range date.
|
|
30
|
-
*
|
|
31
|
-
* In the case of an undefined date, the current date at NOON UTC will be used to avoid the date changing.
|
|
32
|
-
*
|
|
33
|
-
* The @internationalized/date library's fromDate function is used internally to convert the date given (should be UTC) to the local time zone. It's converted back via it's toDate function.
|
|
34
|
-
*/
|
|
35
|
-
const date = defineModel<SingleDate | RangeDate>({ required: true })
|
|
36
|
-
const isRange = computed(() => date.value !== undefined && !(date.value instanceof Date))
|
|
37
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { getLocalTimeZone } from "@internationalized/date";
|
|
3
|
+
import { computed, useAttrs } from "vue";
|
|
4
|
+
import LibRangeDatePicker from "./LibRangeDatePicker.vue";
|
|
5
|
+
import LibSingleDatePicker from "./LibSingleDatePicker.vue";
|
|
6
|
+
import { getFallbackId } from "../shared/props.js";
|
|
7
|
+
const attrs = useAttrs();
|
|
8
|
+
defineProps({
|
|
9
|
+
showTime: { type: Boolean, required: false, default: false },
|
|
10
|
+
id: { type: String, required: false, default: void 0 },
|
|
11
|
+
fallbackDate: { type: Date, required: false, default: () => /* @__PURE__ */ new Date() },
|
|
12
|
+
timeZone: { type: String, required: false, default: getLocalTimeZone() }
|
|
13
|
+
});
|
|
14
|
+
const fallbackId = getFallbackId();
|
|
15
|
+
const date = defineModel({ type: null, ...{ required: true } });
|
|
16
|
+
const isRange = computed(() => date.value !== void 0 && !(date.value instanceof Date));
|
|
38
17
|
</script>
|
|
39
18
|
|
|
40
19
|
<template>
|
|
41
|
-
<
|
|
42
|
-
v-if="!isRange"
|
|
43
|
-
v-bind="attrs"
|
|
44
|
-
:id="id ?? fallbackId"
|
|
45
|
-
:use-time="showTime"
|
|
46
|
-
:time-zone="timeZone"
|
|
47
|
-
:fallback-date="fallbackDate"
|
|
48
|
-
v-model="date as SingleDate"
|
|
49
|
-
>
|
|
50
|
-
<template #default="slotProps">
|
|
51
|
-
<slot v-bind="slotProps"/>
|
|
52
|
-
</template>
|
|
53
|
-
</LibSingleDatePicker>
|
|
54
|
-
<LibRangeDatePicker
|
|
55
|
-
v-else
|
|
20
|
+
<component
|
|
56
21
|
:id="id ?? fallbackId"
|
|
57
22
|
v-bind="attrs"
|
|
58
23
|
:use-time="showTime"
|
|
59
24
|
:time-zone="timeZone"
|
|
60
25
|
:fallback-date="fallbackDate"
|
|
61
|
-
|
|
26
|
+
:is="isRange ? LibRangeDatePicker : LibSingleDatePicker"
|
|
27
|
+
v-model="date"
|
|
62
28
|
>
|
|
63
29
|
<template #default="slotProps">
|
|
64
30
|
<slot v-bind="slotProps"/>
|
|
65
31
|
</template>
|
|
66
|
-
</
|
|
32
|
+
</component>
|
|
67
33
|
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RangeDate, SingleDate } from "../../types/index.js.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
showTime?: boolean;
|
|
4
|
+
id?: string;
|
|
5
|
+
/** The fallback suggested date when the modelValue is undefined (it will not update modelValue, it only serves as a suggestions and is used internally in the temporary value). If ignoring the time element, you should probably use the {@link createNoonTodayUtc} function (`createNonTodayUtc().toDate(())`) in the helpers, otherwise `new Date()` (the default) will do. */
|
|
6
|
+
fallbackDate?: Date;
|
|
7
|
+
/** The local user's timezone, defaults to @internationalized/date's getLocalTimeZone(). */
|
|
8
|
+
timeZone?: string;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
11
|
+
/**
|
|
12
|
+
* modelValue can be undefined or an object with start/end undefined, but it must be passed, otherwise we can't tell the difference between a single date and a range date.
|
|
13
|
+
*
|
|
14
|
+
* In the case of an undefined date, the current date at NOON UTC will be used to avoid the date changing.
|
|
15
|
+
*
|
|
16
|
+
* The @internationalized/date library's fromDate function is used internally to convert the date given (should be UTC) to the local time zone. It's converted back via it's toDate function.
|
|
17
|
+
*/
|
|
18
|
+
modelValue: SingleDate | RangeDate;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_8: any;
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_8) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"update:modelValue": (value: SingleDate | RangeDate) => any;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
27
|
+
"onUpdate:modelValue"?: ((value: SingleDate | RangeDate) => any) | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
id: string;
|
|
30
|
+
fallbackDate: Date;
|
|
31
|
+
timeZone: string;
|
|
32
|
+
showTime: boolean;
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
35
|
+
export default _default;
|
|
36
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
37
|
+
new (): {
|
|
38
|
+
$slots: S;
|
|
39
|
+
};
|
|
40
|
+
};
|