@streamscloud/kit 0.94.3 → 0.94.5
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/ui/navigation/cmp.nav-menu-item.svelte +117 -43
- package/dist/ui/navigation/cmp.nav-menu-item.svelte.d.ts +5 -1
- package/dist/ui/navigation/index.d.ts +1 -1
- package/dist/ui/navigation/nav-menu-item-localization.d.ts +3 -0
- package/dist/ui/navigation/nav-menu-item-localization.js +12 -0
- package/dist/ui/navigation/types.d.ts +6 -0
- package/dist/ui/tree/cmp.tree.svelte +2 -2
- package/dist/ui/tree/cmp.tree.svelte.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
<script lang="ts">import { IconSlot } from '../icon';
|
|
2
|
-
|
|
1
|
+
<script lang="ts">import { Icon, IconSlot } from '../icon';
|
|
2
|
+
import { IconText } from '../icon-text';
|
|
3
|
+
import { Popover, PopoverItem } from '../popover';
|
|
4
|
+
import { NavMenuItemLocalization } from './nav-menu-item-localization';
|
|
5
|
+
import IconMoreVertical from '@fluentui/svg-icons/icons/more_vertical_20_regular.svg?raw';
|
|
6
|
+
const { label, icon, href, active = false, activeStyle = 'plain', disabled = false, badge, target, rel, actions = [], on } = $props();
|
|
7
|
+
const localization = new NavMenuItemLocalization();
|
|
8
|
+
let actionsOpened = $state(false);
|
|
3
9
|
const activeFilled = $derived(active && activeStyle === 'filled');
|
|
4
10
|
const activePlain = $derived(active && activeStyle === 'plain');
|
|
5
11
|
const badgeText = $derived(typeof badge === 'number' && badge > 99 ? '99+' : badge);
|
|
6
12
|
const hasBadge = $derived(badge !== undefined && badge !== null && badge !== '');
|
|
13
|
+
const actionsShown = $derived(!disabled && actions.length > 0);
|
|
7
14
|
const handleClick = (event) => {
|
|
8
15
|
if (disabled) {
|
|
9
16
|
return;
|
|
10
17
|
}
|
|
11
18
|
on?.click?.(event);
|
|
12
19
|
};
|
|
20
|
+
const handleActionsOpened = () => {
|
|
21
|
+
actionsOpened = true;
|
|
22
|
+
};
|
|
23
|
+
const handleActionsClosed = () => {
|
|
24
|
+
actionsOpened = false;
|
|
25
|
+
};
|
|
13
26
|
</script>
|
|
14
27
|
|
|
15
28
|
{#snippet content()}
|
|
@@ -22,33 +35,42 @@ const handleClick = (event) => {
|
|
|
22
35
|
<span class="nav-menu-item__label">{label}</span>
|
|
23
36
|
{/snippet}
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
aria-current={active ? 'page' : undefined}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
<div
|
|
39
|
+
class="nav-menu-item"
|
|
40
|
+
class:nav-menu-item--active={active}
|
|
41
|
+
class:nav-menu-item--active-filled={activeFilled}
|
|
42
|
+
class:nav-menu-item--active-plain={activePlain}
|
|
43
|
+
class:nav-menu-item--disabled={disabled}
|
|
44
|
+
class:nav-menu-item--with-actions={actionsShown}
|
|
45
|
+
class:nav-menu-item--actions-opened={actionsOpened}>
|
|
46
|
+
{#if href && !disabled}
|
|
47
|
+
<a class="nav-menu-item__control" href={href} target={target} rel={rel} aria-current={active ? 'page' : undefined} onclick={handleClick}>
|
|
48
|
+
{@render content()}
|
|
49
|
+
</a>
|
|
50
|
+
{:else}
|
|
51
|
+
<button type="button" class="nav-menu-item__control" disabled={disabled} aria-current={active ? 'page' : undefined} onclick={handleClick}>
|
|
52
|
+
{@render content()}
|
|
53
|
+
</button>
|
|
54
|
+
{/if}
|
|
55
|
+
|
|
56
|
+
{#if actionsShown}
|
|
57
|
+
<div class="nav-menu-item__actions">
|
|
58
|
+
<Popover position="bottom-end" aria-label={localization.actionsFor(label)} on={{ opened: handleActionsOpened, closed: handleActionsClosed }}>
|
|
59
|
+
{#snippet trigger()}
|
|
60
|
+
<span class="nav-menu-item__actions-trigger">
|
|
61
|
+
<Icon src={IconMoreVertical} />
|
|
62
|
+
</span>
|
|
63
|
+
{/snippet}
|
|
64
|
+
|
|
65
|
+
{#each actions as action (action)}
|
|
66
|
+
<PopoverItem on={{ click: action.action }}>
|
|
67
|
+
<IconText icon={action.icon} size="sm">{action.name}</IconText>
|
|
68
|
+
</PopoverItem>
|
|
69
|
+
{/each}
|
|
70
|
+
</Popover>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
52
74
|
|
|
53
75
|
<!--
|
|
54
76
|
@component
|
|
@@ -59,6 +81,7 @@ with the `MouseEvent` and the link default is left intact. Active state is consu
|
|
|
59
81
|
(`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
|
|
60
82
|
active row reads: `'plain'` (default) drops the plate, so color plus a heavier label weight carry the
|
|
61
83
|
signal and hover keeps working on the active row; `'filled'` plates it and suppresses hover there.
|
|
84
|
+
`actions` add a "⋮" menu at the end of the row, a sibling of the link, so the link stays a plain link.
|
|
62
85
|
|
|
63
86
|
### CSS Custom Properties
|
|
64
87
|
| Property | Description | Default |
|
|
@@ -87,25 +110,18 @@ signal and hover keeps working on the active row; `'filled'` plates it and suppr
|
|
|
87
110
|
--_nav-menu-item--background-active: var(--sc-kit--nav-menu-item--background--active, var(--sc-kit--color--bg--menu-active));
|
|
88
111
|
--_nav-menu-item--badge-background: var(--sc-kit--nav-menu-item--badge--background, var(--sc-kit--color--accent));
|
|
89
112
|
--_nav-menu-item--badge-color: var(--sc-kit--nav-menu-item--badge--color, var(--sc-kit--color--text--on-accent));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
--_nav-menu-item--actions-size: 1.5rem;
|
|
114
|
+
--_nav-menu-item--actions-inset: var(--sc-kit--space--2);
|
|
115
|
+
position: relative;
|
|
93
116
|
width: 100%;
|
|
94
|
-
padding: 0.375rem var(--sc-kit--space--5);
|
|
95
|
-
background: none;
|
|
96
|
-
border: none;
|
|
97
117
|
border-radius: var(--_nav-menu-item--radius);
|
|
98
|
-
cursor: pointer;
|
|
99
|
-
text-decoration: none;
|
|
100
118
|
color: var(--_nav-menu-item--color);
|
|
101
|
-
font-family: inherit;
|
|
102
|
-
text-align: left;
|
|
103
119
|
transition: color var(--sc-kit--duration--base) var(--sc-kit--ease--default), background-color var(--sc-kit--duration--base) var(--sc-kit--ease--default);
|
|
104
120
|
}
|
|
105
|
-
.nav-menu-item:hover:not(.nav-menu-item--active-filled
|
|
121
|
+
.nav-menu-item:hover:not(.nav-menu-item--active-filled, .nav-menu-item--disabled) {
|
|
106
122
|
background: var(--_nav-menu-item--background-hover);
|
|
107
123
|
}
|
|
108
|
-
.nav-menu-item:hover:not(.nav-menu-item--disabled)
|
|
124
|
+
.nav-menu-item:hover:not(.nav-menu-item--disabled), .nav-menu-item--active {
|
|
109
125
|
color: var(--_nav-menu-item--color-active);
|
|
110
126
|
}
|
|
111
127
|
.nav-menu-item--active-filled {
|
|
@@ -114,14 +130,48 @@ signal and hover keeps working on the active row; `'filled'` plates it and suppr
|
|
|
114
130
|
.nav-menu-item--active-plain {
|
|
115
131
|
font-weight: var(--_nav-menu-item--font-weight-active);
|
|
116
132
|
}
|
|
117
|
-
.nav-menu-item--disabled
|
|
133
|
+
.nav-menu-item--disabled {
|
|
118
134
|
color: var(--_nav-menu-item--color-disabled);
|
|
135
|
+
}
|
|
136
|
+
@media (any-hover: hover) {
|
|
137
|
+
.nav-menu-item--with-actions:not(:hover, :has(:global(:focus-visible)), .nav-menu-item--actions-opened) .nav-menu-item__actions {
|
|
138
|
+
position: absolute;
|
|
139
|
+
width: 1px;
|
|
140
|
+
height: 1px;
|
|
141
|
+
margin: -1px;
|
|
142
|
+
padding: 0;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
clip-path: inset(50%);
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
border: 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.nav-menu-item__control {
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
gap: var(--_nav-menu-item--gap);
|
|
154
|
+
width: 100%;
|
|
155
|
+
padding: 0.375rem var(--sc-kit--space--5);
|
|
156
|
+
background: none;
|
|
157
|
+
border: none;
|
|
158
|
+
border-radius: inherit;
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
text-decoration: none;
|
|
161
|
+
color: inherit;
|
|
162
|
+
font: inherit;
|
|
163
|
+
text-align: left;
|
|
164
|
+
}
|
|
165
|
+
.nav-menu-item__control:disabled {
|
|
119
166
|
cursor: default;
|
|
120
167
|
}
|
|
121
|
-
.nav-menu-
|
|
168
|
+
.nav-menu-item__control:focus-visible {
|
|
122
169
|
outline: 2px solid var(--sc-kit--color--border--focus);
|
|
123
170
|
outline-offset: -2px;
|
|
124
171
|
}
|
|
172
|
+
.nav-menu-item--with-actions > .nav-menu-item__control {
|
|
173
|
+
padding-right: calc(var(--_nav-menu-item--actions-size) + var(--_nav-menu-item--actions-inset) * 2);
|
|
174
|
+
}
|
|
125
175
|
|
|
126
176
|
.nav-menu-item__icon {
|
|
127
177
|
--sc-kit--icon--size: var(--_nav-menu-item--icon-size);
|
|
@@ -162,4 +212,28 @@ signal and hover keeps working on the active row; `'filled'` plates it and suppr
|
|
|
162
212
|
max-width: 100%;
|
|
163
213
|
white-space: nowrap;
|
|
164
214
|
overflow: hidden;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.nav-menu-item__actions {
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: 50%;
|
|
220
|
+
right: var(--_nav-menu-item--actions-inset);
|
|
221
|
+
display: flex;
|
|
222
|
+
translate: 0 -50%;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.nav-menu-item__actions-trigger {
|
|
226
|
+
--sc-kit--icon--size: 1rem;
|
|
227
|
+
display: inline-flex;
|
|
228
|
+
align-items: center;
|
|
229
|
+
justify-content: center;
|
|
230
|
+
width: var(--_nav-menu-item--actions-size);
|
|
231
|
+
height: var(--_nav-menu-item--actions-size);
|
|
232
|
+
border-radius: var(--sc-kit--radius--sm);
|
|
233
|
+
color: var(--sc-kit--color--text--secondary);
|
|
234
|
+
transition: color var(--sc-kit--duration--base) var(--sc-kit--ease--default), background-color var(--sc-kit--duration--base) var(--sc-kit--ease--default);
|
|
235
|
+
}
|
|
236
|
+
.nav-menu-item__actions-trigger:hover {
|
|
237
|
+
background: var(--sc-kit--color--bg--active);
|
|
238
|
+
color: var(--sc-kit--color--text--primary);
|
|
165
239
|
}</style>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type IconProp } from '../icon';
|
|
2
|
+
import type { NavMenuItemAction } from './types';
|
|
2
3
|
type Props = {
|
|
3
4
|
label: string;
|
|
4
5
|
/** Icon — string SVG source, `{ src, color?, size? }` object, or custom snippet. */
|
|
5
6
|
icon: IconProp;
|
|
6
7
|
/** Render as `<a href>` — unless `disabled`, which falls back to the button form. `on.click` still fires; `event.preventDefault()` keeps the click from navigating. */
|
|
7
8
|
href?: string;
|
|
8
|
-
/** Highlight as the current item. Consumer-controlled.
|
|
9
|
+
/** Highlight as the current item. Consumer-controlled. */
|
|
9
10
|
active?: boolean;
|
|
10
11
|
/** Active row visuals — `'plain'` uses color plus a heavier label weight and keeps hover, `'filled'` paints the active background (no hover on it). @default 'plain' */
|
|
11
12
|
activeStyle?: 'filled' | 'plain';
|
|
@@ -16,6 +17,8 @@ type Props = {
|
|
|
16
17
|
target?: string;
|
|
17
18
|
/** Anchor rel — only relevant when `href` is set. */
|
|
18
19
|
rel?: string;
|
|
20
|
+
/** Row menu behind a "⋮" button at the end of the row, revealed on hover, keyboard focus, while open and on touch screens. Hidden while `disabled`. */
|
|
21
|
+
actions?: NavMenuItemAction[];
|
|
19
22
|
on?: {
|
|
20
23
|
click?: (event: MouseEvent) => void;
|
|
21
24
|
};
|
|
@@ -28,6 +31,7 @@ type Props = {
|
|
|
28
31
|
* (`active` prop) — wire it to your router's pathname matching upstream. `activeStyle` picks how the
|
|
29
32
|
* active row reads: `'plain'` (default) drops the plate, so color plus a heavier label weight carry the
|
|
30
33
|
* signal and hover keeps working on the active row; `'filled'` plates it and suppresses hover there.
|
|
34
|
+
* `actions` add a "⋮" menu at the end of the row, a sibling of the link, so the link stays a plain link.
|
|
31
35
|
*
|
|
32
36
|
* ### CSS Custom Properties
|
|
33
37
|
* | Property | Description | Default |
|
|
@@ -5,4 +5,4 @@ export { default as NavMenuGroup } from './cmp.nav-menu-group.svelte';
|
|
|
5
5
|
export { default as NavMenuHeader } from './cmp.nav-menu-header.svelte';
|
|
6
6
|
export { default as NavMenuItem } from './cmp.nav-menu-item.svelte';
|
|
7
7
|
export { default as NavRail } from './cmp.nav-rail.svelte';
|
|
8
|
-
export type { NavRailFooterToggle, NavRailItemData } from './types';
|
|
8
|
+
export type { NavMenuItemAction, NavRailFooterToggle, NavRailItemData } from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppLocale } from '../../core/locale';
|
|
2
|
+
const loc = {
|
|
3
|
+
actionsFor: {
|
|
4
|
+
en: (label) => `Actions for ${label}`,
|
|
5
|
+
no: (label) => `Handlinger for ${label}`
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export class NavMenuItemLocalization {
|
|
9
|
+
actionsFor = (label) => {
|
|
10
|
+
return loc.actionsFor[AppLocale.current](label);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -20,6 +20,12 @@ export type NavRailItemData = {
|
|
|
20
20
|
click?: (event: MouseEvent) => void;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
+
/** One entry of a `NavMenuItem` "⋮" menu. */
|
|
24
|
+
export type NavMenuItemAction = {
|
|
25
|
+
name: string;
|
|
26
|
+
icon?: IconProp;
|
|
27
|
+
action: () => void;
|
|
28
|
+
};
|
|
23
29
|
export type NavRailFooterToggle = {
|
|
24
30
|
/** Icon — string SVG source, `{ src, color?, size? }` object, or custom snippet. */
|
|
25
31
|
icon: IconProp;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">import NodeView from './cmp.tree-node-view.svelte';
|
|
2
2
|
import { createTreeKeyboard } from './tree-keyboard.svelte';
|
|
3
|
-
let { nodes, checked, header } = $props();
|
|
3
|
+
let { nodes, checked, header, keepExpandSlot = false } = $props();
|
|
4
4
|
const nodesComputed = $derived(nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []);
|
|
5
|
-
const hideExpandIcon = $derived(nodesComputed.every((f) => !f.children.length));
|
|
5
|
+
const hideExpandIcon = $derived(!keepExpandSlot && nodesComputed.every((f) => !f.children.length));
|
|
6
6
|
const checkedSet = $derived(checked ? new Set(checked) : null);
|
|
7
7
|
$effect(() => {
|
|
8
8
|
for (const root of nodesComputed) {
|
|
@@ -7,6 +7,8 @@ type Props = {
|
|
|
7
7
|
checked?: readonly string[];
|
|
8
8
|
/** Optional content rendered above the nodes (e.g. a header). */
|
|
9
9
|
header?: Snippet;
|
|
10
|
+
/** Keeps the expand-chevron column even when no node has children, so several Trees stacked together line up. */
|
|
11
|
+
keepExpandSlot?: boolean;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* Tree — hierarchical, collapsible node list driven by `TreeNode` model instances. Each `TreeNode`
|