jb-modal 1.6.1 → 1.7.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.
Files changed (38) hide show
  1. package/README.md +48 -2
  2. package/dist/JBModal.cjs.js +2 -0
  3. package/dist/JBModal.cjs.js.br +0 -0
  4. package/dist/JBModal.cjs.js.gz +0 -0
  5. package/dist/JBModal.cjs.js.map +1 -0
  6. package/dist/JBModal.js +1 -185
  7. package/dist/JBModal.js.br +0 -0
  8. package/dist/JBModal.js.gz +0 -0
  9. package/dist/JBModal.js.map +1 -1
  10. package/dist/JBModal.umd.js +1 -195
  11. package/dist/JBModal.umd.js.br +0 -0
  12. package/dist/JBModal.umd.js.gz +0 -0
  13. package/dist/JBModal.umd.js.map +1 -1
  14. package/dist/{JBModal.d.ts → web-component/jb-modal/lib/JBModal.d.ts} +7 -7
  15. package/index.js +1 -1
  16. package/lib/JBModal.scss +1 -1
  17. package/lib/JBModal.ts +148 -150
  18. package/package.json +5 -3
  19. package/react/LICENSE +21 -0
  20. package/react/README.md +82 -0
  21. package/react/dist/JBModal.cjs.js +67 -0
  22. package/react/dist/JBModal.cjs.js.map +1 -0
  23. package/react/dist/JBModal.js +65 -0
  24. package/react/dist/JBModal.js.map +1 -0
  25. package/react/dist/JBModal.umd.js +70 -0
  26. package/react/dist/JBModal.umd.js.map +1 -0
  27. package/react/dist/common/hooks/use-event.d.ts +3 -0
  28. package/react/dist/common/hooks/useLazyRef.d.ts +4 -0
  29. package/react/dist/common/hooks/useMobx.d.ts +4 -0
  30. package/react/dist/common/scripts/device-detection.d.ts +1 -0
  31. package/react/dist/common/scripts/persian-helper.d.ts +3 -0
  32. package/react/dist/web-component/jb-modal/react/lib/JBModal.d.ts +30 -0
  33. package/react/index.js +1 -0
  34. package/react/lib/JBModal.tsx +80 -0
  35. package/react/package.json +38 -0
  36. package/react/tsconfig.json +18 -0
  37. package/lib/global.d.ts +0 -11
  38. /package/dist/{Types.d.ts → web-component/jb-modal/lib/Types.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"JBModal.umd.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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,CAAC,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzD,IAAI,IAAI,CAAC,EAAE,EAAE;IACT,YAAA,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,YAAA,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAI,CAAA,EAAA,IAAI,CAAC,EAAE,CAAE,CAAA,CAAC,EAAE;IACnC,gBAAA,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAI,CAAA,EAAA,IAAI,CAAC,EAAE,CAAA,CAAE,CAAC,CAAC;IACzD,aAAA;IACJ,SAAA;SACJ;IASJ,CAAA;2NARkB,CAAC,EAAA;QACZ,IAAI,IAAI,CAAC,MAAM,EAAE;IACb,QAAA,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAC9C,QAAA,IAAI,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE;gBACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IAChB,SAAA;IACJ,KAAA;IACL,CAAC,CAAA;IAEL,MAAM,kBAAkB,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3D,IAAI,kBAAkB,EAAE;QACpB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;IACjE;;;;;;;;;;"}
