@casinogate/ui 1.2.0 → 1.3.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 +72 -1
- package/dist/assets/css/theme.css +2 -0
- package/dist/components/app-shell/components/app-shell.nav-bar.svelte +2 -2
- package/dist/components/app-shell/components/app-shell.nav-bar.svelte.d.ts +2 -2
- package/dist/components/app-shell/components/app-shell.root.svelte +0 -4
- package/dist/components/app-shell/components/app-shell.svelte.js +1 -0
- package/dist/components/button-group/components/button-group.root.svelte +0 -2
- package/dist/components/collapsible/collapsible.stories.svelte +24 -8
- package/dist/components/collapsible/components/collapsaible.root.svelte +9 -3
- package/dist/components/collapsible/components/collapsaible.root.svelte.d.ts +4 -3
- package/dist/components/collapsible/components/collapsaible.trigger.svelte +10 -8
- package/dist/components/collapsible/components/collapsaible.trigger.svelte.d.ts +1 -1
- package/dist/components/collapsible/index.d.ts +1 -1
- package/dist/components/collapsible/styles.d.ts +70 -142
- package/dist/components/collapsible/styles.js +24 -5
- package/dist/components/navigation/components/navigation.content.svelte +44 -0
- package/dist/components/navigation/components/navigation.content.svelte.d.ts +7 -0
- package/dist/components/navigation/components/navigation.item.svelte +55 -0
- package/dist/components/navigation/components/navigation.item.svelte.d.ts +7 -0
- package/dist/components/navigation/components/navigation.root.svelte +49 -0
- package/dist/components/navigation/components/navigation.root.svelte.d.ts +10 -0
- package/dist/components/navigation/components/navigation.sub-content.svelte +70 -0
- package/dist/components/navigation/components/navigation.sub-content.svelte.d.ts +9 -0
- package/dist/components/navigation/components/navigation.svelte.d.ts +82 -0
- package/dist/components/navigation/components/navigation.svelte.js +128 -0
- package/dist/components/navigation/components/navigation.trigger.svelte +89 -0
- package/dist/components/navigation/components/navigation.trigger.svelte.d.ts +12 -0
- package/dist/components/navigation/index.d.ts +12 -0
- package/dist/components/navigation/index.js +12 -0
- package/dist/components/navigation/navigation.stories.svelte +85 -0
- package/dist/components/navigation/navigation.stories.svelte.d.ts +18 -0
- package/dist/components/navigation/navigation.svelte +3 -0
- package/dist/components/navigation/navigation.svelte.d.ts +18 -0
- package/dist/components/navigation/styles.d.ts +38 -0
- package/dist/components/navigation/styles.js +34 -0
- package/dist/components/popover/components/popover.content.svelte +39 -0
- package/dist/components/popover/components/popover.content.svelte.d.ts +5 -0
- package/dist/components/popover/components/popover.root.svelte +38 -0
- package/dist/components/popover/components/popover.root.svelte.d.ts +8 -0
- package/dist/components/popover/components/popover.svelte.d.ts +41 -0
- package/dist/components/popover/components/popover.svelte.js +59 -0
- package/dist/components/popover/components/popover.trigger.svelte +32 -0
- package/dist/components/popover/components/popover.trigger.svelte.d.ts +5 -0
- package/dist/components/popover/index.js +15 -0
- package/dist/components/popover/popover.stories.svelte +135 -0
- package/dist/components/popover/popover.stories.svelte.d.ts +4 -0
- package/dist/components/popover/popover.svelte +97 -0
- package/dist/components/popover/popover.svelte.d.ts +35 -0
- package/dist/components/popover/styles.d.ts +56 -0
- package/dist/components/popover/styles.js +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +12 -12
|
@@ -6,22 +6,41 @@ export const collapsibleVariants = tv({
|
|
|
6
6
|
root: [
|
|
7
7
|
'cgui:relative cgui:overflow-hidden',
|
|
8
8
|
'cgui:w-full',
|
|
9
|
-
'cgui:bg-surface-lightest',
|
|
10
|
-
'cgui:border cgui:border-stroke-divider cgui:rounded-sm',
|
|
11
9
|
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
12
|
-
'cgui:hover:bg-surface-primary-light cgui:hover:[&_[data-slot=icon]]:text-icon-focus',
|
|
13
10
|
'cgui:data-[disabled]:opacity-50 cgui:data-[disabled]:cursor-not-allowed cgui:data-[disabled]:pointer-events-none',
|
|
14
11
|
],
|
|
15
12
|
trigger: [
|
|
16
13
|
'cgui:w-full cgui:text-left cgui:py-1.5 cgui:px-2 cgui:flex cgui:items-center cgui:gap-1',
|
|
17
|
-
'cgui:cursor-pointer cgui:
|
|
14
|
+
'cgui:cursor-pointer cgui:font-normal cgui:text-body-2',
|
|
18
15
|
'cgui:data-[state=open]:[&_[data-slot=icon]]:rotate-90',
|
|
19
16
|
],
|
|
20
17
|
icon: [
|
|
21
|
-
'cgui:relative cgui:inline-flex cgui:size-6 cgui:items-center cgui:justify-center cgui:shrink-0
|
|
18
|
+
'cgui:relative cgui:inline-flex cgui:size-6 cgui:items-center cgui:justify-center cgui:shrink-0 ',
|
|
22
19
|
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
23
20
|
],
|
|
24
21
|
content: ['cgui:px-2 cgui:pb-1.5', 'cgui:text-fg-medium cgui:text-body-2'],
|
|
25
22
|
},
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
default: {
|
|
26
|
+
root: [
|
|
27
|
+
'cgui:bg-surface-lightest',
|
|
28
|
+
'cgui:border cgui:border-stroke-divider cgui:rounded-sm',
|
|
29
|
+
'cgui:hover:bg-surface-primary-light cgui:hover:[&_[data-slot=icon]]:text-icon-focus',
|
|
30
|
+
],
|
|
31
|
+
trigger: ['cgui:text-fg-darkest'],
|
|
32
|
+
icon: ['cgui:text-icon-regular'],
|
|
33
|
+
},
|
|
34
|
+
clean: {},
|
|
35
|
+
},
|
|
36
|
+
iconPosition: {
|
|
37
|
+
start: {
|
|
38
|
+
trigger: ['cgui:flex-row'],
|
|
39
|
+
},
|
|
40
|
+
end: {
|
|
41
|
+
trigger: ['cgui:flex-row-reverse cgui:justify-end'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
26
45
|
});
|
|
27
46
|
export const CollapsibleStylesContext = new Context(keyWithPrefix('collapsible-styles'));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
3
|
+
import { boxWith, mergeProps, type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
4
|
+
|
|
5
|
+
type NavigationContentPropsWithoutHTML = WithElementRef<WithChild<{}>>;
|
|
6
|
+
|
|
7
|
+
export type NavigationContentProps = NavigationContentPropsWithoutHTML &
|
|
8
|
+
Without<PrimitiveElementAttributes, NavigationContentPropsWithoutHTML>;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { NavigationStylesContext } from '../styles.js';
|
|
13
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
14
|
+
import { NavigationContentState } from './navigation.svelte.js';
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
ref = $bindable(null),
|
|
18
|
+
id = useId(),
|
|
19
|
+
children,
|
|
20
|
+
child,
|
|
21
|
+
class: className,
|
|
22
|
+
...restProps
|
|
23
|
+
}: NavigationContentProps = $props();
|
|
24
|
+
|
|
25
|
+
const contentState = NavigationContentState.create({
|
|
26
|
+
ref: boxWith(
|
|
27
|
+
() => ref,
|
|
28
|
+
(v) => (ref = v)
|
|
29
|
+
),
|
|
30
|
+
id: boxWith(() => id),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const mergedProps = $derived(
|
|
34
|
+
mergeProps(restProps, contentState.props, { class: cn(NavigationStylesContext.get().current.content(), className) })
|
|
35
|
+
);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#if child}
|
|
39
|
+
{@render child({ props: mergedProps })}
|
|
40
|
+
{:else}
|
|
41
|
+
<ul {...mergedProps}>
|
|
42
|
+
{@render children?.()}
|
|
43
|
+
</ul>
|
|
44
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
2
|
+
import { type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
3
|
+
type NavigationContentPropsWithoutHTML = WithElementRef<WithChild<{}>>;
|
|
4
|
+
export type NavigationContentProps = NavigationContentPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationContentPropsWithoutHTML>;
|
|
5
|
+
declare const Navigation: import("svelte").Component<NavigationContentProps, {}, "ref">;
|
|
6
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
7
|
+
export default Navigation;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type NavigationItemPropsWithoutHTML = WithElementRef<WithChild<{}>>;
|
|
3
|
+
|
|
4
|
+
export type NavigationItemProps = NavigationItemPropsWithoutHTML &
|
|
5
|
+
Without<PrimitiveElementAttributes, NavigationItemPropsWithoutHTML>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { CollapsiblePrimitive } from '../../collapsible/index.js';
|
|
10
|
+
import { NavigationStylesContext } from '../styles.js';
|
|
11
|
+
import { PopoverPrimitive } from '../../popover/index.js';
|
|
12
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
13
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
14
|
+
import { boxWith, mergeProps, type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
15
|
+
import { NavigationItemState } from './navigation.svelte.js';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
ref = $bindable(null),
|
|
19
|
+
id = useId(),
|
|
20
|
+
children,
|
|
21
|
+
child,
|
|
22
|
+
class: className,
|
|
23
|
+
...restProps
|
|
24
|
+
}: NavigationItemProps = $props();
|
|
25
|
+
|
|
26
|
+
const itemState = NavigationItemState.create({
|
|
27
|
+
ref: boxWith(
|
|
28
|
+
() => ref,
|
|
29
|
+
(v) => (ref = v)
|
|
30
|
+
),
|
|
31
|
+
id: boxWith(() => id),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const mergedProps = $derived(
|
|
35
|
+
mergeProps(restProps, itemState.props, { class: cn(NavigationStylesContext.get().current.item(), className) })
|
|
36
|
+
);
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
{#if child}
|
|
40
|
+
{@render child({ props: mergedProps })}
|
|
41
|
+
{:else if itemState.root.isCompact}
|
|
42
|
+
<li {...mergedProps}>
|
|
43
|
+
<PopoverPrimitive.Root>
|
|
44
|
+
{@render children?.()}
|
|
45
|
+
</PopoverPrimitive.Root>
|
|
46
|
+
</li>
|
|
47
|
+
{:else}
|
|
48
|
+
<CollapsiblePrimitive.Root variant="clean">
|
|
49
|
+
{#snippet child({ props: childProps })}
|
|
50
|
+
<li {...mergedProps} {...childProps}>
|
|
51
|
+
{@render children?.()}
|
|
52
|
+
</li>
|
|
53
|
+
{/snippet}
|
|
54
|
+
</CollapsiblePrimitive.Root>
|
|
55
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type NavigationItemPropsWithoutHTML = WithElementRef<WithChild<{}>>;
|
|
2
|
+
export type NavigationItemProps = NavigationItemPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationItemPropsWithoutHTML>;
|
|
3
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
4
|
+
import { type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
5
|
+
declare const Navigation: import("svelte").Component<NavigationItemProps, {}, "ref">;
|
|
6
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
7
|
+
export default Navigation;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type NavigationRootPropsWithoutHTML = WithElementRef<WithChild<{}, { compact: boolean }>> & NavigationVariantsProps;
|
|
3
|
+
|
|
4
|
+
export type NavigationRootProps = NavigationRootPropsWithoutHTML &
|
|
5
|
+
Without<PrimitiveElementAttributes, NavigationRootPropsWithoutHTML>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { NavigationStylesContext, navigationVariants, type NavigationVariantsProps } from '../styles.js';
|
|
10
|
+
|
|
11
|
+
import { NavigationRootState } from './navigation.svelte.js';
|
|
12
|
+
|
|
13
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
14
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
15
|
+
import { box, mergeProps, type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
ref = $bindable(null),
|
|
19
|
+
id = useId(),
|
|
20
|
+
children,
|
|
21
|
+
child,
|
|
22
|
+
class: className,
|
|
23
|
+
compact = false,
|
|
24
|
+
...restProps
|
|
25
|
+
}: NavigationRootProps = $props();
|
|
26
|
+
|
|
27
|
+
const rootState = NavigationRootState.create({
|
|
28
|
+
ref: box.with(
|
|
29
|
+
() => ref,
|
|
30
|
+
(v) => (ref = v)
|
|
31
|
+
),
|
|
32
|
+
id: box.with(() => id),
|
|
33
|
+
compact: box.with(() => compact),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const variants = $derived(navigationVariants({ compact }));
|
|
37
|
+
|
|
38
|
+
NavigationStylesContext.set(box.with(() => variants));
|
|
39
|
+
|
|
40
|
+
const mergedProps = $derived(mergeProps(restProps, rootState.props, { class: cn(variants.root(), className) }));
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
{#if child}
|
|
44
|
+
{@render child({ props: mergedProps, compact })}
|
|
45
|
+
{:else}
|
|
46
|
+
<nav {...mergedProps}>
|
|
47
|
+
{@render children?.({ compact })}
|
|
48
|
+
</nav>
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type NavigationRootPropsWithoutHTML = WithElementRef<WithChild<{}, {
|
|
2
|
+
compact: boolean;
|
|
3
|
+
}>> & NavigationVariantsProps;
|
|
4
|
+
export type NavigationRootProps = NavigationRootPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationRootPropsWithoutHTML>;
|
|
5
|
+
import { type NavigationVariantsProps } from '../styles.js';
|
|
6
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
7
|
+
import { type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
8
|
+
declare const Navigation: import("svelte").Component<NavigationRootProps, {}, "ref">;
|
|
9
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
10
|
+
export default Navigation;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
3
|
+
import { boxWith, mergeProps, type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
4
|
+
|
|
5
|
+
type NavigationSubContentPropsWithoutHTML = WithElementRef<WithChild<{}, { compact: boolean }>>;
|
|
6
|
+
|
|
7
|
+
export type NavigationSubContentProps = NavigationSubContentPropsWithoutHTML &
|
|
8
|
+
Without<PrimitiveElementAttributes, NavigationSubContentPropsWithoutHTML>;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { CollapsiblePrimitive } from '../../collapsible/index.js';
|
|
13
|
+
import { NavigationStylesContext } from '../styles.js';
|
|
14
|
+
import { PopoverPrimitive } from '../../popover/index.js';
|
|
15
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
16
|
+
import { cubicInOut } from 'svelte/easing';
|
|
17
|
+
import { fade, fly } from 'svelte/transition';
|
|
18
|
+
import { NavigationSubContentState } from './navigation.svelte.js';
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
ref = $bindable(null),
|
|
22
|
+
id = useId(),
|
|
23
|
+
children,
|
|
24
|
+
child,
|
|
25
|
+
class: className,
|
|
26
|
+
...restProps
|
|
27
|
+
}: NavigationSubContentProps = $props();
|
|
28
|
+
|
|
29
|
+
const subContentState = NavigationSubContentState.create({
|
|
30
|
+
ref: boxWith(
|
|
31
|
+
() => ref,
|
|
32
|
+
(v) => (ref = v)
|
|
33
|
+
),
|
|
34
|
+
id: boxWith(() => id),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const mergedProps = $derived(
|
|
38
|
+
mergeProps(restProps, subContentState.props, {
|
|
39
|
+
class: cn(NavigationStylesContext.get().current.subContent(), className),
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
{#if child}
|
|
45
|
+
{@render child({ props: mergedProps, compact: subContentState.root.isCompact })}
|
|
46
|
+
{:else if subContentState.root.isCompact}
|
|
47
|
+
<PopoverPrimitive.Portal>
|
|
48
|
+
<PopoverPrimitive.Content side="right" sideOffset={8} forceMount>
|
|
49
|
+
{#snippet child({ props: childProps, wrapperProps, open })}
|
|
50
|
+
{#if open}
|
|
51
|
+
<div {...wrapperProps}>
|
|
52
|
+
<ul {...childProps} {...mergedProps} transition:fly={{ duration: 250, easing: cubicInOut, x: 10 }}>
|
|
53
|
+
{@render children?.({ compact: subContentState.root.isCompact })}
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
{/if}
|
|
57
|
+
{/snippet}
|
|
58
|
+
</PopoverPrimitive.Content>
|
|
59
|
+
</PopoverPrimitive.Portal>
|
|
60
|
+
{:else}
|
|
61
|
+
<CollapsiblePrimitive.Content {...mergedProps}>
|
|
62
|
+
{#snippet child({ props: childProps, open })}
|
|
63
|
+
{#if open}
|
|
64
|
+
<ul {...childProps} {...mergedProps} transition:fade={{ duration: 250, easing: cubicInOut }}>
|
|
65
|
+
{@render children?.({ compact: subContentState.root.isCompact })}
|
|
66
|
+
</ul>
|
|
67
|
+
{/if}
|
|
68
|
+
{/snippet}
|
|
69
|
+
</CollapsiblePrimitive.Content>
|
|
70
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
2
|
+
import { type WithChild, type WithElementRef, type Without } from 'svelte-toolbelt';
|
|
3
|
+
type NavigationSubContentPropsWithoutHTML = WithElementRef<WithChild<{}, {
|
|
4
|
+
compact: boolean;
|
|
5
|
+
}>>;
|
|
6
|
+
export type NavigationSubContentProps = NavigationSubContentPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationSubContentPropsWithoutHTML>;
|
|
7
|
+
declare const Navigation: import("svelte").Component<NavigationSubContentProps, {}, "ref">;
|
|
8
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
9
|
+
export default Navigation;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { RefAttachment } from '../../../internal/types/common.js';
|
|
2
|
+
import { type ReadableBoxedValues, type WithRefProps } from 'svelte-toolbelt';
|
|
3
|
+
type NavigationRootStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
4
|
+
compact: boolean;
|
|
5
|
+
}>>;
|
|
6
|
+
export declare class NavigationRootState {
|
|
7
|
+
static create(opts: NavigationRootStateOpts): NavigationRootState;
|
|
8
|
+
readonly opts: NavigationRootStateOpts;
|
|
9
|
+
readonly attachment: RefAttachment;
|
|
10
|
+
readonly isCompact: boolean;
|
|
11
|
+
constructor(opts: NavigationRootStateOpts);
|
|
12
|
+
readonly props: {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly "data-slot": "root";
|
|
15
|
+
readonly role: "navigation";
|
|
16
|
+
readonly 'data-compact': boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type NavigationContentStateOpts = WithRefProps<{}>;
|
|
20
|
+
export declare class NavigationContentState {
|
|
21
|
+
static create(opts: NavigationContentStateOpts): NavigationContentState;
|
|
22
|
+
readonly opts: NavigationContentStateOpts;
|
|
23
|
+
readonly attachment: RefAttachment;
|
|
24
|
+
readonly root: NavigationRootState;
|
|
25
|
+
constructor(opts: NavigationContentStateOpts, root: NavigationRootState);
|
|
26
|
+
readonly props: {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly "data-slot": "content";
|
|
29
|
+
readonly role: "list";
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
type NavigationItemStateOpts = WithRefProps<{}>;
|
|
33
|
+
export declare class NavigationItemState {
|
|
34
|
+
#private;
|
|
35
|
+
static create(opts: NavigationItemStateOpts): NavigationItemState;
|
|
36
|
+
readonly opts: NavigationItemStateOpts;
|
|
37
|
+
readonly attachment: RefAttachment;
|
|
38
|
+
readonly root: NavigationRootState;
|
|
39
|
+
constructor(opts: NavigationItemStateOpts, root: NavigationRootState);
|
|
40
|
+
get hasSubContent(): boolean;
|
|
41
|
+
set hasSubContent(value: boolean);
|
|
42
|
+
readonly props: {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly "data-slot": "item";
|
|
45
|
+
readonly 'data-compact': boolean;
|
|
46
|
+
readonly role: "listitem";
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type NavigationTriggerStateOpts = WithRefProps<ReadableBoxedValues<{
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
}>>;
|
|
52
|
+
export declare class NavigationTriggerState {
|
|
53
|
+
static create(opts: NavigationTriggerStateOpts): NavigationTriggerState;
|
|
54
|
+
readonly opts: NavigationTriggerStateOpts;
|
|
55
|
+
readonly attachment: RefAttachment;
|
|
56
|
+
readonly root: NavigationRootState;
|
|
57
|
+
readonly item: NavigationItemState;
|
|
58
|
+
constructor(opts: NavigationTriggerStateOpts, root: NavigationRootState, item: NavigationItemState);
|
|
59
|
+
readonly props: {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly "data-slot": "trigger";
|
|
62
|
+
readonly role: "button";
|
|
63
|
+
readonly tabindex: 0;
|
|
64
|
+
readonly 'data-disabled': "" | undefined;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
type NavigationSubContentStateOpts = WithRefProps<{}>;
|
|
68
|
+
export declare class NavigationSubContentState {
|
|
69
|
+
static create(opts: NavigationSubContentStateOpts): NavigationSubContentState;
|
|
70
|
+
readonly opts: NavigationSubContentStateOpts;
|
|
71
|
+
readonly attachment: RefAttachment;
|
|
72
|
+
readonly root: NavigationRootState;
|
|
73
|
+
readonly item: NavigationItemState;
|
|
74
|
+
constructor(opts: NavigationSubContentStateOpts, root: NavigationRootState, item: NavigationItemState);
|
|
75
|
+
readonly props: {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly "data-slot": "sub-content";
|
|
78
|
+
readonly 'data-compact': boolean;
|
|
79
|
+
readonly role: "list";
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { SLOT_ATTR_NAME } from '../../../internal/constants/attrs.js';
|
|
2
|
+
import { boolAttr } from '../../../internal/utils/attrs.js';
|
|
3
|
+
import { keyWithPrefix } from '../../../internal/utils/common.js';
|
|
4
|
+
import { Context } from 'runed';
|
|
5
|
+
import { attachRef } from 'svelte-toolbelt';
|
|
6
|
+
const NavigationRootStateCtx = new Context(keyWithPrefix('navigation-root'));
|
|
7
|
+
const NavigationItemStateCtx = new Context(keyWithPrefix('navigation-item'));
|
|
8
|
+
const SLOT_ATTR_VALUES = {
|
|
9
|
+
root: 'root',
|
|
10
|
+
content: 'content',
|
|
11
|
+
subContent: 'sub-content',
|
|
12
|
+
item: 'item',
|
|
13
|
+
trigger: 'trigger',
|
|
14
|
+
};
|
|
15
|
+
export class NavigationRootState {
|
|
16
|
+
static create(opts) {
|
|
17
|
+
return NavigationRootStateCtx.set(new NavigationRootState(opts));
|
|
18
|
+
}
|
|
19
|
+
opts;
|
|
20
|
+
attachment;
|
|
21
|
+
isCompact = $derived.by(() => this.opts.compact.current);
|
|
22
|
+
constructor(opts) {
|
|
23
|
+
this.opts = opts;
|
|
24
|
+
this.attachment = attachRef(opts.ref);
|
|
25
|
+
}
|
|
26
|
+
props = $derived.by(() => ({
|
|
27
|
+
id: this.opts.id.current,
|
|
28
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.root,
|
|
29
|
+
role: 'navigation',
|
|
30
|
+
'data-compact': this.isCompact,
|
|
31
|
+
...this.attachment,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
export class NavigationContentState {
|
|
35
|
+
static create(opts) {
|
|
36
|
+
return new NavigationContentState(opts, NavigationRootStateCtx.get());
|
|
37
|
+
}
|
|
38
|
+
opts;
|
|
39
|
+
attachment;
|
|
40
|
+
root;
|
|
41
|
+
constructor(opts, root) {
|
|
42
|
+
this.opts = opts;
|
|
43
|
+
this.root = root;
|
|
44
|
+
this.attachment = attachRef(opts.ref);
|
|
45
|
+
}
|
|
46
|
+
props = $derived.by(() => ({
|
|
47
|
+
id: this.opts.id.current,
|
|
48
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.content,
|
|
49
|
+
role: 'list',
|
|
50
|
+
...this.attachment,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
export class NavigationItemState {
|
|
54
|
+
static create(opts) {
|
|
55
|
+
return NavigationItemStateCtx.set(new NavigationItemState(opts, NavigationRootStateCtx.get()));
|
|
56
|
+
}
|
|
57
|
+
opts;
|
|
58
|
+
attachment;
|
|
59
|
+
root;
|
|
60
|
+
#hasSubContent = $state(false);
|
|
61
|
+
constructor(opts, root) {
|
|
62
|
+
this.opts = opts;
|
|
63
|
+
this.root = root;
|
|
64
|
+
this.attachment = attachRef(opts.ref);
|
|
65
|
+
}
|
|
66
|
+
get hasSubContent() {
|
|
67
|
+
return this.#hasSubContent;
|
|
68
|
+
}
|
|
69
|
+
set hasSubContent(value) {
|
|
70
|
+
this.#hasSubContent = value;
|
|
71
|
+
}
|
|
72
|
+
props = $derived.by(() => ({
|
|
73
|
+
id: this.opts.id.current,
|
|
74
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.item,
|
|
75
|
+
'data-compact': this.root.isCompact,
|
|
76
|
+
role: 'listitem',
|
|
77
|
+
...this.attachment,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
export class NavigationTriggerState {
|
|
81
|
+
static create(opts) {
|
|
82
|
+
return new NavigationTriggerState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get());
|
|
83
|
+
}
|
|
84
|
+
opts;
|
|
85
|
+
attachment;
|
|
86
|
+
root;
|
|
87
|
+
item;
|
|
88
|
+
constructor(opts, root, item) {
|
|
89
|
+
this.opts = opts;
|
|
90
|
+
this.root = root;
|
|
91
|
+
this.item = item;
|
|
92
|
+
this.attachment = attachRef(opts.ref);
|
|
93
|
+
}
|
|
94
|
+
props = $derived.by(() => ({
|
|
95
|
+
id: this.opts.id.current,
|
|
96
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.trigger,
|
|
97
|
+
role: 'button',
|
|
98
|
+
tabindex: 0,
|
|
99
|
+
'data-disabled': boolAttr(this.opts.disabled.current),
|
|
100
|
+
...this.attachment,
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
export class NavigationSubContentState {
|
|
104
|
+
static create(opts) {
|
|
105
|
+
return new NavigationSubContentState(opts, NavigationRootStateCtx.get(), NavigationItemStateCtx.get());
|
|
106
|
+
}
|
|
107
|
+
opts;
|
|
108
|
+
attachment;
|
|
109
|
+
root;
|
|
110
|
+
item;
|
|
111
|
+
constructor(opts, root, item) {
|
|
112
|
+
this.opts = opts;
|
|
113
|
+
this.root = root;
|
|
114
|
+
this.item = item;
|
|
115
|
+
this.attachment = attachRef(opts.ref);
|
|
116
|
+
this.item.hasSubContent = true;
|
|
117
|
+
$effect.pre(() => {
|
|
118
|
+
this.item.hasSubContent = true;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
props = $derived.by(() => ({
|
|
122
|
+
id: this.opts.id.current,
|
|
123
|
+
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.subContent,
|
|
124
|
+
'data-compact': this.root.isCompact,
|
|
125
|
+
role: 'list',
|
|
126
|
+
...this.attachment,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type NavigationTriggerPropsWithoutHTML = WithElementRef<
|
|
3
|
+
WithChild<
|
|
4
|
+
{
|
|
5
|
+
href?: string;
|
|
6
|
+
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
compact: boolean;
|
|
11
|
+
}
|
|
12
|
+
>
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
export type NavigationTriggerProps = NavigationTriggerPropsWithoutHTML &
|
|
16
|
+
Without<PrimitiveElementAttributes, NavigationTriggerPropsWithoutHTML>;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { CollapsiblePrimitive } from '../../collapsible/index.js';
|
|
21
|
+
import ChevronDown from '../../icons/chevron-down.svelte';
|
|
22
|
+
import { NavigationStylesContext } from '../styles.js';
|
|
23
|
+
import { PopoverPrimitive } from '../../popover/index.js';
|
|
24
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
25
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
26
|
+
import type { WithChild, WithElementRef, Without } from 'svelte-toolbelt';
|
|
27
|
+
import { boxWith, mergeProps } from 'svelte-toolbelt';
|
|
28
|
+
import { NavigationTriggerState } from './navigation.svelte.js';
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
ref = $bindable(null),
|
|
32
|
+
id = useId(),
|
|
33
|
+
children,
|
|
34
|
+
child,
|
|
35
|
+
class: className,
|
|
36
|
+
href,
|
|
37
|
+
disabled = false,
|
|
38
|
+
...restProps
|
|
39
|
+
}: NavigationTriggerProps = $props();
|
|
40
|
+
|
|
41
|
+
const triggerState = NavigationTriggerState.create({
|
|
42
|
+
ref: boxWith(
|
|
43
|
+
() => ref,
|
|
44
|
+
(v) => (ref = v)
|
|
45
|
+
),
|
|
46
|
+
id: boxWith(() => id),
|
|
47
|
+
disabled: boxWith(() => disabled),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const mergedProps = $derived(
|
|
51
|
+
mergeProps(restProps, triggerState.props, { class: cn(NavigationStylesContext.get().current.trigger(), className) })
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const sharedProps = $derived({
|
|
55
|
+
compact: triggerState.root.isCompact,
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
{#if child}
|
|
60
|
+
{@render child({ props: mergedProps, ...sharedProps })}
|
|
61
|
+
{:else if href}
|
|
62
|
+
<a {href} {...mergedProps}>
|
|
63
|
+
{@render children?.(sharedProps)}
|
|
64
|
+
</a>
|
|
65
|
+
{:else if triggerState.item.hasSubContent && triggerState.root.isCompact}
|
|
66
|
+
<PopoverPrimitive.Trigger>
|
|
67
|
+
{#snippet child({ props: childProps })}
|
|
68
|
+
<button {...childProps} {...mergedProps} data-type="popover-trigger">
|
|
69
|
+
{@render children?.(sharedProps)}
|
|
70
|
+
</button>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</PopoverPrimitive.Trigger>
|
|
73
|
+
{:else if triggerState.item.hasSubContent && !triggerState.root.isCompact}
|
|
74
|
+
<CollapsiblePrimitive.Trigger>
|
|
75
|
+
{#snippet child({ props: childProps })}
|
|
76
|
+
<button {...childProps} {...mergedProps} data-type="collapsible-trigger">
|
|
77
|
+
{@render children?.(sharedProps)}
|
|
78
|
+
|
|
79
|
+
<span class="cgui:flex cgui:items-center cgui:justify-center cgui:size-5 cgui:shrink-0">
|
|
80
|
+
<ChevronDown width={20} height={20} />
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
{/snippet}
|
|
84
|
+
</CollapsiblePrimitive.Trigger>
|
|
85
|
+
{:else}
|
|
86
|
+
<button {...mergedProps}>
|
|
87
|
+
{@render children?.(sharedProps)}
|
|
88
|
+
</button>
|
|
89
|
+
{/if}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type NavigationTriggerPropsWithoutHTML = WithElementRef<WithChild<{
|
|
2
|
+
href?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
}, {
|
|
5
|
+
compact: boolean;
|
|
6
|
+
}>>;
|
|
7
|
+
export type NavigationTriggerProps = NavigationTriggerPropsWithoutHTML & Without<PrimitiveElementAttributes, NavigationTriggerPropsWithoutHTML>;
|
|
8
|
+
import type { PrimitiveElementAttributes } from '../../../internal/types/html-attributes.js';
|
|
9
|
+
import type { WithChild, WithElementRef, Without } from 'svelte-toolbelt';
|
|
10
|
+
declare const Navigation: import("svelte").Component<NavigationTriggerProps, {}, "ref">;
|
|
11
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
12
|
+
export default Navigation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type NavigationContentProps } from './components/navigation.content.svelte';
|
|
2
|
+
import { type NavigationItemProps } from './components/navigation.item.svelte';
|
|
3
|
+
import { type NavigationRootProps } from './components/navigation.root.svelte';
|
|
4
|
+
import { type NavigationSubContentProps } from './components/navigation.sub-content.svelte';
|
|
5
|
+
export declare const NavigationPrimitive: {
|
|
6
|
+
readonly Root: import("svelte").Component<NavigationRootProps, {}, "ref">;
|
|
7
|
+
readonly Trigger: import("svelte").Component<import("./components/navigation.trigger.svelte").NavigationTriggerProps, {}, "ref">;
|
|
8
|
+
readonly Content: import("svelte").Component<NavigationContentProps, {}, "ref">;
|
|
9
|
+
readonly Item: import("svelte").Component<NavigationItemProps, {}, "ref">;
|
|
10
|
+
readonly SubContent: import("svelte").Component<NavigationSubContentProps, {}, "ref">;
|
|
11
|
+
};
|
|
12
|
+
export type { NavigationContentProps, NavigationItemProps, NavigationRootProps, NavigationSubContentProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Content, {} from './components/navigation.content.svelte';
|
|
2
|
+
import Item, {} from './components/navigation.item.svelte';
|
|
3
|
+
import Root, {} from './components/navigation.root.svelte';
|
|
4
|
+
import SubContent, {} from './components/navigation.sub-content.svelte';
|
|
5
|
+
import Trigger from './components/navigation.trigger.svelte';
|
|
6
|
+
export const NavigationPrimitive = {
|
|
7
|
+
Root,
|
|
8
|
+
Trigger,
|
|
9
|
+
Content,
|
|
10
|
+
Item,
|
|
11
|
+
SubContent,
|
|
12
|
+
};
|