jb-modal 1.6.1 → 1.7.1

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.
Files changed (53) hide show
  1. package/README.md +48 -2
  2. package/dist/jb-modal.cjs.js +2 -0
  3. package/dist/jb-modal.cjs.js.br +0 -0
  4. package/dist/jb-modal.cjs.js.gz +0 -0
  5. package/dist/jb-modal.cjs.js.map +1 -0
  6. package/dist/{JBModal.d.ts → jb-modal.d.ts} +8 -7
  7. package/dist/jb-modal.js +2 -0
  8. package/dist/jb-modal.js.br +0 -0
  9. package/dist/jb-modal.js.gz +0 -0
  10. package/dist/jb-modal.js.map +1 -0
  11. package/dist/jb-modal.umd.js +2 -0
  12. package/dist/jb-modal.umd.js.br +0 -0
  13. package/dist/jb-modal.umd.js.gz +0 -0
  14. package/dist/jb-modal.umd.js.map +1 -0
  15. package/dist/types.d.ts +7 -0
  16. package/index.js +1 -1
  17. package/lib/{JBModal.scss → jb-modal.scss} +1 -1
  18. package/lib/jb-modal.ts +158 -0
  19. package/lib/types.ts +9 -0
  20. package/package.json +9 -3
  21. package/react/LICENSE +21 -0
  22. package/react/README.md +82 -0
  23. package/react/dist/JBModal.cjs.js +2 -0
  24. package/react/dist/JBModal.cjs.js.map +1 -0
  25. package/react/dist/JBModal.d.ts +26 -0
  26. package/react/dist/JBModal.js +2 -0
  27. package/react/dist/JBModal.js.map +1 -0
  28. package/react/dist/JBModal.umd.js +2 -0
  29. package/react/dist/JBModal.umd.js.map +1 -0
  30. package/react/dist/common/hooks/use-event.d.ts +3 -0
  31. package/react/dist/common/hooks/useLazyRef.d.ts +4 -0
  32. package/react/dist/common/hooks/useMobx.d.ts +4 -0
  33. package/react/dist/common/scripts/device-detection.d.ts +1 -0
  34. package/react/dist/common/scripts/persian-helper.d.ts +3 -0
  35. package/react/dist/events-hook.d.ts +18 -0
  36. package/react/dist/lib/JBModal.d.ts +26 -0
  37. package/react/dist/lib/events-hook.d.ts +18 -0
  38. package/react/dist/web-component/jb-modal/react/lib/JBModal.d.ts +26 -0
  39. package/react/dist/web-component/jb-modal/react/lib/events-hook.d.ts +18 -0
  40. package/react/index.js +1 -0
  41. package/react/lib/JBModal.tsx +62 -0
  42. package/react/lib/events-hook.ts +25 -0
  43. package/react/package.json +38 -0
  44. package/react/tsconfig.json +16 -0
  45. package/dist/JBModal.js +0 -186
  46. package/dist/JBModal.js.map +0 -1
  47. package/dist/JBModal.umd.js +0 -196
  48. package/dist/JBModal.umd.js.map +0 -1
  49. package/dist/Types.d.ts +0 -4
  50. package/lib/JBModal.ts +0 -158
  51. package/lib/Types.ts +0 -4
  52. package/lib/global.d.ts +0 -11
  53. /package/lib/{JBModal.html → jb-modal.html} +0 -0
