@quaffui/quaff 0.1.0-prealpha7 → 0.1.0-prealpha9

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 (103) hide show
  1. package/dist/components/avatar/QAvatar.svelte +8 -7
  2. package/dist/components/avatar/props.d.ts +2 -2
  3. package/dist/components/button/QBtn.svelte +20 -7
  4. package/dist/components/button/QBtn.svelte.d.ts +0 -1
  5. package/dist/components/button/index.scss +18 -1
  6. package/dist/components/button/props.d.ts +2 -2
  7. package/dist/components/chip/QChip.svelte +8 -2
  8. package/dist/components/chip/props.d.ts +2 -2
  9. package/dist/components/dialog/QDialog.svelte +28 -13
  10. package/dist/components/dialog/QDialog.svelte.d.ts +0 -1
  11. package/dist/components/drawer/QDrawer.svelte +49 -37
  12. package/dist/components/drawer/index.scss +11 -8
  13. package/dist/components/drawer/props.d.ts +2 -2
  14. package/dist/components/footer/QFooter.svelte +18 -4
  15. package/dist/components/footer/QFooter.svelte.d.ts +2 -2
  16. package/dist/components/footer/index.scss +23 -0
  17. package/dist/components/footer/props.d.ts +4 -4
  18. package/dist/components/header/QHeader.svelte +28 -0
  19. package/dist/components/header/QHeader.svelte.d.ts +24 -0
  20. package/dist/components/header/props.d.ts +15 -0
  21. package/dist/components/header/props.js +1 -0
  22. package/dist/components/icon/QIcon.svelte +5 -12
  23. package/dist/components/icon/props.d.ts +2 -2
  24. package/dist/components/index.d.ts +2 -1
  25. package/dist/components/index.js +2 -1
  26. package/dist/components/layout/index.scss +89 -75
  27. package/dist/components/list/index.scss +1 -0
  28. package/dist/components/private/QApi.svelte +3 -1
  29. package/dist/components/progress/QCircularProgress.svelte +4 -3
  30. package/dist/components/progress/QCircularProgress.svelte.d.ts +1 -1
  31. package/dist/components/progress/props.d.ts +26 -9
  32. package/dist/components/progress/props.js +1 -7
  33. package/dist/components/railbar/QRailbar.svelte +48 -29
  34. package/dist/components/railbar/QRailbar.svelte.d.ts +1 -1
  35. package/dist/components/railbar/index.scss +39 -0
  36. package/dist/components/railbar/props.d.ts +11 -3
  37. package/dist/components/railbar/props.js +1 -7
  38. package/dist/components/tabs/QTab.svelte +44 -16
  39. package/dist/components/tabs/QTab.svelte.d.ts +1 -3
  40. package/dist/components/tabs/QTabs.svelte +3 -7
  41. package/dist/components/tabs/index.scss +40 -9
  42. package/dist/components/toolbar/QToolbar.svelte +6 -22
  43. package/dist/components/toolbar/QToolbar.svelte.d.ts +3 -1
  44. package/dist/components/toolbar/index.scss +8 -0
  45. package/dist/components/toolbar/props.d.ts +19 -4
  46. package/dist/components/toolbar/props.js +1 -10
  47. package/dist/composables/use-size.d.ts +8 -8
  48. package/dist/composables/use-size.js +23 -13
  49. package/dist/css/index.css +1 -1
  50. package/dist/css/index.scss +2 -2
  51. package/dist/css/mixins.scss +1 -3
  52. package/dist/css/ripple.scss +42 -0
  53. package/dist/css/states.scss +6 -2
  54. package/dist/helpers/ripple.d.ts +10 -0
  55. package/dist/helpers/ripple.js +75 -0
  56. package/dist/helpers/version.d.ts +1 -1
  57. package/dist/helpers/version.js +1 -1
  58. package/dist/index.d.ts +1 -0
  59. package/dist/index.js +1 -0
  60. package/dist/utils/dom.d.ts +8 -0
  61. package/dist/utils/dom.js +71 -0
  62. package/dist/utils/events.d.ts +13 -0
  63. package/dist/utils/events.js +13 -0
  64. package/dist/utils/props.d.ts +1 -1
  65. package/dist/utils/props.js +1 -1
  66. package/dist/utils/types.d.ts +3 -0
  67. package/package.json +1 -1
  68. package/dist/css/material-symbols-outlined-latin-100-normal.woff +0 -0
  69. package/dist/css/material-symbols-outlined-latin-100-normal.woff2 +0 -0
  70. package/dist/css/material-symbols-outlined-latin-200-normal.woff +0 -0
  71. package/dist/css/material-symbols-outlined-latin-200-normal.woff2 +0 -0
  72. package/dist/css/material-symbols-outlined-latin-300-normal.woff +0 -0
  73. package/dist/css/material-symbols-outlined-latin-300-normal.woff2 +0 -0
  74. package/dist/css/material-symbols-outlined-latin-400-normal.woff +0 -0
  75. package/dist/css/material-symbols-outlined-latin-400-normal.woff2 +0 -0
  76. package/dist/css/material-symbols-rounded-latin-100-normal.woff +0 -0
  77. package/dist/css/material-symbols-rounded-latin-100-normal.woff2 +0 -0
  78. package/dist/css/material-symbols-rounded-latin-200-normal.woff +0 -0
  79. package/dist/css/material-symbols-rounded-latin-200-normal.woff2 +0 -0
  80. package/dist/css/material-symbols-rounded-latin-300-normal.woff +0 -0
  81. package/dist/css/material-symbols-rounded-latin-300-normal.woff2 +0 -0
  82. package/dist/css/material-symbols-rounded-latin-400-normal.woff +0 -0
  83. package/dist/css/material-symbols-rounded-latin-400-normal.woff2 +0 -0
  84. package/dist/css/material-symbols-sharp-latin-100-normal.woff +0 -0
  85. package/dist/css/material-symbols-sharp-latin-100-normal.woff2 +0 -0
  86. package/dist/css/material-symbols-sharp-latin-200-normal.woff +0 -0
  87. package/dist/css/material-symbols-sharp-latin-200-normal.woff2 +0 -0
  88. package/dist/css/material-symbols-sharp-latin-300-normal.woff +0 -0
  89. package/dist/css/material-symbols-sharp-latin-300-normal.woff2 +0 -0
  90. package/dist/css/material-symbols-sharp-latin-400-normal.woff +0 -0
  91. package/dist/css/material-symbols-sharp-latin-400-normal.woff2 +0 -0
  92. package/dist/css/roboto-cyrillic-400-normal.woff +0 -0
  93. package/dist/css/roboto-cyrillic-400-normal.woff2 +0 -0
  94. package/dist/css/roboto-cyrillic-ext-400-normal.woff +0 -0
  95. package/dist/css/roboto-cyrillic-ext-400-normal.woff2 +0 -0
  96. package/dist/css/roboto-greek-400-normal.woff +0 -0
  97. package/dist/css/roboto-greek-400-normal.woff2 +0 -0
  98. package/dist/css/roboto-latin-400-normal.woff +0 -0
  99. package/dist/css/roboto-latin-400-normal.woff2 +0 -0
  100. package/dist/css/roboto-latin-ext-400-normal.woff +0 -0
  101. package/dist/css/roboto-latin-ext-400-normal.woff2 +0 -0
  102. package/dist/css/roboto-vietnamese-400-normal.woff +0 -0
  103. package/dist/css/roboto-vietnamese-400-normal.woff2 +0 -0
