@casinogate/ui 0.0.3
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/README.md +171 -0
- package/dist/app.d.ts +15 -0
- package/dist/app.html +12 -0
- package/dist/assets/css/root.css +1057 -0
- package/dist/assets/css/theme.css +255 -0
- package/dist/assets/icons/check.svg +4 -0
- package/dist/assets/icons/chevron-down.svg +4 -0
- package/dist/assets/icons/chevron-left.svg +4 -0
- package/dist/assets/icons/chevron-right.svg +4 -0
- package/dist/assets/icons/chevron-small-down.svg +4 -0
- package/dist/assets/icons/chevron-small-left.svg +4 -0
- package/dist/assets/icons/chevron-small-right.svg +4 -0
- package/dist/assets/icons/chevron-small-up.svg +4 -0
- package/dist/assets/icons/chevron-up.svg +4 -0
- package/dist/assets/icons/error.svg +4 -0
- package/dist/assets/icons/info.svg +4 -0
- package/dist/assets/icons/minus.svg +4 -0
- package/dist/assets/icons/success.svg +4 -0
- package/dist/assets/icons/warning.svg +3 -0
- package/dist/components/button/button.component.svelte +173 -0
- package/dist/components/button/button.component.svelte.d.ts +239 -0
- package/dist/components/button/button.stories.svelte +106 -0
- package/dist/components/button/button.stories.svelte.d.ts +19 -0
- package/dist/components/button/index.d.ts +233 -0
- package/dist/components/button/index.js +4 -0
- package/dist/components/checkbox/checkbox.stories.svelte +52 -0
- package/dist/components/checkbox/checkbox.stories.svelte.d.ts +18 -0
- package/dist/components/checkbox/components/checkbox.group.svelte +3 -0
- package/dist/components/checkbox/components/checkbox.group.svelte.d.ts +18 -0
- package/dist/components/checkbox/components/checkbox.root.svelte +51 -0
- package/dist/components/checkbox/components/checkbox.root.svelte.d.ts +6 -0
- package/dist/components/checkbox/index.js +6 -0
- package/dist/components/checkbox/model/checkbox-model.svelte.d.ts +16 -0
- package/dist/components/checkbox/model/checkbox-model.svelte.js +25 -0
- package/dist/components/checkbox/model/index.d.ts +1 -0
- package/dist/components/checkbox/model/index.js +1 -0
- package/dist/components/checkbox/styles.d.ts +126 -0
- package/dist/components/checkbox/styles.js +60 -0
- package/dist/components/collapsible/collapsible.stories.svelte +53 -0
- package/dist/components/collapsible/collapsible.stories.svelte.d.ts +18 -0
- package/dist/components/collapsible/components/collapsaible.content.svelte +40 -0
- package/dist/components/collapsible/components/collapsaible.content.svelte.d.ts +5 -0
- package/dist/components/collapsible/components/collapsaible.group.svelte +0 -0
- package/dist/components/collapsible/components/collapsaible.group.svelte.d.ts +26 -0
- package/dist/components/collapsible/components/collapsaible.root.svelte +62 -0
- package/dist/components/collapsible/components/collapsaible.root.svelte.d.ts +5 -0
- package/dist/components/collapsible/components/collapsaible.svelte.d.ts +44 -0
- package/dist/components/collapsible/components/collapsaible.svelte.js +92 -0
- package/dist/components/collapsible/components/collapsaible.trigger.svelte +50 -0
- package/dist/components/collapsible/components/collapsaible.trigger.svelte.d.ts +8 -0
- package/dist/components/collapsible/index.d.ts +9 -0
- package/dist/components/collapsible/index.js +8 -0
- package/dist/components/collapsible/styles.d.ts +178 -0
- package/dist/components/collapsible/styles.js +27 -0
- package/dist/components/collapsible/types.d.ts +1 -0
- package/dist/components/collapsible/types.js +1 -0
- package/dist/components/switch/components/switch.root.svelte +27 -0
- package/dist/components/switch/components/switch.root.svelte.d.ts +6 -0
- package/dist/components/switch/components/switch.thumb.svelte +17 -0
- package/dist/components/switch/components/switch.thumb.svelte.d.ts +5 -0
- package/dist/components/switch/index.d.ts +5 -0
- package/dist/components/switch/index.js +7 -0
- package/dist/components/switch/model/index.d.ts +1 -0
- package/dist/components/switch/model/index.js +1 -0
- package/dist/components/switch/model/switch-model.svelte.d.ts +12 -0
- package/dist/components/switch/model/switch-model.svelte.js +18 -0
- package/dist/components/switch/styles.d.ts +74 -0
- package/dist/components/switch/styles.js +44 -0
- package/dist/components/switch/switch.stories.svelte +48 -0
- package/dist/components/switch/switch.stories.svelte.d.ts +18 -0
- package/dist/components/toast/toast.component.svelte +149 -0
- package/dist/components/toast/toast.component.svelte.d.ts +158 -0
- package/dist/components/toast/toast.stories.svelte +96 -0
- package/dist/components/toast/toast.stories.svelte.d.ts +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/types/attrs.d.ts +1 -0
- package/dist/internal/types/attrs.js +3 -0
- package/dist/internal/types/common.d.ts +25 -0
- package/dist/internal/types/common.js +1 -0
- package/dist/internal/types/composition.d.ts +45 -0
- package/dist/internal/types/composition.js +1 -0
- package/dist/internal/types/html-attributes.d.ts +48 -0
- package/dist/internal/types/html-attributes.js +1 -0
- package/dist/internal/utils/arrays.d.ts +1 -0
- package/dist/internal/utils/arrays.js +30 -0
- package/dist/internal/utils/common.d.ts +6 -0
- package/dist/internal/utils/common.js +9 -0
- package/dist/internal/utils/tailwindcss.d.ts +3 -0
- package/dist/internal/utils/tailwindcss.js +29 -0
- package/package.json +75 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type CollapsibleTriggerProps = CollapsibleTriggerPropsPrimitive & {
|
|
3
|
+
icon?: Snippet;
|
|
4
|
+
};
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import ChevronSmallRightIcon from '../../../assets/icons/chevron-small-right.svg?component';
|
|
9
|
+
import { CollapsibleStylesContext } from '../styles.js';
|
|
10
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
Collapsible as CollapsiblePrimitive,
|
|
14
|
+
useId,
|
|
15
|
+
type CollapsibleTriggerProps as CollapsibleTriggerPropsPrimitive,
|
|
16
|
+
} from 'bits-ui';
|
|
17
|
+
import type { Snippet } from 'svelte';
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
ref = $bindable(null),
|
|
21
|
+
id = useId(),
|
|
22
|
+
class: className,
|
|
23
|
+
child: childSnippet,
|
|
24
|
+
children: childrenSnippet,
|
|
25
|
+
icon: iconSnippet,
|
|
26
|
+
...restProps
|
|
27
|
+
}: CollapsibleTriggerProps = $props();
|
|
28
|
+
|
|
29
|
+
const styles = CollapsibleStylesContext.get();
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<CollapsiblePrimitive.Trigger bind:ref {id} class={cn(styles.current.trigger(), className)} {...restProps}>
|
|
33
|
+
{#snippet child(childProps)}
|
|
34
|
+
{#if childSnippet}
|
|
35
|
+
{@render childSnippet?.(childProps)}
|
|
36
|
+
{:else}
|
|
37
|
+
<button {...childProps.props}>
|
|
38
|
+
<span data-slot="icon" class={styles.current.icon()}>
|
|
39
|
+
{#if iconSnippet}
|
|
40
|
+
{@render iconSnippet?.()}
|
|
41
|
+
{:else}
|
|
42
|
+
<ChevronSmallRightIcon />
|
|
43
|
+
{/if}
|
|
44
|
+
</span>
|
|
45
|
+
|
|
46
|
+
{@render childrenSnippet?.()}
|
|
47
|
+
</button>
|
|
48
|
+
{/if}
|
|
49
|
+
{/snippet}
|
|
50
|
+
</CollapsiblePrimitive.Trigger>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CollapsibleTriggerProps = CollapsibleTriggerPropsPrimitive & {
|
|
2
|
+
icon?: Snippet;
|
|
3
|
+
};
|
|
4
|
+
import { type CollapsibleTriggerProps as CollapsibleTriggerPropsPrimitive } from 'bits-ui';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
declare const Collapsaible: import("svelte").Component<CollapsibleTriggerProps, {}, "ref">;
|
|
7
|
+
type Collapsaible = ReturnType<typeof Collapsaible>;
|
|
8
|
+
export default Collapsaible;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CollapsibleContentProps } from './components/collapsaible.content.svelte';
|
|
2
|
+
import { type CollapsibleRootProps } from './components/collapsaible.root.svelte';
|
|
3
|
+
import { type CollapsibleTriggerProps } from './components/collapsaible.trigger.svelte';
|
|
4
|
+
export declare const CollapsiblePrimitive: {
|
|
5
|
+
Root: import("svelte").Component<import("bits-ui").CollapsibleRootProps, {}, "ref" | "open">;
|
|
6
|
+
Trigger: import("svelte").Component<CollapsibleTriggerProps, {}, "ref">;
|
|
7
|
+
Content: import("svelte").Component<import("bits-ui").CollapsibleContentProps, {}, "ref">;
|
|
8
|
+
};
|
|
9
|
+
export type { CollapsibleContentProps, CollapsibleRootProps, CollapsibleTriggerProps };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Content, {} from './components/collapsaible.content.svelte';
|
|
2
|
+
import Root, {} from './components/collapsaible.root.svelte';
|
|
3
|
+
import Trigger, {} from './components/collapsaible.trigger.svelte';
|
|
4
|
+
export const CollapsiblePrimitive = {
|
|
5
|
+
Root,
|
|
6
|
+
Trigger,
|
|
7
|
+
Content,
|
|
8
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Context } from 'runed';
|
|
2
|
+
import type { ReadableBox } from 'svelte-toolbelt';
|
|
3
|
+
import type { VariantProps } from 'tailwind-variants';
|
|
4
|
+
export declare const collapsibleVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
[key: string]: {
|
|
6
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
7
|
+
content?: import("tailwind-variants").ClassValue;
|
|
8
|
+
root?: import("tailwind-variants").ClassValue;
|
|
9
|
+
trigger?: import("tailwind-variants").ClassValue;
|
|
10
|
+
icon?: import("tailwind-variants").ClassValue;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
[x: string]: {
|
|
15
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
16
|
+
content?: import("tailwind-variants").ClassValue;
|
|
17
|
+
root?: import("tailwind-variants").ClassValue;
|
|
18
|
+
trigger?: import("tailwind-variants").ClassValue;
|
|
19
|
+
icon?: import("tailwind-variants").ClassValue;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
} | {}, {
|
|
23
|
+
root: string[];
|
|
24
|
+
trigger: string[];
|
|
25
|
+
icon: string[];
|
|
26
|
+
content: string[];
|
|
27
|
+
}, undefined, {
|
|
28
|
+
[key: string]: {
|
|
29
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
30
|
+
content?: import("tailwind-variants").ClassValue;
|
|
31
|
+
root?: import("tailwind-variants").ClassValue;
|
|
32
|
+
trigger?: import("tailwind-variants").ClassValue;
|
|
33
|
+
icon?: import("tailwind-variants").ClassValue;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
} | {}, {
|
|
37
|
+
root: string[];
|
|
38
|
+
trigger: string[];
|
|
39
|
+
icon: string[];
|
|
40
|
+
content: string[];
|
|
41
|
+
}, import("tailwind-variants").TVReturnType<unknown, {
|
|
42
|
+
root: string[];
|
|
43
|
+
trigger: string[];
|
|
44
|
+
icon: string[];
|
|
45
|
+
content: string[];
|
|
46
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
47
|
+
export type CollapsibleVariantsProps = VariantProps<typeof collapsibleVariants>;
|
|
48
|
+
export declare const CollapsibleStylesContext: Context<ReadableBox<{
|
|
49
|
+
root: (slotProps?: ({
|
|
50
|
+
[x: string]: string | number | undefined;
|
|
51
|
+
[x: number]: string | number | undefined;
|
|
52
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
53
|
+
[x: string]: string | number | undefined;
|
|
54
|
+
[x: number]: string | number | undefined;
|
|
55
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
56
|
+
[x: string]: string | number | undefined;
|
|
57
|
+
[x: number]: string | number | undefined;
|
|
58
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
59
|
+
[x: string]: string | number | undefined;
|
|
60
|
+
[x: number]: string | number | undefined;
|
|
61
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
62
|
+
[x: string]: string | number | undefined;
|
|
63
|
+
[x: number]: string | number | undefined;
|
|
64
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
65
|
+
trigger: (slotProps?: ({
|
|
66
|
+
[x: string]: string | number | undefined;
|
|
67
|
+
[x: number]: string | number | undefined;
|
|
68
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
69
|
+
[x: string]: string | number | undefined;
|
|
70
|
+
[x: number]: string | number | undefined;
|
|
71
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
72
|
+
[x: string]: string | number | undefined;
|
|
73
|
+
[x: number]: string | number | undefined;
|
|
74
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
75
|
+
[x: string]: string | number | undefined;
|
|
76
|
+
[x: number]: string | number | undefined;
|
|
77
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
78
|
+
[x: string]: string | number | undefined;
|
|
79
|
+
[x: number]: string | number | undefined;
|
|
80
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
81
|
+
icon: (slotProps?: ({
|
|
82
|
+
[x: string]: string | number | undefined;
|
|
83
|
+
[x: number]: string | number | undefined;
|
|
84
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
85
|
+
[x: string]: string | number | undefined;
|
|
86
|
+
[x: number]: string | number | undefined;
|
|
87
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
88
|
+
[x: string]: string | number | undefined;
|
|
89
|
+
[x: number]: string | number | undefined;
|
|
90
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
91
|
+
[x: string]: string | number | undefined;
|
|
92
|
+
[x: number]: string | number | undefined;
|
|
93
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
94
|
+
[x: string]: string | number | undefined;
|
|
95
|
+
[x: number]: string | number | undefined;
|
|
96
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
97
|
+
content: (slotProps?: ({
|
|
98
|
+
[x: string]: string | number | undefined;
|
|
99
|
+
[x: number]: string | number | undefined;
|
|
100
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
101
|
+
[x: string]: string | number | undefined;
|
|
102
|
+
[x: number]: string | number | undefined;
|
|
103
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
104
|
+
[x: string]: string | number | undefined;
|
|
105
|
+
[x: number]: string | number | undefined;
|
|
106
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
107
|
+
[x: string]: string | number | undefined;
|
|
108
|
+
[x: number]: string | number | undefined;
|
|
109
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
110
|
+
[x: string]: string | number | undefined;
|
|
111
|
+
[x: number]: string | number | undefined;
|
|
112
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
113
|
+
} & {
|
|
114
|
+
root: (slotProps?: ({
|
|
115
|
+
[x: string]: string | number | undefined;
|
|
116
|
+
[x: number]: string | number | undefined;
|
|
117
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
118
|
+
[x: string]: string | number | undefined;
|
|
119
|
+
[x: number]: string | number | undefined;
|
|
120
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
121
|
+
[x: string]: string | number | undefined;
|
|
122
|
+
[x: number]: string | number | undefined;
|
|
123
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
124
|
+
[x: string]: string | number | undefined;
|
|
125
|
+
[x: number]: string | number | undefined;
|
|
126
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
127
|
+
[x: string]: string | number | undefined;
|
|
128
|
+
[x: number]: string | number | undefined;
|
|
129
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
130
|
+
trigger: (slotProps?: ({
|
|
131
|
+
[x: string]: string | number | undefined;
|
|
132
|
+
[x: number]: string | number | undefined;
|
|
133
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
134
|
+
[x: string]: string | number | undefined;
|
|
135
|
+
[x: number]: string | number | undefined;
|
|
136
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
137
|
+
[x: string]: string | number | undefined;
|
|
138
|
+
[x: number]: string | number | undefined;
|
|
139
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
140
|
+
[x: string]: string | number | undefined;
|
|
141
|
+
[x: number]: string | number | undefined;
|
|
142
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
143
|
+
[x: string]: string | number | undefined;
|
|
144
|
+
[x: number]: string | number | undefined;
|
|
145
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
146
|
+
icon: (slotProps?: ({
|
|
147
|
+
[x: string]: string | number | undefined;
|
|
148
|
+
[x: number]: string | number | undefined;
|
|
149
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
150
|
+
[x: string]: string | number | undefined;
|
|
151
|
+
[x: number]: string | number | undefined;
|
|
152
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
153
|
+
[x: string]: string | number | undefined;
|
|
154
|
+
[x: number]: string | number | undefined;
|
|
155
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
156
|
+
[x: string]: string | number | undefined;
|
|
157
|
+
[x: number]: string | number | undefined;
|
|
158
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
159
|
+
[x: string]: string | number | undefined;
|
|
160
|
+
[x: number]: string | number | undefined;
|
|
161
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
162
|
+
content: (slotProps?: ({
|
|
163
|
+
[x: string]: string | number | undefined;
|
|
164
|
+
[x: number]: string | number | undefined;
|
|
165
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
166
|
+
[x: string]: string | number | undefined;
|
|
167
|
+
[x: number]: string | number | undefined;
|
|
168
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
169
|
+
[x: string]: string | number | undefined;
|
|
170
|
+
[x: number]: string | number | undefined;
|
|
171
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
172
|
+
[x: string]: string | number | undefined;
|
|
173
|
+
[x: number]: string | number | undefined;
|
|
174
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
|
|
175
|
+
[x: string]: string | number | undefined;
|
|
176
|
+
[x: number]: string | number | undefined;
|
|
177
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
178
|
+
} & {}>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { keyWithPrefix } from '../../internal/utils/common.js';
|
|
2
|
+
import { tv } from '../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Context } from 'runed';
|
|
4
|
+
export const collapsibleVariants = tv({
|
|
5
|
+
slots: {
|
|
6
|
+
root: [
|
|
7
|
+
'cgui:relative cgui:overflow-hidden',
|
|
8
|
+
'cgui:w-full',
|
|
9
|
+
'cgui:bg-surface-lightest',
|
|
10
|
+
'cgui:border cgui:border-stroke-divider cgui:rounded-sm',
|
|
11
|
+
'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
|
+
'cgui:data-[disabled]:opacity-50 cgui:data-[disabled]:cursor-not-allowed cgui:data-[disabled]:pointer-events-none',
|
|
14
|
+
],
|
|
15
|
+
trigger: [
|
|
16
|
+
'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:text-fg-darkest cgui:font-normal cgui:text-body-2',
|
|
18
|
+
'cgui:data-[state=open]:[&_[data-slot=icon]]:rotate-90',
|
|
19
|
+
],
|
|
20
|
+
icon: [
|
|
21
|
+
'cgui:relative cgui:inline-flex cgui:size-6 cgui:items-center cgui:justify-center cgui:shrink-0 cgui:text-icon-regular',
|
|
22
|
+
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
23
|
+
],
|
|
24
|
+
content: ['cgui:px-2 cgui:pb-1.5', 'cgui:text-fg-medium cgui:text-body-2'],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
export const CollapsibleStylesContext = new Context(keyWithPrefix('collapsible-styles'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CollapsibleOpenVariant = 'single' | 'multiple';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type SwitchRootProps = SwitchRootPropsPrimitive & SwitchVariantsProps;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { box } from 'svelte-toolbelt';
|
|
7
|
+
|
|
8
|
+
import { SwitchStylesContext, switchVariants, type SwitchVariantsProps } from '../styles.js';
|
|
9
|
+
|
|
10
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
11
|
+
import { Switch as SwitchPrimitive, useId, type SwitchRootProps as SwitchRootPropsPrimitive } from 'bits-ui';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
id = useId(),
|
|
15
|
+
ref = $bindable(null),
|
|
16
|
+
checked = $bindable(false),
|
|
17
|
+
size = 'md',
|
|
18
|
+
class: className,
|
|
19
|
+
...props
|
|
20
|
+
}: SwitchRootProps = $props();
|
|
21
|
+
|
|
22
|
+
const variants = $derived(switchVariants({ size }));
|
|
23
|
+
|
|
24
|
+
SwitchStylesContext.set(box.with(() => variants));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<SwitchPrimitive.Root bind:ref bind:checked {id} class={cn(variants.root(), className)} {...props} />
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SwitchRootProps = SwitchRootPropsPrimitive & SwitchVariantsProps;
|
|
2
|
+
import { type SwitchVariantsProps } from '../styles.js';
|
|
3
|
+
import { type SwitchRootProps as SwitchRootPropsPrimitive } from 'bits-ui';
|
|
4
|
+
declare const Switch: import("svelte").Component<SwitchRootProps, {}, "ref" | "checked">;
|
|
5
|
+
type Switch = ReturnType<typeof Switch>;
|
|
6
|
+
export default Switch;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type SwitchThumbProps = SwitchThumbPropsPrimitive;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
7
|
+
|
|
8
|
+
import { SwitchStylesContext } from '../styles.js';
|
|
9
|
+
|
|
10
|
+
import { Switch as SwitchPrimitive, useId, type SwitchThumbProps as SwitchThumbPropsPrimitive } from 'bits-ui';
|
|
11
|
+
|
|
12
|
+
let { ref = $bindable(null), id = useId(), class: className, ...props }: SwitchThumbProps = $props();
|
|
13
|
+
|
|
14
|
+
const styles = SwitchStylesContext.get();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<SwitchPrimitive.Thumb bind:ref {id} class={cn(styles.current.thumb(), className)} {...props} />
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SwitchThumbProps = SwitchThumbPropsPrimitive;
|
|
2
|
+
import { Switch as SwitchPrimitive, type SwitchThumbProps as SwitchThumbPropsPrimitive } from 'bits-ui';
|
|
3
|
+
declare const Switch: import("svelte").Component<SwitchPrimitive.ThumbProps, {}, "ref">;
|
|
4
|
+
type Switch = ReturnType<typeof Switch>;
|
|
5
|
+
export default Switch;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const SwitchPrimitive: {
|
|
2
|
+
Root: import("svelte").Component<import("./components/switch.root.svelte").SwitchRootProps, {}, "ref" | "checked">;
|
|
3
|
+
Thumb: import("svelte").Component<import("bits-ui").SwitchThumbProps, {}, "ref">;
|
|
4
|
+
};
|
|
5
|
+
export declare const Switch: {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSwitchModel, SwitchModel } from './switch-model.svelte.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSwitchModel, SwitchModel } from './switch-model.svelte.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SwitchModelOpts = {
|
|
2
|
+
defaultChecked?: boolean;
|
|
3
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare class SwitchModel {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(opts?: SwitchModelOpts);
|
|
8
|
+
get checked(): boolean;
|
|
9
|
+
set checked(value: boolean);
|
|
10
|
+
}
|
|
11
|
+
export declare const createSwitchModel: (opts?: SwitchModelOpts) => SwitchModel;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class SwitchModel {
|
|
2
|
+
#opts;
|
|
3
|
+
#checked = $state(false);
|
|
4
|
+
constructor(opts = {}) {
|
|
5
|
+
this.#opts = opts;
|
|
6
|
+
this.#checked = this.#opts.defaultChecked ?? false;
|
|
7
|
+
}
|
|
8
|
+
get checked() {
|
|
9
|
+
return this.#checked;
|
|
10
|
+
}
|
|
11
|
+
set checked(value) {
|
|
12
|
+
this.#checked = value;
|
|
13
|
+
this.#opts.onCheckedChange?.(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const createSwitchModel = (opts = {}) => {
|
|
17
|
+
return new SwitchModel(opts);
|
|
18
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Context } from 'runed';
|
|
2
|
+
import type { ReadableBox } from 'svelte-toolbelt';
|
|
3
|
+
import type { VariantProps } from 'tailwind-variants';
|
|
4
|
+
export declare const switchVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
size: {
|
|
6
|
+
sm: {
|
|
7
|
+
root: string[];
|
|
8
|
+
thumb: string[];
|
|
9
|
+
};
|
|
10
|
+
md: {
|
|
11
|
+
root: string[];
|
|
12
|
+
thumb: string[];
|
|
13
|
+
};
|
|
14
|
+
lg: {
|
|
15
|
+
root: string[];
|
|
16
|
+
thumb: string[];
|
|
17
|
+
};
|
|
18
|
+
xl: {
|
|
19
|
+
root: string[];
|
|
20
|
+
thumb: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
root: string[];
|
|
25
|
+
thumb: string[];
|
|
26
|
+
}, undefined, {
|
|
27
|
+
size: {
|
|
28
|
+
sm: {
|
|
29
|
+
root: string[];
|
|
30
|
+
thumb: string[];
|
|
31
|
+
};
|
|
32
|
+
md: {
|
|
33
|
+
root: string[];
|
|
34
|
+
thumb: string[];
|
|
35
|
+
};
|
|
36
|
+
lg: {
|
|
37
|
+
root: string[];
|
|
38
|
+
thumb: string[];
|
|
39
|
+
};
|
|
40
|
+
xl: {
|
|
41
|
+
root: string[];
|
|
42
|
+
thumb: string[];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
root: string[];
|
|
47
|
+
thumb: string[];
|
|
48
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
49
|
+
size: {
|
|
50
|
+
sm: {
|
|
51
|
+
root: string[];
|
|
52
|
+
thumb: string[];
|
|
53
|
+
};
|
|
54
|
+
md: {
|
|
55
|
+
root: string[];
|
|
56
|
+
thumb: string[];
|
|
57
|
+
};
|
|
58
|
+
lg: {
|
|
59
|
+
root: string[];
|
|
60
|
+
thumb: string[];
|
|
61
|
+
};
|
|
62
|
+
xl: {
|
|
63
|
+
root: string[];
|
|
64
|
+
thumb: string[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
root: string[];
|
|
69
|
+
thumb: string[];
|
|
70
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
71
|
+
export type SwitchVariantsProps = VariantProps<typeof switchVariants>;
|
|
72
|
+
type SwitchStylesContextValues = ReadableBox<ReturnType<typeof switchVariants>>;
|
|
73
|
+
export declare const SwitchStylesContext: Context<SwitchStylesContextValues>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tv } from '../../internal/utils/tailwindcss.js';
|
|
2
|
+
import { Context } from 'runed';
|
|
3
|
+
import { keyWithPrefix } from './../../internal/utils/common.js';
|
|
4
|
+
export const switchVariants = tv({
|
|
5
|
+
slots: {
|
|
6
|
+
root: [
|
|
7
|
+
'cgui:relative cgui:overflow-hidden',
|
|
8
|
+
'cgui:flex cgui:items-center cgui:p-0.5',
|
|
9
|
+
'cgui:bg-surface-regular cgui:rounded-xl',
|
|
10
|
+
'cgui:transition-all cgui:duration-300 cgui:ease-in-out',
|
|
11
|
+
'cgui:cursor-pointer cgui:select-none',
|
|
12
|
+
'cgui:data-[state=checked]:bg-surface-primary',
|
|
13
|
+
'cgui:active:[&_span]:w-2/3 cgui:active:data-[state=checked]:[&_span]:translate-x-[calc(44%+2px)]',
|
|
14
|
+
'cgui:disabled:opacity-50 cgui:disabled:cursor-not-allowed cgui:disabled:pointer-events-none',
|
|
15
|
+
],
|
|
16
|
+
thumb: [
|
|
17
|
+
'cgui:relative',
|
|
18
|
+
'cgui:h-full cgui:rounded-full cgui:bg-surface-light',
|
|
19
|
+
'cgui:transition-all cgui:duration-300 cgui:ease-in-out',
|
|
20
|
+
'cgui:data-[state=checked]:translate-x-full cgui:data-[state=checked]:shadow-switch-thumb',
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
variants: {
|
|
24
|
+
size: {
|
|
25
|
+
sm: {
|
|
26
|
+
root: ['cgui:h-3.5 cgui:w-6'],
|
|
27
|
+
thumb: ['cgui:w-2.5'],
|
|
28
|
+
},
|
|
29
|
+
md: {
|
|
30
|
+
root: ['cgui:h-4 cgui:w-7.5'],
|
|
31
|
+
thumb: ['cgui:w-3', 'cgui:data-[state=checked]:translate-x-[calc(100%+2px)]'],
|
|
32
|
+
},
|
|
33
|
+
lg: {
|
|
34
|
+
root: ['cgui:h-5 cgui:w-9'],
|
|
35
|
+
thumb: ['cgui:w-4'],
|
|
36
|
+
},
|
|
37
|
+
xl: {
|
|
38
|
+
root: ['cgui:h-6 cgui:w-11'],
|
|
39
|
+
thumb: ['cgui:w-5'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
export const SwitchStylesContext = new Context(keyWithPrefix('switch-styles'));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { defineMeta } from '../../storybook/addon-svelte-csf';
|
|
3
|
+
import type { Parameters } from '../../storybook/sveltekit';
|
|
4
|
+
|
|
5
|
+
import type { ComponentProps } from 'svelte';
|
|
6
|
+
import SwitchRoot from './components/switch.root.svelte';
|
|
7
|
+
import SwitchThumb from './components/switch.thumb.svelte';
|
|
8
|
+
|
|
9
|
+
const parameters: Parameters = {
|
|
10
|
+
controls: {
|
|
11
|
+
include: ['size', 'disabled', 'checked'],
|
|
12
|
+
},
|
|
13
|
+
layout: 'centered',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const { Story } = defineMeta({
|
|
17
|
+
title: 'UI Kit/Switch',
|
|
18
|
+
component: SwitchRoot,
|
|
19
|
+
render: template,
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
|
|
22
|
+
argTypes: {
|
|
23
|
+
checked: {
|
|
24
|
+
table: {
|
|
25
|
+
defaultValue: { summary: 'false' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
parameters,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
type Args = ComponentProps<typeof SwitchRoot>;
|
|
34
|
+
|
|
35
|
+
const args: Args = {
|
|
36
|
+
size: 'md',
|
|
37
|
+
checked: false,
|
|
38
|
+
disabled: false,
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#snippet template(args: Args)}
|
|
43
|
+
<SwitchRoot {...args}>
|
|
44
|
+
<SwitchThumb />
|
|
45
|
+
</SwitchRoot>
|
|
46
|
+
{/snippet}
|
|
47
|
+
|
|
48
|
+
<Story name="Basic" {args} {template} {parameters} />
|
|
@@ -0,0 +1,18 @@
|
|
|
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 Switch: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Switch = InstanceType<typeof Switch>;
|
|
18
|
+
export default Switch;
|