@finsweet/webflow-apps-utils 1.0.3 → 1.0.4
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/router/Router.mdx +958 -0
- package/dist/router/Router.stories.d.ts +6 -0
- package/dist/router/Router.stories.js +47 -0
- package/dist/router/examples/RouterExample.svelte +271 -0
- package/dist/router/examples/RouterExample.svelte.d.ts +18 -0
- package/dist/router/examples/index.d.ts +4 -0
- package/dist/router/examples/index.js +4 -0
- package/dist/router/examples/pages/AboutPage.svelte +568 -0
- package/dist/router/examples/pages/AboutPage.svelte.d.ts +13 -0
- package/dist/router/examples/pages/HomePage.svelte +200 -0
- package/dist/router/examples/pages/HomePage.svelte.d.ts +14 -0
- package/dist/router/examples/pages/NotFoundPage.svelte +307 -0
- package/dist/router/examples/pages/NotFoundPage.svelte.d.ts +17 -0
- package/dist/router/hooks.svelte.d.ts +2 -2
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.js +3 -0
- package/dist/router/{Link.svelte → providers/Link.svelte} +1 -1
- package/dist/router/{Route.svelte → providers/Route.svelte} +1 -1
- package/dist/router/{Route.svelte.d.ts → providers/Route.svelte.d.ts} +1 -1
- package/dist/router/{Router.svelte → providers/RouterProvider.svelte} +22 -5
- package/dist/router/{Router.svelte.d.ts → providers/RouterProvider.svelte.d.ts} +8 -4
- package/dist/router/providers/index.d.ts +3 -0
- package/dist/router/providers/index.js +3 -0
- package/dist/router/{index.svelte.d.ts → router.svelte.d.ts} +1 -3
- package/dist/router/{index.svelte.js → router.svelte.js} +1 -4
- package/dist/stores/docs/Form.mdx +542 -0
- package/dist/stores/forms.d.ts +41 -4
- package/dist/stores/forms.js +86 -32
- package/dist/types/customCode.d.ts +1 -1
- package/dist/types/window.d.ts +1 -0
- package/dist/ui/components/copy-text/CopyText.stories.d.ts +70 -0
- package/dist/ui/components/copy-text/CopyText.stories.js +241 -0
- package/dist/ui/components/copy-text/CopyText.svelte +249 -0
- package/dist/ui/components/copy-text/CopyText.svelte.d.ts +4 -0
- package/dist/ui/components/copy-text/index.d.ts +2 -0
- package/dist/ui/components/copy-text/index.js +1 -0
- package/dist/ui/components/copy-text/types.d.ts +52 -0
- package/dist/ui/components/copy-text/types.js +1 -0
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/components/input/Input.stories.d.ts +9 -0
- package/dist/ui/components/input/Input.stories.js +78 -0
- package/dist/ui/components/input/Input.svelte +39 -3
- package/dist/ui/components/input/types.d.ts +6 -0
- package/dist/ui/components/layout/Layout.svelte +7 -59
- package/dist/ui/components/layout/Layout.svelte.d.ts +2 -2
- package/dist/ui/components/layout/examples/ExampleLayout.svelte +22 -17
- package/dist/ui/components/layout/index.d.ts +1 -1
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte +20 -0
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte.d.ts +7 -0
- package/dist/ui/components/layout/types.d.ts +1 -10
- package/dist/ui/components/notification/Notification.stories.svelte +12 -1
- package/dist/ui/components/notification/Notification.svelte +10 -5
- package/dist/ui/components/notification/Notification.svelte.d.ts +1 -1
- package/dist/ui/components/notification/types.d.ts +1 -1
- package/dist/ui/components/section/Section.svelte +4 -2
- package/dist/ui/components/section/types.d.ts +8 -0
- package/dist/ui/components/text/Text.stories.svelte +67 -1
- package/dist/ui/components/text/Text.svelte +209 -8
- package/dist/ui/components/text/types.d.ts +4 -0
- package/dist/utils/animations/factory.d.ts +7 -0
- package/dist/utils/animations/factory.js +101 -0
- package/dist/utils/animations/index.d.ts +7 -0
- package/dist/utils/animations/index.js +62 -0
- package/dist/utils/animations/types.d.ts +39 -0
- package/dist/utils/animations/types.js +1 -0
- package/dist/utils/custom-code/configs.d.ts +22 -0
- package/dist/utils/custom-code/configs.js +40 -0
- package/dist/utils/custom-code/index.d.ts +1 -0
- package/dist/utils/custom-code/index.js +1 -0
- package/dist/utils/helpers/capitalizeFirstLetter.d.ts +4 -0
- package/dist/utils/helpers/capitalizeFirstLetter.js +9 -0
- package/dist/utils/helpers/getTimeNow.d.ts +4 -0
- package/dist/utils/helpers/getTimeNow.js +8 -0
- package/dist/utils/helpers/index.d.ts +4 -0
- package/dist/utils/helpers/index.js +4 -0
- package/dist/utils/helpers/minifyCode.d.ts +10 -0
- package/dist/utils/helpers/minifyCode.js +73 -0
- package/dist/utils/helpers/objectsToModuleExports.d.ts +1 -1
- package/dist/utils/helpers/objectsToModuleExports.js +1 -0
- package/dist/utils/helpers/toHumanReadableList.d.ts +4 -0
- package/dist/utils/helpers/toHumanReadableList.js +11 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/webflow-canvas/getAllChildren.d.ts +16 -0
- package/dist/utils/webflow-canvas/getAllChildren.js +65 -0
- package/dist/utils/webflow-canvas/getElementClassList.d.ts +9 -0
- package/dist/utils/webflow-canvas/getElementClassList.js +19 -0
- package/dist/utils/webflow-canvas/index.d.ts +2 -0
- package/dist/utils/webflow-canvas/index.js +2 -0
- package/package.json +6 -1
- package/dist/router/README.md +0 -397
- /package/dist/router/{Link.svelte.d.ts → providers/Link.svelte.d.ts} +0 -0
|
@@ -41,22 +41,14 @@
|
|
|
41
41
|
{ path: 'code', name: 'Code', icon: CodeIcon, isActive: false }
|
|
42
42
|
];
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: 'main' as const,
|
|
55
|
-
text: 'Apply Settings',
|
|
56
|
-
variant: 'primary' as const,
|
|
57
|
-
onClick: () => console.log('Apply clicked')
|
|
58
|
-
}
|
|
59
|
-
];
|
|
44
|
+
// Footer button handlers
|
|
45
|
+
function handleSaveClick() {
|
|
46
|
+
console.log('Save clicked');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleApplyClick() {
|
|
50
|
+
console.log('Apply clicked');
|
|
51
|
+
}
|
|
60
52
|
|
|
61
53
|
// Create tabs with active state
|
|
62
54
|
let tabs = $derived(
|
|
@@ -234,7 +226,6 @@
|
|
|
234
226
|
{activeTab}
|
|
235
227
|
{tabs}
|
|
236
228
|
{switchTab}
|
|
237
|
-
footer={{ buttons: dummyFooterButtons }}
|
|
238
229
|
formKey="dummy-layout"
|
|
239
230
|
{editMode}
|
|
240
231
|
{showFooter}
|
|
@@ -332,6 +323,20 @@
|
|
|
332
323
|
{#snippet previewBar()}
|
|
333
324
|
<Text fontSize="md" fontWeight="normal">Preview bar content</Text>
|
|
334
325
|
{/snippet}
|
|
326
|
+
|
|
327
|
+
{#snippet footer()}
|
|
328
|
+
<Button
|
|
329
|
+
variant="secondary"
|
|
330
|
+
icon={CheckCircleIcon}
|
|
331
|
+
onclick={handleSaveClick}
|
|
332
|
+
disabled={editMode}
|
|
333
|
+
>
|
|
334
|
+
Save Changes
|
|
335
|
+
</Button>
|
|
336
|
+
<Button variant="primary" onclick={handleApplyClick} disabled={editMode}>
|
|
337
|
+
Apply Settings
|
|
338
|
+
</Button>
|
|
339
|
+
{/snippet}
|
|
335
340
|
</Layout>
|
|
336
341
|
</div>
|
|
337
342
|
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CodeIcon, SettingsIcon } from '../../../icons';
|
|
3
|
+
import { Button } from '../../button';
|
|
4
|
+
import Layout from '../Layout.svelte';
|
|
5
|
+
import type { LayoutProps } from '../types';
|
|
6
|
+
|
|
7
|
+
interface TestLayoutWithFooterProps extends Omit<LayoutProps, 'footer'> {
|
|
8
|
+
footerText?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { footerText = 'Test Button', ...layoutProps }: TestLayoutWithFooterProps = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Layout {...layoutProps}>
|
|
15
|
+
{#snippet footer()}
|
|
16
|
+
<Button variant="primary" onclick={() => {}}>
|
|
17
|
+
{footerText}
|
|
18
|
+
</Button>
|
|
19
|
+
{/snippet}
|
|
20
|
+
</Layout>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LayoutProps } from '../types';
|
|
2
|
+
interface TestLayoutWithFooterProps extends Omit<LayoutProps, 'footer'> {
|
|
3
|
+
footerText?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const TestLayoutWithFooter: import("svelte").Component<TestLayoutWithFooterProps, {}, "">;
|
|
6
|
+
type TestLayoutWithFooter = ReturnType<typeof TestLayoutWithFooter>;
|
|
7
|
+
export default TestLayoutWithFooter;
|
|
@@ -7,15 +7,6 @@ export interface LayoutTab {
|
|
|
7
7
|
isActive: boolean;
|
|
8
8
|
hidden?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export interface LayoutFooter {
|
|
11
|
-
buttons: Array<{
|
|
12
|
-
id: string;
|
|
13
|
-
text: string;
|
|
14
|
-
variant: 'primary' | 'secondary';
|
|
15
|
-
icon?: Component;
|
|
16
|
-
onClick?: () => void;
|
|
17
|
-
}>;
|
|
18
|
-
}
|
|
19
10
|
export interface LayoutNotification {
|
|
20
11
|
path: string;
|
|
21
12
|
success: boolean;
|
|
@@ -29,7 +20,7 @@ export interface LayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
29
20
|
main?: Snippet;
|
|
30
21
|
sidebar?: Snippet;
|
|
31
22
|
previewBar?: Snippet;
|
|
32
|
-
footer?:
|
|
23
|
+
footer?: Snippet;
|
|
33
24
|
formKey: string;
|
|
34
25
|
editMode?: boolean;
|
|
35
26
|
showFooter?: boolean;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
ArrowIcon,
|
|
7
7
|
CheckCircleIcon,
|
|
8
8
|
CloseCircleIcon,
|
|
9
|
+
InfoIcon,
|
|
9
10
|
WarningCircleOutlineIcon,
|
|
10
11
|
WarningTriangleIcon
|
|
11
12
|
} from '../../icons';
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
argTypes: {
|
|
22
23
|
variant: {
|
|
23
24
|
control: { type: 'select' },
|
|
24
|
-
options: ['warning', 'error', 'success'],
|
|
25
|
+
options: ['warning', 'error', 'success', 'info'],
|
|
25
26
|
description: 'The type of notification or custom color string'
|
|
26
27
|
},
|
|
27
28
|
message: {
|
|
@@ -98,6 +99,16 @@
|
|
|
98
99
|
}}
|
|
99
100
|
/>
|
|
100
101
|
|
|
102
|
+
<Story
|
|
103
|
+
name="Info"
|
|
104
|
+
args={{
|
|
105
|
+
variant: 'info',
|
|
106
|
+
title: 'Information Notification',
|
|
107
|
+
message: 'Here is some important information you should know.',
|
|
108
|
+
icon: InfoIcon
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
|
|
101
112
|
<!-- Content Variations -->
|
|
102
113
|
<Story
|
|
103
114
|
name="Message Only"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { TimesIcon, WarningCircleOutlineIcon } from '../../icons';
|
|
5
5
|
import { Text } from '../';
|
|
6
6
|
|
|
7
|
-
type NotificationType = 'warning' | 'error' | 'success';
|
|
7
|
+
type NotificationType = 'warning' | 'error' | 'success' | 'info';
|
|
8
8
|
|
|
9
9
|
interface NotificationProps {
|
|
10
10
|
/**
|
|
@@ -93,18 +93,23 @@
|
|
|
93
93
|
switch (variant) {
|
|
94
94
|
case 'warning':
|
|
95
95
|
return {
|
|
96
|
-
icon: '
|
|
96
|
+
icon: 'var(--yellowIcon)',
|
|
97
97
|
border: 'var(--yellowBorder)'
|
|
98
98
|
};
|
|
99
99
|
case 'error':
|
|
100
100
|
return {
|
|
101
|
-
icon: '
|
|
101
|
+
icon: 'var(--redIcon)',
|
|
102
102
|
border: 'var(--redBorder)'
|
|
103
103
|
};
|
|
104
104
|
case 'success':
|
|
105
105
|
return {
|
|
106
|
-
icon: '
|
|
107
|
-
border: 'var(--
|
|
106
|
+
icon: 'var(--greenIcon)',
|
|
107
|
+
border: 'var(--greenBorder)'
|
|
108
|
+
};
|
|
109
|
+
case 'info':
|
|
110
|
+
return {
|
|
111
|
+
icon: 'var(--blueIcon)',
|
|
112
|
+
border: 'var(--blueBorder)'
|
|
108
113
|
};
|
|
109
114
|
default:
|
|
110
115
|
// Custom color string
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Component, Snippet } from 'svelte';
|
|
2
|
-
export type NotificationType = 'warning' | 'error' | 'success';
|
|
2
|
+
export type NotificationType = 'warning' | 'error' | 'success' | 'info';
|
|
3
3
|
export interface NotificationProps {
|
|
4
4
|
/**
|
|
5
5
|
* Additional CSS classes to apply
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
width,
|
|
21
21
|
height,
|
|
22
22
|
backgroundColor,
|
|
23
|
+
padding = 'var(--Spacing-12, 12px)',
|
|
24
|
+
gap = 'var(--Spacing-8, 8px)',
|
|
23
25
|
class: className = '',
|
|
24
26
|
tooltip,
|
|
25
27
|
disabledMessage,
|
|
@@ -107,6 +109,8 @@
|
|
|
107
109
|
if (width) styles.width = width;
|
|
108
110
|
if (height) styles.height = height;
|
|
109
111
|
if (backgroundColor) styles['background-color'] = backgroundColor;
|
|
112
|
+
if (padding) styles.padding = padding;
|
|
113
|
+
if (gap) styles.gap = gap;
|
|
110
114
|
|
|
111
115
|
return styles;
|
|
112
116
|
});
|
|
@@ -201,10 +205,8 @@
|
|
|
201
205
|
<style>
|
|
202
206
|
.section-wrap {
|
|
203
207
|
display: flex;
|
|
204
|
-
padding: var(--Spacing-12, 12px);
|
|
205
208
|
flex-direction: column;
|
|
206
209
|
align-items: flex-start;
|
|
207
|
-
gap: var(--Spacing-8, 8px);
|
|
208
210
|
align-self: stretch;
|
|
209
211
|
position: relative;
|
|
210
212
|
border: 1px solid transparent;
|
|
@@ -39,6 +39,14 @@ export interface SectionProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
39
39
|
* Background color of the section (CSS color value)
|
|
40
40
|
*/
|
|
41
41
|
backgroundColor?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Padding of the section (CSS value) - defaults to var(--Spacing-12, 12px)
|
|
44
|
+
*/
|
|
45
|
+
padding?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Gap between child elements (CSS value) - defaults to var(--Spacing-8, 8px)
|
|
48
|
+
*/
|
|
49
|
+
gap?: string;
|
|
42
50
|
/**
|
|
43
51
|
* Additional CSS classes to apply
|
|
44
52
|
*/
|
|
@@ -63,6 +63,11 @@
|
|
|
63
63
|
control: { type: 'object' },
|
|
64
64
|
description: 'Tooltip configuration'
|
|
65
65
|
},
|
|
66
|
+
tooltipTarget: {
|
|
67
|
+
control: { type: 'select' },
|
|
68
|
+
options: ['text', 'icon'],
|
|
69
|
+
description: 'Specifies whether to show tooltip on text or icon'
|
|
70
|
+
},
|
|
66
71
|
popup: {
|
|
67
72
|
control: { type: 'object' },
|
|
68
73
|
description: 'Popup action configuration'
|
|
@@ -144,7 +149,7 @@
|
|
|
144
149
|
</div>
|
|
145
150
|
</Story>
|
|
146
151
|
|
|
147
|
-
<!-- Tooltip
|
|
152
|
+
<!-- Tooltip Examples -->
|
|
148
153
|
<Story
|
|
149
154
|
name="With Tooltip"
|
|
150
155
|
args={{
|
|
@@ -156,6 +161,67 @@
|
|
|
156
161
|
}}
|
|
157
162
|
/>
|
|
158
163
|
|
|
164
|
+
<Story
|
|
165
|
+
name="Tooltip on Icon"
|
|
166
|
+
args={{
|
|
167
|
+
label: 'Text with tooltip on icon',
|
|
168
|
+
icon: ToolTipInfoCircleIcon,
|
|
169
|
+
tooltip: {
|
|
170
|
+
message: 'This tooltip appears on the icon',
|
|
171
|
+
placement: 'top'
|
|
172
|
+
},
|
|
173
|
+
tooltipTarget: 'icon'
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<Story name="Tooltip Target Examples">
|
|
178
|
+
<div style="display: flex; flex-direction: column; gap: 16px; padding: 16px;">
|
|
179
|
+
<div style="border: 1px dashed #ccc; padding: 12px;">
|
|
180
|
+
<h4 style="margin: 0 0 8px 0; font-size: 12px; color: #666;">Tooltip on Text (default):</h4>
|
|
181
|
+
<Text
|
|
182
|
+
label="Hover over this text"
|
|
183
|
+
icon={AccountIcon}
|
|
184
|
+
tooltip={{ message: 'Tooltip on the text', placement: 'top' }}
|
|
185
|
+
tooltipTarget="text"
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div style="border: 1px dashed #ccc; padding: 12px;">
|
|
190
|
+
<h4 style="margin: 0 0 8px 0; font-size: 12px; color: #666;">Tooltip on Icon:</h4>
|
|
191
|
+
<Text
|
|
192
|
+
label="Hover over the icon"
|
|
193
|
+
icon={ToolTipInfoCircleIcon}
|
|
194
|
+
tooltip={{ message: 'Tooltip on the icon', placement: 'top' }}
|
|
195
|
+
tooltipTarget="icon"
|
|
196
|
+
/>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<div style="border: 1px dashed #ccc; padding: 12px;">
|
|
200
|
+
<h4 style="margin: 0 0 8px 0; font-size: 12px; color: #666;">
|
|
201
|
+
With Ellipsis + Icon Tooltip:
|
|
202
|
+
</h4>
|
|
203
|
+
<Text
|
|
204
|
+
label="Long text that will be truncated with ellipsis"
|
|
205
|
+
icon={ToolTipInfoCircleIcon}
|
|
206
|
+
tooltip={{ message: 'Icon tooltip with ellipsis', placement: 'top' }}
|
|
207
|
+
tooltipTarget="icon"
|
|
208
|
+
ellipsisOnWidth="200px"
|
|
209
|
+
/>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<div style="border: 1px dashed #ccc; padding: 12px;">
|
|
213
|
+
<h4 style="margin: 0 0 8px 0; font-size: 12px; color: #666;">
|
|
214
|
+
Invalid Configuration (no icon for icon target):
|
|
215
|
+
</h4>
|
|
216
|
+
<Text
|
|
217
|
+
label="No icon but tooltipTarget is icon"
|
|
218
|
+
tooltip={{ message: 'This tooltip should not show', placement: 'top' }}
|
|
219
|
+
tooltipTarget="icon"
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
</Story>
|
|
224
|
+
|
|
159
225
|
<!-- Popup Example -->
|
|
160
226
|
<Story
|
|
161
227
|
name="With Popup Action"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
// Tooltip configuration - pass any tooltip props
|
|
34
34
|
tooltip,
|
|
35
|
+
tooltipTarget = 'icon',
|
|
35
36
|
|
|
36
37
|
// Popup configuration - for action popups (reset, delete, etc.)
|
|
37
38
|
popup,
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
disabled: popup?.disabled ?? false,
|
|
88
89
|
title: popup?.title ?? 'Remove',
|
|
89
90
|
subtitle: popup?.subtitle ?? 'Alt + click',
|
|
91
|
+
onclick: popup?.onclick ?? null,
|
|
90
92
|
description: popup?.description ?? 'This action will remove the current selection.',
|
|
91
93
|
icon: popup?.icon ?? DeleteIcon,
|
|
92
94
|
active: popup?.active ?? false
|
|
@@ -114,6 +116,8 @@
|
|
|
114
116
|
wrapperElement.dispatchEvent(new CustomEvent('popupAction', actionEvent));
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
popup?.onclick?.();
|
|
120
|
+
|
|
117
121
|
isPopupHidden = true;
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -280,11 +284,26 @@
|
|
|
280
284
|
!disabled &&
|
|
281
285
|
(isPopupHidden || !hasPopup)
|
|
282
286
|
);
|
|
287
|
+
|
|
288
|
+
// Validate tooltipTarget - if 'icon' is specified, icon must be present and not loading
|
|
289
|
+
let isValidTooltipTarget = $derived(
|
|
290
|
+
tooltipTarget === 'text' || (tooltipTarget === 'icon' && !!icon && !loading)
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// Determine if tooltip should show on text (default behavior or when explicitly set to 'text')
|
|
294
|
+
let shouldShowTooltipOnText = $derived(
|
|
295
|
+
shouldShowTooltip && isValidTooltipTarget && tooltipTarget === 'text'
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// Determine if tooltip should show on icon (when explicitly set to 'icon' and icon is present)
|
|
299
|
+
let shouldShowTooltipOnIcon = $derived(
|
|
300
|
+
shouldShowTooltip && isValidTooltipTarget && tooltipTarget === 'icon' && !!icon && !loading
|
|
301
|
+
);
|
|
283
302
|
</script>
|
|
284
303
|
|
|
285
304
|
{#if label || tooltip || icon || children}
|
|
286
|
-
{#if !hasPopup &&
|
|
287
|
-
<!-- Simple text with tooltip -->
|
|
305
|
+
{#if !hasPopup && shouldShowTooltipOnText}
|
|
306
|
+
<!-- Simple text with tooltip on text -->
|
|
288
307
|
<Tooltip {...tooltip}>
|
|
289
308
|
{#snippet target()}
|
|
290
309
|
<div
|
|
@@ -314,8 +333,14 @@
|
|
|
314
333
|
<div class="loading" style="flex-shrink: 0;">
|
|
315
334
|
<Loader size={16} />
|
|
316
335
|
</div>
|
|
317
|
-
{:else if icon}
|
|
336
|
+
{:else if icon && !shouldShowTooltipOnIcon}
|
|
318
337
|
<IconComponent style="flex-shrink: 0;" />
|
|
338
|
+
{:else if icon && shouldShowTooltipOnIcon}
|
|
339
|
+
<Tooltip {...tooltip}>
|
|
340
|
+
{#snippet target()}
|
|
341
|
+
<IconComponent style="flex-shrink: 0;" />
|
|
342
|
+
{/snippet}
|
|
343
|
+
</Tooltip>
|
|
319
344
|
{/if}
|
|
320
345
|
{/if}
|
|
321
346
|
<div class={textClasses()} style={textStyles()}>
|
|
@@ -336,8 +361,14 @@
|
|
|
336
361
|
<div class="loading">
|
|
337
362
|
<Loader size={16} />
|
|
338
363
|
</div>
|
|
339
|
-
{:else if icon}
|
|
364
|
+
{:else if icon && !shouldShowTooltipOnIcon}
|
|
340
365
|
<IconComponent />
|
|
366
|
+
{:else if icon && shouldShowTooltipOnIcon}
|
|
367
|
+
<Tooltip {...tooltip}>
|
|
368
|
+
{#snippet target()}
|
|
369
|
+
<IconComponent />
|
|
370
|
+
{/snippet}
|
|
371
|
+
</Tooltip>
|
|
341
372
|
{/if}
|
|
342
373
|
{/if}
|
|
343
374
|
|
|
@@ -358,6 +389,85 @@
|
|
|
358
389
|
</div>
|
|
359
390
|
{/snippet}
|
|
360
391
|
</Tooltip>
|
|
392
|
+
{:else if !hasPopup && shouldShowTooltipOnIcon}
|
|
393
|
+
<!-- Simple text with tooltip on icon -->
|
|
394
|
+
<div
|
|
395
|
+
class={labelClasses()}
|
|
396
|
+
data-component="Text"
|
|
397
|
+
{...isInteractive ? { tabindex: 0 } : {}}
|
|
398
|
+
role={isInteractive ? 'button' : undefined}
|
|
399
|
+
onclick={handleClick}
|
|
400
|
+
{title}
|
|
401
|
+
style={labelStyles()}
|
|
402
|
+
{...restProps}
|
|
403
|
+
>
|
|
404
|
+
{#if label?.trim() || icon || children}
|
|
405
|
+
{#if ellipsisOnWidth && (icon || loading)}
|
|
406
|
+
<!-- handling ellipsis with icons -->
|
|
407
|
+
<div
|
|
408
|
+
class="text-with-icon"
|
|
409
|
+
style="display: flex; align-items: center; gap: 4px; width: {ellipsisOnWidth}; justify-content: {textAlign ===
|
|
410
|
+
'center'
|
|
411
|
+
? 'center'
|
|
412
|
+
: textAlign === 'right'
|
|
413
|
+
? 'flex-end'
|
|
414
|
+
: 'flex-start'};"
|
|
415
|
+
>
|
|
416
|
+
{#if icon || loading}
|
|
417
|
+
{#if loading}
|
|
418
|
+
<div class="loading" style="flex-shrink: 0;">
|
|
419
|
+
<Loader size={16} />
|
|
420
|
+
</div>
|
|
421
|
+
{:else if icon}
|
|
422
|
+
<Tooltip {...tooltip}>
|
|
423
|
+
{#snippet target()}
|
|
424
|
+
<IconComponent style="flex-shrink: 0;" />
|
|
425
|
+
{/snippet}
|
|
426
|
+
</Tooltip>
|
|
427
|
+
{/if}
|
|
428
|
+
{/if}
|
|
429
|
+
<div class={textClasses()} style={textStyles()}>
|
|
430
|
+
{#if children}
|
|
431
|
+
{@render children()}
|
|
432
|
+
{:else if raw}
|
|
433
|
+
{@html label}
|
|
434
|
+
{:else}
|
|
435
|
+
{label}
|
|
436
|
+
{/if}
|
|
437
|
+
</div>
|
|
438
|
+
</div>
|
|
439
|
+
{:else}
|
|
440
|
+
<!-- Normal text handling -->
|
|
441
|
+
<div class={textClasses()} style={textStyles()}>
|
|
442
|
+
{#if icon || loading}
|
|
443
|
+
{#if loading}
|
|
444
|
+
<div class="loading">
|
|
445
|
+
<Loader size={16} />
|
|
446
|
+
</div>
|
|
447
|
+
{:else if icon}
|
|
448
|
+
<Tooltip {...tooltip}>
|
|
449
|
+
{#snippet target()}
|
|
450
|
+
<IconComponent />
|
|
451
|
+
{/snippet}
|
|
452
|
+
</Tooltip>
|
|
453
|
+
{/if}
|
|
454
|
+
{/if}
|
|
455
|
+
|
|
456
|
+
{#if children}
|
|
457
|
+
{@render children()}
|
|
458
|
+
{:else if raw}
|
|
459
|
+
{@html label}
|
|
460
|
+
{:else}
|
|
461
|
+
{label}
|
|
462
|
+
{/if}
|
|
463
|
+
</div>
|
|
464
|
+
{/if}
|
|
465
|
+
{/if}
|
|
466
|
+
|
|
467
|
+
{#if pill}
|
|
468
|
+
{@render pill()}
|
|
469
|
+
{/if}
|
|
470
|
+
</div>
|
|
361
471
|
{:else if !hasPopup}
|
|
362
472
|
<!-- Simple text without tooltip -->
|
|
363
473
|
<div
|
|
@@ -451,8 +561,8 @@
|
|
|
451
561
|
>
|
|
452
562
|
{#snippet target()}
|
|
453
563
|
<span class="dropdown-label item {popupConfig.active ? 'active' : ''}">
|
|
454
|
-
{#if
|
|
455
|
-
<!-- Text with popup and tooltip -->
|
|
564
|
+
{#if shouldShowTooltipOnText}
|
|
565
|
+
<!-- Text with popup and tooltip on text -->
|
|
456
566
|
<Tooltip {...tooltip}>
|
|
457
567
|
{#snippet target()}
|
|
458
568
|
<div
|
|
@@ -482,8 +592,14 @@
|
|
|
482
592
|
<div class="loading" style="flex-shrink: 0;">
|
|
483
593
|
<Loader size={16} />
|
|
484
594
|
</div>
|
|
485
|
-
{:else if icon}
|
|
595
|
+
{:else if icon && !shouldShowTooltipOnIcon}
|
|
486
596
|
<IconComponent style="flex-shrink: 0;" />
|
|
597
|
+
{:else if icon && shouldShowTooltipOnIcon}
|
|
598
|
+
<Tooltip {...tooltip}>
|
|
599
|
+
{#snippet target()}
|
|
600
|
+
<IconComponent style="flex-shrink: 0;" />
|
|
601
|
+
{/snippet}
|
|
602
|
+
</Tooltip>
|
|
487
603
|
{/if}
|
|
488
604
|
{/if}
|
|
489
605
|
<div class={textClasses()} style={textStyles()}>
|
|
@@ -504,8 +620,14 @@
|
|
|
504
620
|
<div class="loading">
|
|
505
621
|
<Loader size={16} />
|
|
506
622
|
</div>
|
|
507
|
-
{:else if icon}
|
|
623
|
+
{:else if icon && !shouldShowTooltipOnIcon}
|
|
508
624
|
<IconComponent />
|
|
625
|
+
{:else if icon && shouldShowTooltipOnIcon}
|
|
626
|
+
<Tooltip {...tooltip}>
|
|
627
|
+
{#snippet target()}
|
|
628
|
+
<IconComponent />
|
|
629
|
+
{/snippet}
|
|
630
|
+
</Tooltip>
|
|
509
631
|
{/if}
|
|
510
632
|
{/if}
|
|
511
633
|
|
|
@@ -526,6 +648,85 @@
|
|
|
526
648
|
</div>
|
|
527
649
|
{/snippet}
|
|
528
650
|
</Tooltip>
|
|
651
|
+
{:else if shouldShowTooltipOnIcon}
|
|
652
|
+
<!-- Text with popup and tooltip on icon -->
|
|
653
|
+
<div
|
|
654
|
+
class={labelClasses()}
|
|
655
|
+
data-component="Text"
|
|
656
|
+
{...isInteractive ? { tabindex: 0 } : {}}
|
|
657
|
+
role={isInteractive ? 'button' : undefined}
|
|
658
|
+
onclick={handleClick}
|
|
659
|
+
{title}
|
|
660
|
+
style={labelStyles()}
|
|
661
|
+
{...restProps}
|
|
662
|
+
>
|
|
663
|
+
{#if label?.trim() || icon || children}
|
|
664
|
+
{#if ellipsisOnWidth && (icon || loading)}
|
|
665
|
+
<!-- handling ellipsis with icons -->
|
|
666
|
+
<div
|
|
667
|
+
class="text-with-icon"
|
|
668
|
+
style="display: flex; align-items: center; gap: 4px; width: {ellipsisOnWidth}; justify-content: {textAlign ===
|
|
669
|
+
'center'
|
|
670
|
+
? 'center'
|
|
671
|
+
: textAlign === 'right'
|
|
672
|
+
? 'flex-end'
|
|
673
|
+
: 'flex-start'};"
|
|
674
|
+
>
|
|
675
|
+
{#if icon || loading}
|
|
676
|
+
{#if loading}
|
|
677
|
+
<div class="loading" style="flex-shrink: 0;">
|
|
678
|
+
<Loader size={16} />
|
|
679
|
+
</div>
|
|
680
|
+
{:else if icon}
|
|
681
|
+
<Tooltip {...tooltip}>
|
|
682
|
+
{#snippet target()}
|
|
683
|
+
<IconComponent style="flex-shrink: 0;" />
|
|
684
|
+
{/snippet}
|
|
685
|
+
</Tooltip>
|
|
686
|
+
{/if}
|
|
687
|
+
{/if}
|
|
688
|
+
<div class={textClasses()} style={textStyles()}>
|
|
689
|
+
{#if children}
|
|
690
|
+
{@render children()}
|
|
691
|
+
{:else if raw}
|
|
692
|
+
{@html label}
|
|
693
|
+
{:else}
|
|
694
|
+
{label}
|
|
695
|
+
{/if}
|
|
696
|
+
</div>
|
|
697
|
+
</div>
|
|
698
|
+
{:else}
|
|
699
|
+
<!-- Normal text handling -->
|
|
700
|
+
<div class={textClasses()} style={textStyles()}>
|
|
701
|
+
{#if icon || loading}
|
|
702
|
+
{#if loading}
|
|
703
|
+
<div class="loading">
|
|
704
|
+
<Loader size={16} />
|
|
705
|
+
</div>
|
|
706
|
+
{:else if icon}
|
|
707
|
+
<Tooltip {...tooltip}>
|
|
708
|
+
{#snippet target()}
|
|
709
|
+
<IconComponent />
|
|
710
|
+
{/snippet}
|
|
711
|
+
</Tooltip>
|
|
712
|
+
{/if}
|
|
713
|
+
{/if}
|
|
714
|
+
|
|
715
|
+
{#if children}
|
|
716
|
+
{@render children()}
|
|
717
|
+
{:else if raw}
|
|
718
|
+
{@html label}
|
|
719
|
+
{:else}
|
|
720
|
+
{label}
|
|
721
|
+
{/if}
|
|
722
|
+
</div>
|
|
723
|
+
{/if}
|
|
724
|
+
{/if}
|
|
725
|
+
|
|
726
|
+
{#if pill}
|
|
727
|
+
{@render pill()}
|
|
728
|
+
{/if}
|
|
729
|
+
</div>
|
|
529
730
|
{:else}
|
|
530
731
|
<!-- Text with popup without tooltip -->
|
|
531
732
|
<div
|
|
@@ -21,6 +21,8 @@ export interface PopupConfig {
|
|
|
21
21
|
icon?: Component | null;
|
|
22
22
|
/** Whether the popup trigger is currently active */
|
|
23
23
|
active?: boolean;
|
|
24
|
+
/** Event handler for popup action */
|
|
25
|
+
onclick?: () => void;
|
|
24
26
|
}
|
|
25
27
|
export interface TextProps {
|
|
26
28
|
label?: string;
|
|
@@ -37,6 +39,8 @@ export interface TextProps {
|
|
|
37
39
|
height?: string;
|
|
38
40
|
ellipsisOnWidth?: string;
|
|
39
41
|
tooltip?: Partial<TooltipProps>;
|
|
42
|
+
/** Specifies whether to show tooltip on the text or icon. Requires icon prop when set to 'icon' */
|
|
43
|
+
tooltipTarget?: 'text' | 'icon';
|
|
40
44
|
popup?: PopupConfig;
|
|
41
45
|
icon?: Component | null;
|
|
42
46
|
loading?: boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnimationFunctions, AnimationProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Animation.
|
|
4
|
+
* @param props The animaiton props.
|
|
5
|
+
* @returns A new `in` and `out` Animation functions.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createAnimation: ({ initialStyles, keyframes }: AnimationProps) => AnimationFunctions;
|