reburn-ui 0.4.10 → 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 +4 -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
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type WithGetters } from '../../svelte-utils/extract.js';
|
|
2
2
|
import type { CodeHighlightSettings } from './CodeHighlight.svelte';
|
|
3
|
-
|
|
4
|
-
interface CodeHighlightContextProps {
|
|
5
|
-
codeColorScheme: Getter<CodeHighlightSettings['codeColorScheme']>;
|
|
6
|
-
}
|
|
3
|
+
type CodeHighlightContextProps = WithGetters<CodeHighlightSettings>;
|
|
7
4
|
export declare class CodeHighlightContext {
|
|
8
5
|
#private;
|
|
9
6
|
codeColorScheme: "dark" | "light" | undefined;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { getContext } from 'svelte';
|
|
2
|
-
import { extract } from '
|
|
3
|
-
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { extract } from '../../svelte-utils/extract.js';
|
|
3
|
+
const CODE_HIGHLIGHT_CONTEXT_KEY = Symbol();
|
|
4
4
|
export class CodeHighlightContext {
|
|
5
5
|
#props;
|
|
6
6
|
codeColorScheme = $derived(extract(this.#props.codeColorScheme));
|
|
7
7
|
constructor(props) {
|
|
8
8
|
this.#props = props;
|
|
9
|
+
setContext(CODE_HIGHLIGHT_CONTEXT_KEY, this);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
export function getCodeHighlightContext() {
|
|
@@ -66,9 +66,8 @@
|
|
|
66
66
|
</script>
|
|
67
67
|
|
|
68
68
|
<script lang="ts">
|
|
69
|
-
import
|
|
70
|
-
import
|
|
71
|
-
import { CODE_HIGHLIGHT_CONTEXT_KEY, CodeHighlightContext } from './CodeHighlight.context.svelte.js';
|
|
69
|
+
import ScrollArea from '../components/ScrollArea/index.js';
|
|
70
|
+
import { CodeHighlightContext } from './CodeHighlight.context.svelte.js';
|
|
72
71
|
import { useHighlight } from './CodeHighlightAdapterProvider.context.svelte.js';
|
|
73
72
|
import CopyCodeButton from './CopyCodeButton/CopyCodeButton.svelte';
|
|
74
73
|
import ExpandCodeButton from './ExpandCodeButton/ExpandCodeButton.svelte';
|
|
@@ -94,8 +93,6 @@
|
|
|
94
93
|
|
|
95
94
|
const context = new CodeHighlightContext({ codeColorScheme: () => codeColorScheme });
|
|
96
95
|
|
|
97
|
-
setContext(CODE_HIGHLIGHT_CONTEXT_KEY, context);
|
|
98
|
-
|
|
99
96
|
const shouldDisplayControls = $derived((controls && controls.length > 0) || withExpandButton || withCopyButton);
|
|
100
97
|
|
|
101
98
|
function handleExpand(value: boolean) {
|
|
@@ -126,11 +123,10 @@
|
|
|
126
123
|
{/if}
|
|
127
124
|
</div>
|
|
128
125
|
{/if}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
<pre class="pre" data-with-offset={__withOffset || undefined}><code class="code">{@html highlightedCode}</code>
|
|
132
|
-
</
|
|
133
|
-
</ScrollArea>
|
|
126
|
+
<ScrollArea.Autosize type="hover" scrollbarSize={4} dir="ltr" offsetScrollbars={false} data-collapsed={!expanded || undefined} class="scrollarea">
|
|
127
|
+
<!-- we need to write it in one line or we will have whitespace that breaks the layout -->
|
|
128
|
+
<pre class="pre" data-with-offset={__withOffset || undefined}><code class="code">{@html highlightedCode}</code></pre>
|
|
129
|
+
</ScrollArea.Autosize>
|
|
134
130
|
</div>
|
|
135
131
|
{/if}
|
|
136
132
|
|
|
@@ -21,7 +21,14 @@
|
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
{#snippet control(tooltipProps?: Record<string, unknown>)}
|
|
24
|
-
<ActionIcon
|
|
24
|
+
<ActionIcon
|
|
25
|
+
{...props}
|
|
26
|
+
{...tooltipProps}
|
|
27
|
+
class="code-highlight-control-TFWsGDXb"
|
|
28
|
+
variant="transparent"
|
|
29
|
+
data-code-color-scheme={ctx.codeColorScheme}
|
|
30
|
+
size="xs"
|
|
31
|
+
>
|
|
25
32
|
{@render children?.()}
|
|
26
33
|
</ActionIcon>
|
|
27
34
|
{/snippet}
|
|
@@ -35,3 +42,46 @@
|
|
|
35
42
|
{:else}
|
|
36
43
|
{@render control()}
|
|
37
44
|
{/if}
|
|
45
|
+
|
|
46
|
+
<style>:global(.code-highlight-control-TFWsGDXb) {
|
|
47
|
+
color: var(--mantine-color-text);
|
|
48
|
+
opacity: 0.5;
|
|
49
|
+
}
|
|
50
|
+
@media (hover: hover) {
|
|
51
|
+
:global(.code-highlight-control-TFWsGDXb):hover {
|
|
52
|
+
color: var(--mantine-color-bright);
|
|
53
|
+
opacity: 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
@media (hover: none) {
|
|
57
|
+
:global(.code-highlight-control-TFWsGDXb):active {
|
|
58
|
+
color: var(--mantine-color-bright);
|
|
59
|
+
opacity: 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
:global(:where([data-mantine-color-scheme='dark'])) :global(.code-highlight-control-TFWsGDXb) {
|
|
63
|
+
color: var(--mantine-color-dark-0);
|
|
64
|
+
}
|
|
65
|
+
@media (hover: hover) {
|
|
66
|
+
:global(:where([data-mantine-color-scheme='dark'])) :global(.code-highlight-control-TFWsGDXb):hover {
|
|
67
|
+
color: var(--mantine-color-white);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
@media (hover: none) {
|
|
71
|
+
:global(:where([data-mantine-color-scheme='dark'])) :global(.code-highlight-control-TFWsGDXb):active {
|
|
72
|
+
color: var(--mantine-color-white);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
:global(:where([data-mantine-color-scheme='light'])) :global(.code-highlight-control-TFWsGDXb) {
|
|
76
|
+
color: var(--mantine-color-black);
|
|
77
|
+
}
|
|
78
|
+
@media (hover: hover) {
|
|
79
|
+
:global(:where([data-mantine-color-scheme='light'])) :global(.code-highlight-control-TFWsGDXb):hover {
|
|
80
|
+
color: var(--mantine-color-black);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
@media (hover: none) {
|
|
84
|
+
:global(:where([data-mantine-color-scheme='light'])) :global(.code-highlight-control-TFWsGDXb):active {
|
|
85
|
+
color: var(--mantine-color-black);
|
|
86
|
+
}
|
|
87
|
+
}</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useClipboard } from '../../hooks/use-clipboard.svelte.js';
|
|
3
3
|
import CodeHighlightControl from '../CodeHighlightControl.svelte';
|
|
4
4
|
import CopyIcon from './CopyIcon.svelte';
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
let { code, copiedLabel = 'Copied', copyLabel = 'Copy' }: CopyCodeButtonProps = $props();
|
|
13
13
|
|
|
14
|
-
const clipboard =
|
|
14
|
+
const clipboard = useClipboard();
|
|
15
15
|
|
|
16
16
|
function handleClick() {
|
|
17
17
|
clipboard.copy(code.trim());
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import { onMount } from 'svelte';
|
|
3
2
|
import type { NotificationProps } from '../components/Notification/Notification.svelte';
|
|
4
|
-
import Notification from '../components/Notification/Notification.svelte';
|
|
5
|
-
import { getAutoClose } from './get-auto-close.js';
|
|
6
3
|
import type { NotificationData } from './NotificationsStore.svelte.js';
|
|
7
4
|
|
|
8
5
|
export interface NotificationContainerProps extends NotificationProps {
|
|
@@ -13,6 +10,10 @@
|
|
|
13
10
|
</script>
|
|
14
11
|
|
|
15
12
|
<script lang="ts">
|
|
13
|
+
import { onMount } from 'svelte';
|
|
14
|
+
import Notification from '../components/Notification/Notification.svelte';
|
|
15
|
+
import { getAutoClose } from './get-auto-close.js';
|
|
16
|
+
|
|
16
17
|
let { data, onHide, autoClose, ...props }: NotificationContainerProps = $props();
|
|
17
18
|
|
|
18
19
|
const { message, children, ...notificationProps } = $derived(data);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import OptionalPortal from '../components/Portal/OptionalPortal.svelte';
|
|
4
4
|
import type { BasePortalProps } from '../components/Portal/Portal.svelte';
|
|
5
5
|
import type { DivElement } from '../element-types.js';
|
|
6
|
-
import {
|
|
6
|
+
import { useReducedMotion } from '../hooks/use-reduced-motion.svelte.js';
|
|
7
7
|
import { theme } from '../MantineProvider/theme.svelte.js';
|
|
8
8
|
import { getDefaultZIndex } from '../utils/get-default-z-index.js';
|
|
9
9
|
import { rem } from '../utils/index.js';
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
const styles = $derived(`--notifications-z-index: ${zIndex}; --notifications-container-width: ${rem(containerWidth)};`);
|
|
81
81
|
|
|
82
82
|
const duration = $derived.by(() => {
|
|
83
|
-
const shouldReduceMotion =
|
|
83
|
+
const shouldReduceMotion = useReducedMotion.current;
|
|
84
84
|
const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
85
85
|
return reduceMotion ? 1 : transitionDuration;
|
|
86
86
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type MaybeGetter } from '../../svelte-utils/extract.js';
|
|
2
3
|
import type { NotificationProps } from '../components/Notification/Notification.svelte';
|
|
3
|
-
import { type MaybeGetter } from '../context/extract.js';
|
|
4
4
|
export type NotificationPosition = 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center';
|
|
5
5
|
export interface NotificationData extends Omit<NotificationProps, 'onclose'> {
|
|
6
6
|
/** Notification id, can be used to close or update notification */
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type WithGetters } from '../../../svelte-utils/extract.js';
|
|
2
2
|
import type { ChartData } from '../types.js';
|
|
3
3
|
import type { ChartRootProps } from './ChartRoot.svelte';
|
|
4
|
-
|
|
5
|
-
series: Getter<ChartRootProps<T>['series']>;
|
|
6
|
-
data: Getter<ChartRootProps<T>['data']>;
|
|
7
|
-
dataKey: Getter<ChartRootProps<T>['dataKey']>;
|
|
8
|
-
yAxisProps: Getter<ChartRootProps<T>['yAxisProps']>;
|
|
9
|
-
xAxisProps: Getter<ChartRootProps<T>['xAxisProps']>;
|
|
10
|
-
xScale: Getter<ChartRootProps<T>['xScale']>;
|
|
11
|
-
yScale: Getter<ChartRootProps<T>['yScale']>;
|
|
12
|
-
xGrid: Getter<ChartRootProps<T>['xGrid']>;
|
|
13
|
-
yGrid: Getter<ChartRootProps<T>['yGrid']>;
|
|
14
|
-
}
|
|
4
|
+
type ChartContextProps<T extends ChartData> = Pick<WithGetters<ChartRootProps<T>>, 'series' | 'data' | 'dataKey' | 'yAxisProps' | 'xAxisProps' | 'xScale' | 'yScale' | 'xGrid' | 'yGrid'>;
|
|
15
5
|
export declare class ChartContext<T extends ChartData> {
|
|
16
6
|
#private;
|
|
17
7
|
dataKey: keyof T;
|
|
@@ -59,6 +49,5 @@ export declare class ChartContext<T extends ChartData> {
|
|
|
59
49
|
maxLength: number;
|
|
60
50
|
};
|
|
61
51
|
}
|
|
62
|
-
export declare const CHART_CONTEXT_KEY: unique symbol;
|
|
63
52
|
export declare function getChartContext<T extends ChartData>(): ChartContext<T>;
|
|
64
53
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { extract } from '
|
|
2
|
-
import { getContext } from 'svelte';
|
|
1
|
+
import { extract } from '../../../svelte-utils/extract.js';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
3
3
|
import { scaleLinear } from '../d3/scale/scaleLinear.js';
|
|
4
4
|
import { minMax } from '../utils/minMax.js';
|
|
5
5
|
import { minMaxObject } from '../utils/minMaxObject.js';
|
|
@@ -42,6 +42,7 @@ export class ChartContext {
|
|
|
42
42
|
chartRef = $state();
|
|
43
43
|
constructor(props) {
|
|
44
44
|
this.#props = props;
|
|
45
|
+
setContext(CHART_CONTEXT_KEY, this);
|
|
45
46
|
}
|
|
46
47
|
get xTicks() {
|
|
47
48
|
return tickLabels(this.xRange, this.xScale, this.xFormatLabel, this.#xAxisProps?.ticks || DEFAULT_X_TICKS);
|
|
@@ -50,7 +51,7 @@ export class ChartContext {
|
|
|
50
51
|
return tickLabels(this.yRange, this.yScale, this.yFormatLabel, this.#yAxisProps?.ticks || DEFAULT_Y_TICKS);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
const CHART_CONTEXT_KEY = Symbol();
|
|
54
55
|
export function getChartContext() {
|
|
55
56
|
return getContext(CHART_CONTEXT_KEY);
|
|
56
57
|
}
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
import NewChartTooltip, { type ChartTooltipProps } from '../ChartTooltip/ChartTooltip.svelte';
|
|
8
8
|
import { scaleLinear } from '../d3/scale/scaleLinear.js';
|
|
9
9
|
import type { ChartSeries } from '../types.js';
|
|
10
|
-
import {
|
|
11
|
-
import ChartXGrid from './ChartXGrid.svelte';
|
|
12
|
-
import ChartXLabels from './ChartXLabels.svelte';
|
|
13
|
-
import ChartYGrid from './ChartYGrid.svelte';
|
|
14
|
-
import ChartYLabels from './ChartYLabels.svelte';
|
|
10
|
+
import { ChartContext } from './ChartContext.svelte.js';
|
|
15
11
|
|
|
16
12
|
export interface ChartYAxisProps {
|
|
17
13
|
/** The domain of the y-axis */
|
|
@@ -111,7 +107,11 @@
|
|
|
111
107
|
</script>
|
|
112
108
|
|
|
113
109
|
<script lang="ts" generics="T extends Record<string, unknown>">
|
|
114
|
-
import {
|
|
110
|
+
import { type Snippet } from 'svelte';
|
|
111
|
+
import ChartXGrid from './ChartXGrid.svelte';
|
|
112
|
+
import ChartXLabels from './ChartXLabels.svelte';
|
|
113
|
+
import ChartYGrid from './ChartYGrid.svelte';
|
|
114
|
+
import ChartYLabels from './ChartYLabels.svelte';
|
|
115
115
|
|
|
116
116
|
let {
|
|
117
117
|
width = '100%',
|
|
@@ -147,8 +147,6 @@
|
|
|
147
147
|
xGrid: () => xGrid,
|
|
148
148
|
yGrid: () => yGrid,
|
|
149
149
|
});
|
|
150
|
-
|
|
151
|
-
setContext(CHART_CONTEXT_KEY, context);
|
|
152
150
|
</script>
|
|
153
151
|
|
|
154
152
|
<div
|
|
@@ -46,18 +46,33 @@
|
|
|
46
46
|
const { tooltip, rect } = getTooltipPosition(event);
|
|
47
47
|
|
|
48
48
|
chartRect = rect;
|
|
49
|
+
|
|
49
50
|
if (position === 'inside') {
|
|
50
51
|
tooltipY = tooltip.y;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
let dataElement: T | null = null;
|
|
55
|
+
|
|
56
|
+
if ((event.target as SVGCircleElement).dataset.type === 'scatter-dot') {
|
|
57
|
+
const dot = event.target as SVGCircleElement;
|
|
58
|
+
|
|
59
|
+
const index = parseInt(dot.getAttribute('data-index') || '-1');
|
|
60
|
+
|
|
61
|
+
if (index === -1) return;
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
const data = ctx.data[index];
|
|
64
|
+
|
|
65
|
+
dataElement = data;
|
|
66
|
+
} else {
|
|
67
|
+
const xValue = ctx.xScale.invert(tooltip.x);
|
|
68
|
+
|
|
69
|
+
dataElement = findClosestElement(ctx.data, xValue, ctx.xAccessor);
|
|
70
|
+
}
|
|
56
71
|
|
|
57
|
-
if (
|
|
58
|
-
const actualX = ctx.xScale(ctx.xAccessor(
|
|
72
|
+
if (dataElement) {
|
|
73
|
+
const actualX = ctx.xScale(ctx.xAccessor(dataElement));
|
|
59
74
|
|
|
60
|
-
element =
|
|
75
|
+
element = dataElement;
|
|
61
76
|
|
|
62
77
|
tooltipLine = {
|
|
63
78
|
top: 0,
|
|
@@ -69,7 +84,7 @@
|
|
|
69
84
|
|
|
70
85
|
for (let i = 0; i < ctx.series.length; i++) {
|
|
71
86
|
const series = ctx.series[i];
|
|
72
|
-
const value =
|
|
87
|
+
const value = dataElement[series.name];
|
|
73
88
|
|
|
74
89
|
if (isNotEmpty(value)) {
|
|
75
90
|
dots.push({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getThemeColor } from '../../MantineProvider/index.js';
|
|
3
3
|
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
4
4
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
5
|
-
import type
|
|
5
|
+
import { type ChartContext } from '../ChartRoot/ChartContext.svelte.js';
|
|
6
6
|
import type { ChartData, ChartSeries } from '../types.js';
|
|
7
7
|
import { isNotEmpty } from '../utils/isNotEmpty.js';
|
|
8
8
|
import type { __ScatterChartProps } from './ScatterChart.svelte';
|
|
@@ -40,13 +40,15 @@
|
|
|
40
40
|
}
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
|
-
{#snippet dot(item: T, series: ChartSeries<T, keyof T>, value: T[keyof T])}
|
|
43
|
+
{#snippet dot(item: T, series: ChartSeries<T, keyof T>, value: T[keyof T], index: number)}
|
|
44
44
|
{#if value !== undefined}
|
|
45
45
|
<circle
|
|
46
46
|
{...props}
|
|
47
47
|
cx={context.xScale(context.xAccessor(item))}
|
|
48
48
|
cy={context.yScale(series.accessor?.(value) || value)}
|
|
49
49
|
class="dot"
|
|
50
|
+
data-type="scatter-dot"
|
|
51
|
+
data-index={index}
|
|
50
52
|
fill={getColor(series.color || color)}
|
|
51
53
|
r={dotSize}
|
|
52
54
|
/>
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
{/snippet}
|
|
55
57
|
|
|
56
58
|
{#if context.xRange}
|
|
57
|
-
{#each context.data as item}
|
|
59
|
+
{#each context.data as item, index}
|
|
58
60
|
{#each context.series as series (series.name)}
|
|
59
61
|
{#if isScatterSeries(series)}
|
|
60
62
|
{@const _value = item[series.name]}
|
|
@@ -62,10 +64,10 @@
|
|
|
62
64
|
{#if isNotEmpty(_value)}
|
|
63
65
|
{#if Array.isArray(_value)}
|
|
64
66
|
{#each item[series.name] as value}
|
|
65
|
-
{@render dot(item, series, value)}
|
|
67
|
+
{@render dot(item, series, value, index)}
|
|
66
68
|
{/each}
|
|
67
69
|
{:else}
|
|
68
|
-
{@render dot(item, series, _value)}
|
|
70
|
+
{@render dot(item, series, _value, index)}
|
|
69
71
|
{/if}
|
|
70
72
|
{/if}
|
|
71
73
|
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
2
|
-
import type
|
|
2
|
+
import { type ChartContext } from '../ChartRoot/ChartContext.svelte.js';
|
|
3
3
|
import type { ChartData } from '../types.js';
|
|
4
4
|
import type { __ScatterChartProps } from './ScatterChart.svelte';
|
|
5
5
|
type CircleElement = SvelteHTMLElements['circle'];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
// TODO: create TextProps
|
|
5
|
+
// export interface AnchorProps extends Omit<TextProps, 'span'> {
|
|
6
|
+
|
|
7
|
+
export interface AnchorProps extends HTMLAnchorAttributes {
|
|
8
|
+
/** Determines in which cases link should have `text-decoration: underline` styles, `hover` by default */
|
|
9
|
+
underline?: 'always' | 'hover' | 'not-hover' | 'never';
|
|
10
|
+
|
|
11
|
+
ref?: HTMLAnchorElement;
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
let { underline = 'hover', children, ref = $bindable(), ...props }: AnchorProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<a {...props} bind:this={ref} class={['root', props.class]} data-underline={underline}>
|
|
20
|
+
{@render children?.()}
|
|
21
|
+
</a>
|
|
22
|
+
|
|
23
|
+
<style>.root {
|
|
24
|
+
color: var(--mantine-color-anchor);
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
appearance: none;
|
|
27
|
+
border: none;
|
|
28
|
+
display: inline;
|
|
29
|
+
padding: 0;
|
|
30
|
+
margin: 0;
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
@media (hover: hover) {
|
|
35
|
+
.root:where([data-underline=hover]):hover {
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
@media (hover: none) {
|
|
40
|
+
.root:where([data-underline=hover]):active {
|
|
41
|
+
text-decoration: underline;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
.root:where([data-underline=not-hover]) {
|
|
45
|
+
text-decoration: underline;
|
|
46
|
+
}
|
|
47
|
+
@media (hover: hover) {
|
|
48
|
+
.root:where([data-underline=not-hover]):hover {
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
@media (hover: none) {
|
|
53
|
+
.root:where([data-underline=not-hover]):active {
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
.root:where([data-underline=always]) {
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
}
|
|
60
|
+
.root:where([data-variant=gradient]), .root:where([data-variant=gradient]):hover {
|
|
61
|
+
text-decoration: none;
|
|
62
|
+
}
|
|
63
|
+
.root:where([data-line-clamp]) {
|
|
64
|
+
display: -webkit-box;
|
|
65
|
+
}</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
2
|
+
export interface AnchorProps extends HTMLAnchorAttributes {
|
|
3
|
+
/** Determines in which cases link should have `text-decoration: underline` styles, `hover` by default */
|
|
4
|
+
underline?: 'always' | 'hover' | 'not-hover' | 'never';
|
|
5
|
+
ref?: HTMLAnchorElement;
|
|
6
|
+
}
|
|
7
|
+
declare const Anchor: import("svelte").Component<AnchorProps, {}, "ref">;
|
|
8
|
+
type Anchor = ReturnType<typeof Anchor>;
|
|
9
|
+
export default Anchor;
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
|
|
54
54
|
<script lang="ts">
|
|
55
55
|
import { getDefaultZIndex } from '../../utils/get-default-z-index.js';
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
56
|
+
import { type Snippet } from 'svelte';
|
|
57
|
+
import { AppShellContext } from './AppShellContext.svelte.js';
|
|
58
58
|
import AppShellMediaStyles from './AppShellMediaStyles/AppShellMediaStyles.svelte';
|
|
59
59
|
import { Resizing } from './Resizing.svelte.js';
|
|
60
60
|
|
|
@@ -80,8 +80,6 @@
|
|
|
80
80
|
offsetScrollbars: () => offsetScrollbars,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
setContext(APP_SHELL_CONTEXT_KEY, context);
|
|
84
|
-
|
|
85
83
|
const resizing = new Resizing(
|
|
86
84
|
() => disabled,
|
|
87
85
|
() => transitionDuration
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type WithGetters } from '../../../svelte-utils/extract.js';
|
|
2
2
|
import type { AppShellProps } from './AppShell.svelte';
|
|
3
|
-
|
|
4
|
-
withBorder: NonNullableGetter<AppShellProps['withBorder']>;
|
|
5
|
-
zIndex: NonNullableGetter<AppShellProps['zIndex']>;
|
|
6
|
-
disabled: NonNullableGetter<AppShellProps['disabled']>;
|
|
7
|
-
offsetScrollbars: NonNullableGetter<AppShellProps['offsetScrollbars']>;
|
|
8
|
-
}
|
|
9
|
-
export declare const APP_SHELL_CONTEXT_KEY: unique symbol;
|
|
3
|
+
type AppShellContextProps = Pick<WithGetters<AppShellProps>, 'withBorder' | 'zIndex' | 'disabled' | 'offsetScrollbars'>;
|
|
10
4
|
export declare function getAppShellContext(): AppShellContext;
|
|
11
5
|
export declare class AppShellContext {
|
|
12
|
-
readonly withBorder:
|
|
13
|
-
readonly zIndex:
|
|
14
|
-
readonly disabled:
|
|
15
|
-
readonly offsetScrollbars:
|
|
6
|
+
readonly withBorder: boolean | undefined;
|
|
7
|
+
readonly zIndex: string | number | undefined;
|
|
8
|
+
readonly disabled: boolean | undefined;
|
|
9
|
+
readonly offsetScrollbars: boolean | undefined;
|
|
16
10
|
constructor({ withBorder, zIndex, disabled, offsetScrollbars }: AppShellContextProps);
|
|
17
11
|
}
|
|
12
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { extract } from '
|
|
2
|
-
import { getContext } from 'svelte';
|
|
3
|
-
|
|
1
|
+
import { extract } from '../../../svelte-utils/extract.js';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
3
|
+
const APP_SHELL_CONTEXT_KEY = Symbol();
|
|
4
4
|
export function getAppShellContext() {
|
|
5
5
|
return getContext(APP_SHELL_CONTEXT_KEY);
|
|
6
6
|
}
|
|
@@ -14,5 +14,6 @@ export class AppShellContext {
|
|
|
14
14
|
this.zIndex = $derived(extract(zIndex));
|
|
15
15
|
this.disabled = $derived(extract(disabled));
|
|
16
16
|
this.offsetScrollbars = $derived(extract(offsetScrollbars));
|
|
17
|
+
setContext(APP_SHELL_CONTEXT_KEY, this);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -56,10 +56,13 @@
|
|
|
56
56
|
</script>
|
|
57
57
|
|
|
58
58
|
<script lang="ts">
|
|
59
|
+
// TODO: the bind: does not respect when the checked = $bindable(false) gets a bind:checked={() => false, () => {}}
|
|
59
60
|
import IconCheck from '../../icons/IconCheck.svelte';
|
|
60
61
|
import IconMinus from '../../icons/IconMinus.svelte';
|
|
61
62
|
import { parseThemeColor } from '../../MantineProvider/color-functions/parse-theme-color.svelte.js';
|
|
63
|
+
import { getAutoContrastValue, getContrastColor, getThemeColor } from '../../MantineProvider/index.js';
|
|
62
64
|
import { theme } from '../../MantineProvider/theme.svelte.js';
|
|
65
|
+
import { dataAttr } from '../../utils/data-attr.js';
|
|
63
66
|
import { getRadius, getSize } from '../../utils/get-size.js';
|
|
64
67
|
import InlineInput from '../InlineInput/InlineInput.svelte';
|
|
65
68
|
import { getCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext.svelte.js';
|
|
@@ -81,6 +84,8 @@
|
|
|
81
84
|
description,
|
|
82
85
|
wrapperProps,
|
|
83
86
|
icon,
|
|
87
|
+
iconColor,
|
|
88
|
+
autoContrast,
|
|
84
89
|
...props
|
|
85
90
|
}: CheckboxProps = $props();
|
|
86
91
|
|
|
@@ -88,20 +93,24 @@
|
|
|
88
93
|
|
|
89
94
|
const context = getCheckboxGroupContext();
|
|
90
95
|
|
|
91
|
-
// TODO: replacing CheckboxIcon and CheckboxIndeterminateIcon
|
|
92
|
-
|
|
93
96
|
// What have i done
|
|
94
97
|
const contextValueSetter = context
|
|
95
98
|
? { get: () => context.value.includes(props.value || ''), set: (newValue: boolean) => context.change(props.value, newValue) }
|
|
96
99
|
: { get: () => checked || false, set: (newValue: boolean) => (checked = newValue) };
|
|
97
100
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const checkboxColor = $derived.by(() => {
|
|
102
|
+
const parsedColor = parseThemeColor({ color: color || theme.primaryColor });
|
|
103
|
+
const outlineColor =
|
|
104
|
+
parsedColor.isThemeColor && parsedColor.shade === undefined ? `var(--mantine-color-${parsedColor.color}-outline)` : parsedColor.color;
|
|
105
|
+
|
|
106
|
+
if (variant === 'outline') {
|
|
107
|
+
return outlineColor;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return getThemeColor(color);
|
|
111
|
+
});
|
|
102
112
|
</script>
|
|
103
113
|
|
|
104
|
-
<!-- TODO: find out how do do this better without the style attribute -->
|
|
105
114
|
<InlineInput
|
|
106
115
|
{...wrapperProps}
|
|
107
116
|
{id}
|
|
@@ -112,14 +121,19 @@
|
|
|
112
121
|
{label}
|
|
113
122
|
{disabled}
|
|
114
123
|
{variant}
|
|
115
|
-
data-checked={contextValueSetter.get()
|
|
124
|
+
data-checked={dataAttr(contextValueSetter.get())}
|
|
116
125
|
>
|
|
117
126
|
<div
|
|
118
127
|
class="inner"
|
|
119
128
|
data-label-position={labelPosition}
|
|
120
129
|
style:--checkbox-size={getSize(size, 'checkbox-size')}
|
|
121
130
|
style:--checkbox-radius={radius ? getRadius(radius) : undefined}
|
|
122
|
-
style:--checkbox-color={
|
|
131
|
+
style:--checkbox-color={checkboxColor}
|
|
132
|
+
style:--checkbox-icon-color={iconColor
|
|
133
|
+
? getThemeColor(iconColor)
|
|
134
|
+
: getAutoContrastValue(autoContrast)
|
|
135
|
+
? getContrastColor({ color, autoContrast })
|
|
136
|
+
: undefined}
|
|
123
137
|
>
|
|
124
138
|
<input
|
|
125
139
|
{...props}
|
|
@@ -129,18 +143,23 @@
|
|
|
129
143
|
bind:this={input}
|
|
130
144
|
bind:checked={contextValueSetter.get, contextValueSetter.set}
|
|
131
145
|
{disabled}
|
|
132
|
-
data-error={
|
|
133
|
-
data-indeterminate={indeterminate
|
|
146
|
+
data-error={dataAttr(error)}
|
|
147
|
+
data-indeterminate={dataAttr(indeterminate)}
|
|
134
148
|
/>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{#if
|
|
149
|
+
|
|
150
|
+
{#if icon}
|
|
151
|
+
{#if indeterminate || contextValueSetter.get()}
|
|
152
|
+
<!-- TODO: need to check how we can pass the class down -->
|
|
138
153
|
{@render icon(indeterminate, 'icon')}
|
|
139
|
-
{:else if indeterminate}
|
|
140
|
-
<IconMinus class="icon" />
|
|
141
|
-
{:else}
|
|
142
|
-
<IconCheck class="icon" />
|
|
143
154
|
{/if}
|
|
155
|
+
{:else if indeterminate}
|
|
156
|
+
<IconMinus class="icon" />
|
|
157
|
+
{:else if contextValueSetter.get()}{/if}
|
|
158
|
+
<!-- TODO: missing icon support for indeterminate -->
|
|
159
|
+
{#if indeterminate}
|
|
160
|
+
<IconMinus class="icon" />
|
|
161
|
+
{:else if contextValueSetter.get()}
|
|
162
|
+
<IconCheck class="icon" />
|
|
144
163
|
{/if}
|
|
145
164
|
</div>
|
|
146
165
|
</InlineInput>
|