@quaffui/quaff 0.1.0-prealpha16 → 0.1.0-prealpha19
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 +6 -6
- package/dist/classes/QContext.svelte.d.ts +42 -0
- package/dist/classes/QContext.svelte.js +63 -0
- package/dist/classes/QScrollObserver.svelte.d.ts +44 -0
- package/dist/classes/QScrollObserver.svelte.js +95 -0
- package/dist/classes/QTheme.svelte.d.ts +11 -0
- package/dist/classes/QTheme.svelte.js +49 -0
- package/dist/classes/Quaff.svelte.d.ts +14 -0
- package/dist/classes/Quaff.svelte.js +35 -0
- package/dist/components/avatar/QAvatar.scss +97 -0
- package/dist/components/avatar/QAvatar.svelte +35 -60
- package/dist/components/avatar/QAvatar.svelte.d.ts +2 -25
- package/dist/components/avatar/docs.props.js +21 -5
- package/dist/components/avatar/index.scss +5 -3
- package/dist/components/avatar/props.d.ts +24 -7
- package/dist/components/breadcrumbs/QBreadcrumbs.scss +10 -0
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +24 -9
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +2 -22
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +10 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +64 -38
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +2 -25
- package/dist/components/breadcrumbs/docs.props.js +27 -27
- package/dist/components/breadcrumbs/props.d.ts +25 -24
- package/dist/components/button/QBtn.scss +133 -0
- package/dist/components/button/QBtn.svelte +88 -48
- package/dist/components/button/QBtn.svelte.d.ts +2 -33
- package/dist/components/button/docs.props.js +26 -18
- package/dist/components/button/props.d.ts +21 -15
- package/dist/components/card/QCard.scss +25 -0
- package/dist/components/card/QCard.svelte +25 -16
- package/dist/components/card/QCard.svelte.d.ts +2 -25
- package/dist/components/card/QCardActions.scss +10 -0
- package/dist/components/card/QCardActions.svelte +11 -8
- package/dist/components/card/QCardActions.svelte.d.ts +2 -21
- package/dist/components/card/QCardSection.scss +10 -0
- package/dist/components/card/QCardSection.svelte +8 -6
- package/dist/components/card/QCardSection.svelte.d.ts +2 -22
- package/dist/components/card/docs.props.js +6 -14
- package/dist/components/card/props.d.ts +9 -15
- package/dist/components/checkbox/QCheckbox.svelte +8 -3
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +2 -20
- package/dist/components/checkbox/docs.props.js +1 -1
- package/dist/components/checkbox/index.scss +3 -1
- package/dist/components/checkbox/props.d.ts +1 -2
- package/dist/components/chip/QChip.scss +179 -0
- package/dist/components/chip/QChip.svelte +95 -70
- package/dist/components/chip/QChip.svelte.d.ts +2 -35
- package/dist/components/chip/docs.props.js +23 -47
- package/dist/components/chip/props.d.ts +21 -34
- package/dist/components/codeBlock/QCodeBlock.svelte +64 -42
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +2 -20
- package/dist/components/codeBlock/docs.props.js +10 -2
- package/dist/components/codeBlock/props.d.ts +6 -1
- package/dist/components/dialog/{index.scss → QDialog.scss} +9 -7
- package/dist/components/dialog/QDialog.svelte +72 -70
- package/dist/components/dialog/QDialog.svelte.d.ts +6 -36
- package/dist/components/dialog/docs.props.d.ts +0 -8
- package/dist/components/dialog/docs.props.js +1 -131
- package/dist/components/dialog/props.d.ts +0 -16
- package/dist/components/drawer/QDrawer.scss +45 -0
- package/dist/components/drawer/QDrawer.svelte +87 -91
- package/dist/components/drawer/QDrawer.svelte.d.ts +6 -32
- package/dist/components/drawer/docs.props.js +3 -3
- package/dist/components/drawer/props.d.ts +2 -2
- package/dist/components/footer/QFooter.scss +42 -0
- package/dist/components/footer/QFooter.svelte +62 -23
- package/dist/components/footer/QFooter.svelte.d.ts +2 -23
- package/dist/components/footer/docs.props.js +14 -6
- package/dist/components/footer/props.d.ts +8 -5
- package/dist/components/header/QHeader.scss +54 -0
- package/dist/components/header/QHeader.svelte +52 -24
- package/dist/components/header/QHeader.svelte.d.ts +2 -23
- package/dist/components/header/docs.props.js +23 -7
- package/dist/components/header/props.d.ts +11 -3
- package/dist/components/icon/{index.scss → QIcon.scss} +2 -4
- package/dist/components/icon/QIcon.svelte +29 -16
- package/dist/components/icon/QIcon.svelte.d.ts +2 -27
- package/dist/components/icon/docs.props.js +3 -3
- package/dist/components/icon/props.d.ts +4 -4
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/input/QInput.svelte +52 -25
- package/dist/components/input/QInput.svelte.d.ts +2 -32
- package/dist/components/input/docs.props.js +33 -1
- package/dist/components/input/props.d.ts +5 -12
- package/dist/components/input/props.js +1 -12
- package/dist/components/layout/QLayout.scss +178 -0
- package/dist/components/layout/QLayout.svelte +100 -80
- package/dist/components/layout/QLayout.svelte.d.ts +16 -43
- package/dist/components/layout/docs.props.js +57 -1
- package/dist/components/layout/props.d.ts +8 -0
- package/dist/components/list/QItem.scss +61 -0
- package/dist/components/list/QItem.svelte +65 -46
- package/dist/components/list/QItem.svelte.d.ts +2 -30
- package/dist/components/list/QItemSection.scss +45 -0
- package/dist/components/list/QItemSection.svelte +48 -33
- package/dist/components/list/QItemSection.svelte.d.ts +2 -24
- package/dist/components/list/QList.scss +30 -0
- package/dist/components/list/QList.svelte +25 -14
- package/dist/components/list/QList.svelte.d.ts +2 -28
- package/dist/components/list/docs.props.js +36 -4
- package/dist/components/list/props.d.ts +9 -8
- package/dist/components/list/props.js +1 -25
- package/dist/components/private/ContextReseter.svelte +6 -11
- package/dist/components/private/ContextReseter.svelte.d.ts +6 -18
- package/dist/components/private/QApi.svelte +117 -103
- package/dist/components/private/QApi.svelte.d.ts +4 -16
- package/dist/components/private/QDocs.svelte +67 -48
- package/dist/components/private/QDocs.svelte.d.ts +9 -20
- package/dist/components/private/QDocsSection.svelte +15 -14
- package/dist/components/private/QDocsSection.svelte.d.ts +7 -19
- package/dist/components/private/QIconSnippet.svelte +12 -0
- package/dist/components/private/QIconSnippet.svelte.d.ts +8 -0
- package/dist/components/progress/QCircularProgress.scss +63 -0
- package/dist/components/progress/QCircularProgress.svelte +104 -28
- package/dist/components/progress/QCircularProgress.svelte.d.ts +2 -22
- package/dist/components/progress/QLinearProgress.scss +75 -0
- package/dist/components/progress/QLinearProgress.svelte +55 -13
- package/dist/components/progress/QLinearProgress.svelte.d.ts +2 -20
- package/dist/components/progress/docs.props.js +138 -10
- package/dist/components/progress/props.d.ts +75 -12
- package/dist/components/radio/QRadio.svelte +14 -3
- package/dist/components/radio/QRadio.svelte.d.ts +2 -21
- package/dist/components/radio/docs.props.js +1 -1
- package/dist/components/radio/index.scss +3 -1
- package/dist/components/radio/props.d.ts +1 -3
- package/dist/components/radio/props.js +1 -8
- package/dist/components/railbar/QRailbar.scss +54 -0
- package/dist/components/railbar/QRailbar.svelte +43 -66
- package/dist/components/railbar/QRailbar.svelte.d.ts +2 -22
- package/dist/components/railbar/docs.props.js +4 -4
- package/dist/components/railbar/props.d.ts +3 -3
- package/dist/components/select/QSelect.svelte +121 -88
- package/dist/components/select/QSelect.svelte.d.ts +2 -34
- package/dist/components/select/docs.js +7 -0
- package/dist/components/select/docs.props.js +41 -1
- package/dist/components/select/index.scss +8 -6
- package/dist/components/select/props.d.ts +6 -12
- package/dist/components/select/props.js +1 -12
- package/dist/components/separator/QSeparator.scss +54 -0
- package/dist/components/separator/QSeparator.svelte +38 -45
- package/dist/components/separator/QSeparator.svelte.d.ts +2 -24
- package/dist/components/separator/docs.props.js +4 -4
- package/dist/components/separator/props.d.ts +5 -7
- package/dist/components/separator/props.js +1 -9
- package/dist/components/switch/QSwitch.scss +305 -0
- package/dist/components/switch/QSwitch.svelte +96 -0
- package/dist/components/switch/QSwitch.svelte.d.ts +3 -0
- package/dist/components/{toggle → switch}/docs.d.ts +1 -1
- package/dist/components/{toggle → switch}/docs.js +3 -3
- package/dist/components/{toggle → switch}/docs.props.d.ts +1 -1
- package/dist/components/{toggle → switch}/docs.props.js +30 -6
- package/dist/components/switch/props.d.ts +13 -0
- package/dist/components/switch/props.js +1 -0
- package/dist/components/table/QTable.svelte +99 -85
- package/dist/components/table/QTable.svelte.d.ts +3 -29
- package/dist/components/table/docs.props.js +9 -1
- package/dist/components/table/index.scss +3 -1
- package/dist/components/table/props.d.ts +10 -0
- package/dist/components/tabs/QTab.scss +71 -0
- package/dist/components/tabs/QTab.svelte +74 -90
- package/dist/components/tabs/QTab.svelte.d.ts +2 -25
- package/dist/components/tabs/QTabs.scss +40 -0
- package/dist/components/tabs/QTabs.svelte +110 -58
- package/dist/components/tabs/QTabs.svelte.d.ts +6 -31
- package/dist/components/tabs/docs.props.js +3 -3
- package/dist/components/tabs/index.scss +4 -2
- package/dist/components/tabs/props.d.ts +5 -4
- package/dist/components/toolbar/QToolbar.svelte +15 -12
- package/dist/components/toolbar/QToolbar.svelte.d.ts +2 -23
- package/dist/components/toolbar/QToolbarTitle.svelte +8 -7
- package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +2 -21
- package/dist/components/toolbar/docs.props.js +4 -4
- package/dist/components/toolbar/index.scss +12 -14
- package/dist/components/toolbar/props.d.ts +4 -5
- package/dist/components/tooltip/QTooltip.svelte +5 -9
- package/dist/components/tooltip/QTooltip.svelte.d.ts +2 -21
- package/dist/components/tooltip/docs.props.js +1 -1
- package/dist/components/tooltip/index.scss +3 -1
- package/dist/components/tooltip/props.d.ts +1 -1
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/index.js +1 -1
- package/dist/composables/useSize.d.ts +10 -9
- package/dist/composables/useSize.js +32 -20
- package/dist/composables/useSizeLegacy.d.ts +9 -0
- package/dist/composables/useSizeLegacy.js +25 -0
- package/dist/css/_components.scss +31 -0
- package/dist/css/_disabled.scss +18 -0
- package/dist/css/{ripple.scss → _ripple.scss} +1 -1
- package/dist/css/_variables.scss +73 -0
- package/dist/css/classes/_design.scss +57 -0
- package/dist/css/classes/_flex.scss +62 -0
- package/dist/css/classes/_grid.scss +35 -0
- package/dist/css/classes/_index.scss +7 -0
- package/dist/css/classes/_overflow.scss +7 -0
- package/dist/css/classes/_position.scss +7 -0
- package/dist/css/classes/_select.scss +6 -0
- package/dist/css/classes/_spaces.scss +23 -0
- package/dist/css/index.css +1 -1
- package/dist/css/index.scss +15 -94
- package/dist/css/mixins/_design.scss +63 -0
- package/dist/css/mixins/{field-mixins.scss → _field.scss} +16 -5
- package/dist/css/mixins/_image.scss +63 -0
- package/dist/css/mixins/_index.scss +9 -0
- package/dist/css/mixins/_layout.scss +20 -0
- package/dist/css/mixins/{menu.scss → _menu.scss} +4 -2
- package/dist/css/mixins/{selection.scss → _selection.scss} +7 -67
- package/dist/css/mixins/_spaces.scss +36 -0
- package/dist/css/mixins/_typography.scss +7 -0
- package/dist/css/shared/q-field.scss +62 -32
- package/dist/css/theme/_colors.scss +173 -0
- package/dist/css/theme/css-variables.scss +5 -0
- package/dist/css/theme/page.scss +3 -3
- package/dist/css/theme/reset.scss +17 -1
- package/dist/css/theme/theme.scss +2 -3
- package/dist/css/theme/tokens.scss +0 -159
- package/dist/helpers/clickOutside.js +2 -1
- package/dist/helpers/ripple.d.ts +1 -1
- package/dist/helpers/ripple.js +13 -4
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/stores/index.d.ts +0 -2
- package/dist/stores/index.js +1 -2
- package/dist/utils/colors.d.ts +71 -0
- package/dist/utils/colors.js +101 -14
- package/dist/utils/dom.d.ts +2 -0
- package/dist/utils/dom.js +6 -0
- package/dist/utils/number.d.ts +2 -0
- package/dist/utils/number.js +9 -0
- package/dist/utils/props.js +3 -1
- package/dist/utils/router.d.ts +17 -0
- package/dist/utils/router.js +23 -0
- package/dist/utils/string.d.ts +1 -0
- package/dist/utils/string.js +3 -0
- package/dist/utils/types.d.ts +6 -1
- package/dist/utils/types.js +0 -3
- package/dist/utils/types.json +8 -5
- package/dist/utils/watchable.d.ts +0 -1
- package/package.json +40 -37
- package/dist/components/breadcrumbs/index.scss +0 -20
- package/dist/components/button/index.scss +0 -103
- package/dist/components/card/index.scss +0 -56
- package/dist/components/chip/index.scss +0 -103
- package/dist/components/drawer/index.scss +0 -59
- package/dist/components/footer/index.scss +0 -28
- package/dist/components/layout/index.scss +0 -387
- package/dist/components/list/index.scss +0 -144
- package/dist/components/progress/index.scss +0 -82
- package/dist/components/railbar/index.scss +0 -39
- package/dist/components/separator/index.scss +0 -52
- package/dist/components/toggle/QToggle.svelte +0 -34
- package/dist/components/toggle/QToggle.svelte.d.ts +0 -23
- package/dist/components/toggle/index.scss +0 -31
- package/dist/components/toggle/props.d.ts +0 -9
- package/dist/components/toggle/props.js +0 -9
- package/dist/css/grid.scss +0 -50
- package/dist/css/mixins.scss +0 -137
- package/dist/css/states.scss +0 -75
- package/dist/css/theme/bridge.scss +0 -15
- package/dist/css/theme/theme.dark.scss +0 -39
- package/dist/css/theme/theme.light.scss +0 -39
- package/dist/css/variables-sass.scss +0 -16
- package/dist/stores/QTheme.d.ts +0 -42
- package/dist/stores/QTheme.js +0 -59
- package/dist/stores/Quaff.d.ts +0 -32
- package/dist/stores/Quaff.js +0 -58
- /package/dist/css/mixins/{table.scss → _table.scss} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import QIconSnippet from "../private/QIconSnippet.svelte";
|
|
3
|
+
import { ripple } from "../../helpers";
|
|
4
|
+
import { isActivationKey } from "../../utils";
|
|
5
|
+
let {
|
|
6
|
+
value = $bindable(),
|
|
7
|
+
label = void 0,
|
|
8
|
+
labelPosition = "right",
|
|
9
|
+
disabled = false,
|
|
10
|
+
icons = false,
|
|
11
|
+
showOnlyCheckedIcon = false,
|
|
12
|
+
checkedIcon,
|
|
13
|
+
uncheckedIcon,
|
|
14
|
+
...props
|
|
15
|
+
} = $props();
|
|
16
|
+
let qSwitch;
|
|
17
|
+
let qSwitchInput;
|
|
18
|
+
function toggle() {
|
|
19
|
+
value = !value;
|
|
20
|
+
}
|
|
21
|
+
function onclick(event) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
if (!qSwitchInput || disabled) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
props.onclick?.(event);
|
|
27
|
+
qSwitchInput.focus();
|
|
28
|
+
toggle();
|
|
29
|
+
}
|
|
30
|
+
function onkeydown(event) {
|
|
31
|
+
if (!qSwitch || disabled || !isActivationKey(event)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
props.onkeydown?.(event);
|
|
35
|
+
if (event.defaultPrevented) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
qSwitch.click();
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
bind:this={qSwitch}
|
|
45
|
+
{...props}
|
|
46
|
+
class="q-switch{props.class ? ` ${props.class}` : ''}"
|
|
47
|
+
class:q-switch--disabled={disabled}
|
|
48
|
+
class:q-switch--reversed={labelPosition === "left"}
|
|
49
|
+
{onclick}
|
|
50
|
+
{onkeydown}
|
|
51
|
+
aria-disabled={disabled || undefined}
|
|
52
|
+
role="switch"
|
|
53
|
+
aria-checked={value || undefined}
|
|
54
|
+
tabindex={disabled ? -1 : 0}
|
|
55
|
+
>
|
|
56
|
+
<label class="q-switch__inner">
|
|
57
|
+
<input
|
|
58
|
+
bind:checked={value}
|
|
59
|
+
bind:this={qSwitchInput}
|
|
60
|
+
type="checkbox"
|
|
61
|
+
disabled={disabled || undefined}
|
|
62
|
+
/>
|
|
63
|
+
<span class="q-switch__track">
|
|
64
|
+
<span class="q-switch__touch"></span>
|
|
65
|
+
<span class="q-switch__handle-container" use:ripple={{ disabled }}>
|
|
66
|
+
<span
|
|
67
|
+
class="q-switch__handle"
|
|
68
|
+
class:q-switch__handle--with-icon={showOnlyCheckedIcon
|
|
69
|
+
? !!value
|
|
70
|
+
: icons || uncheckedIcon}
|
|
71
|
+
>
|
|
72
|
+
{#if (uncheckedIcon || icons) && !showOnlyCheckedIcon}
|
|
73
|
+
{@render icon("unchecked")}
|
|
74
|
+
{/if}
|
|
75
|
+
{#if checkedIcon || icons || showOnlyCheckedIcon}
|
|
76
|
+
{@render icon("checked")}
|
|
77
|
+
{/if}
|
|
78
|
+
</span>
|
|
79
|
+
</span>
|
|
80
|
+
</span>
|
|
81
|
+
</label>
|
|
82
|
+
{#if label}
|
|
83
|
+
<span class="q-switch__label">
|
|
84
|
+
{label}
|
|
85
|
+
</span>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
{#snippet icon(type: "unchecked" | "checked")}
|
|
90
|
+
<QIconSnippet
|
|
91
|
+
icon={type === "unchecked" ? uncheckedIcon : checkedIcon}
|
|
92
|
+
defaultIcon={type === "unchecked" ? "close" : "check"}
|
|
93
|
+
size="1rem"
|
|
94
|
+
class="q-switch__icon q-switch__icon--{type}"
|
|
95
|
+
/>
|
|
96
|
+
{/snippet}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { QComponentDocs } from "../../utils";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const QSwitchDocs: QComponentDocs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const
|
|
2
|
-
name: "
|
|
3
|
-
description: "
|
|
1
|
+
export const QSwitchDocs = {
|
|
2
|
+
name: "QSwitch",
|
|
3
|
+
description: "QSwitch is a switch-like checkbox which offers binary choices. It supports labels, icons and different positioning of the labels.",
|
|
4
4
|
docs: {
|
|
5
5
|
props: [
|
|
6
6
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// AUTO GENERATED FILE - DO NOT MODIFY OR DELETE
|
|
2
|
-
// @quaffHash
|
|
3
|
-
export const
|
|
2
|
+
// @quaffHash 1f6e8500a10f28d00338bc8232a16447
|
|
3
|
+
export const QSwitchDocsProps = [
|
|
4
4
|
{
|
|
5
5
|
name: "value",
|
|
6
6
|
type: "boolean",
|
|
@@ -18,7 +18,15 @@ export const QToggleDocsProps = [
|
|
|
18
18
|
default: "",
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
name: "
|
|
21
|
+
name: "labelPosition",
|
|
22
|
+
type: '"left" | "right"',
|
|
23
|
+
optional: true,
|
|
24
|
+
clickableType: false,
|
|
25
|
+
description: "",
|
|
26
|
+
default: "",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "icons",
|
|
22
30
|
type: "boolean",
|
|
23
31
|
optional: true,
|
|
24
32
|
clickableType: false,
|
|
@@ -26,15 +34,31 @@ export const QToggleDocsProps = [
|
|
|
26
34
|
default: "",
|
|
27
35
|
},
|
|
28
36
|
{
|
|
29
|
-
name: "
|
|
30
|
-
type: "
|
|
37
|
+
name: "showOnlyCheckedIcon",
|
|
38
|
+
type: "boolean",
|
|
31
39
|
optional: true,
|
|
32
40
|
clickableType: false,
|
|
33
41
|
description: "",
|
|
34
42
|
default: "",
|
|
35
43
|
},
|
|
36
44
|
{
|
|
37
|
-
name: "
|
|
45
|
+
name: "checkedIcon",
|
|
46
|
+
type: "MaterialSymbol | Snippet",
|
|
47
|
+
optional: true,
|
|
48
|
+
clickableType: true,
|
|
49
|
+
description: "",
|
|
50
|
+
default: "",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "uncheckedIcon",
|
|
54
|
+
type: "MaterialSymbol | Snippet",
|
|
55
|
+
optional: true,
|
|
56
|
+
clickableType: true,
|
|
57
|
+
description: "",
|
|
58
|
+
default: "",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "disabled",
|
|
38
62
|
type: "boolean",
|
|
39
63
|
optional: true,
|
|
40
64
|
clickableType: false,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MaterialSymbol } from "material-symbols";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
export interface QSwitchProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
value?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
labelPosition?: "left" | "right";
|
|
8
|
+
icons?: boolean;
|
|
9
|
+
showOnlyCheckedIcon?: boolean;
|
|
10
|
+
checkedIcon?: MaterialSymbol | Snippet;
|
|
11
|
+
uncheckedIcon?: MaterialSymbol | Snippet;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,97 +1,109 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let rowsSorted = rows;
|
|
15
|
-
let rowsPaginated = [];
|
|
16
|
-
let numberFrom = 1;
|
|
17
|
-
let numberTo = 5;
|
|
18
|
-
let numberOf = rows.length;
|
|
19
|
-
$:
|
|
20
|
-
numberFrom = rowsPerPage * page - rowsPerPage + 1;
|
|
21
|
-
$:
|
|
22
|
-
numberTo = rowsPerPage * page > rows.length ? rows.length : rowsPerPage * page;
|
|
23
|
-
$:
|
|
24
|
-
numberOf = rows.length;
|
|
25
|
-
$:
|
|
26
|
-
rowsPaginated = rowsSorted.slice(numberFrom - 1, numberTo);
|
|
27
|
-
$: {
|
|
28
|
-
if (rowsPerPage * (page - 1) >= rows.length) {
|
|
29
|
-
page = 1;
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { QIcon, QSelect, QBtn } from "../..";
|
|
3
|
+
let {
|
|
4
|
+
columns = [],
|
|
5
|
+
rows = [],
|
|
6
|
+
flat,
|
|
7
|
+
bordered,
|
|
8
|
+
dense = false,
|
|
9
|
+
bodyCell,
|
|
10
|
+
...props
|
|
11
|
+
} = $props();
|
|
12
|
+
function getField(fieldRaw, row) {
|
|
13
|
+
return typeof fieldRaw === "function" ? fieldRaw(row) : row[fieldRaw];
|
|
30
14
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
let page = $state(1);
|
|
16
|
+
let rowsPerPage = $state(5);
|
|
17
|
+
let rowsPerPageOptions = $state(
|
|
18
|
+
[5, 10, 25, 50].map((e) => ({
|
|
19
|
+
label: e.toString(),
|
|
20
|
+
value: e.toString(),
|
|
21
|
+
})),
|
|
22
|
+
);
|
|
23
|
+
let sort = $state(null);
|
|
24
|
+
const numberFrom = $derived(rowsPerPage * page - rowsPerPage + 1);
|
|
25
|
+
const numberTo = $derived(
|
|
26
|
+
rowsPerPage * page > rows.length ? rows.length : rowsPerPage * page,
|
|
27
|
+
);
|
|
28
|
+
const numberOf = $derived(rows.length);
|
|
29
|
+
$effect(() => {
|
|
30
|
+
if (rowsPerPage * (page - 1) >= rows.length) {
|
|
31
|
+
page = 1;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const rowsSorted = $derived.by(() => {
|
|
35
|
+
if (sort) {
|
|
36
|
+
return structuredClone(rows).sort((a, b) => {
|
|
37
|
+
const valA = getField(sort.columnField, a);
|
|
38
|
+
const valB = getField(sort.columnField, b);
|
|
39
|
+
if (typeof valA === "string" && typeof valB === "string") {
|
|
40
|
+
return sort?.type === "desc"
|
|
41
|
+
? valB.localeCompare(valA)
|
|
42
|
+
: valA.localeCompare(valB);
|
|
43
|
+
}
|
|
44
|
+
return sort?.type === "desc"
|
|
45
|
+
? parseFloat(valA.toString()) > parseFloat(valB.toString())
|
|
46
|
+
? -1
|
|
47
|
+
: 1
|
|
48
|
+
: parseFloat(valB.toString()) > parseFloat(valA.toString())
|
|
49
|
+
? -1
|
|
50
|
+
: 1;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return rows;
|
|
54
|
+
});
|
|
55
|
+
const rowsPaginated = $derived(rowsSorted.slice(numberFrom - 1, numberTo));
|
|
56
|
+
function getThStyle(column) {
|
|
57
|
+
let style = allowsSort(column) ? "cursor: pointer; " : "";
|
|
58
|
+
return style + getCellStyle(column);
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return "text-align: center";
|
|
53
|
-
} else if (column.align === "right") {
|
|
54
|
-
return "text-align: right";
|
|
60
|
+
function getCellStyle(column) {
|
|
61
|
+
if (column.align === "center") {
|
|
62
|
+
return "text-align: center";
|
|
63
|
+
} else if (column.align === "right") {
|
|
64
|
+
return "text-align: right";
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
function allowsSort(column) {
|
|
69
|
+
return columns.find((col) => col.name === column.name)?.sortable;
|
|
70
|
+
}
|
|
71
|
+
function hasSort(column, sort2) {
|
|
72
|
+
return sort2?.columnField === column.field;
|
|
73
|
+
}
|
|
74
|
+
function setSort(column) {
|
|
75
|
+
const shouldRemove = hasSort(column, sort) && sort?.type === "desc";
|
|
76
|
+
if (shouldRemove) {
|
|
77
|
+
sort = null;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
sort = {
|
|
81
|
+
columnField: column.field,
|
|
82
|
+
type: !sort?.type || sort?.type === "desc" ? "asc" : "desc",
|
|
83
|
+
};
|
|
69
84
|
}
|
|
70
|
-
sort = {
|
|
71
|
-
columnField: column.field,
|
|
72
|
-
type: !sort?.type || sort?.type === "desc" ? "asc" : "desc"
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
85
|
</script>
|
|
76
86
|
|
|
77
|
-
<div class="q-table"
|
|
87
|
+
<div {...props} class="q-table">
|
|
78
88
|
<table
|
|
79
|
-
class="q-table__table {
|
|
80
|
-
class:q-
|
|
81
|
-
class:q-
|
|
82
|
-
class:q-
|
|
89
|
+
class="q-table__table{props.class ? ` ${props.class}` : ''}"
|
|
90
|
+
class:q-table__table--flat={flat}
|
|
91
|
+
class:q-table__table--bordered={bordered}
|
|
92
|
+
class:q-table__table--dense={dense}
|
|
83
93
|
>
|
|
84
94
|
<thead>
|
|
85
95
|
<tr>
|
|
86
96
|
{#each columns as column}
|
|
87
|
-
<th style={getThStyle(column)}
|
|
97
|
+
<th style={getThStyle(column)} onclick={() => setSort(column)}>
|
|
88
98
|
{#if column.align === "left"}
|
|
89
99
|
{column.label}
|
|
90
100
|
{/if}
|
|
91
101
|
|
|
92
102
|
{#if allowsSort(column)}
|
|
93
103
|
<QIcon
|
|
94
|
-
name={sort?.type !== "desc"
|
|
104
|
+
name={sort?.type !== "desc"
|
|
105
|
+
? "keyboard_arrow_up"
|
|
106
|
+
: "keyboard_arrow_down"}
|
|
95
107
|
class="q-icon {hasSort(column, sort) ? 'q-icon--sort' : ''}"
|
|
96
108
|
/>
|
|
97
109
|
{/if}
|
|
@@ -107,11 +119,13 @@ function setSort(column) {
|
|
|
107
119
|
{#each rowsPaginated as row}
|
|
108
120
|
<tr>
|
|
109
121
|
{#each columns as column}
|
|
110
|
-
|
|
122
|
+
{#if bodyCell}
|
|
123
|
+
{@render bodyCell({ column, row, style: getCellStyle(column) })}
|
|
124
|
+
{:else}
|
|
111
125
|
<td class="q-table__body-cell" style={getCellStyle(column)}
|
|
112
126
|
>{getField(column.field, row)}</td
|
|
113
127
|
>
|
|
114
|
-
|
|
128
|
+
{/if}
|
|
115
129
|
{/each}
|
|
116
130
|
</tr>
|
|
117
131
|
{/each}
|
|
@@ -130,16 +144,16 @@ function setSort(column) {
|
|
|
130
144
|
<QBtn
|
|
131
145
|
icon="chevron_left"
|
|
132
146
|
size="sm"
|
|
133
|
-
flat
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
design="flat"
|
|
148
|
+
disabled={page === 1}
|
|
149
|
+
onclick={() => page--}
|
|
136
150
|
/>
|
|
137
151
|
<QBtn
|
|
138
152
|
icon="chevron_right"
|
|
139
153
|
size="sm"
|
|
140
|
-
flat
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
design="flat"
|
|
155
|
+
disabled={page * rowsPerPage >= rows.length}
|
|
156
|
+
onclick={() => page++}
|
|
143
157
|
/>
|
|
144
158
|
</div>
|
|
145
159
|
</div>
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
props: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
columns?: QTableColumn[] | undefined;
|
|
7
|
-
rows?: QTableRow[] | undefined;
|
|
8
|
-
flat?: QTableProps["flat"];
|
|
9
|
-
bordered?: QTableProps["bordered"];
|
|
10
|
-
dense?: QTableProps["dense"];
|
|
11
|
-
class?: string | null | undefined;
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
[evt: string]: CustomEvent<any>;
|
|
15
|
-
};
|
|
16
|
-
slots: {
|
|
17
|
-
'body-cell': {
|
|
18
|
-
column: QTableColumn;
|
|
19
|
-
row: QTableRow;
|
|
20
|
-
style: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
type QTableProps_ = typeof __propDef.props;
|
|
25
|
-
export { QTableProps_ as QTableProps };
|
|
26
|
-
export type QTableEvents = typeof __propDef.events;
|
|
27
|
-
export type QTableSlots = typeof __propDef.slots;
|
|
28
|
-
export default class QTable extends SvelteComponent<QTableProps, QTableEvents, QTableSlots> {
|
|
29
|
-
}
|
|
1
|
+
import type { QTableProps } from "./props";
|
|
2
|
+
declare const QTable: import("svelte").Component<QTableProps, {}, "">;
|
|
3
|
+
export default QTable;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// AUTO GENERATED FILE - DO NOT MODIFY OR DELETE
|
|
2
|
-
// @quaffHash
|
|
2
|
+
// @quaffHash d9ca4c59cff5796a9346569afaa9042b
|
|
3
3
|
export const QTableDocsProps = [
|
|
4
4
|
{
|
|
5
5
|
name: "columns",
|
|
@@ -41,4 +41,12 @@ export const QTableDocsProps = [
|
|
|
41
41
|
description: "Shows the Table in dense mode (takes up less space).",
|
|
42
42
|
default: "false",
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
name: "bodyCell",
|
|
46
|
+
type: "string }]>",
|
|
47
|
+
optional: true,
|
|
48
|
+
clickableType: true,
|
|
49
|
+
description: "Optionally pass a snippet to render each table cell.",
|
|
50
|
+
default: "undefined",
|
|
51
|
+
},
|
|
44
52
|
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NativeProps } from "../../utils";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
2
3
|
import type { HTMLAttributes } from "svelte/elements";
|
|
3
4
|
export type QTableColumn = {
|
|
4
5
|
name: string;
|
|
@@ -43,4 +44,13 @@ export interface QTableProps extends NativeProps, HTMLAttributes<HTMLDivElement>
|
|
|
43
44
|
* @default false
|
|
44
45
|
*/
|
|
45
46
|
dense?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Optionally pass a snippet to render each table cell.
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
51
|
+
bodyCell?: Snippet<[{
|
|
52
|
+
column: QTableColumn;
|
|
53
|
+
row: QTableRow;
|
|
54
|
+
style: string;
|
|
55
|
+
}]>;
|
|
46
56
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@use "$css/mixins";
|
|
2
|
+
|
|
3
|
+
.q-tab {
|
|
4
|
+
position: relative;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
min-height: 3rem;
|
|
7
|
+
height: 3rem;
|
|
8
|
+
min-width: max-content;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
flex: 1;
|
|
13
|
+
background-color: var(--surface);
|
|
14
|
+
color: var(--on-surface);
|
|
15
|
+
border-radius: 0;
|
|
16
|
+
gap: 0;
|
|
17
|
+
overflow: visible;
|
|
18
|
+
@include mixins.padding("x-md");
|
|
19
|
+
|
|
20
|
+
& .q-tab__icon {
|
|
21
|
+
margin-right: 0.25rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.q-tab--active {
|
|
25
|
+
color: var(--primary);
|
|
26
|
+
|
|
27
|
+
& .q-tab__indicator {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:is(:hover, :focus):not([aria-disabled])::after {
|
|
33
|
+
content: "";
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
background-color: var(--on-surface);
|
|
40
|
+
border-radius: none;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&:hover:not([aria-disabled])::after {
|
|
45
|
+
opacity: 0.08;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:focus:not([aria-disabled])::after {
|
|
49
|
+
opacity: 0.16;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
& .q-tab__content {
|
|
53
|
+
height: 100%;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
& .q-tab__indicator {
|
|
60
|
+
position: absolute;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
transform-origin: bottom left;
|
|
63
|
+
background: var(--primary);
|
|
64
|
+
border-radius: 0.1875rem 0.1875rem 0 0;
|
|
65
|
+
height: 0.1875rem;
|
|
66
|
+
inset: auto 0 0 0;
|
|
67
|
+
// hidden unless the tab is selected
|
|
68
|
+
opacity: 0;
|
|
69
|
+
z-index: 1;
|
|
70
|
+
}
|
|
71
|
+
}
|