@@ -1,7 +1,15 @@
1
- import { type NativeProps } from "../../utils/types";
1
+ import type { NativeProps, CssValue } from "../../utils/types";
2
2
  export interface QRailbarProps extends NativeProps {
3
- width: number | string;
3
+ /**
4
+ * @default 88px
5
+ */
6
+ width: CssValue | number;
7
+ /**
8
+ * @default left
9
+ */
4
10
  side: "left" | "right";
11
+ /**
12
+ * @default false
13
+ */
5
14
  bordered: boolean;
6
15
  }
7
- export declare const QRailbarPropsDefaults: QRailbarProps;
@@ -1,7 +1 @@
1
- import { NativePropsDefaults } from "../../utils/types";
2
- export const QRailbarPropsDefaults = {
3
- width: 88,
4
- side: "left",
5
- bordered: false,
6
- ...NativePropsDefaults,
7
- };
1
+ export {};
@@ -3,10 +3,13 @@ import { getContext, hasContext } from "svelte";
3
3
  import { createClasses } from "../../utils/props";
4
4
  import QIcon from "../icon/QIcon.svelte";
5
5
  import { isRouteActive } from "../../composables/use-router-link";
6
+ import { getDirection, isActivationKey, isArrowKey, isTabKey } from "../../utils/events";
7
+ import { ripple } from "../../helpers/ripple";
8
+ import { getClosestFocusableBlock, getClosestFocusableSibling } from "../../utils/dom";
6
9
  export let name = void 0, to = void 0, icon = void 0, userClasses = void 0;
