@streamscloud/kit 0.2.4 → 0.2.5
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/ui/badge/cmp.badge.svelte +85 -0
- package/dist/ui/badge/cmp.badge.svelte.d.ts +26 -0
- package/dist/ui/badge/index.d.ts +2 -0
- package/dist/ui/badge/index.js +1 -0
- package/dist/ui/badge/types.d.ts +1 -0
- package/dist/ui/badge/types.js +1 -0
- package/dist/ui/button/cmp.button.svelte.d.ts +1 -0
- package/dist/ui/button/cmp.options-button.svelte.d.ts +1 -0
- package/dist/ui/checkbox/cmp.checkbox.svelte +102 -0
- package/dist/ui/checkbox/cmp.checkbox.svelte.d.ts +34 -0
- package/dist/ui/checkbox/cmp.three-state-checkbox.svelte +112 -0
- package/dist/ui/checkbox/cmp.three-state-checkbox.svelte.d.ts +37 -0
- package/dist/ui/checkbox/index.d.ts +3 -0
- package/dist/ui/checkbox/index.js +2 -0
- package/dist/ui/checkbox/types.d.ts +1 -0
- package/dist/ui/checkbox/types.js +1 -0
- package/dist/ui/confirmation-dialog/cmp.confirmation-dialog.svelte +58 -0
- package/dist/ui/confirmation-dialog/cmp.confirmation-dialog.svelte.d.ts +9 -0
- package/dist/ui/confirmation-dialog/confirmation-dialog-localization.d.ts +4 -0
- package/dist/ui/confirmation-dialog/confirmation-dialog-localization.js +19 -0
- package/dist/ui/confirmation-dialog/index.d.ts +19 -0
- package/dist/ui/confirmation-dialog/index.js +22 -0
- package/dist/ui/confirmation-dialog/types.d.ts +7 -0
- package/dist/ui/confirmation-dialog/types.js +1 -0
- package/dist/ui/datetime-picker/cmp.datetime-picker.svelte +286 -0
- package/dist/ui/datetime-picker/cmp.datetime-picker.svelte.d.ts +37 -0
- package/dist/ui/datetime-picker/datetime-picker-localization.d.ts +5 -0
- package/dist/ui/datetime-picker/datetime-picker-localization.js +26 -0
- package/dist/ui/datetime-picker/flatpickr-theme.d.ts +1 -0
- package/dist/ui/datetime-picker/flatpickr-theme.js +13 -0
- package/dist/ui/datetime-picker/index.d.ts +2 -0
- package/dist/ui/datetime-picker/index.js +1 -0
- package/dist/ui/datetime-picker/types.d.ts +16 -0
- package/dist/ui/datetime-picker/types.js +1 -0
- package/dist/ui/dialog/cmp.dialog-button.svelte.d.ts +1 -0
- package/dist/ui/dropdown/cmp.dropdown.svelte +23 -9
- package/dist/ui/dropdown/cmp.dropdown.svelte.d.ts +7 -2
- package/dist/ui/dropdown/index.d.ts +0 -1
- package/dist/ui/dropdown/index.js +0 -1
- package/dist/ui/icon-text/cmp.icon-text.svelte +1 -1
- package/dist/ui/inputs/input/cmp.input-validatable.svelte.d.ts +1 -0
- package/dist/ui/inputs/input/cmp.input.svelte.d.ts +1 -0
- package/dist/ui/inputs/textarea/cmp.textarea-validatable.svelte.d.ts +2 -1
- package/dist/ui/inputs/textarea/cmp.textarea.svelte.d.ts +1 -0
- package/dist/ui/placeholder/cmp.placeholder.svelte +65 -0
- package/dist/ui/placeholder/cmp.placeholder.svelte.d.ts +19 -0
- package/dist/ui/placeholder/index.d.ts +1 -0
- package/dist/ui/placeholder/index.js +1 -0
- package/dist/ui/selects/_multiselect.scss +3 -3
- package/dist/ui/selects/_singleselect.scss +1 -1
- package/dist/ui/selects/cmp.multiselect.svelte +2 -2
- package/dist/ui/selects/cmp.search-multiselect.svelte +2 -2
- package/dist/ui/toggle/cmp.toggle.svelte +103 -0
- package/dist/ui/toggle/cmp.toggle.svelte.d.ts +25 -0
- package/dist/ui/toggle/index.d.ts +1 -0
- package/dist/ui/toggle/index.js +1 -0
- package/dist/ui/tooltip/cmp.tooltip.svelte +192 -0
- package/dist/ui/tooltip/cmp.tooltip.svelte.d.ts +31 -0
- package/dist/ui/tooltip/index.d.ts +2 -0
- package/dist/ui/tooltip/index.js +1 -0
- package/dist/ui/tooltip/types.d.ts +2 -0
- package/dist/ui/tooltip/types.js +1 -0
- package/package.json +31 -1
- package/dist/ui/dropdown/cmp.dropdown-panel.svelte +0 -29
- package/dist/ui/dropdown/cmp.dropdown-panel.svelte.d.ts +0 -18
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">import { HtmlHelper } from '../../core/utils';
|
|
2
|
+
const { imageSrc, title, body, actions } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div class="placeholder">
|
|
6
|
+
<div class="placeholder__body">
|
|
7
|
+
<div class="placeholder__image">
|
|
8
|
+
<img src={imageSrc} alt="" />
|
|
9
|
+
</div>
|
|
10
|
+
<div class="placeholder__text">
|
|
11
|
+
<div class="placeholder__text-title">{@html title ? HtmlHelper.sanitizeHtml(title) : ''}</div>
|
|
12
|
+
<span class="placeholder__text-body">{body}</span>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="placeholder-actions">
|
|
16
|
+
{#if actions}
|
|
17
|
+
{@render actions()}
|
|
18
|
+
{/if}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
@component
|
|
24
|
+
Displays an empty-state placeholder with optional image, title, body text, and action buttons.
|
|
25
|
+
|
|
26
|
+
### CSS Custom Properties
|
|
27
|
+
| Property | Description | Default |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `--sc-kit--placeholder--flex-direction` | Body layout direction | `column` |
|
|
30
|
+
| `--sc-kit--placeholder--margin-top` | Top margin | `5.25em` |
|
|
31
|
+
-->
|
|
32
|
+
|
|
33
|
+
<style>.placeholder {
|
|
34
|
+
--_placeholder--flex-direction: var(--sc-kit--placeholder--flex-direction, column);
|
|
35
|
+
--_placeholder--margin-top: var(--sc-kit--placeholder--margin-top, 5.25em);
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
align-items: center;
|
|
39
|
+
margin-top: var(--_placeholder--margin-top);
|
|
40
|
+
}
|
|
41
|
+
.placeholder__body {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: var(--_placeholder--flex-direction);
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
.placeholder__text {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 0.3125em;
|
|
51
|
+
margin-bottom: 3.125em;
|
|
52
|
+
}
|
|
53
|
+
.placeholder__text-title {
|
|
54
|
+
font-size: 2em;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
text-align: center;
|
|
57
|
+
}
|
|
58
|
+
.placeholder__text-title :global(span) {
|
|
59
|
+
color: light-dark(#144ab0, #5a8dec);
|
|
60
|
+
}
|
|
61
|
+
.placeholder__text-body {
|
|
62
|
+
font-size: 1.125em;
|
|
63
|
+
color: light-dark(#6b7280, #d1d5db);
|
|
64
|
+
font-weight: 300;
|
|
65
|
+
}</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
imageSrc?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
body: string;
|
|
6
|
+
actions?: Snippet;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Displays an empty-state placeholder with optional image, title, body text, and action buttons.
|
|
10
|
+
*
|
|
11
|
+
* ### CSS Custom Properties
|
|
12
|
+
* | Property | Description | Default |
|
|
13
|
+
* |---|---|---|
|
|
14
|
+
* | `--sc-kit--placeholder--flex-direction` | Body layout direction | `column` |
|
|
15
|
+
* | `--sc-kit--placeholder--margin-top` | Top margin | `5.25em` |
|
|
16
|
+
*/
|
|
17
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
19
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Placeholder } from './cmp.placeholder.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Placeholder } from './cmp.placeholder.svelte';
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
|
|
141
141
|
&__icon {
|
|
142
142
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
143
|
-
--sc-kit--icon--size:
|
|
143
|
+
--sc-kit--icon--size: #{functions.em(20)};
|
|
144
144
|
display: flex;
|
|
145
145
|
align-items: center;
|
|
146
146
|
|
|
@@ -258,7 +258,7 @@
|
|
|
258
258
|
|
|
259
259
|
&__deselect {
|
|
260
260
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
261
|
-
--sc-kit--icon--size: #{functions.
|
|
261
|
+
--sc-kit--icon--size: #{functions.em(20)};
|
|
262
262
|
cursor: pointer;
|
|
263
263
|
display: flex;
|
|
264
264
|
align-items: center;
|
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
|
|
267
267
|
&__drag-handle {
|
|
268
268
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
269
|
-
--sc-kit--icon--size: #{functions.
|
|
269
|
+
--sc-kit--icon--size: #{functions.em(16)};
|
|
270
270
|
cursor: grab;
|
|
271
271
|
display: flex;
|
|
272
272
|
align-items: center;
|
|
@@ -514,14 +514,14 @@ Multi-value select dropdown built on svelte-select with fuzzy search. Supports e
|
|
|
514
514
|
}
|
|
515
515
|
.multiselect-tags__deselect {
|
|
516
516
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
517
|
-
--sc-kit--icon--size: 1.
|
|
517
|
+
--sc-kit--icon--size: 1.25em;
|
|
518
518
|
cursor: pointer;
|
|
519
519
|
display: flex;
|
|
520
520
|
align-items: center;
|
|
521
521
|
}
|
|
522
522
|
.multiselect-tags__drag-handle {
|
|
523
523
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
524
|
-
--sc-kit--icon--size:
|
|
524
|
+
--sc-kit--icon--size: 1em;
|
|
525
525
|
cursor: grab;
|
|
526
526
|
display: flex;
|
|
527
527
|
align-items: center;
|
|
@@ -510,14 +510,14 @@ Uses the same `--sc-kit--multiselect--*` variables as the Multiselect component.
|
|
|
510
510
|
}
|
|
511
511
|
.search-multiselect-tags__deselect {
|
|
512
512
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
513
|
-
--sc-kit--icon--size: 1.
|
|
513
|
+
--sc-kit--icon--size: 1.25em;
|
|
514
514
|
cursor: pointer;
|
|
515
515
|
display: flex;
|
|
516
516
|
align-items: center;
|
|
517
517
|
}
|
|
518
518
|
.search-multiselect-tags__drag-handle {
|
|
519
519
|
--sc-kit--icon--color: var(--_multiselect--icon--color);
|
|
520
|
-
--sc-kit--icon--size:
|
|
520
|
+
--sc-kit--icon--size: 1em;
|
|
521
521
|
cursor: grab;
|
|
522
522
|
display: flex;
|
|
523
523
|
align-items: center;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script lang="ts">const { isOn, label = '', disabled = false, on } = $props();
|
|
2
|
+
const toggleState = () => {
|
|
3
|
+
if (disabled) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
on?.change(!isOn);
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="toggle" class:toggle--disabled={disabled} onclick={toggleState} onkeydown={() => {}} role="none">
|
|
11
|
+
<button type="button" aria-label="Toggle" class="toggle-switch">
|
|
12
|
+
<input type="checkbox" class="toggle-switch__checkbox" checked={isOn} disabled={disabled} />
|
|
13
|
+
<span class="toggle-switch__slider"></span>
|
|
14
|
+
</button>
|
|
15
|
+
{#if label}
|
|
16
|
+
<span class="toggle__label">{label}</span>
|
|
17
|
+
{/if}
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<!--
|
|
21
|
+
@component
|
|
22
|
+
A toggle switch for boolean on/off states with optional label.
|
|
23
|
+
|
|
24
|
+
### CSS Custom Properties
|
|
25
|
+
| Property | Description | Default |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `--sc-kit--toggle--color` | Active track color | `primary-500` / `primary-400` |
|
|
28
|
+
| `--sc-kit--toggle--root--font-size` | Root font size | `1rem` |
|
|
29
|
+
| `--sc-kit--toggle--label--font-size` | Label font size | `1em` |
|
|
30
|
+
| `--sc-kit--toggle--switch--font-size` | Switch font size | `1em` |
|
|
31
|
+
| `--sc-kit--toggle--switch--width` | Switch track width | `2.5em` |
|
|
32
|
+
| `--sc-kit--toggle--switch--height` | Switch track height | `1.375em` |
|
|
33
|
+
| `--sc-kit--toggle--switch--border-radius` | Track border radius | `(height)` |
|
|
34
|
+
-->
|
|
35
|
+
|
|
36
|
+
<style>.toggle {
|
|
37
|
+
--_toggle--color: var(--sc-kit--toggle--color, light-dark(#144ab0, #5a8dec));
|
|
38
|
+
--_toggle--root--font-size: var(--sc-kit--toggle--root--font-size, 1rem);
|
|
39
|
+
--_toggle--label--font-size: var(--sc-kit--toggle--label--font-size, 1em);
|
|
40
|
+
--_toggle--switch--font-size: var(--sc-kit--toggle--switch--font-size, 1em);
|
|
41
|
+
--_toggle--switch--width: var(--sc-kit--toggle--switch--width, 2.5em);
|
|
42
|
+
--_toggle--switch--height: var(--sc-kit--toggle--switch--height, 1.375em);
|
|
43
|
+
--_toggle--switch--border-radius: var(--sc-kit--toggle--switch--border-radius, var(--_toggle--switch--height));
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
font-size: var(--_toggle--root--font-size);
|
|
48
|
+
}
|
|
49
|
+
.toggle--disabled {
|
|
50
|
+
opacity: 0.6;
|
|
51
|
+
cursor: default;
|
|
52
|
+
}
|
|
53
|
+
.toggle .toggle-switch {
|
|
54
|
+
font-size: var(--_toggle--switch--font-size);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
position: relative;
|
|
57
|
+
display: inline-block;
|
|
58
|
+
width: var(--_toggle--switch--width);
|
|
59
|
+
min-width: var(--_toggle--switch--width);
|
|
60
|
+
height: var(--_toggle--switch--height);
|
|
61
|
+
}
|
|
62
|
+
.toggle .toggle-switch .toggle-switch__checkbox {
|
|
63
|
+
opacity: 0;
|
|
64
|
+
width: 0;
|
|
65
|
+
height: 0;
|
|
66
|
+
}
|
|
67
|
+
.toggle .toggle-switch .toggle-switch__checkbox:checked + .toggle-switch__slider {
|
|
68
|
+
background-color: var(--_toggle--color);
|
|
69
|
+
}
|
|
70
|
+
.toggle .toggle-switch .toggle-switch__checkbox:checked + .toggle-switch__slider:before {
|
|
71
|
+
transform: translateX(calc(var(--_toggle--switch--width) - var(--_toggle--switch--height)));
|
|
72
|
+
}
|
|
73
|
+
.toggle .toggle-switch .toggle-switch__checkbox:focus + .toggle-switch__slider {
|
|
74
|
+
box-shadow: 0 0 1px var(--_toggle--color);
|
|
75
|
+
}
|
|
76
|
+
.toggle .toggle-switch .toggle-switch__slider {
|
|
77
|
+
position: absolute;
|
|
78
|
+
top: 0;
|
|
79
|
+
left: 0;
|
|
80
|
+
right: 0;
|
|
81
|
+
bottom: 0;
|
|
82
|
+
background-color: light-dark(#d1d5db, #4b5563);
|
|
83
|
+
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
84
|
+
border-radius: var(--_toggle--switch--border-radius);
|
|
85
|
+
margin: 0;
|
|
86
|
+
}
|
|
87
|
+
.toggle .toggle-switch .toggle-switch__slider:before {
|
|
88
|
+
position: absolute;
|
|
89
|
+
content: "";
|
|
90
|
+
background-color: #ffffff;
|
|
91
|
+
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
92
|
+
border-radius: 50%;
|
|
93
|
+
height: calc(var(--_toggle--switch--height) - 2 * 0.125em);
|
|
94
|
+
width: calc(var(--_toggle--switch--height) - 2 * 0.125em);
|
|
95
|
+
left: 0.125em;
|
|
96
|
+
bottom: 0.125em;
|
|
97
|
+
}
|
|
98
|
+
.toggle .toggle__label {
|
|
99
|
+
margin-left: 0.875em;
|
|
100
|
+
font-size: var(--_toggle--label--font-size);
|
|
101
|
+
cursor: inherit;
|
|
102
|
+
user-select: none;
|
|
103
|
+
}</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
isOn: boolean;
|
|
3
|
+
label?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
on?: {
|
|
6
|
+
change: (value: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A toggle switch for boolean on/off states with optional label.
|
|
11
|
+
*
|
|
12
|
+
* ### CSS Custom Properties
|
|
13
|
+
* | Property | Description | Default |
|
|
14
|
+
* |---|---|---|
|
|
15
|
+
* | `--sc-kit--toggle--color` | Active track color | `primary-500` / `primary-400` |
|
|
16
|
+
* | `--sc-kit--toggle--root--font-size` | Root font size | `1rem` |
|
|
17
|
+
* | `--sc-kit--toggle--label--font-size` | Label font size | `1em` |
|
|
18
|
+
* | `--sc-kit--toggle--switch--font-size` | Switch font size | `1em` |
|
|
19
|
+
* | `--sc-kit--toggle--switch--width` | Switch track width | `2.5em` |
|
|
20
|
+
* | `--sc-kit--toggle--switch--height` | Switch track height | `1.375em` |
|
|
21
|
+
* | `--sc-kit--toggle--switch--border-radius` | Track border radius | `(height)` |
|
|
22
|
+
*/
|
|
23
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
24
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
25
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Toggle } from './cmp.toggle.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Toggle } from './cmp.toggle.svelte';
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<script lang="ts">import { Icon } from '../icon';
|
|
2
|
+
import IconChevronDown from '@fluentui/svg-icons/icons/chevron_down_20_regular.svg?raw';
|
|
3
|
+
import { createPopper } from '@popperjs/core';
|
|
4
|
+
let { position = 'bottom-start', ignoreClick = false, disabled = false, fixedPosition = false, offset = 8, boundaryMargin = 8, children, trigger } = $props();
|
|
5
|
+
let open = $state(false);
|
|
6
|
+
let hidden = $state(false);
|
|
7
|
+
let triggerRef = $state(null);
|
|
8
|
+
let openedByHover = false;
|
|
9
|
+
let popper;
|
|
10
|
+
let _blocked = false;
|
|
11
|
+
const toggleHandler = (ev) => {
|
|
12
|
+
if (ignoreClick) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const wasOpenedByHover = openedByHover;
|
|
16
|
+
openedByHover = false;
|
|
17
|
+
if (open && wasOpenedByHover) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (ev.type === 'focusin' && !open) {
|
|
21
|
+
_blocked = true;
|
|
22
|
+
setTimeout(() => (_blocked = false), 250);
|
|
23
|
+
}
|
|
24
|
+
open = ev.type === 'click' && !_blocked ? !open : true;
|
|
25
|
+
};
|
|
26
|
+
const showHandlerOnHover = (ev) => {
|
|
27
|
+
if (open && !openedByHover) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (ev.type === 'mouseenter') {
|
|
31
|
+
openedByHover = true;
|
|
32
|
+
open = true;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const hideHandler = (ev) => {
|
|
36
|
+
if (ignoreClick) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
if (ev.type === 'focusout' && shouldBeHidden(ev)) {
|
|
41
|
+
hidden = true;
|
|
42
|
+
}
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
if (shouldBeHidden(ev)) {
|
|
45
|
+
open = false;
|
|
46
|
+
}
|
|
47
|
+
}, 100);
|
|
48
|
+
}, 50);
|
|
49
|
+
};
|
|
50
|
+
const hideHandlerOnHover = (ev) => {
|
|
51
|
+
if (!openedByHover) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (ev.type === 'mouseleave' && openedByHover) {
|
|
55
|
+
open = false;
|
|
56
|
+
}
|
|
57
|
+
openedByHover = false;
|
|
58
|
+
};
|
|
59
|
+
const shouldBeHidden = (ev) => {
|
|
60
|
+
const hasFocus = (el) => !!el?.contains && el.contains(document.activeElement);
|
|
61
|
+
if (ev.type === 'focusout') {
|
|
62
|
+
if (hasFocus(ev.target)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
68
|
+
$effect(() => {
|
|
69
|
+
popper?.setOptions({ placement: position });
|
|
70
|
+
});
|
|
71
|
+
$effect(() => {
|
|
72
|
+
if (open) {
|
|
73
|
+
hidden = false;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const init = (node, _triggerEl) => {
|
|
77
|
+
popper = createPopper(_triggerEl, node, {
|
|
78
|
+
placement: position,
|
|
79
|
+
strategy: fixedPosition ? 'fixed' : 'absolute',
|
|
80
|
+
modifiers: [
|
|
81
|
+
{
|
|
82
|
+
name: 'offset',
|
|
83
|
+
options: {
|
|
84
|
+
offset: () => [0, offset]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{ name: 'eventListeners', enabled: open },
|
|
88
|
+
{ name: 'flip' },
|
|
89
|
+
{
|
|
90
|
+
name: 'preventOverflow',
|
|
91
|
+
options: {
|
|
92
|
+
boundary: document.body,
|
|
93
|
+
padding: boundaryMargin
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
update(_triggerEl) {
|
|
100
|
+
popper.state.elements.reference = _triggerEl;
|
|
101
|
+
popper.update();
|
|
102
|
+
},
|
|
103
|
+
destroy() {
|
|
104
|
+
popper.destroy();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<div
|
|
111
|
+
class="tooltip"
|
|
112
|
+
class:tooltip--disabled={disabled}
|
|
113
|
+
onclick={(e) => e.stopPropagation()}
|
|
114
|
+
onkeydown={() => {}}
|
|
115
|
+
onfocusout={hideHandler}
|
|
116
|
+
onmouseenter={showHandlerOnHover}
|
|
117
|
+
onmouseleave={hideHandlerOnHover}
|
|
118
|
+
role="none">
|
|
119
|
+
<button type="button" class="tooltip__trigger" bind:this={triggerRef} onclick={toggleHandler} data-role="tooltip-trigger">
|
|
120
|
+
{#if trigger}
|
|
121
|
+
{@render trigger()}
|
|
122
|
+
{:else}
|
|
123
|
+
<Icon src={IconChevronDown} />
|
|
124
|
+
{/if}
|
|
125
|
+
</button>
|
|
126
|
+
{#if open}
|
|
127
|
+
<div use:init={triggerRef} class="tooltip__content" class:tooltip__content--hidden={hidden} role="tooltip" tabindex="-1">
|
|
128
|
+
{@render children()}
|
|
129
|
+
</div>
|
|
130
|
+
{/if}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<!--
|
|
134
|
+
@component
|
|
135
|
+
A tooltip/popover that positions content relative to a trigger element using Popper.js.
|
|
136
|
+
Supports hover-only mode, click toggle, and configurable placement.
|
|
137
|
+
|
|
138
|
+
### CSS Custom Properties
|
|
139
|
+
| Property | Description | Default |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| `--sc-kit--tooltip--background-color` | Tooltip background | light-dark white/gray-900 |
|
|
142
|
+
| `--sc-kit--tooltip--border-radius` | Corner radius | `0` |
|
|
143
|
+
| `--sc-kit--tooltip--box-shadow` | Drop shadow | `0 2px 10px` light-dark |
|
|
144
|
+
-->
|
|
145
|
+
|
|
146
|
+
<style>.tooltip {
|
|
147
|
+
--_tooltip--background-color: var(--sc-kit--tooltip--background-color, light-dark(#ffffff, #1c1c1c));
|
|
148
|
+
--_tooltip--border-radius: var(--sc-kit--tooltip--border-radius, 0);
|
|
149
|
+
--_tooltip--box-shadow: var(--sc-kit--tooltip--box-shadow, 0 2px 10px light-dark(rgb(0 0 0 / 15%), rgb(255 255 255 / 20%)));
|
|
150
|
+
height: 100%;
|
|
151
|
+
display: inline-block;
|
|
152
|
+
-webkit-user-drag: none;
|
|
153
|
+
user-select: none;
|
|
154
|
+
}
|
|
155
|
+
.tooltip :global([contenteditable]) {
|
|
156
|
+
user-select: text;
|
|
157
|
+
}
|
|
158
|
+
.tooltip__trigger {
|
|
159
|
+
height: 100%;
|
|
160
|
+
width: 100%;
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
line-height: 1;
|
|
164
|
+
}
|
|
165
|
+
.tooltip--disabled {
|
|
166
|
+
opacity: 0.5;
|
|
167
|
+
pointer-events: none;
|
|
168
|
+
}
|
|
169
|
+
.tooltip__content {
|
|
170
|
+
box-shadow: var(--_tooltip--box-shadow);
|
|
171
|
+
background: var(--_tooltip--background-color);
|
|
172
|
+
width: max-content;
|
|
173
|
+
z-index: 999;
|
|
174
|
+
border-radius: var(--_tooltip--border-radius);
|
|
175
|
+
animation: tooltip-appear 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
176
|
+
transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
177
|
+
}
|
|
178
|
+
.tooltip__content--hidden {
|
|
179
|
+
opacity: 0;
|
|
180
|
+
}
|
|
181
|
+
.tooltip :global([data-popper-escaped]) {
|
|
182
|
+
visibility: hidden !important;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@keyframes tooltip-appear {
|
|
186
|
+
from {
|
|
187
|
+
opacity: 0;
|
|
188
|
+
}
|
|
189
|
+
to {
|
|
190
|
+
opacity: 1;
|
|
191
|
+
}
|
|
192
|
+
}</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TooltipPosition } from './types';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** @default 'bottom-start' */
|
|
5
|
+
position?: TooltipPosition;
|
|
6
|
+
/** Tooltip will be activated on hover only */
|
|
7
|
+
ignoreClick?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Use when tooltip appears in a fixed container to prevent unnecessary calculations */
|
|
10
|
+
fixedPosition?: boolean;
|
|
11
|
+
/** Offset from tooltip trigger @default 8 */
|
|
12
|
+
offset?: number;
|
|
13
|
+
/** Additional margin from document.body to prevent sticking to screen edges @default 8 */
|
|
14
|
+
boundaryMargin?: number;
|
|
15
|
+
children: Snippet;
|
|
16
|
+
trigger: Snippet;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A tooltip/popover that positions content relative to a trigger element using Popper.js.
|
|
20
|
+
* Supports hover-only mode, click toggle, and configurable placement.
|
|
21
|
+
*
|
|
22
|
+
* ### CSS Custom Properties
|
|
23
|
+
* | Property | Description | Default |
|
|
24
|
+
* |---|---|---|
|
|
25
|
+
* | `--sc-kit--tooltip--background-color` | Tooltip background | light-dark white/gray-900 |
|
|
26
|
+
* | `--sc-kit--tooltip--border-radius` | Corner radius | `0` |
|
|
27
|
+
* | `--sc-kit--tooltip--box-shadow` | Drop shadow | `0 2px 10px` light-dark |
|
|
28
|
+
*/
|
|
29
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
30
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
31
|
+
export default Cmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Tooltip } from './cmp.tooltip.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamscloud/kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"author": "StreamsCloud",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
"types": "./dist/core/validation/index.d.ts",
|
|
86
86
|
"svelte": "./dist/core/validation/index.js"
|
|
87
87
|
},
|
|
88
|
+
"./ui/badge": {
|
|
89
|
+
"types": "./dist/ui/badge/index.d.ts",
|
|
90
|
+
"svelte": "./dist/ui/badge/index.js"
|
|
91
|
+
},
|
|
88
92
|
"./ui/button": {
|
|
89
93
|
"types": "./dist/ui/button/index.d.ts",
|
|
90
94
|
"svelte": "./dist/ui/button/index.js"
|
|
@@ -93,14 +97,26 @@
|
|
|
93
97
|
"types": "./dist/ui/card-actions/index.d.ts",
|
|
94
98
|
"svelte": "./dist/ui/card-actions/index.js"
|
|
95
99
|
},
|
|
100
|
+
"./ui/checkbox": {
|
|
101
|
+
"types": "./dist/ui/checkbox/index.d.ts",
|
|
102
|
+
"svelte": "./dist/ui/checkbox/index.js"
|
|
103
|
+
},
|
|
96
104
|
"./ui/color-picker": {
|
|
97
105
|
"types": "./dist/ui/color-picker/index.d.ts",
|
|
98
106
|
"svelte": "./dist/ui/color-picker/index.js"
|
|
99
107
|
},
|
|
108
|
+
"./ui/confirmation-dialog": {
|
|
109
|
+
"types": "./dist/ui/confirmation-dialog/index.d.ts",
|
|
110
|
+
"svelte": "./dist/ui/confirmation-dialog/index.js"
|
|
111
|
+
},
|
|
100
112
|
"./ui/cropper": {
|
|
101
113
|
"types": "./dist/ui/cropper/img-cropper/index.d.ts",
|
|
102
114
|
"svelte": "./dist/ui/cropper/img-cropper/index.js"
|
|
103
115
|
},
|
|
116
|
+
"./ui/datetime-picker": {
|
|
117
|
+
"types": "./dist/ui/datetime-picker/index.d.ts",
|
|
118
|
+
"svelte": "./dist/ui/datetime-picker/index.js"
|
|
119
|
+
},
|
|
104
120
|
"./ui/dialog": {
|
|
105
121
|
"types": "./dist/ui/dialog/index.d.ts",
|
|
106
122
|
"svelte": "./dist/ui/dialog/index.js"
|
|
@@ -181,6 +197,10 @@
|
|
|
181
197
|
"types": "./dist/ui/player/providers/index.d.ts",
|
|
182
198
|
"svelte": "./dist/ui/player/providers/index.js"
|
|
183
199
|
},
|
|
200
|
+
"./ui/placeholder": {
|
|
201
|
+
"types": "./dist/ui/placeholder/index.d.ts",
|
|
202
|
+
"svelte": "./dist/ui/placeholder/index.js"
|
|
203
|
+
},
|
|
184
204
|
"./ui/progress": {
|
|
185
205
|
"types": "./dist/ui/progress/index.d.ts",
|
|
186
206
|
"svelte": "./dist/ui/progress/index.js"
|
|
@@ -205,6 +225,14 @@
|
|
|
205
225
|
"types": "./dist/ui/time-ago/index.d.ts",
|
|
206
226
|
"svelte": "./dist/ui/time-ago/index.js"
|
|
207
227
|
},
|
|
228
|
+
"./ui/toggle": {
|
|
229
|
+
"types": "./dist/ui/toggle/index.d.ts",
|
|
230
|
+
"svelte": "./dist/ui/toggle/index.js"
|
|
231
|
+
},
|
|
232
|
+
"./ui/tooltip": {
|
|
233
|
+
"types": "./dist/ui/tooltip/index.d.ts",
|
|
234
|
+
"svelte": "./dist/ui/tooltip/index.js"
|
|
235
|
+
},
|
|
208
236
|
"./ui/validatable": {
|
|
209
237
|
"types": "./dist/ui/validatable/index.d.ts",
|
|
210
238
|
"svelte": "./dist/ui/validatable/index.js"
|
|
@@ -249,6 +277,7 @@
|
|
|
249
277
|
"cropperjs": "^2.1.0",
|
|
250
278
|
"dequal": "^2.0.0",
|
|
251
279
|
"dompurify": "^3.3.0",
|
|
280
|
+
"flatpickr": "^4.6.13",
|
|
252
281
|
"fuse.js": "^7.1.0",
|
|
253
282
|
"mime": "^4.1.0",
|
|
254
283
|
"nanoid": "^5.1.6",
|
|
@@ -287,6 +316,7 @@
|
|
|
287
316
|
"eslint-plugin-promise": "^7.2.1",
|
|
288
317
|
"eslint-plugin-svelte": "^3.15.0",
|
|
289
318
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
319
|
+
"flatpickr": "^4.6.13",
|
|
290
320
|
"fuse.js": "^7.1.0",
|
|
291
321
|
"globals": "^17.3.0",
|
|
292
322
|
"mime": "^4.1.0",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="ts">const { children } = $props();
|
|
2
|
-
export {};
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div class="dropdown-panel">
|
|
6
|
-
{@render children()}
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
@component
|
|
11
|
-
Visual panel wrapper for dropdown content — provides background, box-shadow, and border-radius.
|
|
12
|
-
Typically used as a direct child of `Dropdown`.
|
|
13
|
-
|
|
14
|
-
### CSS Custom Properties
|
|
15
|
-
| Property | Description | Default |
|
|
16
|
-
|---|---|---|
|
|
17
|
-
| `--sc-kit--dropdown-panel--background` | Panel background | light-dark white/gray-900 |
|
|
18
|
-
| `--sc-kit--dropdown-panel--box-shadow` | Panel shadow | `0 2px 10px` light rgb(0 0 0 / 15%), dark rgb(255 255 255 / 20%) |
|
|
19
|
-
| `--sc-kit--dropdown-panel--border-radius` | Corner radius | `0` |
|
|
20
|
-
-->
|
|
21
|
-
|
|
22
|
-
<style>.dropdown-panel {
|
|
23
|
-
--_dropdown-panel--background: var(--sc-kit--dropdown-panel--background, light-dark(#ffffff, #1c1c1c));
|
|
24
|
-
--_dropdown-panel--box-shadow: var(--sc-kit--dropdown-panel--box-shadow, 0 2px 10px light-dark(rgb(0 0 0 / 15%), rgb(255 255 255 / 20%)));
|
|
25
|
-
--_dropdown-panel--border-radius: var(--sc-kit--dropdown-panel--border-radius, 0);
|
|
26
|
-
background: var(--_dropdown-panel--background);
|
|
27
|
-
box-shadow: var(--_dropdown-panel--box-shadow);
|
|
28
|
-
border-radius: var(--_dropdown-panel--border-radius);
|
|
29
|
-
}</style>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
type Props = {
|
|
3
|
-
children: Snippet;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Visual panel wrapper for dropdown content — provides background, box-shadow, and border-radius.
|
|
7
|
-
* Typically used as a direct child of `Dropdown`.
|
|
8
|
-
*
|
|
9
|
-
* ### CSS Custom Properties
|
|
10
|
-
* | Property | Description | Default |
|
|
11
|
-
* |---|---|---|
|
|
12
|
-
* | `--sc-kit--dropdown-panel--background` | Panel background | light-dark white/gray-900 |
|
|
13
|
-
* | `--sc-kit--dropdown-panel--box-shadow` | Panel shadow | `0 2px 10px` light rgb(0 0 0 / 15%), dark rgb(255 255 255 / 20%) |
|
|
14
|
-
* | `--sc-kit--dropdown-panel--border-radius` | Corner radius | `0` |
|
|
15
|
-
*/
|
|
16
|
-
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
17
|
-
type Cmp = ReturnType<typeof Cmp>;
|
|
18
|
-
export default Cmp;
|