@quaffui/quaff 0.1.0-prealpha15 → 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 -50
- package/dist/components/avatar/QAvatar.svelte.d.ts +2 -25
- package/dist/components/avatar/docs.d.ts +1 -1
- package/dist/components/avatar/docs.js +1 -1
- 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 -10
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +2 -22
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +10 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +62 -38
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +2 -25
- package/dist/components/breadcrumbs/docs.d.ts +1 -1
- package/dist/components/breadcrumbs/docs.js +1 -1
- 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 +89 -46
- package/dist/components/button/QBtn.svelte.d.ts +2 -33
- package/dist/components/button/docs.d.ts +1 -1
- package/dist/components/button/docs.js +1 -1
- 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 +26 -17
- 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 +9 -7
- package/dist/components/card/QCardSection.svelte.d.ts +2 -22
- package/dist/components/card/docs.d.ts +3 -3
- package/dist/components/card/docs.js +3 -3
- package/dist/components/card/docs.props.js +6 -14
- package/dist/components/card/props.d.ts +9 -15
- package/dist/components/checkbox/QCheckbox.svelte +6 -5
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +2 -20
- package/dist/components/checkbox/docs.d.ts +1 -1
- package/dist/components/checkbox/docs.js +1 -1
- 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 +97 -69
- package/dist/components/chip/QChip.svelte.d.ts +2 -35
- package/dist/components/chip/docs.d.ts +1 -1
- package/dist/components/chip/docs.js +1 -1
- package/dist/components/chip/docs.props.js +23 -47
- package/dist/components/chip/props.d.ts +21 -34
- package/dist/components/codeBlock/QCodeBlock.svelte +63 -45
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +2 -19
- 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.d.ts +1 -1
- package/dist/components/dialog/docs.js +1 -1
- 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 -94
- package/dist/components/drawer/QDrawer.svelte.d.ts +6 -39
- package/dist/components/drawer/docs.d.ts +1 -1
- package/dist/components/drawer/docs.js +1 -1
- 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 +65 -24
- package/dist/components/footer/QFooter.svelte.d.ts +2 -23
- package/dist/components/footer/docs.d.ts +1 -1
- package/dist/components/footer/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/icon/docs.js +1 -1
- package/dist/components/icon/docs.props.js +5 -5
- package/dist/components/icon/props.d.ts +6 -6
- 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.d.ts +1 -1
- package/dist/components/input/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/layout/docs.js +1 -1
- 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 +46 -34
- package/dist/components/list/QItemSection.svelte.d.ts +2 -24
- package/dist/components/list/QList.scss +30 -0
- package/dist/components/list/QList.svelte +28 -16
- package/dist/components/list/QList.svelte.d.ts +2 -28
- package/dist/components/list/docs.d.ts +1 -1
- package/dist/components/list/docs.js +1 -1
- 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 +118 -97
- package/dist/components/private/QApi.svelte.d.ts +4 -16
- package/dist/components/private/QDocs.svelte +67 -58
- package/dist/components/private/QDocs.svelte.d.ts +9 -20
- package/dist/components/private/QDocsSection.svelte +15 -22
- package/dist/components/private/QDocsSection.svelte.d.ts +7 -29
- 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.d.ts +1 -1
- package/dist/components/progress/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/radio/docs.js +1 -1
- package/dist/components/radio/docs.props.js +2 -2
- package/dist/components/radio/index.scss +3 -1
- package/dist/components/radio/props.d.ts +2 -4
- 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.d.ts +1 -1
- package/dist/components/railbar/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/select/docs.js +8 -1
- 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.d.ts +1 -1
- package/dist/components/separator/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/table/docs.js +1 -1
- 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 +75 -96
- package/dist/components/tabs/QTab.svelte.d.ts +2 -25
- package/dist/components/tabs/QTabs.scss +40 -0
- package/dist/components/tabs/QTabs.svelte +107 -59
- package/dist/components/tabs/QTabs.svelte.d.ts +6 -31
- package/dist/components/tabs/docs.d.ts +1 -1
- package/dist/components/tabs/docs.js +1 -1
- 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/tabs/props.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/toolbar/docs.js +1 -1
- 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.d.ts +1 -1
- package/dist/components/tooltip/docs.js +1 -1
- 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 +3 -3
- package/dist/composables/index.js +3 -3
- package/dist/composables/useSize.d.ts +10 -0
- package/dist/composables/useSize.js +37 -0
- package/dist/composables/{use-size.d.ts → useSizeLegacy.d.ts} +2 -2
- package/dist/composables/{use-size.js → useSizeLegacy.js} +5 -5
- 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/fonts.scss +16 -3
- 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/global.d.ts +1 -1
- package/dist/helpers/clickOutside.d.ts +2 -2
- package/dist/helpers/clickOutside.js +5 -4
- package/dist/helpers/ripple.d.ts +1 -1
- package/dist/helpers/ripple.js +14 -5
- 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/clipboard.js +2 -2
- package/dist/utils/colors.d.ts +71 -0
- package/dist/utils/colors.js +103 -15
- package/dist/utils/dom.d.ts +2 -0
- package/dist/utils/dom.js +10 -4
- package/dist/utils/number.d.ts +2 -0
- package/dist/utils/number.js +9 -0
- package/dist/utils/props.d.ts +2 -2
- package/dist/utils/props.js +8 -6
- 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 +4 -1
- package/dist/utils/types.d.ts +7 -2
- package/dist/utils/types.js +0 -3
- package/dist/utils/types.json +8 -5
- package/dist/utils/watchable.d.ts +0 -1
- package/dist/utils/watchable.js +1 -1
- package/package.json +42 -39
- package/dist/components/breadcrumbs/index.scss +0 -20
- package/dist/components/button/index.scss +0 -98
- 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 -60
- package/dist/stores/Quaff.d.ts +0 -32
- package/dist/stores/Quaff.js +0 -58
- /package/dist/composables/{use-align.d.ts → useAlign.d.ts} +0 -0
- /package/dist/composables/{use-align.js → useAlign.js} +0 -0
- /package/dist/composables/{use-router-link.d.ts → useRouterLink.d.ts} +0 -0
- /package/dist/composables/{use-router-link.js → useRouterLink.js} +0 -0
- /package/dist/css/mixins/{table.scss → _table.scss} +0 -0
|
@@ -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,2 +1,2 @@
|
|
|
1
1
|
import type { QComponentDocs } from "../../utils";
|
|
2
|
-
export declare
|
|
2
|
+
export declare const QTableDocs: QComponentDocs;
|
|
@@ -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
|
+
}
|
|
@@ -1,113 +1,92 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let qTab;
|
|
19
|
-
const
|
|
20
|
-
if (!hasContext("
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const isInitallyActive = to !== void 0 ? isRouteActive($Quaff.router, to) : name === $qTabStore.value;
|
|
24
|
-
$:
|
|
25
|
-
if (isInitallyActive && qTab) {
|
|
26
|
-
setActive(qTab);
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, hasContext } from "svelte";
|
|
3
|
+
import { QIcon } from "../..";
|
|
4
|
+
import QContext from "../../classes/QContext.svelte";
|
|
5
|
+
import { ripple } from "../../helpers";
|
|
6
|
+
import {
|
|
7
|
+
getClosestFocusableBlock,
|
|
8
|
+
getClosestFocusableSibling,
|
|
9
|
+
} from "../../utils/dom";
|
|
10
|
+
import {
|
|
11
|
+
getDirection,
|
|
12
|
+
isActivationKey,
|
|
13
|
+
isArrowKey,
|
|
14
|
+
isTabKey,
|
|
15
|
+
} from "../../utils/events";
|
|
16
|
+
import { isRouteActive } from "../../utils/router";
|
|
17
|
+
let { name, to, icon, children, ...props } = $props();
|
|
18
|
+
let qTab;
|
|
19
|
+
const tag = $derived(to ? "a" : "button");
|
|
20
|
+
if (!hasContext("QTabsValue")) {
|
|
21
|
+
console.warn("QTab should be use inside QTabs.");
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function setActive(el) {
|
|
38
|
-
const store = get(qTabStore);
|
|
39
|
-
const previousEl = store.activeEl;
|
|
40
|
-
const variant = store.variant;
|
|
41
|
-
const child = variant === "primary" ? el.firstElementChild : { offsetLeft: 0, offsetWidth: 0 };
|
|
42
|
-
const position = variant === "vertical" ? el.offsetTop : el.offsetLeft + child.offsetLeft;
|
|
43
|
-
const size = variant === "vertical" ? el.offsetHeight : child.offsetWidth || el.offsetWidth;
|
|
44
|
-
$qTabStore = {
|
|
45
|
-
variant,
|
|
46
|
-
value: name,
|
|
47
|
-
previousEl,
|
|
48
|
-
activeEl: el,
|
|
49
|
-
utils: {
|
|
50
|
-
size,
|
|
51
|
-
position
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function onClick(e) {
|
|
56
|
-
if (!isActive) {
|
|
57
|
-
setActive(e.target);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function onKeydown(e) {
|
|
61
|
-
if (isActivationKey(e)) {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
const click = new MouseEvent("click");
|
|
64
|
-
qTab.dispatchEvent(click);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (isArrowKey(e)) {
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
const direction = getDirection(e);
|
|
70
|
-
const targetTab = getClosestFocusableSibling(qTab, direction);
|
|
71
|
-
if (targetTab === qTab) {
|
|
23
|
+
const qTabsRequestCtx = QContext.get("QTabsRequest");
|
|
24
|
+
const qTabsValueCtx = QContext.get("QTabsValue");
|
|
25
|
+
const variant = getContext("QTabsVariant");
|
|
26
|
+
const isActive = $derived(
|
|
27
|
+
to ? $isRouteActive(to) : name === qTabsValueCtx.value,
|
|
28
|
+
);
|
|
29
|
+
function onclick(e) {
|
|
30
|
+
props.onclick?.(e);
|
|
31
|
+
if (e.defaultPrevented || isActive) {
|
|
72
32
|
return;
|
|
73
33
|
}
|
|
74
|
-
|
|
75
|
-
return;
|
|
34
|
+
qTabsRequestCtx.update(name);
|
|
76
35
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
36
|
+
function onkeydown(e) {
|
|
37
|
+
props.onkeydown?.(e);
|
|
38
|
+
if (isActivationKey(e)) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
const click = new MouseEvent("click");
|
|
41
|
+
return onclick(click);
|
|
42
|
+
}
|
|
43
|
+
if (isArrowKey(e)) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
const direction = getDirection(e);
|
|
46
|
+
const targetTab = getClosestFocusableSibling(qTab, direction);
|
|
47
|
+
if (targetTab === qTab) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
return targetTab?.focus();
|
|
51
|
+
}
|
|
52
|
+
if (isTabKey(e)) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
const direction = e.shiftKey ? "previous" : "next";
|
|
55
|
+
const targetBlock = getClosestFocusableBlock(qTab, direction);
|
|
56
|
+
targetBlock?.focus();
|
|
57
|
+
}
|
|
82
58
|
}
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
59
|
</script>
|
|
86
60
|
|
|
87
61
|
<svelte:element
|
|
88
|
-
use:ripple
|
|
89
|
-
bind:this={qTab}
|
|
90
62
|
this={tag}
|
|
91
|
-
|
|
63
|
+
bind:this={qTab}
|
|
64
|
+
use:ripple
|
|
65
|
+
{...props}
|
|
66
|
+
class="q-tab{props.class ? ` ${props.class}` : ''}"
|
|
67
|
+
class:q-tab--active={isActive}
|
|
92
68
|
href={to}
|
|
93
69
|
role={tag === "a" ? "button" : undefined}
|
|
94
70
|
aria-current={isActive || undefined}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
on:click
|
|
100
|
-
on:click={onClick}
|
|
101
|
-
on:keydown={onKeydown}
|
|
102
|
-
|
|
103
|
-
{...$$restProps}
|
|
71
|
+
aria-label={name}
|
|
72
|
+
{onclick}
|
|
73
|
+
{onkeydown}
|
|
104
74
|
>
|
|
105
|
-
<div>
|
|
106
|
-
{#if icon}
|
|
75
|
+
<div class="q-tab__content">
|
|
76
|
+
{#if typeof icon === "string"}
|
|
107
77
|
<QIcon name={icon} class="q-tab__icon" />
|
|
108
|
-
{:else
|
|
109
|
-
|
|
78
|
+
{:else}
|
|
79
|
+
{@render icon?.()}
|
|
80
|
+
{/if}
|
|
81
|
+
|
|
82
|
+
{@render children?.()}
|
|
83
|
+
|
|
84
|
+
{#if variant === "primary"}
|
|
85
|
+
<div class="q-tab__indicator"></div>
|
|
110
86
|
{/if}
|
|
111
|
-
<slot />
|
|
112
87
|
</div>
|
|
88
|
+
|
|
89
|
+
{#if variant !== "primary"}
|
|
90
|
+
<div class="q-tab__indicator"></div>
|
|
91
|
+
{/if}
|
|
113
92
|
</svelte:element>
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { QTabProps } from "./props";
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
name: QTabProps["name"];
|
|
7
|
-
to?: QTabProps["to"];
|
|
8
|
-
icon?: QTabProps["icon"];
|
|
9
|
-
class?: string | null | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
click: MouseEvent;
|
|
13
|
-
} & {
|
|
14
|
-
[evt: string]: CustomEvent<any>;
|
|
15
|
-
};
|
|
16
|
-
slots: {
|
|
17
|
-
icon: {};
|
|
18
|
-
default: {};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
type QTabProps_ = typeof __propDef.props;
|
|
22
|
-
export { QTabProps_ as QTabProps };
|
|
23
|
-
export type QTabEvents = typeof __propDef.events;
|
|
24
|
-
export type QTabSlots = typeof __propDef.slots;
|
|
25
|
-
export default class QTab extends SvelteComponent<QTabProps, QTabEvents, QTabSlots> {
|
|
26
|
-
}
|
|
2
|
+
declare const QTab: import("svelte").Component<QTabProps, {}, "">;
|
|
3
|
+
export default QTab;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@use "$css/mixins";
|
|
2
|
+
|
|
3
|
+
.q-tabs {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 0;
|
|
8
|
+
max-width: 100%;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
scroll-behavior: smooth;
|
|
11
|
+
border-radius: 0;
|
|
12
|
+
border-bottom: solid 0.0625rem var(--outline);
|
|
13
|
+
&::-webkit-scrollbar {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.q-tabs--secondary .q-tab .q-tab__indicator {
|
|
18
|
+
border-radius: 0;
|
|
19
|
+
height: 0.125rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.q-tabs--vertical {
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
align-items: stretch;
|
|
26
|
+
border-bottom: unset;
|
|
27
|
+
border-right: solid 0.0625rem var(--outline);
|
|
28
|
+
|
|
29
|
+
& > .q-tab {
|
|
30
|
+
@include mixins.padding("x-md");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
& .q-tab .q-tab__indicator {
|
|
34
|
+
inset: 0 0 0 auto;
|
|
35
|
+
border-radius: 0;
|
|
36
|
+
height: unset;
|
|
37
|
+
width: 0.125rem;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|