@quaffui/quaff 0.1.0-prealpha21 → 0.1.0-prealpha22

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 (105) hide show
  1. package/dist/components/avatar/QAvatar.svelte +4 -1
  2. package/dist/components/avatar/QAvatar.svelte.d.ts +14 -2
  3. package/dist/components/breadcrumbs/QBreadcrumbs.svelte +7 -2
  4. package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +14 -2
  5. package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +16 -5
  6. package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +14 -2
  7. package/dist/components/button/QBtn.svelte +61 -11
  8. package/dist/components/button/QBtn.svelte.d.ts +14 -2
  9. package/dist/components/button/docs.props.js +37 -5
  10. package/dist/components/button/props.d.ts +24 -4
  11. package/dist/components/card/QCard.svelte +6 -2
  12. package/dist/components/card/QCard.svelte.d.ts +14 -2
  13. package/dist/components/card/QCardActions.svelte +9 -1
  14. package/dist/components/card/QCardActions.svelte.d.ts +14 -2
  15. package/dist/components/card/QCardSection.svelte +3 -1
  16. package/dist/components/card/QCardSection.svelte.d.ts +14 -2
  17. package/dist/components/checkbox/QCheckbox.svelte +8 -1
  18. package/dist/components/checkbox/QCheckbox.svelte.d.ts +14 -3
  19. package/dist/components/chip/QChip.svelte +30 -9
  20. package/dist/components/chip/QChip.svelte.d.ts +14 -3
  21. package/dist/components/codeBlock/QCodeBlock.svelte +25 -10
  22. package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +14 -3
  23. package/dist/components/dialog/QDialog.svelte +20 -5
  24. package/dist/components/dialog/QDialog.svelte.d.ts +21 -7
  25. package/dist/components/drawer/QDrawer.svelte +36 -7
  26. package/dist/components/drawer/QDrawer.svelte.d.ts +21 -7
  27. package/dist/components/footer/QFooter.svelte +24 -6
  28. package/dist/components/footer/QFooter.svelte.d.ts +14 -3
  29. package/dist/components/header/QHeader.svelte +19 -6
  30. package/dist/components/header/QHeader.svelte.d.ts +14 -3
  31. package/dist/components/icon/QIcon.svelte +6 -1
  32. package/dist/components/icon/QIcon.svelte.d.ts +14 -2
  33. package/dist/components/input/QInput.svelte +23 -10
  34. package/dist/components/input/QInput.svelte.d.ts +14 -3
  35. package/dist/components/input/index.scss +1 -1
  36. package/dist/components/layout/QLayout.scss +2 -1
  37. package/dist/components/layout/QLayout.svelte +50 -8
  38. package/dist/components/layout/QLayout.svelte.d.ts +14 -3
  39. package/dist/components/list/QItem.svelte +11 -2
  40. package/dist/components/list/QItem.svelte.d.ts +14 -3
  41. package/dist/components/list/QItemSection.svelte +9 -3
  42. package/dist/components/list/QItemSection.svelte.d.ts +14 -3
  43. package/dist/components/list/QList.svelte +8 -3
  44. package/dist/components/list/QList.svelte.d.ts +14 -3
  45. package/dist/components/private/ContextReseter.svelte +10 -1
  46. package/dist/components/private/ContextReseter.svelte.d.ts +14 -6
  47. package/dist/components/private/QApi.svelte +32 -9
  48. package/dist/components/private/QApi.svelte.d.ts +14 -5
  49. package/dist/components/private/QDocs.svelte +18 -1
  50. package/dist/components/private/QDocs.svelte.d.ts +14 -10
  51. package/dist/components/private/QDocsSection.svelte +14 -2
  52. package/dist/components/private/QDocsSection.svelte.d.ts +14 -7
  53. package/dist/components/private/QIconSnippet.svelte +11 -1
  54. package/dist/components/private/QIconSnippet.svelte.d.ts +14 -8
  55. package/dist/components/progress/QCircularProgress.svelte +19 -3
  56. package/dist/components/progress/QCircularProgress.svelte.d.ts +14 -2
  57. package/dist/components/progress/QLinearProgress.svelte +12 -4
  58. package/dist/components/progress/QLinearProgress.svelte.d.ts +14 -2
  59. package/dist/components/radio/QRadio.svelte +3 -1
  60. package/dist/components/radio/QRadio.svelte.d.ts +14 -3
  61. package/dist/components/railbar/QRailbar.svelte +17 -4
  62. package/dist/components/railbar/QRailbar.svelte.d.ts +14 -3
  63. package/dist/components/select/QSelect.svelte +65 -23
  64. package/dist/components/select/QSelect.svelte.d.ts +14 -3
  65. package/dist/components/select/index.scss +1 -1
  66. package/dist/components/separator/QSeparator.svelte +4 -1
  67. package/dist/components/separator/QSeparator.svelte.d.ts +14 -3
  68. package/dist/components/switch/QSwitch.svelte +20 -6
  69. package/dist/components/switch/QSwitch.svelte.d.ts +14 -3
  70. package/dist/components/table/QTable.svelte +47 -19
  71. package/dist/components/table/QTable.svelte.d.ts +14 -3
  72. package/dist/components/tabs/QTab.svelte +32 -9
  73. package/dist/components/tabs/QTab.svelte.d.ts +14 -3
  74. package/dist/components/tabs/QTabs.svelte +58 -16
  75. package/dist/components/tabs/QTabs.svelte.d.ts +14 -3
  76. package/dist/components/toolbar/QToolbar.svelte +3 -1
  77. package/dist/components/toolbar/QToolbar.svelte.d.ts +14 -3
  78. package/dist/components/toolbar/QToolbarTitle.svelte +3 -1
  79. package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +14 -3
  80. package/dist/components/tooltip/QTooltip.svelte +8 -1
  81. package/dist/components/tooltip/QTooltip.svelte.d.ts +14 -3
  82. package/dist/css/classes/_index.scss +7 -7
  83. package/dist/css/fonts.scss +3 -2
  84. package/dist/css/index.css +1 -1
  85. package/dist/css/index.scss +7 -5
  86. package/dist/css/mixins/_design.scss +5 -4
  87. package/dist/css/mixins/_image.scss +2 -1
  88. package/dist/css/mixins/_index.scss +9 -9
  89. package/dist/css/theme/_index.scss +12 -0
  90. package/dist/css/theme/_page.scss +17 -0
  91. package/dist/css/theme/{palette.scss → _palette.scss} +5 -3
  92. package/dist/helpers/version.d.ts +1 -1
  93. package/dist/helpers/version.js +1 -1
  94. package/dist/utils/types.json +1 -1
  95. package/package.json +27 -28
  96. package/dist/css/flex.scss +0 -41
  97. package/dist/css/theme/page.scss +0 -16
  98. package/dist/css/theme/theme.scss +0 -10
  99. /package/dist/css/theme/{colors.module.scss → _color-classes.scss} +0 -0
  100. /package/dist/css/theme/{css-variables.scss → _css-variables.scss} +0 -0
  101. /package/dist/css/theme/{elevate.scss → _elevate.scss} +0 -0
  102. /package/dist/css/theme/{reset.scss → _reset.scss} +0 -0
  103. /package/dist/css/theme/{typography.module.scss → _typography-classes.scss} +0 -0
  104. /package/dist/css/theme/{tokens.scss → _typography-variables.scss} +0 -0
  105. /package/dist/css/theme/{typography.scss → _typography.scss} +0 -0
