@websline/system-components 1.4.4 → 1.4.6

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.
Files changed (52) hide show
  1. package/dist/components/atoms/checkbox/checkbox.variants.d.ts +2 -2
  2. package/dist/components/atoms/checkbox/checkbox.variants.js +1 -1
  3. package/dist/components/atoms/inputDate/InputDate.svelte +114 -0
  4. package/dist/components/atoms/inputDate/InputDate.svelte.d.ts +97 -0
  5. package/dist/components/atoms/inputDate/Picker.svelte +36 -0
  6. package/dist/components/atoms/inputDate/Picker.svelte.d.ts +21 -0
  7. package/dist/components/atoms/inputDate/input.variants.d.ts +64 -0
  8. package/dist/components/atoms/inputDate/input.variants.js +20 -0
  9. package/dist/components/atoms/radio/Radio.svelte +55 -2
  10. package/dist/components/atoms/tag/Tag.svelte +9 -7
  11. package/dist/components/atoms/tag/Tag.svelte.d.ts +8 -8
  12. package/dist/components/atoms/tag/tag.variants.d.ts +0 -9
  13. package/dist/components/atoms/tag/tag.variants.js +1 -4
  14. package/dist/components/molecules/calendar/Calendar.svelte +95 -0
  15. package/dist/components/molecules/calendar/Calendar.svelte.d.ts +42 -0
  16. package/dist/components/molecules/calendar/Container.svelte +25 -0
  17. package/dist/components/molecules/calendar/Container.svelte.d.ts +25 -0
  18. package/dist/components/molecules/calendar/DayCell.svelte +47 -0
  19. package/dist/components/molecules/calendar/RootContext.svelte +28 -0
  20. package/dist/components/molecules/calendar/RootContext.svelte.d.ts +21 -0
  21. package/dist/components/molecules/calendar/WeekRow.svelte +65 -0
  22. package/dist/components/molecules/calendar/Weekdays.svelte +27 -0
  23. package/dist/components/molecules/calendar/Weekdays.svelte.d.ts +17 -0
  24. package/dist/components/molecules/calendar/calendar.variant.d.ts +79 -0
  25. package/dist/components/molecules/calendar/calendar.variant.js +36 -0
  26. package/dist/components/molecules/calendar/index.d.ts +8 -0
  27. package/dist/components/molecules/calendar/index.js +10 -0
  28. package/dist/components/molecules/formField/FormField.svelte +1 -1
  29. package/dist/components/molecules/formField/FormField.svelte.d.ts +2 -2
  30. package/dist/components/molecules/formField/formField.variants.d.ts +12 -12
  31. package/dist/components/molecules/formField/formField.variants.js +21 -5
  32. package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +2 -4
  33. package/dist/components/molecules/selectorCard/SelectorCard.svelte +8 -2
  34. package/dist/components/molecules/selectorCard/SelectorCard.svelte.d.ts +2 -2
  35. package/dist/components/molecules/tagSelector/TagSelector.svelte +12 -0
  36. package/dist/components/molecules/tagSelector/TagSelector.svelte.d.ts +16 -0
  37. package/dist/components/molecules/tagSelector/ValueList.svelte +12 -2
  38. package/dist/components/molecules/tagSelector/ValueList.svelte.d.ts +4 -0
  39. package/dist/components/molecules/tagSelector/tagSelector.variants.js +2 -2
  40. package/dist/components/organisms/tooltip/Content.svelte +51 -0
  41. package/dist/components/organisms/tooltip/Content.svelte.d.ts +57 -0
  42. package/dist/components/organisms/tooltip/Tooltip.svelte +15 -0
  43. package/dist/components/organisms/tooltip/Tooltip.svelte.d.ts +17 -0
  44. package/dist/components/organisms/tooltip/Trigger.svelte +13 -0
  45. package/dist/components/organisms/tooltip/Trigger.svelte.d.ts +17 -0
  46. package/dist/components/organisms/tooltip/index.d.ts +4 -0
  47. package/dist/components/organisms/tooltip/index.js +5 -0
  48. package/dist/components/organisms/tooltip/tooltip.variant.d.ts +24 -0
  49. package/dist/components/organisms/tooltip/tooltip.variant.js +20 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.js +3 -0
  52. package/package.json +25 -25
