@marianmeres/stuic 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppShell/AppShell.svelte +11 -6
- package/dist/components/AppShell/AppShell.svelte.d.ts +1 -0
- package/dist/components/Drawer/Drawer.svelte +7 -10
- package/dist/components/Expandable/Expandable.svelte +54 -0
- package/dist/components/Expandable/Expandable.svelte.d.ts +27 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<script context="module">export const appShellSetHtmlBodyHeight = () => {
|
|
2
|
+
const _set = (flag) => {
|
|
3
|
+
document.body.style.height = flag ? "100vh" : "auto";
|
|
4
|
+
document.body.style.overflow = flag ? "hidden" : "visible";
|
|
5
|
+
};
|
|
6
|
+
_set(true);
|
|
7
|
+
return () => _set(false);
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
1
11
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
12
|
import { twMerge } from "tailwind-merge";
|
|
3
13
|
const dispatch = createEventDispatcher();
|
|
@@ -193,9 +203,4 @@ Then update your global stylesheet with the following. This will disable overflo
|
|
|
193
203
|
html and body tags to prevent duplicate scroll bars.
|
|
194
204
|
|
|
195
205
|
html, body { @apply h-full overflow-hidden; }
|
|
196
|
-
|
|
197
|
-
:global(html),
|
|
198
|
-
:global(body) {
|
|
199
|
-
height: 100vh !important;
|
|
200
|
-
overflow: hidden !important;
|
|
201
|
-
}</style>
|
|
206
|
+
*/</style>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script context="module">import { createClog } from "@marianmeres/clog";
|
|
2
2
|
import { createSwitchStore } from "@marianmeres/switch-store";
|
|
3
3
|
import { createEventDispatcher } from "svelte";
|
|
4
|
-
import {
|
|
4
|
+
import { fly } from "svelte/transition";
|
|
5
5
|
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { clickOutside } from "../../actions/click-outside.js";
|
|
6
7
|
import { prefersReducedMotionStore } from "../../utils/prefers-reduced-motion.js";
|
|
7
8
|
import Backdrop from "../Backdrop/Backdrop.svelte";
|
|
8
|
-
import { clickOutside } from "../../actions/click-outside.js";
|
|
9
9
|
export const createDrawerStore = (open = false) => createSwitchStore(open);
|
|
10
10
|
</script>
|
|
11
11
|
|
|
@@ -36,8 +36,8 @@ const _presetsClsBackdrop = {
|
|
|
36
36
|
const _presetsCls = {
|
|
37
37
|
left: `w-full sm:w-[66vw] h-full`,
|
|
38
38
|
right: `w-full sm:w-[66vw] h-full`,
|
|
39
|
-
top: `w-full
|
|
40
|
-
bottom: `w-full
|
|
39
|
+
top: `w-full h-full sm:h-[66vh]`,
|
|
40
|
+
bottom: `w-full h-full sm:h-[66vh]`
|
|
41
41
|
};
|
|
42
42
|
$:
|
|
43
43
|
_presetsAnim = {
|
|
@@ -52,12 +52,9 @@ $:
|
|
|
52
52
|
dispatch("element", { drawer: el });
|
|
53
53
|
</script>
|
|
54
54
|
|
|
55
|
-
<!-- prettier-ignore -->
|
|
56
55
|
{#if $drawer.isOpen}
|
|
57
56
|
<Backdrop
|
|
58
|
-
class={twMerge(`
|
|
59
|
-
${_presetsClsBackdrop[position] || ''} ${backdropClass}
|
|
60
|
-
`.trim())}
|
|
57
|
+
class={twMerge(`${_presetsClsBackdrop[position] || ''} ${backdropClass}`)}
|
|
61
58
|
on:escape
|
|
62
59
|
on:click={(e) => dispatch('click_backdrop')}
|
|
63
60
|
{fadeInDuration}
|
|
@@ -72,7 +69,7 @@ $:
|
|
|
72
69
|
<div
|
|
73
70
|
bind:this={el}
|
|
74
71
|
on:click|stopPropagation
|
|
75
|
-
aria-modal="true"
|
|
72
|
+
aria-modal="true"
|
|
76
73
|
role="dialog"
|
|
77
74
|
aria-labelledby={labelledby}
|
|
78
75
|
aria-describedby={describedby}
|
|
@@ -80,7 +77,7 @@ $:
|
|
|
80
77
|
duration: transitionEnabled ? transitionDuration : 0,
|
|
81
78
|
...(_presetsAnim[position] || {}),
|
|
82
79
|
}}
|
|
83
|
-
class={twMerge(`overflow-y-auto ${_presetsCls[position] || ''} ${_class}
|
|
80
|
+
class={twMerge(`overflow-y-auto ${_presetsCls[position] || ''} ${_class}`)}
|
|
84
81
|
use:clickOutside={() => dispatch('click_outside')}
|
|
85
82
|
>
|
|
86
83
|
<slot />
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { prefersReducedMotionStore } from "../../utils/prefers-reduced-motion.js";
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
export let position = "left";
|
|
6
|
+
export let expandsOn = "hover";
|
|
7
|
+
export let force = false;
|
|
8
|
+
let _class = "";
|
|
9
|
+
export { _class as class };
|
|
10
|
+
export let expandedClass = "";
|
|
11
|
+
const _presetsCls = {
|
|
12
|
+
left: `left-0`,
|
|
13
|
+
right: `right-0`,
|
|
14
|
+
top: `top-0`,
|
|
15
|
+
bottom: `bottom-0`
|
|
16
|
+
};
|
|
17
|
+
$:
|
|
18
|
+
_isExpanded = !!force;
|
|
19
|
+
const click = "click";
|
|
20
|
+
const hover = "hover";
|
|
21
|
+
const both = "both";
|
|
22
|
+
const _onHover = (flag) => {
|
|
23
|
+
if (force)
|
|
24
|
+
return _isExpanded = true;
|
|
25
|
+
if ([hover, both].includes(expandsOn))
|
|
26
|
+
_isExpanded = !!flag;
|
|
27
|
+
};
|
|
28
|
+
const _onClick = (e) => {
|
|
29
|
+
if (force)
|
|
30
|
+
return _isExpanded = true;
|
|
31
|
+
if ([click, both].includes(expandsOn))
|
|
32
|
+
_isExpanded = !_isExpanded;
|
|
33
|
+
};
|
|
34
|
+
$:
|
|
35
|
+
dispatch("expanded", _isExpanded);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
|
39
|
+
<div
|
|
40
|
+
on:mouseenter={() => _onHover(true)}
|
|
41
|
+
on:mouseleave={() => _onHover(false)}
|
|
42
|
+
on:click={_onClick}
|
|
43
|
+
on:click
|
|
44
|
+
aria-expanded={_isExpanded}
|
|
45
|
+
class={twMerge(`
|
|
46
|
+
absolute w-full h-full flex flex-col
|
|
47
|
+
${$prefersReducedMotionStore ? '' : 'transition-all'}
|
|
48
|
+
${_presetsCls[position] || ''}
|
|
49
|
+
${_class}
|
|
50
|
+
${_isExpanded ? expandedClass : ''}
|
|
51
|
+
`)}
|
|
52
|
+
>
|
|
53
|
+
<slot isExpanded={_isExpanded} />
|
|
54
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
position?: "left" | "top" | "right" | "bottom" | undefined;
|
|
5
|
+
expandsOn?: "click" | "hover" | "both" | undefined;
|
|
6
|
+
force?: boolean | undefined;
|
|
7
|
+
class?: string | undefined;
|
|
8
|
+
expandedClass?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
click: MouseEvent;
|
|
12
|
+
expanded: CustomEvent<any>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {
|
|
18
|
+
isExpanded: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type ExpandableProps = typeof __propDef.props;
|
|
23
|
+
export type ExpandableEvents = typeof __propDef.events;
|
|
24
|
+
export type ExpandableSlots = typeof __propDef.slots;
|
|
25
|
+
export default class Expandable extends SvelteComponent<ExpandableProps, ExpandableEvents, ExpandableSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { default as AppShell } from './components/AppShell/AppShell.svelte';
|
|
1
|
+
export { default as AppShell, appShellSetHtmlBodyHeight, } from './components/AppShell/AppShell.svelte';
|
|
2
2
|
export { default as Backdrop, BackdropConfig, } from './components/Backdrop/Backdrop.svelte';
|
|
3
3
|
export { default as Button, ButtonConfig } from './components/Button/Button.svelte';
|
|
4
4
|
export { default as SystemAwareColorScheme } from './components/ColorScheme/SystemAwareColorScheme.svelte';
|
|
5
5
|
export { default as LocalColorScheme } from './components/ColorScheme/LocalColorScheme.svelte';
|
|
6
6
|
export { ColorScheme } from './components/ColorScheme/color-scheme.js';
|
|
7
7
|
export { default as Drawer, createDrawerStore } from './components/Drawer/Drawer.svelte';
|
|
8
|
+
export { default as Expandable } from './components/Expandable/Expandable.svelte';
|
|
8
9
|
export { default as X } from './components/X/X.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Reexport your entry components here
|
|
2
2
|
//
|
|
3
|
-
export { default as AppShell } from './components/AppShell/AppShell.svelte';
|
|
3
|
+
export { default as AppShell, appShellSetHtmlBodyHeight, } from './components/AppShell/AppShell.svelte';
|
|
4
4
|
//
|
|
5
5
|
export { default as Backdrop, BackdropConfig, } from './components/Backdrop/Backdrop.svelte';
|
|
6
6
|
//
|
|
@@ -12,4 +12,6 @@ export { ColorScheme } from './components/ColorScheme/color-scheme.js';
|
|
|
12
12
|
//
|
|
13
13
|
export { default as Drawer, createDrawerStore } from './components/Drawer/Drawer.svelte';
|
|
14
14
|
//
|
|
15
|
+
export { default as Expandable } from './components/Expandable/Expandable.svelte';
|
|
16
|
+
//
|
|
15
17
|
export { default as X } from './components/X/X.svelte';
|