7
10
  export { userClasses as class };
8
11
  let index = 1;
9
- let tabEl;
12
+ let qTab;
10
13
  if (!hasContext("QTabCount")) {
11
14
  console.warn("QTab should be used inside QTabs");
12
15
  }
@@ -20,23 +23,21 @@ let activeStore = getContext("activeTab");
20
23
  $:
21
24
  isActive = to !== void 0 ? isRouteActive($Quaff.router, to) : name === $activeStore.name;
22
25
  $:
23
- if (isActive && tabEl) {
24
- setActive(tabEl);
26
+ if (isActive && qTab) {
27
+ setActive(qTab);
25
28
  }
26
29
  let tag;
27
30
  $:
28
31
  tag = to === void 0 ? "button" : "a";
29
32
  $:
30
- classes = createClasses([
31
- "q-tab",
32
- isActive ? "active primary-text on-surface-text" : "surface on-surface-variant-text",
33
- tag === "a" && "button",
33
+ classes = createClasses([isActive && "active"], {
34
+ component: "q-tab",
34
35
  userClasses
35
- ]);
36
+ });
36
37
  function setActive(el) {
37
38
  let rect;
38
39
  if (variant === "primary") {
39
- rect = el.firstChild.getBoundingClientRect();
40
+ rect = el.firstElementChild.getBoundingClientRect();
40
41
  } else {
41
42
  rect = el.getBoundingClientRect();
42
43
  }
@@ -51,25 +52,52 @@ function setActive(el) {
51
52
  };
52
53
  }
53
54
  }
