@quaffui/quaff 1.0.0-beta6 → 1.0.0-beta9

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.
Files changed (55) hide show
  1. package/README.md +2 -0
  2. package/dist/components/avatar/QAvatar.svelte +4 -0
  3. package/dist/components/breadcrumbs/QBreadcrumbs.svelte +28 -5
  4. package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +23 -0
  5. package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +17 -14
  6. package/dist/components/button/QBtn.svelte +21 -11
  7. package/dist/components/card/QCard.svelte +9 -5
  8. package/dist/components/card/QCardActions.svelte +4 -0
  9. package/dist/components/card/QCardSection.svelte +2 -0
  10. package/dist/components/checkbox/QCheckbox.svelte +2 -0
  11. package/dist/components/chip/QChip.svelte +24 -14
  12. package/dist/components/codeBlock/QCodeBlock.svelte +8 -0
  13. package/dist/components/dialog/QDialog.svelte +12 -0
  14. package/dist/components/drawer/QDrawer.svelte +50 -39
  15. package/dist/components/expansion-item/QExpansionItem.svelte +16 -2
  16. package/dist/components/footer/QFooter.svelte +27 -22
  17. package/dist/components/header/QHeader.svelte +37 -28
  18. package/dist/components/icon/QIcon.svelte +4 -0
  19. package/dist/components/input/QInput.svelte +9 -2
  20. package/dist/components/layout/QLayout.svelte +243 -90
  21. package/dist/components/layout/QLayout.svelte.d.ts +64 -2
  22. package/dist/components/list/QItem.svelte +43 -24
  23. package/dist/components/list/QItem.svelte.d.ts +14 -0
  24. package/dist/components/list/QItemSection.svelte +16 -12
  25. package/dist/components/list/QList.svelte +28 -6
  26. package/dist/components/list/QList.svelte.d.ts +15 -0
  27. package/dist/components/private/ContextReseter.svelte +2 -3
  28. package/dist/components/private/QApi.svelte +15 -7
  29. package/dist/components/private/QDocs.svelte +40 -20
  30. package/dist/components/private/QDocs.svelte.d.ts +30 -0
  31. package/dist/components/private/QDocsSection.svelte +11 -7
  32. package/dist/components/progress/QCircularProgress.svelte +14 -5
  33. package/dist/components/progress/QLinearProgress.svelte +12 -6
  34. package/dist/components/radio/QRadio.svelte +2 -0
  35. package/dist/components/railbar/QRailbar.svelte +36 -35
  36. package/dist/components/select/QSelect.svelte +32 -23
  37. package/dist/components/separator/QSeparator.svelte +4 -0
  38. package/dist/components/switch/QSwitch.svelte +6 -0
  39. package/dist/components/table/QTable.svelte +23 -13
  40. package/dist/components/tabs/QTab.svelte +19 -22
  41. package/dist/components/tabs/QTabs.svelte +59 -32
  42. package/dist/components/tabs/QTabs.svelte.d.ts +15 -4
  43. package/dist/components/toolbar/QToolbar.svelte +2 -0
  44. package/dist/components/toolbar/QToolbarTitle.svelte +2 -0
  45. package/dist/components/tooltip/QTooltip.svelte +22 -8
  46. package/dist/components/tooltip/QTooltipBase.svelte +18 -8
  47. package/dist/composables/useRouterLink.d.ts +2 -1
  48. package/dist/css/index.css +1 -1
  49. package/dist/helpers/version.d.ts +1 -1
  50. package/dist/helpers/version.js +1 -1
  51. package/dist/utils/context.d.ts +49 -32
  52. package/dist/utils/context.js +82 -33
  53. package/package.json +28 -27
  54. package/dist/classes/QContext.svelte.d.ts +0 -42
  55. package/dist/classes/QContext.svelte.js +0 -63
