@max-ts/svelte 1.12.6 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/styles.css +35 -2
- package/dist/components/OverflowTypography/OverflowTypography.js +175 -0
- package/dist/components/OverflowTypography/OverflowTypography.svelte.d.ts +4 -0
- package/dist/components/OverflowTypography/index.d.ts +2 -0
- package/dist/components/OverflowTypography/store.svelte.d.ts +22 -0
- package/dist/components/OverflowTypography/store.svelte.js +84 -0
- package/dist/components/OverflowTypography/styles.css.d.ts +5 -0
- package/dist/components/OverflowTypography/styles.css.js +12 -0
- package/dist/components/OverflowTypography/types.d.ts +18 -0
- package/dist/components/Tooltip/Tooltip.js +9 -6
- package/dist/components/Tooltip/store.svelte.d.ts +5 -2
- package/dist/components/Tooltip/store.svelte.js +18 -16
- package/dist/components/Tooltip/styles.css.d.ts +2 -5
- package/dist/components/Tooltip/styles.css.js +3 -5
- package/dist/components/Tooltip/types.d.ts +1 -0
- package/dist/components/Typography/Typography.js +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -3
- package/dist/stories/OverflowTypography.stories.svelte.d.ts +19 -0
- package/package.json +1 -1
package/dist/assets/styles.css
CHANGED
|
@@ -2754,6 +2754,37 @@ img, picture, video, canvas {
|
|
|
2754
2754
|
cursor: not-allowed;
|
|
2755
2755
|
opacity: 0.5;
|
|
2756
2756
|
}
|
|
2757
|
+
.styles_truncate__dpgi0n0 {
|
|
2758
|
+
overflow: hidden;
|
|
2759
|
+
max-width: 100%;
|
|
2760
|
+
min-width: 0;
|
|
2761
|
+
text-overflow: ellipsis;
|
|
2762
|
+
white-space: nowrap;
|
|
2763
|
+
}
|
|
2764
|
+
.styles_multipleRows__dpgi0n1 {
|
|
2765
|
+
display: -webkit-box;
|
|
2766
|
+
white-space: initial;
|
|
2767
|
+
-webkit-box-orient: vertical;
|
|
2768
|
+
-webkit-line-clamp: var(--rows-count);
|
|
2769
|
+
}
|
|
2770
|
+
.styles_wrapper__dpgi0n2 {
|
|
2771
|
+
display: flex;
|
|
2772
|
+
min-width: 0;
|
|
2773
|
+
width: 100%;
|
|
2774
|
+
white-space: nowrap;
|
|
2775
|
+
}
|
|
2776
|
+
.styles_wrapperAlignments_left__dpgi0n3 {
|
|
2777
|
+
justify-content: flex-start;
|
|
2778
|
+
}
|
|
2779
|
+
.styles_wrapperAlignments_center__dpgi0n4 {
|
|
2780
|
+
justify-content: center;
|
|
2781
|
+
}
|
|
2782
|
+
.styles_wrapperAlignments_right__dpgi0n5 {
|
|
2783
|
+
justify-content: flex-end;
|
|
2784
|
+
}
|
|
2785
|
+
.styles_wrapperAlignments_justify__dpgi0n6 {
|
|
2786
|
+
justify-content: space-between;
|
|
2787
|
+
}
|
|
2757
2788
|
.styles_wrapper__rub3490 {
|
|
2758
2789
|
display: block;
|
|
2759
2790
|
max-width: 100%;
|
|
@@ -3516,13 +3547,15 @@ img, picture, video, canvas {
|
|
|
3516
3547
|
background-color: var(--colors-background-tooltip);
|
|
3517
3548
|
color: var(--colors-background-paper);
|
|
3518
3549
|
border-radius: var(--radius-small);
|
|
3519
|
-
padding: var(--spacing-2)
|
|
3550
|
+
padding: var(--spacing-2);
|
|
3520
3551
|
font-size: var(--fontSize-xs);
|
|
3521
3552
|
font-weight: var(--fontWeight-semibold);
|
|
3522
3553
|
text-align: center;
|
|
3523
3554
|
width: fit-content;
|
|
3555
|
+
max-width: min(320px, calc(100vw - 32px));
|
|
3524
3556
|
animation: styles_fadeIn__1ovcrev0 150ms ease-out, styles_zoomIn__1ovcrev2 150ms ease-out;
|
|
3525
|
-
|
|
3557
|
+
white-space: normal;
|
|
3558
|
+
overflow-wrap: break-word;
|
|
3526
3559
|
line-height: var(--lineHeight-none);
|
|
3527
3560
|
}
|
|
3528
3561
|
.styles_content__1ovcrev8[data-state="closed"] {
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import Typography from "../Typography/Typography.js";
|
|
2
|
+
import Tooltip from "../Tooltip/Tooltip.js";
|
|
3
|
+
import { OverflowTypographyStore } from "./store.svelte.js";
|
|
4
|
+
import { truncate, wrapper, wrapperAlignments } from "./styles.css.js";
|
|
5
|
+
import "svelte/internal/disclose-version";
|
|
6
|
+
import * as $ from "svelte/internal/client";
|
|
7
|
+
//#region src/components/OverflowTypography/OverflowTypography.svelte
|
|
8
|
+
var root_2 = $.from_html(`<div><!> <!></div>`);
|
|
9
|
+
function OverflowTypography($$anchor, $$props) {
|
|
10
|
+
$.push($$props, true);
|
|
11
|
+
const typography = ($$anchor) => {
|
|
12
|
+
var fragment = $.comment();
|
|
13
|
+
var node = $.first_child(fragment);
|
|
14
|
+
var consequent = ($$anchor) => {
|
|
15
|
+
var div = root_2();
|
|
16
|
+
var node_1 = $.child(div);
|
|
17
|
+
Typography(node_1, $.spread_props(() => restProps, {
|
|
18
|
+
get align() {
|
|
19
|
+
return align();
|
|
20
|
+
},
|
|
21
|
+
get class() {
|
|
22
|
+
return $.get(truncateClass);
|
|
23
|
+
},
|
|
24
|
+
component: "span",
|
|
25
|
+
display: "block",
|
|
26
|
+
get style() {
|
|
27
|
+
return $$props.style;
|
|
28
|
+
},
|
|
29
|
+
get ref() {
|
|
30
|
+
return ref();
|
|
31
|
+
},
|
|
32
|
+
set ref($$value) {
|
|
33
|
+
ref($$value);
|
|
34
|
+
},
|
|
35
|
+
children: ($$anchor, $$slotProps) => {
|
|
36
|
+
$.next();
|
|
37
|
+
var text_1 = $.text();
|
|
38
|
+
$.template_effect(() => $.set_text(text_1, store.firstPartLabel));
|
|
39
|
+
$.append($$anchor, text_1);
|
|
40
|
+
},
|
|
41
|
+
$$slots: { default: true }
|
|
42
|
+
}));
|
|
43
|
+
Typography($.sibling(node_1, 2), $.spread_props(() => restProps, {
|
|
44
|
+
get align() {
|
|
45
|
+
return align();
|
|
46
|
+
},
|
|
47
|
+
get class() {
|
|
48
|
+
return $$props.class;
|
|
49
|
+
},
|
|
50
|
+
component: "span",
|
|
51
|
+
get style() {
|
|
52
|
+
return $$props.style;
|
|
53
|
+
},
|
|
54
|
+
children: ($$anchor, $$slotProps) => {
|
|
55
|
+
$.next();
|
|
56
|
+
var text_2 = $.text();
|
|
57
|
+
$.template_effect(() => $.set_text(text_2, store.secondPartLabel));
|
|
58
|
+
$.append($$anchor, text_2);
|
|
59
|
+
},
|
|
60
|
+
$$slots: { default: true }
|
|
61
|
+
}));
|
|
62
|
+
$.reset(div);
|
|
63
|
+
$.template_effect(() => $.set_class(div, 1, $.clsx($.get(wrapperClass))));
|
|
64
|
+
$.append($$anchor, div);
|
|
65
|
+
};
|
|
66
|
+
var alternate = ($$anchor) => {
|
|
67
|
+
Typography($$anchor, $.spread_props(() => restProps, {
|
|
68
|
+
get align() {
|
|
69
|
+
return align();
|
|
70
|
+
},
|
|
71
|
+
get class() {
|
|
72
|
+
return $.get(contentClass);
|
|
73
|
+
},
|
|
74
|
+
display: "block",
|
|
75
|
+
get style() {
|
|
76
|
+
return $.get(contentStyle);
|
|
77
|
+
},
|
|
78
|
+
get ref() {
|
|
79
|
+
return ref();
|
|
80
|
+
},
|
|
81
|
+
set ref($$value) {
|
|
82
|
+
ref($$value);
|
|
83
|
+
},
|
|
84
|
+
children: ($$anchor, $$slotProps) => {
|
|
85
|
+
var fragment_4 = $.comment();
|
|
86
|
+
var node_3 = $.first_child(fragment_4);
|
|
87
|
+
var consequent_1 = ($$anchor) => {
|
|
88
|
+
var text_3 = $.text();
|
|
89
|
+
$.template_effect(() => $.set_text(text_3, $.get(label)));
|
|
90
|
+
$.append($$anchor, text_3);
|
|
91
|
+
};
|
|
92
|
+
var consequent_2 = ($$anchor) => {
|
|
93
|
+
var fragment_6 = $.comment();
|
|
94
|
+
var node_4 = $.first_child(fragment_6);
|
|
95
|
+
$.snippet(node_4, () => $$props.children);
|
|
96
|
+
$.append($$anchor, fragment_6);
|
|
97
|
+
};
|
|
98
|
+
$.if(node_3, ($$render) => {
|
|
99
|
+
if ($.get(label)) $$render(consequent_1);
|
|
100
|
+
else if (typeof $$props.children === "function") $$render(consequent_2, 1);
|
|
101
|
+
});
|
|
102
|
+
$.append($$anchor, fragment_4);
|
|
103
|
+
},
|
|
104
|
+
$$slots: { default: true }
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
$.if(node, ($$render) => {
|
|
108
|
+
if (store.hasVisibleLastSymbols) $$render(consequent);
|
|
109
|
+
else $$render(alternate, -1);
|
|
110
|
+
});
|
|
111
|
+
$.append($$anchor, fragment);
|
|
112
|
+
};
|
|
113
|
+
let ref = $.prop($$props, "ref", 15, null), align = $.prop($$props, "align", 3, "left"), rowsCount = $.prop($$props, "rowsCount", 3, 1), visibleLastSymbolsCount = $.prop($$props, "visibleLastSymbolsCount", 3, 0), restProps = $.rest_props($$props, [
|
|
114
|
+
"$$slots",
|
|
115
|
+
"$$events",
|
|
116
|
+
"$$legacy",
|
|
117
|
+
"ref",
|
|
118
|
+
"align",
|
|
119
|
+
"children",
|
|
120
|
+
"class",
|
|
121
|
+
"style",
|
|
122
|
+
"rowsCount",
|
|
123
|
+
"text",
|
|
124
|
+
"tooltipProps",
|
|
125
|
+
"visibleLastSymbolsCount"
|
|
126
|
+
]);
|
|
127
|
+
const label = $.derived(() => $$props.text ?? (typeof $$props.children === "string" ? $$props.children : void 0));
|
|
128
|
+
const store = new OverflowTypographyStore({
|
|
129
|
+
get text() {
|
|
130
|
+
return $.get(label);
|
|
131
|
+
},
|
|
132
|
+
get rowsCount() {
|
|
133
|
+
return rowsCount();
|
|
134
|
+
},
|
|
135
|
+
get visibleLastSymbolsCount() {
|
|
136
|
+
return visibleLastSymbolsCount();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const joinClasses = (...classes) => classes.filter(Boolean).join(" ");
|
|
140
|
+
const wrapperClass = $.derived(() => joinClasses(wrapper, wrapperAlignments[align()]));
|
|
141
|
+
const truncateClass = $.derived(() => joinClasses(truncate, $$props.class));
|
|
142
|
+
const contentClass = $.derived(() => joinClasses(truncate, store.hasMultipleRows && "styles_multipleRows__dpgi0n1", $$props.class));
|
|
143
|
+
const contentStyle = $.derived(() => [$$props.style, `--rows-count: ${store.rowsCount}`].filter(Boolean).join("; "));
|
|
144
|
+
const tooltipContent = $.derived(() => $$props.tooltipProps?.content ?? (store.isOverflowed ? $.get(label) : void 0));
|
|
145
|
+
const tooltipConfig = $.derived(() => ({
|
|
146
|
+
...$$props.tooltipProps,
|
|
147
|
+
content: $.get(tooltipContent),
|
|
148
|
+
open: store.isOverflowed
|
|
149
|
+
}));
|
|
150
|
+
let cleanup;
|
|
151
|
+
$.user_effect(() => {
|
|
152
|
+
if (!ref()) return;
|
|
153
|
+
cleanup?.();
|
|
154
|
+
cleanup = store.attach(ref());
|
|
155
|
+
return () => {
|
|
156
|
+
cleanup?.();
|
|
157
|
+
cleanup = void 0;
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
$.user_effect(() => {
|
|
161
|
+
$.get(label);
|
|
162
|
+
rowsCount();
|
|
163
|
+
visibleLastSymbolsCount();
|
|
164
|
+
store.check();
|
|
165
|
+
});
|
|
166
|
+
Tooltip($$anchor, $.spread_props(() => $.get(tooltipConfig), {
|
|
167
|
+
children: ($$anchor, $$slotProps) => {
|
|
168
|
+
typography($$anchor);
|
|
169
|
+
},
|
|
170
|
+
$$slots: { default: true }
|
|
171
|
+
}));
|
|
172
|
+
$.pop();
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { OverflowTypography as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
text?: string;
|
|
3
|
+
rowsCount?: number;
|
|
4
|
+
visibleLastSymbolsCount?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class OverflowTypographyStore {
|
|
7
|
+
#private;
|
|
8
|
+
isOverflowed: boolean;
|
|
9
|
+
constructor(options: Options);
|
|
10
|
+
get rowsCount(): number;
|
|
11
|
+
get hasVisibleLastSymbols(): boolean;
|
|
12
|
+
get hasMultipleRows(): boolean;
|
|
13
|
+
get firstPartLabel(): string;
|
|
14
|
+
get secondPartLabel(): string;
|
|
15
|
+
attach: (node: HTMLElement) => () => void;
|
|
16
|
+
check: () => void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
private get visibleLastSymbolsCount();
|
|
19
|
+
private get truncatedLabel();
|
|
20
|
+
private checkOverflow;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/components/OverflowTypography/store.svelte.ts
|
|
2
|
+
const DEFAULT_ROWS_COUNT = 1;
|
|
3
|
+
const RESIZE_DEBOUNCE_MS = 500;
|
|
4
|
+
const truncateString = (visibleLastSymbolsCount, label) => {
|
|
5
|
+
return {
|
|
6
|
+
firstPartLabel: label.slice(0, -visibleLastSymbolsCount),
|
|
7
|
+
secondPartLabel: label.slice(-visibleLastSymbolsCount)
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
var OverflowTypographyStore = class {
|
|
11
|
+
isOverflowed = $state(false);
|
|
12
|
+
#options;
|
|
13
|
+
#node;
|
|
14
|
+
#resizeObserver;
|
|
15
|
+
#resizeTimer;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.#options = options;
|
|
18
|
+
}
|
|
19
|
+
get rowsCount() {
|
|
20
|
+
return this.#options.rowsCount ?? DEFAULT_ROWS_COUNT;
|
|
21
|
+
}
|
|
22
|
+
get hasVisibleLastSymbols() {
|
|
23
|
+
return Boolean(this.#options.text && this.visibleLastSymbolsCount > 0);
|
|
24
|
+
}
|
|
25
|
+
get hasMultipleRows() {
|
|
26
|
+
return this.hasVisibleLastSymbols ? false : this.rowsCount > 1;
|
|
27
|
+
}
|
|
28
|
+
get firstPartLabel() {
|
|
29
|
+
return this.truncatedLabel.firstPartLabel;
|
|
30
|
+
}
|
|
31
|
+
get secondPartLabel() {
|
|
32
|
+
return this.truncatedLabel.secondPartLabel;
|
|
33
|
+
}
|
|
34
|
+
attach = (node) => {
|
|
35
|
+
this.#node = node;
|
|
36
|
+
this.checkOverflow([{
|
|
37
|
+
target: node,
|
|
38
|
+
contentRect: node.getBoundingClientRect()
|
|
39
|
+
}]);
|
|
40
|
+
this.#resizeObserver = new ResizeObserver((entries) => {
|
|
41
|
+
clearTimeout(this.#resizeTimer);
|
|
42
|
+
this.#resizeTimer = setTimeout(() => {
|
|
43
|
+
this.checkOverflow(entries);
|
|
44
|
+
}, RESIZE_DEBOUNCE_MS);
|
|
45
|
+
});
|
|
46
|
+
this.#resizeObserver.observe(node);
|
|
47
|
+
return () => {
|
|
48
|
+
this.#resizeObserver?.unobserve(node);
|
|
49
|
+
this.destroy();
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
check = () => {
|
|
53
|
+
if (!this.#node) return;
|
|
54
|
+
this.checkOverflow([{
|
|
55
|
+
target: this.#node,
|
|
56
|
+
contentRect: this.#node.getBoundingClientRect()
|
|
57
|
+
}]);
|
|
58
|
+
};
|
|
59
|
+
destroy() {
|
|
60
|
+
clearTimeout(this.#resizeTimer);
|
|
61
|
+
this.#resizeObserver?.disconnect();
|
|
62
|
+
this.#resizeObserver = void 0;
|
|
63
|
+
this.#node = void 0;
|
|
64
|
+
}
|
|
65
|
+
get visibleLastSymbolsCount() {
|
|
66
|
+
return this.#options.visibleLastSymbolsCount ?? 0;
|
|
67
|
+
}
|
|
68
|
+
get truncatedLabel() {
|
|
69
|
+
if (!this.hasVisibleLastSymbols || !this.#options.text) return {
|
|
70
|
+
firstPartLabel: "",
|
|
71
|
+
secondPartLabel: ""
|
|
72
|
+
};
|
|
73
|
+
return truncateString(this.visibleLastSymbolsCount, this.#options.text);
|
|
74
|
+
}
|
|
75
|
+
checkOverflow(entries) {
|
|
76
|
+
const [{ target, contentRect }] = entries;
|
|
77
|
+
const isScrollHeightBigger = target.scrollHeight > Math.round(contentRect.height);
|
|
78
|
+
const isScrollWidthBigger = target.scrollWidth > Math.round(contentRect.width);
|
|
79
|
+
const isOverflowed = this.hasMultipleRows ? isScrollWidthBigger || isScrollHeightBigger : isScrollWidthBigger;
|
|
80
|
+
if (this.isOverflowed !== isOverflowed) this.isOverflowed = isOverflowed;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { OverflowTypographyStore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/components/OverflowTypography/styles.css.ts
|
|
2
|
+
var multipleRows = "styles_multipleRows__dpgi0n1";
|
|
3
|
+
var truncate = "styles_truncate__dpgi0n0";
|
|
4
|
+
var wrapper = "styles_wrapper__dpgi0n2";
|
|
5
|
+
var wrapperAlignments = {
|
|
6
|
+
left: "styles_wrapperAlignments_left__dpgi0n3",
|
|
7
|
+
center: "styles_wrapperAlignments_center__dpgi0n4",
|
|
8
|
+
right: "styles_wrapperAlignments_right__dpgi0n5",
|
|
9
|
+
justify: "styles_wrapperAlignments_justify__dpgi0n6"
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { multipleRows, truncate, wrapper, wrapperAlignments };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { TooltipProps } from '../Tooltip';
|
|
3
|
+
import type { TypographyProps } from '../Typography';
|
|
4
|
+
export type OverflowTypographyTooltipProps = Omit<TooltipProps, 'children' | 'content'> & {
|
|
5
|
+
content?: TooltipProps['content'];
|
|
6
|
+
};
|
|
7
|
+
export type OverflowTypographyProps = Omit<TypographyProps, 'children' | 'ref'> & {
|
|
8
|
+
/** Максимальное количество отображаемых строк. */
|
|
9
|
+
rowsCount?: number;
|
|
10
|
+
/** Количество видимых символов в конце обрезанной строки. */
|
|
11
|
+
visibleLastSymbolsCount?: number;
|
|
12
|
+
/** Текст для обрезки и дефолтного содержимого tooltip. */
|
|
13
|
+
text?: string;
|
|
14
|
+
/** Пропсы для кастомизации tooltip. */
|
|
15
|
+
tooltipProps?: OverflowTypographyTooltipProps;
|
|
16
|
+
children?: Snippet<[]> | string;
|
|
17
|
+
ref?: HTMLElement | null;
|
|
18
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Portal from "../Portal/Portal.js";
|
|
2
2
|
import { TooltipStore } from "./store.svelte.js";
|
|
3
|
-
import
|
|
3
|
+
import { arrow, content } from "./styles.css.js";
|
|
4
4
|
import "svelte/internal/disclose-version";
|
|
5
5
|
import * as $ from "svelte/internal/client";
|
|
6
6
|
//#region src/components/Tooltip/Tooltip.svelte
|
|
@@ -9,7 +9,7 @@ var root_2 = $.from_html(`<div role="tooltip" data-slot="tooltip-content"><!> <!
|
|
|
9
9
|
var root = $.from_html(`<span style="display: contents;" data-slot="tooltip-trigger"><!></span> <!>`, 1);
|
|
10
10
|
function Tooltip($$anchor, $$props) {
|
|
11
11
|
$.push($$props, true);
|
|
12
|
-
let offset = $.prop($$props, "offset", 3, 10), placement = $.prop($$props, "placement", 3, "top"), arrow = $.prop($$props, "arrow", 3, false), delayDuration = $.prop($$props, "delayDuration", 3, 100);
|
|
12
|
+
let offset = $.prop($$props, "offset", 3, 10), placement = $.prop($$props, "placement", 3, "top"), arrow$1 = $.prop($$props, "arrow", 3, false), delayDuration = $.prop($$props, "delayDuration", 3, 100);
|
|
13
13
|
const store = new TooltipStore({
|
|
14
14
|
get placement() {
|
|
15
15
|
return placement();
|
|
@@ -17,6 +17,9 @@ function Tooltip($$anchor, $$props) {
|
|
|
17
17
|
get offset() {
|
|
18
18
|
return offset();
|
|
19
19
|
},
|
|
20
|
+
get open() {
|
|
21
|
+
return $$props.open;
|
|
22
|
+
},
|
|
20
23
|
get delayDuration() {
|
|
21
24
|
return delayDuration();
|
|
22
25
|
}
|
|
@@ -55,13 +58,13 @@ function Tooltip($$anchor, $$props) {
|
|
|
55
58
|
var consequent_1 = ($$anchor) => {
|
|
56
59
|
var svg = root_5();
|
|
57
60
|
$.template_effect(() => {
|
|
58
|
-
$.set_class(svg, 0, $.clsx([
|
|
61
|
+
$.set_class(svg, 0, $.clsx([arrow, $$props.arrowClass]));
|
|
59
62
|
$.set_attribute(svg, "data-side", store.placement);
|
|
60
63
|
});
|
|
61
64
|
$.append($$anchor, svg);
|
|
62
65
|
};
|
|
63
66
|
$.if(node_4, ($$render) => {
|
|
64
|
-
if (arrow()) $$render(consequent_1);
|
|
67
|
+
if (arrow$1()) $$render(consequent_1);
|
|
65
68
|
});
|
|
66
69
|
$.reset(div);
|
|
67
70
|
$.attach(div, () => store.attachContent);
|
|
@@ -69,7 +72,7 @@ function Tooltip($$anchor, $$props) {
|
|
|
69
72
|
$.set_attribute(div, "id", store.tooltipId);
|
|
70
73
|
$.set_attribute(div, "data-state", store.open ? "open" : "closed");
|
|
71
74
|
$.set_attribute(div, "data-side", store.placement);
|
|
72
|
-
$.set_class(div, 1, $.clsx([
|
|
75
|
+
$.set_class(div, 1, $.clsx([content, $$props.contentClass]));
|
|
73
76
|
styles_1 = $.set_style(div, "", styles_1, {
|
|
74
77
|
position: "fixed",
|
|
75
78
|
top: `${store.y ?? ""}px`,
|
|
@@ -88,7 +91,7 @@ function Tooltip($$anchor, $$props) {
|
|
|
88
91
|
});
|
|
89
92
|
};
|
|
90
93
|
$.if(node_1, ($$render) => {
|
|
91
|
-
if (store.visible) $$render(consequent_2);
|
|
94
|
+
if (store.visible && $$props.content != null && $$props.open !== false) $$render(consequent_2);
|
|
92
95
|
});
|
|
93
96
|
$.append($$anchor, fragment);
|
|
94
97
|
$.pop();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { TooltipProps } from './types';
|
|
2
|
-
type Options = Pick<TooltipProps, 'delayDuration' | 'placement' | 'offset'>;
|
|
2
|
+
type Options = Pick<TooltipProps, 'delayDuration' | 'placement' | 'offset' | 'open'>;
|
|
3
3
|
export declare class TooltipStore {
|
|
4
4
|
#private;
|
|
5
5
|
open: boolean;
|
|
6
6
|
visible: boolean;
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
|
+
placement: NonNullable<import("@floating-ui/dom").Placement | undefined>;
|
|
9
10
|
readonly tooltipId: string;
|
|
10
11
|
private static active;
|
|
11
12
|
private static readonly CLOSE_DURATION;
|
|
@@ -14,7 +15,6 @@ export declare class TooltipStore {
|
|
|
14
15
|
private delayTimer;
|
|
15
16
|
private closeTimer;
|
|
16
17
|
constructor(options: Options);
|
|
17
|
-
get placement(): import("@floating-ui/dom").Placement | undefined;
|
|
18
18
|
show: () => void;
|
|
19
19
|
hide: () => void;
|
|
20
20
|
keepOpen: () => void;
|
|
@@ -22,5 +22,8 @@ export declare class TooltipStore {
|
|
|
22
22
|
attachContent: (node: HTMLElement) => (() => void) | undefined;
|
|
23
23
|
destroy(): void;
|
|
24
24
|
private forceClose;
|
|
25
|
+
private get delayDuration();
|
|
26
|
+
private get offset();
|
|
27
|
+
private get preferredPlacement();
|
|
25
28
|
}
|
|
26
29
|
export {};
|
|
@@ -5,11 +5,8 @@ var TooltipStore = class TooltipStore {
|
|
|
5
5
|
visible = $state(false);
|
|
6
6
|
x = $state(0);
|
|
7
7
|
y = $state(0);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
placement: "top",
|
|
11
|
-
offset: 8
|
|
12
|
-
});
|
|
8
|
+
placement = $state("top");
|
|
9
|
+
#options;
|
|
13
10
|
tooltipId = `tooltip-${Math.random().toString(36).slice(2, 11)}`;
|
|
14
11
|
static active = null;
|
|
15
12
|
static CLOSE_DURATION = 150;
|
|
@@ -18,15 +15,11 @@ var TooltipStore = class TooltipStore {
|
|
|
18
15
|
delayTimer;
|
|
19
16
|
closeTimer;
|
|
20
17
|
constructor(options) {
|
|
21
|
-
this.#options =
|
|
22
|
-
|
|
23
|
-
...options
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
get placement() {
|
|
27
|
-
return this.#options.placement;
|
|
18
|
+
this.#options = options;
|
|
19
|
+
this.placement = this.preferredPlacement;
|
|
28
20
|
}
|
|
29
21
|
show = () => {
|
|
22
|
+
if (this.#options.open === false) return;
|
|
30
23
|
if (TooltipStore.active && TooltipStore.active !== this) TooltipStore.active.forceClose();
|
|
31
24
|
clearTimeout(this.closeTimer);
|
|
32
25
|
clearTimeout(this.delayTimer);
|
|
@@ -34,7 +27,7 @@ var TooltipStore = class TooltipStore {
|
|
|
34
27
|
this.delayTimer = setTimeout(() => {
|
|
35
28
|
this.visible = true;
|
|
36
29
|
this.open = true;
|
|
37
|
-
}, this
|
|
30
|
+
}, this.delayDuration);
|
|
38
31
|
};
|
|
39
32
|
hide = () => {
|
|
40
33
|
clearTimeout(this.delayTimer);
|
|
@@ -73,17 +66,17 @@ var TooltipStore = class TooltipStore {
|
|
|
73
66
|
this.cleanupAutoUpdate = autoUpdate(this.triggerEl, node, () => {
|
|
74
67
|
if (!this.triggerEl) return;
|
|
75
68
|
computePosition(this.triggerEl, node, {
|
|
76
|
-
placement: this
|
|
69
|
+
placement: this.preferredPlacement,
|
|
77
70
|
strategy: "fixed",
|
|
78
71
|
middleware: [
|
|
79
|
-
offset({ mainAxis: this
|
|
72
|
+
offset({ mainAxis: this.offset }),
|
|
80
73
|
flip(),
|
|
81
74
|
shift({ padding: 8 })
|
|
82
75
|
]
|
|
83
76
|
}).then(({ x, y, placement }) => {
|
|
84
77
|
this.x = x;
|
|
85
78
|
this.y = y;
|
|
86
|
-
this
|
|
79
|
+
this.placement = placement;
|
|
87
80
|
});
|
|
88
81
|
});
|
|
89
82
|
return () => {
|
|
@@ -103,6 +96,15 @@ var TooltipStore = class TooltipStore {
|
|
|
103
96
|
this.cleanupAutoUpdate?.();
|
|
104
97
|
this.cleanupAutoUpdate = void 0;
|
|
105
98
|
}
|
|
99
|
+
get delayDuration() {
|
|
100
|
+
return this.#options.delayDuration ?? 300;
|
|
101
|
+
}
|
|
102
|
+
get offset() {
|
|
103
|
+
return this.#options.offset ?? 8;
|
|
104
|
+
}
|
|
105
|
+
get preferredPlacement() {
|
|
106
|
+
return this.#options.placement ?? "top";
|
|
107
|
+
}
|
|
106
108
|
};
|
|
107
109
|
//#endregion
|
|
108
110
|
export { TooltipStore };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//#region src/components/Tooltip/styles.css.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
arrow: "styles_arrow__1ovcrev9"
|
|
5
|
-
};
|
|
2
|
+
var arrow = "styles_arrow__1ovcrev9";
|
|
3
|
+
var content = "styles_content__1ovcrev8";
|
|
6
4
|
//#endregion
|
|
7
|
-
export {
|
|
5
|
+
export { arrow, content };
|
|
@@ -4,7 +4,7 @@ import * as $ from "svelte/internal/client";
|
|
|
4
4
|
//#region src/components/Typography/Typography.svelte
|
|
5
5
|
function Typography($$anchor, $$props) {
|
|
6
6
|
$.push($$props, true);
|
|
7
|
-
let ref = $.prop($$props, "ref",
|
|
7
|
+
let ref = $.prop($$props, "ref", 15, null), align = $.prop($$props, "align", 3, "left"), color = $.prop($$props, "color", 3, "primary"), decoration = $.prop($$props, "decoration", 3, "none"), display = $.prop($$props, "display", 3, "inline"), variant = $.prop($$props, "variant", 3, "body1"), weight = $.prop($$props, "weight", 3, "normal"), restProps = $.rest_props($$props, [
|
|
8
8
|
"$$slots",
|
|
9
9
|
"$$events",
|
|
10
10
|
"$$legacy",
|
|
@@ -38,7 +38,6 @@ function Typography($$anchor, $$props) {
|
|
|
38
38
|
const TagComponent = $.derived(() => $$props.component || VARIANT_COMPONENT_MAP[variant()]);
|
|
39
39
|
const mergedProps = $.derived(() => ({
|
|
40
40
|
...restProps,
|
|
41
|
-
ref: ref(),
|
|
42
41
|
class: [
|
|
43
42
|
decorations[decoration()],
|
|
44
43
|
variants[variant()],
|
|
@@ -54,6 +53,7 @@ function Typography($$anchor, $$props) {
|
|
|
54
53
|
var fragment = $.comment();
|
|
55
54
|
var node = $.first_child(fragment);
|
|
56
55
|
$.element(node, () => $.get(TagComponent), false, ($$element, $$anchor) => {
|
|
56
|
+
$.bind_this($$element, ($$value) => ref($$value), () => ref());
|
|
57
57
|
$.attribute_effect($$element, () => ({ ...$.get(mergedProps) }));
|
|
58
58
|
var fragment_1 = $.comment();
|
|
59
59
|
var node_1 = $.first_child(fragment_1);
|
|
@@ -22,6 +22,7 @@ export { Input, type InputProps, type InputType, } from './Input';
|
|
|
22
22
|
export { InputGroup, type InputGroupAddonAlign, type InputGroupButtonSize, } from './InputGroup';
|
|
23
23
|
export { Item, type ItemProps, type ItemSize, type ItemVariant, } from './Item';
|
|
24
24
|
export { Label } from './Label';
|
|
25
|
+
export { OverflowTypography, type OverflowTypographyProps, type OverflowTypographyTooltipProps, } from './OverflowTypography';
|
|
25
26
|
export { Placeholder, type PlaceholderProps, type PlaceholderSize, } from './Placeholder';
|
|
26
27
|
export { Popover, type PopoverProps } from './Popover';
|
|
27
28
|
export { Portal } from './Portal';
|
package/dist/components/index.js
CHANGED
|
@@ -27,13 +27,14 @@ import { Field } from "./Field/index.js";
|
|
|
27
27
|
import Input from "./Input/Input.js";
|
|
28
28
|
import { InputGroup } from "./InputGroup/index.js";
|
|
29
29
|
import { Item } from "./Item/index.js";
|
|
30
|
-
import { Popover } from "./Popover/index.js";
|
|
31
30
|
import Portal from "./Portal/Portal.js";
|
|
31
|
+
import Tooltip from "./Tooltip/Tooltip.js";
|
|
32
|
+
import OverflowTypography from "./OverflowTypography/OverflowTypography.js";
|
|
33
|
+
import { Popover } from "./Popover/index.js";
|
|
32
34
|
import Slider from "./Slider/Slider.js";
|
|
33
35
|
import RangeInput from "./RangeInput/RangeInput.js";
|
|
34
36
|
import ScalableContainer from "./ScalableContainer/ScalableContainer.js";
|
|
35
37
|
import { Select } from "./Select/index.js";
|
|
36
38
|
import SliderInput from "./SliderInput/SliderInput.js";
|
|
37
39
|
import { Tabs } from "./Tabs/index.js";
|
|
38
|
-
|
|
39
|
-
export { Accordion, Alert, Badge, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, CircularProgress, ContentState, DataGrid, DataGridSortHeader, Description, Dialog, Drawer, DropdownMenu_exports as DropdownMenu, Empty, Field, Input, InputGroup, Item, Label_1 as Label, Placeholder, Popover, Portal, RangeInput, ScalableContainer, Select, Separator, Slider, SliderInput, Spinner, Tabs, Tooltip, Typography, badgeVariants, buttonVariants };
|
|
40
|
+
export { Accordion, Alert, Badge, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, CircularProgress, ContentState, DataGrid, DataGridSortHeader, Description, Dialog, Drawer, DropdownMenu_exports as DropdownMenu, Empty, Field, Input, InputGroup, Item, Label_1 as Label, OverflowTypography, Placeholder, Popover, Portal, RangeInput, ScalableContainer, Select, Separator, Slider, SliderInput, Spinner, Tabs, Tooltip, Typography, badgeVariants, buttonVariants };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OverflowTypography } from '../components';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const OverflowTypography: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type OverflowTypography = InstanceType<typeof OverflowTypography>;
|
|
19
|
+
export default OverflowTypography;
|