@brytdesigns/web-component-drawer 1.1.12 → 3.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.
- package/dist/main/components/drawer-backdrop.js +50 -77
- package/dist/main/components/drawer-backdrop.js.map +1 -1
- package/dist/main/components/drawer-content.js +60 -83
- package/dist/main/components/drawer-content.js.map +1 -1
- package/dist/main/components/drawer-context.js +119 -113
- package/dist/main/components/drawer-context.js.map +1 -1
- package/dist/main/components/drawer-trigger.js +90 -71
- package/dist/main/components/drawer-trigger.js.map +1 -1
- package/dist/main/components/index.js +4 -10
- package/dist/main/consts.js +8 -13
- package/dist/main/consts.js.map +1 -1
- package/dist/main/hooks/index.js +2 -3
- package/dist/main/hooks/useDrawer.js +85 -81
- package/dist/main/hooks/useDrawer.js.map +1 -1
- package/dist/main/index.d.ts +32 -30
- package/dist/main/index.js +27 -31
- package/dist/main/index.js.map +1 -1
- package/dist/main/utils.js +5 -4
- package/dist/main/utils.js.map +1 -1
- package/package.json +8 -9
- package/dist/esm/index.js +0 -491
- package/dist/esm/index.js.map +0 -1
- package/dist/main/components/index.js.map +0 -1
- package/dist/main/hooks/index.js.map +0 -1
package/dist/main/index.d.ts
CHANGED
|
@@ -3,43 +3,45 @@
|
|
|
3
3
|
import { ICustomElement } from 'component-register';
|
|
4
4
|
import { AnimationPlaybackControlsWithThen } from 'motion';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* `component-register` types `options.element` as a bare `ICustomElement`, but
|
|
8
|
+
* at runtime it is always also an `HTMLElement`. Every component in this repo
|
|
9
|
+
* needs the DOM half.
|
|
10
|
+
*/
|
|
6
11
|
export type CorrectComponentOptions = {
|
|
7
12
|
element: HTMLElement & ICustomElement;
|
|
8
13
|
};
|
|
9
14
|
export type CorrectComponentType<T> = (props: T, options: CorrectComponentOptions) => unknown;
|
|
10
15
|
export type Props = {};
|
|
11
|
-
declare const Name = "drawer-
|
|
16
|
+
declare const Name = "drawer-backdrop";
|
|
12
17
|
declare const Component: CorrectComponentType<Props>;
|
|
18
|
+
type Props$1 = {};
|
|
19
|
+
declare const Name$1 = "drawer-content";
|
|
20
|
+
declare const Component$1: CorrectComponentType<Props$1>;
|
|
21
|
+
type Props$2 = {
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
id: string;
|
|
24
|
+
closeOnEscape: boolean;
|
|
25
|
+
shouldTrapFocus: boolean;
|
|
26
|
+
isAnimating: boolean;
|
|
27
|
+
debug?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const Name$2 = "drawer-context";
|
|
30
|
+
declare const Component$2: CorrectComponentType<Props$2>;
|
|
13
31
|
export type Action = (typeof ACTION)[keyof typeof ACTION];
|
|
14
32
|
declare const ACTION: {
|
|
15
33
|
OPEN: string;
|
|
16
34
|
CLOSE: string;
|
|
17
35
|
TOGGLE: string;
|
|
18
36
|
};
|
|
19
|
-
type Props$
|
|
37
|
+
type Props$3 = {
|
|
20
38
|
target?: string;
|
|
21
39
|
action?: Action | "";
|
|
22
40
|
on?: keyof HTMLElementEventMap | "enter" | "exit";
|
|
23
41
|
preventDefault: boolean;
|
|
24
42
|
};
|
|
25
|
-
declare const Name$
|
|
26
|
-
declare const Component$1: CorrectComponentType<Props$1>;
|
|
27
|
-
type Props$2 = {};
|
|
28
|
-
declare const Name$2 = "drawer-backdrop";
|
|
29
|
-
declare const Component$2: CorrectComponentType<Props$2>;
|
|
30
|
-
type Props$3 = {
|
|
31
|
-
isOpen: boolean;
|
|
32
|
-
id: string;
|
|
33
|
-
closeOnEscape: boolean;
|
|
34
|
-
shouldTrapFocus: boolean;
|
|
35
|
-
isAnimating: boolean;
|
|
36
|
-
debug?: boolean;
|
|
37
|
-
};
|
|
38
|
-
declare const Name$3 = "drawer-context";
|
|
43
|
+
declare const Name$3 = "drawer-trigger";
|
|
39
44
|
declare const Component$3: CorrectComponentType<Props$3>;
|
|
40
|
-
export type StoreContext = {
|
|
41
|
-
animationQueue: AnimationPlaybackControlsWithThen[];
|
|
42
|
-
};
|
|
43
45
|
export type CreateContextOptions = {
|
|
44
46
|
root: HTMLElement & ICustomElement;
|
|
45
47
|
isOpen: boolean;
|
|
@@ -49,7 +51,7 @@ export declare const useDrawer: (element: HTMLElement & ICustomElement) => reado
|
|
|
49
51
|
{
|
|
50
52
|
isOpen: boolean;
|
|
51
53
|
isAnimating: boolean;
|
|
52
|
-
animationQueue: AnimationPlaybackControlsWithThen[];
|
|
54
|
+
readonly animationQueue: AnimationPlaybackControlsWithThen[];
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
readonly updateAnimationQueue: (animation: AnimationPlaybackControlsWithThen) => void;
|
|
@@ -58,22 +60,22 @@ export declare const useDrawer: (element: HTMLElement & ICustomElement) => reado
|
|
|
58
60
|
readonly toggle: () => void;
|
|
59
61
|
}
|
|
60
62
|
];
|
|
61
|
-
export declare const
|
|
63
|
+
export declare const useDrawerAt: (target: () => string | undefined, host: HTMLElement) => import("solid-js").SourceAccessor<readonly [
|
|
62
64
|
{
|
|
63
65
|
isOpen: boolean;
|
|
64
66
|
isAnimating: boolean;
|
|
65
|
-
animationQueue: AnimationPlaybackControlsWithThen[];
|
|
67
|
+
readonly animationQueue: AnimationPlaybackControlsWithThen[];
|
|
66
68
|
},
|
|
67
69
|
{
|
|
68
70
|
readonly setElementState: (key: keyof Omit<CreateContextOptions, "root">, value: boolean | ((v: boolean) => boolean)) => void;
|
|
69
|
-
readonly
|
|
71
|
+
readonly setAnimationQueue: import("solid-js").Setter<AnimationPlaybackControlsWithThen[]>;
|
|
70
72
|
}
|
|
71
|
-
]
|
|
73
|
+
]>;
|
|
72
74
|
export declare const getDrawerContext: (element: Element) => readonly [
|
|
73
75
|
{
|
|
74
76
|
isOpen: boolean;
|
|
75
77
|
isAnimating: boolean;
|
|
76
|
-
animationQueue: AnimationPlaybackControlsWithThen[];
|
|
78
|
+
readonly animationQueue: AnimationPlaybackControlsWithThen[];
|
|
77
79
|
},
|
|
78
80
|
{
|
|
79
81
|
readonly updateAnimationQueue: (animation: AnimationPlaybackControlsWithThen) => void;
|
|
@@ -82,12 +84,12 @@ export declare const getDrawerContext: (element: Element) => readonly [
|
|
|
82
84
|
readonly toggle: () => void;
|
|
83
85
|
}
|
|
84
86
|
];
|
|
85
|
-
export type DrawerContentProps = Props;
|
|
86
|
-
export type DrawerContextProps =
|
|
87
|
-
export type DrawerTriggerProps = Props
|
|
88
|
-
export type DrawerBackdropProps = Props
|
|
87
|
+
export type DrawerContentProps = Props$1;
|
|
88
|
+
export type DrawerContextProps = Props$2;
|
|
89
|
+
export type DrawerTriggerProps = DrawerTrigger.Props;
|
|
90
|
+
export type DrawerBackdropProps = Props;
|
|
89
91
|
|
|
90
|
-
declare namespace
|
|
92
|
+
declare namespace DrawerTrigger {
|
|
91
93
|
export { Component$3 as Component, Name$3 as Name, Props$3 as Props };
|
|
92
94
|
}
|
|
93
95
|
|
package/dist/main/index.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { getDrawerContext, useDrawer, useDrawerAt } from "./hooks/useDrawer.js";
|
|
2
|
+
import "./hooks/index.js";
|
|
3
|
+
import { Component, Name } from "./components/drawer-backdrop.js";
|
|
4
|
+
import { Component as Component$1, Name as Name$1 } from "./components/drawer-content.js";
|
|
5
|
+
import { Component as Component$2, Name as Name$2 } from "./components/drawer-context.js";
|
|
6
|
+
import { Component as Component$3, Name as Name$3 } from "./components/drawer-trigger.js";
|
|
7
|
+
import "./components/index.js";
|
|
8
|
+
import { customShadowlessElement } from "@brytdesigns/web-component-core/utils";
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
customShadowlessElement(Name$2, {
|
|
11
|
+
isOpen: false,
|
|
12
|
+
id: crypto.randomUUID(),
|
|
13
|
+
closeOnEscape: true,
|
|
14
|
+
shouldTrapFocus: true,
|
|
15
|
+
isAnimating: false,
|
|
16
|
+
debug: false
|
|
17
|
+
}, Component$2);
|
|
18
|
+
customShadowlessElement(Name$3, {
|
|
19
|
+
target: "",
|
|
20
|
+
action: "",
|
|
21
|
+
on: "click",
|
|
22
|
+
preventDefault: true
|
|
23
|
+
}, Component$3);
|
|
24
|
+
customShadowlessElement(Name, {}, Component);
|
|
25
|
+
customShadowlessElement(Name$1, {}, Component$1);
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getDrawerContext, useDrawer, useDrawerAt };
|
|
4
28
|
|
|
5
|
-
customShadowlessElement(
|
|
6
|
-
DrawerContext.Name,
|
|
7
|
-
{
|
|
8
|
-
isOpen: false,
|
|
9
|
-
id: crypto.randomUUID(),
|
|
10
|
-
closeOnEscape: false,
|
|
11
|
-
shouldTrapFocus: false,
|
|
12
|
-
isAnimating: false,
|
|
13
|
-
debug: false
|
|
14
|
-
},
|
|
15
|
-
correctElementType(DrawerContext.Component)
|
|
16
|
-
);
|
|
17
|
-
customShadowlessElement(
|
|
18
|
-
DrawerTrigger.Name,
|
|
19
|
-
{ target: "", action: "", on: "click", preventDefault: true },
|
|
20
|
-
correctElementType(DrawerTrigger.Component)
|
|
21
|
-
);
|
|
22
|
-
customShadowlessElement(
|
|
23
|
-
DrawerBackdrop.Name,
|
|
24
|
-
{},
|
|
25
|
-
correctElementType(DrawerBackdrop.Component)
|
|
26
|
-
);
|
|
27
|
-
customShadowlessElement(
|
|
28
|
-
DrawerContent.Name,
|
|
29
|
-
{},
|
|
30
|
-
correctElementType(DrawerContent.Component)
|
|
31
|
-
);
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
33
29
|
//# sourceMappingURL=index.js.map
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { customShadowlessElement } from \"@brytdesigns/web-component-core/utils\";\n\nimport {\n\tDrawerBackdrop,\n\tDrawerContent,\n\tDrawerContext,\n\tDrawerTrigger,\n} from \"./components/index.js\";\n\nexport type DrawerContentProps = DrawerContent.Props;\nexport type DrawerContextProps = DrawerContext.Props;\nexport type DrawerTriggerProps = DrawerTrigger.Props;\nexport type DrawerBackdropProps = DrawerBackdrop.Props;\n\ncustomShadowlessElement(\n\tDrawerContext.Name,\n\t{\n\t\tisOpen: false,\n\t\tid: crypto.randomUUID(),\n\t\t// On by default: an overlay that traps nothing and closes on no key is\n\t\t// not a dialog. Set close-on-escape=\"false\" / should-trap-focus=\"false\"\n\t\t// in markup to opt out.\n\t\tcloseOnEscape: true,\n\t\tshouldTrapFocus: true,\n\t\tisAnimating: false,\n\t\tdebug: false,\n\t},\n\tDrawerContext.Component,\n);\n\ncustomShadowlessElement(\n\tDrawerTrigger.Name,\n\t{ target: \"\", action: \"\", on: \"click\", preventDefault: true },\n\tDrawerTrigger.Component,\n);\n\ncustomShadowlessElement(DrawerBackdrop.Name, {}, DrawerBackdrop.Component);\n\ncustomShadowlessElement(DrawerContent.Name, {}, DrawerContent.Component);\n\nexport {\n\tgetDrawerContext,\n\tuseDrawer,\n\tuseDrawerAt,\n} from \"./hooks/index.js\";\n"],"mappings":";;;;;;;;;AAcA,wBACC,QACA;CACC,QAAQ;CACR,IAAI,OAAO,WAAW;CAItB,eAAe;CACf,iBAAiB;CACjB,aAAa;CACb,OAAO;AACR,GACA,WACD;AAEA,wBACC,QACA;CAAE,QAAQ;CAAI,QAAQ;CAAI,IAAI;CAAS,gBAAgB;AAAK,GAC5D,WACD;AAEA,wBAAwB,MAAqB,CAAC,GAAG,SAAwB;AAEzE,wBAAwB,QAAoB,CAAC,GAAG,WAAuB"}
|
package/dist/main/utils.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
//#region src/utils.ts
|
|
1
2
|
function hideElement(element) {
|
|
2
|
-
|
|
3
|
+
element.style.display = "none";
|
|
3
4
|
}
|
|
4
5
|
function showElement(element) {
|
|
5
|
-
|
|
6
|
+
element.style.display = "block";
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
8
9
|
export { hideElement, showElement };
|
|
9
|
-
|
|
10
|
+
|
|
10
11
|
//# sourceMappingURL=utils.js.map
|
package/dist/main/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export function hideElement<T extends HTMLElement>(element: T) {\n\telement.style.display = \"none\";\n}\n\nexport function showElement<T extends HTMLElement>(element: T) {\n\telement.style.display = \"block\";\n}\n"],"mappings":";AAAA,SAAgB,YAAmC,SAAY;CAC9D,QAAQ,MAAM,UAAU;AACzB;AAEA,SAAgB,YAAmC,SAAY;CAC9D,QAAQ,MAAM,UAAU;AACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brytdesigns/web-component-drawer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Headless drawer web component",
|
|
5
5
|
"main": "./dist/main/index.js",
|
|
6
6
|
"module": "./dist/main/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/main/index.d.ts",
|
|
12
|
-
"
|
|
12
|
+
"default": "./dist/main/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -20,20 +20,19 @@
|
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"peer-dependencies": {},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@brytdesigns/web-component-core": "3.0.0",
|
|
23
24
|
"body-scroll-lock-upgrade": "^1.1.0",
|
|
24
25
|
"component-register": "0.8.7",
|
|
25
|
-
"motion": "^12.
|
|
26
|
+
"motion": "^12.43.0",
|
|
26
27
|
"observe-element-in-viewport": "^0.0.15",
|
|
27
|
-
"solid-
|
|
28
|
-
"solid-js": "^1.9.9",
|
|
29
|
-
"@brytdesigns/web-component-core": "1.1.7"
|
|
28
|
+
"solid-js": "2.0.0-rc.14"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
31
|
+
"@repo/vite-config": "0.0.0",
|
|
32
|
+
"vite": "^8.2.2"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
|
-
"build": "
|
|
35
|
+
"build": "vite build",
|
|
37
36
|
"typecheck": "tsc --noEmit"
|
|
38
37
|
}
|
|
39
38
|
}
|