@websline/system-components 1.4.4 → 1.4.7
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/fonts/borna-bold-webfont.woff +0 -0
- package/dist/assets/fonts/borna-bold-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-bolditalic-webfont.woff +0 -0
- package/dist/assets/fonts/borna-bolditalic-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-medium-webfont.woff +0 -0
- package/dist/assets/fonts/borna-medium-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-mediumitalic-webfont.woff +0 -0
- package/dist/assets/fonts/borna-mediumitalic-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-regular-webfont.woff +0 -0
- package/dist/assets/fonts/borna-regular-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-regularitalic-webfont.woff +0 -0
- package/dist/assets/fonts/borna-regularitalic-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-semibold-webfont.woff +0 -0
- package/dist/assets/fonts/borna-semibold-webfont.woff2 +0 -0
- package/dist/assets/fonts/borna-semibolditalic-webfont.woff +0 -0
- package/dist/assets/fonts/borna-semibolditalic-webfont.woff2 +0 -0
- package/dist/components/atoms/checkbox/checkbox.variants.d.ts +2 -2
- package/dist/components/atoms/checkbox/checkbox.variants.js +1 -1
- package/dist/components/atoms/icon/components/Lightning.svelte +26 -0
- package/dist/components/atoms/icon/components/Lightning.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/index.d.ts +1 -0
- package/dist/components/atoms/icon/components/index.js +1 -0
- package/dist/components/atoms/radio/Radio.svelte +57 -2
- package/dist/components/atoms/tag/Tag.svelte +9 -7
- package/dist/components/atoms/tag/Tag.svelte.d.ts +8 -8
- package/dist/components/atoms/tag/tag.variants.d.ts +0 -9
- package/dist/components/atoms/tag/tag.variants.js +1 -4
- package/dist/components/molecules/calendar/Calendar.svelte +95 -0
- package/dist/components/molecules/calendar/Calendar.svelte.d.ts +42 -0
- package/dist/components/molecules/calendar/Container.svelte +25 -0
- package/dist/components/molecules/calendar/Container.svelte.d.ts +25 -0
- package/dist/components/molecules/calendar/DayCell.svelte +47 -0
- package/dist/components/molecules/calendar/RootContext.svelte +28 -0
- package/dist/components/molecules/calendar/RootContext.svelte.d.ts +21 -0
- package/dist/components/molecules/calendar/WeekRow.svelte +65 -0
- package/dist/components/molecules/calendar/Weekdays.svelte +27 -0
- package/dist/components/molecules/calendar/Weekdays.svelte.d.ts +17 -0
- package/dist/components/molecules/calendar/calendar.variant.d.ts +79 -0
- package/dist/components/molecules/calendar/calendar.variant.js +36 -0
- package/dist/components/molecules/calendar/index.d.ts +8 -0
- package/dist/components/molecules/calendar/index.js +10 -0
- package/dist/components/molecules/formField/FormField.svelte +1 -1
- package/dist/components/molecules/formField/FormField.svelte.d.ts +2 -2
- package/dist/components/molecules/formField/formField.variants.d.ts +12 -12
- package/dist/components/molecules/formField/formField.variants.js +21 -5
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +2 -4
- package/dist/components/molecules/selectorCard/SelectorCard.svelte +8 -2
- package/dist/components/molecules/selectorCard/SelectorCard.svelte.d.ts +2 -2
- package/dist/components/molecules/tagSelector/TagSelector.svelte +12 -0
- package/dist/components/molecules/tagSelector/TagSelector.svelte.d.ts +16 -0
- package/dist/components/molecules/tagSelector/ValueList.svelte +12 -2
- package/dist/components/molecules/tagSelector/ValueList.svelte.d.ts +4 -0
- package/dist/components/molecules/tagSelector/tagSelector.variants.js +2 -2
- package/dist/components/organisms/tooltip/Content.svelte +51 -0
- package/dist/components/organisms/tooltip/Content.svelte.d.ts +57 -0
- package/dist/components/organisms/tooltip/Tooltip.svelte +15 -0
- package/dist/components/organisms/tooltip/Tooltip.svelte.d.ts +17 -0
- package/dist/components/organisms/tooltip/Trigger.svelte +13 -0
- package/dist/components/organisms/tooltip/Trigger.svelte.d.ts +17 -0
- package/dist/components/organisms/tooltip/index.d.ts +4 -0
- package/dist/components/organisms/tooltip/index.js +5 -0
- package/dist/components/organisms/tooltip/tooltip.variant.d.ts +24 -0
- package/dist/components/organisms/tooltip/tooltip.variant.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +108 -99
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,7 @@ export const checkboxVariants: import("tailwind-variants").TVReturnType<{
|
|
|
5
5
|
error: {
|
|
6
6
|
true: string;
|
|
7
7
|
};
|
|
8
|
-
}, undefined, "size-4 cursor-pointer rounded border border-
|
|
8
|
+
}, undefined, "size-4 cursor-pointer rounded-xs border border-neutral-300 bg-transparent bg-none text-neutral-900 ring-0 ring-transparent ring-offset-transparent outline-transparent duration-300 after:block after:size-full checked:bg-none checked:after:bg-current focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:border-neutral-600 dark:text-white", {
|
|
9
9
|
disabled: {
|
|
10
10
|
true: string;
|
|
11
11
|
};
|
|
@@ -19,4 +19,4 @@ export const checkboxVariants: import("tailwind-variants").TVReturnType<{
|
|
|
19
19
|
error: {
|
|
20
20
|
true: string;
|
|
21
21
|
};
|
|
22
|
-
}, undefined, "size-4 cursor-pointer rounded border border-
|
|
22
|
+
}, undefined, "size-4 cursor-pointer rounded-xs border border-neutral-300 bg-transparent bg-none text-neutral-900 ring-0 ring-transparent ring-offset-transparent outline-transparent duration-300 after:block after:size-full checked:bg-none checked:after:bg-current focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:border-neutral-600 dark:text-white", unknown, unknown, undefined>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tv } from "../../../utils/tailwind.js";
|
|
2
2
|
|
|
3
3
|
const checkboxVariants = tv({
|
|
4
|
-
base: "size-4 cursor-pointer rounded border border-
|
|
4
|
+
base: "size-4 cursor-pointer rounded-xs border border-neutral-300 bg-transparent bg-none text-neutral-900 ring-0 ring-transparent ring-offset-transparent outline-transparent duration-300 after:block after:size-full checked:bg-none checked:after:bg-current focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:border-neutral-600 dark:text-white",
|
|
5
5
|
variants: {
|
|
6
6
|
disabled: {
|
|
7
7
|
true: "cursor-not-allowed",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} Props
|
|
4
|
+
* @property {string} [color=""] Icon color
|
|
5
|
+
* @property {number} [height=24] Icon height
|
|
6
|
+
* @property {number} [strokeWidth=1.5] Icon StrokeWidth
|
|
7
|
+
* @property {number} [width=24] Icon width
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {Props} */
|
|
11
|
+
let { color, height, width, strokeWidth, ...rest } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<svg
|
|
15
|
+
{height}
|
|
16
|
+
{width}
|
|
17
|
+
viewBox="0 0 20 20"
|
|
18
|
+
fill="none"
|
|
19
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
20
|
+
{...rest}>
|
|
21
|
+
<path
|
|
22
|
+
d="M7.77843 2.5H15.0512L10.6067 7.75H16.6673L6.97035 17.5L8.99055 10.375H3.33398L7.77843 2.5Z"
|
|
23
|
+
stroke={color}
|
|
24
|
+
stroke-width={strokeWidth}
|
|
25
|
+
stroke-linejoin="round"/>
|
|
26
|
+
</svg>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export default Lightning;
|
|
2
|
+
type Lightning = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Lightning: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Icon color
|
|
9
|
+
*/
|
|
10
|
+
color?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Icon height
|
|
13
|
+
*/
|
|
14
|
+
height?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Icon StrokeWidth
|
|
17
|
+
*/
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Icon width
|
|
21
|
+
*/
|
|
22
|
+
width?: number;
|
|
23
|
+
}, {}, "">;
|
|
24
|
+
type Props = {
|
|
25
|
+
/**
|
|
26
|
+
* Icon color
|
|
27
|
+
*/
|
|
28
|
+
color?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Icon height
|
|
31
|
+
*/
|
|
32
|
+
height?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Icon StrokeWidth
|
|
35
|
+
*/
|
|
36
|
+
strokeWidth?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Icon width
|
|
39
|
+
*/
|
|
40
|
+
width?: number;
|
|
41
|
+
};
|
|
@@ -60,6 +60,7 @@ export { default as Info } from "./Info.svelte";
|
|
|
60
60
|
export { default as Intergration } from "./Intergration.svelte";
|
|
61
61
|
export { default as Italic } from "./Italic.svelte";
|
|
62
62
|
export { default as Layout } from "./Layout.svelte";
|
|
63
|
+
export { default as Lightning } from "./Lightning.svelte";
|
|
63
64
|
export { default as Link } from "./Link.svelte";
|
|
64
65
|
export { default as LinkAi } from "./LinkAi.svelte";
|
|
65
66
|
export { default as ListOrdered } from "./ListOrdered.svelte";
|
|
@@ -60,6 +60,7 @@ export { default as Info } from "./Info.svelte";
|
|
|
60
60
|
export { default as Intergration } from "./Intergration.svelte";
|
|
61
61
|
export { default as Italic } from "./Italic.svelte";
|
|
62
62
|
export { default as Layout } from "./Layout.svelte";
|
|
63
|
+
export { default as Lightning } from "./Lightning.svelte";
|
|
63
64
|
export { default as Link } from "./Link.svelte";
|
|
64
65
|
export { default as LinkAi } from "./LinkAi.svelte";
|
|
65
66
|
export { default as ListOrdered } from "./ListOrdered.svelte";
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
/** @type {Map<string, Set>} valueCheckers */
|
|
3
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
4
|
+
const valueCheckers = new Map();
|
|
5
|
+
|
|
6
|
+
const checkValues = (name) => {
|
|
7
|
+
const checkers = valueCheckers.get(name);
|
|
8
|
+
for (const fn of checkers?.values() ?? []) {
|
|
9
|
+
fn?.();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const addValueUpdater = (name, checker) => {
|
|
14
|
+
let checkerSet = valueCheckers.get(name);
|
|
15
|
+
if (!checkerSet) {
|
|
16
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
17
|
+
checkerSet = new Set();
|
|
18
|
+
valueCheckers.set(name, checkerSet);
|
|
19
|
+
}
|
|
20
|
+
checkerSet.add(checker);
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
checkerSet.delete(checker);
|
|
24
|
+
if (!checkerSet.size) {
|
|
25
|
+
valueCheckers.delete(name);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
1
31
|
<script>
|
|
2
32
|
import { getContext } from "svelte";
|
|
3
33
|
import { radioVariants } from "./radio.variants.js";
|
|
@@ -22,11 +52,13 @@
|
|
|
22
52
|
error,
|
|
23
53
|
id,
|
|
24
54
|
name,
|
|
55
|
+
onchange,
|
|
25
56
|
required,
|
|
26
57
|
value = "on",
|
|
27
58
|
...rest
|
|
28
59
|
} = $props();
|
|
29
60
|
|
|
61
|
+
let element = $state();
|
|
30
62
|
let store = getContext("form-field-store") ?? null;
|
|
31
63
|
|
|
32
64
|
let localValues = $derived.by(() => {
|
|
@@ -39,10 +71,32 @@
|
|
|
39
71
|
required: required ?? storeValues.required ?? false,
|
|
40
72
|
};
|
|
41
73
|
});
|
|
74
|
+
|
|
75
|
+
const handleChange = (e) => {
|
|
76
|
+
if (name?.length) {
|
|
77
|
+
checkValues(name);
|
|
78
|
+
} else {
|
|
79
|
+
checked = e.target.checked;
|
|
80
|
+
}
|
|
81
|
+
onchange?.(e);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
$effect(() => {
|
|
85
|
+
let offUpdater;
|
|
86
|
+
if (name) {
|
|
87
|
+
offUpdater = addValueUpdater(name, () => {
|
|
88
|
+
checked = element?.checked || false;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return () => {
|
|
93
|
+
offUpdater?.();
|
|
94
|
+
};
|
|
95
|
+
});
|
|
42
96
|
</script>
|
|
43
97
|
|
|
44
98
|
<input
|
|
45
|
-
|
|
99
|
+
bind:this={element}
|
|
46
100
|
{checked}
|
|
47
101
|
class={radioVariants({
|
|
48
102
|
checked,
|
|
@@ -53,7 +107,8 @@
|
|
|
53
107
|
disabled={localValues.disabled}
|
|
54
108
|
id={localValues.id}
|
|
55
109
|
{name}
|
|
110
|
+
onchange={handleChange}
|
|
56
111
|
required={localValues.required}
|
|
57
|
-
type="
|
|
112
|
+
type="radio"
|
|
58
113
|
{value}
|
|
59
114
|
{...rest} />
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @typedef {Object} Props
|
|
7
7
|
* @property {import('svelte').Snippet} [children] Content inside the tag – can be text, HTML, or Svelte components
|
|
8
8
|
* @property {string} [class=""] Additional CSS classes for the tag
|
|
9
|
-
* @property {string} [
|
|
10
|
-
* @property {
|
|
9
|
+
* @property {string} [iconEnd=""] Name of the icon to display at the end
|
|
10
|
+
* @property {string} [iconStart=""] Name of the icon to display at the start
|
|
11
11
|
* @property {boolean} [selected=false] Whether the tag is in a visually selected state
|
|
12
12
|
* @property {"round" | "round-big"} [shape="round"] Shape of the tag
|
|
13
13
|
* @property {"small" | "big"} [size="small"] Size of the tag
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
let {
|
|
19
19
|
children,
|
|
20
20
|
class: className,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
iconEnd = "",
|
|
22
|
+
iconStart = "",
|
|
23
23
|
selected = false,
|
|
24
24
|
shape = "round",
|
|
25
25
|
size = "small",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
<button
|
|
32
32
|
class={tagVariants({
|
|
33
33
|
class: className,
|
|
34
|
-
iconPosition,
|
|
35
34
|
selected,
|
|
36
35
|
shape,
|
|
37
36
|
size,
|
|
@@ -39,10 +38,13 @@
|
|
|
39
38
|
})}
|
|
40
39
|
type="button"
|
|
41
40
|
{...rest}>
|
|
42
|
-
{#if
|
|
43
|
-
<Icon name={
|
|
41
|
+
{#if iconStart}
|
|
42
|
+
<Icon name={iconStart} size={14} />
|
|
44
43
|
{/if}
|
|
45
44
|
<span>
|
|
46
45
|
{@render children?.()}
|
|
47
46
|
</span>
|
|
47
|
+
{#if iconEnd}
|
|
48
|
+
<Icon name={iconEnd} size={14} />
|
|
49
|
+
{/if}
|
|
48
50
|
</button>
|
|
@@ -13,13 +13,13 @@ declare const Tag: import("svelte").Component<{
|
|
|
13
13
|
*/
|
|
14
14
|
class?: string;
|
|
15
15
|
/**
|
|
16
|
-
* Name of the icon to display
|
|
16
|
+
* Name of the icon to display at the end
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
iconEnd?: string;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Name of the icon to display at the start
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
iconStart?: string;
|
|
23
23
|
/**
|
|
24
24
|
* Whether the tag is in a visually selected state
|
|
25
25
|
*/
|
|
@@ -47,13 +47,13 @@ type Props = {
|
|
|
47
47
|
*/
|
|
48
48
|
class?: string;
|
|
49
49
|
/**
|
|
50
|
-
* Name of the icon to display
|
|
50
|
+
* Name of the icon to display at the end
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
iconEnd?: string;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Name of the icon to display at the start
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
iconStart?: string;
|
|
57
57
|
/**
|
|
58
58
|
* Whether the tag is in a visually selected state
|
|
59
59
|
*/
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export const tagVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
-
iconPosition: {
|
|
3
|
-
end: string;
|
|
4
|
-
};
|
|
5
2
|
selected: {
|
|
6
3
|
true: string;
|
|
7
4
|
};
|
|
@@ -18,9 +15,6 @@ export const tagVariants: import("tailwind-variants").TVReturnType<{
|
|
|
18
15
|
outline: string;
|
|
19
16
|
};
|
|
20
17
|
}, undefined, string[], {
|
|
21
|
-
iconPosition: {
|
|
22
|
-
end: string;
|
|
23
|
-
};
|
|
24
18
|
selected: {
|
|
25
19
|
true: string;
|
|
26
20
|
};
|
|
@@ -37,9 +31,6 @@ export const tagVariants: import("tailwind-variants").TVReturnType<{
|
|
|
37
31
|
outline: string;
|
|
38
32
|
};
|
|
39
33
|
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
40
|
-
iconPosition: {
|
|
41
|
-
end: string;
|
|
42
|
-
};
|
|
43
34
|
selected: {
|
|
44
35
|
true: string;
|
|
45
36
|
};
|
|
@@ -8,11 +8,8 @@ const tagVariants = tv({
|
|
|
8
8
|
"border border-neutral-100 hover:border-neutral-200 dark:border-neutral-700 hover:dark:border-neutral-700",
|
|
9
9
|
],
|
|
10
10
|
variants: {
|
|
11
|
-
iconPosition: {
|
|
12
|
-
end: "flex-row-reverse",
|
|
13
|
-
},
|
|
14
11
|
selected: {
|
|
15
|
-
true: "border-neutral-900
|
|
12
|
+
true: "border-neutral-900 bg-neutral-900! text-neutral-100 dark:border-blue-400 dark:bg-blue-400!",
|
|
16
13
|
},
|
|
17
14
|
shape: {
|
|
18
15
|
round: "rounded-sm",
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Calendar } from "bits-ui";
|
|
3
|
+
import { Icon } from "../../../index.js";
|
|
4
|
+
import { calendarVariants } from "./calendar.variant.js";
|
|
5
|
+
import RootContext from "./RootContext.svelte";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("bits-ui").CalendarRootPropsWithoutHTML} CalendarRootProps
|
|
9
|
+
*
|
|
10
|
+
* @typedef {Object} Props
|
|
11
|
+
* @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
|
|
12
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
13
|
+
* @property {boolean} [hideHeader=false] Whether to show the header or not
|
|
14
|
+
* @property {number} [maxMonths=false] The maximum of months to display side by side
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @type {Omit<CalendarRootProps, "disabled" | "disableDaysOutsideMonth" | "isDateDisabled" | "numberOfMonths" | "pagedNavigation" | "weekStartsOn"> & Props} */
|
|
18
|
+
let {
|
|
19
|
+
children: _children,
|
|
20
|
+
class: className = "",
|
|
21
|
+
hideHeader = false,
|
|
22
|
+
locale = "de",
|
|
23
|
+
maxDays = 2,
|
|
24
|
+
maxMonths = 1,
|
|
25
|
+
ref = $bindable(null),
|
|
26
|
+
type,
|
|
27
|
+
value = $bindable(),
|
|
28
|
+
weekdayFormat = "short",
|
|
29
|
+
...rest
|
|
30
|
+
} = $props();
|
|
31
|
+
|
|
32
|
+
let ro;
|
|
33
|
+
let numberOfMonths = $state(1);
|
|
34
|
+
let styles = $derived(calendarVariants());
|
|
35
|
+
|
|
36
|
+
const setValue = (newValue) => {
|
|
37
|
+
if (Array.isArray(newValue)) {
|
|
38
|
+
// make sure dates are sorted for the range selection
|
|
39
|
+
value = newValue.toSorted();
|
|
40
|
+
} else {
|
|
41
|
+
value = newValue;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const updateVisibleMonths = (table, parentElement) => {
|
|
46
|
+
numberOfMonths = Math.min(
|
|
47
|
+
Math.max(Math.floor(parentElement.offsetWidth / table.offsetWidth), 1),
|
|
48
|
+
maxMonths,
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
$effect(() => {
|
|
53
|
+
if (maxMonths > 1 && ref?.parentElement) {
|
|
54
|
+
const firstTable = ref.querySelector("[data-calendar-grid]");
|
|
55
|
+
ro = new ResizeObserver(() => {
|
|
56
|
+
updateVisibleMonths(firstTable, ref.parentElement);
|
|
57
|
+
});
|
|
58
|
+
ro.observe(ref.parentElement);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
numberOfMonths = 1;
|
|
63
|
+
ro?.disconnect();
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<Calendar.Root
|
|
69
|
+
class={styles.base({ class: className })}
|
|
70
|
+
{locale}
|
|
71
|
+
{maxDays}
|
|
72
|
+
{numberOfMonths}
|
|
73
|
+
pagedNavigation
|
|
74
|
+
bind:ref
|
|
75
|
+
{type}
|
|
76
|
+
bind:value={() => value, setValue}
|
|
77
|
+
{weekdayFormat}
|
|
78
|
+
{...rest}>
|
|
79
|
+
{#snippet children({ months, weekdays })}
|
|
80
|
+
{#if !hideHeader}
|
|
81
|
+
<Calendar.Header class={styles.header({ class: className })} {...rest}>
|
|
82
|
+
<Calendar.PrevButton class={styles.headerBtn({ class: "rotate-90" })}>
|
|
83
|
+
<Icon name="chevronDown" size={20} />
|
|
84
|
+
</Calendar.PrevButton>
|
|
85
|
+
<Calendar.Heading class={styles.heading()} />
|
|
86
|
+
<Calendar.NextButton class={styles.headerBtn({ class: "rotate-270" })}>
|
|
87
|
+
<Icon name="chevronDown" size={20} />
|
|
88
|
+
</Calendar.NextButton>
|
|
89
|
+
</Calendar.Header>
|
|
90
|
+
{/if}
|
|
91
|
+
<RootContext {maxDays} {months} {value} {weekdays}>
|
|
92
|
+
{@render _children?.()}
|
|
93
|
+
</RootContext>
|
|
94
|
+
{/snippet}
|
|
95
|
+
</Calendar.Root>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export default Calendar;
|
|
2
|
+
type Calendar = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Omit<CalendarRootPropsWithoutHTML, "disabled" | "disableDaysOutsideMonth" | "isDateDisabled" | "numberOfMonths" | "pagedNavigation" | "weekStartsOn"> & Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Calendar: import("svelte").Component<Omit<import("bits-ui").CalendarRootPropsWithoutHTML, "disabled" | "disableDaysOutsideMonth" | "isDateDisabled" | "numberOfMonths" | "pagedNavigation" | "weekStartsOn"> & {
|
|
7
|
+
/**
|
|
8
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
9
|
+
*/
|
|
10
|
+
children?: import("svelte").Snippet;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the header or not
|
|
17
|
+
*/
|
|
18
|
+
hideHeader?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The maximum of months to display side by side
|
|
21
|
+
*/
|
|
22
|
+
maxMonths?: number;
|
|
23
|
+
}, {}, "value" | "ref">;
|
|
24
|
+
import { Calendar } from "bits-ui";
|
|
25
|
+
type Props = {
|
|
26
|
+
/**
|
|
27
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
28
|
+
*/
|
|
29
|
+
children?: import("svelte").Snippet;
|
|
30
|
+
/**
|
|
31
|
+
* Additional CSS classes to apply to the component
|
|
32
|
+
*/
|
|
33
|
+
class?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to show the header or not
|
|
36
|
+
*/
|
|
37
|
+
hideHeader?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The maximum of months to display side by side
|
|
40
|
+
*/
|
|
41
|
+
maxMonths?: number;
|
|
42
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Calendar } from "bits-ui";
|
|
3
|
+
import { getContext } from "svelte";
|
|
4
|
+
import { calendarVariants } from "./calendar.variant.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} Props
|
|
8
|
+
* @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
|
|
9
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** @type {Props} */
|
|
13
|
+
let { children, class: className = "", ...rest } = $props();
|
|
14
|
+
|
|
15
|
+
let ctx = $derived.by(getContext("calendar-root-store"));
|
|
16
|
+
let styles = $derived(calendarVariants());
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class={styles.gridWrapper({ class: className })} {...rest}>
|
|
20
|
+
{#each ctx.months as month, i (i)}
|
|
21
|
+
<Calendar.Grid class={styles.grid()}>
|
|
22
|
+
{@render children?.({ month })}
|
|
23
|
+
</Calendar.Grid>
|
|
24
|
+
{/each}
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default Container;
|
|
2
|
+
type Container = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Container: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
9
|
+
*/
|
|
10
|
+
children?: import("svelte").Snippet;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
}, {}, "">;
|
|
16
|
+
type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
19
|
+
*/
|
|
20
|
+
children?: import("svelte").Snippet;
|
|
21
|
+
/**
|
|
22
|
+
* Additional CSS classes to apply to the component
|
|
23
|
+
*/
|
|
24
|
+
class?: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Calendar } from "bits-ui";
|
|
3
|
+
import { getContext } from "svelte";
|
|
4
|
+
import { calendarVariants } from "./calendar.variant.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("bits-ui").CalendarCellPropsWithoutHTML} CalendarCellPropsWithoutHTML
|
|
8
|
+
*
|
|
9
|
+
* @typedef {Object} Props
|
|
10
|
+
* @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
|
|
11
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** @type {CalendarCellPropsWithoutHTML & Props} */
|
|
15
|
+
let { children, class: className = "", date, month, ...rest } = $props();
|
|
16
|
+
|
|
17
|
+
let ctx = $derived.by(getContext("calendar-root-store"));
|
|
18
|
+
let styles = $derived(calendarVariants());
|
|
19
|
+
|
|
20
|
+
const handleHover = () => {
|
|
21
|
+
ctx.hoverValue = date;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleLeave = () => {
|
|
25
|
+
const hoverValue = ctx.hoverValue;
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
if (hoverValue !== ctx.hoverValue) return;
|
|
28
|
+
ctx.hoverValue = null;
|
|
29
|
+
}, 150);
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Calendar.Cell
|
|
34
|
+
class={styles.dateCell({ class: className })}
|
|
35
|
+
{date}
|
|
36
|
+
month={month.value}
|
|
37
|
+
onmouseenter={handleHover}
|
|
38
|
+
onmouseleave={handleLeave}
|
|
39
|
+
{...rest}>
|
|
40
|
+
<Calendar.Day class={styles.dateDay()}>
|
|
41
|
+
{#if children}
|
|
42
|
+
{@render children()}
|
|
43
|
+
{:else}
|
|
44
|
+
{date.day}
|
|
45
|
+
{/if}
|
|
46
|
+
</Calendar.Day>
|
|
47
|
+
</Calendar.Cell>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// NOTE: this is an internal component to pass the props as context
|
|
3
|
+
import { setContext } from "svelte";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
hoverValue = $bindable(),
|
|
8
|
+
maxDays,
|
|
9
|
+
months,
|
|
10
|
+
value,
|
|
11
|
+
weekdays,
|
|
12
|
+
} = $props();
|
|
13
|
+
|
|
14
|
+
setContext("calendar-root-store", () => ({
|
|
15
|
+
maxDays,
|
|
16
|
+
months,
|
|
17
|
+
value,
|
|
18
|
+
weekdays,
|
|
19
|
+
get hoverValue() {
|
|
20
|
+
return hoverValue;
|
|
21
|
+
},
|
|
22
|
+
set hoverValue(value) {
|
|
23
|
+
hoverValue = value;
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
{@render children?.()}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default RootContext;
|
|
2
|
+
type RootContext = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const RootContext: import("svelte").Component<{
|
|
7
|
+
children: any;
|
|
8
|
+
hoverValue?: any;
|
|
9
|
+
maxDays: any;
|
|
10
|
+
months: any;
|
|
11
|
+
value: any;
|
|
12
|
+
weekdays: any;
|
|
13
|
+
}, {}, "hoverValue">;
|
|
14
|
+
type $$ComponentProps = {
|
|
15
|
+
children: any;
|
|
16
|
+
hoverValue?: any;
|
|
17
|
+
maxDays: any;
|
|
18
|
+
months: any;
|
|
19
|
+
value: any;
|
|
20
|
+
weekdays: any;
|
|
21
|
+
};
|