fluent-svelte-extra 1.9.4 → 1.9.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/ContentDialog/ContentDialog.svelte +1 -0
- package/Expander/Expander.svelte +1 -1
- package/TeachingTip/TeachingTipSurface.scss +14 -0
- package/TeachingTip/TeachingTipSurface.svelte +15 -0
- package/TeachingTip/TeachingTipSurface.svelte.d.ts +20 -0
- package/TeachingTip/TeachingTipWrapper.scss +79 -0
- package/TeachingTip/TeachingTipWrapper.svelte +121 -0
- package/TeachingTip/TeachingTipWrapper.svelte.d.ts +48 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/internal.js +1 -1
- package/package.json +5 -1
package/Expander/Expander.svelte
CHANGED
|
@@ -80,7 +80,7 @@ Expanders are controls that display a header and a collapsable content area. The
|
|
|
80
80
|
aria-controls={contentId}
|
|
81
81
|
class="expander-header"
|
|
82
82
|
aria-expanded={expanded}
|
|
83
|
-
tabindex=
|
|
83
|
+
tabindex={expandable ? 0 : -1}
|
|
84
84
|
bind:this={headerElement}
|
|
85
85
|
on:keydown={handleKeydown}
|
|
86
86
|
on:click={() => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use "../mixins" as *;
|
|
2
|
+
|
|
3
|
+
.teaching-tip {
|
|
4
|
+
@include typography-body;
|
|
5
|
+
padding: 16px;
|
|
6
|
+
min-inline-size: 320px;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
color: var(--text-primary);
|
|
9
|
+
border-radius: var(--overlay-corner-radius);
|
|
10
|
+
border: 1px solid var(--surface-stroke-default);
|
|
11
|
+
background-color: var(--solid-background-quarternary);
|
|
12
|
+
background-clip: padding-box;
|
|
13
|
+
box-shadow: var(--flyout-shadow);
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script >import { get_current_component } from "svelte/internal";
|
|
2
|
+
import { createEventForwarder } from "../internal";
|
|
3
|
+
/** Specifies a custom class name for the surface. */
|
|
4
|
+
let className = "";
|
|
5
|
+
export { className as class };
|
|
6
|
+
/** Obtains a bound DOM reference to the surface element. */
|
|
7
|
+
export let element = null;
|
|
8
|
+
const forwardEvents = createEventForwarder(get_current_component());
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="teaching-tip {className}" use:forwardEvents bind:this={element} {...$$restProps}>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style >.teaching-tip{background-clip:padding-box;background-color:var(--fds-solid-background-quarternary);border:1px solid var(--fds-surface-stroke-default);border-radius:var(--fds-overlay-corner-radius);box-shadow:var(--fds-flyout-shadow);box-sizing:border-box;color:var(--fds-text-primary);font-family:var(--fds-font-family-text);font-size:var(--fds-body-font-size);font-weight:400;line-height:20px;min-inline-size:320px;padding:16px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
class?: string;
|
|
6
|
+
element?: HTMLDivElement;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
default: {};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare type TeachingTipSurfaceProps = typeof __propDef.props;
|
|
16
|
+
export declare type TeachingTipSurfaceEvents = typeof __propDef.events;
|
|
17
|
+
export declare type TeachingTipSurfaceSlots = typeof __propDef.slots;
|
|
18
|
+
export default class TeachingTipSurface extends SvelteComponentTyped<TeachingTipSurfaceProps, TeachingTipSurfaceEvents, TeachingTipSurfaceSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
.teaching-tip- {
|
|
3
|
+
&wrapper {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
inline-size: fit-content;
|
|
6
|
+
block-size: fit-content;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
&backdrop {
|
|
10
|
+
position: fixed;
|
|
11
|
+
top: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
inline-size: 100%;
|
|
14
|
+
block-size: 100%;
|
|
15
|
+
z-index: 9999;
|
|
16
|
+
}
|
|
17
|
+
&anchor {
|
|
18
|
+
position: absolute;
|
|
19
|
+
z-index: 10000;
|
|
20
|
+
transform: var(--teaching-tip-transform);
|
|
21
|
+
&.placement- {
|
|
22
|
+
--teaching-tip-transform: translateX(0%);
|
|
23
|
+
&top {
|
|
24
|
+
transform-origin: bottom;
|
|
25
|
+
bottom: calc(100% + var(--teaching-tip-offset));
|
|
26
|
+
--teaching-tip-transition-offset: translateY(12px);
|
|
27
|
+
}
|
|
28
|
+
&bottom {
|
|
29
|
+
transform-origin: top;
|
|
30
|
+
top: calc(100% + var(--teaching-tip-offset));
|
|
31
|
+
--teaching-tip-transition-offset: translateY(-12px);
|
|
32
|
+
}
|
|
33
|
+
&left {
|
|
34
|
+
transform-origin: right;
|
|
35
|
+
right: calc(100% + var(--teaching-tip-offset));
|
|
36
|
+
--teaching-tip-transition-offset: translateX(12px);
|
|
37
|
+
}
|
|
38
|
+
&right {
|
|
39
|
+
transform-origin: left;
|
|
40
|
+
left: calc(100% + var(--teaching-tip-offset));
|
|
41
|
+
--teaching-tip-transition-offset: translateX(-12px);
|
|
42
|
+
}
|
|
43
|
+
&top,
|
|
44
|
+
&bottom {
|
|
45
|
+
&.alignment- {
|
|
46
|
+
&start {
|
|
47
|
+
inset-inline-start: 0;
|
|
48
|
+
--teaching-tip-transform: translateX(0%);
|
|
49
|
+
}
|
|
50
|
+
&end {
|
|
51
|
+
inset-inline-end: 0;
|
|
52
|
+
--teaching-tip-transform: translateX(0%);
|
|
53
|
+
}
|
|
54
|
+
¢er {
|
|
55
|
+
inset-inline-start: 50%;
|
|
56
|
+
--teaching-tip-transform: translateX(-50%);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
&left,
|
|
61
|
+
&right {
|
|
62
|
+
&.alignment- {
|
|
63
|
+
&start {
|
|
64
|
+
inset-block-start: 0;
|
|
65
|
+
--teaching-tip-transform: translateY(0%);
|
|
66
|
+
}
|
|
67
|
+
&end {
|
|
68
|
+
inset-block-end: 0;
|
|
69
|
+
--teaching-tip-transform: translateY(0%);
|
|
70
|
+
}
|
|
71
|
+
¢er {
|
|
72
|
+
inset-block-start: 50%;
|
|
73
|
+
--teaching-tip-transform: translateY(-50%);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script >import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { uid, focusTrap, getCSSDuration } from "../internal";
|
|
3
|
+
import { fade, scale } from "svelte/transition";
|
|
4
|
+
import { expoIn, expoOut } from "svelte/easing";
|
|
5
|
+
import TeachingTipSurface from "./TeachingTipSurface.svelte";
|
|
6
|
+
/** Determines the teaching-tip's visibility. */
|
|
7
|
+
export let open = false;
|
|
8
|
+
/** Determines if the teaching-tip can be closed using conventional user interaction. */
|
|
9
|
+
export let closable = true;
|
|
10
|
+
/** Determines if the teaching-tip can be closed by clicking outside of it. */
|
|
11
|
+
export let closeOnBackdropClick = false;
|
|
12
|
+
/** Determines if the teaching-tip can be clicked. */
|
|
13
|
+
export let enableClick = true;
|
|
14
|
+
/** Direction that the teaching-tip will be opened from. */
|
|
15
|
+
export let placement = "top";
|
|
16
|
+
/** Alignment of the menu along the clickable target's given axis. */
|
|
17
|
+
export let alignment = "center";
|
|
18
|
+
/** Distance of the teaching-tip from the control button in pixels. */
|
|
19
|
+
export let offset = 4;
|
|
20
|
+
/** Determines if keyboard focus should be locked to the teaching-tip's contents. */
|
|
21
|
+
export let trapFocus = true;
|
|
22
|
+
/** Specifies a custom class name for the content wrapper. */
|
|
23
|
+
let className = "";
|
|
24
|
+
export { className as class };
|
|
25
|
+
/** Obtains a bound DOM reference to the content wrapper element. */
|
|
26
|
+
export let wrapperElement = null;
|
|
27
|
+
/** Obtains a bound DOM reference to the menu's positioning anchor element. */
|
|
28
|
+
export let anchorElement = null;
|
|
29
|
+
/** Obtains a bound DOM reference to the inner menu element. */
|
|
30
|
+
export let menuElement = null;
|
|
31
|
+
/** Obtains a bound DOM reference to the menu backdrop, which is present while the menu is `open`. */
|
|
32
|
+
export let backdropElement = null;
|
|
33
|
+
const dispatch = createEventDispatcher();
|
|
34
|
+
const menuId = uid("fds-teaching-tip-anchor-");
|
|
35
|
+
$: _focusTrap = trapFocus ? focusTrap : () => { };
|
|
36
|
+
$: if (open) {
|
|
37
|
+
dispatch("open");
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
dispatch("close");
|
|
41
|
+
}
|
|
42
|
+
function handleEscapeKey({ key }) {
|
|
43
|
+
if (key === "Escape" && closable)
|
|
44
|
+
open = false;
|
|
45
|
+
}
|
|
46
|
+
function closeTeachingTip() {
|
|
47
|
+
if (closable && closeOnBackdropClick)
|
|
48
|
+
open = false;
|
|
49
|
+
}
|
|
50
|
+
function handleKeyDown(event) {
|
|
51
|
+
if (event.key === " " || event.key === "Enter") {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
open = !open;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<!--
|
|
59
|
+
@component
|
|
60
|
+
TeachingTips represent a control that displays lightweight UI that is either information, or requires user interaction. Unlike a dialog, a TeachingTip can be dismissed by clicking or tapping outside of it, or pressing the Esc key. [Docs](https://fluent-svelte.vercel.app/docs/components/teaching-tip)
|
|
61
|
+
- Usage:
|
|
62
|
+
```tsx
|
|
63
|
+
<TeachingTip>
|
|
64
|
+
<Button>Trigger Button</Button>
|
|
65
|
+
<svelte:fragment slot="teaching-tip">
|
|
66
|
+
TeachingTip Contents
|
|
67
|
+
</svelte:fragment>
|
|
68
|
+
</TeachingTip>
|
|
69
|
+
```
|
|
70
|
+
-->
|
|
71
|
+
|
|
72
|
+
<svelte:window on:keydown={handleEscapeKey} />
|
|
73
|
+
|
|
74
|
+
<div
|
|
75
|
+
class="teaching-tip-wrapper {className}"
|
|
76
|
+
aria-expanded={open}
|
|
77
|
+
aria-haspopup={open}
|
|
78
|
+
aria-controls={menuId}
|
|
79
|
+
on:click={() => {
|
|
80
|
+
enableClick && (open = !open);
|
|
81
|
+
}}
|
|
82
|
+
on:keydown={handleKeyDown}
|
|
83
|
+
bind:this={wrapperElement}
|
|
84
|
+
>
|
|
85
|
+
<slot />
|
|
86
|
+
{#if open}
|
|
87
|
+
<div
|
|
88
|
+
id={menuId}
|
|
89
|
+
class="teaching-tip-anchor placement-{placement} alignment-{alignment}"
|
|
90
|
+
style="--fds-teaching-tip-offset: {offset}px;"
|
|
91
|
+
use:_focusTrap
|
|
92
|
+
in:scale|local={{
|
|
93
|
+
duration: getCSSDuration("--fds-control-slow-duration"),
|
|
94
|
+
easing: expoOut,
|
|
95
|
+
opacity: 1
|
|
96
|
+
}}
|
|
97
|
+
out:scale|local={{
|
|
98
|
+
duration: getCSSDuration("--fds-control-slow-duration"),
|
|
99
|
+
easing: expoIn,
|
|
100
|
+
opacity: 1
|
|
101
|
+
}}
|
|
102
|
+
bind:this={anchorElement}
|
|
103
|
+
on:click={e => e.stopPropagation()}
|
|
104
|
+
{...$$restProps}
|
|
105
|
+
>
|
|
106
|
+
<slot name="override">
|
|
107
|
+
<TeachingTipSurface bind:element={menuElement}>
|
|
108
|
+
<slot name="flyout" />
|
|
109
|
+
</TeachingTipSurface>
|
|
110
|
+
</slot>
|
|
111
|
+
</div>
|
|
112
|
+
<div
|
|
113
|
+
class="teaching-tip-backdrop"
|
|
114
|
+
bind:this={backdropElement}
|
|
115
|
+
on:click={e => e.stopPropagation()}
|
|
116
|
+
on:mousedown={closeTeachingTip}
|
|
117
|
+
/>
|
|
118
|
+
{/if}
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<style >.teaching-tip-wrapper{block-size:-webkit-fit-content;block-size:-moz-fit-content;block-size:fit-content;display:inline-block;inline-size:-webkit-fit-content;inline-size:-moz-fit-content;inline-size:fit-content;position:relative}.teaching-tip-backdrop{block-size:100%;inline-size:100%;left:0;position:fixed;top:0;z-index:9999}.teaching-tip-anchor{position:absolute;transform:var(--fds-teaching-tip-transform);z-index:10000}.teaching-tip-anchor.placement-{--fds-teaching-tip-transform:translateX(0%)}.teaching-tip-anchor.placement-top{--fds-teaching-tip-transition-offset:translateY(12px);bottom:calc(100% + var(--fds-teaching-tip-offset));transform-origin:bottom}.teaching-tip-anchor.placement-bottom{--fds-teaching-tip-transition-offset:translateY(-12px);top:calc(100% + var(--fds-teaching-tip-offset));transform-origin:top}.teaching-tip-anchor.placement-left{--fds-teaching-tip-transition-offset:translateX(12px);right:calc(100% + var(--fds-teaching-tip-offset));transform-origin:right}.teaching-tip-anchor.placement-right{--fds-teaching-tip-transition-offset:translateX(-12px);left:calc(100% + var(--fds-teaching-tip-offset));transform-origin:left}.teaching-tip-anchor.placement-bottom.alignment-start,.teaching-tip-anchor.placement-top.alignment-start{--fds-teaching-tip-transform:translateX(0%);inset-inline-start:0}.teaching-tip-anchor.placement-bottom.alignment-end,.teaching-tip-anchor.placement-top.alignment-end{--fds-teaching-tip-transform:translateX(0%);inset-inline-end:0}.teaching-tip-anchor.placement-bottom.alignment-center,.teaching-tip-anchor.placement-top.alignment-center{--fds-teaching-tip-transform:translateX(-50%);inset-inline-start:50%}.teaching-tip-anchor.placement-left.alignment-start,.teaching-tip-anchor.placement-right.alignment-start{--fds-teaching-tip-transform:translateY(0%);inset-block-start:0}.teaching-tip-anchor.placement-left.alignment-end,.teaching-tip-anchor.placement-right.alignment-end{--fds-teaching-tip-transform:translateY(0%);inset-block-end:0}.teaching-tip-anchor.placement-left.alignment-center,.teaching-tip-anchor.placement-right.alignment-center{--fds-teaching-tip-transform:translateY(-50%);inset-block-start:50%}</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
closable?: boolean;
|
|
7
|
+
closeOnBackdropClick?: boolean;
|
|
8
|
+
enableClick?: boolean;
|
|
9
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
10
|
+
alignment?: "start" | "center" | "end";
|
|
11
|
+
offset?: number;
|
|
12
|
+
trapFocus?: boolean;
|
|
13
|
+
class?: string;
|
|
14
|
+
wrapperElement?: HTMLDivElement;
|
|
15
|
+
anchorElement?: HTMLDivElement;
|
|
16
|
+
menuElement?: HTMLDivElement;
|
|
17
|
+
backdropElement?: HTMLDivElement;
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
open: CustomEvent<any>;
|
|
21
|
+
close: CustomEvent<any>;
|
|
22
|
+
} & {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {
|
|
26
|
+
default: {};
|
|
27
|
+
override: {};
|
|
28
|
+
flyout: {};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare type TeachingTipWrapperProps = typeof __propDef.props;
|
|
32
|
+
export declare type TeachingTipWrapperEvents = typeof __propDef.events;
|
|
33
|
+
export declare type TeachingTipWrapperSlots = typeof __propDef.slots;
|
|
34
|
+
/**
|
|
35
|
+
* TeachingTips represent a control that displays lightweight UI that is either information, or requires user interaction. Unlike a dialog, a TeachingTip can be dismissed by clicking or tapping outside of it, or pressing the Esc key. [Docs](https://fluent-svelte.vercel.app/docs/components/teaching-tip)
|
|
36
|
+
* - Usage:
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <TeachingTip>
|
|
39
|
+
* <Button>Trigger Button</Button>
|
|
40
|
+
* <svelte:fragment slot="teaching-tip">
|
|
41
|
+
* TeachingTip Contents
|
|
42
|
+
* </svelte:fragment>
|
|
43
|
+
* </TeachingTip>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export default class TeachingTipWrapper extends SvelteComponentTyped<TeachingTipWrapperProps, TeachingTipWrapperEvents, TeachingTipWrapperSlots> {
|
|
47
|
+
}
|
|
48
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as ProgressBar } from "./ProgressBar/ProgressBar.svelte";
|
|
|
7
7
|
export { default as ComboBox } from "./ComboBox/ComboBox.svelte";
|
|
8
8
|
export { default as InfoBadge } from "./InfoBadge/InfoBadge.svelte";
|
|
9
9
|
export { default as Flyout } from "./Flyout/FlyoutWrapper.svelte";
|
|
10
|
+
export { default as TeachingTip } from "./TeachingTip/TeachingTipWrapper.svelte";
|
|
10
11
|
export { default as InfoBar } from "./InfoBar/InfoBar.svelte";
|
|
11
12
|
export { default as TextBox } from "./TextBox/TextBox.svelte";
|
|
12
13
|
export { default as TextBoxButton } from "./TextBox/TextBoxButton.svelte";
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as ProgressBar } from "./ProgressBar/ProgressBar.svelte";
|
|
|
7
7
|
export { default as ComboBox } from "./ComboBox/ComboBox.svelte";
|
|
8
8
|
export { default as InfoBadge } from "./InfoBadge/InfoBadge.svelte";
|
|
9
9
|
export { default as Flyout } from "./Flyout/FlyoutWrapper.svelte";
|
|
10
|
+
export { default as TeachingTip } from "./TeachingTip/TeachingTipWrapper.svelte";
|
|
10
11
|
export { default as InfoBar } from "./InfoBar/InfoBar.svelte";
|
|
11
12
|
export { default as TextBox } from "./TextBox/TextBox.svelte";
|
|
12
13
|
export { default as TextBoxButton } from "./TextBox/TextBoxButton.svelte";
|
package/internal.js
CHANGED
|
@@ -33,7 +33,7 @@ export function externalMouseEvents(node, options = { type: "click", stopPropaga
|
|
|
33
33
|
}
|
|
34
34
|
// Basic wrapper action around focus-trap
|
|
35
35
|
export function focusTrap(node, options) {
|
|
36
|
-
const trap = createFocusTrap(node, (options = { ...options, fallbackFocus: node }));
|
|
36
|
+
const trap = createFocusTrap(node, (options = { allowOutsideClick: true, ...options, fallbackFocus: node }));
|
|
37
37
|
trap.activate();
|
|
38
38
|
return {
|
|
39
39
|
destroy() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fluent-svelte-extra",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"description": "A faithful implementation of Microsoft's Fluent Design System in Svelte.",
|
|
5
5
|
"homepage": "https://github.com/OpenAnime/fluent-svelte-extra",
|
|
6
6
|
"license": "MIT",
|
|
@@ -146,6 +146,10 @@
|
|
|
146
146
|
"./Slider/Slider.scss": "./Slider/Slider.scss",
|
|
147
147
|
"./Slider/Slider.svelte": "./Slider/Slider.svelte",
|
|
148
148
|
"./switchable.css": "./switchable.css",
|
|
149
|
+
"./TeachingTip/TeachingTipSurface.scss": "./TeachingTip/TeachingTipSurface.scss",
|
|
150
|
+
"./TeachingTip/TeachingTipSurface.svelte": "./TeachingTip/TeachingTipSurface.svelte",
|
|
151
|
+
"./TeachingTip/TeachingTipWrapper.scss": "./TeachingTip/TeachingTipWrapper.scss",
|
|
152
|
+
"./TeachingTip/TeachingTipWrapper.svelte": "./TeachingTip/TeachingTipWrapper.svelte",
|
|
149
153
|
"./TextArea/TextArea.scss": "./TextArea/TextArea.scss",
|
|
150
154
|
"./TextArea/TextArea.svelte": "./TextArea/TextArea.svelte",
|
|
151
155
|
"./TextBlock/TextBlock.scss": "./TextBlock/TextBlock.scss",
|