@@ -1 +1 @@
1
- export default "1.0.0-beta6";
1
+ export default "1.0.0-beta9";
@@ -1,33 +1,50 @@
1
- export declare const QBreadcrumbsCtxName: {
2
- activeColor: symbol;
3
- separator: symbol;
4
- };
5
- export declare const QDocsCtxName: {
6
- snippets: symbol;
7
- };
8
- export declare const QItemCtxName: {
9
- activeClass: symbol;
10
- multiline: symbol;
11
- };
12
- export declare const QLayoutCtxName: {
13
- view: symbol;
14
- header: symbol;
15
- footer: symbol;
16
- railbar: {
17
- left: symbol;
18
- right: symbol;
19
- };
20
- drawer: {
21
- left: symbol;
22
- right: symbol;
23
- };
24
- };
25
- export declare const QListCtxName: {
26
- activeClass: symbol;
27
- separator: symbol;
28
- };
29
- export declare const QTabsCtxName: {
30
- request: symbol;
31
- value: symbol;
32
- variant: symbol;
1
+ /**
2
+ * This function allows to manipulate contexts more easily.
3
+ * It avoids having to pass a Svelte store down the components but rather use runes to keep the context reactive.
4
+ */
5
+ export declare function QContext<T>(name: string): {
6
+ /**
7
+ * The inner symbol used to identify the context.
8
+ */
9
+ readonly symbol: symbol;
10
+ /**
11
+ * Get the context value.
12
+ * @returns The context value or undefined if not found.
13
+ */
14
+ get(): T | undefined;
15
+ /**
16
+ * Get the context value or throw an error if not found.
17
+ *
18
+ * @param errorMsg Optional error message to throw if context is not found.
19
+ * @returns The context value.
20
+ * @throws Error if context is not found.
21
+ */
22
+ assertGet(errorMsg?: string): NonNullable<T>;
23
+ /**
24
+ * Set the context value.
25
+ * @param context The context value to set.
26
+ */
27
+ set(context: T): void;
28
+ /**
29
+ * Reset the context value.
30
+ */
31
+ reset(): void;
32
+ /**
33
+ * Checks whether the context exists.
34
+ * @returns True if the context exists, false otherwise.
35
+ */
36
+ exists(): boolean;
37
+ /**
38
+ * Update one entry of the context.
39
+ *
40
+ * @param key The key of the entry to update.
41
+ * @param value The new value for the entry.
42
+ */
43
+ updateEntry(key: keyof T, value: NonNullable<T>[keyof T]): void;
44
+ /**
45
+ * Update multiple entries of the context.
46
+ *
47
+ * @param updates The key/value pairs to update in the context.
48
+ */
49
+ updateEntries(updates: Partial<T>): void;
33
50
  };
@@ -1,33 +1,82 @@
1
- export const QBreadcrumbsCtxName = {
2
- activeColor: Symbol("activeColor"),
3
- separator: Symbol("separator"),
4
- };
5
- export const QDocsCtxName = {
6
- snippets: Symbol("snippets"),
7
- };
8
- export const QItemCtxName = {
9
- activeClass: Symbol("activeClass"),
10
- multiline: Symbol("multiline"),
11
- };
12
- export const QLayoutCtxName = {
13
- view: Symbol("layoutView"),
14
- header: Symbol("QHeader"),
15
- footer: Symbol("QFooter"),
16
- railbar: {
17
- left: Symbol("QRailbar-left"),
18
- right: Symbol("QRailbar-right"),
19
- },
20
- drawer: {
21
- left: Symbol("QDrawer-left"),
22
- right: Symbol("QDrawer-right"),
23
- },
24
- };
25
- export const QListCtxName = {
26
- activeClass: Symbol("activeClass"),
27
- separator: Symbol("separator"),
28
- };
29
- export const QTabsCtxName = {
30
- request: Symbol("request"),
31
- value: Symbol("value"),
32
- variant: Symbol("variant"),
33
- };
1
+ import { getContext, hasContext, setContext } from "svelte";
2
+ /**
3
+ * This function allows to manipulate contexts more easily.
4
+ * It avoids having to pass a Svelte store down the components but rather use runes to keep the context reactive.
5
+ */
6
+ export function QContext(name) {
7
+ const sym = Symbol(name);
8
+ return {
9
+ /**
10
+ * The inner symbol used to identify the context.
11
+ */
12
+ get symbol() {
13
+ return sym;
14
+ },
15
+ /**
16
+ * Get the context value.
17
+ * @returns The context value or undefined if not found.
18
+ */
19
+ get() {
20
+ return getContext(sym);
21
+ },
22
+ /**
23
+ * Get the context value or throw an error if not found.
24
+ *
25
+ * @param errorMsg Optional error message to throw if context is not found.
26
+ * @returns The context value.
27
+ * @throws Error if context is not found.
28
+ */
29
+ assertGet(errorMsg) {
30
+ const ctx = getContext(sym);
31
+ if (!ctx) {
32
+ throw new Error(errorMsg || `Context "${name}" not found`);
33
+ }
34
+ return ctx;
35
+ },
36
+ /**
37
+ * Set the context value.
38
+ * @param context The context value to set.
39
+ */
40
+ set(context) {
41
+ setContext(sym, context);
42
+ },
43
+ /**
44
+ * Reset the context value.
45
+ */
46
+ reset() {
47
+ setContext(sym, undefined);
48
+ },
49
+ /**
50
+ * Checks whether the context exists.
51
+ * @returns True if the context exists, false otherwise.
52
+ */
53
+ exists() {
54
+ return hasContext(sym);
55
+ },
56
+ /**
57
+ * Update one entry of the context.
58
+ *
59
+ * @param key The key of the entry to update.
60
+ * @param value The new value for the entry.
61
+ */
62
+ updateEntry(key, value) {
63
+ const ctx = getContext(sym);
64
+ if (!ctx) {
65
+ return;
66
+ }
67
+ ctx[key] = value;
68
+ },
69
+ /**
70
+ * Update multiple entries of the context.
71
+ *
72
+ * @param updates The key/value pairs to update in the context.
73
+ */
74
+ updateEntries(updates) {
75
+ const ctx = getContext(sym);
76
+ if (!ctx) {
77
+ return;
78
+ }
79
+ Object.assign(ctx, updates);
80
+ },
81
+ };
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quaffui/quaff",
3
- "version": "1.0.0-beta6",
3
+ "version": "1.0.0-beta9",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "open": "vite dev --open",
@@ -18,7 +18,8 @@
18
18
  "docgen-props": "bun scripts/docgenProps.ts",
19
19
  "colorgen": "bun scripts/colorgen.ts",
20
20
  "docgen-snippets": "bun scripts/docgenSnippets.ts",
21
- "write-version": "bun scripts/writeVersion.ts"
21
+ "write-version": "bun scripts/writeVersion.ts",
22
+ "gen:plugins": "tsc --outDir plugins/dist plugins/index.ts --declaration --target esnext --module esnext --moduleResolution bundler"
22
23
  },
23
24
  "exports": {
24
25
  ".": {
@@ -36,36 +37,36 @@
36
37
  "shiki": "^3.4.2"
37
38
  },
38
39
  "devDependencies": {
39
- "@fontsource/roboto": "^5.2.5",
40
- "@sveltejs/adapter-static": "^3.0.8",
41
- "@sveltejs/kit": "^2.21.1",
42
- "@sveltejs/package": "^2.3.11",
43
- "@sveltejs/vite-plugin-svelte": "^5.0.3",
40
+ "@fontsource/roboto": "^5.2.8",
41
+ "@sveltejs/adapter-static": "^3.0.9",
42
+ "@sveltejs/kit": "^2.42.2",
43
+ "@sveltejs/package": "^2.5.2",
44
+ "@sveltejs/vite-plugin-svelte": "^6.2.0",
44
45
  "@types/prettier": "^3.0.0",
45
46
  "@types/prismjs": "^1.26.5",
46
- "@typescript-eslint/eslint-plugin": "^8.33.0",
47
- "@typescript-eslint/parser": "^8.33.0",
48
- "bun-types": "^1.2.15",
49
- "eslint": "^9.28.0",
50
- "eslint-config-prettier": "^10.1.5",
51
- "eslint-plugin-import-x": "^4.15.0",
52
- "eslint-plugin-svelte": "^3.9.0",
53
- "eslint-plugin-unicorn": "^59.0.1",
47
+ "@typescript-eslint/eslint-plugin": "^8.44.0",
48
+ "@typescript-eslint/parser": "^8.44.0",
49
+ "bun-types": "^1.2.22",
50
+ "eslint": "^9.36.0",
51
+ "eslint-config-prettier": "^10.1.8",
52
+ "eslint-plugin-import-x": "^4.16.1",
53
+ "eslint-plugin-svelte": "^3.12.3",
54
+ "eslint-plugin-unicorn": "^61.0.2",
54
55
  "estree-walker": "^3.0.3",
55
- "globals": "^16.2.0",
56
- "magic-string": "^0.30.17",
57
- "material-symbols": "^0.31.4",
58
- "prettier": "^3.5.3",
56
+ "globals": "^16.4.0",
57
+ "magic-string": "^0.30.19",
58
+ "material-symbols": "^0.35.2",
59
+ "prettier": "^3.6.2",
59
60
  "prettier-plugin-svelte": "^3.4.0",
60
- "publint": "^0.3.12",
61
- "sass": "^1.89.1",
62
- "svelte": "^5.33.11",
63
- "svelte-check": "^4.2.1",
64
- "svelte-eslint-parser": "^1.2.0",
61
+ "publint": "^0.3.13",
62
+ "sass": "^1.92.1",
63
+ "svelte": "^5.39.2",
64
+ "svelte-check": "^4.3.1",
65
+ "svelte-eslint-parser": "^1.3.2",
65
66
  "tslib": "^2.8.1",
66
- "typescript": "^5.8.3",
67
- "vite": "^6.3.5",
68
- "vitest": "^3.1.4"
67
+ "typescript": "^5.9.2",
68
+ "vite": "^7.1.6",
69
+ "vitest": "^3.2.4"
69
70
  },
70
71
  "svelte": "./dist/index.js",
71
72
  "types": "./dist/index.d.ts",
@@ -1,42 +0,0 @@
1
- /**
2
- * This class allows to manipulate reactive contexts more easily.
3
- * It avoids having to pass a Svelte store down the components but rather use runes to keep the context reactive.
4
- *
5
- * This class should be used when the context has to be modified from a child component. Otherwise, using svelte's context API should be enough.
6
- */
7
- export declare class QContext<T> {
8
- #private;
9
- constructor(contextSymbol: symbol, init: T);
10
- /**
11
- * Gets the value of context with id `contextSymbol`
12
- * @param contextSymbol - Name of the context to get
13
- * @returns The context's value
14
- */
15
- static get<T>(contextSymbol: symbol): QContext<T> | undefined;
16
- /**
17
- * Prevents the propagation of the context further down
18
- * @param contextSymbol - Name of the context to get
19
- * @returns The context result
20
- */
21
- static reset(contextSymbol: symbol): void;
22
- /**
23
- * Updates the context's inner value with `newVal`
24
- * @param newVal - New value to update the context with
25
- */
26
- update(newVal: T): void;
27
- /**
28
- * Updates the property of id `key` with `newVal` in the context's inner value
29
- * @param key - Key to update
30
- * @param newVal - New value to update the context's property with
31
- */
32
- updateEntry(key: keyof T, newVal: NonNullable<T>[keyof T]): void;
33
- /**
34
- * Updates the given properties their corresponding values in the context's inner value
35
- * @param from - Object containing keys to update with their respective value
36
- */
37
- updateEntries(from: Record<keyof T, NonNullable<T>[keyof T]>): void;
38
- /**
39
- * Inner value of the context
40
- */
41
- get value(): T;
42
- }
@@ -1,63 +0,0 @@
1
- import { getContext, setContext } from "svelte";
2
- /**
3
- * This class allows to manipulate reactive contexts more easily.
4
- * It avoids having to pass a Svelte store down the components but rather use runes to keep the context reactive.
5
- *
6
- * This class should be used when the context has to be modified from a child component. Otherwise, using svelte's context API should be enough.
7
- */
8
- export class QContext {
9
- #state = $state();
10
- constructor(contextSymbol, init) {
11
- this.#state = init;
12
- setContext(contextSymbol, this);
13
- }
14
- /**
15
- * Gets the value of context with id `contextSymbol`
16
- * @param contextSymbol - Name of the context to get
17
- * @returns The context's value
18
- */
19
- static get(contextSymbol) {
20
- return getContext(contextSymbol);
21
- }
22
- /**
23
- * Prevents the propagation of the context further down
24
- * @param contextSymbol - Name of the context to get
25
- * @returns The context result
26
- */
27
- static reset(contextSymbol) {
28
- setContext(contextSymbol, undefined);
29
- }
30
- /**
31
- * Updates the context's inner value with `newVal`
32
- * @param newVal - New value to update the context with
33
- */
34
- update(newVal) {
35
- this.#state = newVal;
36
- }
37
- /**
38
- * Updates the property of id `key` with `newVal` in the context's inner value
39
- * @param key - Key to update
40
- * @param newVal - New value to update the context's property with
41
- */
42
- updateEntry(key, newVal) {
43
- if (!this.#state || typeof this.#state !== "object" || !Object.hasOwn(this.#state, key)) {
44
- throw new Error(`${key.toString()} doesn't exist on ${this.#state}`);
45
- }
46
- this.#state[key] = newVal;
47
- }
48
- /**
49
- * Updates the given properties their corresponding values in the context's inner value
50
- * @param from - Object containing keys to update with their respective value
51
- */
52
- updateEntries(from) {
53
- for (const key in from) {
54
- this.updateEntry(key, from[key]);
55
- }
56
- }
57
- /**
58
- * Inner value of the context
59
- */
60
- get value() {
61
- return this.#state;
62
- }
63
- }