@casinogate/ui 1.8.8 → 1.9.0
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/assets/css/root.css +75 -39
- package/dist/components/navigation/components/navigation.content.svelte +3 -4
- package/dist/components/navigation/components/navigation.item.svelte +19 -17
- package/dist/components/navigation/components/navigation.root.svelte +10 -12
- package/dist/components/navigation/components/navigation.sub-content.svelte +27 -28
- package/dist/components/navigation/components/navigation.sub-trigger.svelte +107 -0
- package/dist/components/navigation/components/navigation.sub-trigger.svelte.d.ts +4 -0
- package/dist/components/navigation/components/navigation.sub.svelte +55 -0
- package/dist/components/navigation/components/navigation.sub.svelte.d.ts +4 -0
- package/dist/components/navigation/components/navigation.svelte.d.ts +45 -15
- package/dist/components/navigation/components/navigation.svelte.js +68 -28
- package/dist/components/navigation/components/navigation.trigger.svelte +36 -80
- package/dist/components/navigation/exports-primitive.d.ts +2 -0
- package/dist/components/navigation/exports-primitive.js +2 -0
- package/dist/components/navigation/exports.d.ts +1 -1
- package/dist/components/navigation/exports.js +1 -1
- package/dist/components/navigation/index.d.ts +2 -1
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/navigation.svelte +114 -29
- package/dist/components/navigation/navigation.svelte.d.ts +3 -0
- package/dist/components/navigation/styles.d.ts +19 -28
- package/dist/components/navigation/styles.js +45 -28
- package/dist/components/navigation/types.d.ts +59 -20
- package/dist/components/popover/popover.svelte +12 -3
- package/dist/components/popover/styles.js +1 -1
- package/dist/components/popover/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { RefAttachment } from '../../../internal/types/common.js';
|
|
2
2
|
import { Context } from 'runed';
|
|
3
|
-
import { type ReadableBoxedValues, type WithRefProps } from 'svelte-toolbelt';
|
|
3
|
+
import { type ReadableBoxedValues, type WithRefProps, type WritableBoxedValues } from 'svelte-toolbelt';
|
|
4
4
|
import type { NavigationRootProps } from '../types.js';
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const NavigationSubStateCtx: Context<NavigationSubState>;
|
|
6
6
|
type NavigationRootStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
7
7
|
compact: boolean;
|
|
8
|
-
|
|
8
|
+
dropdownProps: NavigationRootProps['dropdownProps'];
|
|
9
9
|
}>>;
|
|
10
10
|
export declare class NavigationRootState {
|
|
11
11
|
static create(opts: NavigationRootStateOpts): NavigationRootState;
|
|
@@ -35,14 +35,11 @@ export declare class NavigationContentState {
|
|
|
35
35
|
}
|
|
36
36
|
type NavigationItemStateOpts = WithRefProps<{}>;
|
|
37
37
|
export declare class NavigationItemState {
|
|
38
|
-
#private;
|
|
39
38
|
static create(opts: NavigationItemStateOpts): NavigationItemState;
|
|
40
39
|
readonly opts: NavigationItemStateOpts;
|
|
41
40
|
readonly attachment: RefAttachment;
|
|
42
41
|
readonly root: NavigationRootState;
|
|
43
42
|
constructor(opts: NavigationItemStateOpts, root: NavigationRootState);
|
|
44
|
-
get hasSubContent(): boolean;
|
|
45
|
-
set hasSubContent(value: boolean);
|
|
46
43
|
readonly props: {
|
|
47
44
|
readonly id: string;
|
|
48
45
|
readonly "data-slot": "item";
|
|
@@ -54,20 +51,53 @@ type NavigationTriggerStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
|
54
51
|
disabled: boolean;
|
|
55
52
|
}>>;
|
|
56
53
|
export declare class NavigationTriggerState {
|
|
57
|
-
static create(opts: NavigationTriggerStateOpts
|
|
54
|
+
static create(opts: NavigationTriggerStateOpts): NavigationTriggerState;
|
|
58
55
|
readonly opts: NavigationTriggerStateOpts;
|
|
59
56
|
readonly attachment: RefAttachment;
|
|
60
57
|
readonly root: NavigationRootState;
|
|
61
|
-
|
|
62
|
-
readonly subContent: NavigationSubContentState | null;
|
|
63
|
-
constructor(opts: NavigationTriggerStateOpts, root: NavigationRootState, item: NavigationItemState, subContent: NavigationSubContentState | null);
|
|
58
|
+
constructor(opts: NavigationTriggerStateOpts, root: NavigationRootState);
|
|
64
59
|
readonly props: {
|
|
65
60
|
readonly id: string;
|
|
66
61
|
readonly "data-slot": "trigger";
|
|
67
|
-
readonly role: "button";
|
|
68
|
-
readonly tabindex: 0;
|
|
69
62
|
readonly 'data-disabled': "" | undefined;
|
|
70
|
-
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
type NavigationSubStateOpts = WithRefProps<WritableBoxedValues<{
|
|
66
|
+
open: boolean;
|
|
67
|
+
}>>;
|
|
68
|
+
export declare class NavigationSubState {
|
|
69
|
+
static create(opts: NavigationSubStateOpts): NavigationSubState;
|
|
70
|
+
readonly opts: NavigationSubStateOpts;
|
|
71
|
+
readonly attachment: RefAttachment;
|
|
72
|
+
readonly root: NavigationRootState;
|
|
73
|
+
readonly isOpen: boolean;
|
|
74
|
+
constructor(opts: NavigationSubStateOpts, root: NavigationRootState);
|
|
75
|
+
setOpen(value: boolean): void;
|
|
76
|
+
toggle(): void;
|
|
77
|
+
readonly props: {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly "data-slot": "sub";
|
|
80
|
+
readonly 'data-compact': boolean;
|
|
81
|
+
readonly 'data-state': "open" | "closed";
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
type NavigationSubTriggerStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
85
|
+
disabled: boolean;
|
|
86
|
+
}>>;
|
|
87
|
+
export declare class NavigationSubTriggerState {
|
|
88
|
+
static create(opts: NavigationSubTriggerStateOpts): NavigationSubTriggerState;
|
|
89
|
+
readonly opts: NavigationSubTriggerStateOpts;
|
|
90
|
+
readonly attachment: RefAttachment;
|
|
91
|
+
readonly root: NavigationRootState;
|
|
92
|
+
readonly sub: NavigationSubState;
|
|
93
|
+
constructor(opts: NavigationSubTriggerStateOpts, root: NavigationRootState, sub: NavigationSubState);
|
|
94
|
+
readonly props: {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly "data-slot": "sub-trigger";
|
|
97
|
+
readonly 'data-disabled': "" | undefined;
|
|
98
|
+
readonly 'data-state': "open" | "closed";
|
|
99
|
+
readonly 'aria-expanded': boolean;
|
|
100
|
+
readonly 'aria-haspopup': "menu";
|
|
71
101
|
};
|
|
72
102
|
}
|
|
73
103
|
type NavigationSubContentStateOpts = WithRefProps<{}>;
|
|
@@ -76,8 +106,8 @@ export declare class NavigationSubContentState {
|
|
|
76
106
|
readonly opts: NavigationSubContentStateOpts;
|
|
77
107
|
readonly attachment: RefAttachment;
|
|
78
108
|
readonly root: NavigationRootState;
|
|
79
|
-
readonly
|
|
80
|
-
constructor(opts: NavigationSubContentStateOpts, root: NavigationRootState,
|
|
109
|
+
readonly sub: NavigationSubState;
|
|
110
|
+
constructor(opts: NavigationSubContentStateOpts, root: NavigationRootState, sub: NavigationSubState);
|
|
81
111
|
readonly props: {
|
|
82
112
|
readonly id: string;
|
|
83
113
|
readonly "data-slot": "sub-content";
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { SLOT_ATTR_NAME } from '../../../internal/constants/attrs.js';
|
|
2
2
|
import { boolAttr } from '../../../internal/utils/attrs.js';
|
|
3
3
|
import { keyWithPrefix } from '../../../internal/utils/common.js';
|
|
4
|
-
import { Context } from 'runed';
|
|
4
|
+
import { Context, watch } from 'runed';
|
|
5
5
|
import { attachRef } from 'svelte-toolbelt';
|
|
6
6
|
const NavigationRootStateCtx = new Context(keyWithPrefix('navigation-root'));
|
|
7
7
|
const NavigationItemStateCtx = new Context(keyWithPrefix('navigation-item'));
|
|
8
|
-
export const
|
|
8
|
+
export const NavigationSubStateCtx = new Context(keyWithPrefix('navigation-sub'));
|
|
9
9
|
const SLOT_ATTR_VALUES = {
|
|
10
10
|
root: 'root',
|
|
11
11
|
content: 'content',
|
|
12
|
-
subContent: 'sub-content',
|
|
13
12
|
item: 'item',
|
|
14
13
|
trigger: 'trigger',
|
|
14
|
+
sub: 'sub',
|
|
15
|
+
subTrigger: 'sub-trigger',
|
|
16
|
+
subContent: 'sub-content',
|
|
15
17
|
};
|
|
16
18
|
export class NavigationRootState {
|
|
17
19
|
static create(opts) {
|
|
@@ -58,18 +60,11 @@ export class NavigationItemState {
|
|
|
58
60
|
opts;
|
|
59
61
|
attachment;
|
|
60
62
|
root;
|
|
61
|
-
#hasSubContent = $state(false);
|
|
62
63
|
constructor(opts, root) {
|
|
63
64
|
this.opts = opts;
|
|
64
65
|
this.root = root;
|
|
65
66
|
this.attachment = attachRef(opts.ref);
|
|
66
67
|
}
|
|
67
|
-
get hasSubContent() {
|
|
68
|
-
return this.#hasSubContent;
|
|
69
|
-
}
|
|
70
|
-
set hasSubContent(value) {
|
|
71
|
-
this.#hasSubContent = value;
|
|
72
|
-
}
|
|
73
68
|
props = $derived.by(() => ({
|
|
74
69
|
id: this.opts.id.current,
|
|
75
70
|
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.item,
|
|
@@ -79,49 +74,94 @@ export class NavigationItemState {
|
|
|
79
74
|
}));
|
|
80
75
|
}
|
|
81
76
|
export class NavigationTriggerState {
|
|
82
|
-
static create(opts
|
|
83
|
-
return new NavigationTriggerState(opts, NavigationRootStateCtx.get()
|
|
77
|
+
static create(opts) {
|
|
78
|
+
return new NavigationTriggerState(opts, NavigationRootStateCtx.get());
|
|
84
79
|
}
|
|
85
80
|
opts;
|
|
86
81
|
attachment;
|
|
87
82
|
root;
|
|
88
|
-
|
|
89
|
-
subContent;
|
|
90
|
-
constructor(opts, root, item, subContent) {
|
|
83
|
+
constructor(opts, root) {
|
|
91
84
|
this.opts = opts;
|
|
92
85
|
this.root = root;
|
|
93
|
-
this.item = item;
|
|
94
|
-
this.subContent = subContent;
|
|
95
86
|
this.attachment = attachRef(opts.ref);
|
|
96
87
|
}
|
|
97
88
|
props = $derived.by(() => ({
|
|
98
89
|
id: this.opts.id.current,
|
|
99
90
|
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.trigger,
|
|
100
|
-
role: 'button',
|
|
101
|
-
tabindex: 0,
|
|
102
91
|
'data-disabled': boolAttr(this.opts.disabled.current),
|
|
103
|
-
'data-sub-content': this.subContent !== null,
|
|
104
92
|
...this.attachment,
|
|
105
93
|
}));
|
|
106
94
|
}
|
|
107
|
-
export class
|
|
95
|
+
export class NavigationSubState {
|
|
108
96
|
static create(opts) {
|
|
109
|
-
return
|
|
97
|
+
return NavigationSubStateCtx.set(new NavigationSubState(opts, NavigationRootStateCtx.get()));
|
|
110
98
|
}
|
|
111
99
|
opts;
|
|
112
100
|
attachment;
|
|
113
101
|
root;
|
|
114
|
-
|
|
115
|
-
constructor(opts, root
|
|
102
|
+
isOpen = $derived.by(() => this.opts.open.current);
|
|
103
|
+
constructor(opts, root) {
|
|
116
104
|
this.opts = opts;
|
|
117
105
|
this.root = root;
|
|
118
|
-
this.item = item;
|
|
119
106
|
this.attachment = attachRef(opts.ref);
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
watch(() => this.root.isCompact, () => {
|
|
108
|
+
if (this.isOpen && this.root.isCompact) {
|
|
109
|
+
this.opts.open.current = false;
|
|
110
|
+
}
|
|
123
111
|
});
|
|
124
112
|
}
|
|
113
|
+
setOpen(value) {
|
|
114
|
+
this.opts.open.current = value;
|
|
115
|
+
}
|
|
116
|
+
toggle() {
|
|
117
|
+
this.opts.open.current = !this.opts.open.current;
|
|
118
|
+
}
|
|
119
|
+
props = $derived.by(() => ({
|
|
120
|
+
id: this.opts.id.current,
|
|
121
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.sub,
|
|
122
|
+
'data-compact': this.root.isCompact,
|
|
123
|
+
'data-state': this.isOpen ? 'open' : 'closed',
|
|
124
|
+
...this.attachment,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
export class NavigationSubTriggerState {
|
|
128
|
+
static create(opts) {
|
|
129
|
+
return new NavigationSubTriggerState(opts, NavigationRootStateCtx.get(), NavigationSubStateCtx.get());
|
|
130
|
+
}
|
|
131
|
+
opts;
|
|
132
|
+
attachment;
|
|
133
|
+
root;
|
|
134
|
+
sub;
|
|
135
|
+
constructor(opts, root, sub) {
|
|
136
|
+
this.opts = opts;
|
|
137
|
+
this.root = root;
|
|
138
|
+
this.sub = sub;
|
|
139
|
+
this.attachment = attachRef(opts.ref);
|
|
140
|
+
}
|
|
141
|
+
props = $derived.by(() => ({
|
|
142
|
+
id: this.opts.id.current,
|
|
143
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.subTrigger,
|
|
144
|
+
'data-disabled': boolAttr(this.opts.disabled.current),
|
|
145
|
+
'data-state': this.sub.isOpen ? 'open' : 'closed',
|
|
146
|
+
'aria-expanded': this.sub.isOpen,
|
|
147
|
+
'aria-haspopup': 'menu',
|
|
148
|
+
...this.attachment,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
export class NavigationSubContentState {
|
|
152
|
+
static create(opts) {
|
|
153
|
+
return new NavigationSubContentState(opts, NavigationRootStateCtx.get(), NavigationSubStateCtx.get());
|
|
154
|
+
}
|
|
155
|
+
opts;
|
|
156
|
+
attachment;
|
|
157
|
+
root;
|
|
158
|
+
sub;
|
|
159
|
+
constructor(opts, root, sub) {
|
|
160
|
+
this.opts = opts;
|
|
161
|
+
this.root = root;
|
|
162
|
+
this.sub = sub;
|
|
163
|
+
this.attachment = attachRef(opts.ref);
|
|
164
|
+
}
|
|
125
165
|
props = $derived.by(() => ({
|
|
126
166
|
id: this.opts.id.current,
|
|
127
167
|
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.subContent,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { CollapsiblePrimitive } from '../../collapsible/index.js';
|
|
3
|
-
import ChevronDown from '../../icons/chevron-down.svelte';
|
|
4
|
-
import { NavigationStylesContext } from '../styles.js';
|
|
5
|
-
import { PopoverPrimitive } from '../../popover/index.js';
|
|
6
2
|
import { cn, useId } from '../../../internal/utils/common.js';
|
|
7
3
|
import { boxWith, mergeProps } from 'svelte-toolbelt';
|
|
4
|
+
import { cubicInOut } from 'svelte/easing';
|
|
5
|
+
import { slide } from 'svelte/transition';
|
|
6
|
+
import { navigationTriggerStyles } from '../styles.js';
|
|
8
7
|
import type { NavigationTriggerProps } from '../types.js';
|
|
9
|
-
import {
|
|
8
|
+
import { NavigationSubStateCtx, NavigationTriggerState } from './navigation.svelte.js';
|
|
10
9
|
|
|
11
10
|
const uid = $props.id();
|
|
12
11
|
|
|
@@ -22,36 +21,34 @@
|
|
|
22
21
|
...restProps
|
|
23
22
|
}: NavigationTriggerProps = $props();
|
|
24
23
|
|
|
25
|
-
const
|
|
24
|
+
const subState = NavigationSubStateCtx.getOr(null);
|
|
25
|
+
const isInsideSub = $derived(subState !== null);
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
id: boxWith(() => id),
|
|
36
|
-
disabled: boxWith(() => disabled),
|
|
37
|
-
},
|
|
38
|
-
subContent
|
|
39
|
-
);
|
|
27
|
+
const triggerState = NavigationTriggerState.create({
|
|
28
|
+
ref: boxWith(
|
|
29
|
+
() => ref,
|
|
30
|
+
(v) => (ref = v)
|
|
31
|
+
),
|
|
32
|
+
id: boxWith(() => id),
|
|
33
|
+
disabled: boxWith(() => disabled),
|
|
34
|
+
});
|
|
40
35
|
|
|
41
36
|
const mergedProps = $derived(
|
|
42
|
-
mergeProps(restProps, triggerState.props, { class: cn(
|
|
37
|
+
mergeProps(restProps, triggerState.props, { class: cn(navigationTriggerStyles(), className) })
|
|
43
38
|
);
|
|
44
39
|
|
|
45
|
-
const
|
|
40
|
+
const attrs = $derived({
|
|
46
41
|
compact: triggerState.root.isCompact,
|
|
47
42
|
});
|
|
43
|
+
|
|
44
|
+
const shouldShowLabel = $derived(!triggerState.root.isCompact || isInsideSub);
|
|
48
45
|
</script>
|
|
49
46
|
|
|
50
47
|
{#snippet content()}
|
|
51
48
|
{#if icon}
|
|
52
49
|
<span
|
|
53
50
|
data-slot="icon"
|
|
54
|
-
class={cn('
|
|
51
|
+
class={cn('cgui:inline-flex cgui:items-center cgui:justify-center cgui:shrink-0 cgui:empty:hidden')}
|
|
55
52
|
>
|
|
56
53
|
{@render icon?.()}
|
|
57
54
|
</span>
|
|
@@ -59,72 +56,31 @@
|
|
|
59
56
|
|
|
60
57
|
{#if label}
|
|
61
58
|
{#if typeof label === 'string'}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
{#if shouldShowLabel}
|
|
60
|
+
<span
|
|
61
|
+
data-slot="label"
|
|
62
|
+
class="cgui:min-w-0 cgui:text-left cgui:whitespace-nowrap cgui:overflow-hidden cgui:flex-1"
|
|
63
|
+
transition:slide={{ axis: 'x', duration: 250, easing: cubicInOut }}
|
|
64
|
+
>
|
|
65
|
+
<span class="cgui:inline-block" transition:slide={{ axis: 'x', duration: 150, easing: cubicInOut }}>
|
|
66
|
+
{label}
|
|
67
|
+
</span>
|
|
68
|
+
</span>
|
|
69
|
+
{/if}
|
|
70
70
|
{:else}
|
|
71
71
|
{@render label?.({ props: { 'data-slot': 'label' } })}
|
|
72
72
|
{/if}
|
|
73
73
|
{/if}
|
|
74
74
|
{/snippet}
|
|
75
75
|
|
|
76
|
-
{#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<button {...childProps} {...mergedProps} data-type="popover-trigger">
|
|
80
|
-
{@render content?.()}
|
|
81
|
-
</button>
|
|
82
|
-
{/snippet}
|
|
83
|
-
</PopoverPrimitive.Trigger>
|
|
84
|
-
{/snippet}
|
|
85
|
-
|
|
86
|
-
{#snippet collapsibleTrigger()}
|
|
87
|
-
<CollapsiblePrimitive.Trigger>
|
|
88
|
-
{#snippet child({ props: childProps, open })}
|
|
89
|
-
<button {...childProps} {...mergedProps} data-type="collapsible-trigger">
|
|
90
|
-
{@render content?.()}
|
|
91
|
-
|
|
92
|
-
<span
|
|
93
|
-
data-slot="icon"
|
|
94
|
-
class={cn(
|
|
95
|
-
'cgui:flex cgui:items-center cgui:justify-center cgui:shrink-0 cgui:transition-transform cgui:duration-250 cgui:ease-in-out',
|
|
96
|
-
{
|
|
97
|
-
'cgui:rotate-180': open,
|
|
98
|
-
}
|
|
99
|
-
)}
|
|
100
|
-
>
|
|
101
|
-
<ChevronDown width={24} height={24} />
|
|
102
|
-
</span>
|
|
103
|
-
</button>
|
|
104
|
-
{/snippet}
|
|
105
|
-
</CollapsiblePrimitive.Trigger>
|
|
106
|
-
{/snippet}
|
|
107
|
-
|
|
108
|
-
{#snippet buttonTrigger()}
|
|
109
|
-
<button {...mergedProps}>
|
|
110
|
-
{@render content?.()}
|
|
111
|
-
</button>
|
|
112
|
-
{/snippet}
|
|
113
|
-
|
|
114
|
-
{#snippet linkTrigger()}
|
|
76
|
+
{#if child}
|
|
77
|
+
{@render child({ props: mergedProps, ...attrs })}
|
|
78
|
+
{:else if href}
|
|
115
79
|
<a {href} {...mergedProps}>
|
|
116
80
|
{@render content?.()}
|
|
117
81
|
</a>
|
|
118
|
-
{/snippet}
|
|
119
|
-
|
|
120
|
-
{#if child}
|
|
121
|
-
{@render child({ props: mergedProps, ...sharedProps })}
|
|
122
|
-
{:else if href}
|
|
123
|
-
{@render linkTrigger?.()}
|
|
124
|
-
{:else if triggerState.item.hasSubContent && triggerState.root.isCompact}
|
|
125
|
-
{@render popoverTrigger?.()}
|
|
126
|
-
{:else if triggerState.item.hasSubContent && !triggerState.root.isCompact}
|
|
127
|
-
{@render collapsibleTrigger?.()}
|
|
128
82
|
{:else}
|
|
129
|
-
{
|
|
83
|
+
<button {...mergedProps}>
|
|
84
|
+
{@render content?.()}
|
|
85
|
+
</button>
|
|
130
86
|
{/if}
|
|
@@ -2,4 +2,6 @@ export { default as Content } from './components/navigation.content.svelte';
|
|
|
2
2
|
export { default as Item } from './components/navigation.item.svelte';
|
|
3
3
|
export { default as Root } from './components/navigation.root.svelte';
|
|
4
4
|
export { default as SubContent } from './components/navigation.sub-content.svelte';
|
|
5
|
+
export { default as SubTrigger } from './components/navigation.sub-trigger.svelte';
|
|
6
|
+
export { default as Sub } from './components/navigation.sub.svelte';
|
|
5
7
|
export { default as Trigger } from './components/navigation.trigger.svelte';
|
|
@@ -2,4 +2,6 @@ export { default as Content } from './components/navigation.content.svelte';
|
|
|
2
2
|
export { default as Item } from './components/navigation.item.svelte';
|
|
3
3
|
export { default as Root } from './components/navigation.root.svelte';
|
|
4
4
|
export { default as SubContent } from './components/navigation.sub-content.svelte';
|
|
5
|
+
export { default as SubTrigger } from './components/navigation.sub-trigger.svelte';
|
|
6
|
+
export { default as Sub } from './components/navigation.sub.svelte';
|
|
5
7
|
export { default as Trigger } from './components/navigation.trigger.svelte';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Root } from './navigation.svelte';
|
|
1
|
+
export { createNavigationCollection, default as Root } from './navigation.svelte';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Root } from './navigation.svelte';
|
|
1
|
+
export { createNavigationCollection, default as Root } from './navigation.svelte';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * as NavigationPrimitive from './exports-primitive.js';
|
|
2
2
|
export * as Navigation from './exports.js';
|
|
3
|
-
export
|
|
3
|
+
export { createNavigationCollection } from './navigation.svelte';
|
|
4
|
+
export type { NavigationCollection, NavigationCollectionOptions, NavigationContentProps, NavigationItem, NavigationItemAction, NavigationItemBase, NavigationItemLink, NavigationItemProps, NavigationItemSeparator, NavigationItemSub, NavigationProps, NavigationRootProps, NavigationSelectableItem, NavigationSubContentProps, NavigationSubProps, NavigationSubTriggerProps, NavigationTriggerProps, } from './types.js';
|
|
@@ -1,36 +1,121 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { createListCollection } from '../../internal/index.js';
|
|
3
|
+
import type { ListCollection } from '../../internal/lib/collection/index.js';
|
|
4
|
+
import type {
|
|
5
|
+
NavigationCollectionOptions,
|
|
6
|
+
NavigationItem,
|
|
7
|
+
NavigationItemAction,
|
|
8
|
+
NavigationItemLink,
|
|
9
|
+
NavigationItemSub,
|
|
10
|
+
NavigationSelectableItem,
|
|
11
|
+
} from './types.js';
|
|
12
|
+
|
|
13
|
+
export function createNavigationCollection(options: NavigationCollectionOptions): ListCollection<NavigationItem> {
|
|
14
|
+
const { items } = options;
|
|
15
|
+
|
|
16
|
+
return createListCollection({
|
|
17
|
+
items,
|
|
18
|
+
itemToValue: (item) => item.key,
|
|
19
|
+
itemToString: (item) => {
|
|
20
|
+
return item.label;
|
|
21
|
+
},
|
|
22
|
+
isItemDisabled: (item) => {
|
|
23
|
+
return !!item.disabled;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isLink(item: NavigationSelectableItem): item is NavigationItemLink {
|
|
29
|
+
return item.type === 'link';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isSub(item: NavigationSelectableItem): item is NavigationItemSub {
|
|
33
|
+
return item.type === 'sub';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isAction(item: NavigationSelectableItem): item is NavigationItemAction {
|
|
37
|
+
return item.type === 'action';
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
1
41
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import Item from './components/navigation.item.svelte';
|
|
4
|
-
import Root from './components/navigation.root.svelte';
|
|
5
|
-
import SubContent from './components/navigation.sub-content.svelte';
|
|
6
|
-
import Trigger from './components/navigation.trigger.svelte';
|
|
42
|
+
import * as Primitive from './exports-primitive.js';
|
|
7
43
|
import type { NavigationProps } from './types.js';
|
|
8
44
|
|
|
9
|
-
let {
|
|
45
|
+
let {
|
|
46
|
+
collection,
|
|
47
|
+
ref = $bindable(null),
|
|
48
|
+
compact = $bindable(false),
|
|
49
|
+
contentClass,
|
|
50
|
+
item: itemSnippet,
|
|
51
|
+
...restProps
|
|
52
|
+
}: NavigationProps = $props();
|
|
53
|
+
|
|
54
|
+
const items = $derived(collection.items);
|
|
10
55
|
</script>
|
|
11
56
|
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
{#if item.icon}
|
|
19
|
-
<item.icon width={24} height={24} />
|
|
20
|
-
{/if}
|
|
21
|
-
{/snippet}
|
|
22
|
-
</Trigger>
|
|
23
|
-
|
|
24
|
-
{#if 'children' in item}
|
|
25
|
-
<SubContent>
|
|
26
|
-
{#each item.children as child (child.key)}
|
|
27
|
-
<Item>
|
|
28
|
-
<Trigger label={child.label} href={child.href} />
|
|
29
|
-
</Item>
|
|
30
|
-
{/each}
|
|
31
|
-
</SubContent>
|
|
57
|
+
{#snippet defaultSubRenderer(item: NavigationItemSub)}
|
|
58
|
+
<Primitive.Sub>
|
|
59
|
+
<Primitive.SubTrigger label={item.label} disabled={item.disabled}>
|
|
60
|
+
{#snippet icon()}
|
|
61
|
+
{#if item.icon}
|
|
62
|
+
<item.icon width={24} height={24} />
|
|
32
63
|
{/if}
|
|
33
|
-
|
|
64
|
+
{/snippet}
|
|
65
|
+
</Primitive.SubTrigger>
|
|
66
|
+
|
|
67
|
+
<Primitive.SubContent>
|
|
68
|
+
{#each item.children as child (child.key)}
|
|
69
|
+
{@render renderItem(child)}
|
|
70
|
+
{/each}
|
|
71
|
+
</Primitive.SubContent>
|
|
72
|
+
</Primitive.Sub>
|
|
73
|
+
{/snippet}
|
|
74
|
+
|
|
75
|
+
{#snippet defaultLinkRenderer(item: NavigationItemLink)}
|
|
76
|
+
<Primitive.Item>
|
|
77
|
+
<Primitive.Trigger label={item.label} href={item.href} disabled={item.disabled}>
|
|
78
|
+
{#snippet icon()}
|
|
79
|
+
{#if item.icon}
|
|
80
|
+
<item.icon width={24} height={24} />
|
|
81
|
+
{/if}
|
|
82
|
+
{/snippet}
|
|
83
|
+
</Primitive.Trigger>
|
|
84
|
+
</Primitive.Item>
|
|
85
|
+
{/snippet}
|
|
86
|
+
|
|
87
|
+
{#snippet defaultActionRenderer(item: NavigationItemAction)}
|
|
88
|
+
<Primitive.Item>
|
|
89
|
+
<Primitive.Trigger label={item.label} disabled={item.disabled}>
|
|
90
|
+
{#snippet icon()}
|
|
91
|
+
{#if item.icon}
|
|
92
|
+
<item.icon width={24} height={24} />
|
|
93
|
+
{/if}
|
|
94
|
+
{/snippet}
|
|
95
|
+
</Primitive.Trigger>
|
|
96
|
+
</Primitive.Item>
|
|
97
|
+
{/snippet}
|
|
98
|
+
|
|
99
|
+
{#snippet renderItem(item: NavigationSelectableItem)}
|
|
100
|
+
{#if itemSnippet}
|
|
101
|
+
<Primitive.Item>
|
|
102
|
+
{#snippet child({ props })}
|
|
103
|
+
{@render itemSnippet({ item, props })}
|
|
104
|
+
{/snippet}
|
|
105
|
+
</Primitive.Item>
|
|
106
|
+
{:else if isSub(item)}
|
|
107
|
+
{@render defaultSubRenderer(item)}
|
|
108
|
+
{:else if isLink(item)}
|
|
109
|
+
{@render defaultLinkRenderer(item)}
|
|
110
|
+
{:else if isAction(item)}
|
|
111
|
+
{@render defaultActionRenderer(item)}
|
|
112
|
+
{/if}
|
|
113
|
+
{/snippet}
|
|
114
|
+
|
|
115
|
+
<Primitive.Root bind:ref bind:compact {...restProps}>
|
|
116
|
+
<Primitive.Content class={contentClass}>
|
|
117
|
+
{#each items as item (item.key)}
|
|
118
|
+
{@render renderItem(item)}
|
|
34
119
|
{/each}
|
|
35
|
-
</Content>
|
|
36
|
-
</Root>
|
|
120
|
+
</Primitive.Content>
|
|
121
|
+
</Primitive.Root>
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ListCollection } from '../../internal/lib/collection/index.js';
|
|
2
|
+
import type { NavigationCollectionOptions, NavigationItem } from './types.js';
|
|
3
|
+
export declare function createNavigationCollection(options: NavigationCollectionOptions): ListCollection<NavigationItem>;
|
|
1
4
|
import type { NavigationProps } from './types.js';
|
|
2
5
|
declare const Navigation: import("svelte").Component<NavigationProps, {}, "ref" | "compact">;
|
|
3
6
|
type Navigation = ReturnType<typeof Navigation>;
|
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
import { Context } from 'runed';
|
|
2
|
-
import type { ReadableBox } from 'svelte-toolbelt';
|
|
3
1
|
import type { VariantProps } from 'tailwind-variants';
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const navigationRootStyles: import("tailwind-variants").TVReturnType<{
|
|
5
3
|
compact: {
|
|
6
4
|
true: {};
|
|
7
5
|
};
|
|
8
|
-
}, {
|
|
9
|
-
root: string[];
|
|
10
|
-
content: string[];
|
|
11
|
-
item: never[];
|
|
12
|
-
subContent: string[];
|
|
13
|
-
trigger: string[];
|
|
14
|
-
}, undefined, {
|
|
6
|
+
}, undefined, string[], {
|
|
15
7
|
compact: {
|
|
16
8
|
true: {};
|
|
17
9
|
};
|
|
18
|
-
}, {
|
|
19
|
-
root: string[];
|
|
20
|
-
content: string[];
|
|
21
|
-
item: never[];
|
|
22
|
-
subContent: string[];
|
|
23
|
-
trigger: string[];
|
|
24
|
-
}, import("tailwind-variants").TVReturnType<{
|
|
10
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
25
11
|
compact: {
|
|
26
12
|
true: {};
|
|
27
13
|
};
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, undefined, unknown, unknown, undefined>>;
|
|
35
|
-
export
|
|
36
|
-
type
|
|
37
|
-
export
|
|
38
|
-
export
|
|
14
|
+
}, undefined, string[], unknown, unknown, undefined>>;
|
|
15
|
+
export declare const navigationContentStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
16
|
+
export declare const navigationItemStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, never[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, never[], unknown, unknown, undefined>>;
|
|
17
|
+
export declare const navigationTriggerStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
18
|
+
export declare const navigationSubStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, never[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, never[], unknown, unknown, undefined>>;
|
|
19
|
+
export declare const navigationSubTriggerStyles: import("tailwind-variants").TVReturnType<{} | {} | {} | {}, undefined, string[], {} | {} | {}, undefined, import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>>;
|
|
20
|
+
export declare const navigationSubContentStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
21
|
+
export declare const navigationDropdownContentStyles: import("tailwind-variants").TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import("tailwind-variants").TVReturnType<unknown, undefined, string[], unknown, unknown, undefined>>;
|
|
22
|
+
export type NavigationRootVariantsProps = VariantProps<typeof navigationRootStyles>;
|
|
23
|
+
export type NavigationContentVariantsProps = VariantProps<typeof navigationContentStyles>;
|
|
24
|
+
export type NavigationItemVariantsProps = VariantProps<typeof navigationItemStyles>;
|
|
25
|
+
export type NavigationTriggerVariantsProps = VariantProps<typeof navigationTriggerStyles>;
|
|
26
|
+
export type NavigationSubVariantsProps = VariantProps<typeof navigationSubStyles>;
|
|
27
|
+
export type NavigationSubTriggerVariantsProps = VariantProps<typeof navigationSubTriggerStyles>;
|
|
28
|
+
export type NavigationSubContentVariantsProps = VariantProps<typeof navigationSubContentStyles>;
|
|
29
|
+
export type NavigationDropdownContentVariantsProps = VariantProps<typeof navigationDropdownContentStyles>;
|