@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.
- package/dist/components/avatar/QAvatar.svelte +4 -1
- package/dist/components/avatar/QAvatar.svelte.d.ts +14 -2
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +7 -2
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +14 -2
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +16 -5
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +14 -2
- package/dist/components/button/QBtn.svelte +61 -11
- package/dist/components/button/QBtn.svelte.d.ts +14 -2
- package/dist/components/button/docs.props.js +37 -5
- package/dist/components/button/props.d.ts +24 -4
- package/dist/components/card/QCard.svelte +6 -2
- package/dist/components/card/QCard.svelte.d.ts +14 -2
- package/dist/components/card/QCardActions.svelte +9 -1
- package/dist/components/card/QCardActions.svelte.d.ts +14 -2
- package/dist/components/card/QCardSection.svelte +3 -1
- package/dist/components/card/QCardSection.svelte.d.ts +14 -2
- package/dist/components/checkbox/QCheckbox.svelte +8 -1
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +14 -3
- package/dist/components/chip/QChip.svelte +30 -9
- package/dist/components/chip/QChip.svelte.d.ts +14 -3
- package/dist/components/codeBlock/QCodeBlock.svelte +25 -10
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +14 -3
- package/dist/components/dialog/QDialog.svelte +20 -5
- package/dist/components/dialog/QDialog.svelte.d.ts +21 -7
- package/dist/components/drawer/QDrawer.svelte +36 -7
- package/dist/components/drawer/QDrawer.svelte.d.ts +21 -7
- package/dist/components/footer/QFooter.svelte +24 -6
- package/dist/components/footer/QFooter.svelte.d.ts +14 -3
- package/dist/components/header/QHeader.svelte +19 -6
- package/dist/components/header/QHeader.svelte.d.ts +14 -3
- package/dist/components/icon/QIcon.svelte +6 -1
- package/dist/components/icon/QIcon.svelte.d.ts +14 -2
- package/dist/components/input/QInput.svelte +23 -10
- package/dist/components/input/QInput.svelte.d.ts +14 -3
- package/dist/components/input/index.scss +1 -1
- package/dist/components/layout/QLayout.scss +2 -1
- package/dist/components/layout/QLayout.svelte +50 -8
- package/dist/components/layout/QLayout.svelte.d.ts +14 -3
- package/dist/components/list/QItem.svelte +11 -2
- package/dist/components/list/QItem.svelte.d.ts +14 -3
- package/dist/components/list/QItemSection.svelte +9 -3
- package/dist/components/list/QItemSection.svelte.d.ts +14 -3
- package/dist/components/list/QList.svelte +8 -3
- package/dist/components/list/QList.svelte.d.ts +14 -3
- package/dist/components/private/ContextReseter.svelte +10 -1
- package/dist/components/private/ContextReseter.svelte.d.ts +14 -6
- package/dist/components/private/QApi.svelte +32 -9
- package/dist/components/private/QApi.svelte.d.ts +14 -5
- package/dist/components/private/QDocs.svelte +18 -1
- package/dist/components/private/QDocs.svelte.d.ts +14 -10
- package/dist/components/private/QDocsSection.svelte +14 -2
- package/dist/components/private/QDocsSection.svelte.d.ts +14 -7
- package/dist/components/private/QIconSnippet.svelte +11 -1
- package/dist/components/private/QIconSnippet.svelte.d.ts +14 -8
- package/dist/components/progress/QCircularProgress.svelte +19 -3
- package/dist/components/progress/QCircularProgress.svelte.d.ts +14 -2
- package/dist/components/progress/QLinearProgress.svelte +12 -4
- package/dist/components/progress/QLinearProgress.svelte.d.ts +14 -2
- package/dist/components/radio/QRadio.svelte +3 -1
- package/dist/components/radio/QRadio.svelte.d.ts +14 -3
- package/dist/components/railbar/QRailbar.svelte +17 -4
- package/dist/components/railbar/QRailbar.svelte.d.ts +14 -3
- package/dist/components/select/QSelect.svelte +65 -23
- package/dist/components/select/QSelect.svelte.d.ts +14 -3
- package/dist/components/select/index.scss +1 -1
- package/dist/components/separator/QSeparator.svelte +4 -1
- package/dist/components/separator/QSeparator.svelte.d.ts +14 -3
- package/dist/components/switch/QSwitch.svelte +20 -6
- package/dist/components/switch/QSwitch.svelte.d.ts +14 -3
- package/dist/components/table/QTable.svelte +47 -19
- package/dist/components/table/QTable.svelte.d.ts +14 -3
- package/dist/components/tabs/QTab.svelte +32 -9
- package/dist/components/tabs/QTab.svelte.d.ts +14 -3
- package/dist/components/tabs/QTabs.svelte +58 -16
- package/dist/components/tabs/QTabs.svelte.d.ts +14 -3
- package/dist/components/toolbar/QToolbar.svelte +3 -1
- package/dist/components/toolbar/QToolbar.svelte.d.ts +14 -3
- package/dist/components/toolbar/QToolbarTitle.svelte +3 -1
- package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +14 -3
- package/dist/components/tooltip/QTooltip.svelte +8 -1
- package/dist/components/tooltip/QTooltip.svelte.d.ts +14 -3
- package/dist/css/classes/_index.scss +7 -7
- package/dist/css/fonts.scss +3 -2
- package/dist/css/index.css +1 -1
- package/dist/css/index.scss +7 -5
- package/dist/css/mixins/_design.scss +5 -4
- package/dist/css/mixins/_image.scss +2 -1
- package/dist/css/mixins/_index.scss +9 -9
- package/dist/css/theme/_index.scss +12 -0
- package/dist/css/theme/_page.scss +17 -0
- package/dist/css/theme/{palette.scss → _palette.scss} +5 -3
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/utils/types.json +1 -1
- package/package.json +27 -28
- package/dist/css/flex.scss +0 -41
- package/dist/css/theme/page.scss +0 -16
- package/dist/css/theme/theme.scss +0 -10
- /package/dist/css/theme/{colors.module.scss → _color-classes.scss} +0 -0
- /package/dist/css/theme/{css-variables.scss → _css-variables.scss} +0 -0
- /package/dist/css/theme/{elevate.scss → _elevate.scss} +0 -0
- /package/dist/css/theme/{reset.scss → _reset.scss} +0 -0
- /package/dist/css/theme/{typography.module.scss → _typography-classes.scss} +0 -0
- /package/dist/css/theme/{tokens.scss → _typography-variables.scss} +0 -0
- /package/dist/css/theme/{typography.scss → _typography.scss} +0 -0
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
4
|
import { useSize } from "../../composables/useSize";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { QLinearProgressProps } from "./props";
|
|
6
|
+
|
|
7
|
+
function width(val: number, reverse: boolean) {
|
|
8
|
+
return reverse
|
|
7
9
|
? `translateX(100%) scale3d(-${val}, 1, 1)`
|
|
8
10
|
: `scale3d(${val}, 1, 1)`;
|
|
9
11
|
}
|
|
12
|
+
|
|
10
13
|
let {
|
|
11
14
|
value = 0,
|
|
12
15
|
buffer,
|
|
@@ -19,13 +22,18 @@
|
|
|
19
22
|
trackColor = "secondary-container",
|
|
20
23
|
indeterminate = false,
|
|
21
24
|
...props
|
|
22
|
-
} = $props();
|
|
25
|
+
}: QLinearProgressProps = $props();
|
|
26
|
+
|
|
23
27
|
const normalized = $derived(value > 1 ? value / 100 : value);
|
|
28
|
+
|
|
24
29
|
const qSize = $derived(useSize(size, "q-linear-progress"));
|
|
30
|
+
|
|
25
31
|
const radius = $derived(noRound ? "0" : "0.75rem");
|
|
26
32
|
const origin = $derived(reverse ? "0 100%" : "0 0");
|
|
27
33
|
const transition = $derived(
|
|
28
|
-
instantFeedback || indeterminate
|
|
34
|
+
instantFeedback || indeterminate
|
|
35
|
+
? undefined
|
|
36
|
+
: `transform ${animationSpeed}ms`,
|
|
29
37
|
);
|
|
30
38
|
const trackTransform = $derived(width(buffer ?? 1, reverse));
|
|
31
39
|
const indicatorTransform = $derived(
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
1
2
|
import type { QLinearProgressProps } from "./props";
|
|
2
|
-
declare const
|
|
3
|
-
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: QLinearProgressProps;
|
|
5
|
+
events: {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots: {};
|
|
9
|
+
};
|
|
10
|
+
type QLinearProgressProps_ = typeof __propDef.props;
|
|
11
|
+
export { QLinearProgressProps_ as QLinearProgressProps };
|
|
12
|
+
export type QLinearProgressEvents = typeof __propDef.events;
|
|
13
|
+
export type QLinearProgressSlots = typeof __propDef.slots;
|
|
14
|
+
export default class QLinearProgress extends SvelteComponentTyped<QLinearProgressProps_, QLinearProgressEvents, QLinearProgressSlots> {
|
|
15
|
+
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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 QRadioProps_ = typeof __propDef.props;
|
|
10
|
+
export { QRadioProps_ as QRadioProps };
|
|
11
|
+
export type QRadioEvents = typeof __propDef.events;
|
|
12
|
+
export type QRadioSlots = typeof __propDef.slots;
|
|
13
|
+
export default class QRadio extends SvelteComponentTyped<QRadioProps_, QRadioEvents, QRadioSlots> {
|
|
14
|
+
}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext, onDestroy, untrack } from "svelte";
|
|
3
3
|
import QContext from "../../classes/QContext.svelte";
|
|
4
|
+
import type { QLayoutProps } from "../layout/props";
|
|
5
|
+
import type { DrawerContext } from "../layout/QLayout.svelte";
|
|
6
|
+
import type { QRailbarProps } from "./props";
|
|
7
|
+
|
|
4
8
|
let {
|
|
5
9
|
width = 88,
|
|
6
10
|
side = "left",
|
|
7
11
|
bordered = false,
|
|
8
12
|
children,
|
|
9
13
|
...props
|
|
10
|
-
} = $props();
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
+
}: QRailbarProps = $props();
|
|
15
|
+
|
|
16
|
+
const railbarCtx = QContext.get<DrawerContext>(`QRailbar-${side}`);
|
|
17
|
+
const layoutView = getContext<{ value: NonNullable<QLayoutProps["view"]> }>(
|
|
18
|
+
"view",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
let railbarEl = $state<HTMLElement>();
|
|
22
|
+
|
|
14
23
|
onDestroy(() => {
|
|
15
24
|
untrack(() => railbarCtx)?.updateEntries({
|
|
16
25
|
width: 0,
|
|
17
26
|
takesSpace: false,
|
|
18
27
|
});
|
|
19
28
|
});
|
|
29
|
+
|
|
20
30
|
$effect.pre(() => {
|
|
21
31
|
untrack(() => railbarCtx)?.updateEntries({
|
|
22
32
|
width,
|
|
23
33
|
takesSpace: railbarEl?.style.display !== "none" || false,
|
|
24
34
|
});
|
|
25
35
|
});
|
|
36
|
+
|
|
26
37
|
const offsetTop = $derived.by(() => {
|
|
27
38
|
const charPos = side === "left" ? 0 : 2;
|
|
28
39
|
return layoutView?.value.charAt(charPos) === "h";
|
|
@@ -31,7 +42,9 @@
|
|
|
31
42
|
const charPos = side === "left" ? 8 : 10;
|
|
32
43
|
return layoutView?.value.charAt(charPos) === "f";
|
|
33
44
|
});
|
|
45
|
+
|
|
34
46
|
const railbarWidthStyle = $derived(`--${side}-railbar-width: ${width}px`);
|
|
47
|
+
|
|
35
48
|
const style = $derived(`${railbarWidthStyle};${props.style ?? ""}`);
|
|
36
49
|
</script>
|
|
37
50
|
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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 QRailbarProps_ = typeof __propDef.props;
|
|
10
|
+
export { QRailbarProps_ as QRailbarProps };
|
|
11
|
+
export type QRailbarEvents = typeof __propDef.events;
|
|
12
|
+
export type QRailbarSlots = typeof __propDef.slots;
|
|
13
|
+
export default class QRailbar extends SvelteComponentTyped<QRailbarProps_, QRailbarEvents, QRailbarSlots> {
|
|
14
|
+
}
|
|
@@ -2,100 +2,142 @@
|
|
|
2
2
|
import { onMount, onDestroy } from "svelte";
|
|
3
3
|
import { browser } from "$app/environment";
|
|
4
4
|
import { QIcon } from "../..";
|
|
5
|
+
import type { QEvent } from "../../utils";
|
|
6
|
+
import type {
|
|
7
|
+
QSelectProps,
|
|
8
|
+
QSelectOption,
|
|
9
|
+
QSelectMultipleValue,
|
|
10
|
+
} from "./props";
|
|
11
|
+
|
|
12
|
+
type QSelectEvent<T> = QEvent<T, HTMLDivElement>;
|
|
13
|
+
|
|
5
14
|
let {
|
|
6
15
|
options,
|
|
7
16
|
multiple = false,
|
|
8
17
|
dense = false,
|
|
9
18
|
disable = false,
|
|
10
19
|
error = false,
|
|
11
|
-
errorMessage =
|
|
20
|
+
errorMessage = undefined,
|
|
12
21
|
filled = false,
|
|
13
|
-
hint =
|
|
14
|
-
label =
|
|
22
|
+
hint = undefined,
|
|
23
|
+
label = undefined,
|
|
15
24
|
outlined = false,
|
|
16
25
|
rounded = false,
|
|
17
26
|
displayValue,
|
|
18
|
-
before =
|
|
19
|
-
prepend =
|
|
20
|
-
append =
|
|
21
|
-
after =
|
|
27
|
+
before = undefined,
|
|
28
|
+
prepend = undefined,
|
|
29
|
+
append = undefined,
|
|
30
|
+
after = undefined,
|
|
22
31
|
value = $bindable(),
|
|
23
32
|
...props
|
|
24
|
-
} = $props();
|
|
33
|
+
}: QSelectProps = $props();
|
|
34
|
+
|
|
25
35
|
let focus = $state(false);
|
|
36
|
+
|
|
26
37
|
const currentDisplayValue = $derived.by(() => {
|
|
27
|
-
if (displayValue !==
|
|
38
|
+
if (displayValue !== undefined) {
|
|
28
39
|
return displayValue;
|
|
29
40
|
}
|
|
41
|
+
|
|
30
42
|
if (!multiple) {
|
|
31
43
|
return value;
|
|
32
44
|
}
|
|
33
|
-
|
|
45
|
+
|
|
46
|
+
return (value as QSelectMultipleValue).join(", ");
|
|
34
47
|
});
|
|
48
|
+
|
|
35
49
|
const active = $derived(currentDisplayValue || focus);
|
|
36
|
-
|
|
50
|
+
|
|
51
|
+
let wrapper: HTMLDivElement | null = $state(null);
|
|
37
52
|
let isMenuOpen = $state(false);
|
|
38
53
|
let wasClicked = $state(false);
|
|
39
54
|
let preventClose = $state(false);
|
|
40
|
-
|
|
55
|
+
|
|
56
|
+
function handleMousedown(e: QSelectEvent<MouseEvent>) {
|
|
41
57
|
isMenuOpen = !isMenuOpen;
|
|
42
58
|
wasClicked = true;
|
|
43
59
|
props.onmousedown?.(e);
|
|
44
60
|
}
|
|
45
|
-
|
|
61
|
+
|
|
62
|
+
function handleFocus(e: QSelectEvent<FocusEvent>) {
|
|
46
63
|
focus = true;
|
|
47
64
|
if (!wasClicked) {
|
|
48
65
|
isMenuOpen = true;
|
|
49
66
|
}
|
|
67
|
+
|
|
50
68
|
wasClicked = false;
|
|
51
69
|
props.onfocus?.(e);
|
|
52
70
|
}
|
|
53
|
-
|
|
71
|
+
|
|
72
|
+
function handleBlur(e: QSelectEvent<FocusEvent>) {
|
|
54
73
|
focus = false;
|
|
74
|
+
|
|
55
75
|
if (!multiple && !preventClose) {
|
|
56
76
|
isMenuOpen = false;
|
|
57
77
|
}
|
|
58
78
|
preventClose = false;
|
|
59
79
|
props.onblur?.(e);
|
|
60
80
|
}
|
|
61
|
-
|
|
81
|
+
|
|
82
|
+
const selectedOptions: boolean[] = $derived(
|
|
62
83
|
options.map((option) => isSelected(option), value),
|
|
63
84
|
);
|
|
85
|
+
|
|
64
86
|
let snippetPrependWidth = $state(0);
|
|
65
|
-
|
|
87
|
+
|
|
88
|
+
function isSelected(option: QSelectOption) {
|
|
66
89
|
const optionValue = typeof option === "string" ? option : option.value;
|
|
67
|
-
return multiple
|
|
90
|
+
return multiple
|
|
91
|
+
? (value as QSelectMultipleValue).includes(optionValue)
|
|
92
|
+
: value === optionValue;
|
|
68
93
|
}
|
|
69
|
-
|
|
94
|
+
|
|
95
|
+
function select(evt: MouseEvent, option: QSelectOption) {
|
|
70
96
|
evt.preventDefault();
|
|
71
97
|
const optionValue = typeof option === "string" ? option : option.value;
|
|
98
|
+
|
|
72
99
|
if (multiple) {
|
|
73
|
-
const hasItem = value.some(
|
|
100
|
+
const hasItem = (value as QSelectMultipleValue).some(
|
|
101
|
+
(entry) => entry === optionValue,
|
|
102
|
+
);
|
|
103
|
+
|
|
74
104
|
if (hasItem) {
|
|
75
|
-
value
|
|
105
|
+
(value as QSelectMultipleValue) = (
|
|
106
|
+
value as QSelectMultipleValue
|
|
107
|
+
).filter((val) => val !== optionValue);
|
|
76
108
|
} else {
|
|
77
|
-
value = [
|
|
109
|
+
(value as QSelectMultipleValue) = [
|
|
110
|
+
...(value as QSelectMultipleValue),
|
|
111
|
+
optionValue,
|
|
112
|
+
];
|
|
78
113
|
}
|
|
114
|
+
|
|
79
115
|
return;
|
|
80
116
|
}
|
|
117
|
+
|
|
81
118
|
value = optionValue;
|
|
82
119
|
isMenuOpen = false;
|
|
83
120
|
}
|
|
84
|
-
|
|
85
|
-
|
|
121
|
+
|
|
122
|
+
function handleClickOutside(event: MouseEvent) {
|
|
123
|
+
if (wrapper && !wrapper.contains(event.target as Node)) {
|
|
86
124
|
isMenuOpen = false;
|
|
87
125
|
}
|
|
88
126
|
}
|
|
127
|
+
|
|
89
128
|
onMount(() => {
|
|
90
129
|
if (browser) {
|
|
91
130
|
window.document.addEventListener("click", handleClickOutside);
|
|
92
131
|
}
|
|
93
132
|
});
|
|
133
|
+
|
|
94
134
|
onDestroy(() => {
|
|
95
135
|
if (browser) {
|
|
96
136
|
document.removeEventListener("click", handleClickOutside);
|
|
97
137
|
}
|
|
98
138
|
});
|
|
139
|
+
|
|
140
|
+
// q-field here, q-select in classes
|
|
99
141
|
</script>
|
|
100
142
|
|
|
101
143
|
<div
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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 QSelectProps_ = typeof __propDef.props;
|
|
10
|
+
export { QSelectProps_ as QSelectProps };
|
|
11
|
+
export type QSelectEvents = typeof __propDef.events;
|
|
12
|
+
export type QSelectSlots = typeof __propDef.slots;
|
|
13
|
+
export default class QSelect extends SvelteComponentTyped<QSelectProps_, QSelectEvents, QSelectSlots> {
|
|
14
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useSize } from "../../composables/useSize";
|
|
3
|
+
import type { QSeparatorProps } from "./props";
|
|
4
|
+
|
|
3
5
|
let {
|
|
4
6
|
spacing = "none",
|
|
5
7
|
inset = false,
|
|
@@ -9,7 +11,8 @@
|
|
|
9
11
|
text,
|
|
10
12
|
textAlign = vertical ? "middle" : "center",
|
|
11
13
|
...props
|
|
12
|
-
} = $props();
|
|
14
|
+
}: QSeparatorProps = $props();
|
|
15
|
+
|
|
13
16
|
const orientation = $derived(vertical ? "vertical" : "horizontal");
|
|
14
17
|
const qSize = $derived(useSize(spacing, "q-separator__spacing"));
|
|
15
18
|
</script>
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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
|
+
}
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
import QIconSnippet from "../private/QIconSnippet.svelte";
|
|
3
3
|
import { ripple } from "../../helpers";
|
|
4
4
|
import { isActivationKey } from "../../utils";
|
|
5
|
+
import type { QEvent } from "../../utils";
|
|
6
|
+
import type { QSwitchProps } from "./props";
|
|
7
|
+
|
|
8
|
+
type QSwitchEvent<T> = QEvent<T, HTMLDivElement>;
|
|
9
|
+
|
|
5
10
|
let {
|
|
6
11
|
value = $bindable(),
|
|
7
|
-
label =
|
|
12
|
+
label = undefined,
|
|
8
13
|
labelPosition = "right",
|
|
9
14
|
disabled = false,
|
|
10
15
|
icons = false,
|
|
@@ -12,29 +17,38 @@
|
|
|
12
17
|
checkedIcon,
|
|
13
18
|
uncheckedIcon,
|
|
14
19
|
...props
|
|
15
|
-
} = $props();
|
|
16
|
-
|
|
17
|
-
let
|
|
20
|
+
}: QSwitchProps = $props();
|
|
21
|
+
|
|
22
|
+
let qSwitch: HTMLDivElement;
|
|
23
|
+
let qSwitchInput: HTMLInputElement;
|
|
24
|
+
|
|
18
25
|
function toggle() {
|
|
19
26
|
value = !value;
|
|
20
27
|
}
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
function onclick(event: QSwitchEvent<MouseEvent>) {
|
|
22
30
|
event.preventDefault();
|
|
23
31
|
if (!qSwitchInput || disabled) {
|
|
24
32
|
return;
|
|
25
33
|
}
|
|
34
|
+
|
|
26
35
|
props.onclick?.(event);
|
|
36
|
+
|
|
27
37
|
qSwitchInput.focus();
|
|
28
38
|
toggle();
|
|
29
39
|
}
|
|
30
|
-
|
|
40
|
+
|
|
41
|
+
function onkeydown(event: QSwitchEvent<KeyboardEvent>) {
|
|
31
42
|
if (!qSwitch || disabled || !isActivationKey(event)) {
|
|
32
43
|
return;
|
|
33
44
|
}
|
|
45
|
+
|
|
34
46
|
props.onkeydown?.(event);
|
|
47
|
+
|
|
35
48
|
if (event.defaultPrevented) {
|
|
36
49
|
return;
|
|
37
50
|
}
|
|
51
|
+
|
|
38
52
|
event.preventDefault();
|
|
39
53
|
qSwitch.click();
|
|
40
54
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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,5 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { QIcon, QSelect, QBtn } from "../..";
|
|
3
|
+
import type {
|
|
4
|
+
QTableProps,
|
|
5
|
+
QTableColumn,
|
|
6
|
+
QTableRow,
|
|
7
|
+
QTableSort,
|
|
8
|
+
} from "./props";
|
|
9
|
+
|
|
3
10
|
let {
|
|
4
11
|
columns = [],
|
|
5
12
|
rows = [],
|
|
@@ -8,10 +15,15 @@
|
|
|
8
15
|
dense = false,
|
|
9
16
|
bodyCell,
|
|
10
17
|
...props
|
|
11
|
-
} = $props();
|
|
12
|
-
|
|
18
|
+
}: QTableProps = $props();
|
|
19
|
+
|
|
20
|
+
function getField(
|
|
21
|
+
fieldRaw: QTableColumn["field"],
|
|
22
|
+
row: QTableRow,
|
|
23
|
+
): string | number {
|
|
13
24
|
return typeof fieldRaw === "function" ? fieldRaw(row) : row[fieldRaw];
|
|
14
25
|
}
|
|
26
|
+
|
|
15
27
|
let page = $state(1);
|
|
16
28
|
let rowsPerPage = $state(5);
|
|
17
29
|
let rowsPerPageOptions = $state(
|
|
@@ -20,27 +32,32 @@
|
|
|
20
32
|
value: e.toString(),
|
|
21
33
|
})),
|
|
22
34
|
);
|
|
23
|
-
let sort = $state(null);
|
|
24
|
-
|
|
25
|
-
const
|
|
35
|
+
let sort: QTableSort = $state(null);
|
|
36
|
+
|
|
37
|
+
const numberFrom: number = $derived(rowsPerPage * page - rowsPerPage + 1);
|
|
38
|
+
const numberTo: number = $derived(
|
|
26
39
|
rowsPerPage * page > rows.length ? rows.length : rowsPerPage * page,
|
|
27
40
|
);
|
|
28
|
-
const numberOf = $derived(rows.length);
|
|
41
|
+
const numberOf: number = $derived(rows.length);
|
|
42
|
+
|
|
29
43
|
$effect(() => {
|
|
30
44
|
if (rowsPerPage * (page - 1) >= rows.length) {
|
|
31
45
|
page = 1;
|
|
32
46
|
}
|
|
33
47
|
});
|
|
34
|
-
|
|
48
|
+
|
|
49
|
+
const rowsSorted: QTableRow[] = $derived.by(() => {
|
|
35
50
|
if (sort) {
|
|
36
|
-
return structuredClone(rows).sort((a, b) => {
|
|
37
|
-
const valA = getField(sort
|
|
38
|
-
const valB = getField(sort
|
|
51
|
+
return structuredClone(rows).sort((a: QTableRow, b: QTableRow) => {
|
|
52
|
+
const valA = getField(sort!.columnField, a);
|
|
53
|
+
const valB = getField(sort!.columnField, b);
|
|
54
|
+
|
|
39
55
|
if (typeof valA === "string" && typeof valB === "string") {
|
|
40
56
|
return sort?.type === "desc"
|
|
41
57
|
? valB.localeCompare(valA)
|
|
42
58
|
: valA.localeCompare(valB);
|
|
43
59
|
}
|
|
60
|
+
|
|
44
61
|
return sort?.type === "desc"
|
|
45
62
|
? parseFloat(valA.toString()) > parseFloat(valB.toString())
|
|
46
63
|
? -1
|
|
@@ -50,33 +67,44 @@
|
|
|
50
67
|
: 1;
|
|
51
68
|
});
|
|
52
69
|
}
|
|
70
|
+
|
|
53
71
|
return rows;
|
|
54
72
|
});
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
|
|
74
|
+
const rowsPaginated: QTableRow[] = $derived(
|
|
75
|
+
rowsSorted.slice(numberFrom - 1, numberTo),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
function getThStyle(column: QTableColumn) {
|
|
57
79
|
let style = allowsSort(column) ? "cursor: pointer; " : "";
|
|
58
80
|
return style + getCellStyle(column);
|
|
59
81
|
}
|
|
60
|
-
|
|
82
|
+
|
|
83
|
+
function getCellStyle(column: QTableColumn) {
|
|
61
84
|
if (column.align === "center") {
|
|
62
85
|
return "text-align: center";
|
|
63
86
|
} else if (column.align === "right") {
|
|
64
87
|
return "text-align: right";
|
|
65
88
|
}
|
|
89
|
+
|
|
66
90
|
return "";
|
|
67
91
|
}
|
|
68
|
-
|
|
92
|
+
|
|
93
|
+
function allowsSort(column: QTableColumn) {
|
|
69
94
|
return columns.find((col) => col.name === column.name)?.sortable;
|
|
70
95
|
}
|
|
71
|
-
|
|
72
|
-
|
|
96
|
+
|
|
97
|
+
function hasSort(column: QTableColumn, sort: QTableSort) {
|
|
98
|
+
return sort?.columnField === column.field;
|
|
73
99
|
}
|
|
74
|
-
|
|
100
|
+
|
|
101
|
+
function setSort(column: QTableColumn) {
|
|
75
102
|
const shouldRemove = hasSort(column, sort) && sort?.type === "desc";
|
|
76
103
|
if (shouldRemove) {
|
|
77
104
|
sort = null;
|
|
78
105
|
return;
|
|
79
106
|
}
|
|
107
|
+
|
|
80
108
|
sort = {
|
|
81
109
|
columnField: column.field,
|
|
82
110
|
type: !sort?.type || sort?.type === "desc" ? "asc" : "desc",
|
|
@@ -144,14 +172,14 @@
|
|
|
144
172
|
<QBtn
|
|
145
173
|
icon="chevron_left"
|
|
146
174
|
size="sm"
|
|
147
|
-
|
|
175
|
+
variant="flat"
|
|
148
176
|
disabled={page === 1}
|
|
149
177
|
onclick={() => page--}
|
|
150
178
|
/>
|
|
151
179
|
<QBtn
|
|
152
180
|
icon="chevron_right"
|
|
153
181
|
size="sm"
|
|
154
|
-
|
|
182
|
+
variant="flat"
|
|
155
183
|
disabled={page * rowsPerPage >= rows.length}
|
|
156
184
|
onclick={() => page++}
|
|
157
185
|
/>
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
|
|
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
|
+
}
|