@casinogate/ui 1.3.6 → 1.4.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 +31 -3
- package/dist/components/collapsible/components/collapsaible.svelte.d.ts +11 -0
- package/dist/components/collapsible/components/collapsaible.svelte.js +16 -0
- package/dist/components/collapsible/components/collapsaible.trigger.svelte +17 -5
- package/dist/components/collapsible/types.d.ts +5 -2
- package/dist/components/navigation/components/navigation.root.svelte +1 -1
- package/dist/components/navigation/components/navigation.root.svelte.d.ts +1 -1
- package/dist/components/navigation/components/navigation.svelte.d.ts +6 -2
- package/dist/components/navigation/components/navigation.svelte.js +8 -4
- package/dist/components/navigation/components/navigation.trigger.svelte +83 -25
- 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 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/navigation/navigation.stories.svelte +29 -15
- package/dist/components/navigation/navigation.stories.svelte.d.ts +1 -0
- package/dist/components/navigation/navigation.svelte +35 -2
- package/dist/components/navigation/navigation.svelte.d.ts +3 -17
- package/dist/components/navigation/styles.d.ts +3 -3
- package/dist/components/navigation/styles.js +5 -3
- package/dist/components/navigation/types.d.ts +28 -3
- package/dist/components/segment/components/segment.root.svelte +2 -1
- package/dist/components/segment/styles.js +1 -1
- package/package.json +1 -1
package/dist/assets/css/root.css
CHANGED
|
@@ -372,6 +372,9 @@
|
|
|
372
372
|
.cgui\:w-\(--app-shell-sidebar-width\) {
|
|
373
373
|
width: var(--app-shell-sidebar-width);
|
|
374
374
|
}
|
|
375
|
+
.cgui\:w-0 {
|
|
376
|
+
width: calc(var(--cgui-spacing) * 0);
|
|
377
|
+
}
|
|
375
378
|
.cgui\:w-1\.5 {
|
|
376
379
|
width: calc(var(--cgui-spacing) * 1.5);
|
|
377
380
|
}
|
|
@@ -429,9 +432,15 @@
|
|
|
429
432
|
.cgui\:max-w-100 {
|
|
430
433
|
max-width: calc(var(--cgui-spacing) * 100);
|
|
431
434
|
}
|
|
435
|
+
.cgui\:min-w-0 {
|
|
436
|
+
min-width: calc(var(--cgui-spacing) * 0);
|
|
437
|
+
}
|
|
432
438
|
.cgui\:min-w-42 {
|
|
433
439
|
min-width: calc(var(--cgui-spacing) * 42);
|
|
434
440
|
}
|
|
441
|
+
.cgui\:min-w-fit {
|
|
442
|
+
min-width: fit-content;
|
|
443
|
+
}
|
|
435
444
|
.cgui\:min-w-px {
|
|
436
445
|
min-width: 1px;
|
|
437
446
|
}
|
|
@@ -456,6 +465,9 @@
|
|
|
456
465
|
--tw-scale-x: calc(1 * -1);
|
|
457
466
|
scale: var(--tw-scale-x) var(--tw-scale-y);
|
|
458
467
|
}
|
|
468
|
+
.cgui\:rotate-180 {
|
|
469
|
+
rotate: 180deg;
|
|
470
|
+
}
|
|
459
471
|
.cgui\:animate-pulse {
|
|
460
472
|
animation: var(--cgui-animate-pulse);
|
|
461
473
|
}
|
|
@@ -489,9 +501,6 @@
|
|
|
489
501
|
.cgui\:items-stretch {
|
|
490
502
|
align-items: stretch;
|
|
491
503
|
}
|
|
492
|
-
.cgui\:justify-between {
|
|
493
|
-
justify-content: space-between;
|
|
494
|
-
}
|
|
495
504
|
.cgui\:justify-center {
|
|
496
505
|
justify-content: center;
|
|
497
506
|
}
|
|
@@ -864,6 +873,9 @@
|
|
|
864
873
|
.cgui\:underline {
|
|
865
874
|
text-decoration-line: underline;
|
|
866
875
|
}
|
|
876
|
+
.cgui\:opacity-0 {
|
|
877
|
+
opacity: 0%;
|
|
878
|
+
}
|
|
867
879
|
.cgui\:opacity-50 {
|
|
868
880
|
opacity: 50%;
|
|
869
881
|
}
|
|
@@ -1370,6 +1382,19 @@
|
|
|
1370
1382
|
border-color: var(--cg-ui-palette-primary-80);
|
|
1371
1383
|
}
|
|
1372
1384
|
}
|
|
1385
|
+
.cgui\:data-\[sub-content\=\"false\"\]\:group-data-\[compact\=true\]\/navigation\:justify-center {
|
|
1386
|
+
&[data-sub-content="false"] {
|
|
1387
|
+
&:is(:where(.cgui\:group\/navigation)[data-compact="true"] *) {
|
|
1388
|
+
justify-content: center;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
.cgui\:\[\&_\[data-slot\=\"icon\"\]\]\:size-6 {
|
|
1393
|
+
& [data-slot="icon"] {
|
|
1394
|
+
width: calc(var(--cgui-spacing) * 6);
|
|
1395
|
+
height: calc(var(--cgui-spacing) * 6);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1373
1398
|
.cgui\:data-\[compact\=false\]\:\[\&_\[data-slot\=\"trigger\"\]\]\:pl-0 {
|
|
1374
1399
|
&[data-compact="false"] {
|
|
1375
1400
|
& [data-slot="trigger"] {
|
|
@@ -1608,6 +1633,9 @@
|
|
|
1608
1633
|
--cg-ui-palette-system-info-100: hsla(232, 22%, 29%, 1);
|
|
1609
1634
|
--cg-ui-palette-system-info-10: hsla(240, 12%, 93%, 1);
|
|
1610
1635
|
}
|
|
1636
|
+
:root {
|
|
1637
|
+
interpolate-size: allow-keywords;
|
|
1638
|
+
}
|
|
1611
1639
|
@layer base {
|
|
1612
1640
|
[type='text'],input:where(:not([type])),[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select {
|
|
1613
1641
|
appearance: none;
|
|
@@ -41,4 +41,15 @@ export declare class CollapsibleRootState {
|
|
|
41
41
|
readonly 'data-disabled': "" | undefined;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
export type CollapsibleTriggerStateOpts = WithRefProps<{}>;
|
|
45
|
+
export declare class CollapsibleTriggerState {
|
|
46
|
+
static create(opts: CollapsibleTriggerStateOpts): CollapsibleTriggerState;
|
|
47
|
+
readonly opts: CollapsibleTriggerStateOpts;
|
|
48
|
+
readonly attachment: RefAttachment;
|
|
49
|
+
readonly root: CollapsibleRootState;
|
|
50
|
+
constructor(opts: CollapsibleTriggerStateOpts, root: CollapsibleRootState);
|
|
51
|
+
readonly props: {
|
|
52
|
+
readonly [x: symbol]: (node: HTMLElement) => () => void;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
44
55
|
export {};
|
|
@@ -90,3 +90,19 @@ export class CollapsibleRootState {
|
|
|
90
90
|
...this.attachment,
|
|
91
91
|
}));
|
|
92
92
|
}
|
|
93
|
+
export class CollapsibleTriggerState {
|
|
94
|
+
static create(opts) {
|
|
95
|
+
return new CollapsibleTriggerState(opts, CollapsibleRootContext.get());
|
|
96
|
+
}
|
|
97
|
+
opts;
|
|
98
|
+
attachment;
|
|
99
|
+
root;
|
|
100
|
+
constructor(opts, root) {
|
|
101
|
+
this.opts = opts;
|
|
102
|
+
this.root = root;
|
|
103
|
+
this.attachment = attachRef(opts.ref);
|
|
104
|
+
}
|
|
105
|
+
props = $derived.by(() => ({
|
|
106
|
+
...this.attachment,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import { cn, useId } from '../../../internal/utils/common.js';
|
|
6
6
|
|
|
7
7
|
import { Collapsible as CollapsiblePrimitive } from 'bits-ui';
|
|
8
|
+
import { boxWith, mergeProps } from 'svelte-toolbelt';
|
|
9
|
+
import { CollapsibleTriggerState } from './collapsaible.svelte.js';
|
|
8
10
|
|
|
9
11
|
const uid = $props.id();
|
|
10
12
|
|
|
@@ -18,15 +20,25 @@
|
|
|
18
20
|
...restProps
|
|
19
21
|
}: CollapsibleTriggerProps = $props();
|
|
20
22
|
|
|
23
|
+
const triggerState = CollapsibleTriggerState.create({
|
|
24
|
+
ref: boxWith(
|
|
25
|
+
() => ref,
|
|
26
|
+
(v) => (ref = v)
|
|
27
|
+
),
|
|
28
|
+
id: boxWith(() => id),
|
|
29
|
+
});
|
|
30
|
+
|
|
21
31
|
const styles = CollapsibleStylesContext.get();
|
|
32
|
+
|
|
33
|
+
const mergedProps = $derived(mergeProps(restProps, triggerState.props));
|
|
22
34
|
</script>
|
|
23
35
|
|
|
24
|
-
<CollapsiblePrimitive.Trigger bind:ref {id} class={cn(styles.current.trigger(), className)} {...
|
|
25
|
-
{#snippet child(childProps)}
|
|
36
|
+
<CollapsiblePrimitive.Trigger bind:ref {id} class={cn(styles.current.trigger(), className)} {...mergedProps}>
|
|
37
|
+
{#snippet child({ props: childProps })}
|
|
26
38
|
{#if childSnippet}
|
|
27
|
-
{@render childSnippet?.(childProps)}
|
|
39
|
+
{@render childSnippet?.({ props: childProps, open: triggerState.root.opts.value.current })}
|
|
28
40
|
{:else}
|
|
29
|
-
<button {...childProps
|
|
41
|
+
<button {...childProps}>
|
|
30
42
|
{#if iconSnippet !== null}
|
|
31
43
|
<span data-slot="icon" class={styles.current.icon()}>
|
|
32
44
|
{#if iconSnippet}
|
|
@@ -37,7 +49,7 @@
|
|
|
37
49
|
</span>
|
|
38
50
|
{/if}
|
|
39
51
|
|
|
40
|
-
{@render childrenSnippet?.()}
|
|
52
|
+
{@render childrenSnippet?.({ open: triggerState.root.opts.value.current })}
|
|
41
53
|
</button>
|
|
42
54
|
{/if}
|
|
43
55
|
{/snippet}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { CollapsibleVariantsProps } from './styles.js';
|
|
2
2
|
import { type CollapsibleContentProps as CollapsibleContentPropsPrimitive, type CollapsibleRootProps as CollapsibleRootPropsPrimitive, type CollapsibleTriggerProps as CollapsibleTriggerPropsPrimitive } from 'bits-ui';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { WithChild, WithoutChild } from 'svelte-toolbelt';
|
|
4
5
|
export type CollapsibleOpenVariant = 'single' | 'multiple';
|
|
5
6
|
export type CollapsibleRootProps = CollapsibleRootPropsPrimitive & CollapsibleVariantsProps;
|
|
6
7
|
export type CollapsibleContentProps = CollapsibleContentPropsPrimitive;
|
|
7
|
-
export type CollapsibleTriggerProps = CollapsibleTriggerPropsPrimitive & {
|
|
8
|
+
export type CollapsibleTriggerProps = WithChild<WithoutChild<CollapsibleTriggerPropsPrimitive> & {
|
|
8
9
|
icon?: Snippet | null;
|
|
9
|
-
}
|
|
10
|
+
}, {
|
|
11
|
+
open: boolean;
|
|
12
|
+
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { NavigationRootProps } from '../types.js';
|
|
2
|
-
declare const Navigation: import("svelte").Component<NavigationRootProps, {}, "ref">;
|
|
2
|
+
declare const Navigation: import("svelte").Component<NavigationRootProps, {}, "ref" | "compact">;
|
|
3
3
|
type Navigation = ReturnType<typeof Navigation>;
|
|
4
4
|
export default Navigation;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RefAttachment } from '../../../internal/types/common.js';
|
|
2
|
+
import { Context } from 'runed';
|
|
2
3
|
import { type ReadableBoxedValues, type WithRefProps } from 'svelte-toolbelt';
|
|
4
|
+
export declare const NavigationSubContentStateCtx: Context<NavigationSubContentState>;
|
|
3
5
|
type NavigationRootStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
4
6
|
compact: boolean;
|
|
5
7
|
}>>;
|
|
@@ -50,18 +52,20 @@ type NavigationTriggerStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
|
50
52
|
disabled: boolean;
|
|
51
53
|
}>>;
|
|
52
54
|
export declare class NavigationTriggerState {
|
|
53
|
-
static create(opts: NavigationTriggerStateOpts): NavigationTriggerState;
|
|
55
|
+
static create(opts: NavigationTriggerStateOpts, subContent: NavigationSubContentState | null): NavigationTriggerState;
|
|
54
56
|
readonly opts: NavigationTriggerStateOpts;
|
|
55
57
|
readonly attachment: RefAttachment;
|
|
56
58
|
readonly root: NavigationRootState;
|
|
57
59
|
readonly item: NavigationItemState;
|
|
58
|
-
|
|
60
|
+
readonly subContent: NavigationSubContentState | null;
|
|
61
|
+
constructor(opts: NavigationTriggerStateOpts, root: NavigationRootState, item: NavigationItemState, subContent: NavigationSubContentState | null);
|
|
59
62
|
readonly props: {
|
|
60
63
|
readonly id: string;
|
|
61
64
|
readonly "data-slot": "trigger";
|
|
62
65
|
readonly role: "button";
|
|
63
66
|
readonly tabindex: 0;
|
|
64
67
|
readonly 'data-disabled': "" | undefined;
|
|
68
|
+
readonly 'data-sub-content': boolean;
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
type NavigationSubContentStateOpts = WithRefProps<{}>;
|
|
@@ -5,6 +5,7 @@ import { Context } 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 NavigationSubContentStateCtx = new Context(keyWithPrefix('navigation-sub-content'));
|
|
8
9
|
const SLOT_ATTR_VALUES = {
|
|
9
10
|
root: 'root',
|
|
10
11
|
content: 'content',
|
|
@@ -78,17 +79,19 @@ export class NavigationItemState {
|
|
|
78
79
|
}));
|
|
79
80
|
}
|
|
80
81
|
export class NavigationTriggerState {
|
|
81
|
-
static create(opts) {
|
|
82
|
-
return new NavigationTriggerState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get());
|
|
82
|
+
static create(opts, subContent) {
|
|
83
|
+
return new NavigationTriggerState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get(), subContent);
|
|
83
84
|
}
|
|
84
85
|
opts;
|
|
85
86
|
attachment;
|
|
86
87
|
root;
|
|
87
88
|
item;
|
|
88
|
-
|
|
89
|
+
subContent;
|
|
90
|
+
constructor(opts, root, item, subContent) {
|
|
89
91
|
this.opts = opts;
|
|
90
92
|
this.root = root;
|
|
91
93
|
this.item = item;
|
|
94
|
+
this.subContent = subContent;
|
|
92
95
|
this.attachment = attachRef(opts.ref);
|
|
93
96
|
}
|
|
94
97
|
props = $derived.by(() => ({
|
|
@@ -97,12 +100,13 @@ export class NavigationTriggerState {
|
|
|
97
100
|
role: 'button',
|
|
98
101
|
tabindex: 0,
|
|
99
102
|
'data-disabled': boolAttr(this.opts.disabled.current),
|
|
103
|
+
'data-sub-content': this.subContent !== null,
|
|
100
104
|
...this.attachment,
|
|
101
105
|
}));
|
|
102
106
|
}
|
|
103
107
|
export class NavigationSubContentState {
|
|
104
108
|
static create(opts) {
|
|
105
|
-
return new NavigationSubContentState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get());
|
|
109
|
+
return NavigationSubContentStateCtx.set(new NavigationSubContentState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get()));
|
|
106
110
|
}
|
|
107
111
|
opts;
|
|
108
112
|
attachment;
|
|
@@ -6,29 +6,37 @@
|
|
|
6
6
|
import { cn, useId } from '../../../internal/utils/common.js';
|
|
7
7
|
import { boxWith, mergeProps } from 'svelte-toolbelt';
|
|
8
8
|
import type { NavigationTriggerProps } from '../types.js';
|
|
9
|
-
import { NavigationTriggerState } from './navigation.svelte.js';
|
|
9
|
+
import { NavigationSubContentStateCtx, NavigationTriggerState } from './navigation.svelte.js';
|
|
10
10
|
|
|
11
11
|
const uid = $props.id();
|
|
12
12
|
|
|
13
13
|
let {
|
|
14
14
|
ref = $bindable(null),
|
|
15
15
|
id = useId(uid),
|
|
16
|
-
children,
|
|
17
16
|
child,
|
|
17
|
+
icon,
|
|
18
|
+
label,
|
|
18
19
|
class: className,
|
|
19
20
|
href,
|
|
20
21
|
disabled = false,
|
|
21
22
|
...restProps
|
|
22
23
|
}: NavigationTriggerProps = $props();
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const subContent = NavigationSubContentStateCtx.getOr(null);
|
|
26
|
+
|
|
27
|
+
const isSubTrigger = $derived.by(() => subContent !== null);
|
|
28
|
+
|
|
29
|
+
const triggerState = NavigationTriggerState.create(
|
|
30
|
+
{
|
|
31
|
+
ref: boxWith(
|
|
32
|
+
() => ref,
|
|
33
|
+
(v) => (ref = v)
|
|
34
|
+
),
|
|
35
|
+
id: boxWith(() => id),
|
|
36
|
+
disabled: boxWith(() => disabled),
|
|
37
|
+
},
|
|
38
|
+
subContent
|
|
39
|
+
);
|
|
32
40
|
|
|
33
41
|
const mergedProps = $derived(
|
|
34
42
|
mergeProps(restProps, triggerState.props, { class: cn(NavigationStylesContext.get().current.trigger(), className) })
|
|
@@ -39,34 +47,84 @@
|
|
|
39
47
|
});
|
|
40
48
|
</script>
|
|
41
49
|
|
|
42
|
-
{#
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
50
|
+
{#snippet content()}
|
|
51
|
+
{#if icon}
|
|
52
|
+
<span
|
|
53
|
+
data-slot="icon"
|
|
54
|
+
class={cn('cgap:inline-flex cgap:items-center cgap:justify-center cgap:shrink-0 cgap:size-6')}
|
|
55
|
+
>
|
|
56
|
+
{@render icon?.()}
|
|
57
|
+
</span>
|
|
58
|
+
{/if}
|
|
59
|
+
|
|
60
|
+
{#if label}
|
|
61
|
+
{#if typeof label === 'string'}
|
|
62
|
+
<span
|
|
63
|
+
data-slot="label"
|
|
64
|
+
class={cn('cgui:flex-1 cgui:min-w-0 cgui:text-left cgui:transition-all cgui:duration-250 cgui:ease-in-out', {
|
|
65
|
+
'cgui:w-0 cgui:opacity-0 cgui:pointer-events-none cgui:hidden': !isSubTrigger && triggerState.root.isCompact,
|
|
66
|
+
})}
|
|
67
|
+
>
|
|
68
|
+
{label}
|
|
69
|
+
</span>
|
|
70
|
+
{:else}
|
|
71
|
+
{@render label?.({ props: { 'data-slot': 'label' } })}
|
|
72
|
+
{/if}
|
|
73
|
+
{/if}
|
|
74
|
+
{/snippet}
|
|
75
|
+
|
|
76
|
+
{#snippet popoverTrigger()}
|
|
49
77
|
<PopoverPrimitive.Trigger>
|
|
50
78
|
{#snippet child({ props: childProps })}
|
|
51
79
|
<button {...childProps} {...mergedProps} data-type="popover-trigger">
|
|
52
|
-
{@render
|
|
80
|
+
{@render content?.()}
|
|
53
81
|
</button>
|
|
54
82
|
{/snippet}
|
|
55
83
|
</PopoverPrimitive.Trigger>
|
|
56
|
-
{
|
|
84
|
+
{/snippet}
|
|
85
|
+
|
|
86
|
+
{#snippet collapsibleTrigger()}
|
|
57
87
|
<CollapsiblePrimitive.Trigger>
|
|
58
|
-
{#snippet child({ props: childProps })}
|
|
88
|
+
{#snippet child({ props: childProps, open })}
|
|
59
89
|
<button {...childProps} {...mergedProps} data-type="collapsible-trigger">
|
|
60
|
-
{@render
|
|
90
|
+
{@render content?.()}
|
|
61
91
|
|
|
62
|
-
<span
|
|
63
|
-
|
|
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} />
|
|
64
102
|
</span>
|
|
65
103
|
</button>
|
|
66
104
|
{/snippet}
|
|
67
105
|
</CollapsiblePrimitive.Trigger>
|
|
68
|
-
{
|
|
106
|
+
{/snippet}
|
|
107
|
+
|
|
108
|
+
{#snippet buttonTrigger()}
|
|
69
109
|
<button {...mergedProps}>
|
|
70
|
-
{@render
|
|
110
|
+
{@render content?.()}
|
|
71
111
|
</button>
|
|
112
|
+
{/snippet}
|
|
113
|
+
|
|
114
|
+
{#snippet linkTrigger()}
|
|
115
|
+
<a {href} {...mergedProps}>
|
|
116
|
+
{@render content?.()}
|
|
117
|
+
</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
|
+
{:else}
|
|
129
|
+
{@render buttonTrigger?.()}
|
|
72
130
|
{/if}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as Root } from './navigation.svelte';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as Root } from './navigation.svelte';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * as NavigationPrimitive from './exports-primitive.js';
|
|
2
|
-
export * from './exports.js';
|
|
3
|
-
export type { NavigationContentProps, NavigationItemProps, NavigationRootProps, NavigationSubContentProps, NavigationTriggerProps, } from './types.js';
|
|
2
|
+
export * as Navigation from './exports.js';
|
|
3
|
+
export type { NavigationContentProps, NavigationItemProps, NavigationItemValue, NavigationProps, NavigationRootProps, NavigationSubContentProps, NavigationTriggerProps, } from './types.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as NavigationPrimitive from './exports-primitive.js';
|
|
2
|
-
export * from './exports.js';
|
|
2
|
+
export * as Navigation from './exports.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import { Icon } from '../icons/index.js';
|
|
2
3
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
4
|
import type { Parameters } from '@storybook/sveltekit';
|
|
4
5
|
import type { ComponentProps } from 'svelte';
|
|
5
6
|
import Root from './components/navigation.root.svelte';
|
|
6
|
-
import { NavigationPrimitive } from './index.js';
|
|
7
|
+
import { Navigation, NavigationPrimitive, type NavigationItemValue } from './index.js';
|
|
7
8
|
|
|
8
9
|
const parameters: Parameters = {
|
|
9
10
|
controls: {
|
|
@@ -23,35 +24,36 @@
|
|
|
23
24
|
const args: Args = {
|
|
24
25
|
compact: false,
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
type NavigationItem = {
|
|
28
|
-
id: number;
|
|
29
|
-
label: string;
|
|
30
|
-
children?: NavigationItem[];
|
|
31
|
-
};
|
|
32
27
|
</script>
|
|
33
28
|
|
|
34
29
|
<script lang="ts">
|
|
35
|
-
const NAVIGATION_ITEMS = [
|
|
30
|
+
const NAVIGATION_ITEMS: NavigationItemValue[] = [
|
|
36
31
|
{
|
|
37
|
-
|
|
32
|
+
key: 1,
|
|
38
33
|
label: 'Item 1',
|
|
34
|
+
icon: Icon.Info,
|
|
35
|
+
href: '#',
|
|
39
36
|
},
|
|
40
37
|
{
|
|
41
|
-
|
|
38
|
+
key: 2,
|
|
42
39
|
label: 'Item 2',
|
|
40
|
+
icon: Icon.Info,
|
|
41
|
+
href: '#',
|
|
43
42
|
},
|
|
44
43
|
{
|
|
45
|
-
|
|
44
|
+
key: 3,
|
|
46
45
|
label: 'Item 3',
|
|
46
|
+
icon: Icon.Info,
|
|
47
47
|
children: [
|
|
48
48
|
{
|
|
49
|
-
|
|
49
|
+
key: 4,
|
|
50
50
|
label: 'Sub Item 1',
|
|
51
|
+
href: '#',
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
|
-
|
|
54
|
+
key: 5,
|
|
54
55
|
label: 'Sub Item 2',
|
|
56
|
+
href: '#',
|
|
55
57
|
},
|
|
56
58
|
],
|
|
57
59
|
},
|
|
@@ -65,13 +67,17 @@
|
|
|
65
67
|
<NavigationPrimitive.Content>
|
|
66
68
|
{#each NAVIGATION_ITEMS as item}
|
|
67
69
|
<NavigationPrimitive.Item>
|
|
68
|
-
<NavigationPrimitive.Trigger
|
|
70
|
+
<NavigationPrimitive.Trigger label={item.label}>
|
|
71
|
+
{#snippet icon()}
|
|
72
|
+
<item.icon width={24} height={24} />
|
|
73
|
+
{/snippet}
|
|
74
|
+
</NavigationPrimitive.Trigger>
|
|
69
75
|
|
|
70
76
|
{#if item?.children && item.children.length > 0}
|
|
71
77
|
<NavigationPrimitive.SubContent>
|
|
72
78
|
{#each item.children as child}
|
|
73
79
|
<NavigationPrimitive.Item>
|
|
74
|
-
<NavigationPrimitive.Trigger
|
|
80
|
+
<NavigationPrimitive.Trigger label={child.label} />
|
|
75
81
|
</NavigationPrimitive.Item>
|
|
76
82
|
{/each}
|
|
77
83
|
</NavigationPrimitive.SubContent>
|
|
@@ -83,3 +89,11 @@
|
|
|
83
89
|
</div>
|
|
84
90
|
{/snippet}
|
|
85
91
|
</Story>
|
|
92
|
+
|
|
93
|
+
<Story name="Preset" {args} {parameters}>
|
|
94
|
+
{#snippet template(args: Args)}
|
|
95
|
+
<div class="cgui:max-w-64 cgui:mx-auto">
|
|
96
|
+
<Navigation.Root {...args} items={NAVIGATION_ITEMS} />
|
|
97
|
+
</div>
|
|
98
|
+
{/snippet}
|
|
99
|
+
</Story>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Navigation } from './index.js';
|
|
1
2
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
4
|
$$bindings?: Bindings;
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
<script lang="ts"
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Content from './components/navigation.content.svelte';
|
|
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';
|
|
7
|
+
import type { NavigationProps } from './types.js';
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
let { items, ref = $bindable(null), compact = $bindable(false), ...restProps }: NavigationProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Root bind:ref bind:compact {...restProps}>
|
|
13
|
+
<Content>
|
|
14
|
+
{#each items as item (item.key)}
|
|
15
|
+
<Item>
|
|
16
|
+
<Trigger label={item.label} {...'href' in item ? { href: item.href } : {}}>
|
|
17
|
+
{#snippet icon()}
|
|
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>
|
|
32
|
+
{/if}
|
|
33
|
+
</Item>
|
|
34
|
+
{/each}
|
|
35
|
+
</Content>
|
|
36
|
+
</Root>
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Navigation: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type Navigation = InstanceType<typeof Navigation>;
|
|
1
|
+
import type { NavigationProps } from './types.js';
|
|
2
|
+
declare const Navigation: import("svelte").Component<NavigationProps, {}, "ref" | "compact">;
|
|
3
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
18
4
|
export default Navigation;
|
|
@@ -7,7 +7,7 @@ export declare const navigationVariants: import("tailwind-variants").TVReturnTyp
|
|
|
7
7
|
};
|
|
8
8
|
}, {
|
|
9
9
|
root: string[];
|
|
10
|
-
content:
|
|
10
|
+
content: string[];
|
|
11
11
|
item: never[];
|
|
12
12
|
subContent: string[];
|
|
13
13
|
trigger: string[];
|
|
@@ -17,7 +17,7 @@ export declare const navigationVariants: import("tailwind-variants").TVReturnTyp
|
|
|
17
17
|
};
|
|
18
18
|
}, {
|
|
19
19
|
root: string[];
|
|
20
|
-
content:
|
|
20
|
+
content: string[];
|
|
21
21
|
item: never[];
|
|
22
22
|
subContent: string[];
|
|
23
23
|
trigger: string[];
|
|
@@ -27,7 +27,7 @@ export declare const navigationVariants: import("tailwind-variants").TVReturnTyp
|
|
|
27
27
|
};
|
|
28
28
|
}, {
|
|
29
29
|
root: string[];
|
|
30
|
-
content:
|
|
30
|
+
content: string[];
|
|
31
31
|
item: never[];
|
|
32
32
|
subContent: string[];
|
|
33
33
|
trigger: string[];
|
|
@@ -9,7 +9,7 @@ export const navigationVariants = tv({
|
|
|
9
9
|
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
10
10
|
'cgui:bg-surface-darkest',
|
|
11
11
|
],
|
|
12
|
-
content: [],
|
|
12
|
+
content: ['cgui:overflow-hidden'],
|
|
13
13
|
item: [],
|
|
14
14
|
subContent: [
|
|
15
15
|
'cgui:data-[compact=false]:pl-10',
|
|
@@ -17,12 +17,14 @@ export const navigationVariants = tv({
|
|
|
17
17
|
'cgui:data-[popover-content]:bg-surface-darkest cgui:data-[popover-content]:rounded-md',
|
|
18
18
|
],
|
|
19
19
|
trigger: [
|
|
20
|
-
'cgui:flex cgui:items-center cgui:gap-
|
|
20
|
+
'cgui:flex cgui:items-center cgui:gap-2',
|
|
21
|
+
'cgui:overflow-hidden',
|
|
21
22
|
'cgui:w-full cgui:px-3 cgui:py-4',
|
|
22
|
-
'cgui:group-data-[compact=true]/navigation:py-3',
|
|
23
|
+
'cgui:group-data-[compact=true]/navigation:py-3 cgui:data-[sub-content="false"]:group-data-[compact=true]/navigation:justify-center',
|
|
23
24
|
'cgui:text-fg-semilight cgui:text-body',
|
|
24
25
|
'cgui:cursor-pointer cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
25
26
|
'cgui:[data-disabled]:cursor-not-allowed cgui:[data-disabled]:opacity-50',
|
|
27
|
+
'cgui:[&_[data-slot="icon"]]:size-6',
|
|
26
28
|
],
|
|
27
29
|
},
|
|
28
30
|
variants: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PrimitiveElementAttributes } from '../../internal/types/html-attributes.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { WithChild, WithElementRef, Without, WithoutChildren, WithoutChildrenOrChild } from 'svelte-toolbelt';
|
|
3
4
|
import type { NavigationVariantsProps } from './styles.js';
|
|
4
5
|
type NavigationRootPropsWithoutHTML = WithElementRef<WithChild<{}, {
|
|
5
6
|
compact: boolean;
|
|
@@ -13,11 +14,35 @@ type NavigationSubContentPropsWithoutHTML = WithElementRef<WithChild<{}, {
|
|
|
13
14
|
compact: boolean;
|
|
14
15
|
}>>;
|
|
15
16
|
export type NavigationSubContentProps = NavigationSubContentPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationSubContentPropsWithoutHTML>;
|
|
16
|
-
type NavigationTriggerPropsWithoutHTML = WithElementRef<WithChild<{
|
|
17
|
+
type NavigationTriggerPropsWithoutHTML = WithElementRef<WithoutChildren<WithChild<{
|
|
17
18
|
href?: string;
|
|
18
19
|
disabled?: boolean;
|
|
20
|
+
icon?: Snippet;
|
|
21
|
+
label?: string | Snippet<[{
|
|
22
|
+
props: Record<string, unknown>;
|
|
23
|
+
}]>;
|
|
19
24
|
}, {
|
|
20
25
|
compact: boolean;
|
|
21
|
-
}
|
|
26
|
+
}>>>;
|
|
22
27
|
export type NavigationTriggerProps = NavigationTriggerPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationTriggerPropsWithoutHTML>;
|
|
28
|
+
type NavigationItemBaseValue = {
|
|
29
|
+
key: string | number;
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: Component<{
|
|
32
|
+
width?: number;
|
|
33
|
+
height?: number;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
type NavigationItemValueWithHref = NavigationItemBaseValue & {
|
|
37
|
+
href: string;
|
|
38
|
+
children?: never;
|
|
39
|
+
};
|
|
40
|
+
type NavigationItemValueWithChildren = NavigationItemBaseValue & {
|
|
41
|
+
children: Omit<NavigationItemValueWithHref, 'icon'>[];
|
|
42
|
+
href?: never;
|
|
43
|
+
};
|
|
44
|
+
export type NavigationItemValue = NavigationItemValueWithHref | NavigationItemValueWithChildren;
|
|
45
|
+
export type NavigationProps = WithoutChildrenOrChild<NavigationRootProps> & {
|
|
46
|
+
items: NavigationItemValue[];
|
|
47
|
+
};
|
|
23
48
|
export {};
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
variant = 'primary',
|
|
18
18
|
rounded = 'sm',
|
|
19
19
|
size = 'md',
|
|
20
|
+
spacingX = 'md',
|
|
20
21
|
onValueChange,
|
|
21
22
|
...restProps
|
|
22
23
|
}: SegmentRootProps = $props();
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
disabled: box.with(() => disabled),
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
const variants = $derived(segmentVariants({ variant, rounded, size }));
|
|
41
|
+
const variants = $derived(segmentVariants({ variant, rounded, size, spacingX }));
|
|
41
42
|
|
|
42
43
|
SegmentStylesContext.set(box.with(() => variants));
|
|
43
44
|
|
|
@@ -9,7 +9,7 @@ export const segmentVariants = tv({
|
|
|
9
9
|
'cgui:data-[disabled=""]:opacity-50 cgui:data-[disabled=""]:cursor-not-allowed cgui:data-[disabled=""]:pointer-events-none',
|
|
10
10
|
],
|
|
11
11
|
item: [
|
|
12
|
-
'cgui:flex cgui:items-center cgui:justify-center cgui:
|
|
12
|
+
'cgui:flex cgui:items-center cgui:justify-center cgui:min-w-fit',
|
|
13
13
|
'cgui:font-medium cgui:text-body-2',
|
|
14
14
|
'cgui:rounded-[inherit]',
|
|
15
15
|
'cgui:cursor-pointer cgui:overflow-hidden cgui:select-none',
|