reburn-ui 0.4.9 → 0.4.11
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/core/CodeHighlight/CodeHighlight.context.svelte.d.ts +2 -5
- package/dist/core/CodeHighlight/CodeHighlight.context.svelte.js +4 -3
- package/dist/core/CodeHighlight/CodeHighlight.svelte +6 -10
- package/dist/core/CodeHighlight/CodeHighlightControl.svelte +51 -1
- package/dist/core/CodeHighlight/CopyCodeButton/CopyCodeButton.svelte +2 -2
- package/dist/core/Notifications/NotificationContainer.svelte +4 -3
- package/dist/core/Notifications/Notifications.svelte +2 -2
- package/dist/core/Notifications/NotificationsStore.svelte.d.ts +1 -1
- package/dist/core/Notifications/NotificationsStore.svelte.js +1 -1
- package/dist/core/charts/ChartRoot/ChartContext.svelte.d.ts +2 -13
- package/dist/core/charts/ChartRoot/ChartContext.svelte.js +4 -3
- package/dist/core/charts/ChartRoot/ChartRoot.svelte +6 -8
- package/dist/core/charts/ChartTooltip/ChartTooltip.svelte +21 -6
- package/dist/core/charts/ScatterChart/ScatterChartInner.svelte +7 -5
- package/dist/core/charts/ScatterChart/ScatterChartInner.svelte.d.ts +1 -1
- package/dist/core/components/Anchor/Anchor.svelte +65 -0
- package/dist/core/components/Anchor/Anchor.svelte.d.ts +9 -0
- package/dist/core/components/AppShell/AppShell.svelte +2 -4
- package/dist/core/components/AppShell/AppShellContext.svelte.d.ts +7 -12
- package/dist/core/components/AppShell/AppShellContext.svelte.js +4 -3
- package/dist/core/components/Checkbox/Checkbox.svelte +37 -18
- package/dist/core/components/Checkbox/CheckboxCard/CheckboxCard.svelte +1 -4
- package/dist/core/components/Checkbox/CheckboxCard/CheckboxCardContext.svelte.d.ts +1 -2
- package/dist/core/components/Checkbox/CheckboxCard/CheckboxCardContext.svelte.js +4 -3
- package/dist/core/components/Checkbox/CheckboxGroup/CheckboxGroup.svelte +6 -7
- package/dist/core/components/Checkbox/CheckboxGroup/CheckboxGroup.svelte.d.ts +2 -2
- package/dist/core/components/Checkbox/CheckboxGroup/CheckboxGroupContext.svelte.d.ts +1 -2
- package/dist/core/components/Checkbox/CheckboxGroup/CheckboxGroupContext.svelte.js +4 -3
- package/dist/core/components/Checkbox/CheckboxIndicator.svelte +5 -7
- package/dist/core/components/Chip/ChipGroup/ChipGroup.svelte +1 -4
- package/dist/core/components/Chip/ChipGroup/ChipGroupContext.svelte.d.ts +1 -2
- package/dist/core/components/Chip/ChipGroup/ChipGroupContext.svelte.js +4 -3
- package/dist/core/components/Combobox/Combobox.svelte +3 -6
- package/dist/core/components/Combobox/Combobox.svelte.d.ts +1 -1
- package/dist/core/components/Combobox/ComboboxContext.svelte.d.ts +1 -2
- package/dist/core/components/Combobox/ComboboxContext.svelte.js +4 -3
- package/dist/core/components/CopyButton/CopyButton.svelte +2 -3
- package/dist/core/components/Floating/CreateFloating.svelte.d.ts +1 -1
- package/dist/core/components/Floating/CreateFloating.svelte.js +4 -4
- package/dist/core/components/Input/Input.context.svelte.d.ts +1 -2
- package/dist/core/components/Input/Input.context.svelte.js +4 -3
- package/dist/core/components/Input/Input.svelte +2 -4
- package/dist/core/components/Input/InputWrapper.context.svelte.d.ts +1 -2
- package/dist/core/components/Input/InputWrapper.context.svelte.js +4 -3
- package/dist/core/components/Input/InputWrapper.svelte +2 -4
- package/dist/core/components/ModalBase/CreateModal.svelte.js +2 -2
- package/dist/core/components/ModalBase/LockScroll.svelte.js +2 -2
- package/dist/core/components/Overlay/Overlay.svelte +2 -4
- package/dist/core/components/Pill/PillGroup.svelte +1 -4
- package/dist/core/components/Pill/PillGroupContext.svelte.d.ts +4 -8
- package/dist/core/components/Pill/PillGroupContext.svelte.js +3 -2
- package/dist/core/components/Popover/Popover.svelte +8 -10
- package/dist/core/components/Popover/PopoverContext.svelte.d.ts +7 -7
- package/dist/core/components/Popover/PopoverContext.svelte.js +33 -56
- package/dist/core/components/Popover/PopoverDropdown.svelte +5 -5
- package/dist/core/components/Progress/ProgressContext.svelte.d.ts +1 -2
- package/dist/core/components/Progress/ProgressContext.svelte.js +4 -3
- package/dist/core/components/Progress/ProgressRoot.svelte +3 -5
- package/dist/core/components/ScrollArea/ScrollAreaCorner.svelte +3 -3
- package/dist/core/components/ScrollArea/ScrollAreaScrollbar/ScrollAreaScrollbarAuto.svelte +3 -3
- package/dist/core/components/ScrollArea/ScrollAreaScrollbar/Scrollbar.svelte +3 -3
- package/dist/core/components/Select/Select.svelte +2 -2
- package/dist/core/components/Slider/CreateRangeSlider.svelte.d.ts +1 -1
- package/dist/core/components/Slider/CreateRangeSlider.svelte.js +1 -1
- package/dist/core/components/Slider/CreateSlider.svelte.d.ts +1 -1
- package/dist/core/components/Slider/CreateSlider.svelte.js +1 -1
- package/dist/core/components/Stack/Stack.svelte +33 -0
- package/dist/core/components/Stack/Stack.svelte.d.ts +14 -0
- package/dist/core/components/Switch/SwitchGroup/SwitchGroup.svelte +2 -5
- package/dist/core/components/Switch/SwitchGroup/SwitchGroupContext.svelte.d.ts +1 -2
- package/dist/core/components/Switch/SwitchGroup/SwitchGroupContext.svelte.js +4 -3
- package/dist/core/components/Table/Table.svelte +1 -4
- package/dist/core/components/Table/TableContext.svelte.d.ts +1 -2
- package/dist/core/components/Table/TableContext.svelte.js +4 -3
- package/dist/core/components/Tabs/Tabs.svelte +87 -0
- package/dist/core/components/Tabs/Tabs.svelte.d.ts +41 -0
- package/dist/core/components/Tooltip/CreateTooltip.svelte.d.ts +1 -1
- package/dist/core/components/Tooltip/Tooltip.svelte +4 -3
- package/dist/core/components/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/core/components/Transitions/transitions.d.ts +31 -11
- package/dist/core/components/Transitions/transitions.js +13 -12
- package/dist/core/components/index.d.ts +3 -0
- package/dist/core/components/index.js +3 -0
- package/dist/core/hooks/index.d.ts +1 -0
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/use-click-outside.svelte.d.ts +3 -5
- package/dist/core/hooks/use-click-outside.svelte.js +18 -15
- package/dist/core/hooks/use-clipboard.svelte.d.ts +6 -5
- package/dist/core/hooks/use-clipboard.svelte.js +17 -11
- package/dist/core/hooks/use-color-scheme.svelte.d.ts +3 -1
- package/dist/core/hooks/use-color-scheme.svelte.js +4 -1
- package/dist/core/hooks/use-counter.svelte.d.ts +3 -1
- package/dist/core/hooks/use-counter.svelte.js +4 -1
- package/dist/core/hooks/use-disclosur.svelte.d.ts +2 -1
- package/dist/core/hooks/use-disclosur.svelte.js +4 -1
- package/dist/core/hooks/use-focus-return.svelte.d.ts +3 -1
- package/dist/core/hooks/use-focus-return.svelte.js +4 -1
- package/dist/core/hooks/use-previous.svelte.d.ts +3 -1
- package/dist/core/hooks/use-previous.svelte.js +4 -1
- package/dist/core/hooks/use-reduced-motion.svelte.d.ts +1 -1
- package/dist/core/hooks/use-reduced-motion.svelte.js +1 -1
- package/dist/core/hooks/use-resize-observer.svelte.d.ts +3 -1
- package/dist/core/hooks/use-resize-observer.svelte.js +4 -1
- package/dist/core/hooks/utils/random-id.d.ts +1 -0
- package/dist/core/hooks/utils/random-id.js +3 -0
- package/dist/core/utils/data-attr.d.ts +1 -0
- package/dist/core/utils/data-attr.js +3 -0
- package/dist/docs/CodeDemo.svelte +23 -0
- package/dist/docs/CodeDemo.svelte.d.ts +7 -0
- package/dist/docs/DocsNavbar.svelte +47 -0
- package/dist/docs/DocsNavbar.svelte.d.ts +18 -0
- package/dist/docs/DocsTitle.svelte +36 -0
- package/dist/docs/DocsTitle.svelte.d.ts +6 -0
- package/dist/docs/StaticDemo.svelte +62 -0
- package/dist/docs/StaticDemo.svelte.d.ts +11 -0
- package/dist/docs/UsageDemo.svelte +65 -17
- package/dist/docs/UsageDemo.svelte.d.ts +15 -7
- package/dist/docs/UsageDemoSizeSlider.svelte +41 -0
- package/dist/docs/UsageDemoSizeSlider.svelte.d.ts +14 -0
- package/dist/docs/formatProps.d.ts +6 -0
- package/dist/docs/formatProps.js +37 -0
- package/dist/dropzone/Child.svelte +11 -0
- package/dist/dropzone/Child.svelte.d.ts +18 -0
- package/dist/dropzone/Dropzone.svelte +141 -0
- package/dist/dropzone/Dropzone.svelte.d.ts +90 -0
- package/dist/dropzone/DropzoneContext.svelte.d.ts +7 -0
- package/dist/dropzone/DropzoneContext.svelte.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/ports/index.d.ts +1 -0
- package/dist/ports/index.js +1 -0
- package/dist/ports/svelte-dropzone/CreateDropzone.svelte.d.ts +23 -0
- package/dist/ports/svelte-dropzone/CreateDropzone.svelte.js +402 -0
- package/dist/ports/svelte-dropzone/types.d.ts +28 -0
- package/dist/ports/svelte-dropzone/types.js +1 -0
- package/dist/ports/svelte-dropzone/utils.d.ts +133 -0
- package/dist/ports/svelte-dropzone/utils.js +235 -0
- package/dist/styles/default-css-variables.css +14 -6
- package/dist/svelte-utils/CreateSvelteEvent.svelte.d.ts +20 -0
- package/dist/svelte-utils/CreateSvelteEvent.svelte.js +13 -0
- package/dist/{core/context → svelte-utils}/extract.d.ts +8 -1
- package/package.json +20 -18
- /package/dist/{core/context → svelte-utils}/extract.js +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { title }: { title: string } = $props();
|
|
3
|
+
|
|
4
|
+
function createAnchorId(title: string) {
|
|
5
|
+
return title.toLowerCase().replace(/ /g, '-');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// svelte-ignore state_referenced_locally
|
|
9
|
+
const anchorId = createAnchorId(title);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<h2 class="title" id={anchorId}>
|
|
13
|
+
<a class="link" href={`#${anchorId}`}>{title}</a>
|
|
14
|
+
</h2>
|
|
15
|
+
|
|
16
|
+
<style>.title {
|
|
17
|
+
--title-fw: var(--mantine-h2-font-weight);
|
|
18
|
+
--title-lh: var(--mantine-h2-line-height);
|
|
19
|
+
--title-fz: var(--mantine-h2-font-size);
|
|
20
|
+
margin: 0;
|
|
21
|
+
font-size: var(--title-fz);
|
|
22
|
+
line-height: var(--title-lh);
|
|
23
|
+
text-wrap: var(--title-text-wrap, var(--mantine-heading-text-wrap));
|
|
24
|
+
margin-top: calc(var(--mantine-spacing-xl) * 1.2);
|
|
25
|
+
margin-bottom: var(--mantine-spacing-md);
|
|
26
|
+
overflow-wrap: break-word;
|
|
27
|
+
font-family: var(--docs-font-primary);
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
position: relative;
|
|
30
|
+
color: var(--mantine-color-bright);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.link {
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
color: inherit;
|
|
36
|
+
}</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CodeHighlight from '../core/CodeHighlight/CodeHighlight.svelte';
|
|
3
|
+
import { type Snippet } from 'svelte';
|
|
4
|
+
import DocsTitle from './DocsTitle.svelte';
|
|
5
|
+
|
|
6
|
+
interface UsageDemoProps {
|
|
7
|
+
title: string;
|
|
8
|
+
children: Snippet;
|
|
9
|
+
withPadding?: boolean;
|
|
10
|
+
centered?: boolean;
|
|
11
|
+
code?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { title, children, withPadding = true, centered = true, code }: UsageDemoProps = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<DocsTitle {title} />
|
|
18
|
+
|
|
19
|
+
<div class="container">
|
|
20
|
+
<div class="demo-container">
|
|
21
|
+
<div class="demo-preview" data-with-padding={withPadding || undefined} data-centered={centered || undefined}>
|
|
22
|
+
{@render children()}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
{#if code}
|
|
27
|
+
<div class="demo-code">
|
|
28
|
+
<CodeHighlight {code} language="svelte" />
|
|
29
|
+
</div>
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<style>.container {
|
|
34
|
+
container-type: inline-size;
|
|
35
|
+
border: 1px solid var(--demo-border);
|
|
36
|
+
border-radius: var(--mantine-radius-md);
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
:global([data-mantine-color-scheme='light']) .container {
|
|
40
|
+
--demo-border: var(--mantine-color-gray-2);
|
|
41
|
+
}
|
|
42
|
+
:global([data-mantine-color-scheme='dark']) .container {
|
|
43
|
+
--demo-border: var(--mantine-color-dark-5);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.demo-container {
|
|
47
|
+
display: flex;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.demo-preview {
|
|
51
|
+
flex: 1;
|
|
52
|
+
border-top-left-radius: calc(var(--mantine-radius-md) - 1px);
|
|
53
|
+
border-top-right-radius: calc(var(--mantine-radius-md) - 1px);
|
|
54
|
+
}
|
|
55
|
+
.demo-preview[data-with-padding] {
|
|
56
|
+
padding: var(--mantine-spacing-md);
|
|
57
|
+
}
|
|
58
|
+
.demo-preview[data-centered] {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
}</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
interface UsageDemoProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: Snippet;
|
|
5
|
+
withPadding?: boolean;
|
|
6
|
+
centered?: boolean;
|
|
7
|
+
code?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const StaticDemo: import("svelte").Component<UsageDemoProps, {}, "">;
|
|
10
|
+
type StaticDemo = ReturnType<typeof StaticDemo>;
|
|
11
|
+
export default StaticDemo;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SegmentedControlProps } from '../core/components/SegmentedControl/SegmentedControl.svelte';
|
|
3
|
-
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
4
|
-
import type { SwitchProps } from '../core/components/Switch/Switch.svelte';
|
|
5
|
-
import type { TextInputProps } from '../core/components/TextInput/TextInput.svelte';
|
|
6
|
-
import { SegmentedControl, Slider, Switch, TextInput } from '../core/index.js';
|
|
7
|
-
import type { Snippet } from 'svelte';
|
|
8
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
9
2
|
interface SegmentedControlItem extends SegmentedControlProps {
|
|
10
3
|
type: 'segmented-control';
|
|
11
4
|
name: string;
|
|
@@ -24,6 +17,14 @@
|
|
|
24
17
|
type: 'slider';
|
|
25
18
|
name: string;
|
|
26
19
|
defaultValue: number;
|
|
20
|
+
inputLabel: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface UsageDemoSizeSliderItem extends Omit<SliderProps, 'defaultValue'> {
|
|
24
|
+
type: 'size-slider';
|
|
25
|
+
name: string;
|
|
26
|
+
defaultValue: (typeof usageDemoSizeSliderMarks)[number]['label'];
|
|
27
|
+
inputLabel: string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
interface SwitchItem extends SwitchProps {
|
|
@@ -33,20 +34,33 @@
|
|
|
33
34
|
defaultValue: boolean;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
type UsageDemoSettings = SegmentedControlItem | TextInputItem | SliderItem | SwitchItem;
|
|
37
|
+
export type UsageDemoSettings = SegmentedControlItem | TextInputItem | SliderItem | SwitchItem | UsageDemoSizeSliderItem;
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
import CodeHighlight from '../core/CodeHighlight/CodeHighlight.svelte';
|
|
42
|
+
import type { SegmentedControlProps } from '../core/components/SegmentedControl/SegmentedControl.svelte';
|
|
43
|
+
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
44
|
+
import type { SwitchProps } from '../core/components/Switch/Switch.svelte';
|
|
45
|
+
import type { TextInputProps } from '../core/components/TextInput/TextInput.svelte';
|
|
46
|
+
import { Input, SegmentedControl, Slider, Switch, TextInput } from '../core/index.js';
|
|
47
|
+
import { untrack, type Snippet } from 'svelte';
|
|
48
|
+
import DocsTitle from './DocsTitle.svelte';
|
|
49
|
+
import UsageDemoSizeSlider, { usageDemoSizeSliderMarks } from './UsageDemoSizeSlider.svelte';
|
|
50
|
+
import { formatProps } from './formatProps.js';
|
|
37
51
|
|
|
38
52
|
interface UsageDemoProps {
|
|
39
53
|
title?: string;
|
|
40
54
|
children: Snippet<[props: Record<string, unknown>]>;
|
|
41
55
|
withPadding?: boolean;
|
|
42
56
|
centered?: boolean;
|
|
43
|
-
|
|
57
|
+
code?: (props: string) => string;
|
|
44
58
|
|
|
45
59
|
defaultProps?: Record<string, unknown>;
|
|
46
60
|
settings: UsageDemoSettings[];
|
|
47
61
|
}
|
|
48
62
|
|
|
49
|
-
let { title = 'Usage', children, withPadding = true, centered = true,
|
|
63
|
+
let { title = 'Usage', children, withPadding = true, centered = true, defaultProps = {}, settings, code }: UsageDemoProps = $props();
|
|
50
64
|
|
|
51
65
|
function createPreviewProps(settings: UsageDemoSettings[]) {
|
|
52
66
|
const _props = { ...defaultProps };
|
|
@@ -56,12 +70,12 @@
|
|
|
56
70
|
return _props;
|
|
57
71
|
}
|
|
58
72
|
|
|
59
|
-
let previewProps = $state(createPreviewProps(settings));
|
|
73
|
+
let previewProps = $state(createPreviewProps(untrack(() => settings)));
|
|
74
|
+
|
|
75
|
+
const formattedProps = $derived(formatProps(previewProps, defaultProps, settings));
|
|
60
76
|
</script>
|
|
61
77
|
|
|
62
|
-
<
|
|
63
|
-
<a class="link" href={`${href}#usage`} id="usage">{title}</a>
|
|
64
|
-
</h2>
|
|
78
|
+
<DocsTitle {title} />
|
|
65
79
|
|
|
66
80
|
<div class="container">
|
|
67
81
|
<div class="demo-container">
|
|
@@ -72,21 +86,44 @@
|
|
|
72
86
|
<div class="demo-settings">
|
|
73
87
|
{#each settings as setting}
|
|
74
88
|
{#if setting.type === 'segmented-control'}
|
|
75
|
-
<
|
|
89
|
+
<Input.Wrapper label={setting.label}>
|
|
90
|
+
<SegmentedControl {...setting} bind:value={previewProps[setting.name] as string} fullWidth />
|
|
91
|
+
</Input.Wrapper>
|
|
76
92
|
{:else if setting.type === 'text'}
|
|
77
93
|
<TextInput {...setting} bind:value={previewProps[setting.name] as string} />
|
|
78
94
|
{:else if setting.type === 'slider'}
|
|
79
|
-
<
|
|
95
|
+
<Input.Wrapper label={setting.inputLabel}>
|
|
96
|
+
<Slider {...setting} bind:value={previewProps[setting.name] as number} />
|
|
97
|
+
</Input.Wrapper>
|
|
98
|
+
{:else if setting.type === 'size-slider'}
|
|
99
|
+
<Input.Wrapper label={setting.inputLabel}>
|
|
100
|
+
<UsageDemoSizeSlider {setting} bind:previewProps />
|
|
101
|
+
</Input.Wrapper>
|
|
80
102
|
{:else if setting.type === 'switch'}
|
|
81
103
|
<Switch {...setting} bind:checked={previewProps[setting.name] as boolean} />
|
|
82
104
|
{/if}
|
|
83
105
|
{/each}
|
|
84
106
|
</div>
|
|
85
107
|
</div>
|
|
108
|
+
|
|
109
|
+
{#if code}
|
|
110
|
+
<div class="demo-code">
|
|
111
|
+
<CodeHighlight code={code(formattedProps)} language="svelte" />
|
|
112
|
+
</div>
|
|
113
|
+
{/if}
|
|
86
114
|
</div>
|
|
87
115
|
|
|
88
116
|
<style>.container {
|
|
89
117
|
container-type: inline-size;
|
|
118
|
+
border: 1px solid var(--demo-border);
|
|
119
|
+
border-radius: var(--mantine-radius-md);
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
}
|
|
122
|
+
:global([data-mantine-color-scheme='light']) .container {
|
|
123
|
+
--demo-border: var(--mantine-color-gray-2);
|
|
124
|
+
}
|
|
125
|
+
:global([data-mantine-color-scheme='dark']) .container {
|
|
126
|
+
--demo-border: var(--mantine-color-dark-5);
|
|
90
127
|
}
|
|
91
128
|
|
|
92
129
|
.demo-container {
|
|
@@ -110,4 +147,15 @@
|
|
|
110
147
|
.link {
|
|
111
148
|
text-decoration: none;
|
|
112
149
|
color: inherit;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.demo-settings {
|
|
153
|
+
--sg-spacing-x: var(--mantine-spacing-md);
|
|
154
|
+
--sg-spacing-y: var(--mantine-spacing-md);
|
|
155
|
+
--sg-cols: 1;
|
|
156
|
+
display: grid;
|
|
157
|
+
grid-template-columns: repeat(var(--sg-cols), minmax(0, 1fr));
|
|
158
|
+
gap: var(--sg-spacing-y) var(--sg-spacing-x);
|
|
159
|
+
padding: calc(0.5rem * var(--mantine-scale));
|
|
160
|
+
border-inline-start: 1px solid var(--demo-border);
|
|
113
161
|
}</style>
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type { SegmentedControlProps } from '../core/components/SegmentedControl/SegmentedControl.svelte';
|
|
2
|
-
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
3
|
-
import type { SwitchProps } from '../core/components/Switch/Switch.svelte';
|
|
4
|
-
import type { TextInputProps } from '../core/components/TextInput/TextInput.svelte';
|
|
5
|
-
import type { Snippet } from 'svelte';
|
|
6
1
|
interface SegmentedControlItem extends SegmentedControlProps {
|
|
7
2
|
type: 'segmented-control';
|
|
8
3
|
name: string;
|
|
@@ -19,6 +14,13 @@ interface SliderItem extends SliderProps {
|
|
|
19
14
|
type: 'slider';
|
|
20
15
|
name: string;
|
|
21
16
|
defaultValue: number;
|
|
17
|
+
inputLabel: string;
|
|
18
|
+
}
|
|
19
|
+
interface UsageDemoSizeSliderItem extends Omit<SliderProps, 'defaultValue'> {
|
|
20
|
+
type: 'size-slider';
|
|
21
|
+
name: string;
|
|
22
|
+
defaultValue: (typeof usageDemoSizeSliderMarks)[number]['label'];
|
|
23
|
+
inputLabel: string;
|
|
22
24
|
}
|
|
23
25
|
interface SwitchItem extends SwitchProps {
|
|
24
26
|
type: 'switch';
|
|
@@ -26,13 +28,19 @@ interface SwitchItem extends SwitchProps {
|
|
|
26
28
|
name: string;
|
|
27
29
|
defaultValue: boolean;
|
|
28
30
|
}
|
|
29
|
-
type UsageDemoSettings = SegmentedControlItem | TextInputItem | SliderItem | SwitchItem;
|
|
31
|
+
export type UsageDemoSettings = SegmentedControlItem | TextInputItem | SliderItem | SwitchItem | UsageDemoSizeSliderItem;
|
|
32
|
+
import type { SegmentedControlProps } from '../core/components/SegmentedControl/SegmentedControl.svelte';
|
|
33
|
+
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
34
|
+
import type { SwitchProps } from '../core/components/Switch/Switch.svelte';
|
|
35
|
+
import type { TextInputProps } from '../core/components/TextInput/TextInput.svelte';
|
|
36
|
+
import { type Snippet } from 'svelte';
|
|
37
|
+
import { usageDemoSizeSliderMarks } from './UsageDemoSizeSlider.svelte';
|
|
30
38
|
interface UsageDemoProps {
|
|
31
39
|
title?: string;
|
|
32
40
|
children: Snippet<[props: Record<string, unknown>]>;
|
|
33
41
|
withPadding?: boolean;
|
|
34
42
|
centered?: boolean;
|
|
35
|
-
|
|
43
|
+
code?: (props: string) => string;
|
|
36
44
|
defaultProps?: Record<string, unknown>;
|
|
37
45
|
settings: UsageDemoSettings[];
|
|
38
46
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export const usageDemoSizeSliderMarks = [
|
|
3
|
+
{ value: 0, label: 'xs' },
|
|
4
|
+
{ value: 25, label: 'sm' },
|
|
5
|
+
{ value: 50, label: 'md' },
|
|
6
|
+
{ value: 75, label: 'lg' },
|
|
7
|
+
{ value: 100, label: 'xl' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const withoutLabels = usageDemoSizeSliderMarks.map((mark) => ({ value: mark.value }));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
15
|
+
import { Slider } from '../core/index.js';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
setting,
|
|
19
|
+
previewProps = $bindable(),
|
|
20
|
+
}: { setting: Omit<SliderProps, 'defaultValue'> & { name: string }; previewProps: Record<string, unknown> } = $props();
|
|
21
|
+
|
|
22
|
+
function getValue() {
|
|
23
|
+
const found = usageDemoSizeSliderMarks.find((mark) => mark.label === (previewProps[setting.name] as string))?.value;
|
|
24
|
+
|
|
25
|
+
if (found === undefined) return 25;
|
|
26
|
+
|
|
27
|
+
return found;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function setValue(value: number) {
|
|
31
|
+
previewProps[setting.name] = usageDemoSizeSliderMarks.find((mark) => mark.value === value)?.label || 'sm';
|
|
32
|
+
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<Slider {...setting} marks={withoutLabels} restrictToMarks bind:value={getValue, setValue}>
|
|
38
|
+
{#snippet label(val)}
|
|
39
|
+
{usageDemoSizeSliderMarks.find((mark) => mark.value === val)?.label || 'sm'}
|
|
40
|
+
{/snippet}
|
|
41
|
+
</Slider>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const usageDemoSizeSliderMarks: {
|
|
2
|
+
value: number;
|
|
3
|
+
label: string;
|
|
4
|
+
}[];
|
|
5
|
+
import type { SliderProps } from '../core/components/Slider/Slider.svelte';
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
setting: Omit<SliderProps, 'defaultValue'> & {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
previewProps: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
declare const UsageDemoSizeSlider: import("svelte").Component<$$ComponentProps, {}, "previewProps">;
|
|
13
|
+
type UsageDemoSizeSlider = ReturnType<typeof UsageDemoSizeSlider>;
|
|
14
|
+
export default UsageDemoSizeSlider;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function formatProps(props, defaultProps, settings) {
|
|
2
|
+
const formattedProps = [];
|
|
3
|
+
const validProps = {};
|
|
4
|
+
for (let i = 0; i < settings.length; i++) {
|
|
5
|
+
const value = settings[i];
|
|
6
|
+
const propValue = props[value.name];
|
|
7
|
+
if (propValue === undefined) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (propValue === value.defaultValue) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
validProps[value.name] = propValue;
|
|
14
|
+
}
|
|
15
|
+
Object.entries(defaultProps).forEach(([key, value]) => {
|
|
16
|
+
if (validProps[key] === undefined) {
|
|
17
|
+
validProps[key] = value;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.entries(validProps).forEach(([key, value]) => {
|
|
21
|
+
if (typeof value === 'boolean') {
|
|
22
|
+
if (value === true) {
|
|
23
|
+
formattedProps.push(`${key}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
formattedProps.push(`${key}={false}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (typeof value === 'string') {
|
|
30
|
+
formattedProps.push(`${key}="${value}"`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return formattedProps
|
|
34
|
+
.sort()
|
|
35
|
+
.map((prop) => ` ${prop}`)
|
|
36
|
+
.join('\n');
|
|
37
|
+
}
|
|
@@ -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 Child: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Child = InstanceType<typeof Child>;
|
|
18
|
+
export default Child;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Accept } from '../core/components/Dropzone/Dropzone.svelte';
|
|
3
|
+
import type { LoaderProps } from '../core/components/Loader/Loader.svelte';
|
|
4
|
+
import type { DivElement } from '../core/element-types.js';
|
|
5
|
+
import type { MantineColor, MantineRadius } from '../core/index.js';
|
|
6
|
+
import type { DropEvent } from '../ports/svelte-dropzone/types.js';
|
|
7
|
+
import type { FileError, FileRejection } from '../ports/svelte-dropzone/utils.js';
|
|
8
|
+
import type { FileWithPath } from 'file-selector';
|
|
9
|
+
import { type Snippet } from 'svelte';
|
|
10
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
11
|
+
|
|
12
|
+
export type DropzoneVariant = 'filled' | 'light';
|
|
13
|
+
|
|
14
|
+
export interface DropzoneProps extends DivElement {
|
|
15
|
+
/** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept`, `theme.primaryColor` by default */
|
|
16
|
+
acceptColor?: MantineColor;
|
|
17
|
+
|
|
18
|
+
/** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject`, `'red'` by default */
|
|
19
|
+
rejectColor?: MantineColor;
|
|
20
|
+
|
|
21
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem, `theme.defaultRadius` by default */
|
|
22
|
+
radius?: MantineRadius;
|
|
23
|
+
|
|
24
|
+
/** Determines whether files capturing should be disabled, `false` by default */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Called when any files are dropped to the dropzone */
|
|
28
|
+
onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;
|
|
29
|
+
|
|
30
|
+
/** Called when valid files are dropped to the dropzone */
|
|
31
|
+
onDrop: (files: FileWithPath[]) => void;
|
|
32
|
+
|
|
33
|
+
/** Called when dropped files do not meet file restrictions */
|
|
34
|
+
onReject?: (fileRejections: FileRejection[]) => void;
|
|
35
|
+
|
|
36
|
+
/** Determines whether a loading overlay should be displayed over the dropzone, `false` by default */
|
|
37
|
+
loading?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */
|
|
40
|
+
accept?: Accept | string[];
|
|
41
|
+
|
|
42
|
+
/** A ref function which when called opens the file system file picker */
|
|
43
|
+
// openRef?: React.ForwardedRef<() => void | undefined>; // TODO: implement this
|
|
44
|
+
|
|
45
|
+
/** Determines whether multiple files can be dropped to the dropzone or selected from file system picker, `true` by default */
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
|
|
48
|
+
/** Maximum file size in bytes */
|
|
49
|
+
maxSize?: number;
|
|
50
|
+
|
|
51
|
+
/** Name of the form control. Submitted with the form as part of a name/value pair. */
|
|
52
|
+
name?: string;
|
|
53
|
+
|
|
54
|
+
/** Maximum number of files that can be picked at once */
|
|
55
|
+
maxFiles?: number;
|
|
56
|
+
|
|
57
|
+
/** Set to autofocus the root element */
|
|
58
|
+
autoFocus?: boolean;
|
|
59
|
+
|
|
60
|
+
/** If `false`, disables click to open the native file selection dialog */
|
|
61
|
+
activateOnClick?: boolean;
|
|
62
|
+
|
|
63
|
+
/** If `false`, disables drag 'n' drop */
|
|
64
|
+
activateOnDrag?: boolean;
|
|
65
|
+
|
|
66
|
+
/** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */
|
|
67
|
+
activateOnKeyboard?: boolean;
|
|
68
|
+
|
|
69
|
+
/** If `false`, stops drag event propagation to parents */
|
|
70
|
+
dragEventsBubbling?: boolean;
|
|
71
|
+
|
|
72
|
+
/** Called when the `dragenter` event occurs */
|
|
73
|
+
onDragEnter?: (event: DragEvent) => void;
|
|
74
|
+
|
|
75
|
+
/** Called when the `dragleave` event occurs */
|
|
76
|
+
onDragLeave?: (event: DragEvent) => void;
|
|
77
|
+
|
|
78
|
+
/** Called when the `dragover` event occurs */
|
|
79
|
+
onDragOver?: (event: DragEvent) => void;
|
|
80
|
+
|
|
81
|
+
/** Called when user closes the file selection dialog with no selection */
|
|
82
|
+
onFileDialogCancel?: () => void;
|
|
83
|
+
|
|
84
|
+
/** Called when user opens the file selection dialog */
|
|
85
|
+
onFileDialogOpen?: () => void;
|
|
86
|
+
|
|
87
|
+
/** If `false`, allow dropped items to take over the current browser window */
|
|
88
|
+
preventDropOnDocument?: boolean;
|
|
89
|
+
|
|
90
|
+
/** Set to true to use the File System Access API to open the file picker instead of using an <input type="file"> click event, defaults to true */
|
|
91
|
+
useFsAccessApi?: boolean;
|
|
92
|
+
|
|
93
|
+
/** Use this to provide a custom file aggregator */
|
|
94
|
+
getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;
|
|
95
|
+
|
|
96
|
+
/** Custom validation function. It must return null if there's no errors. */
|
|
97
|
+
validator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
98
|
+
|
|
99
|
+
/** Determines whether pointer events should be enabled on the inner element, `false` by default */
|
|
100
|
+
enablePointerEvents?: boolean;
|
|
101
|
+
|
|
102
|
+
/** Props passed down to the Loader component */
|
|
103
|
+
loaderProps?: LoaderProps;
|
|
104
|
+
|
|
105
|
+
/** Props passed down to the internal Input component */
|
|
106
|
+
inputProps?: HTMLInputAttributes;
|
|
107
|
+
|
|
108
|
+
/** Dropzone variant */
|
|
109
|
+
variant?: DropzoneVariant;
|
|
110
|
+
|
|
111
|
+
/** Dropzone children */
|
|
112
|
+
children?: Snippet;
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<script lang="ts">
|
|
117
|
+
import Child from './Child.svelte';
|
|
118
|
+
import { DropzoneContext } from './DropzoneContext.svelte.js';
|
|
119
|
+
|
|
120
|
+
let {
|
|
121
|
+
multiple = true,
|
|
122
|
+
maxSize = Infinity,
|
|
123
|
+
activateOnClick = true,
|
|
124
|
+
activateOnDrag = true,
|
|
125
|
+
dragEventsBubbling = true,
|
|
126
|
+
activateOnKeyboard = true,
|
|
127
|
+
useFsAccessApi = true,
|
|
128
|
+
variant = 'light',
|
|
129
|
+
rejectColor = 'red',
|
|
130
|
+
} = $props();
|
|
131
|
+
|
|
132
|
+
const context = new DropzoneContext();
|
|
133
|
+
|
|
134
|
+
// setContext(DROPZONE_CONTEXT_KEY, context);
|
|
135
|
+
</script>
|
|
136
|
+
|
|
137
|
+
<div>
|
|
138
|
+
<Child />
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<style></style>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Accept } from '../core/components/Dropzone/Dropzone.svelte';
|
|
2
|
+
import type { LoaderProps } from '../core/components/Loader/Loader.svelte';
|
|
3
|
+
import type { DivElement } from '../core/element-types.js';
|
|
4
|
+
import type { MantineColor, MantineRadius } from '../core/index.js';
|
|
5
|
+
import type { DropEvent } from '../ports/svelte-dropzone/types.js';
|
|
6
|
+
import type { FileError, FileRejection } from '../ports/svelte-dropzone/utils.js';
|
|
7
|
+
import type { FileWithPath } from 'file-selector';
|
|
8
|
+
import { type Snippet } from 'svelte';
|
|
9
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
10
|
+
export type DropzoneVariant = 'filled' | 'light';
|
|
11
|
+
export interface DropzoneProps extends DivElement {
|
|
12
|
+
/** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Accept`, `theme.primaryColor` by default */
|
|
13
|
+
acceptColor?: MantineColor;
|
|
14
|
+
/** Key of `theme.colors` or any valid CSS color to set colors of `Dropzone.Reject`, `'red'` by default */
|
|
15
|
+
rejectColor?: MantineColor;
|
|
16
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem, `theme.defaultRadius` by default */
|
|
17
|
+
radius?: MantineRadius;
|
|
18
|
+
/** Determines whether files capturing should be disabled, `false` by default */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Called when any files are dropped to the dropzone */
|
|
21
|
+
onDropAny?: (files: FileWithPath[], fileRejections: FileRejection[]) => void;
|
|
22
|
+
/** Called when valid files are dropped to the dropzone */
|
|
23
|
+
onDrop: (files: FileWithPath[]) => void;
|
|
24
|
+
/** Called when dropped files do not meet file restrictions */
|
|
25
|
+
onReject?: (fileRejections: FileRejection[]) => void;
|
|
26
|
+
/** Determines whether a loading overlay should be displayed over the dropzone, `false` by default */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/** Mime types of the files that dropzone can accepts. By default, dropzone accepts all file types. */
|
|
29
|
+
accept?: Accept | string[];
|
|
30
|
+
/** A ref function which when called opens the file system file picker */
|
|
31
|
+
/** Determines whether multiple files can be dropped to the dropzone or selected from file system picker, `true` by default */
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
/** Maximum file size in bytes */
|
|
34
|
+
maxSize?: number;
|
|
35
|
+
/** Name of the form control. Submitted with the form as part of a name/value pair. */
|
|
36
|
+
name?: string;
|
|
37
|
+
/** Maximum number of files that can be picked at once */
|
|
38
|
+
maxFiles?: number;
|
|
39
|
+
/** Set to autofocus the root element */
|
|
40
|
+
autoFocus?: boolean;
|
|
41
|
+
/** If `false`, disables click to open the native file selection dialog */
|
|
42
|
+
activateOnClick?: boolean;
|
|
43
|
+
/** If `false`, disables drag 'n' drop */
|
|
44
|
+
activateOnDrag?: boolean;
|
|
45
|
+
/** If `false`, disables Space/Enter to open the native file selection dialog. Note that it also stops tracking the focus state. */
|
|
46
|
+
activateOnKeyboard?: boolean;
|
|
47
|
+
/** If `false`, stops drag event propagation to parents */
|
|
48
|
+
dragEventsBubbling?: boolean;
|
|
49
|
+
/** Called when the `dragenter` event occurs */
|
|
50
|
+
onDragEnter?: (event: DragEvent) => void;
|
|
51
|
+
/** Called when the `dragleave` event occurs */
|
|
52
|
+
onDragLeave?: (event: DragEvent) => void;
|
|
53
|
+
/** Called when the `dragover` event occurs */
|
|
54
|
+
onDragOver?: (event: DragEvent) => void;
|
|
55
|
+
/** Called when user closes the file selection dialog with no selection */
|
|
56
|
+
onFileDialogCancel?: () => void;
|
|
57
|
+
/** Called when user opens the file selection dialog */
|
|
58
|
+
onFileDialogOpen?: () => void;
|
|
59
|
+
/** If `false`, allow dropped items to take over the current browser window */
|
|
60
|
+
preventDropOnDocument?: boolean;
|
|
61
|
+
/** Set to true to use the File System Access API to open the file picker instead of using an <input type="file"> click event, defaults to true */
|
|
62
|
+
useFsAccessApi?: boolean;
|
|
63
|
+
/** Use this to provide a custom file aggregator */
|
|
64
|
+
getFilesFromEvent?: (event: DropEvent) => Promise<Array<File | DataTransferItem>>;
|
|
65
|
+
/** Custom validation function. It must return null if there's no errors. */
|
|
66
|
+
validator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
67
|
+
/** Determines whether pointer events should be enabled on the inner element, `false` by default */
|
|
68
|
+
enablePointerEvents?: boolean;
|
|
69
|
+
/** Props passed down to the Loader component */
|
|
70
|
+
loaderProps?: LoaderProps;
|
|
71
|
+
/** Props passed down to the internal Input component */
|
|
72
|
+
inputProps?: HTMLInputAttributes;
|
|
73
|
+
/** Dropzone variant */
|
|
74
|
+
variant?: DropzoneVariant;
|
|
75
|
+
/** Dropzone children */
|
|
76
|
+
children?: Snippet;
|
|
77
|
+
}
|
|
78
|
+
declare const Dropzone: import("svelte").Component<{
|
|
79
|
+
multiple?: boolean;
|
|
80
|
+
maxSize?: typeof Infinity;
|
|
81
|
+
activateOnClick?: boolean;
|
|
82
|
+
activateOnDrag?: boolean;
|
|
83
|
+
dragEventsBubbling?: boolean;
|
|
84
|
+
activateOnKeyboard?: boolean;
|
|
85
|
+
useFsAccessApi?: boolean;
|
|
86
|
+
variant?: string;
|
|
87
|
+
rejectColor?: string;
|
|
88
|
+
}, {}, "">;
|
|
89
|
+
type Dropzone = ReturnType<typeof Dropzone>;
|
|
90
|
+
export default Dropzone;
|