54
- function handleClick(e) {
55
+ function onClick(e) {
55
56
  setActive(e.target);
56
57
  }
58
+ function onKeydown(e) {
59
+ if (isActivationKey(e)) {
60
+ e.preventDefault();
61
+ const click = new MouseEvent("click");
62
+ qTab.dispatchEvent(click);
63
+ return;
64
+ }
65
+ if (isArrowKey(e)) {
66
+ e.preventDefault();
67
+ const direction = getDirection(e);
68
+ const targetTab = getClosestFocusableSibling(qTab, direction);
69
+ if (targetTab === qTab) {
70
+ return;
71
+ }
72
+ targetTab?.focus();
73
+ return;
74
+ }
75
+ if (isTabKey(e)) {
76
+ e.preventDefault();
77
+ const direction = e.shiftKey ? "previous" : "next";
78
+ const targetBlock = getClosestFocusableBlock(qTab, direction);
79
+ targetBlock?.focus();
80
+ }
81
+ return;
82
+ }
57
83
  </script>
58
84
 
59
85
  <svelte:element
60
86
  this={tag}
87
+ use:ripple
61
88
  href={to}
62
89
  class={classes}
63
- on:click={handleClick}
64
- on:keyup
65
- on:keydown
66
- on:keypress
90
+ role={tag === "a" ? "button" : undefined}
91
+ aria-current={isActive || undefined}
92
+ on:click
93
+ on:click={onClick}
94
+ on:keydown={onKeydown}
67
95
  {...$$restProps}
68
- bind:this={tabEl}
96
+ bind:this={qTab}
69
97
  >
70
98
  <div>
71
99
  {#if icon}
72
- <QIcon name={icon} />
100
+ <QIcon name={icon} class="q-tab__icon" />
73
101
  {:else if $$slots.icon}
74
102
  <slot name="icon" />
75
103
  {/if}
@@ -9,9 +9,7 @@ declare const __propDef: {
9
9
  class?: string | undefined;
10
10
  };
11
11
  events: {
12
- keyup: KeyboardEvent;
13
- keydown: KeyboardEvent;
14
- keypress: KeyboardEvent;
12
+ click: MouseEvent;
15
13
  } & {
16
14
  [evt: string]: CustomEvent<any>;
17
15
  };
@@ -27,14 +27,10 @@ setContext("variant", variant);
27
27
  $:
28
28
  value = $activeTabStore.name;
29
29
  $:
30
- classes = createClasses([
31
- "q-tabs",
32
- variant === "vertical" && "vertical-tabs",
33
- round && "round",
34
- variant === "primary" && "small-indicator",
35
- hidden && "hidden-indicator",
30
+ classes = createClasses([variant, round && "rounded", hidden && "hidden-indicator"], {
31
+ component: "q-tabs",
36
32
  userClasses
37
- ]);
33
+ });
38
34
  let indicatorWidth = derived(activeTabStore, ($activeTabStore2) => {
39
35
  return variant === "primary" ? `calc(${$activeTabStore2.size}px + 8px)` : `${$activeTabStore2.size}px`;
40
36
  });
@@ -6,11 +6,14 @@
6
6
  max-width: 100%;
7
7
  overflow: auto;
8
8
  scroll-behavior: smooth;
9
+ border-radius: 0;
10
+ border-bottom: solid 0.0625rem var(--outline);
9
11
  &::-webkit-scrollbar {
10
12
  display: none;
11
13
  }
12
14
 
13
15
  & > .q-tab {
16
+ position: relative;
14
17
  box-sizing: border-box;
15
18
  height: 48px;
16
19
  min-width: max-content;
@@ -18,24 +21,52 @@
18
21
  align-items: center;
19
22
  justify-content: center;
20
23
  flex: 1;
21
- background-color: unset;
24
+ background-color: var(--surface);
25
+ color: var(--on-surface);
22
26
  border-radius: 0;
23
27
  gap: 0;
28
+ overflow: hidden;
24
29
 
25
- & > .q-icon {
26
- margin-right: 8px;
30
+ & .q-tab__icon {
31
+ margin-right: 0.25rem;
27
32
  }
28
33
 
29
- &:is(:hover, :focus)::after {
30
- background-image: radial-gradient(circle, var(--on-surface-variant-2) 1%, transparent 1%);
34
+ &--active {
35
+ color: var(--primary);
36
+ }
37
+
38
+ &:is(:hover, :focus):not([aria-disabled])::after {
39
+ content: "";
40
+ position: absolute;
41
+ top: 0;
42
+ left: 0;
43
+ width: 100%;
44
+ height: 100%;
45
+ background-color: var(--on-surface);
46
+ border-radius: none;
47
+ overflow: hidden;
48
+ }
49
+
50
+ &:hover:not([aria-disabled])::after {
51
+ opacity: 0.08;
52
+ }
53
+
54
+ &:focus:not([aria-disabled])::after {
55
+ opacity: 0.16;
31
56
  }
32
57
  }
33
58
 
34
- &.vertical-tabs {
59
+ &.q-tabs--vertical {
35
60
  flex-direction: column;
36
- min-height: calc(var(--tab-count) * 48px);
61
+ min-height: calc(var(--tab-count) * 3rem);
37
62
  width: fit-content;
38
63
  align-items: stretch;
64
+ border-bottom: unset;
65
+ border-right: solid 0.0625rem var(--outline);
66
+
67
+ & > .q-tab {
68
+ @include padding("x", "md");
69
+ }
39
70
 
40
71
  &::after {
41
72
  top: var(--indicator-position);
@@ -62,11 +93,11 @@
62
93
  opacity: 0;
63
94
  }
64
95
 
65
- &:not(.hidden-indicator)::after {
96
+ &:not(.q-tabs--hidden-indicator)::after {
66
97
  opacity: 1;
67
98
  }
68
99
 
69
- &.small-indicator::after {
100
+ &.q-tabs--primary::after {
70
101
  left: var(--indicator-position);
71
102
  transform: translateX(-50%);
72
103
  height: 3px;
@@ -1,32 +1,16 @@
1
1
  <script>import { createClasses, createStyles } from "../../utils/props";
2
- import { getContext } from "svelte";
3
- import { isNumber } from "../../utils/types";
4
- export let inset = false, height = "64px", userClasses = void 0, userStyles = void 0;
2
+ import { useSize } from "../../composables/use-size";
3
+ export let inset = false, border = false, elevate = false, height = "64px", userClasses = void 0, userStyles = void 0;
5
4
  export { userClasses as class, userStyles as style };
6
- let ctx = getContext("layout");
7
5
  $:
8
- classes = createClasses([
9
- $ctx?.header && "q-header",
10
- "q-toolbar",
11
- "surface",
12
- $ctx?.header?.fixed && "fixed",
13
- inset && "q-toolbar--inset",
6
+ classes = createClasses([inset && "inset", elevate && "elevated", border && "bordered"], {
7
+ component: "q-toolbar",
14
8
  userClasses
15
- ]);
16
- $:
17
- heightStyle = ctx === void 0 ? isNumber(height) ? `${height}px` : height : void 0;
18
- $:
19
- if ($ctx?.header !== void 0) {
20
- if (userStyles?.includes("display: none")) {
21
- $ctx.header.display = false;
22
- } else {
23
- $ctx.header.display = true;
24
- }
25
- }
9
+ });
26
10
  $:
27
11
  style = createStyles(
28
12
  {
29
- "--header-height": heightStyle
13
+ height: !userClasses?.includes("q-header") && useSize(height).style
30
14
  },
31
15
  userStyles
32
16
  );
@@ -4,7 +4,9 @@ declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
6
  inset?: boolean | undefined;
7
- height?: string | number | undefined;
7
+ border?: boolean | undefined;
8
+ elevate?: boolean | undefined;
9
+ height?: number | `${number}px` | `${number}%` | `${number}em` | `${number}ex` | `${number}ch` | `${number}rem` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | undefined;
8
10
  class?: string | undefined;
9
11
  style?: string | undefined;
10
12
  };
@@ -19,6 +19,14 @@
19
19
  &--inset {
20
20
  padding-left: 58px;
21
21
  }
22
+
23
+ &--elevated {
24
+ @include elevate(1, "bottom");
25
+ }
26
+
27
+ &--bordered {
28
+ border-bottom: solid 0.0625rem var(--outline);
29
+ }
22
30
  }
23
31
 
24
32
  .q-toolbar-title {
@@ -1,10 +1,25 @@
1
- import type { NativeProps } from "../../utils/types";
1
+ import type { NativeProps, CssValue } from "../../utils/types";
2
2
  export interface QToolbarProps extends NativeProps {
3
+ /**
4
+ * @default false
5
+ */
3
6
  inset: boolean;
4
- height: string | number;
7
+ /**
8
+ * @default false
9
+ */
10
+ border: boolean;
11
+ /**
12
+ * @default false
13
+ */
14
+ elevate: boolean;
15
+ /**
16
+ * @default 64px
17
+ */
18
+ height: CssValue | number;
5
19
  }
6
- export declare const QToolbarPropsDefaults: QToolbarProps;
7
20
  export interface QToolbarTitleProps extends NativeProps {
21
+ /**
22
+ * @default false
23
+ */
8
24
  shrink: boolean;
9
25
  }
10
- export declare const QToolbarTitlePropsDefaults: QToolbarTitleProps;
@@ -1,10 +1 @@
1
- import { NativePropsDefaults } from "../../utils/types";
2
- export const QToolbarPropsDefaults = {
3
- inset: false,
4
- height: "64px",
5
- ...NativePropsDefaults,
6
- };
7
- export const QToolbarTitlePropsDefaults = {
8
- shrink: false,
9
- ...NativePropsDefaults,
10
- };
1
+ export {};
@@ -1,9 +1,9 @@
1
- export type Size = "xs" | "sm" | "md" | "lg" | "xl";
2
- export declare const sizes: Size[];
3
- export declare const useSizeClasses: {
4
- [key in Size]: string;
5
- };
6
- export interface useSizeProps {
7
- size?: string;
1
+ import { CssUnit, QuaffSizes } from "../utils/types";
2
+ export declare const sizes: QuaffSizes[];
3
+ export declare const CssUnits: CssUnit[];
4
+ interface UseSize {
5
+ class?: string;
6
+ style?: string;
8
7
  }
9
- export default function (sizeProp: any): string | null;
8
+ export declare function useSize(sizeProp: any): UseSize;
9
+ export {};
@@ -1,15 +1,25 @@
1
+ import { isNumber } from "../utils/types";
1
2
  export const sizes = ["xs", "sm", "md", "lg", "xl"];
2
- // @todo change classes or deprecate
3
- export const useSizeClasses = {
4
- xs: "tiny",
5
- sm: "small",
6
- md: "",
7
- lg: "large",
8
- xl: "extra",
9
- };
10
- export default function (sizeProp) {
11
- // return sizeStyle
12
- return sizeProp in useSizeClasses
13
- ? useSizeClasses[sizeProp]
14
- : null;
3
+ export const CssUnits = ["px", "%", "em", "ex", "ch", "rem", "vw", "vh", "vmin", "vmax"];
4
+ export function useSize(sizeProp) {
5
+ if (isNumber(sizeProp) && sizeProp > 0) {
6
+ return {
7
+ style: `${sizeProp}px`,
8
+ };
9
+ }
10
+ else if (typeof sizeProp === "string") {
11
+ for (let unit of CssUnits) {
12
+ if (sizeProp.slice(-unit.length) === unit) {
13
+ return {
14
+ style: sizeProp,
15
+ };
16
+ }
17
+ else if (sizes.includes(sizeProp)) {
18
+ return {
19
+ class: sizeProp,
20
+ };
21
+ }
22
+ }
23
+ }
24
+ return {};
15
25
  }