@@ -7,6 +7,7 @@
7
7
  getClosestFocusableBlock,
8
8
  getClosestFocusableSibling,
9
9
  } from "../../utils/dom";
10
+ import type { Direction } from "../../utils/events";
10
11
  import {
11
12
  getDirection,
12
13
  isActivationKey,
@@ -14,45 +15,67 @@
14
15
  isTabKey,
15
16
  } from "../../utils/events";
16
17
  import { isRouteActive } from "../../utils/router";
17
- let { name, to, icon, children, ...props } = $props();
18
- let qTab;
18
+ import type { QEvent } from "../../utils/types";
19
+ import type { QTabEl } from "./QTabs.svelte";
20
+ import type { QTabProps, QTabsVariants } from "./props";
21
+
22
+ type QTabEvent<T> = QEvent<T, QTabEl>;
23
+
24
+ let { name, to, icon, children, ...props }: QTabProps = $props();
25
+
26
+ let qTab: QTabEl;
27
+
19
28
  const tag = $derived(to ? "a" : "button");
29
+
20
30
  if (!hasContext("QTabsValue")) {
21
31
  console.warn("QTab should be use inside QTabs.");
22
32
  }
23
- const qTabsRequestCtx = QContext.get("QTabsRequest");
24
- const qTabsValueCtx = QContext.get("QTabsValue");
25
- const variant = getContext("QTabsVariant");
33
+
34
+ const qTabsRequestCtx = QContext.get<string | null>("QTabsRequest")!;
35
+
36
+ const qTabsValueCtx = QContext.get<string | undefined | null>("QTabsValue")!;
37
+ const variant = getContext<QTabsVariants>("QTabsVariant");
26
38
  const isActive = $derived(
27
39
  to ? $isRouteActive(to) : name === qTabsValueCtx.value,
28
40
  );
