@geoffcox/sterling-svelte 1.0.5 → 1.0.7
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/{Button.svelte.d.ts → dist/Button.svelte.d.ts} +4 -2
- package/{Callout.svelte → dist/Callout.svelte} +17 -13
- package/{Callout.svelte.d.ts → dist/Callout.svelte.d.ts} +4 -2
- package/{Checkbox.svelte.d.ts → dist/Checkbox.svelte.d.ts} +4 -2
- package/{ColorPicker.svelte.d.ts → dist/ColorPicker.svelte.d.ts} +4 -2
- package/{Dialog.svelte → dist/Dialog.svelte} +9 -1
- package/{Dialog.svelte.d.ts → dist/Dialog.svelte.d.ts} +4 -2
- package/{Dropdown.svelte.d.ts → dist/Dropdown.svelte.d.ts} +4 -2
- package/{HexColorSliders.svelte.d.ts → dist/HexColorSliders.svelte.d.ts} +4 -2
- package/{HslColorSliders.svelte.d.ts → dist/HslColorSliders.svelte.d.ts} +4 -2
- package/{Input.svelte.d.ts → dist/Input.svelte.d.ts} +4 -2
- package/{Label.svelte.d.ts → dist/Label.svelte.d.ts} +4 -2
- package/{Link.svelte.d.ts → dist/Link.svelte.d.ts} +4 -2
- package/{List.svelte → dist/List.svelte} +15 -6
- package/{List.svelte.d.ts → dist/List.svelte.d.ts} +4 -2
- package/{List.types.d.ts → dist/List.types.d.ts} +1 -0
- package/{ListItem.svelte.d.ts → dist/ListItem.svelte.d.ts} +4 -2
- package/{Menu.svelte.d.ts → dist/Menu.svelte.d.ts} +4 -2
- package/{MenuBar.svelte.d.ts → dist/MenuBar.svelte.d.ts} +4 -2
- package/{MenuButton.svelte.d.ts → dist/MenuButton.svelte.d.ts} +4 -2
- package/{MenuItem.svelte.d.ts → dist/MenuItem.svelte.d.ts} +4 -2
- package/{MenuItem.types.d.ts → dist/MenuItem.types.d.ts} +1 -0
- package/{MenuItemDisplay.svelte.d.ts → dist/MenuItemDisplay.svelte.d.ts} +4 -2
- package/{MenuSeparator.svelte.d.ts → dist/MenuSeparator.svelte.d.ts} +4 -2
- package/dist/Popover.constants.d.ts +1 -0
- package/{Popover.constants.js → dist/Popover.constants.js} +0 -1
- package/{Popover.svelte → dist/Popover.svelte} +22 -15
- package/{Popover.svelte.d.ts → dist/Popover.svelte.d.ts} +4 -2
- package/dist/Portal.constants.d.ts +2 -0
- package/dist/Portal.constants.js +2 -0
- package/dist/Portal.types.d.ts +6 -0
- package/{Progress.svelte.d.ts → dist/Progress.svelte.d.ts} +4 -2
- package/{Radio.svelte.d.ts → dist/Radio.svelte.d.ts} +4 -2
- package/{RgbColorSliders.svelte.d.ts → dist/RgbColorSliders.svelte.d.ts} +4 -2
- package/{Select.svelte.d.ts → dist/Select.svelte.d.ts} +4 -2
- package/{Slider.svelte.d.ts → dist/Slider.svelte.d.ts} +4 -2
- package/{Switch.svelte.d.ts → dist/Switch.svelte.d.ts} +4 -2
- package/{Tab.svelte.d.ts → dist/Tab.svelte.d.ts} +4 -2
- package/{TabList.svelte.d.ts → dist/TabList.svelte.d.ts} +4 -2
- package/{TabList.types.d.ts → dist/TabList.types.d.ts} +1 -0
- package/{TextArea.svelte.d.ts → dist/TextArea.svelte.d.ts} +4 -2
- package/{Tooltip.svelte.d.ts → dist/Tooltip.svelte.d.ts} +4 -2
- package/{Tree.svelte.d.ts → dist/Tree.svelte.d.ts} +4 -2
- package/{Tree.types.d.ts → dist/Tree.types.d.ts} +1 -0
- package/{TreeChevron.svelte.d.ts → dist/TreeChevron.svelte.d.ts} +4 -2
- package/{TreeItem.svelte.d.ts → dist/TreeItem.svelte.d.ts} +4 -2
- package/{TreeItem.types.d.ts → dist/TreeItem.types.d.ts} +1 -0
- package/dist/TreeItem.types.js +1 -0
- package/{TreeItemDisplay.svelte.d.ts → dist/TreeItemDisplay.svelte.d.ts} +4 -2
- package/{actions → dist/actions}/portal.d.ts +2 -2
- package/{css → dist/css}/Callout.base.css +1 -1
- package/{css → dist/css}/Dialog.base.css +1 -3
- package/{css → dist/css}/Label.base.css +0 -1
- package/{css → dist/css}/Menu.base.css +1 -1
- package/{css → dist/css}/Popover.css +1 -1
- package/{css → dist/css}/Tab.base.css +3 -3
- package/package.json +51 -199
- package/Popover.constants.d.ts +0 -2
- package/css/Popover copy.css +0 -21
- /package/{@types → dist/@types}/clickOutside.d.ts +0 -0
- /package/{Button.constants.d.ts → dist/Button.constants.d.ts} +0 -0
- /package/{Button.constants.js → dist/Button.constants.js} +0 -0
- /package/{Button.svelte → dist/Button.svelte} +0 -0
- /package/{Button.types.d.ts → dist/Button.types.d.ts} +0 -0
- /package/{Button.types.js → dist/Button.types.js} +0 -0
- /package/{Checkbox.svelte → dist/Checkbox.svelte} +0 -0
- /package/{ColorPicker.constants.d.ts → dist/ColorPicker.constants.d.ts} +0 -0
- /package/{ColorPicker.constants.js → dist/ColorPicker.constants.js} +0 -0
- /package/{ColorPicker.svelte → dist/ColorPicker.svelte} +0 -0
- /package/{ColorPicker.types.d.ts → dist/ColorPicker.types.d.ts} +0 -0
- /package/{ColorPicker.types.js → dist/ColorPicker.types.js} +0 -0
- /package/{Dropdown.svelte → dist/Dropdown.svelte} +0 -0
- /package/{HexColorSliders.svelte → dist/HexColorSliders.svelte} +0 -0
- /package/{HslColorSliders.svelte → dist/HslColorSliders.svelte} +0 -0
- /package/{Input.svelte → dist/Input.svelte} +0 -0
- /package/{Label.constants.d.ts → dist/Label.constants.d.ts} +0 -0
- /package/{Label.constants.js → dist/Label.constants.js} +0 -0
- /package/{Label.svelte → dist/Label.svelte} +0 -0
- /package/{Label.types.d.ts → dist/Label.types.d.ts} +0 -0
- /package/{Label.types.js → dist/Label.types.js} +0 -0
- /package/{Link.svelte → dist/Link.svelte} +0 -0
- /package/{List.constants.d.ts → dist/List.constants.d.ts} +0 -0
- /package/{List.constants.js → dist/List.constants.js} +0 -0
- /package/{List.types.js → dist/List.types.js} +0 -0
- /package/{ListItem.svelte → dist/ListItem.svelte} +0 -0
- /package/{Menu.svelte → dist/Menu.svelte} +0 -0
- /package/{MenuBar.constants.d.ts → dist/MenuBar.constants.d.ts} +0 -0
- /package/{MenuBar.constants.js → dist/MenuBar.constants.js} +0 -0
- /package/{MenuBar.svelte → dist/MenuBar.svelte} +0 -0
- /package/{MenuBar.types.d.ts → dist/MenuBar.types.d.ts} +0 -0
- /package/{MenuBar.types.js → dist/MenuBar.types.js} +0 -0
- /package/{MenuButton.svelte → dist/MenuButton.svelte} +0 -0
- /package/{MenuItem.constants.d.ts → dist/MenuItem.constants.d.ts} +0 -0
- /package/{MenuItem.constants.js → dist/MenuItem.constants.js} +0 -0
- /package/{MenuItem.svelte → dist/MenuItem.svelte} +0 -0
- /package/{MenuItem.types.js → dist/MenuItem.types.js} +0 -0
- /package/{MenuItem.utils.d.ts → dist/MenuItem.utils.d.ts} +0 -0
- /package/{MenuItem.utils.js → dist/MenuItem.utils.js} +0 -0
- /package/{MenuItemDisplay.svelte → dist/MenuItemDisplay.svelte} +0 -0
- /package/{MenuSeparator.svelte → dist/MenuSeparator.svelte} +0 -0
- /package/{Popover.types.d.ts → dist/Popover.types.d.ts} +0 -0
- /package/{Popover.types.js → dist/Popover.types.js} +0 -0
- /package/{Progress.types.js → dist/Portal.types.js} +0 -0
- /package/{Progress.constants.d.ts → dist/Progress.constants.d.ts} +0 -0
- /package/{Progress.constants.js → dist/Progress.constants.js} +0 -0
- /package/{Progress.svelte → dist/Progress.svelte} +0 -0
- /package/{Progress.types.d.ts → dist/Progress.types.d.ts} +0 -0
- /package/{TabList.types.js → dist/Progress.types.js} +0 -0
- /package/{Radio.svelte → dist/Radio.svelte} +0 -0
- /package/{RgbColorSliders.svelte → dist/RgbColorSliders.svelte} +0 -0
- /package/{Select.svelte → dist/Select.svelte} +0 -0
- /package/{Slider.svelte → dist/Slider.svelte} +0 -0
- /package/{Switch.svelte → dist/Switch.svelte} +0 -0
- /package/{Tab.svelte → dist/Tab.svelte} +0 -0
- /package/{TabList.constants.d.ts → dist/TabList.constants.d.ts} +0 -0
- /package/{TabList.constants.js → dist/TabList.constants.js} +0 -0
- /package/{TabList.svelte → dist/TabList.svelte} +0 -0
- /package/{TextArea.types.js → dist/TabList.types.js} +0 -0
- /package/{TextArea.constants.d.ts → dist/TextArea.constants.d.ts} +0 -0
- /package/{TextArea.constants.js → dist/TextArea.constants.js} +0 -0
- /package/{TextArea.svelte → dist/TextArea.svelte} +0 -0
- /package/{TextArea.types.d.ts → dist/TextArea.types.d.ts} +0 -0
- /package/{Tree.types.js → dist/TextArea.types.js} +0 -0
- /package/{Tooltip.svelte → dist/Tooltip.svelte} +0 -0
- /package/{Tree.constants.d.ts → dist/Tree.constants.d.ts} +0 -0
- /package/{Tree.constants.js → dist/Tree.constants.js} +0 -0
- /package/{Tree.svelte → dist/Tree.svelte} +0 -0
- /package/{TreeItem.types.js → dist/Tree.types.js} +0 -0
- /package/{TreeChevron.svelte → dist/TreeChevron.svelte} +0 -0
- /package/{TreeItem.constants.d.ts → dist/TreeItem.constants.d.ts} +0 -0
- /package/{TreeItem.constants.js → dist/TreeItem.constants.js} +0 -0
- /package/{TreeItem.svelte → dist/TreeItem.svelte} +0 -0
- /package/{TreeItemDisplay.svelte → dist/TreeItemDisplay.svelte} +0 -0
- /package/{actions → dist/actions}/applyLightDarkMode.d.ts +0 -0
- /package/{actions → dist/actions}/applyLightDarkMode.js +0 -0
- /package/{actions → dist/actions}/clickOutside.d.ts +0 -0
- /package/{actions → dist/actions}/clickOutside.js +0 -0
- /package/{actions → dist/actions}/forwardEvents.d.ts +0 -0
- /package/{actions → dist/actions}/forwardEvents.js +0 -0
- /package/{actions → dist/actions}/portal.js +0 -0
- /package/{actions → dist/actions}/trapKeyboardFocus.d.ts +0 -0
- /package/{actions → dist/actions}/trapKeyboardFocus.js +0 -0
- /package/{css → dist/css}/Button.base.css +0 -0
- /package/{css → dist/css}/Button.colorful.css +0 -0
- /package/{css → dist/css}/Button.css +0 -0
- /package/{css → dist/css}/Button.secondary.colorful.css +0 -0
- /package/{css → dist/css}/Button.secondary.css +0 -0
- /package/{css → dist/css}/Button.shapes.css +0 -0
- /package/{css → dist/css}/Button.tool.colorful.css +0 -0
- /package/{css → dist/css}/Button.tool.css +0 -0
- /package/{css → dist/css}/Callout.colorful.css +0 -0
- /package/{css → dist/css}/Callout.css +0 -0
- /package/{css → dist/css}/Checkbox.base.css +0 -0
- /package/{css → dist/css}/Checkbox.colorful.css +0 -0
- /package/{css → dist/css}/Checkbox.css +0 -0
- /package/{css → dist/css}/ColorPicker.base.css +0 -0
- /package/{css → dist/css}/ColorPicker.css +0 -0
- /package/{css → dist/css}/Dialog.css +0 -0
- /package/{css → dist/css}/Dropdown.base.css +0 -0
- /package/{css → dist/css}/Dropdown.colorful.css +0 -0
- /package/{css → dist/css}/Dropdown.css +0 -0
- /package/{css → dist/css}/HexColorSliders.base.css +0 -0
- /package/{css → dist/css}/HexColorSliders.css +0 -0
- /package/{css → dist/css}/HslColorSliders.base.css +0 -0
- /package/{css → dist/css}/HslColorSliders.css +0 -0
- /package/{css → dist/css}/Input.base.css +0 -0
- /package/{css → dist/css}/Input.colorful.css +0 -0
- /package/{css → dist/css}/Input.composed.css +0 -0
- /package/{css → dist/css}/Input.css +0 -0
- /package/{css → dist/css}/Label.boxed.colorful.css +0 -0
- /package/{css → dist/css}/Label.boxed.css +0 -0
- /package/{css → dist/css}/Label.colorful.css +0 -0
- /package/{css → dist/css}/Label.css +0 -0
- /package/{css → dist/css}/Link.base.css +0 -0
- /package/{css → dist/css}/Link.colorful.css +0 -0
- /package/{css → dist/css}/Link.css +0 -0
- /package/{css → dist/css}/Link.ghost.colorful.css +0 -0
- /package/{css → dist/css}/Link.ghost.css +0 -0
- /package/{css → dist/css}/Link.undecorated.colorful.css +0 -0
- /package/{css → dist/css}/Link.undecorated.css +0 -0
- /package/{css → dist/css}/List.base.css +0 -0
- /package/{css → dist/css}/List.css +0 -0
- /package/{css → dist/css}/ListItem.base.css +0 -0
- /package/{css → dist/css}/ListItem.css +0 -0
- /package/{css → dist/css}/Menu.css +0 -0
- /package/{css → dist/css}/MenuBar.base.css +0 -0
- /package/{css → dist/css}/MenuBar.css +0 -0
- /package/{css → dist/css}/MenuButton.base.css +0 -0
- /package/{css → dist/css}/MenuButton.css +0 -0
- /package/{css → dist/css}/MenuItem.base.css +0 -0
- /package/{css → dist/css}/MenuItem.css +0 -0
- /package/{css → dist/css}/MenuItemDisplay.base.css +0 -0
- /package/{css → dist/css}/MenuItemDisplay.css +0 -0
- /package/{css → dist/css}/MenuSeparator.base.css +0 -0
- /package/{css → dist/css}/MenuSeparator.css +0 -0
- /package/{css → dist/css}/Progress.base.css +0 -0
- /package/{css → dist/css}/Progress.css +0 -0
- /package/{css → dist/css}/Radio.base.css +0 -0
- /package/{css → dist/css}/Radio.button.css +0 -0
- /package/{css → dist/css}/Radio.colorful.css +0 -0
- /package/{css → dist/css}/Radio.css +0 -0
- /package/{css → dist/css}/RgbColorSliders.base.css +0 -0
- /package/{css → dist/css}/RgbColorSliders.css +0 -0
- /package/{css → dist/css}/Select.base.css +0 -0
- /package/{css → dist/css}/Select.colorful.css +0 -0
- /package/{css → dist/css}/Select.composed.css +0 -0
- /package/{css → dist/css}/Select.css +0 -0
- /package/{css → dist/css}/Slider.base.css +0 -0
- /package/{css → dist/css}/Slider.colorful.css +0 -0
- /package/{css → dist/css}/Slider.composed.css +0 -0
- /package/{css → dist/css}/Slider.css +0 -0
- /package/{css → dist/css}/Switch.base.css +0 -0
- /package/{css → dist/css}/Switch.colorful.css +0 -0
- /package/{css → dist/css}/Switch.css +0 -0
- /package/{css → dist/css}/Tab.colorful.css +0 -0
- /package/{css → dist/css}/Tab.css +0 -0
- /package/{css → dist/css}/TabList.base.css +0 -0
- /package/{css → dist/css}/TabList.css +0 -0
- /package/{css → dist/css}/TextArea.base.css +0 -0
- /package/{css → dist/css}/TextArea.colorful.css +0 -0
- /package/{css → dist/css}/TextArea.composed.css +0 -0
- /package/{css → dist/css}/TextArea.css +0 -0
- /package/{css → dist/css}/Tooltip.base.css +0 -0
- /package/{css → dist/css}/Tooltip.css +0 -0
- /package/{css → dist/css}/Tree.base.css +0 -0
- /package/{css → dist/css}/Tree.composed.css +0 -0
- /package/{css → dist/css}/Tree.css +0 -0
- /package/{css → dist/css}/TreeChevron.base.css +0 -0
- /package/{css → dist/css}/TreeChevron.css +0 -0
- /package/{css → dist/css}/TreeItem.base.css +0 -0
- /package/{css → dist/css}/TreeItem.css +0 -0
- /package/{css → dist/css}/TreeItemDisplay.base.css +0 -0
- /package/{css → dist/css}/TreeItemDisplay.colorful.css +0 -0
- /package/{css → dist/css}/TreeItemDisplay.css +0 -0
- /package/{css → dist/css}/dark-mode.css +0 -0
- /package/{css → dist/css}/light-mode.css +0 -0
- /package/{css → dist/css}/sterling.css +0 -0
- /package/{idGenerator.d.ts → dist/idGenerator.d.ts} +0 -0
- /package/{idGenerator.js → dist/idGenerator.js} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{mediaQueries → dist/mediaQueries}/prefersColorSchemeDark.d.ts +0 -0
- /package/{mediaQueries → dist/mediaQueries}/prefersColorSchemeDark.js +0 -0
- /package/{mediaQueries → dist/mediaQueries}/prefersReducedMotion.d.ts +0 -0
- /package/{mediaQueries → dist/mediaQueries}/prefersReducedMotion.js +0 -0
- /package/{mediaQueries → dist/mediaQueries}/usingKeyboard.d.ts +0 -0
- /package/{mediaQueries → dist/mediaQueries}/usingKeyboard.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -50,12 +50,14 @@ declare const __propDef: {
|
|
|
50
50
|
variant: string;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
exports?: undefined;
|
|
54
|
+
bindings?: undefined;
|
|
53
55
|
};
|
|
54
56
|
export type ButtonProps = typeof __propDef.props;
|
|
55
57
|
export type ButtonEvents = typeof __propDef.events;
|
|
56
58
|
export type ButtonSlots = typeof __propDef.slots;
|
|
57
59
|
/** A styled HTML button element. */
|
|
58
|
-
export default class Button extends
|
|
60
|
+
export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
59
61
|
get click(): () => void;
|
|
60
62
|
get blur(): () => void;
|
|
61
63
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>import { onMount } from 'svelte';
|
|
1
|
+
<script>import { getContext, onMount, tick } from 'svelte';
|
|
2
2
|
import { arrow, autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
|
|
3
3
|
import { portal } from './actions/portal';
|
|
4
|
-
import { STERLING_PORTAL_HOST_ID } from './Popover.constants';
|
|
5
4
|
import { fade } from 'svelte/transition';
|
|
6
5
|
import { prefersReducedMotion } from './mediaQueries/prefersReducedMotion';
|
|
6
|
+
import { STERLING_PORTAL_HOST_ID, STERLING_PORTAL_CONTEXT_ID } from './Portal.constants';
|
|
7
7
|
// ----- Props ----- //
|
|
8
8
|
/** Conditionally renders content based on open. */
|
|
9
9
|
export let conditionalRender = true;
|
|
@@ -28,23 +28,27 @@ let popupPosition = { x: 0, y: 0 };
|
|
|
28
28
|
$: floatingUIPlacement = placement;
|
|
29
29
|
let bodyHeight = 0;
|
|
30
30
|
let resizeObserver = undefined;
|
|
31
|
+
const { portalHost: contextPortalHost } = getContext(STERLING_PORTAL_CONTEXT_ID) || {
|
|
32
|
+
portalHost: undefined
|
|
33
|
+
};
|
|
31
34
|
// ----- Portal Host ----- //
|
|
32
|
-
const ensurePortalHost = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const ensurePortalHost = async () => {
|
|
36
|
+
await tick();
|
|
37
|
+
// use the host set from context, usually set from a Dialog
|
|
38
|
+
let host = $contextPortalHost;
|
|
39
|
+
// use or create the sterling portal host
|
|
40
|
+
if (!host && globalThis?.document) {
|
|
41
|
+
host = globalThis.document.querySelector(`#${STERLING_PORTAL_HOST_ID}`);
|
|
42
|
+
// fallback to creating the sterling portal host
|
|
38
43
|
if (!host) {
|
|
39
|
-
host = document.createElement('div');
|
|
44
|
+
host = globalThis.document.createElement('div');
|
|
40
45
|
host.id = STERLING_PORTAL_HOST_ID;
|
|
41
46
|
host.style.overflow = 'visible';
|
|
42
|
-
document.body.append(host);
|
|
47
|
+
globalThis.document.body.append(host);
|
|
43
48
|
}
|
|
44
|
-
portalHost = host;
|
|
45
49
|
}
|
|
50
|
+
portalHost = host;
|
|
46
51
|
};
|
|
47
|
-
// ----- Body Height Change ----- //
|
|
48
52
|
// ----- Position ----- //
|
|
49
53
|
$: middleware = [
|
|
50
54
|
offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }),
|
|
@@ -142,7 +146,7 @@ ensurePortalHost();
|
|
|
142
146
|
|
|
143
147
|
{#if open || !conditionalRender}
|
|
144
148
|
<div
|
|
145
|
-
use:portal={{ target: portalHost
|
|
149
|
+
use:portal={{ target: portalHost }}
|
|
146
150
|
class="sterling-callout-portal"
|
|
147
151
|
transition:fadeMotion|global={{ duration: 250 }}
|
|
148
152
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -45,10 +45,12 @@ declare const __propDef: {
|
|
|
45
45
|
slots: {
|
|
46
46
|
default: {};
|
|
47
47
|
};
|
|
48
|
+
exports?: undefined;
|
|
49
|
+
bindings?: undefined;
|
|
48
50
|
};
|
|
49
51
|
export type CalloutProps = typeof __propDef.props;
|
|
50
52
|
export type CalloutEvents = typeof __propDef.events;
|
|
51
53
|
export type CalloutSlots = typeof __propDef.slots;
|
|
52
|
-
export default class Callout extends
|
|
54
|
+
export default class Callout extends SvelteComponent<CalloutProps, CalloutEvents, CalloutSlots> {
|
|
53
55
|
}
|
|
54
56
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -48,12 +48,14 @@ declare const __propDef: {
|
|
|
48
48
|
variant: string;
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
+
exports?: undefined;
|
|
52
|
+
bindings?: undefined;
|
|
51
53
|
};
|
|
52
54
|
export type CheckboxProps = typeof __propDef.props;
|
|
53
55
|
export type CheckboxEvents = typeof __propDef.events;
|
|
54
56
|
export type CheckboxSlots = typeof __propDef.slots;
|
|
55
57
|
/** A styled HTML input type=checkbox element. */
|
|
56
|
-
export default class Checkbox extends
|
|
58
|
+
export default class Checkbox extends SvelteComponent<CheckboxProps, CheckboxEvents, CheckboxSlots> {
|
|
57
59
|
get blur(): () => void;
|
|
58
60
|
get click(): () => void;
|
|
59
61
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -39,10 +39,12 @@ declare const __propDef: {
|
|
|
39
39
|
[evt: string]: CustomEvent<any>;
|
|
40
40
|
};
|
|
41
41
|
slots: {};
|
|
42
|
+
exports?: undefined;
|
|
43
|
+
bindings?: undefined;
|
|
42
44
|
};
|
|
43
45
|
export type ColorPickerProps = typeof __propDef.props;
|
|
44
46
|
export type ColorPickerEvents = typeof __propDef.events;
|
|
45
47
|
export type ColorPickerSlots = typeof __propDef.slots;
|
|
46
|
-
export default class ColorPicker extends
|
|
48
|
+
export default class ColorPicker extends SvelteComponent<ColorPickerProps, ColorPickerEvents, ColorPickerSlots> {
|
|
47
49
|
}
|
|
48
50
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
<script>import { onMount, tick } from 'svelte';
|
|
1
|
+
<script>import { onMount, setContext, tick } from 'svelte';
|
|
2
2
|
import Button from './Button.svelte';
|
|
3
|
+
import { STERLING_PORTAL_CONTEXT_ID } from './Portal.constants';
|
|
4
|
+
import { writable } from 'svelte/store';
|
|
3
5
|
const dialogFadeDuration = 250;
|
|
4
6
|
// ----- Props ----- //
|
|
5
7
|
/** When true, clicking outside the dialog causes the dialog close. */
|
|
@@ -19,6 +21,9 @@ let dialogRef;
|
|
|
19
21
|
let contentRef;
|
|
20
22
|
let formRef;
|
|
21
23
|
let closing = false;
|
|
24
|
+
const portalHostStore = writable(undefined);
|
|
25
|
+
// ----- Context ----- //
|
|
26
|
+
setContext(STERLING_PORTAL_CONTEXT_ID, { portalHost: portalHostStore });
|
|
22
27
|
// ----- Event Handlers ----- //
|
|
23
28
|
const onDocumentClick = (event) => {
|
|
24
29
|
// as tracking clicks outside the dialog is only active while the dialog is open
|
|
@@ -102,11 +107,14 @@ $: {
|
|
|
102
107
|
}
|
|
103
108
|
onMount(() => {
|
|
104
109
|
updateDialog(open);
|
|
110
|
+
// Use the dialog for any element portals
|
|
111
|
+
portalHostStore.set(dialogRef);
|
|
105
112
|
dialogRef.addEventListener('cancel', onCancel);
|
|
106
113
|
dialogRef.addEventListener('close', onClose);
|
|
107
114
|
return () => {
|
|
108
115
|
dialogRef?.removeEventListener('cancel', onCancel);
|
|
109
116
|
dialogRef?.removeEventListener('close', onClose);
|
|
117
|
+
portalHostStore.set(undefined);
|
|
110
118
|
};
|
|
111
119
|
});
|
|
112
120
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -20,6 +20,8 @@ declare const __propDef: {
|
|
|
20
20
|
body: {};
|
|
21
21
|
footer: {};
|
|
22
22
|
};
|
|
23
|
+
exports?: undefined;
|
|
24
|
+
bindings?: undefined;
|
|
23
25
|
};
|
|
24
26
|
export type DialogProps = typeof __propDef.props;
|
|
25
27
|
export type DialogEvents = typeof __propDef.events;
|
|
@@ -30,6 +32,6 @@ export type DialogSlots = typeof __propDef.slots;
|
|
|
30
32
|
* - Slots for typical dialog content.
|
|
31
33
|
* - Props and events to make using <dialog> easier
|
|
32
34
|
*/
|
|
33
|
-
export default class Dialog extends
|
|
35
|
+
export default class Dialog extends SvelteComponent<DialogProps, DialogEvents, DialogSlots> {
|
|
34
36
|
}
|
|
35
37
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -63,11 +63,13 @@ declare const __propDef: {
|
|
|
63
63
|
variant: string;
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
+
exports?: undefined;
|
|
67
|
+
bindings?: undefined;
|
|
66
68
|
};
|
|
67
69
|
export type DropdownProps = typeof __propDef.props;
|
|
68
70
|
export type DropdownEvents = typeof __propDef.events;
|
|
69
71
|
export type DropdownSlots = typeof __propDef.slots;
|
|
70
|
-
export default class Dropdown extends
|
|
72
|
+
export default class Dropdown extends SvelteComponent<DropdownProps, DropdownEvents, DropdownSlots> {
|
|
71
73
|
get click(): () => void;
|
|
72
74
|
get blur(): () => void;
|
|
73
75
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -40,10 +40,12 @@ declare const __propDef: {
|
|
|
40
40
|
[evt: string]: CustomEvent<any>;
|
|
41
41
|
};
|
|
42
42
|
slots: {};
|
|
43
|
+
exports?: undefined;
|
|
44
|
+
bindings?: undefined;
|
|
43
45
|
};
|
|
44
46
|
export type HexColorSlidersProps = typeof __propDef.props;
|
|
45
47
|
export type HexColorSlidersEvents = typeof __propDef.events;
|
|
46
48
|
export type HexColorSlidersSlots = typeof __propDef.slots;
|
|
47
|
-
export default class HexColorSliders extends
|
|
49
|
+
export default class HexColorSliders extends SvelteComponent<HexColorSlidersProps, HexColorSlidersEvents, HexColorSlidersSlots> {
|
|
48
50
|
}
|
|
49
51
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -40,10 +40,12 @@ declare const __propDef: {
|
|
|
40
40
|
[evt: string]: CustomEvent<any>;
|
|
41
41
|
};
|
|
42
42
|
slots: {};
|
|
43
|
+
exports?: undefined;
|
|
44
|
+
bindings?: undefined;
|
|
43
45
|
};
|
|
44
46
|
export type HslColorSlidersProps = typeof __propDef.props;
|
|
45
47
|
export type HslColorSlidersEvents = typeof __propDef.events;
|
|
46
48
|
export type HslColorSlidersSlots = typeof __propDef.slots;
|
|
47
|
-
export default class HslColorSliders extends
|
|
49
|
+
export default class HslColorSliders extends SvelteComponent<HslColorSlidersProps, HslColorSlidersEvents, HslColorSlidersSlots> {
|
|
48
50
|
}
|
|
49
51
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -57,11 +57,13 @@ declare const __propDef: {
|
|
|
57
57
|
variant: string;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
exports?: undefined;
|
|
61
|
+
bindings?: undefined;
|
|
60
62
|
};
|
|
61
63
|
export type InputProps = typeof __propDef.props;
|
|
62
64
|
export type InputEvents = typeof __propDef.events;
|
|
63
65
|
export type InputSlots = typeof __propDef.slots;
|
|
64
|
-
export default class Input extends
|
|
66
|
+
export default class Input extends SvelteComponent<InputProps, InputEvents, InputSlots> {
|
|
65
67
|
get blur(): () => void;
|
|
66
68
|
get click(): () => void;
|
|
67
69
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -68,11 +68,13 @@ declare const __propDef: {
|
|
|
68
68
|
variant: string;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
+
exports?: undefined;
|
|
72
|
+
bindings?: undefined;
|
|
71
73
|
};
|
|
72
74
|
export type LabelProps = typeof __propDef.props;
|
|
73
75
|
export type LabelEvents = typeof __propDef.events;
|
|
74
76
|
export type LabelSlots = typeof __propDef.slots;
|
|
75
|
-
export default class Label extends
|
|
77
|
+
export default class Label extends SvelteComponent<LabelProps, LabelEvents, LabelSlots> {
|
|
76
78
|
get click(): () => void;
|
|
77
79
|
get blur(): () => void;
|
|
78
80
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -51,11 +51,13 @@ declare const __propDef: {
|
|
|
51
51
|
variant: string;
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
+
exports?: undefined;
|
|
55
|
+
bindings?: undefined;
|
|
54
56
|
};
|
|
55
57
|
export type LinkProps = typeof __propDef.props;
|
|
56
58
|
export type LinkEvents = typeof __propDef.events;
|
|
57
59
|
export type LinkSlots = typeof __propDef.slots;
|
|
58
|
-
export default class Link extends
|
|
60
|
+
export default class Link extends SvelteComponent<LinkProps, LinkEvents, LinkSlots> {
|
|
59
61
|
get blur(): () => void;
|
|
60
62
|
get click(): () => void;
|
|
61
63
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -75,7 +75,7 @@ const selectItem = (value, element) => {
|
|
|
75
75
|
element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
76
76
|
};
|
|
77
77
|
export const selectFirstItem = () => {
|
|
78
|
-
let candidate = listRef?.
|
|
78
|
+
let candidate = listRef?.querySelector('[data-value][role=listitem]');
|
|
79
79
|
while (candidate && !isElementListItem(candidate)) {
|
|
80
80
|
candidate = candidate.nextElementSibling;
|
|
81
81
|
}
|
|
@@ -113,7 +113,8 @@ export const selectNextItem = () => {
|
|
|
113
113
|
return false;
|
|
114
114
|
};
|
|
115
115
|
export const selectLastItem = () => {
|
|
116
|
-
let candidate = listRef?.
|
|
116
|
+
let candidate = listRef?.querySelector('[data-value][role=listitem]:last-of-type');
|
|
117
|
+
console.log('in selectLastItem', candidate);
|
|
117
118
|
while (candidate && !isElementListItem(candidate)) {
|
|
118
119
|
candidate = candidate.previousElementSibling;
|
|
119
120
|
}
|
|
@@ -153,28 +154,36 @@ const onKeydown = (event) => {
|
|
|
153
154
|
return false;
|
|
154
155
|
case 'ArrowLeft':
|
|
155
156
|
if (horizontal) {
|
|
156
|
-
selectedValue !== undefined
|
|
157
|
+
selectedValue !== undefined && selectedValue.length > 0
|
|
158
|
+
? selectPreviousItem()
|
|
159
|
+
: selectLastItem();
|
|
157
160
|
}
|
|
158
161
|
event.preventDefault();
|
|
159
162
|
event.stopPropagation();
|
|
160
163
|
return false;
|
|
161
164
|
case 'ArrowRight':
|
|
162
165
|
if (horizontal) {
|
|
163
|
-
selectedValue !== undefined
|
|
166
|
+
selectedValue !== undefined && selectedValue.length > 0
|
|
167
|
+
? selectNextItem()
|
|
168
|
+
: selectFirstItem();
|
|
164
169
|
}
|
|
165
170
|
event.preventDefault();
|
|
166
171
|
event.stopPropagation();
|
|
167
172
|
return false;
|
|
168
173
|
case 'ArrowUp':
|
|
169
174
|
if (!horizontal) {
|
|
170
|
-
selectedValue !== undefined
|
|
175
|
+
selectedValue !== undefined && selectedValue.length > 0
|
|
176
|
+
? selectPreviousItem()
|
|
177
|
+
: selectLastItem();
|
|
171
178
|
}
|
|
172
179
|
event.preventDefault();
|
|
173
180
|
event.stopPropagation();
|
|
174
181
|
return false;
|
|
175
182
|
case 'ArrowDown':
|
|
176
183
|
if (!horizontal) {
|
|
177
|
-
selectedValue !== undefined
|
|
184
|
+
selectedValue !== undefined && selectedValue.length > 0
|
|
185
|
+
? selectNextItem()
|
|
186
|
+
: selectFirstItem();
|
|
178
187
|
}
|
|
179
188
|
event.preventDefault();
|
|
180
189
|
event.stopPropagation();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -55,12 +55,14 @@ declare const __propDef: {
|
|
|
55
55
|
variant: string;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
+
exports?: undefined;
|
|
59
|
+
bindings?: undefined;
|
|
58
60
|
};
|
|
59
61
|
export type ListProps = typeof __propDef.props;
|
|
60
62
|
export type ListEvents = typeof __propDef.events;
|
|
61
63
|
export type ListSlots = typeof __propDef.slots;
|
|
62
64
|
/** A list of items where a single item can be selected. */
|
|
63
|
-
export default class List extends
|
|
65
|
+
export default class List extends SvelteComponent<ListProps, ListEvents, ListSlots> {
|
|
64
66
|
get blur(): () => void;
|
|
65
67
|
get click(): () => void;
|
|
66
68
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -53,11 +53,13 @@ declare const __propDef: {
|
|
|
53
53
|
variant: string;
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
+
exports?: undefined;
|
|
57
|
+
bindings?: undefined;
|
|
56
58
|
};
|
|
57
59
|
export type ListItemProps = typeof __propDef.props;
|
|
58
60
|
export type ListItemEvents = typeof __propDef.events;
|
|
59
61
|
export type ListItemSlots = typeof __propDef.slots;
|
|
60
|
-
export default class ListItem extends
|
|
62
|
+
export default class ListItem extends SvelteComponent<ListItemProps, ListItemEvents, ListItemSlots> {
|
|
61
63
|
get click(): () => void;
|
|
62
64
|
get blur(): () => void;
|
|
63
65
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -46,11 +46,13 @@ declare const __propDef: {
|
|
|
46
46
|
variant: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
exports?: undefined;
|
|
50
|
+
bindings?: undefined;
|
|
49
51
|
};
|
|
50
52
|
export type MenuProps = typeof __propDef.props;
|
|
51
53
|
export type MenuEvents = typeof __propDef.events;
|
|
52
54
|
export type MenuSlots = typeof __propDef.slots;
|
|
53
|
-
export default class Menu extends
|
|
55
|
+
export default class Menu extends SvelteComponent<MenuProps, MenuEvents, MenuSlots> {
|
|
54
56
|
get blur(): () => void;
|
|
55
57
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
56
58
|
get focusFirstMenuItem(): () => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -45,11 +45,13 @@ declare const __propDef: {
|
|
|
45
45
|
variant: string;
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
+
exports?: undefined;
|
|
49
|
+
bindings?: undefined;
|
|
48
50
|
};
|
|
49
51
|
export type MenuBarProps = typeof __propDef.props;
|
|
50
52
|
export type MenuBarEvents = typeof __propDef.events;
|
|
51
53
|
export type MenuBarSlots = typeof __propDef.slots;
|
|
52
|
-
export default class MenuBar extends
|
|
54
|
+
export default class MenuBar extends SvelteComponent<MenuBarProps, MenuBarEvents, MenuBarSlots> {
|
|
53
55
|
get blur(): () => void;
|
|
54
56
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
55
57
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -56,12 +56,14 @@ declare const __propDef: {
|
|
|
56
56
|
};
|
|
57
57
|
items: {};
|
|
58
58
|
};
|
|
59
|
+
exports?: undefined;
|
|
60
|
+
bindings?: undefined;
|
|
59
61
|
};
|
|
60
62
|
export type MenuButtonProps = typeof __propDef.props;
|
|
61
63
|
export type MenuButtonEvents = typeof __propDef.events;
|
|
62
64
|
export type MenuButtonSlots = typeof __propDef.slots;
|
|
63
65
|
/** A Button that displays a context menu when clicked. */
|
|
64
|
-
export default class MenuButton extends
|
|
66
|
+
export default class MenuButton extends SvelteComponent<MenuButtonProps, MenuButtonEvents, MenuButtonSlots> {
|
|
65
67
|
get click(): () => void;
|
|
66
68
|
get blur(): () => void;
|
|
67
69
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -69,11 +69,13 @@ declare const __propDef: {
|
|
|
69
69
|
disabled: boolean;
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
exports?: undefined;
|
|
73
|
+
bindings?: undefined;
|
|
72
74
|
};
|
|
73
75
|
export type MenuItemProps = typeof __propDef.props;
|
|
74
76
|
export type MenuItemEvents = typeof __propDef.events;
|
|
75
77
|
export type MenuItemSlots = typeof __propDef.slots;
|
|
76
|
-
export default class MenuItem extends
|
|
78
|
+
export default class MenuItem extends SvelteComponent<MenuItemProps, MenuItemEvents, MenuItemSlots> {
|
|
77
79
|
get blur(): () => void;
|
|
78
80
|
get click(): () => void;
|
|
79
81
|
get focus(): (options?: FocusOptions | undefined) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
/** When true, displays the menu item as checked. */ checked?: boolean | undefined;
|
|
@@ -28,10 +28,12 @@ declare const __propDef: {
|
|
|
28
28
|
variant: string;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
+
exports?: {} | undefined;
|
|
32
|
+
bindings?: string | undefined;
|
|
31
33
|
};
|
|
32
34
|
export type MenuItemDisplayProps = typeof __propDef.props;
|
|
33
35
|
export type MenuItemDisplayEvents = typeof __propDef.events;
|
|
34
36
|
export type MenuItemDisplaySlots = typeof __propDef.slots;
|
|
35
|
-
export default class MenuItemDisplay extends
|
|
37
|
+
export default class MenuItemDisplay extends SvelteComponent<MenuItemDisplayProps, MenuItemDisplayEvents, MenuItemDisplaySlots> {
|
|
36
38
|
}
|
|
37
39
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
@@ -8,11 +8,13 @@ declare const __propDef: {
|
|
|
8
8
|
[evt: string]: CustomEvent<any>;
|
|
9
9
|
};
|
|
10
10
|
slots: {};
|
|
11
|
+
exports?: undefined;
|
|
12
|
+
bindings?: undefined;
|
|
11
13
|
};
|
|
12
14
|
export type MenuSeparatorProps = typeof __propDef.props;
|
|
13
15
|
export type MenuSeparatorEvents = typeof __propDef.events;
|
|
14
16
|
export type MenuSeparatorSlots = typeof __propDef.slots;
|
|
15
17
|
/** A styled line to visually separate groups of menu items in a menu. */
|
|
16
|
-
export default class MenuSeparator extends
|
|
18
|
+
export default class MenuSeparator extends SvelteComponent<MenuSeparatorProps, MenuSeparatorEvents, MenuSeparatorSlots> {
|
|
17
19
|
}
|
|
18
20
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const POPOVER_PLACEMENTS: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script>import { onMount } from 'svelte';
|
|
1
|
+
<script>import { getContext, onMount, tick } from 'svelte';
|
|
2
2
|
import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
|
|
3
3
|
import { portal } from './actions/portal';
|
|
4
|
-
import { STERLING_PORTAL_HOST_ID } from './
|
|
4
|
+
import { STERLING_PORTAL_HOST_ID, STERLING_PORTAL_CONTEXT_ID } from './Portal.constants';
|
|
5
5
|
// ----- Props ----- //
|
|
6
6
|
/** When true, content is rendered only when the popover is open. */
|
|
7
7
|
export let conditionalRender = true;
|
|
@@ -25,22 +25,32 @@ let popupPosition = { x: 0, y: 0 };
|
|
|
25
25
|
$: floatingUIPlacement = placement;
|
|
26
26
|
let bodyHeight = 0;
|
|
27
27
|
let resizeObserver = undefined;
|
|
28
|
+
const { portalHost: contextPortalHost } = getContext(STERLING_PORTAL_CONTEXT_ID) || {
|
|
29
|
+
portalHost: undefined
|
|
30
|
+
};
|
|
28
31
|
// ----- Portal Host ----- //
|
|
29
|
-
const ensurePortalHost = () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const ensurePortalHost = async () => {
|
|
33
|
+
await tick();
|
|
34
|
+
// use the host set from context, usually set from a Dialog
|
|
35
|
+
let host = $contextPortalHost;
|
|
36
|
+
// use or create the sterling portal host
|
|
37
|
+
if (!host && globalThis?.document) {
|
|
38
|
+
host = globalThis.document.querySelector(`#${STERLING_PORTAL_HOST_ID}`);
|
|
39
|
+
// fallback to creating the sterling portal host
|
|
35
40
|
if (!host) {
|
|
36
|
-
host = document.createElement('div');
|
|
41
|
+
host = globalThis.document.createElement('div');
|
|
37
42
|
host.id = STERLING_PORTAL_HOST_ID;
|
|
38
43
|
host.style.overflow = 'visible';
|
|
39
|
-
document.body.append(host);
|
|
44
|
+
globalThis.document.body.append(host);
|
|
40
45
|
}
|
|
41
|
-
portalHost = host;
|
|
42
46
|
}
|
|
47
|
+
portalHost = host;
|
|
43
48
|
};
|
|
49
|
+
$: {
|
|
50
|
+
if ($contextPortalHost || !$contextPortalHost) {
|
|
51
|
+
ensurePortalHost();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
44
54
|
// ----- Position ----- //
|
|
45
55
|
$: middleware = [offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }), flip()];
|
|
46
56
|
const computePopoverPosition = async () => {
|
|
@@ -87,10 +97,7 @@ ensurePortalHost();
|
|
|
87
97
|
</script>
|
|
88
98
|
|
|
89
99
|
{#if open || !conditionalRender}
|
|
90
|
-
<div
|
|
91
|
-
use:portal={{ target: portalHost ?? globalThis?.document?.body }}
|
|
92
|
-
class="sterling-popover-portal"
|
|
93
|
-
>
|
|
100
|
+
<div use:portal={{ target: portalHost }} class="sterling-popover-portal">
|
|
94
101
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
95
102
|
<div
|
|
96
103
|
bind:this={popupRef}
|