@casinogate/ui 1.3.7 → 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.
@@ -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,6 +432,9 @@
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
  }
@@ -459,6 +465,9 @@
459
465
  --tw-scale-x: calc(1 * -1);
460
466
  scale: var(--tw-scale-x) var(--tw-scale-y);
461
467
  }
468
+ .cgui\:rotate-180 {
469
+ rotate: 180deg;
470
+ }
462
471
  .cgui\:animate-pulse {
463
472
  animation: var(--cgui-animate-pulse);
464
473
  }
@@ -492,9 +501,6 @@
492
501
  .cgui\:items-stretch {
493
502
  align-items: stretch;
494
503
  }
495
- .cgui\:justify-between {
496
- justify-content: space-between;
497
- }
498
504
  .cgui\:justify-center {
499
505
  justify-content: center;
500
506
  }
@@ -867,6 +873,9 @@
867
873
  .cgui\:underline {
868
874
  text-decoration-line: underline;
869
875
  }
876
+ .cgui\:opacity-0 {
877
+ opacity: 0%;
878
+ }
870
879
  .cgui\:opacity-50 {
871
880
  opacity: 50%;
872
881
  }
@@ -1373,6 +1382,19 @@
1373
1382
  border-color: var(--cg-ui-palette-primary-80);
1374
1383
  }
1375
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
+ }
1376
1398
  .cgui\:data-\[compact\=false\]\:\[\&_\[data-slot\=\"trigger\"\]\]\:pl-0 {
1377
1399
  &[data-compact="false"] {
1378
1400
  & [data-slot="trigger"] {
@@ -1611,6 +1633,9 @@
1611
1633
  --cg-ui-palette-system-info-100: hsla(232, 22%, 29%, 1);
1612
1634
  --cg-ui-palette-system-info-10: hsla(240, 12%, 93%, 1);
1613
1635
  }
1636
+ :root {
1637
+ interpolate-size: allow-keywords;
1638
+ }
1614
1639
  @layer base {
1615
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 {
1616
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)} {...restProps}>
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.props}>
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
+ }>;
@@ -12,10 +12,10 @@
12
12
  let {
13
13
  ref = $bindable(null),
14
14
  id = useId(uid),
15
+ compact = $bindable(false),
15
16
  children,
16
17
  child,
17
18
  class: className,
18
- compact = false,
19
19
  ...restProps
20
20
  }: NavigationRootProps = $props();
21
21
 
@@ -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
- constructor(opts: NavigationTriggerStateOpts, root: NavigationRootState, item: NavigationItemState);
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
- constructor(opts, root, item) {
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 triggerState = NavigationTriggerState.create({
25
- ref: boxWith(
26
- () => ref,
27
- (v) => (ref = v)
28
- ),
29
- id: boxWith(() => id),
30
- disabled: boxWith(() => disabled),
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
- {#if child}
43
- {@render child({ props: mergedProps, ...sharedProps })}
44
- {:else if href}
45
- <a {href} {...mergedProps}>
46
- {@render children?.(sharedProps)}
47
- </a>
48
- {:else if triggerState.item.hasSubContent && triggerState.root.isCompact}
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 children?.(sharedProps)}
80
+ {@render content?.()}
53
81
  </button>
54
82
  {/snippet}
55
83
  </PopoverPrimitive.Trigger>
56
- {:else if triggerState.item.hasSubContent && !triggerState.root.isCompact}
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 children?.(sharedProps)}
90
+ {@render content?.()}
61
91
 
62
- <span class="cgui:flex cgui:items-center cgui:justify-center cgui:size-5 cgui:shrink-0">
63
- <ChevronDown width={20} height={20} />
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
- {:else}
106
+ {/snippet}
107
+
108
+ {#snippet buttonTrigger()}
69
109
  <button {...mergedProps}>
70
- {@render children?.(sharedProps)}
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 Navigation } from './navigation.svelte';
1
+ export { default as Root } from './navigation.svelte';
@@ -1 +1 @@
1
- export { default as Navigation } from './navigation.svelte';
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
- id: 1,
32
+ key: 1,
38
33
  label: 'Item 1',
34
+ icon: Icon.Info,
35
+ href: '#',
39
36
  },
40
37
  {
41
- id: 2,
38
+ key: 2,
42
39
  label: 'Item 2',
40
+ icon: Icon.Info,
41
+ href: '#',
43
42
  },
44
43
  {
45
- id: 3,
44
+ key: 3,
46
45
  label: 'Item 3',
46
+ icon: Icon.Info,
47
47
  children: [
48
48
  {
49
- id: 4,
49
+ key: 4,
50
50
  label: 'Sub Item 1',
51
+ href: '#',
51
52
  },
52
53
  {
53
- id: 5,
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>{item.label}</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>{child.label}</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" module></script>
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
- <script lang="ts"></script>
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
- 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
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
- $$bindings?: Bindings;
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: never[];
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: never[];
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: never[];
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-1.5 cgui:justify-between',
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 { WithChild, WithElementRef, Without } from 'svelte-toolbelt';
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casinogate/ui",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
4
4
  "svelte": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",