@quaffui/quaff 1.0.0-beta3 → 1.0.0-beta5
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/breadcrumbs/QBreadcrumbs.scss +9 -5
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +15 -14
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +22 -3
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +45 -36
- package/dist/components/breadcrumbs/docs.props.js +3 -7
- package/dist/components/breadcrumbs/props.d.ts +4 -4
- package/dist/components/button/QBtn.svelte +13 -7
- package/dist/components/button/docs.props.js +27 -3
- package/dist/components/button/props.d.ts +9 -2
- package/dist/components/expansion-item/QExpansionItem.scss +46 -0
- package/dist/components/expansion-item/QExpansionItem.svelte +300 -0
- package/dist/components/expansion-item/QExpansionItem.svelte.d.ts +21 -0
- package/dist/components/expansion-item/docs.d.ts +2 -0
- package/dist/components/expansion-item/docs.js +17 -0
- package/dist/components/expansion-item/docs.props.d.ts +3 -0
- package/dist/components/expansion-item/docs.props.js +280 -0
- package/dist/components/expansion-item/props.d.ts +129 -0
- package/dist/components/expansion-item/props.js +1 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +2 -1
- package/dist/components/list/QItem.svelte +1 -0
- package/dist/components/select/QSelect.svelte +38 -24
- package/dist/components/select/docs.props.js +13 -1
- package/dist/components/select/props.d.ts +10 -6
- package/dist/components/table/QTable.svelte +8 -6
- package/dist/css/_components.scss +1 -0
- package/dist/css/index.css +1 -1
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/utils/types.json +2 -4
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { MaterialSymbol } from "material-symbols";
|
|
2
|
+
import { Snippet } from "svelte";
|
|
3
|
+
import { HTMLDetailsAttributes, MouseEventHandler } from "svelte/elements";
|
|
4
|
+
export interface QExpansionItemProps extends HTMLDetailsAttributes {
|
|
5
|
+
/**
|
|
6
|
+
* The value of the expansion item, used to define the expansion state of the item.
|
|
7
|
+
*/
|
|
8
|
+
value?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The label of the expansion item, displayed in the header.
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The icon to display in the header of the expansion item.
|
|
15
|
+
*/
|
|
16
|
+
icon?: MaterialSymbol;
|
|
17
|
+
/**
|
|
18
|
+
* The caption, displayed below the label in the header.
|
|
19
|
+
*/
|
|
20
|
+
caption?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The icon to use as the toggle icon for the expansion item.
|
|
23
|
+
* If not provided, a chevron icon will be used.
|
|
24
|
+
*
|
|
25
|
+
* @default "chevron_down"
|
|
26
|
+
*/
|
|
27
|
+
expandIcon?: MaterialSymbol;
|
|
28
|
+
/**
|
|
29
|
+
* The icon to use as the collapse icon for the expanded item.
|
|
30
|
+
* If not provided, the expandIcon will be rotated 180 degrees when the item is expanded.
|
|
31
|
+
*/
|
|
32
|
+
expandedIcon?: MaterialSymbol;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the expansion item is initially expanded.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
defaultOpened?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Use the dense style for the expansion item, reducing its height.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
dense?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Duration for the expansion animation in milliseconds.
|
|
47
|
+
*
|
|
48
|
+
* @default 300
|
|
49
|
+
*/
|
|
50
|
+
duration?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether to hide the expand icon.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
hideExpandIcon?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Register the expansion item into a group, closing other items in the group when this one is opened.
|
|
59
|
+
* This is often called "accordion" behavior. This name is used to identify the group of items
|
|
60
|
+
* and should thus be unique.
|
|
61
|
+
*/
|
|
62
|
+
name?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The aria-label for the toggle button of the expansion item for accessibility.
|
|
65
|
+
*
|
|
66
|
+
* @default "Open details"
|
|
67
|
+
*/
|
|
68
|
+
toggleAriaLabel?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Makes the toggle icon the trigger for the expansion item instead of the whole header.
|
|
71
|
+
* This is useful when using the expansion item as link, so the icon allows to expand/collapse the item
|
|
72
|
+
* while the header changes the route.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
expandIconToggle?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Make the expansion item navigational, allowing it to be used as a link.
|
|
79
|
+
* It can be used interchangeably with the `href` prop.
|
|
80
|
+
* If both `href` and `to` are provided, the `to` prop will take precedence.
|
|
81
|
+
*/
|
|
82
|
+
to?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The URL to navigate to when the expansion item is clicked.
|
|
85
|
+
* It can be used interchangeably with the `to` prop.
|
|
86
|
+
* If both `href` and `to` are provided, the `to` prop will take precedence.
|
|
87
|
+
*/
|
|
88
|
+
href?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Prevents the rotation of the expand icon when the item is expanded.
|
|
91
|
+
* This is useful when using a custom icon that does not need to be rotated.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
noRotateExpandIcon?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the expansion item is disabled.
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Disables the ripple effect on the expansion item.
|
|
104
|
+
* This is useful when the item is used as a link and you want to prevent the ripple effect.
|
|
105
|
+
*
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
noRipple?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The summary snippet, to override the default header.
|
|
111
|
+
* As the header uses QItem, you can easily use QItemSection components to customize the header layout.
|
|
112
|
+
*/
|
|
113
|
+
summary?: Snippet<[
|
|
114
|
+
{
|
|
115
|
+
expanded: boolean;
|
|
116
|
+
show: () => void;
|
|
117
|
+
hide: () => void;
|
|
118
|
+
toggle: () => void;
|
|
119
|
+
}
|
|
120
|
+
]>;
|
|
121
|
+
/**
|
|
122
|
+
* Event triggered when the expansion icon is clicked.
|
|
123
|
+
*/
|
|
124
|
+
onExpandIconClick?: MouseEventHandler<HTMLElement>;
|
|
125
|
+
/**
|
|
126
|
+
* Event triggered when the expansion item is clicked.
|
|
127
|
+
*/
|
|
128
|
+
onclick?: MouseEventHandler<HTMLElement>;
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,6 +11,7 @@ import QCircularProgress from "./progress/QCircularProgress.svelte";
|
|
|
11
11
|
import QCodeBlock from "./codeBlock/QCodeBlock.svelte";
|
|
12
12
|
import QDialog from "./dialog/QDialog.svelte";
|
|
13
13
|
import QDrawer from "./drawer/QDrawer.svelte";
|
|
14
|
+
import QExpansionItem from "./expansion-item/QExpansionItem.svelte";
|
|
14
15
|
import QFooter from "./footer/QFooter.svelte";
|
|
15
16
|
import QHeader from "./header/QHeader.svelte";
|
|
16
17
|
import QIcon from "./icon/QIcon.svelte";
|
|
@@ -31,4 +32,4 @@ import QSwitch from "./switch/QSwitch.svelte";
|
|
|
31
32
|
import QToolbar from "./toolbar/QToolbar.svelte";
|
|
32
33
|
import QToolbarTitle from "./toolbar/QToolbarTitle.svelte";
|
|
33
34
|
import QTooltip from "./tooltip/QTooltip.svelte";
|
|
34
|
-
export { QAvatar, QBreadcrumbs, QBreadcrumbsEl, QBtn, QCard, QCardSection, QCardActions, QCheckbox, QChip, QCircularProgress, QCodeBlock, QDialog, QDrawer, QFooter, QHeader, QIcon, QInput, QSelect, QLayout, QList, QItem, QItemSection, QLinearProgress, QRadio, QRailbar, QSeparator, QTabs, QTab, QTable, QSwitch, QToolbar, QToolbarTitle, QTooltip, };
|
|
35
|
+
export { QAvatar, QBreadcrumbs, QBreadcrumbsEl, QBtn, QCard, QCardSection, QCardActions, QCheckbox, QChip, QCircularProgress, QCodeBlock, QDialog, QDrawer, QExpansionItem, QFooter, QHeader, QIcon, QInput, QSelect, QLayout, QList, QItem, QItemSection, QLinearProgress, QRadio, QRailbar, QSeparator, QTabs, QTab, QTable, QSwitch, QToolbar, QToolbarTitle, QTooltip, };
|
package/dist/components/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import QCircularProgress from "./progress/QCircularProgress.svelte";
|
|
|
11
11
|
import QCodeBlock from "./codeBlock/QCodeBlock.svelte";
|
|
12
12
|
import QDialog from "./dialog/QDialog.svelte";
|
|
13
13
|
import QDrawer from "./drawer/QDrawer.svelte";
|
|
14
|
+
import QExpansionItem from "./expansion-item/QExpansionItem.svelte";
|
|
14
15
|
import QFooter from "./footer/QFooter.svelte";
|
|
15
16
|
import QHeader from "./header/QHeader.svelte";
|
|
16
17
|
import QIcon from "./icon/QIcon.svelte";
|
|
@@ -31,4 +32,4 @@ import QSwitch from "./switch/QSwitch.svelte";
|
|
|
31
32
|
import QToolbar from "./toolbar/QToolbar.svelte";
|
|
32
33
|
import QToolbarTitle from "./toolbar/QToolbarTitle.svelte";
|
|
33
34
|
import QTooltip from "./tooltip/QTooltip.svelte";
|
|
34
|
-
export { QAvatar, QBreadcrumbs, QBreadcrumbsEl, QBtn, QCard, QCardSection, QCardActions, QCheckbox, QChip, QCircularProgress, QCodeBlock, QDialog, QDrawer, QFooter, QHeader, QIcon, QInput, QSelect, QLayout, QList, QItem, QItemSection, QLinearProgress, QRadio, QRailbar, QSeparator, QTabs, QTab, QTable, QSwitch, QToolbar, QToolbarTitle, QTooltip, };
|
|
35
|
+
export { QAvatar, QBreadcrumbs, QBreadcrumbsEl, QBtn, QCard, QCardSection, QCardActions, QCheckbox, QChip, QCircularProgress, QCodeBlock, QDialog, QDrawer, QExpansionItem, QFooter, QHeader, QIcon, QInput, QSelect, QLayout, QList, QItem, QItemSection, QLinearProgress, QRadio, QRailbar, QSeparator, QTabs, QTab, QTable, QSwitch, QToolbar, QToolbarTitle, QTooltip, };
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
import { browser } from "$app/environment";
|
|
4
4
|
import { QIcon } from "../..";
|
|
5
5
|
import type { QEvent } from "../../utils";
|
|
6
|
-
import type {
|
|
7
|
-
QSelectMultipleValue,
|
|
8
|
-
QSelectOption,
|
|
9
|
-
QSelectProps,
|
|
10
|
-
} from "./props";
|
|
6
|
+
import type { QSelectOption, QSelectProps } from "./props";
|
|
11
7
|
|
|
12
8
|
type QSelectEvent<T> = QEvent<T, HTMLDivElement>;
|
|
13
9
|
|
|
@@ -24,6 +20,7 @@
|
|
|
24
20
|
outlined = false,
|
|
25
21
|
rounded = false,
|
|
26
22
|
displayValue,
|
|
23
|
+
emitValue = false,
|
|
27
24
|
before = undefined,
|
|
28
25
|
prepend = undefined,
|
|
29
26
|
append = undefined,
|
|
@@ -39,11 +36,13 @@
|
|
|
39
36
|
return displayValue;
|
|
40
37
|
}
|
|
41
38
|
|
|
39
|
+
const getOptionPropFn = emitValue ? getOptionValue : getOptionLabel;
|
|
40
|
+
|
|
42
41
|
if (!multiple) {
|
|
43
|
-
return value;
|
|
42
|
+
return getOptionPropFn(value as QSelectOption);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
return (value as
|
|
45
|
+
return (value as QSelectOption[]).map(getOptionPropFn).join(", ");
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
const active = $derived(currentDisplayValue || focus);
|
|
@@ -85,37 +84,53 @@
|
|
|
85
84
|
|
|
86
85
|
let snippetPrependWidth = $state(0);
|
|
87
86
|
|
|
87
|
+
function compareValues<T extends QSelectOption>(a: T, b: T) {
|
|
88
|
+
return getOptionValue(a) === getOptionValue(b);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getOptionValue(option: QSelectOption) {
|
|
92
|
+
return typeof option === "object" ? option.value : option;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getOptionLabel(option: QSelectOption) {
|
|
96
|
+
if (typeof option !== "string" && typeof option !== "number") {
|
|
97
|
+
return option.label;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return options.includes(option)
|
|
101
|
+
? option
|
|
102
|
+
: (
|
|
103
|
+
options.find((opt) => compareValues(opt, option)) as {
|
|
104
|
+
label: string | number;
|
|
105
|
+
}
|
|
106
|
+
)?.label || "";
|
|
107
|
+
}
|
|
108
|
+
|
|
88
109
|
function isSelected(option: QSelectOption) {
|
|
89
|
-
const optionValue = typeof option === "string" ? option : option.value;
|
|
90
110
|
return multiple
|
|
91
|
-
? (value as
|
|
92
|
-
: value
|
|
111
|
+
? (value as QSelectOption[]).some((opt) => compareValues(opt, option))
|
|
112
|
+
: compareValues(value as QSelectOption, option);
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
function select(evt: MouseEvent, option: QSelectOption) {
|
|
96
116
|
evt.preventDefault();
|
|
97
|
-
const optionValue =
|
|
117
|
+
const optionValue = getOptionValue(option);
|
|
98
118
|
|
|
99
119
|
if (multiple) {
|
|
100
|
-
const
|
|
101
|
-
(entry
|
|
120
|
+
const index = (value as QSelectOption[]).findIndex((entry) =>
|
|
121
|
+
compareValues(entry, optionValue),
|
|
102
122
|
);
|
|
103
123
|
|
|
104
|
-
if (
|
|
105
|
-
(value as
|
|
106
|
-
value as QSelectMultipleValue
|
|
107
|
-
).filter((val) => val !== optionValue);
|
|
124
|
+
if (index !== -1) {
|
|
125
|
+
(value as QSelectOption[]).splice(index, 1);
|
|
108
126
|
} else {
|
|
109
|
-
(value as
|
|
110
|
-
...(value as QSelectMultipleValue),
|
|
111
|
-
optionValue,
|
|
112
|
-
];
|
|
127
|
+
(value as QSelectOption[]).push(emitValue ? optionValue : option);
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
return;
|
|
116
131
|
}
|
|
117
132
|
|
|
118
|
-
value = optionValue;
|
|
133
|
+
value = emitValue ? optionValue : option;
|
|
119
134
|
isMenuOpen = false;
|
|
120
135
|
}
|
|
121
136
|
|
|
@@ -216,8 +231,7 @@
|
|
|
216
231
|
? 'q-select__option--selected'
|
|
217
232
|
: ''}"
|
|
218
233
|
onmousedown={() => (preventClose = true)}
|
|
219
|
-
onclick={(e) => select(e, option)}
|
|
220
|
-
>{typeof option === "string" ? option : option.value}</a
|
|
234
|
+
onclick={(e) => select(e, option)}>{getOptionLabel(option)}</a
|
|
221
235
|
>
|
|
222
236
|
{/each}
|
|
223
237
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// AUTO GENERATED FILE - DO NOT MODIFY OR DELETE
|
|
2
|
-
// @quaffHash
|
|
2
|
+
// @quaffHash 14a5489af4e6532cb5f1360522bac468
|
|
3
3
|
export const QSelectDocsProps = [
|
|
4
4
|
{
|
|
5
5
|
isArray: false,
|
|
@@ -157,6 +157,18 @@ export const QSelectDocsProps = [
|
|
|
157
157
|
description: "Custom text to display in the select instead of the selected value.",
|
|
158
158
|
default: "undefined",
|
|
159
159
|
},
|
|
160
|
+
{
|
|
161
|
+
isArray: false,
|
|
162
|
+
optional: true,
|
|
163
|
+
isSnippet: false,
|
|
164
|
+
name: "emitValue",
|
|
165
|
+
type: {
|
|
166
|
+
name: "boolean",
|
|
167
|
+
isClickable: false,
|
|
168
|
+
},
|
|
169
|
+
description: "Indicates whether to emit the value rather than the entire option object when a value is selected.",
|
|
170
|
+
default: "false",
|
|
171
|
+
},
|
|
160
172
|
];
|
|
161
173
|
export const QSelectDocsSnippets = [
|
|
162
174
|
{
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { NativeProps } from "../../utils";
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
3
|
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
-
export type QSelectOption = string | {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
4
|
+
export type QSelectOption = string | number | {
|
|
5
|
+
label: string | number;
|
|
6
|
+
value: string | number;
|
|
7
7
|
};
|
|
8
|
-
export type QSelectValue =
|
|
9
|
-
export type QSelectSingleValue = string | number;
|
|
10
|
-
export type QSelectMultipleValue = QSelectSingleValue[];
|
|
8
|
+
export type QSelectValue = QSelectOption | QSelectOption[];
|
|
11
9
|
export interface QSelectProps extends NativeProps, HTMLAttributes<HTMLDivElement> {
|
|
12
10
|
/**
|
|
13
11
|
* Current value of the select. Can be a single value or an array of values when multiple is true.
|
|
@@ -86,6 +84,12 @@ export interface QSelectProps extends NativeProps, HTMLAttributes<HTMLDivElement
|
|
|
86
84
|
* @default undefined
|
|
87
85
|
*/
|
|
88
86
|
displayValue?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Indicates whether to emit the value rather than the entire option object when a value is selected.
|
|
89
|
+
*
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
emitValue?: boolean;
|
|
89
93
|
/**
|
|
90
94
|
* Content to be placed before the select wrapper element, usually an icon.
|
|
91
95
|
*
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
|
|
27
27
|
let page = $state(1);
|
|
28
28
|
let rowsPerPage = $state(5);
|
|
29
|
-
|
|
30
|
-
[5, 10, 25, 50].map((e) => ({
|
|
31
|
-
label: e.toString(),
|
|
32
|
-
value: e.toString(),
|
|
33
|
-
})),
|
|
34
|
-
);
|
|
29
|
+
|
|
35
30
|
let sort: QTableSort = $state(null);
|
|
36
31
|
|
|
32
|
+
const rowsPerPageOptions = $derived(
|
|
33
|
+
[5, 10, 25, 50].filter((option) => {
|
|
34
|
+
return rows.length >= option || option === 5;
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
37
38
|
const numberFrom: number = $derived(rowsPerPage * page - rowsPerPage + 1);
|
|
38
39
|
const numberTo: number = $derived(
|
|
39
40
|
rowsPerPage * page > rows.length ? rows.length : rowsPerPage * page,
|
|
@@ -170,6 +171,7 @@
|
|
|
170
171
|
outlined
|
|
171
172
|
options={rowsPerPageOptions}
|
|
172
173
|
bind:value={rowsPerPage}
|
|
174
|
+
disable={rowsPerPageOptions.length <= 1}
|
|
173
175
|
/>
|
|
174
176
|
{numberFrom}-{numberTo} of {numberOf}
|
|
175
177
|
<QBtn
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
@forward "$components/chip/QChip.scss";
|
|
10
10
|
@forward "$components/dialog/QDialog.scss";
|
|
11
11
|
@forward "$components/drawer/QDrawer.scss";
|
|
12
|
+
@forward "$components/expansion-item/QExpansionItem.scss";
|
|
12
13
|
@forward "$components/footer/QFooter.scss";
|
|
13
14
|
@forward "$components/header/QHeader.scss";
|
|
14
15
|
@forward "$components/icon/QIcon.scss";
|