@@ -0,0 +1,2 @@
1
+ var e,t;e=this,t=function(e,t,r,n){"use strict";var o=Object.create,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,d=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var o,u=c(t),d=0,f=u.length;d<f;d++)o=u[d],s.call(e,o)||o===r||l(e,o,{get:(e=>t[e]).bind(null,o),enumerable:!(n=a(t,o))||n.enumerable});return e},f=(e,t,r)=>(r=null!=e?o(u(e)):{},d(!t&&e&&e.__esModule?r:l(r,"default",{value:e,enumerable:!0}),e));t=f(t),n=f(n);let i=t.default.forwardRef((e,r)=>{let o=(0,t.useRef)(null),[l,a]=(0,t.useState)(0);return(0,t.useImperativeHandle)(r,()=>o?o.current:{},[o]),(0,t.useEffect)(()=>{a(l+1)},[o.current]),(0,t.useEffect)(()=>{o.current&&(!0==e.isOpen?o.current.open():o.current.close())},[e.isOpen]),(0,t.useEffect)(()=>{o.current&&(o.current.id=e.id)},[e.id]),(0,n.useEvent)(o,"load",e.onLoad,!0),(0,n.useEvent)(o,"init",e.onInit,!0),(0,n.useEvent)(o,"close",e.onClose),(0,n.useEvent)(o,"urlOpen",e.onUrlOpen),t.default.createElement("jb-modal",{ref:o,class:e.className?e.className:""},t.default.createElement("div",{slot:"content"},e.children))});i.displayName="JBModal",e.JBModal=i},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("jb-modal"),require("jb-core/react")):"function"==typeof define&&define.amd?define(["exports","react","jb-modal","jb-core/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBModalReact={},e.React,e.JBModal,e.JBCoreReact);
2
+ //# sourceMappingURL=JBModal.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JBModal.umd.js","names":[],"sources":["../lib/events-hook.ts","../lib/JBModal.tsx"],"sourcesContent":["import { useEvent } from \"jb-core/react\";\r\nimport { RefObject } from \"react\";\r\nimport type {JBModalWebComponent, JBModalEventType} from 'jb-modal';\r\n\r\nexport type EventProps = {\r\n /**\r\n * when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount\r\n */\r\n onLoad?: (e: JBModalEventType<CustomEvent>) => void,\r\n /**\r\n * when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount\r\n */\r\n onInit?: (e: JBModalEventType<CustomEvent>) => void,\r\n onClose?: (e: JBModalEventType<CustomEvent>) => void,\r\n /**\r\n * when modal opened automatically by url hash (when element have id and url has #id) use this to update open state in parent component\r\n */\r\n onUrlOpen?: (e: JBModalEventType<CustomEvent>) => void,\r\n}\r\nexport function useEvents(element:RefObject<JBModalWebComponent>,props:EventProps){\r\n useEvent(element, 'load', props.onLoad, true);\r\n useEvent(element, 'init', props.onInit, true);\r\n useEvent(element, 'close', props.onClose);\r\n useEvent(element, 'urlOpen', props.onUrlOpen);\r\n}","import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';\r\nimport 'jb-modal';\r\n// eslint-disable-next-line no-duplicate-imports\r\nimport { JBModalWebComponent } from 'jb-modal';\r\nimport { useEvents, EventProps } from './events-hook.js';\r\n\r\nexport type Props = EventProps & React.PropsWithChildren<{\r\n className?:string,\r\n isOpen?: boolean,\r\n id?: string,\r\n}>\r\n\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/no-namespace\r\n namespace JSX {\r\n interface IntrinsicElements {\r\n 'jb-modal': JBModalType;\r\n }\r\n interface JBModalType extends React.DetailedHTMLProps<React.HTMLAttributes<JBModalWebComponent>, JBModalWebComponent> {\r\n class?:string,\r\n }\r\n }\r\n}\r\n\r\nexport const JBModal = React.forwardRef((props:Props, ref) => {\r\n const element = useRef<JBModalWebComponent>(null);\r\n const [refChangeCount, refChangeCountSetter] = useState(0);\r\n useImperativeHandle(\r\n ref,\r\n () => (element ? element.current : {}),\r\n [element],\r\n );\r\n useEffect(() => {\r\n refChangeCountSetter(refChangeCount + 1);\r\n }, [element.current]);\r\n useEffect(() => {\r\n if (element.current) {\r\n if (props.isOpen == true) {\r\n element.current.open();\r\n } else {\r\n element.current.close();\r\n }\r\n }\r\n\r\n }, [props.isOpen]);\r\n useEffect(() => {\r\n if (element.current) {\r\n element.current.id = props.id;\r\n }\r\n }, [props.id]);\r\n\r\n useEvents(element, props);\r\n return (\r\n <jb-modal ref={element} class={props.className ? props.className : ''}>\r\n <div slot=\"content\">\r\n {props.children}\r\n </div>\r\n </jb-modal>\r\n );\r\n});\r\n\r\nJBModal.displayName = \"JBModal\";\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBM,SAAU,UAAU,SAAuC,OAAgB;AAC/E,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AACzC,6BAAS,SAAS,WAAW,MAAM,UAAU;AAC9C;;;;MCAY,wBAAgB,cAAY,WAAkB,CAAE,OAAA,QAAA;CAC3D,MAAM,UAAU,kBAA4B,KAAK;CACjD,MAAM,CAAC,gBAAgB,qBAAqB,GAAG,oBAAS,EAAE;AAC1D,gCACE,KACA,MAAG,UAAW,QAAG,UAAe,CAAE,GAAC,CAGrC;AAEA,sBAAI,MAAQ;AACZ,uBAAe,iBAAA,EAAA;aAEP;sBAEH,MAAA;cAAM,aACL,MAAA,UAAgB,KACjB,SAAA,QAAA,MAAA;MAGK,SAAS,QAAA,OAAA;WAIhB,MACF,EAAA;AAED,sBAAU,MAAA;AACV,MACE,QAAA,QACE,SAAA,QAAA,KAAA,MAAK;CAOX,GAAO"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function useEvent(dom: HTMLElement, event: any, handler: any, passive?: boolean): void;
3
+ export declare function useBindEvent<TRef extends React.MutableRefObject<any | null>, TEvent>(ref: TRef, event: string, handler: (e: TEvent) => void, passive?: boolean): void;
@@ -0,0 +1,4 @@
1
+ import { MutableRefObject } from "react";
2
+ type InitFunc<T> = () => T;
3
+ export declare const useLazyRef: <T>(initValFunc: InitFunc<T>) => MutableRefObject<any>;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ type Initializers = any[];
2
+ type Constructor<T extends object = object> = new (...args: any[]) => T;
3
+ export declare const useMobx: <T extends object>(Store: Constructor<T>, initializers: Initializers) => T;
4
+ export {};
@@ -0,0 +1 @@
1
+ export declare const isMobile: () => boolean;
@@ -0,0 +1,3 @@
1
+ declare function faToEnDigits(input: string | number): string;
2
+ declare function enToFaDigits(input: string | number): string;
3
+ export { enToFaDigits, faToEnDigits };
@@ -0,0 +1,18 @@
1
+ import { RefObject } from "react";
2
+ import type { JBModalWebComponent, JBModalEventType } from 'jb-modal';
3
+ export type EventProps = {
4
+ /**
5
+ * when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
6
+ */
7
+ onLoad?: (e: JBModalEventType<CustomEvent>) => void;
8
+ /**
9
+ * when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
10
+ */
11
+ onInit?: (e: JBModalEventType<CustomEvent>) => void;
12
+ onClose?: (e: JBModalEventType<CustomEvent>) => void;
13
+ /**
14
+ * when modal opened automatically by url hash (when element have id and url has #id) use this to update open state in parent component
15
+ */
16
+ onUrlOpen?: (e: JBModalEventType<CustomEvent>) => void;
17
+ };
18
+ export declare function useEvents(element: RefObject<JBModalWebComponent>, props: EventProps): void;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import 'jb-modal';
3
+ import { JBModalWebComponent } from 'jb-modal';
4
+ import { EventProps } from './events-hook.js';
5
+ export type Props = EventProps & React.PropsWithChildren<{
6
+ className?: string;
7
+ isOpen?: boolean;
8
+ id?: string;
9
+ }>;
10
+ declare global {
11
+ namespace JSX {
12
+ interface IntrinsicElements {
13
+ 'jb-modal': JBModalType;
14
+ }
15
+ interface JBModalType extends React.DetailedHTMLProps<React.HTMLAttributes<JBModalWebComponent>, JBModalWebComponent> {
16
+ class?: string;
17
+ }
18
+ }
19
+ }
20
+ export declare const JBModal: React.ForwardRefExoticComponent<EventProps & {
21
+ className?: string;
22
+ isOpen?: boolean;
23
+ id?: string;
24
+ } & {
25
+ children?: React.ReactNode;
26
+ } & React.RefAttributes<unknown>>;
@@ -0,0 +1,18 @@
1
+ import { RefObject } from "react";
2
+ import type { JBModalWebComponent, JBModalEventType } from 'jb-modal';
3
+ export type EventProps = {
4
+ /**
5
+ * when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
6
+ */
7
+ onLoad?: (e: JBModalEventType<CustomEvent>) => void;
8
+ /**
9
+ * when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
10
+ */
11
+ onInit?: (e: JBModalEventType<CustomEvent>) => void;
12
+ onClose?: (e: JBModalEventType<CustomEvent>) => void;
13
+ /**
14
+ * when modal opened automatically by url hash (when element have id and url has #id) use this to update open state in parent component
15
+ */
16
+ onUrlOpen?: (e: JBModalEventType<CustomEvent>) => void;
17
+ };
18
+ export declare function useEvents(element: RefObject<JBModalWebComponent>, props: EventProps): void;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import 'jb-modal';
3
+ import { JBModalWebComponent } from 'jb-modal';
4
+ import { EventProps } from './events-hook.js';
5
+ export type Props = EventProps & React.PropsWithChildren<{
6
+ className?: string;
7
+ isOpen?: boolean;
8
+ id?: string;
9
+ }>;
10
+ declare global {
11
+ namespace JSX {
12
+ interface IntrinsicElements {
13
+ 'jb-modal': JBModalType;
14
+ }
15
+ interface JBModalType extends React.DetailedHTMLProps<React.HTMLAttributes<JBModalWebComponent>, JBModalWebComponent> {
16
+ class?: string;
17
+ }
18
+ }
19
+ }
20
+ export declare const JBModal: React.ForwardRefExoticComponent<EventProps & {
21
+ className?: string;
22
+ isOpen?: boolean;
23
+ id?: string;
24
+ } & {
25
+ children?: React.ReactNode;
26
+ } & React.RefAttributes<unknown>>;
@@ -0,0 +1,18 @@
1
+ import { RefObject } from "react";
2
+ import type { JBModalWebComponent, JBModalEventType } from 'jb-modal';
3
+ export type EventProps = {
4
+ /**
5
+ * when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
6
+ */
7
+ onLoad?: (e: JBModalEventType<CustomEvent>) => void;
8
+ /**
9
+ * when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
10
+ */
11
+ onInit?: (e: JBModalEventType<CustomEvent>) => void;
12
+ onClose?: (e: JBModalEventType<CustomEvent>) => void;
13
+ /**
14
+ * when modal opened automatically by url hash (when element have id and url has #id) use this to update open state in parent component
15
+ */
16
+ onUrlOpen?: (e: JBModalEventType<CustomEvent>) => void;
17
+ };
18
+ export declare function useEvents(element: RefObject<JBModalWebComponent>, props: EventProps): void;
package/react/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/JBModal.js';
@@ -0,0 +1,62 @@
1
+ import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import 'jb-modal';
3
+ // eslint-disable-next-line no-duplicate-imports
4
+ import { JBModalWebComponent } from 'jb-modal';
5
+ import { useEvents, EventProps } from './events-hook.js';
6
+
7
+ export type Props = EventProps & React.PropsWithChildren<{
8
+ className?:string,
9
+ isOpen?: boolean,
10
+ id?: string,
11
+ }>
12
+
13
+ declare global {
14
+ // eslint-disable-next-line @typescript-eslint/no-namespace
15
+ namespace JSX {
16
+ interface IntrinsicElements {
17
+ 'jb-modal': JBModalType;
18
+ }
19
+ interface JBModalType extends React.DetailedHTMLProps<React.HTMLAttributes<JBModalWebComponent>, JBModalWebComponent> {
20
+ class?:string,
21
+ }
22
+ }
23
+ }
24
+
25
+ export const JBModal = React.forwardRef((props:Props, ref) => {
26
+ const element = useRef<JBModalWebComponent>(null);
27
+ const [refChangeCount, refChangeCountSetter] = useState(0);
28
+ useImperativeHandle(
29
+ ref,
30
+ () => (element ? element.current : {}),
31
+ [element],
32
+ );
33
+ useEffect(() => {
34
+ refChangeCountSetter(refChangeCount + 1);
35
+ }, [element.current]);
36
+ useEffect(() => {
37
+ if (element.current) {
38
+ if (props.isOpen == true) {
39
+ element.current.open();
40
+ } else {
41
+ element.current.close();
42
+ }
43
+ }
44
+
45
+ }, [props.isOpen]);
46
+ useEffect(() => {
47
+ if (element.current) {
48
+ element.current.id = props.id;
49
+ }
50
+ }, [props.id]);
51
+
52
+ useEvents(element, props);
53
+ return (
54
+ <jb-modal ref={element} class={props.className ? props.className : ''}>
55
+ <div slot="content">
56
+ {props.children}
57
+ </div>
58
+ </jb-modal>
59
+ );
60
+ });
61
+
62
+ JBModal.displayName = "JBModal";
@@ -0,0 +1,25 @@
1
+ import { useEvent } from "jb-core/react";
2
+ import { RefObject } from "react";
3
+ import type {JBModalWebComponent, JBModalEventType} from 'jb-modal';
4
+
5
+ export type EventProps = {
6
+ /**
7
+ * when component loaded, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
8
+ */
9
+ onLoad?: (e: JBModalEventType<CustomEvent>) => void,
10
+ /**
11
+ * when all property set and ready to use, in most cases component is already loaded before react mount so you dont need this but if you load web-component dynamically with lazy load it will be called after react mount
12
+ */
13
+ onInit?: (e: JBModalEventType<CustomEvent>) => void,
14
+ onClose?: (e: JBModalEventType<CustomEvent>) => void,
15
+ /**
16
+ * when modal opened automatically by url hash (when element have id and url has #id) use this to update open state in parent component
17
+ */
18
+ onUrlOpen?: (e: JBModalEventType<CustomEvent>) => void,
19
+ }
20
+ export function useEvents(element:RefObject<JBModalWebComponent>,props:EventProps){
21
+ useEvent(element, 'load', props.onLoad, true);
22
+ useEvent(element, 'init', props.onInit, true);
23
+ useEvent(element, 'close', props.onClose);
24
+ useEvent(element, 'urlOpen', props.onUrlOpen);
25
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "jb-modal-react",
3
+ "description": "modal react component",
4
+ "type": "module",
5
+ "author": {
6
+ "name": "mohammad javad bathaei",
7
+ "email": "javadbat@gmail.com"
8
+ },
9
+ "keywords": [
10
+ "jb",
11
+ "jb-modal",
12
+ "react component",
13
+ "dialog",
14
+ "modal",
15
+ "react",
16
+ "react modal",
17
+ "modal window",
18
+ "pop up"
19
+ ],
20
+ "version": "1.1.0",
21
+ "bugs": "https://github.com/javadbat/jb-modal/issues",
22
+ "license": "MIT",
23
+ "files": [
24
+ "LICENSE",
25
+ "README.md",
26
+ "lib/",
27
+ "dist/"
28
+ ],
29
+ "main": "index.js",
30
+ "types": "./dist/JBModal.d.ts",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git@github.com:javadbat/jb-modal.git"
34
+ },
35
+ "dependencies": {
36
+ "jb-modal": ">=1.5.3"
37
+ }
38
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "rootDir": "./lib"
5
+ },
6
+ "include": [
7
+ "lib/**/*.ts",
8
+ "lib/**/*.tsx"
9
+ ],
10
+ "exclude": [
11
+ "node_modules",
12
+ "**/*.spec.ts",
13
+ "dist",
14
+ ],
15
+ "extends":"jb-core/configs/tsconfig-react.json"
16
+ }
package/dist/JBModal.js DELETED
@@ -1,186 +0,0 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- function __classPrivateFieldGet(receiver, state, kind, f) {
17
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
- }
21
-
22
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
23
- if (kind === "m") throw new TypeError("Private method is not writable");
24
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
25
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
26
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
27
- }
28
-
29
- var HTML = "<div class=\"jb-modal-web-component --closed\">\r\n <div class=\"modal-background\"></div>\r\n <div class=\"modal-content-wrapper\">\r\n <div class=\"modal-content\">\r\n <slot name=\"content\"></slot>\r\n </div>\r\n </div>\r\n</div>";
30
-
31
- var css_248z = ".jb-modal-web-component {\n position: fixed;\n top: 0;\n left: 0;\n z-index: var(--jb-modal-z-index, 1);\n width: 100%;\n height: 100%; }\n .jb-modal-web-component.--closed {\n display: none; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-modal-web-component.--closed .modal-content-wrapper {\n transform: translateY(100%); } }\n .jb-modal-web-component.--opened {\n display: block; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-modal-web-component.--opened .modal-content-wrapper {\n animation-name: swipe-up;\n animation-duration: 0.3s;\n animation-delay: 0s;\n animation-iteration-count: 1;\n animation-timing-function: ease; } }\n\n@keyframes swipe-up {\n 0% {\n transform: translateY(100%); }\n 100% {\n transform: translateY(0%); } }\n .jb-modal-web-component .modal-background {\n position: absolute;\n top: 0;\n left: 0;\n background-color: var(--jb-modal-back-bg-color, rgba(255, 255, 255, 0.1));\n backdrop-filter: blur(10px);\n z-index: 2;\n width: 100%;\n height: 100%; }\n .jb-modal-web-component .modal-content-wrapper {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: none; }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-modal-web-component .modal-content-wrapper {\n bottom: 0;\n top: initial;\n align-items: flex-end; } }\n .jb-modal-web-component .modal-content-wrapper .modal-content {\n pointer-events: all;\n width: auto;\n height: auto;\n background-color: var(--jb-modal-bg-color, #fff);\n border-radius: var(--jb-modal-border-radius, 24px); }\n @media (min-width: 320px) and (max-width: 767px) {\n .jb-modal-web-component .modal-content-wrapper .modal-content {\n width: 100%;\n height: auto;\n max-height: calc(100% - 80px);\n min-height: 32px;\n border-radius: var(--jb-modal-border-radius-mobile, 24px 24px 0 0);\n overflow-y: auto; } }\n";
32
-
33
- var _JBModalWebComponent_instances, _JBModalWebComponent_isOpen, _JBModalWebComponent_id, _JBModalWebComponent_onBrowserBack;
34
- class JBModalWebComponent extends HTMLElement {
35
- get id() {
36
- const id = this.getAttribute('id') || "";
37
- return __classPrivateFieldGet(this, _JBModalWebComponent_id, "f") || id;
38
- }
39
- set id(value) {
40
- __classPrivateFieldSet(this, _JBModalWebComponent_id, value, "f");
41
- this.checkInitialOpenness();
42
- }
43
- get isOpen() {
44
- return __classPrivateFieldGet(this, _JBModalWebComponent_isOpen, "f");
45
- }
46
- constructor() {
47
- super();
48
- _JBModalWebComponent_instances.add(this);
49
- _JBModalWebComponent_isOpen.set(this, false);
50
- _JBModalWebComponent_id.set(this, "");
51
- this.config = {
52
- autoCloseOnBackgroundClick: false
53
- };
54
- this.initWebComponent();
55
- }
56
- connectedCallback() {
57
- // standard web component event that called when all of dom is binded
58
- this.callOnLoadEvent();
59
- this.initProp();
60
- this.callOnInitEvent();
61
- }
62
- callOnLoadEvent() {
63
- const event = new CustomEvent('load', { bubbles: true, composed: true });
64
- this.dispatchEvent(event);
65
- }
66
- callOnInitEvent() {
67
- const event = new CustomEvent('init', { bubbles: true, composed: true });
68
- this.dispatchEvent(event);
69
- }
70
- initWebComponent() {
71
- const shadowRoot = this.attachShadow({
72
- mode: 'open'
73
- });
74
- const html = `<style>${css_248z}</style>` + '\n' + HTML;
75
- const element = document.createElement('template');
76
- element.innerHTML = html;
77
- shadowRoot.appendChild(element.content.cloneNode(true));
78
- this.elements = {
79
- componentWrapper: shadowRoot.querySelector('.jb-modal-web-component'),
80
- background: shadowRoot.querySelector('.modal-background'),
81
- };
82
- }
83
- registerEventListener() {
84
- this.elements.background.addEventListener('click', this.onBackgroundClick.bind(this));
85
- //TODO: remove listener on component unmount
86
- window.addEventListener('popstate', __classPrivateFieldGet(this, _JBModalWebComponent_instances, "m", _JBModalWebComponent_onBrowserBack).bind(this));
87
- }
88
- initProp() {
89
- this.registerEventListener();
90
- }
91
- checkInitialOpenness() {
92
- //if page has modal url we open it automatically
93
- const location = window.location;
94
- if (location.hash == `#${this.id}`) {
95
- this.triggerUrlOpenEvent();
96
- this.open();
97
- }
98
- }
99
- triggerUrlOpenEvent() {
100
- //when modal open itself becuase url contain modal id
101
- const event = new CustomEvent('urlOpen', { bubbles: true, composed: true });
102
- this.dispatchEvent(event);
103
- }
104
- static get observedAttributes() {
105
- return ['is-open', 'id'];
106
- }
107
- attributeChangedCallback(name, oldValue, newValue) {
108
- // do something when an attribute has changed
109
- this.onAttributeChange(name, newValue);
110
- }
111
- onAttributeChange(name, value) {
112
- switch (name) {
113
- case 'is-open':
114
- if (value == 'true') {
115
- if (!__classPrivateFieldGet(this, _JBModalWebComponent_isOpen, "f")) {
116
- this.open();
117
- }
118
- }
119
- else {
120
- if (__classPrivateFieldGet(this, _JBModalWebComponent_isOpen, "f")) {
121
- this.close();
122
- }
123
- }
124
- break;
125
- case 'id':
126
- this.id = value;
127
- break;
128
- }
129
- }
130
- onBackgroundClick() {
131
- this.dispatchCloseEvent('BACKGROUND_CLICK');
132
- if (this.config.autoCloseOnBackgroundClick) {
133
- this.close();
134
- }
135
- }
136
- dispatchCloseEvent(type) {
137
- //we have many ways to dispatch close event like back button on close clicked
138
- const event = new CustomEvent("close", { detail: { eventType: type } });
139
- this.dispatchEvent(event);
140
- }
141
- /**
142
- * @public
143
- * will close modal
144
- */
145
- close() {
146
- __classPrivateFieldSet(this, _JBModalWebComponent_isOpen, false, "f");
147
- this.elements.componentWrapper.classList.remove('--opened');
148
- this.elements.componentWrapper.classList.add('--closed');
149
- const history = window.history;
150
- const location = window.location;
151
- if (location.hash == `#${this.id}`) {
152
- history.go(-1);
153
- }
154
- }
155
- /**
156
- * @public
157
- * will open modal
158
- */
159
- open() {
160
- __classPrivateFieldSet(this, _JBModalWebComponent_isOpen, true, "f");
161
- this.elements.componentWrapper.classList.remove('--closed');
162
- this.elements.componentWrapper.classList.add('--opened');
163
- if (this.id) {
164
- const history = window.history;
165
- const location = window.location;
166
- if (!(location.hash == `#${this.id}`)) {
167
- history.pushState({ JBModal: {} }, "", `#${this.id}`);
168
- }
169
- }
170
- }
171
- }
172
- _JBModalWebComponent_isOpen = new WeakMap(), _JBModalWebComponent_id = new WeakMap(), _JBModalWebComponent_instances = new WeakSet(), _JBModalWebComponent_onBrowserBack = function _JBModalWebComponent_onBrowserBack(e) {
173
- if (this.isOpen) {
174
- this.dispatchCloseEvent('HISTORY_BACK_EVENT');
175
- if (this.config.autoCloseOnBackgroundClick) {
176
- this.close();
177
- }
178
- }
179
- };
180
- const myElementNotExists = !customElements.get('jb-modal');
181
- if (myElementNotExists) {
182
- window.customElements.define('jb-modal', JBModalWebComponent);
183
- }
184
-
185
- export { JBModalWebComponent };
186
- //# sourceMappingURL=JBModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JBModal.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/JBModal.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.push(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.push(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import HTML from './JBModal.html';\r\nimport CSS from './JBModal.scss';\r\nimport { ElementsObject } from './Types';\r\n\r\nexport class JBModalWebComponent extends HTMLElement {\r\n #isOpen = false;\r\n #id =\"\";\r\n elements!: ElementsObject;\r\n config = {\r\n autoCloseOnBackgroundClick: false\r\n }\r\n get id(){\r\n const id:string =this.getAttribute('id') || \"\";\r\n return this.#id || id;\r\n }\r\n set id(value:string) {\r\n this.#id = value;\r\n this.checkInitialOpenness();\r\n }\r\n get isOpen() {\r\n return this.#isOpen;\r\n }\r\n constructor() {\r\n super();\r\n this.initWebComponent();\r\n }\r\n connectedCallback() {\r\n // standard web component event that called when all of dom is binded\r\n this.callOnLoadEvent();\r\n this.initProp();\r\n this.callOnInitEvent();\r\n\r\n }\r\n callOnLoadEvent() {\r\n const event = new CustomEvent('load', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n callOnInitEvent() {\r\n const event = new CustomEvent('init', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n initWebComponent() {\r\n const shadowRoot = this.attachShadow({\r\n mode: 'open'\r\n });\r\n const html = `<style>${CSS}</style>` + '\\n' + HTML;\r\n const element = document.createElement('template');\r\n element.innerHTML = html;\r\n shadowRoot.appendChild(element.content.cloneNode(true));\r\n this.elements = {\r\n componentWrapper: shadowRoot.querySelector('.jb-modal-web-component')!,\r\n background: shadowRoot.querySelector('.modal-background')!,\r\n }\r\n\r\n }\r\n registerEventListener() {\r\n this.elements.background.addEventListener('click', this.onBackgroundClick.bind(this));\r\n //TODO: remove listener on component unmount\r\n window.addEventListener('popstate', this.#onBrowserBack.bind(this));\r\n }\r\n initProp() {\r\n \r\n this.registerEventListener();\r\n }\r\n checkInitialOpenness() {\r\n //if page has modal url we open it automatically\r\n const location = window.location;\r\n if (location.hash == `#${this.id}`) {\r\n this.triggerUrlOpenEvent();\r\n this.open();\r\n }\r\n }\r\n triggerUrlOpenEvent() {\r\n //when modal open itself becuase url contain modal id\r\n const event = new CustomEvent('urlOpen', { bubbles: true, composed: true });\r\n this.dispatchEvent(event);\r\n }\r\n static get observedAttributes() {\r\n return ['is-open', 'id'];\r\n }\r\n attributeChangedCallback(name, oldValue, newValue) {\r\n // do something when an attribute has changed\r\n this.onAttributeChange(name, newValue);\r\n }\r\n onAttributeChange(name, value) {\r\n switch (name) {\r\n case 'is-open':\r\n if (value == 'true') {\r\n if (!this.#isOpen) {\r\n this.open();\r\n }\r\n } else {\r\n if (this.#isOpen) {\r\n this.close();\r\n }\r\n }\r\n break;\r\n case 'id':\r\n this.id = value;\r\n break;\r\n }\r\n\r\n }\r\n onBackgroundClick() {\r\n this.dispatchCloseEvent('BACKGROUND_CLICK');\r\n if (this.config.autoCloseOnBackgroundClick) {\r\n this.close();\r\n }\r\n\r\n }\r\n dispatchCloseEvent(type) {\r\n //we have many ways to dispatch close event like back button on close clicked\r\n const event = new CustomEvent(\"close\", { detail: { eventType: type } });\r\n this.dispatchEvent(event);\r\n }\r\n /**\r\n * @public\r\n * will close modal\r\n */\r\n close() {\r\n this.#isOpen = false;\r\n this.elements.componentWrapper.classList.remove('--opened')\r\n this.elements.componentWrapper.classList.add('--closed');\r\n const history = window.history;\r\n const location = window.location;\r\n if (location.hash == `#${this.id}`) {\r\n history.go(-1);\r\n }\r\n }\r\n /**\r\n * @public\r\n * will open modal\r\n */\r\n open() {\r\n this.#isOpen = true;\r\n this.elements.componentWrapper.classList.remove('--closed');\r\n this.elements.componentWrapper.classList.add('--opened');\r\n if (this.id) {\r\n const history = window.history;\r\n const location = window.location;\r\n if (!(location.hash == `#${this.id}`)) {\r\n history.pushState({ JBModal: {} }, \"\", `#${this.id}`);\r\n }\r\n }\r\n }\r\n #onBrowserBack(e) {\r\n if (this.isOpen) {\r\n this.dispatchCloseEvent('HISTORY_BACK_EVENT');\r\n if (this.config.autoCloseOnBackgroundClick) {\r\n this.close();\r\n }\r\n }\r\n }\r\n}\r\nconst myElementNotExists = !customElements.get('jb-modal');\r\nif (myElementNotExists) {\r\n window.customElements.define('jb-modal', JBModalWebComponent);\r\n}\r\n"],"names":["CSS"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAsQA;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;AACjE,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;AACjG,IAAI,IAAI,OAAO,KAAK,KAAK,UAAU,GAAG,QAAQ,KAAK,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,SAAS,CAAC,0EAA0E,CAAC,CAAC;AACvL,IAAI,OAAO,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAClG,CAAC;AACD;AACO,SAAS,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;AACxE,IAAI,IAAI,IAAI,KAAK,GAAG,EAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;AAC5E,IA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