@quaffui/quaff 0.1.0-prealpha
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/LICENSE +9 -0
- package/README.md +43 -0
- package/dist/components/avatar/QAvatar.svelte +43 -0
- package/dist/components/avatar/QAvatar.svelte.d.ts +27 -0
- package/dist/components/avatar/docs.d.ts +2 -0
- package/dist/components/avatar/docs.js +22 -0
- package/dist/components/avatar/docs.props.d.ts +8 -0
- package/dist/components/avatar/docs.props.js +34 -0
- package/dist/components/avatar/index.scss +88 -0
- package/dist/components/avatar/props.d.ts +25 -0
- package/dist/components/avatar/props.js +1 -0
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +18 -0
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +23 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +59 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +26 -0
- package/dist/components/breadcrumbs/docs.d.ts +2 -0
- package/dist/components/breadcrumbs/docs.js +16 -0
- package/dist/components/breadcrumbs/docs.props.d.ts +16 -0
- package/dist/components/breadcrumbs/docs.props.js +84 -0
- package/dist/components/breadcrumbs/index.scss +20 -0
- package/dist/components/breadcrumbs/props.d.ts +56 -0
- package/dist/components/breadcrumbs/props.js +1 -0
- package/dist/components/button/QBtn.svelte +59 -0
- package/dist/components/button/QBtn.svelte.d.ts +32 -0
- package/dist/components/button/docs.d.ts +2 -0
- package/dist/components/button/docs.js +22 -0
- package/dist/components/button/docs.props.d.ts +8 -0
- package/dist/components/button/docs.props.js +82 -0
- package/dist/components/button/index.scss +78 -0
- package/dist/components/button/props.d.ts +54 -0
- package/dist/components/button/props.js +1 -0
- package/dist/components/card/QCard.svelte +23 -0
- package/dist/components/card/QCard.svelte.d.ts +26 -0
- package/dist/components/card/QCardActions.svelte +18 -0
- package/dist/components/card/QCardActions.svelte.d.ts +22 -0
- package/dist/components/card/QCardSection.svelte +14 -0
- package/dist/components/card/QCardSection.svelte.d.ts +23 -0
- package/dist/components/card/docs.d.ts +4 -0
- package/dist/components/card/docs.js +46 -0
- package/dist/components/card/docs.props.d.ts +24 -0
- package/dist/components/card/docs.props.js +62 -0
- package/dist/components/card/index.scss +53 -0
- package/dist/components/card/props.d.ts +44 -0
- package/dist/components/card/props.js +1 -0
- package/dist/components/checkbox/QCheckbox.svelte +14 -0
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +21 -0
- package/dist/components/checkbox/docs.d.ts +2 -0
- package/dist/components/checkbox/docs.js +17 -0
- package/dist/components/checkbox/docs.props.d.ts +8 -0
- package/dist/components/checkbox/docs.props.js +26 -0
- package/dist/components/checkbox/index.scss +3 -0
- package/dist/components/checkbox/props.d.ts +17 -0
- package/dist/components/checkbox/props.js +1 -0
- package/dist/components/chip/QChip.svelte +62 -0
- package/dist/components/chip/QChip.svelte.d.ts +35 -0
- package/dist/components/chip/docs.d.ts +2 -0
- package/dist/components/chip/docs.js +30 -0
- package/dist/components/chip/docs.props.d.ts +8 -0
- package/dist/components/chip/docs.props.js +90 -0
- package/dist/components/chip/index.scss +83 -0
- package/dist/components/chip/props.d.ts +59 -0
- package/dist/components/chip/props.js +1 -0
- package/dist/components/codeBlock/QCodeBlock.svelte +71 -0
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +23 -0
- package/dist/components/codeBlock/docs.props.d.ts +8 -0
- package/dist/components/codeBlock/docs.props.js +34 -0
- package/dist/components/codeBlock/props.d.ts +20 -0
- package/dist/components/codeBlock/props.js +1 -0
- package/dist/components/dialog/QDialog.svelte +80 -0
- package/dist/components/dialog/QDialog.svelte.d.ts +37 -0
- package/dist/components/dialog/docs.d.ts +2 -0
- package/dist/components/dialog/docs.js +11 -0
- package/dist/components/dialog/docs.props.d.ts +16 -0
- package/dist/components/dialog/docs.props.js +148 -0
- package/dist/components/dialog/index.scss +27 -0
- package/dist/components/dialog/props.d.ts +45 -0
- package/dist/components/dialog/props.js +1 -0
- package/dist/components/drawer/QDrawer.svelte +87 -0
- package/dist/components/drawer/QDrawer.svelte.d.ts +39 -0
- package/dist/components/drawer/docs.d.ts +2 -0
- package/dist/components/drawer/docs.js +11 -0
- package/dist/components/drawer/docs.props.d.ts +8 -0
- package/dist/components/drawer/docs.props.js +106 -0
- package/dist/components/drawer/index.scss +54 -0
- package/dist/components/drawer/props.d.ts +70 -0
- package/dist/components/drawer/props.js +1 -0
- package/dist/components/footer/QFooter.svelte +14 -0
- package/dist/components/footer/QFooter.svelte.d.ts +24 -0
- package/dist/components/footer/docs.d.ts +2 -0
- package/dist/components/footer/docs.js +11 -0
- package/dist/components/footer/docs.props.d.ts +8 -0
- package/dist/components/footer/docs.props.js +34 -0
- package/dist/components/footer/index.scss +5 -0
- package/dist/components/footer/props.d.ts +23 -0
- package/dist/components/footer/props.js +1 -0
- package/dist/components/icon/QIcon.svelte +40 -0
- package/dist/components/icon/QIcon.svelte.d.ts +28 -0
- package/dist/components/icon/docs.d.ts +2 -0
- package/dist/components/icon/docs.js +11 -0
- package/dist/components/icon/docs.props.d.ts +8 -0
- package/dist/components/icon/docs.props.js +66 -0
- package/dist/components/icon/index.scss +18 -0
- package/dist/components/icon/props.d.ts +45 -0
- package/dist/components/icon/props.js +1 -0
- package/dist/components/index.d.ts +29 -0
- package/dist/components/index.js +29 -0
- package/dist/components/input/QInput.svelte +81 -0
- package/dist/components/input/QInput.svelte.d.ts +32 -0
- package/dist/components/input/docs.d.ts +2 -0
- package/dist/components/input/docs.js +83 -0
- package/dist/components/input/docs.props.d.ts +8 -0
- package/dist/components/input/docs.props.js +90 -0
- package/dist/components/input/index.scss +3 -0
- package/dist/components/input/props.d.ts +27 -0
- package/dist/components/input/props.js +13 -0
- package/dist/components/layout/QLayout.svelte +88 -0
- package/dist/components/layout/QLayout.svelte.d.ts +57 -0
- package/dist/components/layout/docs.d.ts +2 -0
- package/dist/components/layout/docs.js +11 -0
- package/dist/components/layout/docs.props.d.ts +8 -0
- package/dist/components/layout/docs.props.js +58 -0
- package/dist/components/layout/index.scss +370 -0
- package/dist/components/layout/props.d.ts +41 -0
- package/dist/components/layout/props.js +1 -0
- package/dist/components/list/QItem.svelte +60 -0
- package/dist/components/list/QItem.svelte.d.ts +34 -0
- package/dist/components/list/QItemSection.svelte +47 -0
- package/dist/components/list/QItemSection.svelte.d.ts +25 -0
- package/dist/components/list/QList.svelte +23 -0
- package/dist/components/list/QList.svelte.d.ts +36 -0
- package/dist/components/list/docs.props.d.ts +40 -0
- package/dist/components/list/docs.props.js +226 -0
- package/dist/components/list/index.scss +114 -0
- package/dist/components/list/props.d.ts +33 -0
- package/dist/components/list/props.js +25 -0
- package/dist/components/private/ContextReseter.svelte +13 -0
- package/dist/components/private/ContextReseter.svelte.d.ts +18 -0
- package/dist/components/private/QApi.svelte +142 -0
- package/dist/components/private/QApi.svelte.d.ts +17 -0
- package/dist/components/private/QDocs.svelte +66 -0
- package/dist/components/private/QDocs.svelte.d.ts +21 -0
- package/dist/components/private/QDocsSection.svelte +32 -0
- package/dist/components/private/QDocsSection.svelte.d.ts +29 -0
- package/dist/components/progress/QCircularProgress.svelte +26 -0
- package/dist/components/progress/QCircularProgress.svelte.d.ts +22 -0
- package/dist/components/progress/QLinearProgress.svelte +20 -0
- package/dist/components/progress/QLinearProgress.svelte.d.ts +22 -0
- package/dist/components/progress/docs.props.d.ts +8 -0
- package/dist/components/progress/docs.props.js +26 -0
- package/dist/components/progress/index.scss +50 -0
- package/dist/components/progress/props.d.ts +20 -0
- package/dist/components/progress/props.js +7 -0
- package/dist/components/radio/QRadio.svelte +14 -0
- package/dist/components/radio/QRadio.svelte.d.ts +22 -0
- package/dist/components/radio/docs.d.ts +2 -0
- package/dist/components/radio/docs.js +39 -0
- package/dist/components/radio/docs.props.d.ts +8 -0
- package/dist/components/radio/docs.props.js +34 -0
- package/dist/components/radio/index.scss +3 -0
- package/dist/components/radio/props.d.ts +8 -0
- package/dist/components/radio/props.js +8 -0
- package/dist/components/railbar/QRailbar.svelte +52 -0
- package/dist/components/railbar/QRailbar.svelte.d.ts +23 -0
- package/dist/components/railbar/docs.props.d.ts +8 -0
- package/dist/components/railbar/docs.props.js +26 -0
- package/dist/components/railbar/props.d.ts +7 -0
- package/dist/components/railbar/props.js +7 -0
- package/dist/components/select/QSelect.svelte +159 -0
- package/dist/components/select/QSelect.svelte.d.ts +34 -0
- package/dist/components/select/docs.d.ts +2 -0
- package/dist/components/select/docs.js +95 -0
- package/dist/components/select/docs.props.d.ts +8 -0
- package/dist/components/select/docs.props.js +106 -0
- package/dist/components/select/index.scss +34 -0
- package/dist/components/select/props.d.ts +33 -0
- package/dist/components/select/props.js +14 -0
- package/dist/components/separator/QSeparator.svelte +63 -0
- package/dist/components/separator/QSeparator.svelte.d.ts +25 -0
- package/dist/components/separator/docs.props.d.ts +16 -0
- package/dist/components/separator/docs.props.js +116 -0
- package/dist/components/separator/props.d.ts +22 -0
- package/dist/components/separator/props.js +9 -0
- package/dist/components/table/QTable.svelte +154 -0
- package/dist/components/table/QTable.svelte.d.ts +29 -0
- package/dist/components/table/docs.d.ts +2 -0
- package/dist/components/table/docs.js +11 -0
- package/dist/components/table/docs.props.d.ts +8 -0
- package/dist/components/table/docs.props.js +42 -0
- package/dist/components/table/index.scss +77 -0
- package/dist/components/table/props.d.ts +45 -0
- package/dist/components/table/props.js +1 -0
- package/dist/components/tabs/QTab.svelte +78 -0
- package/dist/components/tabs/QTab.svelte.d.ts +28 -0
- package/dist/components/tabs/QTabs.svelte +55 -0
- package/dist/components/tabs/QTabs.svelte.d.ts +23 -0
- package/dist/components/tabs/docs.props.d.ts +16 -0
- package/dist/components/tabs/docs.props.js +60 -0
- package/dist/components/tabs/index.scss +75 -0
- package/dist/components/tabs/props.d.ts +14 -0
- package/dist/components/tabs/props.js +13 -0
- package/dist/components/toggle/QToggle.svelte +35 -0
- package/dist/components/toggle/QToggle.svelte.d.ts +23 -0
- package/dist/components/toggle/docs.d.ts +2 -0
- package/dist/components/toggle/docs.js +47 -0
- package/dist/components/toggle/docs.props.d.ts +8 -0
- package/dist/components/toggle/docs.props.js +42 -0
- package/dist/components/toggle/index.scss +31 -0
- package/dist/components/toggle/props.d.ts +9 -0
- package/dist/components/toggle/props.js +9 -0
- package/dist/components/toolbar/QToolbar.svelte +39 -0
- package/dist/components/toolbar/QToolbar.svelte.d.ts +23 -0
- package/dist/components/toolbar/docs.props.d.ts +8 -0
- package/dist/components/toolbar/docs.props.js +18 -0
- package/dist/components/toolbar/index.scss +7 -0
- package/dist/components/toolbar/props.d.ts +6 -0
- package/dist/components/toolbar/props.js +6 -0
- package/dist/components/tooltip/QTooltip.svelte +15 -0
- package/dist/components/tooltip/QTooltip.svelte.d.ts +22 -0
- package/dist/components/tooltip/docs.props.d.ts +8 -0
- package/dist/components/tooltip/docs.props.js +18 -0
- package/dist/components/tooltip/index.scss +7 -0
- package/dist/components/tooltip/props.d.ts +6 -0
- package/dist/components/tooltip/props.js +6 -0
- package/dist/composables/index.d.ts +0 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-align.d.ts +8 -0
- package/dist/composables/use-align.js +12 -0
- package/dist/composables/use-index.d.ts +2 -0
- package/dist/composables/use-index.js +17 -0
- package/dist/composables/use-router-link.d.ts +18 -0
- package/dist/composables/use-router-link.js +27 -0
- package/dist/composables/use-size.d.ts +11 -0
- package/dist/composables/use-size.js +13 -0
- package/dist/css/grid.scss +65 -0
- package/dist/css/index.scss +119 -0
- package/dist/css/mixins/field.scss +430 -0
- package/dist/css/mixins/menu.scss +70 -0
- package/dist/css/mixins/selection.scss +184 -0
- package/dist/css/mixins/table.scss +36 -0
- package/dist/css/mixins.scss +135 -0
- package/dist/css/states.scss +70 -0
- package/dist/css/theme/colors.module.scss +180 -0
- package/dist/css/theme/theme.dark.scss +36 -0
- package/dist/css/theme/theme.light.scss +36 -0
- package/dist/css/theme/theme.scss +5 -0
- package/dist/css/theme/tokens.scss +266 -0
- package/dist/css/theme/typography.module.scss +150 -0
- package/dist/global.d.ts +10 -0
- package/dist/helpers/activationHandler.d.ts +9 -0
- package/dist/helpers/activationHandler.js +23 -0
- package/dist/helpers/clickOutside.d.ts +6 -0
- package/dist/helpers/clickOutside.js +34 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/stores/QTheme.d.ts +41 -0
- package/dist/stores/QTheme.js +53 -0
- package/dist/stores/Quaff.d.ts +31 -0
- package/dist/stores/Quaff.js +52 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +11 -0
- package/dist/utils/colors.d.ts +10 -0
- package/dist/utils/colors.js +102 -0
- package/dist/utils/fields.d.ts +1 -0
- package/dist/utils/fields.js +14 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/props.d.ts +9 -0
- package/dist/utils/props.js +31 -0
- package/dist/utils/string.d.ts +10 -0
- package/dist/utils/string.js +78 -0
- package/dist/utils/types.d.ts +42 -0
- package/dist/utils/types.js +7 -0
- package/dist/utils/types.json +1 -0
- package/dist/utils/watchable.d.ts +2 -0
- package/dist/utils/watchable.js +22 -0
- package/package.json +66 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="@sveltejs/kit" />
|
|
2
|
+
export declare const quaffStore: {
|
|
3
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<{
|
|
4
|
+
version: string;
|
|
5
|
+
dark: boolean;
|
|
6
|
+
}>, invalidate?: ((value?: {
|
|
7
|
+
version: string;
|
|
8
|
+
dark: boolean;
|
|
9
|
+
} | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
10
|
+
setDarkMode: (newVal: boolean) => void;
|
|
11
|
+
toggleDarkMode: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const Quaff: import("svelte/store").Readable<{
|
|
14
|
+
version: string;
|
|
15
|
+
router: import("@sveltejs/kit").Page<Record<string, string>, string | null>;
|
|
16
|
+
dark: {
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
toggle: () => void;
|
|
19
|
+
set: (newVal: boolean) => void;
|
|
20
|
+
};
|
|
21
|
+
subscribe: {
|
|
22
|
+
quaff: (this: void, run: import("svelte/store").Subscriber<{
|
|
23
|
+
version: string;
|
|
24
|
+
dark: boolean;
|
|
25
|
+
}>, invalidate?: ((value?: {
|
|
26
|
+
version: string;
|
|
27
|
+
dark: boolean;
|
|
28
|
+
} | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
29
|
+
page: (this: void, run: import("svelte/store").Subscriber<import("@sveltejs/kit").Page<Record<string, string>, string | null>>, invalidate?: ((value?: import("@sveltejs/kit").Page<Record<string, string>, string | null> | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { writable, derived } from "svelte/store";
|
|
2
|
+
import { page } from "$app/stores";
|
|
3
|
+
function quaff() {
|
|
4
|
+
const { subscribe, set, update } = writable({
|
|
5
|
+
version: __QUAFF_VERSION__,
|
|
6
|
+
dark: false,
|
|
7
|
+
//TODO lang: {},
|
|
8
|
+
//TODO? iconSet: {},
|
|
9
|
+
});
|
|
10
|
+
const toggleDarkMode = () => {
|
|
11
|
+
return update((q) => {
|
|
12
|
+
q.dark = !q.dark;
|
|
13
|
+
let body = document.querySelector("body");
|
|
14
|
+
if (q.dark === true) {
|
|
15
|
+
body && body.classList.replace("light", "dark");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
body && body.classList.replace("dark", "light");
|
|
19
|
+
}
|
|
20
|
+
let mode = q.dark === true ? "dark" : "light";
|
|
21
|
+
document.cookie = `current_mode=${mode}; max-age=31536000; path="/"; SameSite=strict`;
|
|
22
|
+
return q;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const setDarkMode = (newVal) => {
|
|
26
|
+
return update((q) => {
|
|
27
|
+
q.dark = newVal;
|
|
28
|
+
return q;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
subscribe,
|
|
33
|
+
setDarkMode,
|
|
34
|
+
toggleDarkMode,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export const quaffStore = quaff();
|
|
38
|
+
export const Quaff = derived([quaffStore, page], ([$quaff, $page]) => {
|
|
39
|
+
return {
|
|
40
|
+
version: $quaff.version,
|
|
41
|
+
router: $page,
|
|
42
|
+
dark: {
|
|
43
|
+
isActive: $quaff.dark,
|
|
44
|
+
toggle: quaffStore.toggleDarkMode,
|
|
45
|
+
set: quaffStore.setDarkMode,
|
|
46
|
+
},
|
|
47
|
+
subscribe: {
|
|
48
|
+
quaff: quaffStore.subscribe,
|
|
49
|
+
page: page.subscribe,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function copy(text: string): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
async function copy(text) {
|
|
3
|
+
if (navigator.clipboard.write) {
|
|
4
|
+
let blob = new Blob([text], { type: "text/plain" });
|
|
5
|
+
let item = new ClipboardItem({ "text/plain": blob });
|
|
6
|
+
await navigator.clipboard.write([item]);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
await navigator.clipboard.writeText(text);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class QColors {
|
|
2
|
+
private static hexRegex;
|
|
3
|
+
private static isValidRgb;
|
|
4
|
+
private static isValidHsl;
|
|
5
|
+
static rgbToHex(r: string | number, g: string | number, b: string | number): string;
|
|
6
|
+
static hexToRgb(hex: string): number[];
|
|
7
|
+
static rgbToHsl(r: string | number, g: string | number, b: string | number): number[];
|
|
8
|
+
static hslToRgb(h: string | number, s: string | number, l: string | number): number[];
|
|
9
|
+
}
|
|
10
|
+
export default QColors;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isNumber } from "./types";
|
|
2
|
+
class QColors {
|
|
3
|
+
static hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
4
|
+
static isValidRgb(r, g, b) {
|
|
5
|
+
return (isNumber(r) &&
|
|
6
|
+
isNumber(g) &&
|
|
7
|
+
isNumber(b) &&
|
|
8
|
+
+r >= 0 &&
|
|
9
|
+
+r <= 255 &&
|
|
10
|
+
+g >= 0 &&
|
|
11
|
+
+g <= 255 &&
|
|
12
|
+
+b >= 0 &&
|
|
13
|
+
+b <= 255);
|
|
14
|
+
}
|
|
15
|
+
static isValidHsl(h, s, l) {
|
|
16
|
+
return (isNumber(h) &&
|
|
17
|
+
isNumber(s) &&
|
|
18
|
+
isNumber(l) &&
|
|
19
|
+
+h >= 0 &&
|
|
20
|
+
+h <= 360 &&
|
|
21
|
+
+s >= 0 &&
|
|
22
|
+
+s <= 100 &&
|
|
23
|
+
+l >= 0 &&
|
|
24
|
+
+l <= 100);
|
|
25
|
+
}
|
|
26
|
+
static rgbToHex(r, g, b) {
|
|
27
|
+
if (!QColors.isValidRgb(r, g, b)) {
|
|
28
|
+
throw new Error("Invalid RGB values. They should be in the range 0-255.");
|
|
29
|
+
}
|
|
30
|
+
return "#" + ((1 << 24) + (+r << 16) + (+g << 8) + +b).toString(16).slice(1);
|
|
31
|
+
}
|
|
32
|
+
static hexToRgb(hex) {
|
|
33
|
+
if (!QColors.hexRegex.test(hex)) {
|
|
34
|
+
throw new Error("Invalid HEX value. It should follow the format #xxxxxx or #xxx where x is a hexadecimal digit.");
|
|
35
|
+
}
|
|
36
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
37
|
+
return result
|
|
38
|
+
? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]
|
|
39
|
+
: [];
|
|
40
|
+
}
|
|
41
|
+
static rgbToHsl(r, g, b) {
|
|
42
|
+
if (!QColors.isValidRgb(r, g, b)) {
|
|
43
|
+
throw new Error("Invalid RGB values. They should be in the range 0-255.");
|
|
44
|
+
}
|
|
45
|
+
(r = +r / 255), (g = +g / 255), (b = +b / 255);
|
|
46
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
47
|
+
let h, s, l = (max + min) / 2;
|
|
48
|
+
if (max === min) {
|
|
49
|
+
h = s = 0; // achromatic
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const delta = max - min;
|
|
53
|
+
s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
54
|
+
switch (max) {
|
|
55
|
+
case r:
|
|
56
|
+
default:
|
|
57
|
+
h = (g - b) / delta + (g < b ? 6 : 0);
|
|
58
|
+
break;
|
|
59
|
+
case g:
|
|
60
|
+
h = (b - r) / delta + 2;
|
|
61
|
+
break;
|
|
62
|
+
case b:
|
|
63
|
+
h = (r - g) / delta + 4;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
h /= 6;
|
|
67
|
+
}
|
|
68
|
+
return [h * 360, s * 100, l * 100];
|
|
69
|
+
}
|
|
70
|
+
static hslToRgb(h, s, l) {
|
|
71
|
+
if (!QColors.isValidHsl(h, s, l)) {
|
|
72
|
+
throw new Error("Invalid HSL values. Hue should be in the range 0-360, saturation and lightness in the range 0-100.");
|
|
73
|
+
}
|
|
74
|
+
let r, g, b;
|
|
75
|
+
(h = +h / 360), (s = +s / 100), (l = +l / 100);
|
|
76
|
+
if (s === 0) {
|
|
77
|
+
r = g = b = l; // achromatic
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const hue2rgb = (p, q, t) => {
|
|
81
|
+
if (t < 0)
|
|
82
|
+
t += 1;
|
|
83
|
+
if (t > 1)
|
|
84
|
+
t -= 1;
|
|
85
|
+
if (t < 1 / 6)
|
|
86
|
+
return p + (q - p) * 6 * t;
|
|
87
|
+
if (t < 1 / 2)
|
|
88
|
+
return q;
|
|
89
|
+
if (t < 2 / 3)
|
|
90
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
91
|
+
return p;
|
|
92
|
+
};
|
|
93
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
94
|
+
const p = 2 * l - q;
|
|
95
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
96
|
+
g = hue2rgb(p, q, h);
|
|
97
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
98
|
+
}
|
|
99
|
+
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export default QColors;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function textWidth(element: HTMLElement, font: string): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function textWidth(element, font) {
|
|
2
|
+
if (element.offsetWidth > 0)
|
|
3
|
+
return element.offsetWidth;
|
|
4
|
+
let _canvas = document.querySelector("canvas[data-quaff]")?.getContext("2d");
|
|
5
|
+
if (!_canvas) {
|
|
6
|
+
const canvasElement = document.createElement("canvas");
|
|
7
|
+
canvasElement.style.display = "none";
|
|
8
|
+
canvasElement.setAttribute("data-quaff", "");
|
|
9
|
+
document.body.append(canvasElement);
|
|
10
|
+
_canvas = canvasElement.getContext("2d");
|
|
11
|
+
}
|
|
12
|
+
_canvas.font = font;
|
|
13
|
+
return _canvas.measureText(element.textContent).width;
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function createStyles(styleObj: Record<string, string | number | null | undefined>, userStyles?: string): string | null;
|
|
2
|
+
interface CreateClassesOptions {
|
|
3
|
+
component?: string;
|
|
4
|
+
element?: string;
|
|
5
|
+
userClasses?: string;
|
|
6
|
+
quaffClasses?: any[];
|
|
7
|
+
}
|
|
8
|
+
export declare function createClasses(modifiers: any[], options?: CreateClassesOptions): string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { convertCase } from "./string";
|
|
2
|
+
export function createStyles(styleObj, userStyles) {
|
|
3
|
+
const stylesArray = Object.entries(styleObj);
|
|
4
|
+
const toJoin = [];
|
|
5
|
+
for (let [styleName, styleVal] of stylesArray) {
|
|
6
|
+
if (styleVal === undefined || styleVal === null) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
styleName = convertCase(styleName, "camel", "kebab");
|
|
10
|
+
toJoin.push(`${styleName}: ${styleVal}`);
|
|
11
|
+
}
|
|
12
|
+
userStyles && toJoin.push(userStyles);
|
|
13
|
+
if (toJoin.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return toJoin.join("; ");
|
|
17
|
+
}
|
|
18
|
+
export function createClasses(modifiers, options = { userClasses: "", quaffClasses: [] }) {
|
|
19
|
+
const userClasses = options.userClasses?.trim();
|
|
20
|
+
const quaffClasses = options.quaffClasses?.length && createClasses(options.quaffClasses);
|
|
21
|
+
const baseClasses = `${quaffClasses || ""} ${userClasses || ""}`.trim();
|
|
22
|
+
let component = options.component, element;
|
|
23
|
+
if (component && options.element) {
|
|
24
|
+
element = `${component}__${options.element}`;
|
|
25
|
+
}
|
|
26
|
+
const filteredModifiers = modifiers.filter(Boolean);
|
|
27
|
+
let withModifiers = component
|
|
28
|
+
? filteredModifiers.map((modifier) => `${element || component}--${modifier}`)
|
|
29
|
+
: filteredModifiers;
|
|
30
|
+
return [element || component, ...withModifiers, baseClasses].filter(Boolean).join(" ").trim();
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function capitalize(str: string, eachWord?: boolean): string;
|
|
2
|
+
export declare function uncapitalize(str: string, eachWord?: boolean): string;
|
|
3
|
+
declare const cases: {
|
|
4
|
+
camel: string;
|
|
5
|
+
pascal: string;
|
|
6
|
+
kebab: string;
|
|
7
|
+
snake: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function convertCase(str: string, fromCase: keyof typeof cases, toCase: keyof typeof cases): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export function capitalize(str, eachWord = false) {
|
|
2
|
+
const cap = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
3
|
+
return eachWord ? str.split(" ").map(cap).join(" ") : cap(str);
|
|
4
|
+
}
|
|
5
|
+
export function uncapitalize(str, eachWord = false) {
|
|
6
|
+
const uncap = (str) => str.charAt(0).toLowerCase() + str.slice(1);
|
|
7
|
+
return eachWord ? str.split(" ").map(uncap).join(" ") : uncap(str);
|
|
8
|
+
}
|
|
9
|
+
const cases = {
|
|
10
|
+
camel: "",
|
|
11
|
+
pascal: "",
|
|
12
|
+
kebab: "-",
|
|
13
|
+
snake: "_",
|
|
14
|
+
};
|
|
15
|
+
function convertToPascalCase(str, delimeter) {
|
|
16
|
+
return str
|
|
17
|
+
.split(delimeter)
|
|
18
|
+
.map((word) => capitalize(word))
|
|
19
|
+
.join("");
|
|
20
|
+
}
|
|
21
|
+
function convertToCamelCase(str, delimeter) {
|
|
22
|
+
return str
|
|
23
|
+
.split(delimeter)
|
|
24
|
+
.map((word, index) => (index === 0 ? word : capitalize(word)))
|
|
25
|
+
.join("");
|
|
26
|
+
}
|
|
27
|
+
function convertToKebabSnakeCase(str, caseType) {
|
|
28
|
+
return str
|
|
29
|
+
.split("")
|
|
30
|
+
.map((letter) => (/[A-Z]/.test(letter) ? `${cases[caseType]}${letter.toLowerCase()}` : letter))
|
|
31
|
+
.join("");
|
|
32
|
+
}
|
|
33
|
+
export function convertCase(str, fromCase, toCase) {
|
|
34
|
+
switch (fromCase) {
|
|
35
|
+
case "camel":
|
|
36
|
+
if (toCase === "pascal") {
|
|
37
|
+
return capitalize(str);
|
|
38
|
+
}
|
|
39
|
+
if (toCase === "kebab" || toCase === "snake") {
|
|
40
|
+
return convertToKebabSnakeCase(str, toCase);
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case "pascal":
|
|
44
|
+
let uncap = uncapitalize(str);
|
|
45
|
+
if (toCase === "camel") {
|
|
46
|
+
return uncap;
|
|
47
|
+
}
|
|
48
|
+
if (toCase === "kebab" || toCase === "snake") {
|
|
49
|
+
return convertToKebabSnakeCase(uncap, toCase);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case "snake":
|
|
53
|
+
if (toCase === "kebab") {
|
|
54
|
+
return str.replaceAll("_", "-");
|
|
55
|
+
}
|
|
56
|
+
if (toCase === "camel") {
|
|
57
|
+
return convertToCamelCase(str, "_");
|
|
58
|
+
}
|
|
59
|
+
if (toCase === "pascal") {
|
|
60
|
+
return convertToPascalCase(str, "_");
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "kebab":
|
|
64
|
+
if (toCase === "snake") {
|
|
65
|
+
return str.replaceAll("-", "_");
|
|
66
|
+
}
|
|
67
|
+
if (toCase === "camel") {
|
|
68
|
+
return convertToCamelCase(str, "-");
|
|
69
|
+
}
|
|
70
|
+
if (toCase === "pascal") {
|
|
71
|
+
return convertToPascalCase(str, "-");
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
return str;
|
|
76
|
+
}
|
|
77
|
+
return str;
|
|
78
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface NativeProps {
|
|
2
|
+
userClasses?: string;
|
|
3
|
+
userStyles?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const NativePropsDefaults: NativeProps;
|
|
6
|
+
export interface QComponentDocs {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
docs: {
|
|
10
|
+
props: QComponentProp[];
|
|
11
|
+
slots: QComponentSlot[];
|
|
12
|
+
methods: QComponentMethod[];
|
|
13
|
+
events: QComponentEvent[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface QComponentProp {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
default?: any;
|
|
20
|
+
description: string;
|
|
21
|
+
clickableType?: boolean;
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface QComponentSlot {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}
|
|
28
|
+
export interface QComponentType {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
export interface QComponentEvent {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
}
|
|
37
|
+
export interface QComponentMethod {
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
}
|
|
42
|
+
export declare function isNumber(input: any): input is number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"QAvatarShapeOptions":"type QAvatarShapeOptions =\r\n | \"circle\"\r\n | \"rounded\"\r\n | \"top-round\"\r\n | \"left-round\"\r\n | \"right-round\"\r\n | \"bottom-round\"\r\n | \"top-left-round\"\r\n | \"top-right-round\"\r\n | \"bottom-left-round\"\r\n | \"bottom-right-round\"","QAvatarSizeOptions":"type QAvatarSizeOptions = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | string","QBreadcrumbsGutterOptions":"type QBreadcrumbsGutterOptions = \"none\" | \"sm\" | \"md\" | \"lg\"","QLayoutEvents":"type QLayoutEvents = \"resize\" | \"scroll\" | \"scrollHeight\"","QSelectOption":"type QSelectOption = string | { label: string, value: string }","QItemSectionTypes":"type QItemSectionTypes =\r\n | \"thumbnail\"\r\n | \"video\"\r\n | \"avatar\"\r\n | \"icon\"\r\n | \"trailingIcon\"\r\n | \"trailingText\"\r\n | \"content\"","QBtnSizeOptions":"type QBtnSizeOptions = \"sm\" | \"md\" | \"lg\" | \"xl\"","QDialogPositionOptions":"type QDialogPositionOptions = \"default\" | \"top\" | \"right\" | \"bottom\" | \"left\"","QDrawerSideOptions":"type QDrawerSideOptions = \"left\" | \"right\"","QDrawerBehaviorOptions":"type QDrawerBehaviorOptions = \"default\" | \"desktop\" | \"mobile\"","QIconSizeOptions":"type QIconSizeOptions = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | string | number","QIconTypeOptions":"type QIconTypeOptions = \"outlined\" | \"sharp\" | \"rounded\"","QLayoutViewOptions":"type QLayoutViewOptions = `${\"l\"|\"h\"}${\"h\"|\"H\"}${\"r\"|\"h\"} ${\"l\"|\"L\"}${\"p\"}${\"r\"|\"R\"} ${\"l\"|\"f\"}${\"f\"|\"F\"}${\"r\"|\"f\"}`","QTableColumn":"type QTableColumn = {\r\n name: string\r\n required?: boolean;\r\n label: string;\r\n align?: \"left\" | \"center\" | \"right\";\r\n field: string | ((row: QTableRow) => string);\r\n format?: (val: string) => string;\r\n sortable?: boolean;\r\n sort?: (a: string, b: string) => number;\r\n};","QTableRow":"type QTableRow = {\r\n [key: string]: string | number\r\n};","QTableSort":"type QTableSort = {\r\n columnField: string | ((row: QTableRow) => string)\r\n type: \"asc\" | \"desc\";\r\n} | null;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { derived, writable } from "svelte/store";
|
|
2
|
+
export function watchable(value) {
|
|
3
|
+
let values = writable([value, null]);
|
|
4
|
+
const subscribe = derived(values, ($values) => $values[0]).subscribe;
|
|
5
|
+
const update = (fn, isEqual = (a, b) => a === b) => {
|
|
6
|
+
values.update(($values) => {
|
|
7
|
+
const newValue = fn($values[0]);
|
|
8
|
+
if (isEqual(newValue, $values[0])) {
|
|
9
|
+
return $values;
|
|
10
|
+
}
|
|
11
|
+
return [newValue, $values[0]];
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const set = (newValue) => update(() => newValue);
|
|
15
|
+
const current = {
|
|
16
|
+
subscribe,
|
|
17
|
+
update,
|
|
18
|
+
set,
|
|
19
|
+
};
|
|
20
|
+
const previous = derived(values, ($values) => $values[1]);
|
|
21
|
+
return [current, previous];
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quaffui/quaff",
|
|
3
|
+
"version": "0.1.0-prealpha",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "vite dev",
|
|
6
|
+
"open": "vite dev --open",
|
|
7
|
+
"build": "vite build && npm run package",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
10
|
+
"prepublishOnly": "npm run package",
|
|
11
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
12
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
13
|
+
"test:unit": "vitest",
|
|
14
|
+
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
|
15
|
+
"format": "prettier --plugin-search-dir . --write .",
|
|
16
|
+
"docgen": "ts-node-esm docgen/props/run.ts",
|
|
17
|
+
"snippet": "ts-node-esm docgen/snippets/parseSnippets.ts"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"svelte": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/**/*.test.*",
|
|
28
|
+
"!dist/**/*.spec.*"
|
|
29
|
+
],
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"svelte": "^3.54.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@sveltejs/adapter-auto": "^2.0.0",
|
|
35
|
+
"@sveltejs/kit": "^1.5.0",
|
|
36
|
+
"@sveltejs/package": "^2.0.0",
|
|
37
|
+
"@types/node": "^20.3.1",
|
|
38
|
+
"@types/prettier": "^2.7.3",
|
|
39
|
+
"@types/prismjs": "^1.26.0",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
41
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
42
|
+
"eslint": "^8.28.0",
|
|
43
|
+
"eslint-config-prettier": "^8.5.0",
|
|
44
|
+
"eslint-plugin-svelte": "^2.26.0",
|
|
45
|
+
"prettier": "^2.8.0",
|
|
46
|
+
"prettier-plugin-svelte": "^2.8.1",
|
|
47
|
+
"publint": "^0.1.9",
|
|
48
|
+
"sass": "^1.62.1",
|
|
49
|
+
"svelte": "^3.54.0",
|
|
50
|
+
"svelte-check": "^3.0.1",
|
|
51
|
+
"ts-node": "^10.9.1",
|
|
52
|
+
"tslib": "^2.4.1",
|
|
53
|
+
"typescript": "^5.0.0",
|
|
54
|
+
"vite": "^4.3.0",
|
|
55
|
+
"vitest": "^0.25.3"
|
|
56
|
+
},
|
|
57
|
+
"svelte": "./dist/index.js",
|
|
58
|
+
"types": "./dist/index.d.ts",
|
|
59
|
+
"type": "module",
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"beercss": "^3.2.6",
|
|
62
|
+
"material-dynamic-colors": "^0.1.7",
|
|
63
|
+
"prism-svelte": "0.5.0",
|
|
64
|
+
"prismjs": "^1.29.0"
|
|
65
|
+
}
|
|
66
|
+
}
|