1
+ {"version":3,"file":"JBModal.umd.js","sources":["../lib/JBModal.ts"],"sourcesContent":["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 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 registerEventListener() {\r\n this.elements.background.addEventListener(\r\n \"click\",\r\n this.onBackgroundClick.bind(this)\r\n );\r\n //TODO: remove listener on component unmount\r\n window.addEventListener(\"popstate\", this.#onBrowserBack.bind(this));\r\n }\r\n initProp() {\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:string, oldValue:string, newValue:string) {\r\n // do something when an attribute has changed\r\n this.onAttributeChange(name, newValue);\r\n }\r\n onAttributeChange(name:string, value:string) {\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 onBackgroundClick() {\r\n this.dispatchCloseEvent(\"BACKGROUND_CLICK\");\r\n if (this.config.autoCloseOnBackgroundClick) {\r\n this.close();\r\n }\r\n }\r\n dispatchCloseEvent(type:\"BACKGROUND_CLICK\"| \"HISTORY_BACK_EVENT\" | \"CLOSE_BUTTON_CLICK\") {\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() {\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":["JBModalWebComponent","HTMLElement","id","this","getAttribute","__classPrivateFieldGet","_JBModalWebComponent_id","value","__classPrivateFieldSet","checkInitialOpenness","isOpen","_JBModalWebComponent_isOpen","constructor","super","set","config","autoCloseOnBackgroundClick","initWebComponent","connectedCallback","callOnLoadEvent","initProp","callOnInitEvent","event","CustomEvent","bubbles","composed","dispatchEvent","shadowRoot","attachShadow","mode","element","document","createElement","innerHTML","appendChild","content","cloneNode","elements","componentWrapper","querySelector","background","registerEventListener","addEventListener","onBackgroundClick","bind","window","_JBModalWebComponent_instances","_JBModalWebComponent_onBrowserBack","location","hash","triggerUrlOpenEvent","open","observedAttributes","attributeChangedCallback","name","oldValue","newValue","onAttributeChange","close","dispatchCloseEvent","type","detail","eventType","classList","remove","add","history","go","pushState","JBModal","customElements","get","define"],"mappings":"i8BAIM,MAAOA,UAA4BC,YAOvC,MAAIC,GACF,MAAMA,EAAaC,KAAKC,aAAa,OAAS,GAC9C,OAAOC,EAAAF,KAAQG,EAAA,MAAIJ,CACpB,CACD,MAAIA,CAAGK,GACLC,EAAAL,KAAIG,EAAOC,EAAK,KAChBJ,KAAKM,sBACN,CACD,UAAIC,GACF,OAAOL,EAAAF,KAAIQ,EAAA,IACZ,CACD,WAAAC,GACEC,oBAlBFF,EAAAG,IAAAX,MAAU,GACVG,EAAAQ,IAAAX,KAAM,IAENA,KAAAY,OAAS,CACPC,4BAA4B,GAe5Bb,KAAKc,kBACN,CACD,iBAAAC,GAEEf,KAAKgB,kBACLhB,KAAKiB,WACLjB,KAAKkB,iBACN,CACD,eAAAF,GACE,MAAMG,EAAQ,IAAIC,YAAY,OAAQ,CAAEC,SAAS,EAAMC,UAAU,IACjEtB,KAAKuB,cAAcJ,EACpB,CACD,eAAAD,GACE,MAAMC,EAAQ,IAAIC,YAAY,OAAQ,CAAEC,SAAS,EAAMC,UAAU,IACjEtB,KAAKuB,cAAcJ,EACpB,CACD,gBAAAL,GACE,MAAMU,EAAaxB,KAAKyB,aAAa,CACnCC,KAAM,SAGFC,EAAUC,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iByB,UAAUE,IAAI,YAC7C,MAAMC,EAAUrB,OAAOqB,QACNrB,OAAOG,SACXC,MAAQ,IAAI9C,KAAKD,MAC5BgE,EAAQC,IAAI,EAEf,CAKD,IAAAhB,GAIE,GAHA3C,EAAAL,KAAIQ,GAAW,EAAI,KACnBR,KAAKkC,SAASC,iBAAiByB,UAAUC,OAAO,YAChD7D,KAAKkC,SAASC,iBAAiByB,UAAUE,IAAI,YACzC9D,KAAKD,GAAI,CACX,MAAMgE,EAAUrB,OAAOqB,QACNrB,OAAOG,SACTC,MAAQ,IAAI9C,KAAKD,MAC9BgE,EAAQE,UAAU,CAAEC,QAAS,IAAM,GAAI,IAAIlE,KAAKD,KAEnD,CACF,yDAEKC,KAAKO,SACPP,KAAKwD,mBAAmB,sBACpBxD,KAAKY,OAAOC,4BACdb,KAAKuD,QAGX,GAE0BY,eAAeC,IAAI,aAE7C1B,OAAOyB,eAAeE,OAAO,WAAYxE"}
@@ -1,4 +1,4 @@
1
- import { ElementsObject } from './Types';
1
+ import { ElementsObject } from "./Types";
2
2
  export declare class JBModalWebComponent extends HTMLElement {
3
3
  #private;
4
4
  elements: ElementsObject;
@@ -18,14 +18,14 @@ export declare class JBModalWebComponent extends HTMLElement {
18
18
  checkInitialOpenness(): void;
19
19
  triggerUrlOpenEvent(): void;
20
20
  static get observedAttributes(): string[];
21
- attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
22
- onAttributeChange(name: any, value: any): void;
21
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
22
+ onAttributeChange(name: string, value: string): void;
23
23
  onBackgroundClick(): void;
24
- dispatchCloseEvent(type: any): void;
24
+ dispatchCloseEvent(type: "BACKGROUND_CLICK" | "HISTORY_BACK_EVENT" | "CLOSE_BUTTON_CLICK"): void;
25
25
  /**
26
- * @public
27
- * will close modal
28
- */
26
+ * @public
27
+ * will close modal
28
+ */
29
29
  close(): void;
30
30
  /**
31
31
  * @public
package/index.js CHANGED
@@ -1 +1 @@
1
- import './dist/JBModal.js';
1
+ export * from './dist/JBModal.js';
package/lib/JBModal.scss CHANGED
@@ -1,4 +1,4 @@
1
- @import '../../../common/scss/Medias.scss';
1
+ @use '../../../common/scss/Medias.scss' as *;
2
2
  .jb-modal-web-component {
3
3
  position: fixed;
4
4
  top: 0;
package/lib/JBModal.ts CHANGED
@@ -1,158 +1,156 @@
1
- import HTML from './JBModal.html';
2
- import CSS from './JBModal.scss';
3
- import { ElementsObject } from './Types';
1
+ import HTML from "./JBModal.html";
2
+ import CSS from "./JBModal.scss";
3
+ import { ElementsObject } from "./Types";
4
4
 
5
5
  export class JBModalWebComponent extends HTMLElement {
6
- #isOpen = false;
7
- #id ="";
8
- elements!: ElementsObject;
9
- config = {
10
- autoCloseOnBackgroundClick: false
11
- }
12
- get id(){
13
- const id:string =this.getAttribute('id') || "";
14
- return this.#id || id;
15
- }
16
- set id(value:string) {
17
- this.#id = value;
18
- this.checkInitialOpenness();
19
- }
20
- get isOpen() {
21
- return this.#isOpen;
22
- }
23
- constructor() {
24
- super();
25
- this.initWebComponent();
26
- }
27
- connectedCallback() {
28
- // standard web component event that called when all of dom is binded
29
- this.callOnLoadEvent();
30
- this.initProp();
31
- this.callOnInitEvent();
32
-
33
- }
34
- callOnLoadEvent() {
35
- const event = new CustomEvent('load', { bubbles: true, composed: true });
36
- this.dispatchEvent(event);
37
- }
38
- callOnInitEvent() {
39
- const event = new CustomEvent('init', { bubbles: true, composed: true });
40
- this.dispatchEvent(event);
41
- }
42
- initWebComponent() {
43
- const shadowRoot = this.attachShadow({
44
- mode: 'open'
45
- });
46
- const html = `<style>${CSS}</style>` + '\n' + HTML;
47
- const element = document.createElement('template');
48
- element.innerHTML = html;
49
- shadowRoot.appendChild(element.content.cloneNode(true));
50
- this.elements = {
51
- componentWrapper: shadowRoot.querySelector('.jb-modal-web-component')!,
52
- background: shadowRoot.querySelector('.modal-background')!,
53
- }
54
-
55
- }
56
- registerEventListener() {
57
- this.elements.background.addEventListener('click', this.onBackgroundClick.bind(this));
58
- //TODO: remove listener on component unmount
59
- window.addEventListener('popstate', this.#onBrowserBack.bind(this));
60
- }
61
- initProp() {
62
-
63
- this.registerEventListener();
64
- }
65
- checkInitialOpenness() {
66
- //if page has modal url we open it automatically
67
- const location = window.location;
68
- if (location.hash == `#${this.id}`) {
69
- this.triggerUrlOpenEvent();
6
+ #isOpen = false;
7
+ #id = "";
8
+ elements!: ElementsObject;
9
+ config = {
10
+ autoCloseOnBackgroundClick: false,
11
+ };
12
+ get id() {
13
+ const id: string = this.getAttribute("id") || "";
14
+ return this.#id || id;
15
+ }
16
+ set id(value: string) {
17
+ this.#id = value;
18
+ this.checkInitialOpenness();
19
+ }
20
+ get isOpen() {
21
+ return this.#isOpen;
22
+ }
23
+ constructor() {
24
+ super();
25
+ this.initWebComponent();
26
+ }
27
+ connectedCallback() {
28
+ // standard web component event that called when all of dom is binded
29
+ this.callOnLoadEvent();
30
+ this.initProp();
31
+ this.callOnInitEvent();
32
+ }
33
+ callOnLoadEvent() {
34
+ const event = new CustomEvent("load", { bubbles: true, composed: true });
35
+ this.dispatchEvent(event);
36
+ }
37
+ callOnInitEvent() {
38
+ const event = new CustomEvent("init", { bubbles: true, composed: true });
39
+ this.dispatchEvent(event);
40
+ }
41
+ initWebComponent() {
42
+ const shadowRoot = this.attachShadow({
43
+ mode: "open",
44
+ });
45
+ const html = `<style>${CSS}</style>` + "\n" + HTML;
46
+ const element = document.createElement("template");
47
+ element.innerHTML = html;
48
+ shadowRoot.appendChild(element.content.cloneNode(true));
49
+ this.elements = {
50
+ componentWrapper: shadowRoot.querySelector(".jb-modal-web-component")!,
51
+ background: shadowRoot.querySelector(".modal-background")!,
52
+ };
53
+ }
54
+ registerEventListener() {
55
+ this.elements.background.addEventListener(
56
+ "click",
57
+ this.onBackgroundClick.bind(this)
58
+ );
59
+ //TODO: remove listener on component unmount
60
+ window.addEventListener("popstate", this.#onBrowserBack.bind(this));
61
+ }
62
+ initProp() {
63
+ this.registerEventListener();
64
+ }
65
+ checkInitialOpenness() {
66
+ //if page has modal url we open it automatically
67
+ const location = window.location;
68
+ if (location.hash == `#${this.id}`) {
69
+ this.triggerUrlOpenEvent();
70
+ this.open();
71
+ }
72
+ }
73
+ triggerUrlOpenEvent() {
74
+ //when modal open itself becuase url contain modal id
75
+ const event = new CustomEvent("urlOpen", { bubbles: true, composed: true });
76
+ this.dispatchEvent(event);
77
+ }
78
+ static get observedAttributes() {
79
+ return ["is-open", "id"];
80
+ }
81
+ attributeChangedCallback(name:string, oldValue:string, newValue:string) {
82
+ // do something when an attribute has changed
83
+ this.onAttributeChange(name, newValue);
84
+ }
85
+ onAttributeChange(name:string, value:string) {
86
+ switch (name) {
87
+ case "is-open":
88
+ if (value == "true") {
89
+ if (!this.#isOpen) {
70
90
  this.open();
71
- }
72
- }
73
- triggerUrlOpenEvent() {
74
- //when modal open itself becuase url contain modal id
75
- const event = new CustomEvent('urlOpen', { bubbles: true, composed: true });
76
- this.dispatchEvent(event);
77
- }
78
- static get observedAttributes() {
79
- return ['is-open', 'id'];
80
- }
81
- attributeChangedCallback(name, oldValue, newValue) {
82
- // do something when an attribute has changed
83
- this.onAttributeChange(name, newValue);
84
- }
85
- onAttributeChange(name, value) {
86
- switch (name) {
87
- case 'is-open':
88
- if (value == 'true') {
89
- if (!this.#isOpen) {
90
- this.open();
91
- }
92
- } else {
93
- if (this.#isOpen) {
94
- this.close();
95
- }
96
- }
97
- break;
98
- case 'id':
99
- this.id = value;
100
- break;
101
- }
102
-
103
- }
104
- onBackgroundClick() {
105
- this.dispatchCloseEvent('BACKGROUND_CLICK');
106
- if (this.config.autoCloseOnBackgroundClick) {
91
+ }
92
+ } else {
93
+ if (this.#isOpen) {
107
94
  this.close();
95
+ }
108
96
  }
109
-
110
- }
111
- dispatchCloseEvent(type) {
112
- //we have many ways to dispatch close event like back button on close clicked
113
- const event = new CustomEvent("close", { detail: { eventType: type } });
114
- this.dispatchEvent(event);
115
- }
116
- /**
117
- * @public
118
- * will close modal
119
- */
120
- close() {
121
- this.#isOpen = false;
122
- this.elements.componentWrapper.classList.remove('--opened')
123
- this.elements.componentWrapper.classList.add('--closed');
124
- const history = window.history;
125
- const location = window.location;
126
- if (location.hash == `#${this.id}`) {
127
- history.go(-1);
128
- }
129
- }
130
- /**
131
- * @public
132
- * will open modal
133
- */
134
- open() {
135
- this.#isOpen = true;
136
- this.elements.componentWrapper.classList.remove('--closed');
137
- this.elements.componentWrapper.classList.add('--opened');
138
- if (this.id) {
139
- const history = window.history;
140
- const location = window.location;
141
- if (!(location.hash == `#${this.id}`)) {
142
- history.pushState({ JBModal: {} }, "", `#${this.id}`);
143
- }
144
- }
145
- }
146
- #onBrowserBack(e) {
147
- if (this.isOpen) {
148
- this.dispatchCloseEvent('HISTORY_BACK_EVENT');
149
- if (this.config.autoCloseOnBackgroundClick) {
150
- this.close();
151
- }
152
- }
153
- }
97
+ break;
98
+ case "id":
99
+ this.id = value;
100
+ break;
101
+ }
102
+ }
103
+ onBackgroundClick() {
104
+ this.dispatchCloseEvent("BACKGROUND_CLICK");
105
+ if (this.config.autoCloseOnBackgroundClick) {
106
+ this.close();
107
+ }
108
+ }
109
+ dispatchCloseEvent(type:"BACKGROUND_CLICK"| "HISTORY_BACK_EVENT" | "CLOSE_BUTTON_CLICK") {
110
+ //we have many ways to dispatch close event like back button on close clicked
111
+ const event = new CustomEvent("close", { detail: { eventType: type } });
112
+ this.dispatchEvent(event);
113
+ }
114
+ /**
115
+ * @public
116
+ * will close modal
117
+ */
118
+ close() {
119
+ this.#isOpen = false;
120
+ this.elements.componentWrapper.classList.remove("--opened");
121
+ this.elements.componentWrapper.classList.add("--closed");
122
+ const history = window.history;
123
+ const location = window.location;
124
+ if (location.hash == `#${this.id}`) {
125
+ history.go(-1);
126
+ }
127
+ }
128
+ /**
129
+ * @public
130
+ * will open modal
131
+ */
132
+ open() {
133
+ this.#isOpen = true;
134
+ this.elements.componentWrapper.classList.remove("--closed");
135
+ this.elements.componentWrapper.classList.add("--opened");
136
+ if (this.id) {
137
+ const history = window.history;
138
+ const location = window.location;
139
+ if (!(location.hash == `#${this.id}`)) {
140
+ history.pushState({ JBModal: {} }, "", `#${this.id}`);
141
+ }
142
+ }
143
+ }
144
+ #onBrowserBack() {
145
+ if (this.isOpen) {
146
+ this.dispatchCloseEvent("HISTORY_BACK_EVENT");
147
+ if (this.config.autoCloseOnBackgroundClick) {
148
+ this.close();
149
+ }
150
+ }
151
+ }
154
152
  }
