@quaffui/quaff 1.0.0-beta1 → 1.0.0-beta13

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 (218) hide show
  1. package/README.md +2 -0
  2. package/dist/classes/QScrollObserver.svelte.d.ts +4 -4
  3. package/dist/classes/QScrollObserver.svelte.js +26 -13
  4. package/dist/classes/Quaff.svelte.d.ts +3 -0
  5. package/dist/classes/Quaff.svelte.js +21 -17
  6. package/dist/components/avatar/QAvatar.svelte +4 -0
  7. package/dist/components/avatar/QAvatar.svelte.d.ts +4 -14
  8. package/dist/components/breadcrumbs/QBreadcrumbs.scss +9 -5
  9. package/dist/components/breadcrumbs/QBreadcrumbs.svelte +46 -16
  10. package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +24 -12
  11. package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +22 -3
  12. package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +50 -38
  13. package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +4 -14
  14. package/dist/components/breadcrumbs/props.d.ts +4 -4
  15. package/dist/components/button/QBtn.scss +3 -1
  16. package/dist/components/button/QBtn.svelte +38 -22
  17. package/dist/components/button/QBtn.svelte.d.ts +4 -14
  18. package/dist/components/button/props.d.ts +9 -2
  19. package/dist/components/card/QCard.svelte +9 -5
  20. package/dist/components/card/QCard.svelte.d.ts +4 -14
  21. package/dist/components/card/QCardActions.svelte +4 -0
  22. package/dist/components/card/QCardActions.svelte.d.ts +4 -14
  23. package/dist/components/card/QCardSection.svelte +2 -0
  24. package/dist/components/card/QCardSection.svelte.d.ts +4 -14
  25. package/dist/components/checkbox/QCheckbox.svelte +6 -4
  26. package/dist/components/checkbox/QCheckbox.svelte.d.ts +4 -14
  27. package/dist/components/checkbox/props.d.ts +1 -1
  28. package/dist/components/chip/QChip.scss +3 -1
  29. package/dist/components/chip/QChip.svelte +24 -14
  30. package/dist/components/chip/QChip.svelte.d.ts +4 -14
  31. package/dist/components/codeBlock/QCodeBlock.svelte +8 -0
  32. package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +4 -14
  33. package/dist/components/dialog/QDialog.scss +17 -0
  34. package/dist/components/dialog/QDialog.svelte +34 -9
  35. package/dist/components/dialog/QDialog.svelte.d.ts +8 -21
  36. package/dist/components/drawer/QDrawer.scss +2 -2
  37. package/dist/components/drawer/QDrawer.svelte +124 -69
  38. package/dist/components/drawer/QDrawer.svelte.d.ts +8 -21
  39. package/dist/components/drawer/props.d.ts +3 -3
  40. package/dist/components/expansion-item/QExpansionItem.scss +59 -0
  41. package/dist/components/expansion-item/QExpansionItem.svelte +319 -0
  42. package/dist/components/expansion-item/QExpansionItem.svelte.d.ts +8 -0
  43. package/dist/components/expansion-item/docs.d.ts +2 -0
  44. package/dist/components/expansion-item/docs.js +17 -0
  45. package/dist/components/expansion-item/props.d.ts +129 -0
  46. package/dist/components/expansion-item/props.js +1 -0
  47. package/dist/components/footer/QFooter.scss +1 -1
  48. package/dist/components/footer/QFooter.svelte +32 -28
  49. package/dist/components/footer/QFooter.svelte.d.ts +4 -14
  50. package/dist/components/header/QHeader.scss +1 -1
  51. package/dist/components/header/QHeader.svelte +41 -33
  52. package/dist/components/header/QHeader.svelte.d.ts +4 -14
  53. package/dist/components/icon/QIcon.svelte +6 -4
  54. package/dist/components/icon/QIcon.svelte.d.ts +4 -14
  55. package/dist/components/index.d.ts +3 -1
  56. package/dist/components/index.js +3 -1
  57. package/dist/components/input/QInput.svelte +139 -17
  58. package/dist/components/input/QInput.svelte.d.ts +4 -14
  59. package/dist/components/input/docs.js +2 -2
  60. package/dist/components/input/mask.d.ts +10 -0
  61. package/dist/components/input/mask.js +204 -0
  62. package/dist/components/input/props.d.ts +37 -4
  63. package/dist/components/layout/QLayout.svelte +248 -93
  64. package/dist/components/layout/QLayout.svelte.d.ts +67 -15
  65. package/dist/components/layout/props.d.ts +1 -1
  66. package/dist/components/list/QItem.scss +7 -4
  67. package/dist/components/list/QItem.svelte +44 -24
  68. package/dist/components/list/QItem.svelte.d.ts +17 -13
  69. package/dist/components/list/QItemSection.scss +24 -3
  70. package/dist/components/list/QItemSection.svelte +19 -21
  71. package/dist/components/list/QItemSection.svelte.d.ts +4 -14
  72. package/dist/components/list/QList.scss +17 -4
  73. package/dist/components/list/QList.svelte +30 -8
  74. package/dist/components/list/QList.svelte.d.ts +17 -13
  75. package/dist/components/list/props.d.ts +3 -3
  76. package/dist/components/menu/QMenu.scss +37 -0
  77. package/dist/components/menu/QMenu.svelte +314 -0
  78. package/dist/components/menu/QMenu.svelte.d.ts +8 -0
  79. package/dist/components/menu/docs.d.ts +2 -0
  80. package/dist/components/menu/docs.js +27 -0
  81. package/dist/components/menu/props.d.ts +48 -0
  82. package/dist/components/menu/props.js +1 -0
  83. package/dist/components/progress/QCircularProgress.svelte +17 -14
  84. package/dist/components/progress/QCircularProgress.svelte.d.ts +4 -14
  85. package/dist/components/progress/QLinearProgress.svelte +15 -15
  86. package/dist/components/progress/QLinearProgress.svelte.d.ts +4 -14
  87. package/dist/components/radio/QRadio.svelte +6 -4
  88. package/dist/components/radio/QRadio.svelte.d.ts +4 -14
  89. package/dist/components/radio/props.d.ts +1 -1
  90. package/dist/components/railbar/QRailbar.scss +1 -1
  91. package/dist/components/railbar/QRailbar.svelte +36 -35
  92. package/dist/components/railbar/QRailbar.svelte.d.ts +4 -14
  93. package/dist/components/select/QSelect.svelte +316 -102
  94. package/dist/components/select/QSelect.svelte.d.ts +4 -14
  95. package/dist/components/select/filter.d.ts +13 -0
  96. package/dist/components/select/filter.js +73 -0
  97. package/dist/components/select/index.scss +28 -27
  98. package/dist/components/select/option.d.ts +9 -0
  99. package/dist/components/select/option.js +59 -0
  100. package/dist/components/select/props.d.ts +40 -7
  101. package/dist/components/separator/QSeparator.scss +2 -0
  102. package/dist/components/separator/QSeparator.svelte +9 -8
  103. package/dist/components/separator/QSeparator.svelte.d.ts +4 -14
  104. package/dist/components/switch/QSwitch.scss +12 -6
  105. package/dist/components/switch/QSwitch.svelte +7 -1
  106. package/dist/components/switch/QSwitch.svelte.d.ts +4 -14
  107. package/dist/components/table/QTable.svelte +31 -19
  108. package/dist/components/table/QTable.svelte.d.ts +4 -14
  109. package/dist/components/table/index.scss +1 -1
  110. package/dist/components/tabs/QTab.scss +2 -0
  111. package/dist/components/tabs/QTab.svelte +19 -22
  112. package/dist/components/tabs/QTab.svelte.d.ts +4 -14
  113. package/dist/components/tabs/QTabs.svelte +59 -32
  114. package/dist/components/tabs/QTabs.svelte.d.ts +18 -18
  115. package/dist/components/toolbar/QToolbar.svelte +2 -0
  116. package/dist/components/toolbar/QToolbar.svelte.d.ts +4 -14
  117. package/dist/components/toolbar/QToolbarTitle.svelte +2 -0
  118. package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +4 -14
  119. package/dist/components/tooltip/QTooltip.svelte +48 -38
  120. package/dist/components/tooltip/QTooltip.svelte.d.ts +29 -17
  121. package/dist/components/tooltip/QTooltipBase.svelte +18 -8
  122. package/dist/components/tooltip/QTooltipBase.svelte.d.ts +4 -14
  123. package/dist/composables/index.d.ts +2 -0
  124. package/dist/composables/index.js +2 -0
  125. package/dist/composables/useColor.d.ts +1 -0
  126. package/dist/composables/useColor.js +19 -0
  127. package/dist/composables/useRevealScrollObserver.svelte.d.ts +9 -0
  128. package/dist/composables/useRevealScrollObserver.svelte.js +25 -0
  129. package/dist/composables/useRouterLink.d.ts +3 -2
  130. package/dist/composables/useRouterLink.js +2 -2
  131. package/dist/css/_components.scss +2 -0
  132. package/dist/css/classes/_grid.scss +12 -1
  133. package/dist/css/index.css +1 -1
  134. package/dist/css/mixins/_design.scss +1 -1
  135. package/dist/css/mixins/_field.scss +3 -2
  136. package/dist/css/mixins/_table.scss +1 -1
  137. package/dist/css/mixins/_toolbar.scss +1 -1
  138. package/dist/css/shared/q-field.scss +7 -6
  139. package/dist/css/theme/_page.scss +8 -6
  140. package/dist/css/theme/_reset.scss +2 -1
  141. package/dist/helpers/clickOutside.js +5 -4
  142. package/dist/helpers/ripple.js +5 -6
  143. package/dist/helpers/version.d.ts +1 -1
  144. package/dist/helpers/version.js +1 -1
  145. package/dist/{components/private/ContextReseter.svelte → internal/ContextResetter.svelte} +2 -3
  146. package/dist/internal/ContextResetter.svelte.d.ts +8 -0
  147. package/dist/{components/private → internal}/QIconSnippet.svelte +2 -2
  148. package/dist/internal/QIconSnippet.svelte.d.ts +10 -0
  149. package/dist/utils/context.d.ts +49 -32
  150. package/dist/utils/context.js +82 -33
  151. package/dist/utils/dom.d.ts +6 -0
  152. package/dist/utils/dom.js +33 -0
  153. package/dist/utils/events.d.ts +0 -24
  154. package/dist/utils/events.js +0 -24
  155. package/package.json +44 -38
  156. package/dist/classes/QContext.svelte.d.ts +0 -42
  157. package/dist/classes/QContext.svelte.js +0 -63
  158. package/dist/components/avatar/docs.props.d.ts +0 -3
  159. package/dist/components/avatar/docs.props.js +0 -87
  160. package/dist/components/breadcrumbs/docs.props.d.ts +0 -5
  161. package/dist/components/breadcrumbs/docs.props.js +0 -144
  162. package/dist/components/button/docs.props.d.ts +0 -3
  163. package/dist/components/button/docs.props.js +0 -227
  164. package/dist/components/card/docs.props.d.ts +0 -7
  165. package/dist/components/card/docs.props.js +0 -89
  166. package/dist/components/checkbox/docs.props.d.ts +0 -3
  167. package/dist/components/checkbox/docs.props.js +0 -41
  168. package/dist/components/chip/docs.props.d.ts +0 -3
  169. package/dist/components/chip/docs.props.js +0 -137
  170. package/dist/components/codeBlock/docs.props.d.ts +0 -3
  171. package/dist/components/codeBlock/docs.props.js +0 -83
  172. package/dist/components/dialog/docs.props.d.ts +0 -3
  173. package/dist/components/dialog/docs.props.js +0 -65
  174. package/dist/components/drawer/docs.props.d.ts +0 -3
  175. package/dist/components/drawer/docs.props.js +0 -149
  176. package/dist/components/footer/docs.props.d.ts +0 -3
  177. package/dist/components/footer/docs.props.js +0 -65
  178. package/dist/components/header/docs.props.d.ts +0 -7
  179. package/dist/components/header/docs.props.js +0 -131
  180. package/dist/components/icon/docs.props.d.ts +0 -3
  181. package/dist/components/icon/docs.props.js +0 -107
  182. package/dist/components/input/docs.props.d.ts +0 -3
  183. package/dist/components/input/docs.props.js +0 -162
  184. package/dist/components/layout/docs.props.d.ts +0 -3
  185. package/dist/components/layout/docs.props.js +0 -81
  186. package/dist/components/list/docs.props.d.ts +0 -11
  187. package/dist/components/list/docs.props.js +0 -434
  188. package/dist/components/private/ContextReseter.svelte.d.ts +0 -14
  189. package/dist/components/private/QApi.svelte +0 -296
  190. package/dist/components/private/QApi.svelte.d.ts +0 -14
  191. package/dist/components/private/QDocs.svelte +0 -155
  192. package/dist/components/private/QDocs.svelte.d.ts +0 -14
  193. package/dist/components/private/QDocsSection.svelte +0 -62
  194. package/dist/components/private/QDocsSection.svelte.d.ts +0 -14
  195. package/dist/components/private/QIconSnippet.svelte.d.ts +0 -14
  196. package/dist/components/private/index.d.ts +0 -6
  197. package/dist/components/private/index.js +0 -6
  198. package/dist/components/progress/docs.props.d.ts +0 -5
  199. package/dist/components/progress/docs.props.js +0 -314
  200. package/dist/components/radio/docs.props.d.ts +0 -3
  201. package/dist/components/radio/docs.props.js +0 -53
  202. package/dist/components/railbar/docs.props.d.ts +0 -3
  203. package/dist/components/railbar/docs.props.js +0 -47
  204. package/dist/components/select/docs.props.d.ts +0 -3
  205. package/dist/components/select/docs.props.js +0 -198
  206. package/dist/components/separator/docs.props.d.ts +0 -5
  207. package/dist/components/separator/docs.props.js +0 -196
  208. package/dist/components/switch/docs.props.d.ts +0 -3
  209. package/dist/components/switch/docs.props.js +0 -119
  210. package/dist/components/table/docs.props.d.ts +0 -3
  211. package/dist/components/table/docs.props.js +0 -94
  212. package/dist/components/tabs/docs.props.d.ts +0 -5
  213. package/dist/components/tabs/docs.props.js +0 -86
  214. package/dist/components/toolbar/docs.props.d.ts +0 -5
  215. package/dist/components/toolbar/docs.props.js +0 -68
  216. package/dist/components/tooltip/docs.props.d.ts +0 -3
  217. package/dist/components/tooltip/docs.props.js +0 -77
  218. package/dist/utils/types.json +0 -31
