@marwes-ui/svelte 1.3.0 → 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.
- package/CHANGELOG.md +30 -0
- package/README.md +43 -11
- package/dist/components/README.md +31 -0
- package/dist/components/accordion/AccordionField.svelte +20 -6
- package/dist/components/accordion/index.d.ts +5 -2
- package/dist/components/accordion/index.js +7 -1
- package/dist/components/accordion/types.d.ts +3 -0
- package/dist/components/avatar/AvatarGroup.svelte +5 -2
- package/dist/components/avatar/AvatarGroup.svelte.d.ts +1 -0
- package/dist/components/avatar/TeamAvatarGroup.svelte +1 -0
- package/dist/components/avatar/TeamAvatarGroup.svelte.d.ts +1 -0
- package/dist/components/avatar/index.d.ts +7 -1
- package/dist/components/avatar/index.js +6 -0
- package/dist/components/avatar/types.d.ts +28 -0
- package/dist/components/badge/BadgeGroup.svelte +2 -1
- package/dist/components/badge/index.d.ts +5 -1
- package/dist/components/badge/index.js +4 -0
- package/dist/components/badge/types.d.ts +3 -0
- package/dist/components/banner/Banner.svelte +67 -0
- package/dist/components/banner/Banner.svelte.d.ts +4 -0
- package/dist/components/banner/ErrorBanner.svelte +9 -0
- package/dist/components/banner/ErrorBanner.svelte.d.ts +4 -0
- package/dist/components/banner/InfoBanner.svelte +9 -0
- package/dist/components/banner/InfoBanner.svelte.d.ts +4 -0
- package/dist/components/banner/SuccessBanner.svelte +9 -0
- package/dist/components/banner/SuccessBanner.svelte.d.ts +4 -0
- package/dist/components/banner/WarningBanner.svelte +9 -0
- package/dist/components/banner/WarningBanner.svelte.d.ts +4 -0
- package/dist/components/banner/index.d.ts +7 -0
- package/dist/components/banner/index.js +6 -0
- package/dist/components/banner/types.d.ts +14 -0
- package/dist/components/banner/types.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.svelte +115 -0
- package/dist/components/breadcrumb/Breadcrumb.svelte.d.ts +4 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/breadcrumb/types.d.ts +8 -0
- package/dist/components/breadcrumb/types.js +1 -0
- package/dist/components/button/Button.svelte +8 -4
- package/dist/components/button/DestructiveButton.svelte +1 -1
- package/dist/components/button/IconButton.svelte +9 -0
- package/dist/components/button/IconButton.svelte.d.ts +4 -0
- package/dist/components/button/index.d.ts +24 -1
- package/dist/components/button/index.js +23 -0
- package/dist/components/button/types.d.ts +30 -1
- package/dist/components/card/Card.svelte +2 -1
- package/dist/components/card/index.d.ts +4 -1
- package/dist/components/card/index.js +3 -0
- package/dist/components/card/types.d.ts +4 -0
- package/dist/components/checkbox/CheckboxField.svelte +4 -3
- package/dist/components/checkbox/CheckboxGroupField.svelte +21 -9
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/index.js +4 -1
- package/dist/components/checkbox/types.d.ts +7 -0
- package/dist/components/context-menu/ContextMenu.svelte +56 -0
- package/dist/components/context-menu/ContextMenu.svelte.d.ts +4 -0
- package/dist/components/context-menu/index.d.ts +2 -0
- package/dist/components/context-menu/index.js +1 -0
- package/dist/components/context-menu/types.d.ts +7 -0
- package/dist/components/context-menu/types.js +1 -0
- package/dist/components/date-picker/DatePicker.svelte +14 -2
- package/dist/components/date-picker/DatePickerField.svelte +72 -0
- package/dist/components/date-picker/DatePickerField.svelte.d.ts +4 -0
- package/dist/components/date-picker/index.d.ts +2 -2
- package/dist/components/date-picker/index.js +3 -1
- package/dist/components/date-picker/types.d.ts +15 -0
- package/dist/components/dialog/Dialog.svelte +1 -0
- package/dist/components/dialog/DialogModal.svelte +12 -0
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/types.d.ts +7 -3
- package/dist/components/drawer/Drawer.svelte +132 -0
- package/dist/components/drawer/Drawer.svelte.d.ts +4 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/drawer/types.d.ts +16 -0
- package/dist/components/drawer/types.js +1 -0
- package/dist/components/heading/H1.svelte +10 -0
- package/dist/components/heading/H2.svelte +6 -0
- package/dist/components/heading/H3.svelte +7 -0
- package/dist/components/input/CurrencyField.svelte +1 -1
- package/dist/components/input/Input.svelte +1 -0
- package/dist/components/input/InputField.svelte +4 -3
- package/dist/components/input/InputOtp.svelte +21 -44
- package/dist/components/input/InputOtpField.svelte +81 -0
- package/dist/components/input/InputOtpField.svelte.d.ts +4 -0
- package/dist/components/input/RichText.svelte +7 -6
- package/dist/components/input/RichTextField.svelte +4 -3
- package/dist/components/input/Select.svelte +7 -31
- package/dist/components/input/SelectField.svelte +6 -3
- package/dist/components/input/Textarea.svelte +1 -0
- package/dist/components/input/TextareaField.svelte +20 -5
- package/dist/components/input/index.d.ts +12 -4
- package/dist/components/input/index.js +19 -3
- package/dist/components/input/types.d.ts +59 -5
- package/dist/components/pagination/Pagination.svelte +399 -0
- package/dist/components/pagination/Pagination.svelte.d.ts +4 -0
- package/dist/components/pagination/PaginationField.svelte +72 -0
- package/dist/components/pagination/PaginationField.svelte.d.ts +4 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/types.d.ts +40 -0
- package/dist/components/pagination/types.js +1 -0
- package/dist/components/progress-bar/ProgressBar.svelte +50 -0
- package/dist/components/progress-bar/ProgressBar.svelte.d.ts +4 -0
- package/dist/components/progress-bar/index.d.ts +2 -0
- package/dist/components/progress-bar/index.js +1 -0
- package/dist/components/progress-bar/types.d.ts +6 -0
- package/dist/components/progress-bar/types.js +1 -0
- package/dist/components/radio/OptionRadioGroup.svelte +39 -5
- package/dist/components/radio/OptionRadioGroup.svelte.d.ts +2 -5
- package/dist/components/radio/Radio.svelte +1 -0
- package/dist/components/radio/RadioGroupField.svelte +4 -3
- package/dist/components/radio/RatingRadioGroup.svelte +18 -3
- package/dist/components/radio/YesNoRadioGroup.svelte +18 -3
- package/dist/components/radio/index.d.ts +4 -2
- package/dist/components/radio/index.js +6 -1
- package/dist/components/radio/types.d.ts +47 -0
- package/dist/components/segmented-control/SegmentedControl.svelte +125 -0
- package/dist/components/segmented-control/SegmentedControl.svelte.d.ts +25 -0
- package/dist/components/segmented-control/SegmentedControlField.svelte +76 -0
- package/dist/components/segmented-control/SegmentedControlField.svelte.d.ts +25 -0
- package/dist/components/segmented-control/index.d.ts +2 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/types.d.ts +41 -0
- package/dist/components/segmented-control/types.js +1 -0
- package/dist/components/skip-link/SkipLink.svelte +12 -0
- package/dist/components/skip-link/SkipLink.svelte.d.ts +4 -0
- package/dist/components/skip-link/index.d.ts +2 -0
- package/dist/components/skip-link/index.js +1 -0
- package/dist/components/skip-link/types.d.ts +7 -0
- package/dist/components/skip-link/types.js +1 -0
- package/dist/components/slider/SliderField.svelte +9 -8
- package/dist/components/slider/index.d.ts +5 -2
- package/dist/components/slider/index.js +7 -1
- package/dist/components/slider/types.d.ts +21 -0
- package/dist/components/spinner/EmptyStateSpinner.svelte +2 -3
- package/dist/components/spinner/EmptyStateSpinner.svelte.d.ts +1 -2
- package/dist/components/spinner/Spinner.svelte +2 -0
- package/dist/components/spinner/index.d.ts +2 -1
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/types.d.ts +1 -0
- package/dist/components/switch/Switch.svelte +1 -1
- package/dist/components/switch/SwitchField.svelte +6 -4
- package/dist/components/switch/index.d.ts +4 -2
- package/dist/components/switch/index.js +6 -1
- package/dist/components/switch/types.d.ts +3 -0
- package/dist/components/tab/TabGroup.svelte +7 -4
- package/dist/components/text/Text.svelte +23 -0
- package/dist/components/text/Text.svelte.d.ts +4 -0
- package/dist/components/text/index.d.ts +4 -0
- package/dist/components/text/index.js +2 -0
- package/dist/components/text/types.d.ts +15 -0
- package/dist/components/text/types.js +1 -0
- package/dist/components/tooltip/TooltipGroup.svelte +10 -2
- package/dist/index.d.ts +47 -29
- package/dist/index.js +51 -13
- package/dist/provider/MarwesProvider.svelte +26 -14
- package/dist/provider/types.d.ts +5 -2
- package/package.json +6 -5
- package/dist/components/accordion/README.md +0 -19
- package/dist/components/avatar/README.md +0 -19
- package/dist/components/badge/README.md +0 -16
- package/dist/components/button/README.md +0 -21
- package/dist/components/card/README.md +0 -15
- package/dist/components/checkbox/README.md +0 -17
- package/dist/components/date-picker/README.md +0 -17
- package/dist/components/dialog/README.md +0 -23
- package/dist/components/divider/README.md +0 -15
- package/dist/components/heading/README.md +0 -13
- package/dist/components/icon/README.md +0 -18
- package/dist/components/input/README.md +0 -24
- package/dist/components/paragraph/README.md +0 -13
- package/dist/components/radio/README.md +0 -16
- package/dist/components/skeleton/README.md +0 -16
- package/dist/components/slider/README.md +0 -20
- package/dist/components/spacing/README.md +0 -15
- package/dist/components/spinner/README.md +0 -19
- package/dist/components/stat-tile/README.md +0 -15
- package/dist/components/switch/README.md +0 -17
- package/dist/components/tab/README.md +0 -26
- package/dist/components/toast/README.md +0 -35
- package/dist/components/tooltip/README.md +0 -22
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { IconName, createBreadcrumbRecipe } from "@marwes-ui/core";
|
|
3
|
+
import Icon from "../icon/Icon.svelte";
|
|
4
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
5
|
+
import type { BreadcrumbItem, BreadcrumbProps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
items,
|
|
9
|
+
ariaLabel,
|
|
10
|
+
showHome,
|
|
11
|
+
homeHref,
|
|
12
|
+
homeLabel,
|
|
13
|
+
dataAttributes,
|
|
14
|
+
onitemselect,
|
|
15
|
+
onhomeclick,
|
|
16
|
+
class: className,
|
|
17
|
+
}: BreadcrumbProps = $props();
|
|
18
|
+
|
|
19
|
+
const breadcrumbOptions = $derived.by(() => {
|
|
20
|
+
const options = { items };
|
|
21
|
+
if (ariaLabel !== undefined) Object.assign(options, { ariaLabel });
|
|
22
|
+
if (showHome !== undefined) Object.assign(options, { showHome });
|
|
23
|
+
if (homeHref !== undefined) Object.assign(options, { homeHref });
|
|
24
|
+
if (homeLabel !== undefined) Object.assign(options, { homeLabel });
|
|
25
|
+
if (dataAttributes !== undefined) Object.assign(options, { dataAttributes });
|
|
26
|
+
return options;
|
|
27
|
+
});
|
|
28
|
+
const kit = $derived(createBreadcrumbRecipe(breadcrumbOptions));
|
|
29
|
+
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
30
|
+
|
|
31
|
+
function sourceItem(item: (typeof kit.items)[number]): BreadcrumbItem {
|
|
32
|
+
return (
|
|
33
|
+
(item.kind === "item" ? item.item : undefined) ?? {
|
|
34
|
+
label: item.label,
|
|
35
|
+
...(item.value ? { value: item.value } : {}),
|
|
36
|
+
...(item.href ? { href: item.href } : {}),
|
|
37
|
+
current: item.current,
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<nav class={mergedClass} aria-label={kit.a11y.ariaLabel} {...kit.dataAttributes}>
|
|
44
|
+
<ol class={kit.list.className} role={kit.list.a11y.role}>
|
|
45
|
+
{#each kit.items as item, index (item.key)}
|
|
46
|
+
<li class={item.className} {...item.dataAttributes}>
|
|
47
|
+
{#if index > 0}
|
|
48
|
+
<span class={kit.separator.className} aria-hidden={kit.separator.a11y.ariaHidden}>
|
|
49
|
+
<Icon name={IconName.ChevronRight} decorative size={12} />
|
|
50
|
+
</span>
|
|
51
|
+
{/if}
|
|
52
|
+
|
|
53
|
+
{#if item.kind === "home"}
|
|
54
|
+
{#if item.href}
|
|
55
|
+
<a
|
|
56
|
+
class={item.actionClassName}
|
|
57
|
+
href={item.href}
|
|
58
|
+
aria-label={item.a11y.ariaLabel}
|
|
59
|
+
aria-current={item.current ? "page" : undefined}
|
|
60
|
+
onclick={() => onhomeclick?.()}
|
|
61
|
+
>
|
|
62
|
+
<Icon name={IconName.Home} decorative size={14} />
|
|
63
|
+
</a>
|
|
64
|
+
{:else if !item.current}
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
class={item.actionClassName}
|
|
68
|
+
aria-label={item.a11y.ariaLabel}
|
|
69
|
+
aria-current={item.current ? "page" : undefined}
|
|
70
|
+
onclick={() => onhomeclick?.()}
|
|
71
|
+
>
|
|
72
|
+
<Icon name={IconName.Home} decorative size={14} />
|
|
73
|
+
</button>
|
|
74
|
+
{:else}
|
|
75
|
+
<span
|
|
76
|
+
class={item.actionClassName}
|
|
77
|
+
aria-label={item.a11y.ariaLabel}
|
|
78
|
+
aria-current={item.current ? "page" : undefined}
|
|
79
|
+
>
|
|
80
|
+
<Icon name={IconName.Home} decorative size={14} />
|
|
81
|
+
</span>
|
|
82
|
+
{/if}
|
|
83
|
+
{:else if item.current}
|
|
84
|
+
<span
|
|
85
|
+
class={item.actionClassName}
|
|
86
|
+
aria-label={item.a11y.ariaLabel}
|
|
87
|
+
aria-current={item.a11y.ariaCurrent}
|
|
88
|
+
>
|
|
89
|
+
{item.label}
|
|
90
|
+
</span>
|
|
91
|
+
{:else if item.href}
|
|
92
|
+
<a
|
|
93
|
+
class={item.actionClassName}
|
|
94
|
+
href={item.href}
|
|
95
|
+
aria-label={item.a11y.ariaLabel}
|
|
96
|
+
aria-current={item.a11y.ariaCurrent}
|
|
97
|
+
onclick={() => onitemselect?.(item.value ?? item.label, sourceItem(item))}
|
|
98
|
+
>
|
|
99
|
+
{item.label}
|
|
100
|
+
</a>
|
|
101
|
+
{:else}
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
class={item.actionClassName}
|
|
105
|
+
aria-label={item.a11y.ariaLabel}
|
|
106
|
+
aria-current={item.a11y.ariaCurrent}
|
|
107
|
+
onclick={() => onitemselect?.(item.value ?? item.label, sourceItem(item))}
|
|
108
|
+
>
|
|
109
|
+
{item.label}
|
|
110
|
+
</button>
|
|
111
|
+
{/if}
|
|
112
|
+
</li>
|
|
113
|
+
{/each}
|
|
114
|
+
</ol>
|
|
115
|
+
</nav>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Breadcrumb } from "./Breadcrumb.svelte";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BreadcrumbItem, BreadcrumbOptions } from "@marwes-ui/core";
|
|
2
|
+
export interface BreadcrumbProps extends BreadcrumbOptions {
|
|
3
|
+
items: readonly BreadcrumbItem[];
|
|
4
|
+
onitemselect?: (value: string, item: BreadcrumbItem) => void;
|
|
5
|
+
onhomeclick?: () => void;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
export type { BreadcrumbItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
const mergedStyle = $derived(mergeStyle(cssVarsToStyle(kit.vars), style));
|
|
20
20
|
|
|
21
21
|
const resolvedVariant = $derived((options.variant ?? "primary") as ButtonVariant);
|
|
22
|
-
const isFilledVariant = $derived(
|
|
22
|
+
const isFilledVariant = $derived(
|
|
23
|
+
resolvedVariant === "primary" || resolvedVariant === "success" || resolvedVariant === "danger"
|
|
24
|
+
);
|
|
23
25
|
|
|
24
26
|
const visibleLabel = $derived(
|
|
25
27
|
kit.loading.isLoading && kit.loading.loadingLabel !== undefined
|
|
@@ -43,9 +45,11 @@
|
|
|
43
45
|
<Icon name={options.iconLeft} size="xs" strokeWidth="sm" decorative />
|
|
44
46
|
{/if}
|
|
45
47
|
{#if visibleLabel}
|
|
46
|
-
{visibleLabel}
|
|
47
|
-
{:else}
|
|
48
|
-
|
|
48
|
+
<span class="mw-btn__label">{visibleLabel}</span>
|
|
49
|
+
{:else if children}
|
|
50
|
+
<span class="mw-btn__label">
|
|
51
|
+
{@render children()}
|
|
52
|
+
</span>
|
|
49
53
|
{/if}
|
|
50
54
|
{#if !kit.loading.isLoading && options.iconRight}
|
|
51
55
|
<Icon name={options.iconRight} size="xs" strokeWidth="sm" decorative />
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
type Props = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
6
6
|
let { dataAttributes, ...props }: Props = $props();
|
|
7
7
|
</script>
|
|
8
|
-
<Button {...props} variant="
|
|
8
|
+
<Button {...props} variant="danger" action="delete" as="button" dataAttributes={{ ...dataAttributes, ...createPurposeSemanticAttributes("destructive") }} />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ButtonVariant as ButtonVariants } from "@marwes-ui/core";
|
|
3
|
+
import Button from "./Button.svelte";
|
|
4
|
+
import type { IconButtonProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
let { icon, variant = ButtonVariants.neutral, ...props }: IconButtonProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Button {...props} {variant} iconLeft={icon} iconOnly={true} hasVisibleText={false} />
|
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
export { default as Button } from "./Button.svelte";
|
|
2
|
-
export
|
|
2
|
+
export { default as IconButton } from "./IconButton.svelte";
|
|
3
|
+
export { default as PrimaryButton } from "./PrimaryButton.svelte";
|
|
4
|
+
export { default as SecondaryButton } from "./SecondaryButton.svelte";
|
|
5
|
+
export { default as TextButton } from "./TextButton.svelte";
|
|
6
|
+
export { default as SuccessButton } from "./SuccessButton.svelte";
|
|
7
|
+
export { default as DestructiveButton } from "./DestructiveButton.svelte";
|
|
8
|
+
export { default as SubmitButton } from "./SubmitButton.svelte";
|
|
9
|
+
export { default as CancelButton } from "./CancelButton.svelte";
|
|
10
|
+
export { default as CreateButton } from "./CreateButton.svelte";
|
|
11
|
+
export { default as LinkButton } from "./LinkButton.svelte";
|
|
12
|
+
export { default as SaveButton } from "./SaveButton.svelte";
|
|
13
|
+
export { default as ConfirmButton } from "./ConfirmButton.svelte";
|
|
14
|
+
export { default as VerifyButton } from "./VerifyButton.svelte";
|
|
15
|
+
export { default as EditButton } from "./EditButton.svelte";
|
|
16
|
+
export { default as CloseButton } from "./CloseButton.svelte";
|
|
17
|
+
export { default as RefreshButton } from "./RefreshButton.svelte";
|
|
18
|
+
export { default as UploadButton } from "./UploadButton.svelte";
|
|
19
|
+
export { default as DownloadButton } from "./DownloadButton.svelte";
|
|
20
|
+
export { default as CopyButton } from "./CopyButton.svelte";
|
|
21
|
+
export { default as SearchButton } from "./SearchButton.svelte";
|
|
22
|
+
export { default as FilterButton } from "./FilterButton.svelte";
|
|
23
|
+
export { default as SortButton } from "./SortButton.svelte";
|
|
24
|
+
export { default as DropdownButton } from "./DropdownButton.svelte";
|
|
25
|
+
export type { ButtonProps, CancelButtonProps, CloseButtonProps, ConfirmButtonProps, CopyButtonProps, CreateButtonProps, DestructiveButtonProps, DownloadButtonProps, DropdownButtonProps, EditButtonProps, FilterButtonProps, IconButtonProps, LinkButtonProps, PrimaryButtonProps, RefreshButtonProps, SaveButtonProps, SearchButtonProps, SecondaryButtonProps, SortButtonProps, SubmitButtonProps, SuccessButtonProps, TextButtonProps, UploadButtonProps, VerifyButtonProps, } from "./types.js";
|
|
@@ -1 +1,24 @@
|
|
|
1
1
|
export { default as Button } from "./Button.svelte";
|
|
2
|
+
export { default as IconButton } from "./IconButton.svelte";
|
|
3
|
+
export { default as PrimaryButton } from "./PrimaryButton.svelte";
|
|
4
|
+
export { default as SecondaryButton } from "./SecondaryButton.svelte";
|
|
5
|
+
export { default as TextButton } from "./TextButton.svelte";
|
|
6
|
+
export { default as SuccessButton } from "./SuccessButton.svelte";
|
|
7
|
+
export { default as DestructiveButton } from "./DestructiveButton.svelte";
|
|
8
|
+
export { default as SubmitButton } from "./SubmitButton.svelte";
|
|
9
|
+
export { default as CancelButton } from "./CancelButton.svelte";
|
|
10
|
+
export { default as CreateButton } from "./CreateButton.svelte";
|
|
11
|
+
export { default as LinkButton } from "./LinkButton.svelte";
|
|
12
|
+
export { default as SaveButton } from "./SaveButton.svelte";
|
|
13
|
+
export { default as ConfirmButton } from "./ConfirmButton.svelte";
|
|
14
|
+
export { default as VerifyButton } from "./VerifyButton.svelte";
|
|
15
|
+
export { default as EditButton } from "./EditButton.svelte";
|
|
16
|
+
export { default as CloseButton } from "./CloseButton.svelte";
|
|
17
|
+
export { default as RefreshButton } from "./RefreshButton.svelte";
|
|
18
|
+
export { default as UploadButton } from "./UploadButton.svelte";
|
|
19
|
+
export { default as DownloadButton } from "./DownloadButton.svelte";
|
|
20
|
+
export { default as CopyButton } from "./CopyButton.svelte";
|
|
21
|
+
export { default as SearchButton } from "./SearchButton.svelte";
|
|
22
|
+
export { default as FilterButton } from "./FilterButton.svelte";
|
|
23
|
+
export { default as SortButton } from "./SortButton.svelte";
|
|
24
|
+
export { default as DropdownButton } from "./DropdownButton.svelte";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ButtonOptions } from "@marwes-ui/core";
|
|
1
|
+
import type { ButtonOptions, ButtonVariant, IconName } from "@marwes-ui/core";
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
3
|
export interface ButtonProps extends ButtonOptions {
|
|
4
4
|
children?: Snippet;
|
|
@@ -6,3 +6,32 @@ export interface ButtonProps extends ButtonOptions {
|
|
|
6
6
|
class?: string;
|
|
7
7
|
style?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface IconButtonProps extends Omit<ButtonProps, "children" | "hasVisibleText" | "iconLeft" | "iconOnly" | "iconRight"> {
|
|
10
|
+
icon: IconName;
|
|
11
|
+
/** Accessible name — required for icon-only buttons. Prefer `label`; `ariaLabel` also accepted. */
|
|
12
|
+
label?: string;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
variant?: ButtonVariant;
|
|
15
|
+
}
|
|
16
|
+
export type PrimaryButtonProps = Omit<ButtonProps, "variant" | "as">;
|
|
17
|
+
export type SecondaryButtonProps = Omit<ButtonProps, "variant" | "as">;
|
|
18
|
+
export type TextButtonProps = Omit<ButtonProps, "variant" | "as">;
|
|
19
|
+
export type SuccessButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
20
|
+
export type DestructiveButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
21
|
+
export type SubmitButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
22
|
+
export type CancelButtonProps = Omit<ButtonProps, "action">;
|
|
23
|
+
export type CreateButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
24
|
+
export type LinkButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
25
|
+
export type SaveButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
26
|
+
export type ConfirmButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
27
|
+
export type VerifyButtonProps = Omit<ButtonProps, "variant" | "action" | "as">;
|
|
28
|
+
export type EditButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
29
|
+
export type CloseButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
30
|
+
export type RefreshButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
31
|
+
export type UploadButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
32
|
+
export type DownloadButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
33
|
+
export type CopyButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
34
|
+
export type SearchButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
35
|
+
export type FilterButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
36
|
+
export type SortButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
37
|
+
export type DropdownButtonProps = Omit<ButtonProps, "variant" | "action">;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
children,
|
|
9
9
|
class: className,
|
|
10
10
|
id,
|
|
11
|
+
ariaDisabled,
|
|
11
12
|
dataAttributes,
|
|
12
13
|
}: CardProps = $props();
|
|
13
14
|
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
|
-
<div {id} class={mergedClass} {...kit.dataAttributes}>
|
|
19
|
+
<div {id} class={mergedClass} aria-disabled={ariaDisabled} {...kit.dataAttributes}>
|
|
19
20
|
{#if title}
|
|
20
21
|
<div class="mw-card__header">
|
|
21
22
|
<span class="mw-card__title">
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { default as Card } from "./Card.svelte";
|
|
2
|
-
export
|
|
2
|
+
export { default as ProductCard } from "./ProductCard.svelte";
|
|
3
|
+
export { default as ProfileCard } from "./ProfileCard.svelte";
|
|
4
|
+
export { default as StatCard } from "./StatCard.svelte";
|
|
5
|
+
export type { CardProps, ProductCardProps, ProfileCardProps, StatCardProps } from "./types.js";
|
|
@@ -7,4 +7,8 @@ export interface CardProps extends CardOptions {
|
|
|
7
7
|
children?: Snippet;
|
|
8
8
|
class?: string;
|
|
9
9
|
id?: string;
|
|
10
|
+
ariaDisabled?: boolean | "true" | "false";
|
|
10
11
|
}
|
|
12
|
+
export type ProductCardProps = CardProps;
|
|
13
|
+
export type ProfileCardProps = CardProps;
|
|
14
|
+
export type StatCardProps = CardProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { buildCheckboxFieldA11yIds } from "@marwes-ui/core";
|
|
3
3
|
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import Text from "../text/Text.svelte";
|
|
4
5
|
import Checkbox from "./Checkbox.svelte";
|
|
5
6
|
import type { CheckboxFieldProps, CheckboxProps } from "./types.js";
|
|
6
7
|
|
|
@@ -56,19 +57,19 @@
|
|
|
56
57
|
bind:checked
|
|
57
58
|
/>
|
|
58
59
|
<label class="mw-checkbox-field__label" for={fieldId}>
|
|
59
|
-
<
|
|
60
|
+
<Text variant="label">{label}</Text>
|
|
60
61
|
</label>
|
|
61
62
|
</div>
|
|
62
63
|
|
|
63
64
|
{#if hasDescription}
|
|
64
65
|
<div class="mw-checkbox-field__description" id={a11yIds.descriptionId}>
|
|
65
|
-
<
|
|
66
|
+
<Text variant="caption">{description}</Text>
|
|
66
67
|
</div>
|
|
67
68
|
{/if}
|
|
68
69
|
|
|
69
70
|
{#if hasError}
|
|
70
71
|
<div class="mw-checkbox-field__error" id={a11yIds.errorId} aria-live="polite">
|
|
71
|
-
<
|
|
72
|
+
<Text variant="caption">{error}</Text>
|
|
72
73
|
</div>
|
|
73
74
|
{/if}
|
|
74
75
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { buildCheckboxGroupFieldA11yIds } from "@marwes-ui/core";
|
|
3
3
|
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import Text from "../text/Text.svelte";
|
|
4
5
|
import type { CheckboxGroupFieldProps } from "./types.js";
|
|
5
6
|
|
|
6
7
|
let {
|
|
@@ -24,27 +25,38 @@
|
|
|
24
25
|
const hasError = $derived(hasTextContent(error));
|
|
25
26
|
|
|
26
27
|
const a11yIds = $derived(
|
|
27
|
-
buildCheckboxGroupFieldA11yIds({
|
|
28
|
+
buildCheckboxGroupFieldA11yIds({
|
|
29
|
+
id: fieldId,
|
|
30
|
+
hasDescription,
|
|
31
|
+
hasError,
|
|
32
|
+
externalDescribedBy: ariaDescribedBy,
|
|
33
|
+
})
|
|
28
34
|
);
|
|
29
35
|
|
|
30
36
|
const wrapperClass = $derived(mergeClass("mw-checkbox-group-field", className));
|
|
31
37
|
</script>
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
<!-- svelte-ignore a11y_role_supports_aria_props_implicit -->
|
|
40
|
+
<fieldset
|
|
41
|
+
class={wrapperClass}
|
|
42
|
+
aria-labelledby={a11yIds.labelId}
|
|
43
|
+
aria-describedby={a11yIds.describedBy}
|
|
44
|
+
aria-invalid={hasError ? true : undefined}
|
|
45
|
+
>
|
|
34
46
|
<legend class="mw-checkbox-group-field__label" id={a11yIds.labelId}>
|
|
35
|
-
<
|
|
47
|
+
<Text variant="label">{label}</Text>
|
|
36
48
|
</legend>
|
|
37
|
-
|
|
38
|
-
{@render children?.()}
|
|
39
|
-
</div>
|
|
40
|
-
{#if hasDescription && !hasError}
|
|
49
|
+
{#if hasDescription}
|
|
41
50
|
<div class="mw-checkbox-group-field__description" id={a11yIds.descriptionId}>
|
|
42
|
-
<
|
|
51
|
+
<Text variant="caption">{description}</Text>
|
|
43
52
|
</div>
|
|
44
53
|
{/if}
|
|
54
|
+
<div class="mw-checkbox-group-field__options">
|
|
55
|
+
{@render children?.()}
|
|
56
|
+
</div>
|
|
45
57
|
{#if hasError}
|
|
46
58
|
<div class="mw-checkbox-group-field__error" id={a11yIds.errorId} aria-live="polite">
|
|
47
|
-
<
|
|
59
|
+
<Text variant="caption">{error}</Text>
|
|
48
60
|
</div>
|
|
49
61
|
{/if}
|
|
50
62
|
</fieldset>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as Checkbox } from "./Checkbox.svelte";
|
|
2
1
|
export { default as CheckboxField } from "./CheckboxField.svelte";
|
|
3
|
-
export
|
|
2
|
+
export { default as CheckboxGroupField } from "./CheckboxGroupField.svelte";
|
|
3
|
+
export type { CheckboxFieldProps, CheckboxGroupFieldProps, CheckboxGroupFieldOption, } from "./types.js";
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// `Checkbox` (the atom) is intentionally NOT re-exported here.
|
|
2
|
+
// Use `CheckboxField` (or `CheckboxGroupField`) instead. Internal
|
|
3
|
+
// consumers can deep-import "./Checkbox.svelte" directly.
|
|
2
4
|
export { default as CheckboxField } from "./CheckboxField.svelte";
|
|
5
|
+
export { default as CheckboxGroupField } from "./CheckboxGroupField.svelte";
|
|
@@ -19,6 +19,13 @@ export interface CheckboxFieldProps {
|
|
|
19
19
|
checked?: boolean;
|
|
20
20
|
class?: string;
|
|
21
21
|
}
|
|
22
|
+
export interface CheckboxGroupFieldOption {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
indeterminate?: boolean;
|
|
28
|
+
}
|
|
22
29
|
export interface CheckboxGroupFieldProps {
|
|
23
30
|
id?: string;
|
|
24
31
|
label: string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createContextMenuRecipe } from "@marwes-ui/core";
|
|
3
|
+
import Icon from "../icon/Icon.svelte";
|
|
4
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
5
|
+
import type { ContextMenuProps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
items,
|
|
9
|
+
ariaLabel,
|
|
10
|
+
dataAttributes,
|
|
11
|
+
onselect,
|
|
12
|
+
class: className,
|
|
13
|
+
}: ContextMenuProps = $props();
|
|
14
|
+
|
|
15
|
+
const menuOptions = $derived.by(() => {
|
|
16
|
+
const options = { items };
|
|
17
|
+
if (ariaLabel !== undefined) Object.assign(options, { ariaLabel });
|
|
18
|
+
if (dataAttributes !== undefined) Object.assign(options, { dataAttributes });
|
|
19
|
+
return options;
|
|
20
|
+
});
|
|
21
|
+
const kit = $derived(createContextMenuRecipe(menuOptions));
|
|
22
|
+
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div class={mergedClass} role={kit.a11y.role} aria-label={kit.a11y.ariaLabel} {...kit.dataAttributes}>
|
|
26
|
+
{#each kit.items as item (item.key)}
|
|
27
|
+
{#if item.kind === "divider"}
|
|
28
|
+
<div
|
|
29
|
+
class={item.className}
|
|
30
|
+
role={item.a11y.role}
|
|
31
|
+
aria-orientation={item.a11y.ariaOrientation}
|
|
32
|
+
{...item.dataAttributes}
|
|
33
|
+
></div>
|
|
34
|
+
{:else}
|
|
35
|
+
<button
|
|
36
|
+
type={item.a11y.type}
|
|
37
|
+
role={item.a11y.role}
|
|
38
|
+
disabled={item.a11y.disabled}
|
|
39
|
+
aria-disabled={item.a11y.ariaDisabled}
|
|
40
|
+
class={item.className}
|
|
41
|
+
onclick={() => {
|
|
42
|
+
if (item.item.disabled) return;
|
|
43
|
+
onselect?.(item.value, item.item);
|
|
44
|
+
}}
|
|
45
|
+
{...item.dataAttributes}
|
|
46
|
+
>
|
|
47
|
+
{#if item.icon}
|
|
48
|
+
<span class="mw-context-menu__icon" aria-hidden="true">
|
|
49
|
+
<Icon name={item.icon} decorative />
|
|
50
|
+
</span>
|
|
51
|
+
{/if}
|
|
52
|
+
<span class="mw-context-menu__label">{item.label}</span>
|
|
53
|
+
</button>
|
|
54
|
+
{/if}
|
|
55
|
+
{/each}
|
|
56
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ContextMenu } from "./ContextMenu.svelte";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContextMenuActionItem, ContextMenuEntry, ContextMenuOptions } from "@marwes-ui/core";
|
|
2
|
+
export interface ContextMenuProps extends ContextMenuOptions {
|
|
3
|
+
items: readonly ContextMenuEntry[];
|
|
4
|
+
onselect?: (value: string, item: ContextMenuActionItem) => void;
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
export type { ContextMenuActionItem, ContextMenuEntry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
nextYearLabel,
|
|
16
16
|
cancelLabel,
|
|
17
17
|
applyLabel,
|
|
18
|
+
ariaLabel,
|
|
19
|
+
ariaLabelledBy,
|
|
20
|
+
ariaDescribedBy,
|
|
18
21
|
calendarLabel,
|
|
19
22
|
dataAttributes,
|
|
20
23
|
onpreviousyear,
|
|
@@ -39,6 +42,9 @@
|
|
|
39
42
|
if (nextYearLabel !== undefined) opts.nextYearLabel = nextYearLabel;
|
|
40
43
|
if (cancelLabel !== undefined) opts.cancelLabel = cancelLabel;
|
|
41
44
|
if (applyLabel !== undefined) opts.applyLabel = applyLabel;
|
|
45
|
+
if (ariaLabel !== undefined) opts.ariaLabel = ariaLabel;
|
|
46
|
+
if (ariaLabelledBy !== undefined) opts.ariaLabelledBy = ariaLabelledBy;
|
|
47
|
+
if (ariaDescribedBy !== undefined) opts.ariaDescribedBy = ariaDescribedBy;
|
|
42
48
|
if (calendarLabel !== undefined) opts.calendarLabel = calendarLabel;
|
|
43
49
|
if (dataAttributes !== undefined) opts.dataAttributes = dataAttributes;
|
|
44
50
|
return opts;
|
|
@@ -48,7 +54,13 @@
|
|
|
48
54
|
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
49
55
|
</script>
|
|
50
56
|
|
|
51
|
-
<section
|
|
57
|
+
<section
|
|
58
|
+
class={mergedClass}
|
|
59
|
+
aria-label={kit.a11y.ariaLabel}
|
|
60
|
+
aria-labelledby={kit.a11y.ariaLabelledBy}
|
|
61
|
+
aria-describedby={kit.a11y.ariaDescribedBy}
|
|
62
|
+
{...kit.dataAttributes}
|
|
63
|
+
>
|
|
52
64
|
<header class={kit.slots.headerClassName}>
|
|
53
65
|
<div class={kit.slots.navGroupClassName}>
|
|
54
66
|
<button type="button" class={kit.slots.navButtonClassName} aria-label={kit.labels.previousYear} onclick={onpreviousyear}>«</button>
|
|
@@ -64,7 +76,7 @@
|
|
|
64
76
|
<table class={kit.slots.gridClassName} aria-label={kit.monthLabel}>
|
|
65
77
|
<thead>
|
|
66
78
|
<tr class="mw-date-picker__weekdays">
|
|
67
|
-
{#each kit.weekdayLabels as weekday (
|
|
79
|
+
{#each kit.weekdayLabels as weekday, weekdayIndex (weekdayIndex)}
|
|
68
80
|
<th class={kit.slots.weekdayClassName} scope="col">{weekday}</th>
|
|
69
81
|
{/each}
|
|
70
82
|
</tr>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { buildInputFieldA11yIds } from "@marwes-ui/core";
|
|
3
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import Text from "../text/Text.svelte";
|
|
5
|
+
import DatePicker from "./DatePicker.svelte";
|
|
6
|
+
import type { DatePickerFieldProps, DatePickerProps } from "./types.js";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
id: userProvidedId,
|
|
10
|
+
label,
|
|
11
|
+
helperText,
|
|
12
|
+
error,
|
|
13
|
+
datePicker = {},
|
|
14
|
+
ariaDescribedBy,
|
|
15
|
+
class: className,
|
|
16
|
+
}: DatePickerFieldProps = $props();
|
|
17
|
+
|
|
18
|
+
const uniqueId = $props.id();
|
|
19
|
+
const fieldId = $derived(userProvidedId ?? `mw-date-picker-${uniqueId}`);
|
|
20
|
+
const labelId = $derived(`${fieldId}-label`);
|
|
21
|
+
|
|
22
|
+
function hasTextContent(text: string | undefined): boolean {
|
|
23
|
+
return text !== undefined && text.trim().length > 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const hasHelperText = $derived(hasTextContent(helperText));
|
|
27
|
+
const hasError = $derived(hasTextContent(error));
|
|
28
|
+
|
|
29
|
+
const a11yIds = $derived(
|
|
30
|
+
buildInputFieldA11yIds({
|
|
31
|
+
id: fieldId,
|
|
32
|
+
hasHelperText,
|
|
33
|
+
hasError,
|
|
34
|
+
externalDescribedBy: ariaDescribedBy,
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const wrapperClass = $derived(
|
|
39
|
+
mergeClass("mw-date-picker-field", hasError && "mw-date-picker-field--invalid", className)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const datePickerProps = $derived.by((): DatePickerProps => {
|
|
43
|
+
const props: DatePickerProps = {
|
|
44
|
+
...datePicker,
|
|
45
|
+
ariaLabelledBy: labelId,
|
|
46
|
+
};
|
|
47
|
+
if (a11yIds.describedBy) {
|
|
48
|
+
props.ariaDescribedBy = a11yIds.describedBy;
|
|
49
|
+
}
|
|
50
|
+
return props;
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div class={wrapperClass}>
|
|
55
|
+
<span class="mw-date-picker-field__label" id={labelId}>
|
|
56
|
+
<Text variant="label">{label}</Text>
|
|
57
|
+
</span>
|
|
58
|
+
|
|
59
|
+
<DatePicker {...datePickerProps} />
|
|
60
|
+
|
|
61
|
+
{#if hasHelperText && !hasError}
|
|
62
|
+
<div class="mw-date-picker-field__helper" id={a11yIds.helperTextId}>
|
|
63
|
+
<Text variant="caption">{helperText}</Text>
|
|
64
|
+
</div>
|
|
65
|
+
{/if}
|
|
66
|
+
|
|
67
|
+
{#if hasError}
|
|
68
|
+
<div class="mw-date-picker-field__error" id={a11yIds.errorId} aria-live="polite">
|
|
69
|
+
<Text variant="caption">{error}</Text>
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
72
|
+
</div>
|