@quaffui/quaff 1.0.0-beta6 → 1.0.0-beta9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/components/avatar/QAvatar.svelte +4 -0
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +28 -5
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +23 -0
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +17 -14
- package/dist/components/button/QBtn.svelte +21 -11
- package/dist/components/card/QCard.svelte +9 -5
- package/dist/components/card/QCardActions.svelte +4 -0
- package/dist/components/card/QCardSection.svelte +2 -0
- package/dist/components/checkbox/QCheckbox.svelte +2 -0
- package/dist/components/chip/QChip.svelte +24 -14
- package/dist/components/codeBlock/QCodeBlock.svelte +8 -0
- package/dist/components/dialog/QDialog.svelte +12 -0
- package/dist/components/drawer/QDrawer.svelte +50 -39
- package/dist/components/expansion-item/QExpansionItem.svelte +16 -2
- package/dist/components/footer/QFooter.svelte +27 -22
- package/dist/components/header/QHeader.svelte +37 -28
- package/dist/components/icon/QIcon.svelte +4 -0
- package/dist/components/input/QInput.svelte +9 -2
- package/dist/components/layout/QLayout.svelte +243 -90
- package/dist/components/layout/QLayout.svelte.d.ts +64 -2
- package/dist/components/list/QItem.svelte +43 -24
- package/dist/components/list/QItem.svelte.d.ts +14 -0
- package/dist/components/list/QItemSection.svelte +16 -12
- package/dist/components/list/QList.svelte +28 -6
- package/dist/components/list/QList.svelte.d.ts +15 -0
- package/dist/components/private/ContextReseter.svelte +2 -3
- package/dist/components/private/QApi.svelte +15 -7
- package/dist/components/private/QDocs.svelte +40 -20
- package/dist/components/private/QDocs.svelte.d.ts +30 -0
- package/dist/components/private/QDocsSection.svelte +11 -7
- package/dist/components/progress/QCircularProgress.svelte +14 -5
- package/dist/components/progress/QLinearProgress.svelte +12 -6
- package/dist/components/radio/QRadio.svelte +2 -0
- package/dist/components/railbar/QRailbar.svelte +36 -35
- package/dist/components/select/QSelect.svelte +32 -23
- package/dist/components/separator/QSeparator.svelte +4 -0
- package/dist/components/switch/QSwitch.svelte +6 -0
- package/dist/components/table/QTable.svelte +23 -13
- package/dist/components/tabs/QTab.svelte +19 -22
- package/dist/components/tabs/QTabs.svelte +59 -32
- package/dist/components/tabs/QTabs.svelte.d.ts +15 -4
- package/dist/components/toolbar/QToolbar.svelte +2 -0
- package/dist/components/toolbar/QToolbarTitle.svelte +2 -0
- package/dist/components/tooltip/QTooltip.svelte +22 -8
- package/dist/components/tooltip/QTooltipBase.svelte +18 -8
- package/dist/composables/useRouterLink.d.ts +2 -1
- 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/context.d.ts +49 -32
- package/dist/utils/context.js +82 -33
- package/package.json +28 -27
- package/dist/classes/QContext.svelte.d.ts +0 -42
- package/dist/classes/QContext.svelte.js +0 -63
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import { onMount
|
|
3
|
-
import { QContext } from "../../
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { QContext } from "../../utils";
|
|
4
4
|
import { ContextReseter } from "../private";
|
|
5
|
-
import { QLayoutCtxName } from "../../utils";
|
|
6
5
|
import type { QLayoutProps } from "./props";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
interface AppbarContext {
|
|
8
|
+
readonly view: string;
|
|
9
9
|
height: number;
|
|
10
10
|
collapsed: boolean;
|
|
11
11
|
ready: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface DrawerContext {
|
|
15
|
+
readonly view: string;
|
|
15
16
|
width: number;
|
|
16
17
|
takesSpace: boolean;
|
|
17
18
|
ready: boolean;
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
export const headerCtx = QContext<AppbarContext>("QHeader");
|
|
22
|
+
export const footerCtx = QContext<AppbarContext>("QFooter");
|
|
23
|
+
|
|
24
|
+
export const leftRailbarCtx = QContext<DrawerContext>("QRailbarLeft");
|
|
25
|
+
export const rightRailbarCtx = QContext<DrawerContext>("QRailbarRight");
|
|
26
|
+
export const leftDrawerCtx = QContext<DrawerContext>("QDrawerLeft");
|
|
27
|
+
export const rightDrawerCtx = QContext<DrawerContext>("QDrawerRight");
|
|
19
28
|
</script>
|
|
20
29
|
|
|
21
30
|
<script lang="ts">
|
|
31
|
+
// #region: --- Props
|
|
22
32
|
let {
|
|
23
33
|
view = "hhh lpr fff",
|
|
24
34
|
content,
|
|
@@ -33,81 +43,56 @@
|
|
|
33
43
|
children,
|
|
34
44
|
...props
|
|
35
45
|
}: QLayoutProps = $props();
|
|
46
|
+
// #endregion: --- Props
|
|
36
47
|
|
|
48
|
+
// #region: --- Reactive variables
|
|
37
49
|
let layoutEl = $state<HTMLDivElement>();
|
|
38
50
|
let contentEl = $state<HTMLDivElement>();
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
if (contentEl) {
|
|
43
|
-
contentEl.style.transition = "margin 0.3s";
|
|
44
|
-
}
|
|
45
|
-
}, 100);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
setContext(QLayoutCtxName.view, {
|
|
49
|
-
get value() {
|
|
50
|
-
return view;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const headerCtx = new QContext<AppbarContext>(QLayoutCtxName.header, {
|
|
52
|
+
const headerInfo = $state({
|
|
55
53
|
height: 0,
|
|
56
54
|
collapsed: false,
|
|
57
55
|
ready: false,
|
|
58
56
|
});
|
|
59
|
-
|
|
60
|
-
const footerCtx = new QContext<AppbarContext>(QLayoutCtxName.footer, {
|
|
57
|
+
const footerInfo = $state({
|
|
61
58
|
height: 0,
|
|
62
59
|
collapsed: false,
|
|
63
60
|
ready: false,
|
|
64
61
|
});
|
|
62
|
+
const leftRailbarInfo = $state({
|
|
63
|
+
width: 0,
|
|
64
|
+
takesSpace: false,
|
|
65
|
+
ready: false,
|
|
66
|
+
});
|
|
67
|
+
const rightRailbarInfo = $state({
|
|
68
|
+
width: 0,
|
|
69
|
+
takesSpace: false,
|
|
70
|
+
ready: false,
|
|
71
|
+
});
|
|
72
|
+
const leftDrawerInfo = $state({
|
|
73
|
+
width: 0,
|
|
74
|
+
takesSpace: false,
|
|
75
|
+
ready: false,
|
|
76
|
+
});
|
|
77
|
+
const rightDrawerInfo = $state({
|
|
78
|
+
width: 0,
|
|
79
|
+
takesSpace: false,
|
|
80
|
+
ready: false,
|
|
81
|
+
});
|
|
82
|
+
// #endregion: --- Reactive variables
|
|
65
83
|
|
|
66
|
-
|
|
67
|
-
QLayoutCtxName.railbar.left,
|
|
68
|
-
{
|
|
69
|
-
width: 0,
|
|
70
|
-
takesSpace: false,
|
|
71
|
-
ready: false,
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
const rightRailbarCtx = new QContext<DrawerContext>(
|
|
75
|
-
QLayoutCtxName.railbar.right,
|
|
76
|
-
{
|
|
77
|
-
width: 0,
|
|
78
|
-
takesSpace: false,
|
|
79
|
-
ready: false,
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const leftDrawerCtx = new QContext<DrawerContext>(
|
|
84
|
-
QLayoutCtxName.drawer.left,
|
|
85
|
-
{
|
|
86
|
-
width: 0,
|
|
87
|
-
takesSpace: false,
|
|
88
|
-
ready: false,
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
const rightDrawerCtx = new QContext<DrawerContext>(
|
|
92
|
-
QLayoutCtxName.drawer.right,
|
|
93
|
-
{
|
|
94
|
-
width: 360,
|
|
95
|
-
takesSpace: false,
|
|
96
|
-
ready: false,
|
|
97
|
-
},
|
|
98
|
-
);
|
|
99
|
-
|
|
84
|
+
// #region: --- Derived values
|
|
100
85
|
const topOffset = $derived(
|
|
101
|
-
!header ||
|
|
86
|
+
!header || headerInfo.collapsed ? 0 : headerInfo.height,
|
|
102
87
|
);
|
|
103
88
|
const bottomOffset = $derived(
|
|
104
|
-
!footer ||
|
|
89
|
+
!footer || footerInfo.collapsed ? 0 : footerInfo.height,
|
|
105
90
|
);
|
|
106
91
|
const leftOffset = $derived(
|
|
107
|
-
handleDrawerCtx(
|
|
92
|
+
handleDrawerCtx(leftRailbarInfo) + handleDrawerCtx(leftDrawerInfo),
|
|
108
93
|
);
|
|
109
94
|
const rightOffset = $derived(
|
|
110
|
-
handleDrawerCtx(
|
|
95
|
+
handleDrawerCtx(rightRailbarInfo) + handleDrawerCtx(rightDrawerInfo),
|
|
111
96
|
);
|
|
112
97
|
|
|
113
98
|
const contentMargin = $derived(
|
|
@@ -115,39 +100,207 @@
|
|
|
115
100
|
);
|
|
116
101
|
|
|
117
102
|
const isReady = $derived(
|
|
118
|
-
(
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
(!railbarLeft ||
|
|
125
|
-
leftRailbarCtx.value.ready ||
|
|
126
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-railbar--left"))) &&
|
|
127
|
-
(!railbarRight ||
|
|
128
|
-
rightRailbarCtx.value.ready ||
|
|
129
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-railbar--right"))) &&
|
|
130
|
-
(!drawerLeft ||
|
|
131
|
-
leftDrawerCtx.value.ready ||
|
|
132
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-drawer--left"))) &&
|
|
133
|
-
(!drawerRight ||
|
|
134
|
-
rightDrawerCtx.value.ready ||
|
|
135
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-drawer--right"))),
|
|
103
|
+
appBarReady("header") &&
|
|
104
|
+
appBarReady("footer") &&
|
|
105
|
+
sideBarReady("railbar", "left") &&
|
|
106
|
+
sideBarReady("railbar", "right") &&
|
|
107
|
+
sideBarReady("drawer", "left") &&
|
|
108
|
+
sideBarReady("drawer", "right"),
|
|
136
109
|
);
|
|
110
|
+
// #endregion: --- Derived values
|
|
111
|
+
|
|
112
|
+
// #region: --- Context
|
|
113
|
+
headerCtx.set({
|
|
114
|
+
get view() {
|
|
115
|
+
return view;
|
|
116
|
+
},
|
|
117
|
+
get height() {
|
|
118
|
+
return headerInfo.height;
|
|
119
|
+
},
|
|
120
|
+
set height(newValue) {
|
|
121
|
+
headerInfo.height = newValue;
|
|
122
|
+
},
|
|
123
|
+
get collapsed() {
|
|
124
|
+
return headerInfo.collapsed;
|
|
125
|
+
},
|
|
126
|
+
set collapsed(newValue) {
|
|
127
|
+
headerInfo.collapsed = newValue;
|
|
128
|
+
},
|
|
129
|
+
get ready() {
|
|
130
|
+
return headerInfo.ready;
|
|
131
|
+
},
|
|
132
|
+
set ready(newValue) {
|
|
133
|
+
headerInfo.ready = newValue;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
footerCtx.set({
|
|
137
|
+
get view() {
|
|
138
|
+
return view;
|
|
139
|
+
},
|
|
140
|
+
get height() {
|
|
141
|
+
return footerInfo.height;
|
|
142
|
+
},
|
|
143
|
+
set height(newValue) {
|
|
144
|
+
footerInfo.height = newValue;
|
|
145
|
+
},
|
|
146
|
+
get collapsed() {
|
|
147
|
+
return footerInfo.collapsed;
|
|
148
|
+
},
|
|
149
|
+
set collapsed(newValue) {
|
|
150
|
+
footerInfo.collapsed = newValue;
|
|
151
|
+
},
|
|
152
|
+
get ready() {
|
|
153
|
+
return footerInfo.ready;
|
|
154
|
+
},
|
|
155
|
+
set ready(newValue) {
|
|
156
|
+
footerInfo.ready = newValue;
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
leftRailbarCtx.set({
|
|
161
|
+
get view() {
|
|
162
|
+
return view;
|
|
163
|
+
},
|
|
164
|
+
get width() {
|
|
165
|
+
return leftRailbarInfo.width;
|
|
166
|
+
},
|
|
167
|
+
set width(newValue) {
|
|
168
|
+
leftRailbarInfo.width = newValue;
|
|
169
|
+
},
|
|
170
|
+
get takesSpace() {
|
|
171
|
+
return leftRailbarInfo.takesSpace;
|
|
172
|
+
},
|
|
173
|
+
set takesSpace(newValue) {
|
|
174
|
+
leftRailbarInfo.takesSpace = newValue;
|
|
175
|
+
},
|
|
176
|
+
get ready() {
|
|
177
|
+
return leftRailbarInfo.ready;
|
|
178
|
+
},
|
|
179
|
+
set ready(newValue) {
|
|
180
|
+
leftRailbarInfo.ready = newValue;
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
rightRailbarCtx.set({
|
|
184
|
+
get view() {
|
|
185
|
+
return view;
|
|
186
|
+
},
|
|
187
|
+
get width() {
|
|
188
|
+
return rightRailbarInfo.width;
|
|
189
|
+
},
|
|
190
|
+
set width(newValue) {
|
|
191
|
+
rightRailbarInfo.width = newValue;
|
|
192
|
+
},
|
|
193
|
+
get takesSpace() {
|
|
194
|
+
return rightRailbarInfo.takesSpace;
|
|
195
|
+
},
|
|
196
|
+
set takesSpace(newValue) {
|
|
197
|
+
rightRailbarInfo.takesSpace = newValue;
|
|
198
|
+
},
|
|
199
|
+
get ready() {
|
|
200
|
+
return rightRailbarInfo.ready;
|
|
201
|
+
},
|
|
202
|
+
set ready(newValue) {
|
|
203
|
+
rightRailbarInfo.ready = newValue;
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
leftDrawerCtx.set({
|
|
208
|
+
get view() {
|
|
209
|
+
return view;
|
|
210
|
+
},
|
|
211
|
+
get width() {
|
|
212
|
+
return leftDrawerInfo.width;
|
|
213
|
+
},
|
|
214
|
+
set width(newValue) {
|
|
215
|
+
leftDrawerInfo.width = newValue;
|
|
216
|
+
},
|
|
217
|
+
get takesSpace() {
|
|
218
|
+
return leftDrawerInfo.takesSpace;
|
|
219
|
+
},
|
|
220
|
+
set takesSpace(newValue) {
|
|
221
|
+
leftDrawerInfo.takesSpace = newValue;
|
|
222
|
+
},
|
|
223
|
+
get ready() {
|
|
224
|
+
return leftDrawerInfo.ready;
|
|
225
|
+
},
|
|
226
|
+
set ready(newValue) {
|
|
227
|
+
leftDrawerInfo.ready = newValue;
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
rightDrawerCtx.set({
|
|
231
|
+
get view() {
|
|
232
|
+
return view;
|
|
233
|
+
},
|
|
234
|
+
get width() {
|
|
235
|
+
return rightDrawerInfo.width;
|
|
236
|
+
},
|
|
237
|
+
set width(newValue) {
|
|
238
|
+
rightDrawerInfo.width = newValue;
|
|
239
|
+
},
|
|
240
|
+
get takesSpace() {
|
|
241
|
+
return rightDrawerInfo.takesSpace;
|
|
242
|
+
},
|
|
243
|
+
set takesSpace(newValue) {
|
|
244
|
+
rightDrawerInfo.takesSpace = newValue;
|
|
245
|
+
},
|
|
246
|
+
get ready() {
|
|
247
|
+
return rightDrawerInfo.ready;
|
|
248
|
+
},
|
|
249
|
+
set ready(newValue) {
|
|
250
|
+
rightDrawerInfo.ready = newValue;
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
// #endregion: --- Context
|
|
254
|
+
|
|
255
|
+
// #region: --- Lifecycle
|
|
256
|
+
onMount(() => {
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
if (contentEl) {
|
|
259
|
+
contentEl.style.transition = "margin 0.3s";
|
|
260
|
+
}
|
|
261
|
+
}, 100);
|
|
262
|
+
});
|
|
263
|
+
// #endregion: --- Lifecycle
|
|
264
|
+
|
|
265
|
+
// #region: --- Functions
|
|
266
|
+
function handleDrawerCtx(info: Omit<DrawerContext, "view">) {
|
|
267
|
+
return info.takesSpace ? info.width : 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function appBarReady(barType: "header" | "footer") {
|
|
271
|
+
const barReady = !header || headerInfo.ready;
|
|
272
|
+
|
|
273
|
+
return barReady || (layoutEl && !layoutEl.querySelector(`.q-${barType}`));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function sideBarReady(barType: "railbar" | "drawer", side: "left" | "right") {
|
|
277
|
+
const barReady =
|
|
278
|
+
side === "left"
|
|
279
|
+
? {
|
|
280
|
+
railbar: !railbarLeft || leftRailbarInfo.ready,
|
|
281
|
+
drawer: !drawerLeft || leftDrawerInfo.ready,
|
|
282
|
+
}
|
|
283
|
+
: {
|
|
284
|
+
railbar: !railbarRight || rightRailbarInfo.ready,
|
|
285
|
+
drawer: !drawerRight || rightDrawerInfo.ready,
|
|
286
|
+
};
|
|
137
287
|
|
|
138
|
-
|
|
139
|
-
|
|
288
|
+
return (
|
|
289
|
+
barReady[barType] ||
|
|
290
|
+
(layoutEl && !layoutEl.querySelector(`:scope > .q-${barType}--${side}`))
|
|
291
|
+
);
|
|
140
292
|
}
|
|
293
|
+
// #endregion: --- Functions
|
|
141
294
|
</script>
|
|
142
295
|
|
|
143
296
|
<div
|
|
144
297
|
bind:this={layoutEl}
|
|
145
298
|
{...props}
|
|
146
299
|
class={["q-layout", props.class, isReady && "q-layout--ready"]}
|
|
147
|
-
style:--left-drawer-width={`${drawerLeft ?
|
|
148
|
-
style:--right-drawer-width={`${drawerRight ?
|
|
149
|
-
style:--left-railbar-width={`${railbarLeft ?
|
|
150
|
-
style:--right-railbar-width={`${railbarRight ?
|
|
300
|
+
style:--left-drawer-width={`${drawerLeft ? leftDrawerInfo.width : 0}px`}
|
|
301
|
+
style:--right-drawer-width={`${drawerRight ? rightDrawerInfo.width : 0}px`}
|
|
302
|
+
style:--left-railbar-width={`${railbarLeft ? leftRailbarInfo.width : 0}px`}
|
|
303
|
+
style:--right-railbar-width={`${railbarRight ? rightRailbarInfo.width : 0}px`}
|
|
151
304
|
style:--offset-top={`${topOffset}px`}
|
|
152
305
|
style:--offset-right={`${rightOffset}px`}
|
|
153
306
|
style:--offset-bottom={`${bottomOffset}px`}
|
|
@@ -164,12 +317,12 @@
|
|
|
164
317
|
|
|
165
318
|
<ContextReseter
|
|
166
319
|
keys={[
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
320
|
+
headerCtx.symbol,
|
|
321
|
+
footerCtx.symbol,
|
|
322
|
+
leftRailbarCtx.symbol,
|
|
323
|
+
rightRailbarCtx.symbol,
|
|
324
|
+
leftDrawerCtx.symbol,
|
|
325
|
+
rightDrawerCtx.symbol,
|
|
173
326
|
]}
|
|
174
327
|
>
|
|
175
328
|
<div
|
|
@@ -1,14 +1,76 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
|
|
2
|
+
interface AppbarContext {
|
|
3
|
+
readonly view: string;
|
|
3
4
|
height: number;
|
|
4
5
|
collapsed: boolean;
|
|
5
6
|
ready: boolean;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
interface DrawerContext {
|
|
9
|
+
readonly view: string;
|
|
8
10
|
width: number;
|
|
9
11
|
takesSpace: boolean;
|
|
10
12
|
ready: boolean;
|
|
11
13
|
}
|
|
14
|
+
export declare const headerCtx: {
|
|
15
|
+
readonly symbol: symbol;
|
|
16
|
+
get(): AppbarContext | undefined;
|
|
17
|
+
assertGet(errorMsg?: string): AppbarContext;
|
|
18
|
+
set(context: AppbarContext): void;
|
|
19
|
+
reset(): void;
|
|
20
|
+
exists(): boolean;
|
|
21
|
+
updateEntry(key: keyof AppbarContext, value: string | number | boolean): void;
|
|
22
|
+
updateEntries(updates: Partial<AppbarContext>): void;
|
|
23
|
+
};
|
|
24
|
+
export declare const footerCtx: {
|
|
25
|
+
readonly symbol: symbol;
|
|
26
|
+
get(): AppbarContext | undefined;
|
|
27
|
+
assertGet(errorMsg?: string): AppbarContext;
|
|
28
|
+
set(context: AppbarContext): void;
|
|
29
|
+
reset(): void;
|
|
30
|
+
exists(): boolean;
|
|
31
|
+
updateEntry(key: keyof AppbarContext, value: string | number | boolean): void;
|
|
32
|
+
updateEntries(updates: Partial<AppbarContext>): void;
|
|
33
|
+
};
|
|
34
|
+
export declare const leftRailbarCtx: {
|
|
35
|
+
readonly symbol: symbol;
|
|
36
|
+
get(): DrawerContext | undefined;
|
|
37
|
+
assertGet(errorMsg?: string): DrawerContext;
|
|
38
|
+
set(context: DrawerContext): void;
|
|
39
|
+
reset(): void;
|
|
40
|
+
exists(): boolean;
|
|
41
|
+
updateEntry(key: keyof DrawerContext, value: string | number | boolean): void;
|
|
42
|
+
updateEntries(updates: Partial<DrawerContext>): void;
|
|
43
|
+
};
|
|
44
|
+
export declare const rightRailbarCtx: {
|
|
45
|
+
readonly symbol: symbol;
|
|
46
|
+
get(): DrawerContext | undefined;
|
|
47
|
+
assertGet(errorMsg?: string): DrawerContext;
|
|
48
|
+
set(context: DrawerContext): void;
|
|
49
|
+
reset(): void;
|
|
50
|
+
exists(): boolean;
|
|
51
|
+
updateEntry(key: keyof DrawerContext, value: string | number | boolean): void;
|
|
52
|
+
updateEntries(updates: Partial<DrawerContext>): void;
|
|
53
|
+
};
|
|
54
|
+
export declare const leftDrawerCtx: {
|
|
55
|
+
readonly symbol: symbol;
|
|
56
|
+
get(): DrawerContext | undefined;
|
|
57
|
+
assertGet(errorMsg?: string): DrawerContext;
|
|
58
|
+
set(context: DrawerContext): void;
|
|
59
|
+
reset(): void;
|
|
60
|
+
exists(): boolean;
|
|
61
|
+
updateEntry(key: keyof DrawerContext, value: string | number | boolean): void;
|
|
62
|
+
updateEntries(updates: Partial<DrawerContext>): void;
|
|
63
|
+
};
|
|
64
|
+
export declare const rightDrawerCtx: {
|
|
65
|
+
readonly symbol: symbol;
|
|
66
|
+
get(): DrawerContext | undefined;
|
|
67
|
+
assertGet(errorMsg?: string): DrawerContext;
|
|
68
|
+
set(context: DrawerContext): void;
|
|
69
|
+
reset(): void;
|
|
70
|
+
exists(): boolean;
|
|
71
|
+
updateEntry(key: keyof DrawerContext, value: string | number | boolean): void;
|
|
72
|
+
updateEntries(updates: Partial<DrawerContext>): void;
|
|
73
|
+
};
|
|
12
74
|
declare const __propDef: {
|
|
13
75
|
props: Record<string, never>;
|
|
14
76
|
events: {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { QContext } from "../../utils";
|
|
3
|
+
|
|
4
|
+
interface QItemContext {
|
|
5
|
+
readonly activeClass: string | false;
|
|
6
|
+
multiline: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const itemCtx = QContext<QItemContext>("QItem");
|
|
10
|
+
</script>
|
|
11
|
+
|
|
1
12
|
<script lang="ts">
|
|
2
|
-
import { getContext, setContext } from "svelte";
|
|
3
13
|
import { ripple } from "../../helpers";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
getRouterInfo,
|
|
7
|
-
isRouteActive,
|
|
8
|
-
QItemCtxName,
|
|
9
|
-
QListCtxName,
|
|
10
|
-
} from "../../utils";
|
|
14
|
+
import { getRouterInfo, isRouteActive } from "../../utils";
|
|
11
15
|
import QSeparator from "../separator/QSeparator.svelte";
|
|
12
|
-
import
|
|
16
|
+
import { listCtx } from "./QList.svelte";
|
|
17
|
+
import type { QItemProps } from "./props";
|
|
13
18
|
|
|
19
|
+
// #region: --- Props
|
|
14
20
|
let {
|
|
15
21
|
tag = "div",
|
|
16
22
|
active = false,
|
|
@@ -26,7 +32,15 @@
|
|
|
26
32
|
children,
|
|
27
33
|
...props
|
|
28
34
|
}: QItemProps = $props();
|
|
35
|
+
// #endregion: --- Props
|
|
36
|
+
|
|
37
|
+
// #region: --- Reactive variables
|
|
38
|
+
let multiline = $state(false);
|
|
39
|
+
|
|
40
|
+
const ctx = listCtx.assertGet("QItem should be used inside QList");
|
|
41
|
+
// #endregion: --- Reactive variables
|
|
29
42
|
|
|
43
|
+
// #region: --- Derived values
|
|
30
44
|
const routerInfo = $derived(
|
|
31
45
|
getRouterInfo({
|
|
32
46
|
href,
|
|
@@ -37,30 +51,35 @@
|
|
|
37
51
|
}),
|
|
38
52
|
);
|
|
39
53
|
|
|
40
|
-
const listActiveClass = getContext<() => string>(QListCtxName.activeClass);
|
|
41
|
-
|
|
42
54
|
const activeClassToUse = $derived(
|
|
43
|
-
activeClass === "active" ?
|
|
55
|
+
activeClass === "active" ? ctx.activeClass || activeClass : activeClass,
|
|
44
56
|
);
|
|
45
57
|
|
|
46
|
-
setContext(QItemCtxName.activeClass, () => active && activeClassToUse);
|
|
47
|
-
|
|
48
|
-
const multiline = new QContext(QItemCtxName.multiline, false);
|
|
49
|
-
|
|
50
|
-
const separatorOptions = getContext<
|
|
51
|
-
QListProps["separatorOptions"] | undefined
|
|
52
|
-
>(QListCtxName.separator);
|
|
53
|
-
|
|
54
58
|
const isActionable = $derived(
|
|
55
59
|
clickable || routerInfo.hasLink || tag === "label",
|
|
56
60
|
);
|
|
57
61
|
const isClickable = $derived(isActionable && !disabled);
|
|
58
62
|
|
|
59
63
|
const isActive = $derived(isRouteActive(to || href) || active);
|
|
64
|
+
// #endregion: --- Derived values
|
|
65
|
+
|
|
66
|
+
// #region: --- Context
|
|
67
|
+
itemCtx.set({
|
|
68
|
+
get multiline() {
|
|
69
|
+
return multiline;
|
|
70
|
+
},
|
|
71
|
+
set multiline(newValue) {
|
|
72
|
+
multiline = newValue;
|
|
73
|
+
},
|
|
74
|
+
get activeClass() {
|
|
75
|
+
return active && activeClassToUse;
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
// #endregion: --- Context
|
|
60
79
|
</script>
|
|
61
80
|
|
|
62
|
-
{#if separatorOptions}
|
|
63
|
-
<QSeparator {...separatorOptions} />
|
|
81
|
+
{#if ctx.separatorOptions}
|
|
82
|
+
<QSeparator {...ctx.separatorOptions} />
|
|
64
83
|
{/if}
|
|
65
84
|
|
|
66
85
|
{#if routerInfo.linkAttributes.href}
|
|
@@ -73,7 +92,7 @@
|
|
|
73
92
|
routerInfo.linkClasses,
|
|
74
93
|
isActive && activeClassToUse,
|
|
75
94
|
props.class,
|
|
76
|
-
multiline
|
|
95
|
+
multiline && "q-item--multiline",
|
|
77
96
|
dense && "q-item--dense",
|
|
78
97
|
isActive && "q-item--active",
|
|
79
98
|
clickable && "q-item--clickable",
|
|
@@ -95,7 +114,7 @@
|
|
|
95
114
|
routerInfo.linkClasses,
|
|
96
115
|
isActive && activeClassToUse,
|
|
97
116
|
props.class,
|
|
98
|
-
multiline
|
|
117
|
+
multiline && "q-item--multiline",
|
|
99
118
|
dense && "q-item--dense",
|
|
100
119
|
isActive && "q-item--active",
|
|
101
120
|
clickable && "q-item--clickable",
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
interface QItemContext {
|
|
3
|
+
readonly activeClass: string | false;
|
|
4
|
+
multiline: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const itemCtx: {
|
|
7
|
+
readonly symbol: symbol;
|
|
8
|
+
get(): QItemContext | undefined;
|
|
9
|
+
assertGet(errorMsg?: string): QItemContext;
|
|
10
|
+
set(context: QItemContext): void;
|
|
11
|
+
reset(): void;
|
|
12
|
+
exists(): boolean;
|
|
13
|
+
updateEntry(key: keyof QItemContext, value: string | boolean): void;
|
|
14
|
+
updateEntries(updates: Partial<QItemContext>): void;
|
|
15
|
+
};
|
|
2
16
|
declare const __propDef: {
|
|
3
17
|
props: Record<string, never>;
|
|
4
18
|
events: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { QItemCtxName } from "../../utils";
|
|
2
|
+
import { itemCtx } from "./QItem.svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
5
4
|
import type { QItemSectionProps } from "./props";
|
|
6
5
|
|
|
6
|
+
// #region: --- Props
|
|
7
7
|
let {
|
|
8
8
|
type = "content",
|
|
9
9
|
children,
|
|
@@ -13,22 +13,26 @@
|
|
|
13
13
|
line3,
|
|
14
14
|
...props
|
|
15
15
|
}: QItemSectionProps = $props();
|
|
16
|
+
// #endregion: --- Props
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// #region: --- Reactive variables
|
|
19
|
+
const ctx = itemCtx.assertGet();
|
|
20
|
+
// #endregion: --- Reactive variables
|
|
20
21
|
|
|
22
|
+
// #region: --- Effects
|
|
21
23
|
$effect(() => {
|
|
22
24
|
if (type === "content") {
|
|
23
|
-
multiline
|
|
24
|
-
!!headline && [line1, line2, line3].filter(Boolean).length >= 2
|
|
25
|
-
);
|
|
25
|
+
ctx.multiline =
|
|
26
|
+
!!headline && [line1, line2, line3].filter(Boolean).length >= 2;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
29
|
+
// #endregion: --- Effects
|
|
28
30
|
|
|
31
|
+
// #region: --- Functions
|
|
29
32
|
function getClass(snip: Snippet) {
|
|
30
33
|
return snip === headline ? "q-item__section--headline" : undefined;
|
|
31
34
|
}
|
|
35
|
+
// #endregion: --- Functions
|
|
32
36
|
</script>
|
|
33
37
|
|
|
34
38
|
<div
|
|
@@ -54,11 +58,11 @@
|
|
|
54
58
|
{@render line(line3)}
|
|
55
59
|
{/if}
|
|
56
60
|
{:else if type === "trailingText"}
|
|
57
|
-
<div class={["label-small", activeClass
|
|
61
|
+
<div class={["label-small", ctx.activeClass]}>
|
|
58
62
|
{@render children?.()}
|
|
59
63
|
</div>
|
|
60
64
|
{:else}
|
|
61
|
-
<div class={activeClass
|
|
65
|
+
<div class={ctx.activeClass || undefined}>
|
|
62
66
|
{@render children?.()}
|
|
63
67
|
</div>
|
|
64
68
|
{/if}
|
|
@@ -66,7 +70,7 @@
|
|
|
66
70
|
|
|
67
71
|
{#snippet line(snip: Snippet | undefined)}
|
|
68
72
|
{#if snip}
|
|
69
|
-
<div class={[getClass(snip), activeClass
|
|
73
|
+
<div class={[getClass(snip), ctx.activeClass]}>
|
|
70
74
|
{@render snip()}
|
|
71
75
|
</div>
|
|
72
76
|
{/if}
|