reburn-ui 0.1.8 → 0.2.1
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/Notifications/NotificationContainer.svelte +56 -0
- package/dist/core/Notifications/NotificationContainer.svelte.d.ts +10 -0
- package/dist/core/Notifications/Notifications.svelte +156 -0
- package/dist/core/Notifications/Notifications.svelte.d.ts +28 -0
- package/dist/core/Notifications/NotificationsStore.svelte.d.ts +46 -0
- package/dist/core/Notifications/NotificationsStore.svelte.js +71 -0
- package/dist/core/Notifications/get-auto-close.d.ts +1 -0
- package/dist/core/Notifications/get-auto-close.js +9 -0
- package/dist/core/Notifications/notificationStackAnimation.d.ts +5 -0
- package/dist/core/Notifications/notificationStackAnimation.js +11 -0
- package/dist/core/components/CloseButton/CloseButton.svelte +6 -1
- package/dist/core/components/Floating/CreateFloating.svelte.d.ts +27 -0
- package/dist/core/components/Floating/CreateFloating.svelte.js +47 -0
- package/dist/core/components/Notification/Notification.svelte +216 -0
- package/dist/core/components/Notification/Notification.svelte.d.ts +33 -0
- package/dist/core/components/Popover/Popover.svelte +18 -24
- package/dist/core/components/Portal/Portal.svelte +8 -4
- package/dist/core/components/Progress/Progress.svelte +28 -0
- package/dist/core/components/Progress/Progress.svelte.d.ts +15 -0
- package/dist/core/components/Progress/ProgressContext.svelte.d.ts +8 -0
- package/dist/core/components/Progress/ProgressContext.svelte.js +12 -0
- package/dist/core/components/Progress/ProgressLabel.svelte +25 -0
- package/dist/core/components/Progress/ProgressLabel.svelte.d.ts +6 -0
- package/dist/core/components/Progress/ProgressRoot.svelte +72 -0
- package/dist/core/components/Progress/ProgressRoot.svelte.d.ts +17 -0
- package/dist/core/components/Progress/ProgressSection.svelte +83 -0
- package/dist/core/components/Progress/ProgressSection.svelte.d.ts +17 -0
- package/dist/core/components/Progress/index.d.ts +12 -0
- package/dist/core/components/Progress/index.js +9 -0
- package/dist/core/components/Table/Table.svelte +160 -0
- package/dist/core/components/Table/Table.svelte.d.ts +48 -0
- package/dist/core/components/Table/TableBodyContext.d.ts +2 -0
- package/dist/core/components/Table/TableBodyContext.js +5 -0
- package/dist/core/components/Table/TableCaption.svelte +30 -0
- package/dist/core/components/Table/TableCaption.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableContext.svelte.d.ts +23 -0
- package/dist/core/components/Table/TableContext.svelte.js +18 -0
- package/dist/core/components/Table/TableDataRenderer.svelte +55 -0
- package/dist/core/components/Table/TableDataRenderer.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableHeaderContext.d.ts +2 -0
- package/dist/core/components/Table/TableHeaderContext.js +5 -0
- package/dist/core/components/Table/TableTbody.svelte +20 -0
- package/dist/core/components/Table/TableTbody.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTd.svelte +27 -0
- package/dist/core/components/Table/TableTd.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTfoot.svelte +15 -0
- package/dist/core/components/Table/TableTfoot.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTh.svelte +36 -0
- package/dist/core/components/Table/TableTh.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableThead.svelte +32 -0
- package/dist/core/components/Table/TableThead.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTr.svelte +62 -0
- package/dist/core/components/Table/TableTr.svelte.d.ts +7 -0
- package/dist/core/components/Table/getTableDataAttr.d.ts +11 -0
- package/dist/core/components/Table/getTableDataAttr.js +25 -0
- package/dist/core/components/Table/index.d.ts +20 -0
- package/dist/core/components/Table/index.js +17 -0
- package/dist/core/components/Tooltip/CreateTooltip.svelte.d.ts +20 -0
- package/dist/core/components/Tooltip/CreateTooltip.svelte.js +19 -0
- package/dist/core/components/Tooltip/Tooltip.svelte +235 -0
- package/dist/core/components/Tooltip/Tooltip.svelte.d.ts +46 -0
- package/dist/core/components/Tooltip/Tooltip.types.d.ts +47 -0
- package/dist/core/components/Tooltip/Tooltip.types.js +1 -0
- package/dist/core/components/Tooltip/getTooltipMiddleware.d.ts +15 -0
- package/dist/core/components/Tooltip/getTooltipMiddleware.js +32 -0
- package/dist/core/components/index.d.ts +4 -0
- package/dist/core/components/index.js +4 -0
- package/dist/tools/icon-vite-plugin/utils/generateIconComponent.js +1 -2
- package/package.json +9 -9
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getTableDataAttr(ctx, options) {
|
|
2
|
+
if (!options) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const data = {};
|
|
6
|
+
if (options.columnBorder && ctx.withColumnBorders) {
|
|
7
|
+
data['data-with-column-border'] = true;
|
|
8
|
+
}
|
|
9
|
+
if (options.rowBorder && ctx.withRowBorders) {
|
|
10
|
+
data['data-with-row-border'] = true;
|
|
11
|
+
}
|
|
12
|
+
if (options.striped && ctx.striped) {
|
|
13
|
+
data['data-striped'] = ctx.striped;
|
|
14
|
+
}
|
|
15
|
+
if (options.highlightOnHover && ctx.highlightOnHover) {
|
|
16
|
+
data['data-hover'] = true;
|
|
17
|
+
}
|
|
18
|
+
if (options.captionSide && ctx.captionSide) {
|
|
19
|
+
data['data-side'] = ctx.captionSide;
|
|
20
|
+
}
|
|
21
|
+
if (options.stickyHeader && ctx.stickyHeader) {
|
|
22
|
+
data['data-sticky'] = true;
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import TableComponent from './Table.svelte';
|
|
2
|
+
import TableCaption from './TableCaption.svelte';
|
|
3
|
+
import TableTbody from './TableTbody.svelte';
|
|
4
|
+
import TableTd from './TableTd.svelte';
|
|
5
|
+
import TableTfoot from './TableTfoot.svelte';
|
|
6
|
+
import TableTh from './TableTh.svelte';
|
|
7
|
+
import TableThead from './TableThead.svelte';
|
|
8
|
+
import TableTr from './TableTr.svelte';
|
|
9
|
+
type Table = typeof TableComponent;
|
|
10
|
+
interface ExtendedTable extends Table {
|
|
11
|
+
Caption: typeof TableCaption;
|
|
12
|
+
Thead: typeof TableThead;
|
|
13
|
+
Tbody: typeof TableTbody;
|
|
14
|
+
Tfoot: typeof TableTfoot;
|
|
15
|
+
Tr: typeof TableTr;
|
|
16
|
+
Th: typeof TableTh;
|
|
17
|
+
Td: typeof TableTd;
|
|
18
|
+
}
|
|
19
|
+
declare const Table: ExtendedTable;
|
|
20
|
+
export default Table;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import TableComponent from './Table.svelte';
|
|
2
|
+
import TableCaption from './TableCaption.svelte';
|
|
3
|
+
import TableTbody from './TableTbody.svelte';
|
|
4
|
+
import TableTd from './TableTd.svelte';
|
|
5
|
+
import TableTfoot from './TableTfoot.svelte';
|
|
6
|
+
import TableTh from './TableTh.svelte';
|
|
7
|
+
import TableThead from './TableThead.svelte';
|
|
8
|
+
import TableTr from './TableTr.svelte';
|
|
9
|
+
const Table = TableComponent;
|
|
10
|
+
Table.Caption = TableCaption;
|
|
11
|
+
Table.Thead = TableThead;
|
|
12
|
+
Table.Tbody = TableTbody;
|
|
13
|
+
Table.Tfoot = TableTfoot;
|
|
14
|
+
Table.Tr = TableTr;
|
|
15
|
+
Table.Th = TableTh;
|
|
16
|
+
Table.Td = TableTd;
|
|
17
|
+
export default Table;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MaybeGetter } from '../../context/extract.js';
|
|
2
|
+
import type { TooltipProps } from './Tooltip.svelte';
|
|
3
|
+
export declare class CreateTooltip {
|
|
4
|
+
position: MaybeGetter<TooltipProps['position']>;
|
|
5
|
+
closeDelay: MaybeGetter<TooltipProps['closeDelay']>;
|
|
6
|
+
openDelay: MaybeGetter<TooltipProps['openDelay']>;
|
|
7
|
+
onPositionChange: MaybeGetter<TooltipProps['onPositionChange']>;
|
|
8
|
+
opened: MaybeGetter<TooltipProps['opened']>;
|
|
9
|
+
defaultOpened: MaybeGetter<TooltipProps['defaultOpened']>;
|
|
10
|
+
events: MaybeGetter<TooltipProps['events']>;
|
|
11
|
+
arrowOffset: MaybeGetter<TooltipProps['arrowOffset']>;
|
|
12
|
+
offset: MaybeGetter<TooltipProps['offset']>;
|
|
13
|
+
inline: MaybeGetter<TooltipProps['inline']>;
|
|
14
|
+
strategy: MaybeGetter<TooltipProps['floatingStrategy']>;
|
|
15
|
+
middlewares: MaybeGetter<TooltipProps['middlewares']>;
|
|
16
|
+
dir: import("../../DirectionProvider/direction.svelte.js").Direction;
|
|
17
|
+
arrowRef: HTMLDivElement | undefined;
|
|
18
|
+
floatingElement: HTMLElement | undefined;
|
|
19
|
+
referenceElement: HTMLElement | undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getDirection } from '../../DirectionProvider/direction.svelte.js';
|
|
2
|
+
export class CreateTooltip {
|
|
3
|
+
position;
|
|
4
|
+
closeDelay;
|
|
5
|
+
openDelay;
|
|
6
|
+
onPositionChange;
|
|
7
|
+
opened;
|
|
8
|
+
defaultOpened;
|
|
9
|
+
events;
|
|
10
|
+
arrowOffset;
|
|
11
|
+
offset;
|
|
12
|
+
inline;
|
|
13
|
+
strategy;
|
|
14
|
+
middlewares;
|
|
15
|
+
dir = $derived(getDirection().current);
|
|
16
|
+
arrowRef = $state(undefined);
|
|
17
|
+
floatingElement = $state(undefined);
|
|
18
|
+
referenceElement = $state(undefined);
|
|
19
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { getDefaultZIndex } from '../../utils/get-default-z-index.js';
|
|
3
|
+
import type { ArrowPosition, FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../Floating/types.js';
|
|
4
|
+
import { transitions, type TransitionOverrides } from '../Transitions/transitions.js';
|
|
5
|
+
import type { TooltipBaseProps } from './Tooltip.types.js';
|
|
6
|
+
|
|
7
|
+
export interface TooltipProps extends TooltipBaseProps {
|
|
8
|
+
/** Called when tooltip position changes */
|
|
9
|
+
onPositionChange?: (position: FloatingPosition) => void;
|
|
10
|
+
|
|
11
|
+
/** Open delay in ms */
|
|
12
|
+
openDelay?: number;
|
|
13
|
+
|
|
14
|
+
/** Close delay in ms, `0` by default */
|
|
15
|
+
closeDelay?: number;
|
|
16
|
+
|
|
17
|
+
/** Controlled opened state */
|
|
18
|
+
opened?: boolean;
|
|
19
|
+
|
|
20
|
+
/** Uncontrolled tooltip initial opened state */
|
|
21
|
+
defaultOpened?: boolean;
|
|
22
|
+
|
|
23
|
+
/** Space between target element and tooltip in px, `5` by default */
|
|
24
|
+
offset?: number | FloatingAxesOffsets;
|
|
25
|
+
|
|
26
|
+
/** Determines whether the tooltip should have an arrow, `false` by default */
|
|
27
|
+
withArrow?: boolean;
|
|
28
|
+
|
|
29
|
+
/** Arrow size in px, `4` by default */
|
|
30
|
+
arrowSize?: number;
|
|
31
|
+
|
|
32
|
+
/** Arrow offset in px, `5` by default */
|
|
33
|
+
arrowOffset?: number;
|
|
34
|
+
|
|
35
|
+
/** Arrow `border-radius` in px, `0` by default */
|
|
36
|
+
arrowRadius?: number;
|
|
37
|
+
|
|
38
|
+
/** Arrow position relative to the tooltip, `side` by default */
|
|
39
|
+
arrowPosition?: ArrowPosition;
|
|
40
|
+
|
|
41
|
+
/** Props passed down to the `Transition` component that used to animate tooltip presence, use to configure duration and animation type, `{ duration: 100, transition: 'fade' }` by default */
|
|
42
|
+
transitionProps?: TransitionOverrides;
|
|
43
|
+
|
|
44
|
+
/** Determines which events will be used to show tooltip, `{ hover: true, focus: false, touch: false }` by default */
|
|
45
|
+
events?: { hover: boolean; focus: boolean; touch: boolean };
|
|
46
|
+
|
|
47
|
+
/** Must be set if the tooltip target is an inline element */
|
|
48
|
+
inline?: boolean;
|
|
49
|
+
|
|
50
|
+
/** If set, the tooltip will not be unmounted from the DOM when it is hidden, `display: none` styles will be applied instead */
|
|
51
|
+
keepMounted?: boolean;
|
|
52
|
+
|
|
53
|
+
/** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy), `'absolute'` by default */
|
|
54
|
+
floatingStrategy?: FloatingStrategy;
|
|
55
|
+
|
|
56
|
+
/** Determines whether tooltip text color should depend on `background-color`. If luminosity of the `color` prop is less than `theme.luminosityThreshold`, then `theme.white` will be used for text color, otherwise `theme.black`. Overrides `theme.autoContrast`. */
|
|
57
|
+
autoContrast?: boolean;
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<script lang="ts">
|
|
62
|
+
import { getDirection } from '../../DirectionProvider/direction.svelte.js';
|
|
63
|
+
import { theme } from '../../MantineProvider/theme.svelte.js';
|
|
64
|
+
import { getRadius } from '../../utils/get-size.js';
|
|
65
|
+
import { createAttachmentKey } from 'svelte/attachments';
|
|
66
|
+
import { CreateFloating } from '../Floating/CreateFloating.svelte.js';
|
|
67
|
+
import FloatingArrow from '../Floating/FloatingArrow.svelte';
|
|
68
|
+
import { getFloatingPosition } from '../Floating/get-floating-position.js';
|
|
69
|
+
import OptionalPortal from '../Portal/OptionalPortal.svelte';
|
|
70
|
+
import { getTooltipMiddlewares } from './getTooltipMiddleware.js';
|
|
71
|
+
|
|
72
|
+
let {
|
|
73
|
+
position = 'top',
|
|
74
|
+
withinPortal = true,
|
|
75
|
+
arrowSize = 4,
|
|
76
|
+
arrowOffset = 5,
|
|
77
|
+
arrowRadius = 0,
|
|
78
|
+
arrowPosition = 'side',
|
|
79
|
+
offset = 5,
|
|
80
|
+
transitionProps = { transition: 'fade', options: { duration: 100 } },
|
|
81
|
+
events = { hover: true, focus: false, touch: false },
|
|
82
|
+
zIndex = getDefaultZIndex('popover'),
|
|
83
|
+
middlewares = { flip: true, shift: true, inline: false },
|
|
84
|
+
portalProps,
|
|
85
|
+
children,
|
|
86
|
+
onclick,
|
|
87
|
+
onmouseenter,
|
|
88
|
+
onmouseleave,
|
|
89
|
+
onmousemove,
|
|
90
|
+
onpointerdown,
|
|
91
|
+
onpointerenter,
|
|
92
|
+
defaultOpened = true,
|
|
93
|
+
opened = $bindable(defaultOpened),
|
|
94
|
+
label,
|
|
95
|
+
withArrow = false,
|
|
96
|
+
color,
|
|
97
|
+
autoContrast,
|
|
98
|
+
radius,
|
|
99
|
+
multiline,
|
|
100
|
+
inline,
|
|
101
|
+
floatingStrategy,
|
|
102
|
+
...props
|
|
103
|
+
}: TooltipProps = $props();
|
|
104
|
+
|
|
105
|
+
const transition = transitions[transitionProps.transition];
|
|
106
|
+
|
|
107
|
+
const dir = $derived(getDirection().current);
|
|
108
|
+
|
|
109
|
+
let referenceRef = $state<HTMLElement>();
|
|
110
|
+
let floatingRef = $state<HTMLElement>();
|
|
111
|
+
let arrowRef = $state<HTMLDivElement>();
|
|
112
|
+
|
|
113
|
+
const tooltipMiddlewares = $derived(
|
|
114
|
+
getTooltipMiddlewares({
|
|
115
|
+
middlewares,
|
|
116
|
+
offset: typeof offset === 'number' ? offset + (withArrow ? arrowSize / 2 : 0) : offset,
|
|
117
|
+
arrowRef,
|
|
118
|
+
arrowOffset,
|
|
119
|
+
inline,
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const floating = new CreateFloating({
|
|
124
|
+
placement: () => getFloatingPosition(dir, position),
|
|
125
|
+
referenceElement: () => referenceRef,
|
|
126
|
+
floatingElement: () => floatingRef,
|
|
127
|
+
middleware: () => tooltipMiddlewares,
|
|
128
|
+
strategy: () => floatingStrategy,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
function handleMouseEnter(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement }) {
|
|
132
|
+
onmouseenter?.(event);
|
|
133
|
+
|
|
134
|
+
if (events.hover) {
|
|
135
|
+
opened = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function handleMouseLeave(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement }) {
|
|
140
|
+
onmouseleave?.(event);
|
|
141
|
+
|
|
142
|
+
if (events.hover) {
|
|
143
|
+
opened = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const colors = $derived(
|
|
148
|
+
theme.variantColorResolver({
|
|
149
|
+
color: color || theme.primaryColor,
|
|
150
|
+
autoContrast,
|
|
151
|
+
// TODO: add variant ?
|
|
152
|
+
variant: 'filled',
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<!-- TODO: Tooltip position is not correct -->
|
|
158
|
+
|
|
159
|
+
<OptionalPortal {withinPortal} {...portalProps}>
|
|
160
|
+
{#if opened}
|
|
161
|
+
<div
|
|
162
|
+
{...props}
|
|
163
|
+
bind:this={floatingRef}
|
|
164
|
+
class={['tooltip', props.class]}
|
|
165
|
+
transition:transition={{ ...transitionProps.options }}
|
|
166
|
+
style:--tooltip-radius={radius ? getRadius(radius) : undefined}
|
|
167
|
+
style:--tooltip-bg={color ? colors.background : undefined}
|
|
168
|
+
style:--tooltip-color={color ? colors.color : undefined}
|
|
169
|
+
style:z-index={zIndex}
|
|
170
|
+
style:top="{floating.x}px"
|
|
171
|
+
style:left="{floating.y}px"
|
|
172
|
+
data-multiline={multiline || undefined}
|
|
173
|
+
data-fixed={floatingStrategy === 'fixed' || undefined}
|
|
174
|
+
>
|
|
175
|
+
{#if typeof label === 'string'}
|
|
176
|
+
{label}
|
|
177
|
+
{:else}
|
|
178
|
+
{@render label()}
|
|
179
|
+
{/if}
|
|
180
|
+
|
|
181
|
+
<FloatingArrow
|
|
182
|
+
class="arrow"
|
|
183
|
+
bind:ref={arrowRef}
|
|
184
|
+
arrowX={floating.middlewareData?.arrow?.x ?? 0}
|
|
185
|
+
arrowY={floating.middlewareData?.arrow?.y ?? 0}
|
|
186
|
+
visible={withArrow}
|
|
187
|
+
{position}
|
|
188
|
+
{arrowSize}
|
|
189
|
+
{arrowOffset}
|
|
190
|
+
{arrowRadius}
|
|
191
|
+
{arrowPosition}
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
{/if}
|
|
195
|
+
</OptionalPortal>
|
|
196
|
+
|
|
197
|
+
{@render children({
|
|
198
|
+
[createAttachmentKey()]: (node: HTMLElement) => (referenceRef = node),
|
|
199
|
+
onclick,
|
|
200
|
+
onmouseenter: handleMouseEnter,
|
|
201
|
+
onmouseleave: handleMouseLeave,
|
|
202
|
+
onmousemove,
|
|
203
|
+
onpointerdown,
|
|
204
|
+
onpointerenter,
|
|
205
|
+
})}
|
|
206
|
+
|
|
207
|
+
<style>.tooltip {
|
|
208
|
+
--tooltip-radius: var(--mantine-radius-default);
|
|
209
|
+
position: absolute;
|
|
210
|
+
padding: calc(var(--mantine-spacing-xs) / 2) var(--mantine-spacing-xs);
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
font-size: var(--mantine-font-size-sm);
|
|
213
|
+
white-space: nowrap;
|
|
214
|
+
border-radius: var(--tooltip-radius);
|
|
215
|
+
}
|
|
216
|
+
:global(:where([data-mantine-color-scheme="light"])) .tooltip {
|
|
217
|
+
background-color: var(--tooltip-bg, var(--mantine-color-gray-9));
|
|
218
|
+
color: var(--tooltip-color, var(--mantine-color-white));
|
|
219
|
+
}
|
|
220
|
+
:global(:where([data-mantine-color-scheme="dark"])) .tooltip {
|
|
221
|
+
background-color: var(--tooltip-bg, var(--mantine-color-gray-2));
|
|
222
|
+
color: var(--tooltip-color, var(--mantine-color-black));
|
|
223
|
+
}
|
|
224
|
+
.tooltip:where([data-multiline]) {
|
|
225
|
+
white-space: normal;
|
|
226
|
+
}
|
|
227
|
+
.tooltip:where([data-fixed]) {
|
|
228
|
+
position: fixed;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
* :global(.arrow) {
|
|
232
|
+
background-color: inherit;
|
|
233
|
+
border: 0;
|
|
234
|
+
z-index: 1;
|
|
235
|
+
}</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ArrowPosition, FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../Floating/types.js';
|
|
2
|
+
import { type TransitionOverrides } from '../Transitions/transitions.js';
|
|
3
|
+
import type { TooltipBaseProps } from './Tooltip.types.js';
|
|
4
|
+
export interface TooltipProps extends TooltipBaseProps {
|
|
5
|
+
/** Called when tooltip position changes */
|
|
6
|
+
onPositionChange?: (position: FloatingPosition) => void;
|
|
7
|
+
/** Open delay in ms */
|
|
8
|
+
openDelay?: number;
|
|
9
|
+
/** Close delay in ms, `0` by default */
|
|
10
|
+
closeDelay?: number;
|
|
11
|
+
/** Controlled opened state */
|
|
12
|
+
opened?: boolean;
|
|
13
|
+
/** Uncontrolled tooltip initial opened state */
|
|
14
|
+
defaultOpened?: boolean;
|
|
15
|
+
/** Space between target element and tooltip in px, `5` by default */
|
|
16
|
+
offset?: number | FloatingAxesOffsets;
|
|
17
|
+
/** Determines whether the tooltip should have an arrow, `false` by default */
|
|
18
|
+
withArrow?: boolean;
|
|
19
|
+
/** Arrow size in px, `4` by default */
|
|
20
|
+
arrowSize?: number;
|
|
21
|
+
/** Arrow offset in px, `5` by default */
|
|
22
|
+
arrowOffset?: number;
|
|
23
|
+
/** Arrow `border-radius` in px, `0` by default */
|
|
24
|
+
arrowRadius?: number;
|
|
25
|
+
/** Arrow position relative to the tooltip, `side` by default */
|
|
26
|
+
arrowPosition?: ArrowPosition;
|
|
27
|
+
/** Props passed down to the `Transition` component that used to animate tooltip presence, use to configure duration and animation type, `{ duration: 100, transition: 'fade' }` by default */
|
|
28
|
+
transitionProps?: TransitionOverrides;
|
|
29
|
+
/** Determines which events will be used to show tooltip, `{ hover: true, focus: false, touch: false }` by default */
|
|
30
|
+
events?: {
|
|
31
|
+
hover: boolean;
|
|
32
|
+
focus: boolean;
|
|
33
|
+
touch: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** Must be set if the tooltip target is an inline element */
|
|
36
|
+
inline?: boolean;
|
|
37
|
+
/** If set, the tooltip will not be unmounted from the DOM when it is hidden, `display: none` styles will be applied instead */
|
|
38
|
+
keepMounted?: boolean;
|
|
39
|
+
/** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy), `'absolute'` by default */
|
|
40
|
+
floatingStrategy?: FloatingStrategy;
|
|
41
|
+
/** Determines whether tooltip text color should depend on `background-color`. If luminosity of the `color` prop is less than `theme.luminosityThreshold`, then `theme.white` will be used for text color, otherwise `theme.black`. Overrides `theme.autoContrast`. */
|
|
42
|
+
autoContrast?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare const Tooltip: import("svelte").Component<TooltipProps, {}, "opened">;
|
|
45
|
+
type Tooltip = ReturnType<typeof Tooltip>;
|
|
46
|
+
export default Tooltip;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
import type { MantineColor, MantineRadius } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
import type { FlipOptions, InlineOptions, ShiftOptions, SizeOptions } from '@floating-ui/dom';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { Attachment, createAttachmentKey } from 'svelte/attachments';
|
|
6
|
+
import type { FloatingPosition } from '../Floating/types.js';
|
|
7
|
+
import type { BasePortalProps } from '../Portal/Portal.svelte';
|
|
8
|
+
export interface TooltipMiddlewares {
|
|
9
|
+
shift?: boolean | ShiftOptions;
|
|
10
|
+
flip?: boolean | FlipOptions;
|
|
11
|
+
inline?: boolean | InlineOptions;
|
|
12
|
+
size?: boolean | SizeOptions;
|
|
13
|
+
}
|
|
14
|
+
export interface TooltipBaseProps extends Omit<DivElement, 'children'> {
|
|
15
|
+
/** Target element, must support `ref` prop and `...others` */
|
|
16
|
+
children: Snippet<[
|
|
17
|
+
{
|
|
18
|
+
[key: ReturnType<typeof createAttachmentKey>]: Attachment<HTMLElement>;
|
|
19
|
+
onclick?: () => void;
|
|
20
|
+
onmouseenter?: () => void;
|
|
21
|
+
onmouseleave?: () => void;
|
|
22
|
+
onmousemove?: () => void;
|
|
23
|
+
onpointerdown?: () => void;
|
|
24
|
+
onpointerenter?: () => void;
|
|
25
|
+
}
|
|
26
|
+
]>;
|
|
27
|
+
/** Tooltip position relative to target element (`Tooltip` component) or mouse (`Tooltip.Floating` component) */
|
|
28
|
+
position?: FloatingPosition;
|
|
29
|
+
/** Tooltip content */
|
|
30
|
+
label: string | Snippet;
|
|
31
|
+
/** Determines whether tooltip should be rendered within `Portal`, `true` by default */
|
|
32
|
+
withinPortal?: boolean;
|
|
33
|
+
/** Key of `theme.radius` or any valid CSS value to set border-radius, numbers are converted to rem, `theme.defaultRadius` by default */
|
|
34
|
+
radius?: MantineRadius;
|
|
35
|
+
/** Key of `theme.colors` or any valid CSS color, controls tooltip background, by default set based on current color scheme */
|
|
36
|
+
color?: MantineColor;
|
|
37
|
+
/** Determines whether content should be wrapped on to the next line, `false` by default */
|
|
38
|
+
multiline?: boolean;
|
|
39
|
+
/** Tooltip z-index, `300` by default */
|
|
40
|
+
zIndex?: string | number;
|
|
41
|
+
/** If set, tooltip element will not be rendered */
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/** Props to pass down to the portal when withinPortal is true */
|
|
44
|
+
portalProps?: Omit<BasePortalProps, 'withinPortal'>;
|
|
45
|
+
/** Floating ui middlewares to configure position handling, `{ flip: true, shift: true, inline: false }` by default */
|
|
46
|
+
middlewares?: TooltipMiddlewares;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FloatingAxesOffsets } from '../Floating/types.js';
|
|
2
|
+
import type { TooltipMiddlewares } from './Tooltip.types.js';
|
|
3
|
+
interface GetTooltipMiddlewaresProps {
|
|
4
|
+
middlewares: TooltipMiddlewares;
|
|
5
|
+
offset: number | FloatingAxesOffsets;
|
|
6
|
+
arrowRef: HTMLElement | undefined;
|
|
7
|
+
arrowOffset: number;
|
|
8
|
+
inline: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function getTooltipMiddlewares(settings: GetTooltipMiddlewaresProps): {
|
|
11
|
+
name: string;
|
|
12
|
+
options?: any;
|
|
13
|
+
fn: (state: import("@floating-ui/dom").MiddlewareState) => import("@floating-ui/core").MiddlewareReturn | Promise<import("@floating-ui/core").MiddlewareReturn>;
|
|
14
|
+
}[];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { arrow, flip, inline, offset, shift } from '@floating-ui/dom';
|
|
2
|
+
function getDefaultMiddlewares(middlewares) {
|
|
3
|
+
if (middlewares === undefined) {
|
|
4
|
+
return { shift: true, flip: true };
|
|
5
|
+
}
|
|
6
|
+
const result = { ...middlewares };
|
|
7
|
+
if (middlewares.shift === undefined) {
|
|
8
|
+
result.shift = true;
|
|
9
|
+
}
|
|
10
|
+
if (middlewares.flip === undefined) {
|
|
11
|
+
result.flip = true;
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
export function getTooltipMiddlewares(settings) {
|
|
16
|
+
const middlewaresOptions = getDefaultMiddlewares(settings.middlewares);
|
|
17
|
+
const middlewares = [offset(settings.offset)];
|
|
18
|
+
if (middlewaresOptions.shift) {
|
|
19
|
+
middlewares.push(shift(typeof middlewaresOptions.shift === 'boolean' ? { padding: 8 } : { padding: 8, ...middlewaresOptions.shift }));
|
|
20
|
+
}
|
|
21
|
+
if (middlewaresOptions.flip) {
|
|
22
|
+
middlewares.push(typeof middlewaresOptions.flip === 'boolean' ? flip() : flip(middlewaresOptions.flip));
|
|
23
|
+
}
|
|
24
|
+
middlewares.push(arrow({ element: settings.arrowRef, padding: settings.arrowOffset }));
|
|
25
|
+
if (middlewaresOptions.inline) {
|
|
26
|
+
middlewares.push(typeof middlewaresOptions.inline === 'boolean' ? inline() : inline(middlewaresOptions.inline));
|
|
27
|
+
}
|
|
28
|
+
else if (settings.inline) {
|
|
29
|
+
middlewares.push(inline());
|
|
30
|
+
}
|
|
31
|
+
return middlewares;
|
|
32
|
+
}
|
|
@@ -20,14 +20,18 @@ export { default as InputBase } from './InputBase/InputBase.svelte';
|
|
|
20
20
|
export { default as Loader } from './Loader/Loader.svelte';
|
|
21
21
|
export { default as Modal } from './Modal/index.js';
|
|
22
22
|
export { default as NavLink } from './NavLink/NavLink.svelte';
|
|
23
|
+
export { default as Notification } from './Notification/Notification.svelte';
|
|
23
24
|
export { default as Overlay } from './Overlay/Overlay.svelte';
|
|
24
25
|
export { default as Paper } from './Paper/Paper.svelte';
|
|
25
26
|
export { default as Popover } from './Popover/index.js';
|
|
26
27
|
export { default as Portal } from './Portal/Portal.svelte';
|
|
28
|
+
export { default as Progress } from './Progress/index.js';
|
|
27
29
|
export { default as ScrollArea } from './ScrollArea/index.js';
|
|
28
30
|
export { default as SegmentedControl } from './SegmentedControl/SegmentedControl.svelte';
|
|
29
31
|
export { default as Select } from './Select/Select.svelte';
|
|
30
32
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
31
33
|
export { default as Switch } from './Switch/index.js';
|
|
34
|
+
export { default as Table } from './Table/index.js';
|
|
32
35
|
export { default as TextInput } from './TextInput/TextInput.svelte';
|
|
36
|
+
export { default as Tooltip } from './Tooltip/Tooltip.svelte';
|
|
33
37
|
export * from './Transitions/index.js';
|
|
@@ -20,14 +20,18 @@ export { default as InputBase } from './InputBase/InputBase.svelte';
|
|
|
20
20
|
export { default as Loader } from './Loader/Loader.svelte';
|
|
21
21
|
export { default as Modal } from './Modal/index.js';
|
|
22
22
|
export { default as NavLink } from './NavLink/NavLink.svelte';
|
|
23
|
+
export { default as Notification } from './Notification/Notification.svelte';
|
|
23
24
|
export { default as Overlay } from './Overlay/Overlay.svelte';
|
|
24
25
|
export { default as Paper } from './Paper/Paper.svelte';
|
|
25
26
|
export { default as Popover } from './Popover/index.js';
|
|
26
27
|
export { default as Portal } from './Portal/Portal.svelte';
|
|
28
|
+
export { default as Progress } from './Progress/index.js';
|
|
27
29
|
export { default as ScrollArea } from './ScrollArea/index.js';
|
|
28
30
|
export { default as SegmentedControl } from './SegmentedControl/SegmentedControl.svelte';
|
|
29
31
|
export { default as Select } from './Select/Select.svelte';
|
|
30
32
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
31
33
|
export { default as Switch } from './Switch/index.js';
|
|
34
|
+
export { default as Table } from './Table/index.js';
|
|
32
35
|
export { default as TextInput } from './TextInput/TextInput.svelte';
|
|
36
|
+
export { default as Tooltip } from './Tooltip/Tooltip.svelte';
|
|
33
37
|
export * from './Transitions/index.js';
|
|
@@ -23,9 +23,8 @@ export async function generateIconComponent(name, data, asPackage) {
|
|
|
23
23
|
const component_name = generateComponentName(name);
|
|
24
24
|
const svg_content = minifySVGBody(data.body);
|
|
25
25
|
const iconContainerPath = asPackage ? 'reburn-ui' : '$lib/icons';
|
|
26
|
-
const iconPath = asPackage ? '{IconContainer}' : 'IconContainer';
|
|
27
26
|
const component_code = `<script lang="ts">
|
|
28
|
-
import
|
|
27
|
+
import { IconContainer } from '${iconContainerPath}';
|
|
29
28
|
import type { IconContainerProps } from '${iconContainerPath}';
|
|
30
29
|
|
|
31
30
|
let { size = '100%', ...props }: IconContainerProps = $props();
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reburn-ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"analyze": "ANALYZE=true vite build",
|
|
8
|
-
"dev": "vite dev",
|
|
9
|
-
"build": "vite build",
|
|
8
|
+
"dev": "LOCAL_REBURN_UI_INSTALLED=true vite dev",
|
|
9
|
+
"build": "LOCAL_REBURN_UI_INSTALLED=true vite build",
|
|
10
10
|
"preview": "vite preview",
|
|
11
11
|
"prepare": "svelte-kit sync || echo ''",
|
|
12
|
-
"prepack": "bun vite build && bun svelte-kit sync && bun svelte-package && bun publint",
|
|
12
|
+
"prepack": "LOCAL_REBURN_UI_INSTALLED=true bun vite build && bun svelte-kit sync && bun svelte-package && bun publint",
|
|
13
13
|
"transform-css-files": "bun run scripts/transform-css-files.ts"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@eslint/compat": "^1.3.1",
|
|
66
|
-
"@eslint/js": "^9.
|
|
66
|
+
"@eslint/js": "^9.32.0",
|
|
67
67
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
68
|
-
"@sveltejs/kit": "^2.
|
|
68
|
+
"@sveltejs/kit": "^2.26.1",
|
|
69
69
|
"@sveltejs/package": "^2.4.0",
|
|
70
70
|
"@sveltejs/vite-plugin-svelte": "^6.1.0",
|
|
71
71
|
"@types/bun": "^1.2.19",
|
|
72
72
|
"@types/d3": "^7.4.3",
|
|
73
73
|
"csstype": "^3.1.3",
|
|
74
|
-
"eslint": "^9.
|
|
74
|
+
"eslint": "^9.32.0",
|
|
75
75
|
"eslint-plugin-svelte": "^3.11.0",
|
|
76
76
|
"globals": "^16.3.0",
|
|
77
77
|
"mitata": "^1.0.34",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"publint": "^0.3.12",
|
|
83
83
|
"sass-embedded": "^1.89.2",
|
|
84
84
|
"sonda": "^0.9.0",
|
|
85
|
-
"svelte": "^5.36.
|
|
85
|
+
"svelte": "^5.36.16",
|
|
86
86
|
"svelte-check": "^4.3.0",
|
|
87
87
|
"typescript": "^5.8.3",
|
|
88
88
|
"typescript-eslint": "^8.38.0",
|
|
89
|
-
"vite": "^7.0.
|
|
89
|
+
"vite": "^7.0.6"
|
|
90
90
|
},
|
|
91
91
|
"keywords": [
|
|
92
92
|
"svelte"
|