155
- const myElementNotExists = !customElements.get('jb-modal');
153
+ const myElementNotExists = !customElements.get("jb-modal");
156
154
  if (myElementNotExists) {
157
- window.customElements.define('jb-modal', JBModalWebComponent);
155
+ window.customElements.define("jb-modal", JBModalWebComponent);
158
156
  }
package/package.json CHANGED
@@ -14,17 +14,19 @@
14
14
  "pop up",
15
15
  "web component"
16
16
  ],
17
- "version": "1.6.1",
17
+ "version": "1.7.0",
18
18
  "bugs": "https://github.com/javadbat/jb-modal/issues",
19
19
  "license": "MIT",
20
20
  "files": [
21
21
  "LICENSE",
22
22
  "README.md",
23
23
  "lib/",
24
- "dist/"
24
+ "dist/",
25
+ "react/",
26
+ "react/dist/"
25
27
  ],
26
28
  "main": "index.js",
27
- "types": "./dist/JBModal.d.ts",
29
+ "types": "jb-modal/dist/web-component/jb-modal/lib/JBModal.d.ts",
28
30
  "repository": {
29
31
  "type": "git",
30
32
  "url": "git@github.com:javadbat/jb-modal.git"
package/react/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 javad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,82 @@
1
+ # JBModal
2
+
3
+ a react component modal that open different in mobile and desktop
4
+ this component is React.js wrapper for [jb-modal](https://www.npmjs.com/package/jb-modal) web component.
5
+
6
+ - open like bottomsheet in mobile and open in center position in desktop
7
+
8
+ - customizable layout with css variable
9
+
10
+ - support typescript
11
+
12
+ - support custom url to adapt "back to close" on android and "auto open modal on refresh"
13
+
14
+ ## installation
15
+
16
+ ```command
17
+ npm i jb-modal
18
+ ```
19
+
20
+ in your jsx file
21
+
22
+ ```js
23
+ import {JBModal} from 'jb-modal/react'
24
+ ```
25
+ ``` jsx
26
+ <JBModal></JBModal>
27
+ ```
28
+
29
+ ## use
30
+
31
+ you can place your modal content in ` <JBModal></JBModal>` like:
32
+ ```jsx
33
+ <JBModal>
34
+ <div>
35
+ <p>this is the modal content<p>
36
+ </div>
37
+ </JBModal>
38
+ ```
39
+
40
+ ### props
41
+ - onClose
42
+ you can pass a function to onClose props so that when a user click outside of the modal, the modal closes.
43
+
44
+ ``` jsx
45
+ const [isOpen, setIsOpen] = useState(false);
46
+ <JBModal onClose={() => setIsOpen(false)}></JBModal>
47
+
48
+ ```
49
+
50
+ - isOpen
51
+ you can pass true or false to this props,this way the modal will be open based on the isOpen props.
52
+
53
+ ``` jsx
54
+ <JBModal isOpen={isOpen}></JBModal>
55
+ // the modal is open
56
+ ```
57
+
58
+ - id
59
+ you can set a specific id for each one of your modals,this way when the modal is open the id of the modal will be in your url.
60
+ when you set id modal will add `#your-id` to the url when open so when you refresh the page, modal will open automatically.
61
+
62
+ ``` jsx
63
+ <JBModal id={MYMODAL}></JBModal>
64
+ ```
65
+
66
+ - onUrlOpen
67
+ when the react copmonent first renders the default state of isModalOpen is false.
68
+ when the url contains the id of the modal the function passed to onUrlOpen will update the react state and set the isModalOpen state to true.
69
+ example:
70
+
71
+ ```jsx
72
+ [isModalOpen, setOpen] = useState(false);
73
+ <JBModal onUrlOpen={() => setOpen(true)}></JBModal>
74
+ ```
75
+ ## customize modal look
76
+
77
+ you can customize modal look by following css properties
78
+ | css variable name | description |
79
+ | ------------- | ------------- |
80
+ | --jb-modal-bg-color | modal background color default is black `#fff` |
81
+ | --jb-modal-border-radius | modal border-radius default `24px` |
82
+ | --jb-modal-border-radius-mobile | modal border-radius on mobile default is `24px 24px 0 0` |
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('jb-modal');
5
+
6
+ function useBindEvent(ref, event, handler, passive = false) {
7
+ React.useEffect(() => {
8
+ const dom = ref.current;
9
+ if (dom) {
10
+ // initiate the event handler
11
+ dom.addEventListener(event, handler, passive);
12
+ }
13
+ // this will clean up the event every time the component is re-rendered
14
+ return function cleanup() {
15
+ if (dom) {
16
+ dom.removeEventListener(event, handler, passive);
17
+ }
18
+ };
19
+ }, [ref, event, handler, passive]);
20
+ }
21
+
22
+ const JBModal = React.forwardRef((props, ref) => {
23
+ const element = React.useRef(null);
24
+ const [refChangeCount, refChangeCountSetter] = React.useState(0);
25
+ React.useImperativeHandle(ref, () => (element ? element.current : {}), [element]);
26
+ React.useEffect(() => {
27
+ refChangeCountSetter(refChangeCount + 1);
28
+ }, [element.current]);
29
+ React.useEffect(() => {
30
+ if (element.current) {
31
+ if (props.isOpen == true) {
32
+ element.current.open();
33
+ }
34
+ else {
35
+ element.current.close();
36
+ }
37
+ }
38
+ }, [props.isOpen]);
39
+ React.useEffect(() => {
40
+ if (props.id !== undefined && element.current) {
41
+ element.current.addEventListener('urlOpen', onUrlOpen);
42
+ element.current.id = props.id;
43
+ }
44
+ return () => {
45
+ if (props.id !== undefined && element.current) {
46
+ element.current.removeEventListener('urlOpen', onUrlOpen);
47
+ }
48
+ };
49
+ }, [props.id]);
50
+ function onClose() {
51
+ if (props.onClose) {
52
+ props.onClose();
53
+ }
54
+ }
55
+ function onUrlOpen() {
56
+ if (props.onUrlOpen) {
57
+ props.onUrlOpen();
58
+ }
59
+ }
60
+ useBindEvent(element, 'close', onClose);
61
+ return (React.createElement("jb-modal", { ref: element, class: props.className ? props.className : '' },
62
+ React.createElement("div", { slot: "content" }, props.children)));
63
+ });
64
+ JBModal.displayName = "JBModal";
65
+
66
+ exports.JBModal = JBModal;
67
+ //# sourceMappingURL=JBModal.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JBModal.cjs.js","sources":["../../../../common/hooks/use-event.ts","../lib/JBModal.tsx"],"sourcesContent":["import { useEffect } from \"react\";\r\n\r\nexport function useEvent(dom:HTMLElement, event:any, handler:any, passive = false) {\r\n useEffect(() => {\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n });\r\n}\r\nexport function useBindEvent<TRef extends React.MutableRefObject<any|null>,TEvent>(ref:TRef, event:string, handler:(e:TEvent)=>void, passive = false) {\r\n useEffect(() => {\r\n const dom = ref.current;\r\n if (dom) {\r\n // initiate the event handler\r\n dom.addEventListener(event, handler, passive); \r\n }\r\n // this will clean up the event every time the component is re-rendered\r\n return function cleanup() {\r\n if(dom){\r\n dom.removeEventListener(event, handler, passive);\r\n }\r\n };\r\n },[ref,event,handler,passive]);\r\n}","import PropTypes from 'prop-types';\r\nimport 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 { useBindEvent } from '../../../../common/hooks/use-event.js';\r\nexport type JBModalProps = React.PropsWithChildren<{\r\n onClose?: () => void,\r\n onUrlOpen?: () => void,\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\nconst JBModal = React.forwardRef((props:JBModalProps, 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 (props.id !== undefined && element.current) {\r\n element.current.addEventListener('urlOpen', onUrlOpen);\r\n element.current.id = props.id;\r\n }\r\n return () => {\r\n if (props.id !== undefined && element.current) {\r\n element.current.removeEventListener('urlOpen', onUrlOpen);\r\n }\r\n };\r\n }, [props.id]);\r\n function onClose() {\r\n if (props.onClose) {\r\n props.onClose();\r\n }\r\n }\r\n function onUrlOpen() {\r\n if (props.onUrlOpen) {\r\n props.onUrlOpen();\r\n }\r\n }\r\n useBindEvent(element, 'close', onClose);\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 = \"JB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