@@ -0,0 +1,73 @@
1
+ import { getOptionLabel } from "./option";
2
+ export function getFilteredOptions(options, search, useInput, filterable, hasExternalFilter) {
3
+ if (!useInput || !filterable || hasExternalFilter) {
4
+ return options;
5
+ }
6
+ const query = search.trim().toLowerCase();
7
+ if (!query) {
8
+ return options;
9
+ }
10
+ return options.filter((option) => String(getOptionLabel(option, options)).toLowerCase().includes(query));
11
+ }
12
+ export function getInputValue(currentDisplayValue, search, useInput, isSearching) {
13
+ return useInput && isSearching ? search : currentDisplayValue;
14
+ }
15
+ export function createFilterRunner({ onAbort, onDone }) {
16
+ let timer;
17
+ let run = 0;
18
+ function clear() {
19
+ if (timer) {
20
+ clearTimeout(timer);
21
+ timer = undefined;
22
+ }
23
+ run += 1;
24
+ }
25
+ function schedule(search, onFilter, debounce = 0) {
26
+ clear();
27
+ if (!onFilter) {
28
+ return;
29
+ }
30
+ const currentRun = run;
31
+ if (debounce > 0) {
32
+ timer = setTimeout(() => {
33
+ timer = undefined;
34
+ runFilter(search, onFilter, currentRun);
35
+ }, debounce);
36
+ return;
37
+ }
38
+ runFilter(search, onFilter, currentRun);
39
+ }
40
+ function runFilter(search, onFilter, currentRun) {
41
+ let aborted = false;
42
+ const update = (callbackFn) => {
43
+ try {
44
+ void Promise.resolve(callbackFn())
45
+ .then(() => {
46
+ if (!aborted && currentRun === run) {
47
+ void onDone();
48
+ }
49
+ })
50
+ .catch(abort);
51
+ }
52
+ catch {
53
+ abort();
54
+ }
55
+ };
56
+ const abort = () => {
57
+ if (aborted) {
58
+ return;
59
+ }
60
+ aborted = true;
61
+ if (currentRun === run) {
62
+ onAbort();
63
+ }
64
+ };
65
+ try {
66
+ void Promise.resolve(onFilter(search, update, abort)).catch(abort);
67
+ }
68
+ catch {
69
+ abort();
70
+ }
71
+ }
72
+ return { clear, schedule };
73
+ }
@@ -1,40 +1,41 @@
1
- @use "$css/mixins";
2
- @use "$css/variables";
3
1
  @use "$css/shared/q-field.scss";