29
- function onclick(e) {
41
+
42
+ function onclick(e: QTabEvent<MouseEvent>) {
30
43
  props.onclick?.(e);
44
+
31
45
  if (e.defaultPrevented || isActive) {
32
46
  return;
33
47
  }
48
+
34
49
  qTabsRequestCtx.update(name);
35
50
  }
36
- function onkeydown(e) {
51
+
52
+ function onkeydown(e: QTabEvent<KeyboardEvent>) {
37
53
  props.onkeydown?.(e);
54
+
38
55
  if (isActivationKey(e)) {
39
56
  e.preventDefault();
40
- const click = new MouseEvent("click");
57
+
58
+ const click = new MouseEvent("click") as QTabEvent<MouseEvent>;
41
59
  return onclick(click);
42
60
  }
61
+
43
62
  if (isArrowKey(e)) {
44
63
  e.preventDefault();
45
64
  const direction = getDirection(e);
46
65
  const targetTab = getClosestFocusableSibling(qTab, direction);
66
+
47
67
  if (targetTab === qTab) {
48
68
  return;
49
69
  }
70
+
50
71
  return targetTab?.focus();
51
72
  }
73
+
52
74
  if (isTabKey(e)) {
53
75
  e.preventDefault();
54
- const direction = e.shiftKey ? "previous" : "next";
76
+ const direction: Direction = e.shiftKey ? "previous" : "next";
55
77
  const targetBlock = getClosestFocusableBlock(qTab, direction);
78
+
56
79
  targetBlock?.focus();
57
80
  }
58
81
  }
@@ -1,3 +1,14 @@
1
- import type { QTabProps } from "./props";
2
- declare const QTab: import("svelte").Component<QTabProps, {}, "">;
3
- export default QTab;
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ type QTabProps_ = typeof __propDef.props;
10
+ export { QTabProps_ as QTabProps };
11
+ export type QTabEvents = typeof __propDef.events;
12
+ export type QTabSlots = typeof __propDef.slots;
13
+ export default class QTab extends SvelteComponentTyped<QTabProps_, QTabEvents, QTabSlots> {
14
+ }
@@ -1,39 +1,63 @@
1
- <script context="module" lang="ts"></script>
1
+ <script context="module" lang="ts">
2
+ export type QTabEl = HTMLAnchorElement | HTMLButtonElement;
3
+ export type QTabsElementsContext = {
4
+ previous: QTabEl | null;
5
+ active: QTabEl | null;
6
+ };
7
+ </script>
2
8
 
3
9
  <script lang="ts">
4
10
  import { setContext, untrack } from "svelte";
5
11
  import QContext from "../../classes/QContext.svelte";
6
12
  import { shouldReduceMotion } from "../../utils/dom";
13
+ import type { QTabsProps } from "./props";
14
+
7
15
  let {
8
16
  value = $bindable(),
9
17
  variant = "primary",
10
18
  round = false,
11
19
  children,
12
20
  ...props
13
- } = $props();
14
- let qTabs;
15
- let tabList;
16
- const valueContext = new QContext("QTabsValue", value);
17
- const requestContext = new QContext("QTabsRequest", null);
21
+ }: QTabsProps = $props();
22
+
23
+ let qTabs: HTMLElement;
24
+ let tabList: HTMLElement[];
25
+
26
+ const valueContext = new QContext<string | undefined | null>(
27
+ "QTabsValue",
28
+ value,
29
+ );
30
+ const requestContext = new QContext<string | null>("QTabsRequest", null);
31
+
32
+ // Set the variant context
18
33
  setContext("QTabsVariant", variant);
34
+
19
35
  $effect(() => {
20
36
  tabList = Array.from(qTabs.querySelectorAll(".q-tab"));
21
37
  });
38
+
39
+ // Update the context when "value" changes
22
40
  $effect(() => {
23
41
  if (!value) {
24
42
  return;
25
43
  }
44
+
26
45
  untrack(() => {
27
- const newTab = getResquetingTab(value);
46
+ const newTab = getResquetingTab(value!);
28
47
  animateIndicator(newTab);
48
+
29
49
  valueContext.update(value);
30
50
  });
31
51
  });
52
+
53
+ // Try to update "value" when context changes from a QTab
32
54
  $effect(() => {
33
55
  const request = requestContext.value;
56
+
34
57
  if (!request) {
35
58
  return;
36
59
  }
60
+
37
61
  const defaultPrevented = !dispatchEvent(
38
62
  new Event("change", { bubbles: true, cancelable: true }),
39
63
  );
@@ -41,30 +65,37 @@
41
65
  if (defaultPrevented || !requester) {
42
66
  return;
43
67
  }
68
+
44
69
  untrack(() => {
45
70
  value = request;
46
71
  });
47
72
  });
48
- function getResquetingTab(requestingTabName) {
73
+
74
+ function getResquetingTab(requestingTabName: string) {
49
75
  return (
50
76
  tabList.find(
51
77
  (tab) => tab.getAttribute("aria-label") === requestingTabName,
52
78
  ) ?? null
53
79
  );
54
80
  }
81
+
55
82
  function getActiveTab() {
56
83
  return (
57
84
  tabList.find((tab) => tab.getAttribute("aria-current") === "true") ?? null
58
85
  );
59
86
  }
60
- function animateIndicator(newTab) {
87
+
88
+ function animateIndicator(newTab: HTMLElement | null) {
61
89
  const qIndicator = newTab?.querySelector(".q-tab__indicator");
90
+
62
91
  if (!qIndicator) {
63
92
  return;
64
93
  }
94
+
65
95
  const previousTab = getActiveTab();
96
+
66
97
  qIndicator.getAnimations().forEach((animation) => animation.cancel());
67
- const frames = getKeyframes(previousTab, newTab);
98
+ const frames = getKeyframes(previousTab, newTab!);
68
99
  if (frames) {
69
100
  qIndicator.animate(frames, {
70
101
  duration: 600,
@@ -72,30 +103,38 @@
72
103
  });
73
104
  }
74
105
  }
75
- function getKeyframes(oldTab, newTab) {
106
+
107
+ function getKeyframes(oldTab: HTMLElement | null, newTab: HTMLElement) {
76
108
  const reduceMotion = shouldReduceMotion();
77
109
  if (!oldTab) {
78
110
  return reduceMotion ? [{ opacity: 1 }, { transform: "none" }] : null;
79
111
  }
112
+
80
113
  const previousEl =
81
114
  variant === "primary" ? oldTab?.querySelector(".q-tab__content") : oldTab;
82
115
  const activeEl =
83
116
  variant === "primary" ? newTab?.querySelector(".q-tab__content") : newTab;
117
+
84
118
  const pos = variant === "vertical" ? "top" : "left";
85
119
  const extent = variant === "vertical" ? "height" : "width";
86
120
  const axis = variant === "vertical" ? "Y" : "X";
87
- const fromRect = previousEl?.getBoundingClientRect() ?? {};
121
+
122
+ const fromRect = previousEl?.getBoundingClientRect() ?? ({} as DOMRect);
88
123
  const fromPos = fromRect[pos];
89
124
  const fromExtent = fromRect[extent];
90
- const toRect = activeEl?.getBoundingClientRect() ?? {};
125
+
126
+ const toRect = activeEl?.getBoundingClientRect() ?? ({} as DOMRect);
91
127
  const toPos = toRect[pos];
92
128
  const toExtent = toRect[extent];
129
+
93
130
  const scale = fromExtent / toExtent;
94
- const keyframe = {};
131
+
132
+ const keyframe: Keyframe = {};
133
+
95
134
  if (
96
135
  !reduceMotion &&
97
- fromPos !== void 0 &&
98
- toPos !== void 0 &&
136
+ fromPos !== undefined &&
137
+ toPos !== undefined &&
99
138
  !isNaN(scale)
100
139
  ) {
101
140
  const translateAnimation = (fromPos - toPos).toFixed(4);
@@ -104,6 +143,9 @@
104
143
  } else {
105
144
  keyframe.opacity = 0;
106
145
  }
146
+
147
+ // Including `transform: none` avoids quirky Safari behavior
148
+ // that can hide the animation.
107
149
  return [keyframe, { transform: "none" }];
108
150
  }
109
151
  </script>
@@ -1,8 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
1
2
  export type QTabEl = HTMLAnchorElement | HTMLButtonElement;
2
3
  export type QTabsElementsContext = {
3
4
  previous: QTabEl | null;
4
5
  active: QTabEl | null;
5
6
  };
6
- import type { QTabsProps } from "./props";
7
- declare const QTabs: import("svelte").Component<QTabsProps, {}, "value">;
8
- export default QTabs;
7
+ declare const __propDef: {
8
+ props: Record<string, never>;
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ type QTabsProps_ = typeof __propDef.props;
15
+ export { QTabsProps_ as QTabsProps };
16
+ export type QTabsEvents = typeof __propDef.events;
17
+ export type QTabsSlots = typeof __propDef.slots;
18
+ export default class QTabs extends SvelteComponentTyped<QTabsProps_, QTabsEvents, QTabsSlots> {
19
+ }
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import type { QToolbarProps } from "./props";
3
+
2
4
  let {
3
5
  inset = false,
4
6
  border = false,
@@ -6,7 +8,7 @@
6
8
  height = 64,
7
9
  children,
8
10
  ...props
9
- } = $props();
11
+ }: QToolbarProps = $props();
10
12
  </script>
11
13
 
12
14
  <nav
@@ -1,3 +1,14 @@
1
- import type { QToolbarProps } from "./props";
2
- declare const QToolbar: import("svelte").Component<QToolbarProps, {}, "">;
3
- export default QToolbar;
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ type QToolbarProps_ = typeof __propDef.props;
10
+ export { QToolbarProps_ as QToolbarProps };
11
+ export type QToolbarEvents = typeof __propDef.events;
12
+ export type QToolbarSlots = typeof __propDef.slots;
13
+ export default class QToolbar extends SvelteComponentTyped<QToolbarProps_, QToolbarEvents, QToolbarSlots> {
14
+ }
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
- let { shrink = false, children, ...props } = $props();
2
+ import type { QToolbarTitleProps } from "./props";
3
+
4
+ let { shrink = false, children, ...props }: QToolbarTitleProps = $props();
3
5
  </script>
4
6
 
5
7
  <div
@@ -1,3 +1,14 @@
1
- import type { QToolbarTitleProps } from "./props";
2
- declare const QToolbarTitle: import("svelte").Component<QToolbarTitleProps, {}, "">;
3
- export default QToolbarTitle;
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ type QToolbarTitleProps_ = typeof __propDef.props;
10
+ export { QToolbarTitleProps_ as QToolbarTitleProps };
11
+ export type QToolbarTitleEvents = typeof __propDef.events;
12
+ export type QToolbarTitleSlots = typeof __propDef.slots;
13
+ export default class QToolbarTitle extends SvelteComponentTyped<QToolbarTitleProps_, QToolbarTitleEvents, QToolbarTitleSlots> {
14
+ }
@@ -1,5 +1,12 @@
1
1
  <script lang="ts">
2
- let { value, position = "bottom", children, ...props } = $props();
2
+ import type { QTooltipProps } from "./props";
3
+
4
+ let {
5
+ value,
6
+ position = "bottom",
7
+ children,
8
+ ...props
9
+ }: QTooltipProps = $props();
3
10
  </script>
4
11
 
5
12
  <div
@@ -1,3 +1,14 @@
1
- import type { QTooltipProps } from "./props";
2
- declare const QTooltip: import("svelte").Component<QTooltipProps, {}, "">;
3
- export default QTooltip;
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ type QTooltipProps_ = typeof __propDef.props;
10
+ export { QTooltipProps_ as QTooltipProps };
11
+ export type QTooltipEvents = typeof __propDef.events;
12
+ export type QTooltipSlots = typeof __propDef.slots;
13
+ export default class QTooltip extends SvelteComponentTyped<QTooltipProps_, QTooltipEvents, QTooltipSlots> {
14
+ }
@@ -1,7 +1,7 @@
1
- @import "design";
2
- @import "flex";
3
- @import "grid";
4
- @import "overflow";
5
- @import "position";
6
- @import "select";
7
- @import "spaces";
1
+ @forward "design";
2
+ @forward "flex";
3
+ @forward "grid";
4
+ @forward "overflow";
5
+ @forward "position";
6
+ @forward "select";
7
+ @forward "spaces";
@@ -1,7 +1,8 @@
1
- @import "@fontsource/roboto";
1
+ @use "sass:string";
2
+ @use "@fontsource/roboto";
2
3
 
3
4
  @mixin font-face-declaration($font-name) {
4
- $file-name: to-lower-case($font-name);
5
+ $file-name: string.to-lower-case($font-name);
5
6
 
6
7
  @font-face {
7
8
  font-family: "Material Symbols #{$font-name}";