@brytdesigns/web-component-drawer 1.0.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.
@@ -0,0 +1,60 @@
1
+ import { createEffect, on, onCleanup } from 'solid-js';
2
+ import { animate } from 'motion';
3
+ import { useDrawer } from '../hooks/index.js';
4
+ import { controlPromise, getTransitionConfig } from '../utils.js';
5
+
6
+ const DrawerBackdrop = (_, { element }) => {
7
+ const [state, { updateAnimationQueue, close }] = useDrawer(element);
8
+ createEffect(
9
+ on(
10
+ () => state.isOpen,
11
+ (isOpen) => {
12
+ if (!isOpen) return;
13
+ const animation = enter(element);
14
+ updateAnimationQueue(controlPromise(animation));
15
+ return onCleanup(animation.complete);
16
+ }
17
+ )
18
+ );
19
+ createEffect(
20
+ on(
21
+ () => state.isOpen,
22
+ (isOpen) => {
23
+ if (isOpen) return;
24
+ const animation = exit(element);
25
+ updateAnimationQueue(controlPromise(animation));
26
+ return onCleanup(animation.complete);
27
+ }
28
+ )
29
+ );
30
+ function enter(element2) {
31
+ const style = window.getComputedStyle(element2);
32
+ const options = getTransitionConfig(style);
33
+ return animate(
34
+ element2,
35
+ {
36
+ opacity: [`var(--opacity-from)`, `var(--opacity-to)`]
37
+ },
38
+ options
39
+ );
40
+ }
41
+ function exit(element2) {
42
+ const style = window.getComputedStyle(element2);
43
+ const options = getTransitionConfig(style);
44
+ return animate(
45
+ element2,
46
+ {
47
+ opacity: [`var(--opacity-to)`, `var(--opacity-from)`]
48
+ },
49
+ options
50
+ );
51
+ }
52
+ element.addEventListener("click", close);
53
+ onCleanup(() => {
54
+ element.removeEventListener("click", close);
55
+ });
56
+ };
57
+
58
+ export { DrawerBackdrop };
59
+ //# sourceMappingURL=drawer-backdrop.js.map
60
+ //# sourceMappingURL=drawer-backdrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/drawer-backdrop.ts"],"names":["element"],"mappings":";;;;;AAUO,MAAM,cAA4D,GAAA,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AACzC,IAAO,OAAA,OAAA;AAAA,MACLA,QAAAA;AAAA,MACA;AAAA,QACE,OAAA,EAAS,CAAC,CAAA,iBAAA,CAAA,EAAqB,CAAqB,mBAAA,CAAA;AAAA,OACtD;AAAA,MACA;AAAA,KACF;AAAA;AAGF,EAAQ,OAAA,CAAA,gBAAA,CAAiB,SAAS,KAAK,CAAA;AAEvC,EAAA,SAAA,CAAU,MAAM;AACd,IAAQ,OAAA,CAAA,mBAAA,CAAoB,SAAS,KAAK,CAAA;AAAA,GAC3C,CAAA;AACH","file":"drawer-backdrop.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createEffect, on, onCleanup } from \"solid-js\";\nimport { animate } from \"motion\";\n\nimport { useDrawer } from \"../hooks/index.js\";\nimport { controlPromise, getTransitionConfig } from \"../utils.js\";\n\ntype DrawerBackdropProps = {};\n\nexport const DrawerBackdrop: CorrectComponentType<DrawerBackdropProps> = (\n _,\n { element }\n) => {\n const [state, { updateAnimationQueue, close }] = useDrawer(element);\n\n createEffect(\n on(\n () => state.isOpen,\n (isOpen) => {\n if (!isOpen) return;\n const animation = enter(element);\n updateAnimationQueue(controlPromise(animation));\n return onCleanup(animation.complete);\n }\n )\n );\n\n createEffect(\n on(\n () => state.isOpen,\n (isOpen) => {\n if (isOpen) return;\n const animation = exit(element);\n updateAnimationQueue(controlPromise(animation));\n return onCleanup(animation.complete);\n }\n )\n );\n\n function enter(element: HTMLElement) {\n const style = window.getComputedStyle(element);\n const options = getTransitionConfig(style);\n return animate(\n element,\n {\n opacity: [`var(--opacity-from)`, `var(--opacity-to)`],\n },\n options\n );\n }\n\n function exit(element: HTMLElement) {\n const style = window.getComputedStyle(element);\n const options = getTransitionConfig(style);\n return animate(\n element,\n {\n opacity: [`var(--opacity-to)`, `var(--opacity-from)`],\n },\n options\n );\n }\n\n element.addEventListener(\"click\", close);\n\n onCleanup(() => {\n element.removeEventListener(\"click\", close);\n });\n};\n"]}
@@ -0,0 +1,63 @@
1
+ import { createEffect, on, onCleanup } from 'solid-js';
2
+ import { animate } from 'motion';
3
+ import { useDrawer } from '../hooks/index.js';
4
+ import { controlPromise, getTransitionConfig, convertPositionToTranslate } from '../utils.js';
5
+ import { POSITION } from '../consts.js';
6
+
7
+ const DrawerContent = (props, { element }) => {
8
+ const [state, { updateAnimationQueue }] = useDrawer(element);
9
+ createEffect(
10
+ on(
11
+ () => state.isOpen,
12
+ (isOpen) => {
13
+ if (!isOpen) return;
14
+ const animation = enter(element);
15
+ updateAnimationQueue(controlPromise(animation));
16
+ return onCleanup(animation.complete);
17
+ }
18
+ )
19
+ );
20
+ createEffect(
21
+ on(
22
+ () => state.isOpen,
23
+ (isOpen) => {
24
+ if (isOpen) return;
25
+ const animation = exit(element);
26
+ updateAnimationQueue(controlPromise(animation));
27
+ return onCleanup(animation.complete);
28
+ }
29
+ )
30
+ );
31
+ function enter(element2) {
32
+ const style = window.getComputedStyle(element2);
33
+ const transition = getTransitionConfig(style);
34
+ let position = style.getPropertyValue("--d-position");
35
+ if (!position) position = POSITION.LEFT;
36
+ const transform = convertPositionToTranslate(position);
37
+ return animate(
38
+ element2,
39
+ {
40
+ transform
41
+ },
42
+ transition
43
+ );
44
+ }
45
+ function exit(element2) {
46
+ const style = window.getComputedStyle(element2);
47
+ const transition = getTransitionConfig(style);
48
+ let position = style.getPropertyValue("--d-position");
49
+ if (!position) position = POSITION.LEFT;
50
+ const transform = convertPositionToTranslate(position);
51
+ return animate(
52
+ element2,
53
+ {
54
+ transform
55
+ },
56
+ transition
57
+ );
58
+ }
59
+ };
60
+
61
+ export { DrawerContent };
62
+ //# sourceMappingURL=drawer-content.js.map
63
+ //# sourceMappingURL=drawer-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/drawer-content.ts"],"names":["element"],"mappings":";;;;;;AAeO,MAAM,aAA0D,GAAA,CACrE,KACA,EAAA,EAAE,SACC,KAAA;AACH,EAAA,MAAM,CAAC,KAAO,EAAA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C7C,IAAM,MAAA,UAAA,GAAa,oBAAoB,KAAK,CAAA;AAC5C,IAAI,IAAA,QAAA,GAAW,KAAM,CAAA,gBAAA,CAAiB,cAAc,CAAA;AACpD,IAAI,IAAA,CAAC,QAAU,EAAA,QAAA,GAAW,QAAS,CAAA,IAAA;AACnC,IAAM,MAAA,SAAA,GAAY,2BAA2B,QAAQ,CAAA;AACrD,IAAO,OAAA,OAAA;AAAA,MACLA,QAAAA;AAAA,MACA;AAAA,QACE;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA;AAEJ","file":"drawer-content.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createEffect, on, onCleanup } from \"solid-js\";\nimport { animate } from \"motion\";\n\nimport { useDrawer } from \"../hooks/index.js\";\nimport {\n controlPromise,\n convertPositionToTranslate,\n getTransitionConfig,\n} from \"../utils.js\";\nimport { POSITION, type Position } from \"../consts.js\";\n\ntype DrawerContentProps = {};\n\nexport const DrawerContent: CorrectComponentType<DrawerContentProps> = (\n props,\n { element },\n) => {\n const [state, { updateAnimationQueue }] = useDrawer(element);\n\n createEffect(\n on(\n () => state.isOpen,\n (isOpen) => {\n if (!isOpen) return;\n const animation = enter(element);\n updateAnimationQueue(controlPromise(animation));\n return onCleanup(animation.complete);\n },\n ),\n );\n\n createEffect(\n on(\n () => state.isOpen,\n (isOpen) => {\n if (isOpen) return;\n const animation = exit(element);\n updateAnimationQueue(controlPromise(animation));\n return onCleanup(animation.complete);\n },\n ),\n );\n\n function enter(element: HTMLElement) {\n const style = window.getComputedStyle(element);\n const transition = getTransitionConfig(style);\n let position = style.getPropertyValue(\"--d-position\") as Position;\n if (!position) position = POSITION.LEFT;\n const transform = convertPositionToTranslate(position);\n\n return animate(\n element,\n {\n transform,\n },\n transition,\n );\n }\n\n function exit(element: HTMLElement) {\n const style = window.getComputedStyle(element);\n const transition = getTransitionConfig(style);\n let position = style.getPropertyValue(\"--d-position\") as Position;\n if (!position) position = POSITION.LEFT;\n const transform = convertPositionToTranslate(position);\n return animate(\n element,\n {\n transform,\n },\n transition,\n );\n }\n};\n"]}
@@ -0,0 +1,107 @@
1
+ import { splitProps, createMemo, createEffect, on, onCleanup } from 'solid-js';
2
+ import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock-upgrade';
3
+ import { createFocusTrap } from 'focus-trap';
4
+ import { provideDrawerContext, useDrawerContext } from '../hooks/index.js';
5
+ import { showElement, hideElement } from '../utils.js';
6
+
7
+ const DrawerContext = (props, { element }) => {
8
+ const [contextProps, restProps] = splitProps(props, [
9
+ "isOpen",
10
+ "isAnimating"
11
+ ]);
12
+ const context = provideDrawerContext(contextProps, element);
13
+ const [state, { setElementState }] = context;
14
+ const [_, { updateAnimationQueue, ...events }] = useDrawerContext(context);
15
+ element.actions = events;
16
+ const focusTrap = createMemo(() => {
17
+ return createFocusTrap(element, {
18
+ allowOutsideClick: true,
19
+ escapeDeactivates: restProps.closeOnEscape,
20
+ onDeactivate: () => {
21
+ setElementState("isOpen", false);
22
+ }
23
+ });
24
+ });
25
+ createEffect(
26
+ on(
27
+ () => state.isOpen,
28
+ (isOpen) => {
29
+ const eventName = isOpen ? "drawer:open" : "drawer:close";
30
+ element.dispatchEvent(
31
+ new CustomEvent(eventName, {
32
+ bubbles: true,
33
+ detail: { isOpen, relatedTarget: element }
34
+ })
35
+ );
36
+ element.dispatchEvent(
37
+ new CustomEvent("drawer:toggle", {
38
+ bubbles: true,
39
+ detail: { isOpen, relatedTarget: element }
40
+ })
41
+ );
42
+ }
43
+ )
44
+ );
45
+ createEffect(
46
+ on(
47
+ () => ({
48
+ isOpen: state.isOpen,
49
+ focusTrap: focusTrap(),
50
+ shouldTrapFocus: restProps.shouldTrapFocus
51
+ }),
52
+ ({ isOpen, focusTrap: focusTrap2, shouldTrapFocus }) => {
53
+ if (!isOpen) return;
54
+ showElement(element);
55
+ if (!shouldTrapFocus) return;
56
+ focusTrap2.activate();
57
+ onCleanup(focusTrap2.deactivate);
58
+ }
59
+ )
60
+ );
61
+ createEffect(
62
+ on(
63
+ () => ({
64
+ isOpen: state.isOpen,
65
+ isAnimating: state.isAnimating,
66
+ shouldTrapFocus: restProps.shouldTrapFocus
67
+ }),
68
+ ({ isOpen, isAnimating, shouldTrapFocus }) => {
69
+ if (isOpen && !isAnimating && shouldTrapFocus)
70
+ return disableBodyScroll(element, {
71
+ allowTouchMove: (el) => {
72
+ if (el instanceof HTMLElement) {
73
+ let element2 = el;
74
+ while (element2 && element2 !== document.body) {
75
+ if (element2.tagName === "DRAWER-CONTENT") {
76
+ return true;
77
+ }
78
+ element2 = element2.parentElement;
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+ });
84
+ onCleanup(() => {
85
+ if (!shouldTrapFocus) return;
86
+ enableBodyScroll(element);
87
+ });
88
+ }
89
+ )
90
+ );
91
+ createEffect(
92
+ on(
93
+ () => ({ isOpen: state.isOpen, animationQueue: state.animationQueue }),
94
+ ({ isOpen, animationQueue }) => {
95
+ if (isOpen) return;
96
+ return Promise.all(animationQueue).then(() => hideElement(element));
97
+ }
98
+ )
99
+ );
100
+ onCleanup(() => {
101
+ clearAllBodyScrollLocks();
102
+ });
103
+ };
104
+
105
+ export { DrawerContext };
106
+ //# sourceMappingURL=drawer-context.js.map
107
+ //# sourceMappingURL=drawer-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/drawer-context.ts"],"names":["focusTrap","element"],"mappings":";;;;;;AAqBO,MAAM,aAA0D,GAAA,CACrE,KACA,EAAA,EAAE,SACC,KAAA;AACH,EAAA,MAAM,CAAC,YAAA,EAAc,SAAS,CAAA,GAAI,WAAW,KAAO,EAAA;AAAA,IAClD,QAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAM,MAAA,OAAA,GAAU,oBAAqB,CAAA,YAAA,EAAc,OAAO,CAAA;AAE1D,EAAA,MAAM,CAAC,KAAA,EAAO,EAAE,eAAA,EAAiB,CAAI,GAAA,OA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AI,MAAQ,EAAA;AACZ,QAAO,OAAA,OAAA,CAAQ,IAAI,cAAc,CAAA,CAAE,KAAK,MAAM,WAAA,CAAY,OAAO,CAAC,CAAA;AAAA;AACpE;AACF,GACF;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAwB,uBAAA,EAAA;AAAA,GACzB,CAAA;AACH","file":"drawer-context.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createMemo, createEffect, on, onCleanup, splitProps } from \"solid-js\";\nimport {\n enableBodyScroll,\n disableBodyScroll,\n clearAllBodyScrollLocks,\n} from \"body-scroll-lock-upgrade\";\nimport { createFocusTrap } from \"focus-trap\";\n\nimport { provideDrawerContext, useDrawerContext } from \"../hooks/index.js\";\nimport { hideElement, showElement } from \"../utils.js\";\n\ntype DrawerContextProps = {\n isOpen: boolean;\n id: string;\n closeOnEscape: boolean;\n shouldTrapFocus: boolean;\n isAnimating: boolean;\n};\n\nexport const DrawerContext: CorrectComponentType<DrawerContextProps> = (\n props,\n { element },\n) => {\n const [contextProps, restProps] = splitProps(props, [\n \"isOpen\",\n \"isAnimating\",\n ]);\n\n const context = provideDrawerContext(contextProps, element);\n\n const [state, { setElementState }] = context;\n\n const [_, { updateAnimationQueue, ...events }] = useDrawerContext(context);\n\n element.actions = events;\n\n const focusTrap = createMemo(() => {\n return createFocusTrap(element, {\n allowOutsideClick: true,\n escapeDeactivates: restProps.closeOnEscape,\n onDeactivate: () => {\n setElementState(\"isOpen\", false);\n },\n });\n });\n\n createEffect(\n on(\n () => state.isOpen,\n (isOpen) => {\n const eventName = isOpen ? \"drawer:open\" : \"drawer:close\";\n element.dispatchEvent(\n new CustomEvent(eventName, {\n bubbles: true,\n detail: { isOpen, relatedTarget: element },\n }),\n );\n element.dispatchEvent(\n new CustomEvent(\"drawer:toggle\", {\n bubbles: true,\n detail: { isOpen, relatedTarget: element },\n }),\n );\n },\n ),\n );\n\n createEffect(\n on(\n () => ({\n isOpen: state.isOpen,\n focusTrap: focusTrap(),\n shouldTrapFocus: restProps.shouldTrapFocus,\n }),\n ({ isOpen, focusTrap, shouldTrapFocus }) => {\n if (!isOpen) return;\n showElement(element);\n if (!shouldTrapFocus) return;\n focusTrap.activate();\n onCleanup(focusTrap.deactivate);\n },\n ),\n );\n\n createEffect(\n on(\n () => ({\n isOpen: state.isOpen,\n isAnimating: state.isAnimating,\n shouldTrapFocus: restProps.shouldTrapFocus,\n }),\n ({ isOpen, isAnimating, shouldTrapFocus }) => {\n if (isOpen && !isAnimating && shouldTrapFocus)\n return disableBodyScroll(element, {\n allowTouchMove: (el: EventTarget) => {\n if (el instanceof HTMLElement) {\n let element = el as (EventTarget & HTMLElement) | null;\n while (element && element !== document.body) {\n if (element.tagName === \"DRAWER-CONTENT\") {\n return true;\n }\n\n element = element.parentElement;\n }\n }\n return false;\n },\n });\n onCleanup(() => {\n if (!shouldTrapFocus) return;\n enableBodyScroll(element);\n });\n },\n ),\n );\n\n createEffect(\n on(\n () => ({ isOpen: state.isOpen, animationQueue: state.animationQueue }),\n ({ isOpen, animationQueue }) => {\n if (isOpen) return;\n return Promise.all(animationQueue).then(() => hideElement(element));\n },\n ),\n );\n\n onCleanup(() => {\n clearAllBodyScrollLocks();\n });\n};\n"]}
@@ -0,0 +1,83 @@
1
+ import { createEffect, on, onCleanup } from 'solid-js';
2
+ import { observeElementInViewport } from 'observe-element-in-viewport';
3
+ import { getDrawerContext } from '../hooks/index.js';
4
+
5
+ const DrawerTrigger = (props, { element }) => {
6
+ if (!props.target)
7
+ return console.warn("DrawerTrigger: target prop is required!");
8
+ if (!props.action)
9
+ return console.warn("DrawerTrigger: action prop is required!");
10
+ if (props.action !== "close" && props.action !== "open" && props.action !== "toggle")
11
+ return console.warn(
12
+ "DrawerTrigger: action prop must be 'close', 'open', or 'toggle'"
13
+ );
14
+ if (!props.on) return console.warn("DrawerTrigger: on prop is required!");
15
+ const target = document.querySelector(props.target);
16
+ if (!target) return console.warn("DrawerTrigger: target element not found!");
17
+ const [state, { open, close, toggle }] = getDrawerContext(target);
18
+ function dispatchAction(action) {
19
+ switch (action) {
20
+ case "close":
21
+ close();
22
+ break;
23
+ case "open":
24
+ open();
25
+ break;
26
+ case "toggle":
27
+ toggle();
28
+ break;
29
+ }
30
+ }
31
+ createEffect(() => {
32
+ element.setAttribute("is-open", `${state.isOpen}`);
33
+ element.setAttribute("is-animating", `${state.isAnimating}`);
34
+ });
35
+ createEffect(
36
+ on(
37
+ () => ({
38
+ action: props.action,
39
+ on: props.on,
40
+ preventDefault: props.preventDefault
41
+ }),
42
+ ({ action, on: on2, preventDefault }) => {
43
+ if (!on2 || !action) return;
44
+ switch (on2) {
45
+ case "enter":
46
+ return handleOnEnter(action);
47
+ case "exit":
48
+ return handleOnExit(action);
49
+ default: {
50
+ let handleEvent2 = function(event) {
51
+ if (preventDefault) event.preventDefault();
52
+ dispatchAction(action);
53
+ };
54
+ element.addEventListener(on2, handleEvent2);
55
+ return onCleanup(
56
+ () => element.removeEventListener(on2, handleEvent2)
57
+ );
58
+ }
59
+ }
60
+ }
61
+ )
62
+ );
63
+ function handleOnEnter(action) {
64
+ let unsubscribe = null;
65
+ if (action === "toggle") {
66
+ unsubscribe = observeElementInViewport(element, open, close);
67
+ }
68
+ if (unsubscribe) onCleanup(unsubscribe);
69
+ return;
70
+ }
71
+ function handleOnExit(action) {
72
+ let unsubscribe = null;
73
+ if (action === "toggle") {
74
+ unsubscribe = observeElementInViewport(element, close, open);
75
+ }
76
+ if (unsubscribe) onCleanup(unsubscribe);
77
+ return;
78
+ }
79
+ };
80
+
81
+ export { DrawerTrigger };
82
+ //# sourceMappingURL=drawer-trigger.js.map
83
+ //# sourceMappingURL=drawer-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/drawer-trigger.ts"],"names":["on","handleEvent"],"mappings":";;;;AAeO,MAAM,aAA0D,GAAA,CACrE,KACA,EAAA,EAAE,SACC,KAAA;AACH,EAAA,IAAI,CAAC,KAA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AAAA;AAEJ","file":"drawer-trigger.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\nimport type { Action } from \"../consts\";\n\nimport { createEffect, on, onCleanup } from \"solid-js\";\nimport { observeElementInViewport } from \"observe-element-in-viewport\";\n\nimport { getDrawerContext } from \"../hooks/index.js\";\n\ntype DrawerTriggerProps = {\n target?: string;\n action?: Action | \"\";\n on?: keyof HTMLElementEventMap | \"enter\" | \"exit\";\n preventDefault: boolean;\n};\n\nexport const DrawerTrigger: CorrectComponentType<DrawerTriggerProps> = (\n props,\n { element },\n) => {\n if (!props.target)\n return console.warn(\"DrawerTrigger: target prop is required!\");\n if (!props.action)\n return console.warn(\"DrawerTrigger: action prop is required!\");\n if (\n props.action !== \"close\" &&\n props.action !== \"open\" &&\n props.action !== \"toggle\"\n )\n return console.warn(\n \"DrawerTrigger: action prop must be 'close', 'open', or 'toggle'\",\n );\n if (!props.on) return console.warn(\"DrawerTrigger: on prop is required!\");\n\n const target = document.querySelector(props.target!);\n if (!target) return console.warn(\"DrawerTrigger: target element not found!\");\n\n const [state, { open, close, toggle }] = getDrawerContext(target);\n\n function dispatchAction(action: Action) {\n switch (action) {\n case \"close\":\n close();\n break;\n case \"open\":\n open();\n break;\n case \"toggle\":\n toggle();\n break;\n }\n }\n\n createEffect(() => {\n element.setAttribute(\"is-open\", `${state.isOpen}`);\n element.setAttribute(\"is-animating\", `${state.isAnimating}`);\n });\n\n createEffect(\n on(\n () => ({\n action: props.action!,\n on: props.on,\n preventDefault: props.preventDefault,\n }),\n ({ action, on, preventDefault }) => {\n if (!on || !action) return;\n\n switch (on) {\n case \"enter\":\n return handleOnEnter(action);\n case \"exit\":\n return handleOnExit(action);\n default: {\n function handleEvent(event: Event) {\n if (preventDefault) event.preventDefault();\n dispatchAction(action);\n }\n\n element.addEventListener(on, handleEvent);\n\n return onCleanup(() =>\n element.removeEventListener(on, handleEvent),\n );\n }\n }\n },\n ),\n );\n\n // Handles the enter/exit events for the drawer.\n function handleOnEnter(action: Action) {\n let unsubscribe = null;\n if (action === \"toggle\") {\n unsubscribe = observeElementInViewport(element, open, close);\n }\n\n if (unsubscribe) onCleanup(unsubscribe);\n return;\n }\n\n function handleOnExit(action: Action) {\n let unsubscribe = null;\n if (action === \"toggle\") {\n unsubscribe = observeElementInViewport(element, close, open);\n }\n\n if (unsubscribe) onCleanup(unsubscribe);\n return;\n }\n};\n"]}
@@ -0,0 +1,6 @@
1
+ export * from './drawer-content.js';
2
+ export * from './drawer-trigger.js';
3
+ export * from './drawer-backdrop.js';
4
+ export * from './drawer-context.js';
5
+ //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,16 @@
1
+ const POSITION = {
2
+ TOP: "top",
3
+ BOTTOM: "bottom",
4
+ LEFT: "left",
5
+ RIGHT: "right"
6
+ };
7
+ const ACTION = {
8
+ OPEN: "open",
9
+ CLOSE: "close",
10
+ TOGGLE: "toggle"
11
+ };
12
+ const EVENT_NAMESPACE = `bryt:drawer`;
13
+
14
+ export { ACTION, EVENT_NAMESPACE, POSITION };
15
+ //# sourceMappingURL=consts.js.map
16
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/consts.ts"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA;AAAA,EACtB,GAAK,EAAA,KAAA;AAAA,EACL,MAAQ,EAAA,QAAA;AAAA,EACR,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA;AACT;AAEO,MAAM,MAAS,GAAA;AAAA,EACpB,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA,OAAA;AAAA,EACP,MAAQ,EAAA;AACV;AAEO,MAAM,eAAkB,GAAA,CAAA,WAAA","file":"consts.js","sourcesContent":["export type Position = (typeof POSITION)[keyof typeof POSITION];\nexport type Action = (typeof ACTION)[keyof typeof ACTION];\n\nexport const POSITION = {\n TOP: \"top\",\n BOTTOM: \"bottom\",\n LEFT: \"left\",\n RIGHT: \"right\",\n} as const;\n\nexport const ACTION = {\n OPEN: \"open\",\n CLOSE: \"close\",\n TOGGLE: \"toggle\",\n};\n\nexport const EVENT_NAMESPACE = `bryt:drawer` as const;\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './useDrawer.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,79 @@
1
+ import { createContext, provide, consume } from 'component-register';
2
+ import { splitProps, createEffect, on, batch, mergeProps } from 'solid-js';
3
+ import { createStore } from 'solid-js/store';
4
+ import { toHyphenated, getContextFromProvider } from '@brytdesigns/web-component-utils';
5
+
6
+ function initializeDrawerContext(props) {
7
+ const [element, stateProps] = splitProps(props, ["root"]);
8
+ const [store, setStore] = createStore({ animationQueue: [] });
9
+ createEffect(
10
+ on(
11
+ () => store.animationQueue,
12
+ (animationQueue) => {
13
+ if (!animationQueue.length) return;
14
+ const animations = Promise.all(store.animationQueue);
15
+ setElementState("isAnimating", true);
16
+ animations.then(() => {
17
+ batch(() => {
18
+ setElementState("isAnimating", false);
19
+ setStore("animationQueue", []);
20
+ });
21
+ });
22
+ }
23
+ )
24
+ );
25
+ function setElementState(key, value) {
26
+ if (typeof value === "function") {
27
+ const currentValue = props[key];
28
+ const result = value(currentValue || false);
29
+ element.root.setAttribute(toHyphenated(key), `${result}`);
30
+ return;
31
+ }
32
+ return element.root.setAttribute(toHyphenated(key), `${value}`);
33
+ }
34
+ return [
35
+ mergeProps(store, stateProps),
36
+ { setElementState, setStore }
37
+ ];
38
+ }
39
+ const DrawerContextState = createContext(initializeDrawerContext);
40
+ const provideDrawerContext = (initialState, element) => {
41
+ const props = mergeProps(initialState, { root: element });
42
+ return provide(DrawerContextState, props, element);
43
+ };
44
+ const useDrawerContext = (context) => {
45
+ const [state, { setElementState, setStore: setState }] = context;
46
+ function updateAnimationQueue(animation) {
47
+ setState("animationQueue", (state2) => [...state2, animation]);
48
+ }
49
+ function close() {
50
+ setElementState("isOpen", false);
51
+ }
52
+ function open() {
53
+ setElementState("isOpen", true);
54
+ }
55
+ function toggle() {
56
+ setElementState("isOpen", (open2) => !open2);
57
+ }
58
+ return [state, { updateAnimationQueue, close, open, toggle }];
59
+ };
60
+ const useDrawer = (element) => {
61
+ const context = consume(DrawerContextState, element);
62
+ if (!context) {
63
+ throw console.error(
64
+ "DrawerContext not found! Please ensure to wrap your custom element with drawer-context element."
65
+ );
66
+ }
67
+ return useDrawerContext(context);
68
+ };
69
+ const getDrawerContext = (element) => {
70
+ const context = getContextFromProvider(
71
+ DrawerContextState,
72
+ element
73
+ );
74
+ return useDrawerContext(context);
75
+ };
76
+
77
+ export { getDrawerContext, provideDrawerContext, useDrawer, useDrawerContext };
78
+ //# sourceMappingURL=useDrawer.js.map
79
+ //# sourceMappingURL=useDrawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useDrawer.ts"],"names":["state","open"],"mappings":";;;;;AA2BA,SAAS,wBAAwB,KAA6B,EAAA;AAC5D,EAAM,MAAA,CAAC,SAAS,UAAU,CAAA,GAAI,WAAW,KAAO,EAAA,CAAC,MAAM,CAAC,CAAA;AACxD,EAAM,MAAA,CAAC,OAAO,QAAQ,CAAA,GAAI,YAA0B,EAAE,cAAA,EAAgB,EAAC,EAAG,CAAA;AAE1E,EAAA,YAAA;AAAA,IACE,EAAA;AAAA,MACE,MAAM,KAAM,CAAA,cAAA;AAAA,MACZ,CAAC,cAAmB,KAAA;AAClB,QAAI,IAAA,CAAC,eAAe,MAAQ,EAAA;AAC5B,QAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,GAAI,CAAA,KAAA,CAAM,cAAc,CAAA;AACnD,QAAA,eAAA,CAAgB,eAAe,IAAI,CAAA;AACnC,QAAA,UAAA,C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,CAACA,MAAAA,KAAU,CAAC,GAAGA,MAAAA,EAAO,SAAS,CAAC,CAAA;AAAA;AAG7D,EAAA,SAAS,KAAQ,GAAA;AACf,IAAA,eAAA,CAAgB,UAAU,KAAK,CAAA;AAAA;AAGjC,EAAA,SAAS,IAAO,GAAA;AACd,IAAA,eAAA,CAAgB,UAAU,IAAI,CAAA;AAAA;AAGhC,EAAA,SAAS,MAAS,GAAA;AAChB,IAAA,eAAA,CAAgB,QAAU,EAAA,CAACC,KAAS,KAAA,CAACA,KAAI,CAAA;AAAA;AAG3C,EAAA,OAAO,CAAC,KAAO,EAAA,EAAE,sBAAsB,KAAO,EAAA,IAAA,EAAM,QAAQ,CAAA;AAC9D;AAEa,MAAA,SAAA,GAAY,CAAC,OAA0C,KAAA;AAClE,EAAM,MAAA,OAAA,GAAyB,OAAQ,CAAA,kBAAA,EAAoB,OAAO,CAAA;AAElE,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAA,MAAM,OAAQ,CAAA,KAAA;AAAA,MACZ;AAAA,KACF;AAAA;AAGF,EAAA,OAAO,iBAAiB,OAAO,CAAA;AACjC;AAEa,MAAA,gBAAA,GAAmB,CAAC,OAAqB,KAAA;AACpD,EAAA,MAAM,OAAU,GAAA,sBAAA;AAAA,IACd,kBAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,OAAO,iBAAiB,OAAO,CAAA;AACjC","file":"useDrawer.js","sourcesContent":["import {\n type ICustomElement,\n createContext,\n provide,\n consume,\n} from \"component-register\";\nimport { createEffect, mergeProps, on, batch, splitProps } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\nimport {\n toHyphenated,\n getContextFromProvider,\n} from \"@brytdesigns/web-component-utils\";\n\ntype StoreContext = {\n animationQueue: Promise<unknown>[];\n};\n\ntype CreateContextOptions = {\n root: HTMLElement & ICustomElement;\n isOpen: boolean;\n isAnimating: boolean;\n};\n\ntype WalkableNode = Parameters<typeof provide>[2];\n\ntype DrawerContext = ReturnType<typeof initializeDrawerContext>;\n\nfunction initializeDrawerContext(props: CreateContextOptions) {\n const [element, stateProps] = splitProps(props, [\"root\"]);\n const [store, setStore] = createStore<StoreContext>({ animationQueue: [] });\n\n createEffect(\n on(\n () => store.animationQueue,\n (animationQueue) => {\n if (!animationQueue.length) return;\n const animations = Promise.all(store.animationQueue);\n setElementState(\"isAnimating\", true);\n animations.then(() => {\n batch(() => {\n setElementState(\"isAnimating\", false);\n setStore(\"animationQueue\", []);\n });\n });\n },\n ),\n );\n\n function setElementState(\n key: keyof Omit<CreateContextOptions, \"root\">,\n value: boolean | ((v: boolean) => boolean),\n ) {\n if (typeof value === \"function\") {\n const currentValue = props[key];\n const result = value(currentValue || false);\n element.root.setAttribute(toHyphenated(key), `${result}`);\n return;\n }\n return element.root.setAttribute(toHyphenated(key), `${value}`);\n }\n\n return [\n mergeProps(store, stateProps),\n { setElementState, setStore },\n ] as const;\n}\n\nconst DrawerContextState = createContext(initializeDrawerContext);\n\nexport const provideDrawerContext = (\n initialState: Omit<CreateContextOptions, \"root\">,\n element: WalkableNode,\n): DrawerContext => {\n const props = mergeProps(initialState, { root: element });\n return provide(DrawerContextState, props, element);\n};\n\nexport const useDrawerContext = (context: DrawerContext) => {\n const [state, { setElementState, setStore: setState }] = context;\n\n function updateAnimationQueue(animation: Promise<unknown>) {\n setState(\"animationQueue\", (state) => [...state, animation]);\n }\n\n function close() {\n setElementState(\"isOpen\", false);\n }\n\n function open() {\n setElementState(\"isOpen\", true);\n }\n\n function toggle() {\n setElementState(\"isOpen\", (open) => !open);\n }\n\n return [state, { updateAnimationQueue, close, open, toggle }] as const;\n};\n\nexport const useDrawer = (element: HTMLElement & ICustomElement) => {\n const context: DrawerContext = consume(DrawerContextState, element);\n\n if (!context) {\n throw console.error(\n \"DrawerContext not found! Please ensure to wrap your custom element with drawer-context element.\",\n );\n }\n\n return useDrawerContext(context);\n};\n\nexport const getDrawerContext = (element: Element) => {\n const context = getContextFromProvider<DrawerContext>(\n DrawerContextState,\n element,\n );\n return useDrawerContext(context);\n};\n"]}
@@ -0,0 +1,32 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { ICustomElement } from 'component-register';
4
+
5
+ export declare const useDrawer: (element: HTMLElement & ICustomElement) => readonly [
6
+ {
7
+ animationQueue: Promise<unknown>[];
8
+ isOpen: boolean;
9
+ isAnimating: boolean;
10
+ },
11
+ {
12
+ readonly updateAnimationQueue: (animation: Promise<unknown>) => void;
13
+ readonly close: () => void;
14
+ readonly open: () => void;
15
+ readonly toggle: () => void;
16
+ }
17
+ ];
18
+ export declare const getDrawerContext: (element: Element) => readonly [
19
+ {
20
+ animationQueue: Promise<unknown>[];
21
+ isOpen: boolean;
22
+ isAnimating: boolean;
23
+ },
24
+ {
25
+ readonly updateAnimationQueue: (animation: Promise<unknown>) => void;
26
+ readonly close: () => void;
27
+ readonly open: () => void;
28
+ readonly toggle: () => void;
29
+ }
30
+ ];
31
+
32
+ export {};
@@ -0,0 +1,32 @@
1
+ import { customShadowlessElement, correctElementType } from '@brytdesigns/web-component-utils';
2
+ import { DrawerContext, DrawerTrigger, DrawerBackdrop, DrawerContent } from './components/index.js';
3
+ export { getDrawerContext, useDrawer } from './hooks/index.js';
4
+
5
+ customShadowlessElement(
6
+ "drawer-context",
7
+ {
8
+ isOpen: false,
9
+ id: "",
10
+ closeOnEscape: false,
11
+ shouldTrapFocus: false,
12
+ isAnimating: false
13
+ },
14
+ correctElementType(DrawerContext)
15
+ );
16
+ customShadowlessElement(
17
+ "drawer-trigger",
18
+ { target: "", action: "", on: "click", preventDefault: true },
19
+ correctElementType(DrawerTrigger)
20
+ );
21
+ customShadowlessElement(
22
+ "drawer-backdrop",
23
+ {},
24
+ correctElementType(DrawerBackdrop)
25
+ );
26
+ customShadowlessElement(
27
+ "drawer-content",
28
+ {},
29
+ correctElementType(DrawerContent)
30
+ );
31
+ //# sourceMappingURL=index.js.map
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAYA,uBAAA;AAAA,EACE,gBAAA;AAAA,EACA;AAAA,IACE,MAAQ,EAAA,KAAA;AAAA,IACR,EAAI,EAAA,EAAA;AAAA,IACJ,aAAe,EAAA,KAAA;AAAA,IACf,eAAiB,EAAA,KAAA;AAAA,IACjB,WAAa,EAAA;AAAA,GACf;AAAA,EACA,mBAAmB,aAAa;AAClC,CAAA;AAEA,uBAAA;AAAA,EACE,gBAAA;AAAA,EACA,EAAE,QAAQ,EAAI,EAAA,MAAA,EAAQ,IAAI,EAAI,EAAA,OAAA,EAAS,gBAAgB,IAAK,EAAA;AAAA,EAC5D,mBAAmB,aAAa;AAClC,CAAA;AAEA,uBAAA;AAAA,EACE,iBAAA;AAAA,EACA,EAAC;AAAA,EACD,mBAAmB,cAAc;AACnC,CAAA;AAEA,uBAAA;AAAA,EACE,gBAAA;AAAA,EACA,EAAC;AAAA,EACD,mBAAmB,aAAa;AAClC,CAAA","file":"index.js","sourcesContent":["import {\n customShadowlessElement,\n correctElementType,\n} from \"@brytdesigns/web-component-utils\";\n\nimport {\n DrawerContent,\n DrawerContext,\n DrawerTrigger,\n DrawerBackdrop,\n} from \"./components/index.js\";\n\ncustomShadowlessElement(\n \"drawer-context\",\n {\n isOpen: false,\n id: \"\",\n closeOnEscape: false,\n shouldTrapFocus: false,\n isAnimating: false,\n },\n correctElementType(DrawerContext),\n);\n\ncustomShadowlessElement(\n \"drawer-trigger\",\n { target: \"\", action: \"\", on: \"click\", preventDefault: true },\n correctElementType(DrawerTrigger),\n);\n\ncustomShadowlessElement(\n \"drawer-backdrop\",\n {},\n correctElementType(DrawerBackdrop),\n);\n\ncustomShadowlessElement(\n \"drawer-content\",\n {},\n correctElementType(DrawerContent),\n);\n\nexport { useDrawer, getDrawerContext } from \"./hooks/index.js\";\n"]}
@@ -0,0 +1,75 @@
1
+ import { POSITION } from './consts';
2
+
3
+ function hideElement(element) {
4
+ element.style.display = "none";
5
+ }
6
+ function showElement(element) {
7
+ element.style.display = "block";
8
+ }
9
+ async function controlPromise(controls) {
10
+ return new Promise((resolve) => {
11
+ controls.then(() => resolve(null));
12
+ });
13
+ }
14
+ function convertPositionToTranslate(position) {
15
+ if (position === POSITION.TOP || position === POSITION.BOTTOM)
16
+ return ["translateY(var(--d-slide-from))", "translateY(var(--d-slide-to))"];
17
+ return ["translateX(var(--d-slide-from))", "translateX(var(--d-slide-to))"];
18
+ }
19
+ function getTransitionConfig(style) {
20
+ const properties = {
21
+ autoplay: style.getPropertyValue("--m-autoplay"),
22
+ bounce: style.getPropertyValue("--m-bounce"),
23
+ bounceDamping: style.getPropertyValue("--m-bounce-damping"),
24
+ bounceStiffness: style.getPropertyValue("--m-bounce-stiffness"),
25
+ duration: style.getPropertyValue("--m-duration"),
26
+ damping: style.getPropertyValue("--m-damping"),
27
+ delay: style.getPropertyValue("--m-delay"),
28
+ ease: style.getPropertyValue("--m-ease"),
29
+ elapsed: style.getPropertyValue("--m-elapsed"),
30
+ mass: style.getPropertyValue("--m-mass"),
31
+ max: style.getPropertyValue("--m-max"),
32
+ min: style.getPropertyValue("--m-min"),
33
+ power: style.getPropertyValue("--m-power"),
34
+ repeat: style.getPropertyValue("--m-repeat"),
35
+ repeatDelay: style.getPropertyValue("--m-repeat-delay"),
36
+ repeatType: style.getPropertyValue("--m-repeat-type"),
37
+ restDelta: style.getPropertyValue("--m-rest-delta"),
38
+ restSpeed: style.getPropertyValue("--m-rest-speed"),
39
+ startTime: style.getPropertyValue("--m-start-time"),
40
+ timeConstant: style.getPropertyValue("--m-time-constant"),
41
+ times: style.getPropertyValue("--m-times"),
42
+ type: style.getPropertyValue("--m-type"),
43
+ velocity: style.getPropertyValue("--m-velocity"),
44
+ visualDuration: style.getPropertyValue("--m-visual-duration")
45
+ };
46
+ return {
47
+ autoplay: properties.autoplay === "true",
48
+ bounce: properties.bounce ? parseFloat(properties.bounce) : void 0,
49
+ bounceDamping: properties.bounceDamping ? parseFloat(properties.bounceDamping) : void 0,
50
+ bounceStiffness: properties.bounceStiffness ? parseFloat(properties.bounceStiffness) : void 0,
51
+ duration: properties.duration ? parseFloat(properties.duration) : void 0,
52
+ damping: properties.damping ? parseFloat(properties.damping) : void 0,
53
+ delay: properties.delay ? parseFloat(properties.delay) : void 0,
54
+ ease: properties.ease,
55
+ elapsed: properties.elapsed ? parseFloat(properties.elapsed) : void 0,
56
+ mass: properties.mass ? parseFloat(properties.mass) : void 0,
57
+ max: properties.max ? parseFloat(properties.max) : void 0,
58
+ min: properties.min ? parseFloat(properties.min) : void 0,
59
+ power: properties.power ? parseFloat(properties.power) : void 0,
60
+ repeat: properties.repeat ? parseInt(properties.repeat) : void 0,
61
+ repeatDelay: properties.repeatDelay ? parseFloat(properties.repeatDelay) : void 0,
62
+ repeatType: properties.repeatType,
63
+ restDelta: properties.restDelta ? parseFloat(properties.restDelta) : void 0,
64
+ restSpeed: properties.restSpeed ? parseFloat(properties.restSpeed) : void 0,
65
+ startTime: properties.startTime ? parseFloat(properties.startTime) : void 0,
66
+ timeConstant: properties.timeConstant ? parseFloat(properties.timeConstant) : void 0,
67
+ type: properties.type,
68
+ velocity: properties.velocity ? parseFloat(properties.velocity) : void 0,
69
+ visualDuration: properties.visualDuration ? parseFloat(properties.visualDuration) : void 0
70
+ };
71
+ }
72
+
73
+ export { controlPromise, convertPositionToTranslate, getTransitionConfig, hideElement, showElement };
74
+ //# sourceMappingURL=utils.js.map
75
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils.ts"],"names":[],"mappings":";;AASO,SAAS,YAAmC,OAAY,EAAA;AAC7D,EAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,MAAA;AAC1B;AAEO,SAAS,YAAmC,OAAY,EAAA;AAC7D,EAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,OAAA;AAC1B;AAEA,eAAsB,eAAe,QAAqC,EAAA;AACxE,EAAO,OAAA,IAAI,OAAQ,CAAA,CAAC,O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AA,GAAW,UAAW,CAAA,UAAA,CAAW,QAAQ,CAAI,GAAA,MAAA;AAAA,IAClE,gBAAgB,UAAW,CAAA,cAAA,GACvB,UAAW,CAAA,UAAA,CAAW,cAAc,CACpC,GAAA;AAAA,GACN;AACF","file":"utils.js","sourcesContent":["import type {\n AnimationGeneratorType,\n AnimationPlaybackControls,\n Easing,\n RepeatType,\n Transition,\n} from \"motion\";\nimport { POSITION, type Position } from \"./consts\";\n\nexport function hideElement<T extends HTMLElement>(element: T) {\n element.style.display = \"none\";\n}\n\nexport function showElement<T extends HTMLElement>(element: T) {\n element.style.display = \"block\";\n}\n\nexport async function controlPromise(controls: AnimationPlaybackControls) {\n return new Promise((resolve) => {\n controls.then(() => resolve(null));\n });\n}\n\nexport function convertPositionToTranslate(position: Position) {\n if (position === POSITION.TOP || position === POSITION.BOTTOM)\n return [\"translateY(var(--d-slide-from))\", \"translateY(var(--d-slide-to))\"];\n\n return [\"translateX(var(--d-slide-from))\", \"translateX(var(--d-slide-to))\"];\n}\n\nexport function getTransitionConfig(style: CSSStyleDeclaration) {\n const properties = {\n autoplay: style.getPropertyValue(\"--m-autoplay\"),\n bounce: style.getPropertyValue(\"--m-bounce\"),\n bounceDamping: style.getPropertyValue(\"--m-bounce-damping\"),\n bounceStiffness: style.getPropertyValue(\"--m-bounce-stiffness\"),\n duration: style.getPropertyValue(\"--m-duration\"),\n damping: style.getPropertyValue(\"--m-damping\"),\n delay: style.getPropertyValue(\"--m-delay\"),\n ease: style.getPropertyValue(\"--m-ease\"),\n elapsed: style.getPropertyValue(\"--m-elapsed\"),\n mass: style.getPropertyValue(\"--m-mass\"),\n max: style.getPropertyValue(\"--m-max\"),\n min: style.getPropertyValue(\"--m-min\"),\n power: style.getPropertyValue(\"--m-power\"),\n repeat: style.getPropertyValue(\"--m-repeat\"),\n repeatDelay: style.getPropertyValue(\"--m-repeat-delay\"),\n repeatType: style.getPropertyValue(\"--m-repeat-type\"),\n restDelta: style.getPropertyValue(\"--m-rest-delta\"),\n restSpeed: style.getPropertyValue(\"--m-rest-speed\"),\n startTime: style.getPropertyValue(\"--m-start-time\"),\n timeConstant: style.getPropertyValue(\"--m-time-constant\"),\n times: style.getPropertyValue(\"--m-times\"),\n type: style.getPropertyValue(\"--m-type\"),\n velocity: style.getPropertyValue(\"--m-velocity\"),\n visualDuration: style.getPropertyValue(\"--m-visual-duration\"),\n };\n return {\n autoplay: properties.autoplay === \"true\",\n bounce: properties.bounce ? parseFloat(properties.bounce) : undefined,\n bounceDamping: properties.bounceDamping\n ? parseFloat(properties.bounceDamping)\n : undefined,\n bounceStiffness: properties.bounceStiffness\n ? parseFloat(properties.bounceStiffness)\n : undefined,\n duration: properties.duration ? parseFloat(properties.duration) : undefined,\n damping: properties.damping ? parseFloat(properties.damping) : undefined,\n delay: properties.delay ? parseFloat(properties.delay) : undefined,\n ease: properties.ease as Easing,\n elapsed: properties.elapsed ? parseFloat(properties.elapsed) : undefined,\n mass: properties.mass ? parseFloat(properties.mass) : undefined,\n max: properties.max ? parseFloat(properties.max) : undefined,\n min: properties.min ? parseFloat(properties.min) : undefined,\n power: properties.power ? parseFloat(properties.power) : undefined,\n repeat: properties.repeat ? parseInt(properties.repeat) : undefined,\n repeatDelay: properties.repeatDelay\n ? parseFloat(properties.repeatDelay)\n : undefined,\n repeatType: properties.repeatType as RepeatType,\n restDelta: properties.restDelta\n ? parseFloat(properties.restDelta)\n : undefined,\n restSpeed: properties.restSpeed\n ? parseFloat(properties.restSpeed)\n : undefined,\n startTime: properties.startTime\n ? parseFloat(properties.startTime)\n : undefined,\n timeConstant: properties.timeConstant\n ? parseFloat(properties.timeConstant)\n : undefined,\n type: properties.type as AnimationGeneratorType,\n velocity: properties.velocity ? parseFloat(properties.velocity) : undefined,\n visualDuration: properties.visualDuration\n ? parseFloat(properties.visualDuration)\n : undefined,\n } satisfies Transition;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@brytdesigns/web-component-drawer",
3
+ "version": "1.0.0",
4
+ "description": "Headless drawer web component",
5
+ "main": "./dist/main/index.js",
6
+ "module": "./dist/main/index.js",
7
+ "types": "./dist/main/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/main/index.d.ts",
12
+ "module": "./dist/main/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "keywords": [],
19
+ "author": "Bryt Designs",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "body-scroll-lock-upgrade": "^1.1.0",
23
+ "component-register": "^0.8.7",
24
+ "focus-trap": "^7.6.4",
25
+ "motion": "^12.5.0",
26
+ "observe-element-in-viewport": "^0.0.15",
27
+ "solid-element": "^1.9.1",
28
+ "solid-js": "^1.9.5",
29
+ "@brytdesigns/web-component-utils": "0.1.8"
30
+ },
31
+ "devDependencies": {
32
+ "dts-bundle-generator": "^9.5.1",
33
+ "tsup": "^8.4.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup --clean",
37
+ "typecheck": "tsc --noEmit"
38
+ }
39
+ }