4
2
 
5
3
  .q-select {
6
- &__option--selected {
7
- color: var(--primary);
8
- }
9
-
10
4
  .q-field__wrapper,
11
5
  .q-field__input {
12
6
  cursor: pointer;
13
7
  }
14
8
 
15
- &__menu {
16
- @include mixins.menu;
17
- opacity: 0;
18
- visibility: hidden;
19
- transform: scale(0.8) translateY(120%);
20
- transition:
21
- opacity variables.$speed2,
22
- transform variables.$speed2,
23
- visibility 0s variables.$speed2;
24
-
25
- &--active {
26
- opacity: 1;
27
- visibility: visible;
28
- transform: scale(1) translateY(100%);
29
- transition:
30
- opacity variables.$speed2,
31
- transform variables.$speed2,
32
- visibility 0s 0s;
9
+ .q-field__input {
10
+ caret-color: transparent;
11
+ }
12
+
13
+ &.q-field--use-input {
14
+ .q-field__input {
15
+ caret-color: auto;
16
+ cursor: text;
33
17
  }
34
18
  }
35
19
 
36
- &.q-field--bottom-space &__menu {
37
- bottom: 1.0625rem;
20
+ &__menu {
21
+ max-height: min(50vh, 20rem);
22
+ }
23
+
24
+ &__no-option {
25
+ color: var(--on-surface-variant);
26
+ padding: 0.75rem 1rem;
27
+ }
28
+
29
+ &__option {
30
+ width: 100%;
31
+
32
+ &--selected {
33
+ color: var(--primary);
34
+ }
35
+
36
+ &--focused {
37
+ background-color: color-mix(in srgb, var(--on-surface) 12%, transparent);
38
+ }
38
39
  }
39
40
 
40
41
  & &__arrow-toggle {
@@ -45,7 +46,7 @@
45
46
  }
46
47
  }
47
48
 
48
- &.q-field--disable {
49
+ &.q-field--disabled {
49
50
  opacity: 0.5;
50
51
  &,
51
52
  * {
@@ -0,0 +1,9 @@
1
+ import type { QSelectOption, QSelectValue } from "./props";
2
+ export declare function getOptionValue(option: QSelectOption): string | number;
3
+ export declare function getOptionValue(option: QSelectOption | null | undefined): string | number | null | undefined;
4
+ export declare function doValuesMatch(a: QSelectOption | null | undefined, b: QSelectOption | null | undefined): boolean;
5
+ export declare function getOptionLabel(option: QSelectOption | null | undefined, options: QSelectOption[]): string | number;
6
+ export declare function getDisplayValue(value: QSelectValue | undefined, options: QSelectOption[], multiple: boolean, displayValue?: string): string | number;
7
+ export declare function getInitialOptionIndex(options: QSelectOption[], isSelected: (option: QSelectOption) => boolean, direction?: number): number;
8
+ export declare function normalizeOptionIndex(optionIndex: number, optionCount: number): number;
9
+ export declare function getNextValue(currentValue: QSelectValue | undefined, option: QSelectOption, multiple: boolean, emitValue: boolean): QSelectOption | QSelectOption[];
@@ -0,0 +1,59 @@
1
+ export function getOptionValue(option) {
2
+ return typeof option === "object" && option !== null ? option.value : option;
3
+ }
4
+ export function doValuesMatch(a, b) {
5
+ return getOptionValue(a) === getOptionValue(b);
6
+ }
7
+ export function getOptionLabel(option, options) {
8
+ if (option === undefined || option === null || option === "") {
9
+ return "";
10
+ }
11
+ if (typeof option !== "string" && typeof option !== "number") {
12
+ return option.label;
13
+ }
14
+ if (options.includes(option)) {
15
+ return option;
16
+ }
17
+ const matchedOption = options.find((opt) => doValuesMatch(opt, option));
18
+ return typeof matchedOption === "object" && matchedOption !== null ? matchedOption.label : "";
19
+ }
20
+ export function getDisplayValue(value, options, multiple, displayValue) {
21
+ if (displayValue !== undefined) {
22
+ return displayValue;
23
+ }
24
+ if (!Array.isArray(value)) {
25
+ return getOptionLabel(value, options);
26
+ }
27
+ if (!multiple) {
28
+ return "";
29
+ }
30
+ return value.map((entry) => getOptionLabel(entry, options)).join(", ");
31
+ }
32
+ export function getInitialOptionIndex(options, isSelected, direction = 1) {
33
+ if (!options.length) {
34
+ return -1;
35
+ }
36
+ const selectedIndex = options.findIndex(isSelected);
37
+ if (selectedIndex !== -1) {
38
+ return selectedIndex;
39
+ }
40
+ return direction < 0 ? options.length - 1 : 0;
41
+ }
42
+ export function normalizeOptionIndex(optionIndex, optionCount) {
43
+ if (!optionCount || optionIndex < 0) {
44
+ return optionCount ? optionCount - 1 : -1;
45
+ }
46
+ return optionIndex % optionCount;
47
+ }
48
+ export function getNextValue(currentValue, option, multiple, emitValue) {
49
+ const optionValue = getOptionValue(option);
50
+ if (!multiple) {
51
+ return emitValue ? optionValue : option;
52
+ }
53
+ const entries = Array.isArray(currentValue) ? currentValue : [];
54
+ const index = entries.findIndex((entry) => doValuesMatch(entry, optionValue));
55
+ if (index !== -1) {
56
+ return entries.filter((_, entryIndex) => entryIndex !== index);
57
+ }
58
+ return [...entries, emitValue ? optionValue : option];
59
+ }
@@ -1,13 +1,12 @@
1
1
  import type { NativeProps } from "../../utils";
2
2
  import type { Snippet } from "svelte";
3
3
  import type { HTMLAttributes } from "svelte/elements";
4
- export type QSelectOption = string | {
5
- label: string;
6
- value: string;
4
+ export type QSelectOption = string | number | {
5
+ label: string | number;
6
+ value: string | number;
7
7
  };
8
- export type QSelectValue = QSelectSingleValue | QSelectMultipleValue;
9
- export type QSelectSingleValue = string | number;
10
- export type QSelectMultipleValue = QSelectSingleValue[];
8
+ export type QSelectValue = QSelectOption | QSelectOption[];
9
+ export type QSelectFilterUpdate = (callbackFn: () => void | Promise<void>) => void;
11
10
  export interface QSelectProps extends NativeProps, HTMLAttributes<HTMLDivElement> {
12
11
  /**
13
12
  * Current value of the select. Can be a single value or an array of values when multiple is true.
@@ -37,7 +36,7 @@ export interface QSelectProps extends NativeProps, HTMLAttributes<HTMLDivElement
37
36
  *
38
37
  * @default false
39
38
  */
40
- disable?: boolean;
39
+ disabled?: boolean;
41
40
  /**
42
41
  * Indicates an error state for the select.
43
42
  *
@@ -86,6 +85,40 @@ export interface QSelectProps extends NativeProps, HTMLAttributes<HTMLDivElement
86
85
  * @default undefined
87
86
  */
88
87
  displayValue?: string;
88
+ /**
89
+ * Indicates whether to emit the value rather than the entire option object when a value is selected.
90
+ *
91
+ * @default false
92
+ */
93
+ emitValue?: boolean;
94
+ /**
95
+ * Allows typing into the select field.
96
+ *
97
+ * @default false
98
+ */
99
+ useInput?: boolean;
100
+ /**
101
+ * Filters options by their label while typing. Requires useInput.
102
+ *
103
+ * @default false
104
+ */
105
+ filterable?: boolean;
106
+ /**
107
+ * Delay in milliseconds before calling onFilter after input changes.
108
+ *
109
+ * @default 300
110
+ */
111
+ inputDebounce?: number;
112
+ /**
113
+ * Text shown when no options are available.
114
+ *
115
+ * @default "No options"
116
+ */
117
+ noOptionText?: string;
118
+ /**
119
+ * Called while typing so options can be filtered or loaded externally. Requires useInput.
120
+ */
121
+ onFilter?: (value: string, update: QSelectFilterUpdate, abort: () => void) => void | Promise<void>;
89
122
  /**
90
123
  * Content to be placed before the select wrapper element, usually an icon.
91
124
  *
@@ -25,6 +25,8 @@
25
25
  }
26
26
 
27
27
  .q-separator {
28
+ background-color: var(--q-separator-color, "outline-variant");
29
+
28
30
  border: none;
29
31
  flex: 1 1 auto;
30
32
 
@@ -1,20 +1,25 @@
1
1
  <script lang="ts">
2
- import { useSize } from "../../composables";
2
+ import { useColor, useSize } from "../../composables";
3
3
  import type { QSeparatorProps } from "./props";
4
4
 
5
+ // #region: --- Props
5
6
  let {
6
7
  spacing = "none",
7
8
  inset = false,
8
9
  vertical = false,
9
- color = "outline",
10
+ color = "outline-variant",
10
11
  size,
11
12
  text,
12
13
  textAlign = vertical ? "middle" : "center",
13
14
  ...props
14
15
  }: QSeparatorProps = $props();
16
+ // #endregion: --- Props
15
17
 
18
+ // #region: --- Derived values
16
19
  const orientation = $derived(vertical ? "vertical" : "horizontal");
17
20
  const qSize = $derived(useSize(spacing, "q-separator__spacing"));
21
+ const parsedColor = $derived(useColor(color));
22
+ // #endregion: --- Derived values
18
23
  </script>
19
24
 
20
25
  <div
@@ -26,6 +31,7 @@
26
31
  inset && "q-separator__wrapper--inset",
27
32
  ]}
28
33
  data-quaff
34
+ style:--q-separator-color={parsedColor}
29
35
  >
30
36
  {#if text}
31
37
  {#if (vertical && textAlign !== "top") || (!vertical && textAlign !== "left")}
@@ -44,12 +50,7 @@
44
50
 
45
51
  {#snippet hr()}
46
52
  <hr
47
- class={[
48
- "q-separator",
49
- `bg-${color}`,
50
- qSize.class,
51
- vertical && "q-separator--vertical",
52
- ]}
53
+ class={["q-separator", qSize.class, vertical && "q-separator--vertical"]}
53
54
  style:--q-separator-size={size}
54
55
  aria-orientation={orientation}
55
56
  />
@@ -1,14 +1,4 @@
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 QSeparatorProps_ = typeof __propDef.props;
10
- export { QSeparatorProps_ as QSeparatorProps };
11
- export type QSeparatorEvents = typeof __propDef.events;
12
- export type QSeparatorSlots = typeof __propDef.slots;
13
- export default class QSeparator extends SvelteComponentTyped<QSeparatorProps_, QSeparatorEvents, QSeparatorSlots> {
14
- }
1
+ import type { QSeparatorProps } from "./props";
2
+ declare const QSeparator: import("svelte").Component<QSeparatorProps, {}, "">;
3
+ type QSeparator = ReturnType<typeof QSeparator>;
4
+ export default QSeparator;
@@ -17,14 +17,16 @@ $check-map: (
17
17
 
18
18
  @function getColor($el, $checked: false, $hovered: null) {
19
19
  @if $el == "track" {
20
- @return if($checked, var(--primary), var(--surface-container-highest));
20
+ @return if(sass($checked): var(--primary) ; else: var(--surface-container-highest));
21
21
  } @else if $el == "icon" {
22
- @return if($checked, var(--on-primary-container), var(--surface-container-highest));
22
+ @return if(
23
+ sass($checked): var(--on-primary-container) ; else: var(--surface-container-highest)
24
+ );
23
25
  } @else if $el == "handle" {
24
26
  @if ($checked) {
25
- @return if($hovered, var(--primary-container), var(--on-primary));
27
+ @return if(sass($hovered): var(--primary-container) ; else: var(--on-primary));
26
28
  } @else {
27
- @return if($hovered, var(--on-surface-variant), var(--outline));
29
+ @return if(sass($hovered): var(--on-surface-variant) ; else: var(--outline));
28
30
  }
29
31
  }
30
32
 
@@ -44,6 +46,8 @@ $check-map: (
44
46
 
45
47
  outline: none;
46
48
 
49
+ isolation: isolate;
50
+
47
51
  &--reversed {
48
52
  flex-direction: row-reverse;
49
53
  }
@@ -117,7 +121,8 @@ $check-map: (
117
121
  border-width: 0.125rem;
118
122
  }
119
123
 
120
- &[aria-disabled] #{$track}:is(::before, ::after) {
124
+ &[aria-disabled] #{$track}::before,
125
+ &[aria-disabled] #{$track}::after {
121
126
  transition: none;
122
127
  opacity: 38%;
123
128
  }
@@ -298,7 +303,8 @@ $check-map: (
298
303
  }
299
304
  }
300
305
 
301
- & :is(#{$handle}, #{$handle}::before) {
306
+ & #{$handle},
307
+ & #{$handle}::before {
302
308
  transition: none;
303
309
  }
304
310
  }
@@ -1,11 +1,12 @@
1
1
  <script lang="ts">
2
2
  import { ripple } from "../../helpers";
3
- import { QIconSnippet } from "../private";
3
+ import QIconSnippet from "../../internal/QIconSnippet.svelte";
4
4
  import { isActivationKey, type QEvent } from "../../utils";
5
5
  import type { QSwitchProps } from "./props";
6
6
 
7
7
  type QSwitchEvent<T> = QEvent<T, HTMLDivElement>;
8
8
 
9
+ // #region: --- Props
9
10
  let {
10
11
  value = $bindable(),
11
12
  label = undefined,
@@ -17,10 +18,14 @@
17
18
  uncheckedIcon,
18
19
  ...props
19
20
  }: QSwitchProps = $props();
21
+ // #endregion: --- Props
20
22
 
23
+ // #region: --- Non-reactive variables
21
24
  let qSwitch: HTMLDivElement;
22
25
  let qSwitchInput: HTMLInputElement;
26
+ // #endregion: --- Non-reactive variables
23
27
 
28
+ // #region: --- Functions
24
29
  function toggle() {
25
30
  value = !value;
26
31
 
@@ -53,6 +58,7 @@
53
58
  event.preventDefault();
54
59
  qSwitch.click();
55
60
  }
61
+ // #endregion: --- Functions
56
62
  </script>
57
63
 
58
64
  <div
@@ -1,14 +1,4 @@
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 QSwitchProps_ = typeof __propDef.props;
10
- export { QSwitchProps_ as QSwitchProps };
11
- export type QSwitchEvents = typeof __propDef.events;
12
- export type QSwitchSlots = typeof __propDef.slots;
13
- export default class QSwitch extends SvelteComponentTyped<QSwitchProps_, QSwitchEvents, QSwitchSlots> {
14
- }
1
+ import type { QSwitchProps } from "./props";
2
+ declare const QSwitch: import("svelte").Component<QSwitchProps, {}, "value">;
3
+ type QSwitch = ReturnType<typeof QSwitch>;
4
+ export default QSwitch;
@@ -7,6 +7,7 @@
7
7
  QTableSort,
8
8
  } from "./props";
9
9
 
10
+ // #region: --- Props
10
11
  let {
11
12
  columns = [],
12
13
  rows = [],
@@ -16,23 +17,21 @@
16
17
  bodyCell,
17
18
  ...props
18
19
  }: QTableProps = $props();
20
+ // #endregion: --- Props
19
21
 
20
- function getField(
21
- fieldRaw: QTableColumn["field"],
22
- row: QTableRow,
23
- ): string | number {
24
- return typeof fieldRaw === "function" ? fieldRaw(row) : row[fieldRaw];
25
- }
26
-
22
+ // #region: --- Reactive variables
27
23
  let page = $state(1);
28
24
  let rowsPerPage = $state(5);
29
- let rowsPerPageOptions = $state(
30
- [5, 10, 25, 50].map((e) => ({
31
- label: e.toString(),
32
- value: e.toString(),
33
- })),
34
- );
25
+
35
26
  let sort: QTableSort = $state(null);
27
+ // #endregion: --- Reactive variables
28
+
29
+ // #region: --- Derived values
30
+ const rowsPerPageOptions = $derived(
31
+ [5, 10, 25, 50].filter((option) => {
32
+ return rows.length >= option || option === 5;
33
+ }),
34
+ );
36
35
 
37
36
  const numberFrom: number = $derived(rowsPerPage * page - rowsPerPage + 1);
38
37
  const numberTo: number = $derived(
@@ -40,12 +39,6 @@
40
39
  );
41
40
  const numberOf: number = $derived(rows.length);
42
41
 
43
- $effect(() => {
44
- if (rowsPerPage * (page - 1) >= rows.length) {
45
- page = 1;
46
- }
47
- });
48
-
49
42
  const rowsSorted: QTableRow[] = $derived.by(() => {
50
43
  if (sort) {
51
44
  return structuredClone(rows).sort((a: QTableRow, b: QTableRow) => {
@@ -74,6 +67,23 @@
74
67
  const rowsPaginated: QTableRow[] = $derived(
75
68
  rowsSorted.slice(numberFrom - 1, numberTo),
76
69
  );
70
+ // #endregion: --- Derived values
71
+
72
+ // #region: --- Effects
73
+ $effect(() => {
74
+ if (rowsPerPage * (page - 1) >= rows.length) {
75
+ page = 1;
76
+ }
77
+ });
78
+ // #endregion: --- Effects
79
+
80
+ // #region: --- Functions
81
+ function getField(
82
+ fieldRaw: QTableColumn["field"],
83
+ row: QTableRow,
84
+ ): string | number {
85
+ return typeof fieldRaw === "function" ? fieldRaw(row) : row[fieldRaw];
86
+ }
77
87
 
78
88
  function getThStyle(column: QTableColumn) {
79
89
  let style = allowsSort(column) ? "cursor: pointer; " : "";
@@ -110,6 +120,7 @@
110
120
  type: !sort?.type || sort?.type === "desc" ? "asc" : "desc",
111
121
  };
112
122
  }
123
+ // #endregion: --- Functions
113
124
  </script>
114
125
 
115
126
  <div {...props} class="q-table" data-quaff>
@@ -170,6 +181,7 @@
170
181
  outlined
171
182
  options={rowsPerPageOptions}
172
183
  bind:value={rowsPerPage}
184
+ disabled={rowsPerPageOptions.length <= 1}
173
185
  />
174
186
  {numberFrom}-{numberTo}&nbsp;of&nbsp;{numberOf}
175
187
  <QBtn
@@ -1,14 +1,4 @@
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 QTableProps_ = typeof __propDef.props;
10
- export { QTableProps_ as QTableProps };
11
- export type QTableEvents = typeof __propDef.events;
12
- export type QTableSlots = typeof __propDef.slots;
13
- export default class QTable extends SvelteComponentTyped<QTableProps_, QTableEvents, QTableSlots> {
14
- }
1
+ import type { QTableProps } from "./props";
2
+ declare const QTable: import("svelte").Component<QTableProps, {}, "">;
3
+ type QTable = ReturnType<typeof QTable>;
4
+ export default QTable;
@@ -39,7 +39,7 @@
39
39
  }
40
40
 
41
41
  &--bordered {
42
- border: 1px solid var(--outline);
42
+ border: 1px solid var(--outline-variant);
43
43
 
44
44
  tr:last-child td {
45
45
  border-bottom: none;
@@ -17,6 +17,8 @@
17
17
  overflow: visible;
18
18
  @include mixins.padding("x-md");
19
19
 
20
+ isolation: isolate;
21
+
20
22
  & .q-tab__icon + span {
21
23
  margin-left: 0.5rem;
22
24
  }