@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.
@@ -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-content";
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$1 = {
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$1 = "drawer-trigger";
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 withDrawerElementContext: <D extends unknown>(target: string | import("solid-js").Accessor<string> | import("solid-js").Accessor<() => Element>, dependencies: import("solid-js").Accessor<D> | undefined, cb: (context: readonly [
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 setStore: import("solid-js/store").SetStoreFunction<StoreContext>;
71
+ readonly setAnimationQueue: import("solid-js").Setter<AnimationPlaybackControlsWithThen[]>;
70
72
  }
71
- ], dependencies: D) => void | (() => void)) => void;
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 = DrawerContext.Props;
87
- export type DrawerTriggerProps = Props$1;
88
- export type DrawerBackdropProps = Props$2;
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 DrawerContext {
92
+ declare namespace DrawerTrigger {
91
93
  export { Component$3 as Component, Name$3 as Name, Props$3 as Props };
92
94
  }
93
95
 
@@ -1,33 +1,29 @@
1
- import { customShadowlessElement, correctElementType } from '@brytdesigns/web-component-core/utils';
2
- import { DrawerContext, DrawerTrigger, DrawerBackdrop, DrawerContent } from './components/index.js';
3
- export { getDrawerContext, useDrawer, withDrawerElementContext } from './hooks/index.js';
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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAiBA,uBAAA;AAAA,EACC,aAAc,CAAA,IAAA;AAAA,EACd;AAAA,IACC,MAAQ,EAAA,KAAA;AAAA,IACR,EAAA,EAAI,OAAO,UAAW,EAAA;AAAA,IACtB,aAAe,EAAA,KAAA;AAAA,IACf,eAAiB,EAAA,KAAA;AAAA,IACjB,WAAa,EAAA,KAAA;AAAA,IACb,KAAO,EAAA;AAAA,GACR;AAAA,EACA,kBAAA,CAAmB,cAAc,SAAS;AAC3C,CAAA;AAEA,uBAAA;AAAA,EACC,aAAc,CAAA,IAAA;AAAA,EACd,EAAE,QAAQ,EAAI,EAAA,MAAA,EAAQ,IAAI,EAAI,EAAA,OAAA,EAAS,gBAAgB,IAAK,EAAA;AAAA,EAC5D,kBAAA,CAAmB,cAAc,SAAS;AAC3C,CAAA;AAEA,uBAAA;AAAA,EACC,cAAe,CAAA,IAAA;AAAA,EACf,EAAC;AAAA,EACD,kBAAA,CAAmB,eAAe,SAAS;AAC5C,CAAA;AAEA,uBAAA;AAAA,EACC,aAAc,CAAA,IAAA;AAAA,EACd,EAAC;AAAA,EACD,kBAAA,CAAmB,cAAc,SAAS;AAC3C,CAAA","file":"index.js","sourcesContent":["import {\r\n\tcustomShadowlessElement,\r\n\tcorrectElementType,\r\n} from \"@brytdesigns/web-component-core/utils\";\r\n\r\nimport {\r\n\tDrawerContent,\r\n\tDrawerContext,\r\n\tDrawerTrigger,\r\n\tDrawerBackdrop,\r\n} from \"./components/index.js\";\r\n\r\nexport type DrawerContentProps = DrawerContent.Props;\r\nexport type DrawerContextProps = DrawerContext.Props;\r\nexport type DrawerTriggerProps = DrawerTrigger.Props;\r\nexport type DrawerBackdropProps = DrawerBackdrop.Props;\r\n\r\ncustomShadowlessElement(\r\n\tDrawerContext.Name,\r\n\t{\r\n\t\tisOpen: false,\r\n\t\tid: crypto.randomUUID(),\r\n\t\tcloseOnEscape: false,\r\n\t\tshouldTrapFocus: false,\r\n\t\tisAnimating: false,\r\n\t\tdebug: false,\r\n\t},\r\n\tcorrectElementType(DrawerContext.Component),\r\n);\r\n\r\ncustomShadowlessElement(\r\n\tDrawerTrigger.Name,\r\n\t{ target: \"\", action: \"\", on: \"click\", preventDefault: true },\r\n\tcorrectElementType(DrawerTrigger.Component),\r\n);\r\n\r\ncustomShadowlessElement(\r\n\tDrawerBackdrop.Name,\r\n\t{},\r\n\tcorrectElementType(DrawerBackdrop.Component),\r\n);\r\n\r\ncustomShadowlessElement(\r\n\tDrawerContent.Name,\r\n\t{},\r\n\tcorrectElementType(DrawerContent.Component),\r\n);\r\n\r\nexport {\r\n\tuseDrawer,\r\n\twithDrawerElementContext,\r\n\tgetDrawerContext,\r\n} from \"./hooks/index.js\";\r\n"]}
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"}
@@ -1,10 +1,11 @@
1
+ //#region src/utils.ts
1
2
  function hideElement(element) {
2
- element.style.display = "none";
3
+ element.style.display = "none";
3
4
  }
4
5
  function showElement(element) {
5
- element.style.display = "block";
6
+ element.style.display = "block";
6
7
  }
7
-
8
+ //#endregion
8
9
  export { hideElement, showElement };
9
- //# sourceMappingURL=utils.js.map
10
+
10
11
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.ts"],"names":[],"mappings":"AAAO,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","file":"utils.js","sourcesContent":["export function hideElement<T extends HTMLElement>(element: T) {\r\n element.style.display = \"none\";\r\n}\r\n\r\nexport function showElement<T extends HTMLElement>(element: T) {\r\n element.style.display = \"block\";\r\n}\r\n"]}
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": "1.1.12",
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
- "module": "./dist/main/index.js"
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.40.0",
26
+ "motion": "^12.43.0",
26
27
  "observe-element-in-viewport": "^0.0.15",
27
- "solid-element": "^1.9.1",
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
- "dts-bundle-generator": "^9.5.1",
33
- "tsup": "^8.4.0"
31
+ "@repo/vite-config": "0.0.0",
32
+ "vite": "^8.2.2"
34
33
  },
35
34
  "scripts": {
36
- "build": "tsup --clean",
35
+ "build": "vite build",
37
36
  "typecheck": "tsc --noEmit"
38
37
  }
39
38
  }