@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.
- package/README.md +2 -0
- package/dist/classes/QScrollObserver.svelte.d.ts +4 -4
- package/dist/classes/QScrollObserver.svelte.js +26 -13
- package/dist/classes/Quaff.svelte.d.ts +3 -0
- package/dist/classes/Quaff.svelte.js +21 -17
- package/dist/components/avatar/QAvatar.svelte +4 -0
- package/dist/components/avatar/QAvatar.svelte.d.ts +4 -14
- package/dist/components/breadcrumbs/QBreadcrumbs.scss +9 -5
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +46 -16
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +24 -12
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +22 -3
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +50 -38
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +4 -14
- package/dist/components/breadcrumbs/props.d.ts +4 -4
- package/dist/components/button/QBtn.scss +3 -1
- package/dist/components/button/QBtn.svelte +38 -22
- package/dist/components/button/QBtn.svelte.d.ts +4 -14
- package/dist/components/button/props.d.ts +9 -2
- package/dist/components/card/QCard.svelte +9 -5
- package/dist/components/card/QCard.svelte.d.ts +4 -14
- package/dist/components/card/QCardActions.svelte +4 -0
- package/dist/components/card/QCardActions.svelte.d.ts +4 -14
- package/dist/components/card/QCardSection.svelte +2 -0
- package/dist/components/card/QCardSection.svelte.d.ts +4 -14
- package/dist/components/checkbox/QCheckbox.svelte +6 -4
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +4 -14
- package/dist/components/checkbox/props.d.ts +1 -1
- package/dist/components/chip/QChip.scss +3 -1
- package/dist/components/chip/QChip.svelte +24 -14
- package/dist/components/chip/QChip.svelte.d.ts +4 -14
- package/dist/components/codeBlock/QCodeBlock.svelte +8 -0
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +4 -14
- package/dist/components/dialog/QDialog.scss +17 -0
- package/dist/components/dialog/QDialog.svelte +34 -9
- package/dist/components/dialog/QDialog.svelte.d.ts +8 -21
- package/dist/components/drawer/QDrawer.scss +2 -2
- package/dist/components/drawer/QDrawer.svelte +124 -69
- package/dist/components/drawer/QDrawer.svelte.d.ts +8 -21
- package/dist/components/drawer/props.d.ts +3 -3
- package/dist/components/expansion-item/QExpansionItem.scss +59 -0
- package/dist/components/expansion-item/QExpansionItem.svelte +319 -0
- package/dist/components/expansion-item/QExpansionItem.svelte.d.ts +8 -0
- package/dist/components/expansion-item/docs.d.ts +2 -0
- package/dist/components/expansion-item/docs.js +17 -0
- package/dist/components/expansion-item/props.d.ts +129 -0
- package/dist/components/expansion-item/props.js +1 -0
- package/dist/components/footer/QFooter.scss +1 -1
- package/dist/components/footer/QFooter.svelte +32 -28
- package/dist/components/footer/QFooter.svelte.d.ts +4 -14
- package/dist/components/header/QHeader.scss +1 -1
- package/dist/components/header/QHeader.svelte +41 -33
- package/dist/components/header/QHeader.svelte.d.ts +4 -14
- package/dist/components/icon/QIcon.svelte +6 -4
- package/dist/components/icon/QIcon.svelte.d.ts +4 -14
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/input/QInput.svelte +139 -17
- package/dist/components/input/QInput.svelte.d.ts +4 -14
- package/dist/components/input/docs.js +2 -2
- package/dist/components/input/mask.d.ts +10 -0
- package/dist/components/input/mask.js +204 -0
- package/dist/components/input/props.d.ts +37 -4
- package/dist/components/layout/QLayout.svelte +248 -93
- package/dist/components/layout/QLayout.svelte.d.ts +67 -15
- package/dist/components/layout/props.d.ts +1 -1
- package/dist/components/list/QItem.scss +7 -4
- package/dist/components/list/QItem.svelte +44 -24
- package/dist/components/list/QItem.svelte.d.ts +17 -13
- package/dist/components/list/QItemSection.scss +24 -3
- package/dist/components/list/QItemSection.svelte +19 -21
- package/dist/components/list/QItemSection.svelte.d.ts +4 -14
- package/dist/components/list/QList.scss +17 -4
- package/dist/components/list/QList.svelte +30 -8
- package/dist/components/list/QList.svelte.d.ts +17 -13
- package/dist/components/list/props.d.ts +3 -3
- package/dist/components/menu/QMenu.scss +37 -0
- package/dist/components/menu/QMenu.svelte +314 -0
- package/dist/components/menu/QMenu.svelte.d.ts +8 -0
- package/dist/components/menu/docs.d.ts +2 -0
- package/dist/components/menu/docs.js +27 -0
- package/dist/components/menu/props.d.ts +48 -0
- package/dist/components/menu/props.js +1 -0
- package/dist/components/progress/QCircularProgress.svelte +17 -14
- package/dist/components/progress/QCircularProgress.svelte.d.ts +4 -14
- package/dist/components/progress/QLinearProgress.svelte +15 -15
- package/dist/components/progress/QLinearProgress.svelte.d.ts +4 -14
- package/dist/components/radio/QRadio.svelte +6 -4
- package/dist/components/radio/QRadio.svelte.d.ts +4 -14
- package/dist/components/radio/props.d.ts +1 -1
- package/dist/components/railbar/QRailbar.scss +1 -1
- package/dist/components/railbar/QRailbar.svelte +36 -35
- package/dist/components/railbar/QRailbar.svelte.d.ts +4 -14
- package/dist/components/select/QSelect.svelte +316 -102
- package/dist/components/select/QSelect.svelte.d.ts +4 -14
- package/dist/components/select/filter.d.ts +13 -0
- package/dist/components/select/filter.js +73 -0
- package/dist/components/select/index.scss +28 -27
- package/dist/components/select/option.d.ts +9 -0
- package/dist/components/select/option.js +59 -0
- package/dist/components/select/props.d.ts +40 -7
- package/dist/components/separator/QSeparator.scss +2 -0
- package/dist/components/separator/QSeparator.svelte +9 -8
- package/dist/components/separator/QSeparator.svelte.d.ts +4 -14
- package/dist/components/switch/QSwitch.scss +12 -6
- package/dist/components/switch/QSwitch.svelte +7 -1
- package/dist/components/switch/QSwitch.svelte.d.ts +4 -14
- package/dist/components/table/QTable.svelte +31 -19
- package/dist/components/table/QTable.svelte.d.ts +4 -14
- package/dist/components/table/index.scss +1 -1
- package/dist/components/tabs/QTab.scss +2 -0
- package/dist/components/tabs/QTab.svelte +19 -22
- package/dist/components/tabs/QTab.svelte.d.ts +4 -14
- package/dist/components/tabs/QTabs.svelte +59 -32
- package/dist/components/tabs/QTabs.svelte.d.ts +18 -18
- package/dist/components/toolbar/QToolbar.svelte +2 -0
- package/dist/components/toolbar/QToolbar.svelte.d.ts +4 -14
- package/dist/components/toolbar/QToolbarTitle.svelte +2 -0
- package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +4 -14
- package/dist/components/tooltip/QTooltip.svelte +48 -38
- package/dist/components/tooltip/QTooltip.svelte.d.ts +29 -17
- package/dist/components/tooltip/QTooltipBase.svelte +18 -8
- package/dist/components/tooltip/QTooltipBase.svelte.d.ts +4 -14
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +2 -0
- package/dist/composables/useColor.d.ts +1 -0
- package/dist/composables/useColor.js +19 -0
- package/dist/composables/useRevealScrollObserver.svelte.d.ts +9 -0
- package/dist/composables/useRevealScrollObserver.svelte.js +25 -0
- package/dist/composables/useRouterLink.d.ts +3 -2
- package/dist/composables/useRouterLink.js +2 -2
- package/dist/css/_components.scss +2 -0
- package/dist/css/classes/_grid.scss +12 -1
- package/dist/css/index.css +1 -1
- package/dist/css/mixins/_design.scss +1 -1
- package/dist/css/mixins/_field.scss +3 -2
- package/dist/css/mixins/_table.scss +1 -1
- package/dist/css/mixins/_toolbar.scss +1 -1
- package/dist/css/shared/q-field.scss +7 -6
- package/dist/css/theme/_page.scss +8 -6
- package/dist/css/theme/_reset.scss +2 -1
- package/dist/helpers/clickOutside.js +5 -4
- package/dist/helpers/ripple.js +5 -6
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/{components/private/ContextReseter.svelte → internal/ContextResetter.svelte} +2 -3
- package/dist/internal/ContextResetter.svelte.d.ts +8 -0
- package/dist/{components/private → internal}/QIconSnippet.svelte +2 -2
- package/dist/internal/QIconSnippet.svelte.d.ts +10 -0
- package/dist/utils/context.d.ts +49 -32
- package/dist/utils/context.js +82 -33
- package/dist/utils/dom.d.ts +6 -0
- package/dist/utils/dom.js +33 -0
- package/dist/utils/events.d.ts +0 -24
- package/dist/utils/events.js +0 -24
- package/package.json +44 -38
- package/dist/classes/QContext.svelte.d.ts +0 -42
- package/dist/classes/QContext.svelte.js +0 -63
- package/dist/components/avatar/docs.props.d.ts +0 -3
- package/dist/components/avatar/docs.props.js +0 -87
- package/dist/components/breadcrumbs/docs.props.d.ts +0 -5
- package/dist/components/breadcrumbs/docs.props.js +0 -144
- package/dist/components/button/docs.props.d.ts +0 -3
- package/dist/components/button/docs.props.js +0 -227
- package/dist/components/card/docs.props.d.ts +0 -7
- package/dist/components/card/docs.props.js +0 -89
- package/dist/components/checkbox/docs.props.d.ts +0 -3
- package/dist/components/checkbox/docs.props.js +0 -41
- package/dist/components/chip/docs.props.d.ts +0 -3
- package/dist/components/chip/docs.props.js +0 -137
- package/dist/components/codeBlock/docs.props.d.ts +0 -3
- package/dist/components/codeBlock/docs.props.js +0 -83
- package/dist/components/dialog/docs.props.d.ts +0 -3
- package/dist/components/dialog/docs.props.js +0 -65
- package/dist/components/drawer/docs.props.d.ts +0 -3
- package/dist/components/drawer/docs.props.js +0 -149
- package/dist/components/footer/docs.props.d.ts +0 -3
- package/dist/components/footer/docs.props.js +0 -65
- package/dist/components/header/docs.props.d.ts +0 -7
- package/dist/components/header/docs.props.js +0 -131
- package/dist/components/icon/docs.props.d.ts +0 -3
- package/dist/components/icon/docs.props.js +0 -107
- package/dist/components/input/docs.props.d.ts +0 -3
- package/dist/components/input/docs.props.js +0 -162
- package/dist/components/layout/docs.props.d.ts +0 -3
- package/dist/components/layout/docs.props.js +0 -81
- package/dist/components/list/docs.props.d.ts +0 -11
- package/dist/components/list/docs.props.js +0 -434
- package/dist/components/private/ContextReseter.svelte.d.ts +0 -14
- package/dist/components/private/QApi.svelte +0 -296
- package/dist/components/private/QApi.svelte.d.ts +0 -14
- package/dist/components/private/QDocs.svelte +0 -155
- package/dist/components/private/QDocs.svelte.d.ts +0 -14
- package/dist/components/private/QDocsSection.svelte +0 -62
- package/dist/components/private/QDocsSection.svelte.d.ts +0 -14
- package/dist/components/private/QIconSnippet.svelte.d.ts +0 -14
- package/dist/components/private/index.d.ts +0 -6
- package/dist/components/private/index.js +0 -6
- package/dist/components/progress/docs.props.d.ts +0 -5
- package/dist/components/progress/docs.props.js +0 -314
- package/dist/components/radio/docs.props.d.ts +0 -3
- package/dist/components/radio/docs.props.js +0 -53
- package/dist/components/railbar/docs.props.d.ts +0 -3
- package/dist/components/railbar/docs.props.js +0 -47
- package/dist/components/select/docs.props.d.ts +0 -3
- package/dist/components/select/docs.props.js +0 -198
- package/dist/components/separator/docs.props.d.ts +0 -5
- package/dist/components/separator/docs.props.js +0 -196
- package/dist/components/switch/docs.props.d.ts +0 -3
- package/dist/components/switch/docs.props.js +0 -119
- package/dist/components/table/docs.props.d.ts +0 -3
- package/dist/components/table/docs.props.js +0 -94
- package/dist/components/tabs/docs.props.d.ts +0 -5
- package/dist/components/tabs/docs.props.js +0 -86
- package/dist/components/toolbar/docs.props.d.ts +0 -5
- package/dist/components/toolbar/docs.props.js +0 -68
- package/dist/components/tooltip/docs.props.d.ts +0 -3
- package/dist/components/tooltip/docs.props.js +0 -77
- 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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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--
|
|
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 =
|
|
9
|
-
export type
|
|
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
|
-
|
|
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
|
*
|
|
@@ -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 {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
20
|
+
@return if(sass($checked): var(--primary) ; else: var(--surface-container-highest));
|
|
21
21
|
} @else if $el == "icon" {
|
|
22
|
-
@return if(
|
|
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
|
|
27
|
+
@return if(sass($hovered): var(--primary-container) ; else: var(--on-primary));
|
|
26
28
|
} @else {
|
|
27
|
-
@return if($hovered
|
|
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}
|
|
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
|
-
&
|
|
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
|
|
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 {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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} of {numberOf}
|
|
175
187
|
<QBtn
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
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;
|