@@ -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
+ };
@@ -0,0 +1,65 @@
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").CalendarGridRowPropsWithoutHTML} CalendarGridRowPropsWithoutHTML
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 {CalendarRootProps["minValue"][]} weekDates
14
+ */
15
+
16
+ /** @type {CalendarGridRowPropsWithoutHTML & Props} */
17
+ let { children, class: className = "", weekDates, ...rest } = $props();
18
+
19
+ let ctx = $derived.by(getContext("calendar-root-store"));
20
+
21
+ /**
22
+ * The left/right margin or nothing
23
+ * @type {[number, number] | undefined}
24
+ */
25
+ let range = $derived.by(() => {
26
+ if (!Array.isArray(ctx.value) || ctx.maxDays !== 2 || ctx.value.length > 2)
27
+ return;
28
+
29
+ let dates = [...ctx.value];
30
+ if (dates.length === 1 && ctx.hoverValue) {
31
+ dates.push(ctx.hoverValue);
32
+ }
33
+ if (dates.length !== 2) return;
34
+ dates.sort();
35
+
36
+ const [startOffset, endOffset] = [
37
+ [dates[0], weekDates[0]],
38
+ [dates[1], weekDates.at(-1)],
39
+ ].map(([date, weekday]) => date.compare(weekday) / 7);
40
+
41
+ if (startOffset >= 1 || endOffset <= -1) return;
42
+
43
+ // 1.06 is to prevent the range bg from getting past the selected dates
44
+ return [
45
+ startOffset < 0 ? 0 : startOffset * 1.06, // left
46
+ endOffset > 0 ? 0 : endOffset * -1.06, // right
47
+ ].map((value) => Math.round(value * 1e5) / 1e3);
48
+ });
49
+
50
+ let styles = $derived(calendarVariants());
51
+ </script>
52
+
53
+ <Calendar.GridRow class={styles.gridRow({ class: className })} {...rest}>
54
+ {#each weekDates as date, i (i)}
55
+ {@render children?.({ date })}
56
+ {/each}
57
+ {#if range}
58
+ <div class={styles.rangeWrapper()}>
59
+ <div
60
+ class={styles.rangeBg()}
61
+ style={`margin-left:${range[0]}%;margin-right:${range[1]}%`}>
62
+ </div>
63
+ </div>
64
+ {/if}
65
+ </Calendar.GridRow>
@@ -0,0 +1,27 @@
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").CalendarGridHeadPropsWithoutHTML} CalendarGridHeadPropsWithoutHTML
8
+ *
9
+ * @typedef {Object} Props
10
+ * @property {string} [class=""] Additional CSS classes to apply to the component
11
+ */
12
+
13
+ /** @type {Omit<CalendarGridHeadPropsWithoutHTML, "child" | "children"> & Props} */
14
+ let { class: className = "", ...rest } = $props();
15
+
16
+ let ctx = $derived.by(getContext("calendar-root-store"));
17
+ let styles = $derived(calendarVariants());
18
+ </script>
19
+
20
+ <Calendar.GridHead class={styles.gridHead({ class: className })} {...rest}>
21
+ <Calendar.GridRow class={styles.gridRow()}>
22
+ {#each ctx.weekdays as day, i (i)}
23
+ <Calendar.HeadCell class={styles.gridHeadCell()} style="font-weight:inherit"
24
+ >{day}</Calendar.HeadCell>
25
+ {/each}
26
+ </Calendar.GridRow>
27
+ </Calendar.GridHead>
@@ -0,0 +1,17 @@
1
+ export default Weekdays;
2
+ type Weekdays = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Omit<CalendarGridHeadPropsWithoutHTML, "children" | "child"> & Props>): void;
5
+ };
6
+ declare const Weekdays: import("svelte").Component<Omit<import("bits-ui").CalendarGridHeadPropsWithoutHTML, "children" | "child"> & {
7
+ /**
8
+ * Additional CSS classes to apply to the component
9
+ */
10
+ class?: string;
11
+ }, {}, "">;
12
+ type Props = {
13
+ /**
14
+ * Additional CSS classes to apply to the component
15
+ */
16
+ class?: string;
17
+ };
@@ -0,0 +1,79 @@
1
+ export const calendarVariants: import("tailwind-variants").TVReturnType<{
2
+ [key: string]: {
3
+ [key: string]: import("tailwind-variants").ClassValue | {
4
+ heading?: import("tailwind-variants").ClassValue;
5
+ base?: import("tailwind-variants").ClassValue;
6
+ dateCell?: import("tailwind-variants").ClassValue;
7
+ dateDay?: import("tailwind-variants").ClassValue;
8
+ grid?: import("tailwind-variants").ClassValue;
9
+ gridHead?: import("tailwind-variants").ClassValue;
10
+ gridHeadCell?: import("tailwind-variants").ClassValue;
11
+ gridRow?: import("tailwind-variants").ClassValue;
12
+ gridWrapper?: import("tailwind-variants").ClassValue;
13
+ header?: import("tailwind-variants").ClassValue;
14
+ headerBtn?: import("tailwind-variants").ClassValue;
15
+ rangeBg?: import("tailwind-variants").ClassValue;
16
+ rangeWrapper?: import("tailwind-variants").ClassValue;
17
+ };
18
+ };
19
+ } | {
20
+ [x: string]: {
21
+ [x: string]: import("tailwind-variants").ClassValue | {
22
+ heading?: import("tailwind-variants").ClassValue;
23
+ base?: import("tailwind-variants").ClassValue;
24
+ dateCell?: import("tailwind-variants").ClassValue;
25
+ dateDay?: import("tailwind-variants").ClassValue;
26
+ grid?: import("tailwind-variants").ClassValue;
27
+ gridHead?: import("tailwind-variants").ClassValue;
28
+ gridHeadCell?: import("tailwind-variants").ClassValue;
29
+ gridRow?: import("tailwind-variants").ClassValue;
30
+ gridWrapper?: import("tailwind-variants").ClassValue;
31
+ header?: import("tailwind-variants").ClassValue;
32
+ headerBtn?: import("tailwind-variants").ClassValue;
33
+ rangeBg?: import("tailwind-variants").ClassValue;
34
+ rangeWrapper?: import("tailwind-variants").ClassValue;
35
+ };
36
+ };
37
+ }, {
38
+ base: string;
39
+ dateCell: string[];
40
+ dateDay: string[];
41
+ grid: string;
42
+ gridHead: string;
43
+ gridHeadCell: string;
44
+ gridRow: string;
45
+ gridWrapper: string;
46
+ header: string;
47
+ headerBtn: string[];
48
+ heading: string;
49
+ rangeBg: string;
50
+ rangeWrapper: string;
51
+ }, undefined, any, {
52
+ base: string;
53
+ dateCell: string[];
54
+ dateDay: string[];
55
+ grid: string;
56
+ gridHead: string;
57
+ gridHeadCell: string;
58
+ gridRow: string;
59
+ gridWrapper: string;
60
+ header: string;
61
+ headerBtn: string[];
62
+ heading: string;
63
+ rangeBg: string;
64
+ rangeWrapper: string;
65
+ }, import("tailwind-variants").TVReturnType<any, {
66
+ base: string;
67
+ dateCell: string[];
68
+ dateDay: string[];
69
+ grid: string;
70
+ gridHead: string;
71
+ gridHeadCell: string;
72
+ gridRow: string;
73
+ gridWrapper: string;
74
+ header: string;
75
+ headerBtn: string[];
76
+ heading: string;
77
+ rangeBg: string;
78
+ rangeWrapper: string;
79
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,36 @@
1
+ import { tv } from "../../../utils/tailwind.js";
2
+
3
+ const calendarVariants = tv({
4
+ slots: {
5
+ base: "w-fit rounded-lg bg-white shadow-sm",
6
+ dateCell: [
7
+ "group relative z-1 cursor-pointer p-1 ui-select-label",
8
+ "data-disabled:pointer-events-none data-disabled:text-neutral-400",
9
+ "data-unavailable:pointer-events-none data-unavailable:text-neutral-400 data-unavailable:line-through",
10
+ ],
11
+ dateDay: [
12
+ "grid size-8 place-items-center rounded-full",
13
+ "group-hover:bg-neutral-900 group-hover:text-neutral-100",
14
+ "data-selected:bg-neutral-900 data-selected:text-neutral-100",
15
+ // Today marker:
16
+ "before:absolute before:top-2 before:hidden before:size-0.75 before:rounded-full before:bg-current data-today:before:block",
17
+ ],
18
+ grid: "block border-l border-neutral-300 p-1 select-none first:border-0",
19
+ gridHead: "mb-1 ui-select-label text-neutral-500",
20
+ gridHeadCell: "py-1",
21
+ gridRow:
22
+ "relative flex items-center justify-around px-4 py-1 text-center data-readonly:pointer-events-none",
23
+ gridWrapper: "flex flex-wrap",
24
+ header:
25
+ "flex items-center justify-between gap-2 border-b border-neutral-300 px-6 py-4",
26
+ headerBtn: [
27
+ "inline-flex size-8 cursor-pointer items-center justify-center",
28
+ "data-disabled:pointer-events-none data-disabled:opacity-40",
29
+ ],
30
+ heading: "ui-select-label",
31
+ rangeBg: "h-full rounded-2xl bg-neutral-100",
32
+ rangeWrapper: "absolute inset-0 mx-6 my-2",
33
+ },
34
+ });
35
+
36
+ export { calendarVariants };
@@ -0,0 +1,8 @@
1
+ import Root from "./Calendar.svelte";
2
+ import Container from "./Container.svelte";
3
+ import DayCell from "./DayCell.svelte";
4
+ export const MonthGrid: import("svelte").Component<Calendar.GridBodyProps, {}, "ref">;
5
+ import Weekdays from "./Weekdays.svelte";
6
+ import WeekRow from "./WeekRow.svelte";
7
+ import { Calendar } from "bits-ui";
8
+ export { Root, Container, DayCell, Weekdays, WeekRow };
@@ -0,0 +1,10 @@
1
+ import { Calendar } from "bits-ui";
2
+ import Root from "./Calendar.svelte";
3
+ import Container from "./Container.svelte";
4
+ import DayCell from "./DayCell.svelte";
5
+ import Weekdays from "./Weekdays.svelte";
6
+ import WeekRow from "./WeekRow.svelte";
7
+
8
+ const MonthGrid = Calendar.GridBody;
9
+
10
+ export { Root, Container, DayCell, MonthGrid, Weekdays, WeekRow };
@@ -14,7 +14,7 @@
14
14
  * @property {string} [helperText=""] The helper text for the form field
15
15
  * @property {string} [id=""] The id attribute for the form field (passed down to the input)
16
16
  * @property {string} [label=""] The label text for the form field
17
- * @property {"stacked" | "inline"} [layout="stacked"] The layout of the input and label
17
+ * @property {"stacked" | "inline" | "checkable"} [layout="stacked"] The layout of the input and label
18
18
  * @property {boolean} [required=false] Whether the form field is required (passed down to the input)
19
19
  */
20
20
 
@@ -39,7 +39,7 @@ declare const FormField: import("svelte").Component<{
39
39
  /**
40
40
  * The layout of the input and label
41
41
  */
42
- layout?: "stacked" | "inline";
42
+ layout?: "stacked" | "inline" | "checkable";
43
43
  /**
44
44
  * Whether the form field is required (passed down to the input)
45
45
  */
@@ -81,7 +81,7 @@ type Props = {
81
81
  /**
82
82
  * The layout of the input and label
83
83
  */
84
- layout?: "stacked" | "inline";
84
+ layout?: "stacked" | "inline" | "checkable";
85
85
  /**
86
86
  * Whether the form field is required (passed down to the input)
87
87
  */
@@ -1,10 +1,10 @@
1
1
  export const formFieldVariants: import("tailwind-variants").TVReturnType<{
2
- disabled: {
3
- true: {
2
+ layout: {
3
+ checkable: {
4
+ base: string;
5
+ label: string;
4
6
  helperText: string;
5
7
  };
6
- };
7
- layout: {
8
8
  inline: {
9
9
  base: string;
10
10
  helperText: string;
@@ -15,12 +15,12 @@ export const formFieldVariants: import("tailwind-variants").TVReturnType<{
15
15
  label: string;
16
16
  helperText: string;
17
17
  }, undefined, {
18
- disabled: {
19
- true: {
18
+ layout: {
19
+ checkable: {
20
+ base: string;
21
+ label: string;
20
22
  helperText: string;
21
23
  };
22
- };
23
- layout: {
24
24
  inline: {
25
25
  base: string;
26
26
  helperText: string;
@@ -31,12 +31,12 @@ export const formFieldVariants: import("tailwind-variants").TVReturnType<{
31
31
  label: string;
32
32
  helperText: string;
33
33
  }, import("tailwind-variants").TVReturnType<{
34
- disabled: {
35
- true: {
34
+ layout: {
35
+ checkable: {
36
+ base: string;
37
+ label: string;
36
38
  helperText: string;
37
39
  };
38
- };
39
- layout: {
40
40
  inline: {
41
41
  base: string;
42
42
  helperText: string;
@@ -7,18 +7,34 @@ const formFieldVariants = tv({
7
7
  helperText: "-mt-1 ml-4",
8
8
  },
9
9
  variants: {
10
- disabled: {
11
- true: {
12
- helperText: "opacity-40",
13
- },
14
- },
15
10
  layout: {
11
+ checkable: {
12
+ base: "grid-cols-[min-content_auto] items-center",
13
+ label: "order-2 text-current",
14
+ helperText: "order-3 col-2 ml-0",
15
+ },
16
16
  inline: {
17
17
  base: "items-center sm:grid-cols-[minmax(120px,auto)_1fr]",
18
18
  helperText: "sm:col-2",
19
19
  },
20
20
  },
21
21
  },
22
+ compoundVariants: [
23
+ {
24
+ disabled: true,
25
+ layout: ["inline", "stacked"],
26
+ class: {
27
+ helperText: "opacity-40",
28
+ },
29
+ },
30
+ {
31
+ disabled: true,
32
+ layout: "checkable",
33
+ class: {
34
+ base: "opacity-40",
35
+ },
36
+ },
37
+ ],
22
38
  });
23
39
 
24
40
  export { formFieldVariants };
@@ -198,11 +198,9 @@
198
198
 
199
199
  $effect(() => {
200
200
  if (!editor) return;
201
-
202
- const current = editor.getHTML();
203
201
  const next = content ?? "";
204
-
205
- if (current !== next) {
202
+ const matches = next === editor.getText() || next === editor.getHTML();
203
+ if (!matches) {
206
204
  isContentPropUpdate = true;
207
205
  editor.commands.setContent(next, false);
208
206
  }
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  import { settled } from "svelte";
3
3
  import { selectorCardVariants } from "./selectorCard.variants.js";
4
- import { Switch, Radio, Label, utils } from "../../../index.js";
4
+ import { Checkbox, Switch, Radio, Label, utils } from "../../../index.js";
5
5
 
6
6
  /**
7
7
  * @typedef {Object} Props
@@ -15,7 +15,7 @@
15
15
  * @property {string} [label=""] Label to display in the card
16
16
  * @property {string} [name] The name of the card, used for form submission
17
17
  * @property {boolean} [required=false] Whether the card is required
18
- * @property {"radio" | "switch"} [type="radio"] The type of card
18
+ * @property {"checkbox" | "radio" | "switch"} [type="radio"] The type of card
19
19
  * @property {string} [value=""] The value of the card
20
20
  */
21
21
 
@@ -79,6 +79,12 @@
79
79
  bind:checked
80
80
  class={styles.input()}
81
81
  {...inputProps} />
82
+ {:else if type === "checkbox"}
83
+ <Checkbox
84
+ {@attach utils.attachNode(bindInputRef)}
85
+ bind:checked
86
+ class={styles.input()}
87
+ {...inputProps} />
82
88
  {/if}
83
89
  <div class={styles.content()}>
84
90
  {#if label}
@@ -47,7 +47,7 @@ declare const SelectorCard: import("svelte").Component<{
47
47
  /**
48
48
  * The type of card
49
49
  */
50
- type?: "radio" | "switch";
50
+ type?: "checkbox" | "radio" | "switch";
51
51
  /**
52
52
  * The value of the card
53
53
  */
@@ -97,7 +97,7 @@ type Props = {
97
97
  /**
98
98
  * The type of card
99
99
  */
100
- type?: "radio" | "switch";
100
+ type?: "checkbox" | "radio" | "switch";
101
101
  /**
102
102
  * The value of the card
103
103
  */
@@ -10,6 +10,8 @@
10
10
  * @property {boolean} [autofocus=false] Whether the input should be autofocused on mount
11
11
  * @property {string} [class=""] Additional CSS classes to apply to the component
12
12
  * @property {boolean} [disabled=false] Whether the component is disabled
13
+ * @property {string|undefined} [fixedValueIcon] The name of the icon to distinguish fixed tags from others
14
+ * @property {Array<string>} [fixedValues=[]] The unremovable and always selected tags
13
15
  * @property {string} [id=""] The ID of the input element
14
16
  * @property {string} [labelCreate=""] The label for the create new tag option
15
17
  * @property {string} [name] The name of the input, used for form submission
@@ -23,6 +25,8 @@
23
25
  autofocus = false,
24
26
  class: className = "",
25
27
  disabled = false,
28
+ fixedValueIcon,
29
+ fixedValues = [],
26
30
  id = "",
27
31
  labelCreate = "",
28
32
  name,
@@ -140,6 +144,12 @@
140
144
  return;
141
145
  }
142
146
 
147
+ if (fixedValues.find((i) => i.toLowerCase() === lower)) {
148
+ // is already a fixed (pre-selected) value
149
+ refocusInput();
150
+ return;
151
+ }
152
+
143
153
  const selectedMatch = value.find(
144
154
  (id) => typeof id === "string" && id.toLowerCase() === lower,
145
155
  );
@@ -223,6 +233,8 @@
223
233
  {/if}
224
234
  <ValueList
225
235
  {@attach utils.attachNode(bindInputRef)}
236
+ {fixedValueIcon}
237
+ {fixedValues}
226
238
  {localValues}
227
239
  onKeydown={handleKey}
228
240
  onOpenDropdown={openDropdown}