@cleartrip/ct-platform-drawer 3.7.0-beta.21 → 3.7.0-beta.22
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),n=require("react/jsx-runtime"),o=require("react-dom"),
|
|
1
|
+
"use strict";var e=require("tslib"),n=require("react/jsx-runtime"),o=require("react-dom"),t=require("classnames"),d=require("react"),r=require("@cleartrip/ct-design-icons"),i=require("@cleartrip/ct-platform-utils");function l(e){return e&&e.__esModule?e:{default:e}}var _=l(o),a=l(t);var u={modal__container:"index-module_modal__container__Ko7cH",modal:"index-module_modal__snYTt",left:"index-module_left__u09rj",right:"index-module_right__TIn-v",top:"index-module_top__Kd1uL",bottom:"index-module_bottom__dCRf4",overlay:"index-module_overlay__Ja-Es","transition-end":"index-module_transition-end__sG4Uc",open:"index-module_open__qC-dm","drawer-header":"index-module_drawer-header__m87OY","drawer-close-btn__container":"index-module_drawer-close-btn__container__s0TDe","close-icon":"index-module_close-icon__E3q1h"};!function(e,n){void 0===n&&(n={});var o=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css","top"===o&&t.firstChild?t.insertBefore(d,t.firstChild):t.appendChild(d),d.styleSheet?d.styleSheet.cssText=e:d.appendChild(document.createTextNode(e))}}(".index-module_modal__container__Ko7cH .index-module_modal__snYTt{-webkit-overflow-scrolling:touch;display:flex;flex-direction:column;justify-content:flex-end;overflow:auto;position:fixed;transition:transform .3s ease;width:auto;z-index:1000}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_left__u09rj{left:0;top:0;transform:translateX(-105%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_right__TIn-v{right:0;top:0;transform:translateX(100%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_top__Kd1uL{left:0;right:0;top:0;transform:translateY(-100%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_bottom__dCRf4{bottom:0;left:0;right:0;transform:translateY(100%)}.index-module_modal__container__Ko7cH .index-module_overlay__Ja-Es{background:rgba(0,0,0,.5);height:100%;left:0;opacity:0;pointer-events:none;position:fixed;top:0;transition:opacity .3s ease,visibility .3s ease;visibility:hidden;width:100%;z-index:999}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_left__u09rj,.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_right__TIn-v{transform:translateX(0)}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_bottom__dCRf4,.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_top__Kd1uL{transform:translateY(0)}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_overlay__Ja-Es{opacity:1;pointer-events:auto;visibility:visible;z-index:999}.index-module_drawer-header__m87OY{align-items:center;background-color:transparent;display:flex;justify-content:flex-end;padding:12px 16px}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe{align-items:center;background:#fff;border:none;border-radius:40px;cursor:pointer;display:flex;justify-content:center;outline:none;padding:4px}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe:hover{background:#fff}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe .index-module_close-icon__E3q1h{height:24px;width:24px}");exports.Drawer=function(o){var t,l=o.isOpen,s=o.handleClose,c=o.onClose,m=o.children,x=o.childrenInsideOverlay,f=o.direction,v=void 0===f?"left":f,h=o.showClose,p=void 0!==h&&h,w=o.overlay,y=void 0===w||w,g=o.closeOnOutsideClick,b=void 0!==g&&g,C=d.useRef(null),T=d.useRef(null),q=d.useRef(null),K=d.useRef(null);if(!i.isServer()&&window&&document&&(T.current=document.querySelector("body"),q.current=document.querySelector("#root, #__next")),!i.isServer()&&window&&document){var j=document.getElementById("drawer-parent");K.current=j||function(){if(!i.isServer()&&window&&document){var e=document.createElement("div");return e.setAttribute("id","drawer-parent"),e}return null}()}d.useEffect((function(){var e;null===(e=null==T?void 0:T.current)||void 0===e||e.appendChild(null==K?void 0:K.current);var n=null==K?void 0:K.current,o=null==T?void 0:T.current;return function(){null==n||n.remove(),o&&(o.style.overflow="")}}),[]),d.useEffect((function(){T&&T.current&&(l?(T.current.style.overflow="hidden",(null==q?void 0:q.current)&&(q.current.style.overflow="hidden",q.current.style.height=window.innerHeight+"px")):(T.current.style.overflow="unset",(null==q?void 0:q.current)&&(q.current.style.overflow="unset",q.current.style.height="unset")))}),[l]);var Y=function(e,n){var o=d.useState(!1),t=o[0],r=o[1];return d.useEffect((function(){var o;return e&&!t?r(!0):!e&&t&&(o=setTimeout((function(){return r(!1)}),n)),function(){clearTimeout(o)}}),[n,e,t]),t}(l,500);return Y||l?n.jsx(n.Fragment,{children:_.default.createPortal(n.jsxs("div",e.__assign({"aria-hidden":l?"false":"true",className:a.default(u.modal__container,(t={},t[u.open]=l,t[u["transition-end"]]=Y,t)),onClick:function(e){var n;b&&C.current&&(null===(n=C.current)||void 0===n?void 0:n.contains(e.target))&&s()}},{children:[n.jsxs("div",e.__assign({className:a.default(u.modal,u[v]),role:"dialog"},{children:[p&&n.jsx("div",e.__assign({className:u["drawer-header"]},{children:n.jsx("button",e.__assign({className:u["drawer-close-btn__container"],onClick:function(e){s(e),c()}},{children:n.jsx(r.Cross,{className:u["close-icon"],crossColor:"#1A1A1A"})}))})),m]})),y&&n.jsx("div",e.__assign({"aria-hidden":l?"false":"true",className:"".concat(u.overlay),ref:C},{children:x}))]})),null==K?void 0:K.current)}):null};
|
|
2
2
|
//# sourceMappingURL=ct-platform-drawer.cjs.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as n,Fragment as o,jsxs as t}from"react/jsx-runtime";import d from"react-dom";import r from"classnames";import{useState as i,useEffect as l,useRef as _}from"react";import{Cross as a}from"@cleartrip/ct-design-icons";import{isServer as u}from"@cleartrip/ct-platform-utils";var
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as n,Fragment as o,jsxs as t}from"react/jsx-runtime";import d from"react-dom";import r from"classnames";import{useState as i,useEffect as l,useRef as _}from"react";import{Cross as a}from"@cleartrip/ct-design-icons";import{isServer as u}from"@cleartrip/ct-platform-utils";var c={modal__container:"index-module_modal__container__Ko7cH",modal:"index-module_modal__snYTt",left:"index-module_left__u09rj",right:"index-module_right__TIn-v",top:"index-module_top__Kd1uL",bottom:"index-module_bottom__dCRf4",overlay:"index-module_overlay__Ja-Es","transition-end":"index-module_transition-end__sG4Uc",open:"index-module_open__qC-dm","drawer-header":"index-module_drawer-header__m87OY","drawer-close-btn__container":"index-module_drawer-close-btn__container__s0TDe","close-icon":"index-module_close-icon__E3q1h"};!function(e,n){void 0===n&&(n={});var o=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css","top"===o&&t.firstChild?t.insertBefore(d,t.firstChild):t.appendChild(d),d.styleSheet?d.styleSheet.cssText=e:d.appendChild(document.createTextNode(e))}}(".index-module_modal__container__Ko7cH .index-module_modal__snYTt{-webkit-overflow-scrolling:touch;display:flex;flex-direction:column;justify-content:flex-end;overflow:auto;position:fixed;transition:transform .3s ease;width:auto;z-index:1000}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_left__u09rj{left:0;top:0;transform:translateX(-105%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_right__TIn-v{right:0;top:0;transform:translateX(100%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_top__Kd1uL{left:0;right:0;top:0;transform:translateY(-100%)}.index-module_modal__container__Ko7cH .index-module_modal__snYTt.index-module_bottom__dCRf4{bottom:0;left:0;right:0;transform:translateY(100%)}.index-module_modal__container__Ko7cH .index-module_overlay__Ja-Es{background:rgba(0,0,0,.5);height:100%;left:0;opacity:0;pointer-events:none;position:fixed;top:0;transition:opacity .3s ease,visibility .3s ease;visibility:hidden;width:100%;z-index:999}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_left__u09rj,.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_right__TIn-v{transform:translateX(0)}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_bottom__dCRf4,.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_top__Kd1uL{transform:translateY(0)}.index-module_modal__container__Ko7cH.index-module_transition-end__sG4Uc.index-module_open__qC-dm .index-module_overlay__Ja-Es{opacity:1;pointer-events:auto;visibility:visible;z-index:999}.index-module_drawer-header__m87OY{align-items:center;background-color:transparent;display:flex;justify-content:flex-end;padding:12px 16px}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe{align-items:center;background:#fff;border:none;border-radius:40px;cursor:pointer;display:flex;justify-content:center;outline:none;padding:4px}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe:hover{background:#fff}.index-module_drawer-header__m87OY .index-module_drawer-close-btn__container__s0TDe .index-module_close-icon__E3q1h{height:24px;width:24px}");var m=function(m){var s,x=m.isOpen,f=m.handleClose,p=m.onClose,v=m.children,h=m.childrenInsideOverlay,y=m.direction,w=void 0===y?"left":y,g=m.showClose,b=void 0!==g&&g,C=m.overlay,T=void 0===C||C,K=m.closeOnOutsideClick,Y=void 0!==K&&K,H=_(null),q=_(null),E=_(null),O=_(null);if(!u()&&window&&document&&(q.current=document.querySelector("body"),E.current=document.querySelector("#root, #__next")),!u()&&window&&document){var k=document.getElementById("drawer-parent");O.current=k||function(){if(!u()&&window&&document){var e=document.createElement("div");return e.setAttribute("id","drawer-parent"),e}return null}()}l((function(){var e;null===(e=null==q?void 0:q.current)||void 0===e||e.appendChild(null==O?void 0:O.current);var n=null==O?void 0:O.current,o=null==q?void 0:q.current;return function(){null==n||n.remove(),o&&(o.style.overflow="")}}),[]),l((function(){q&&q.current&&(x?(q.current.style.overflow="hidden",(null==E?void 0:E.current)&&(E.current.style.overflow="hidden",E.current.style.height=window.innerHeight+"px")):(q.current.style.overflow="unset",(null==E?void 0:E.current)&&(E.current.style.overflow="unset",E.current.style.height="unset")))}),[x]);var N=function(e,n){var o=i(!1),t=o[0],d=o[1];return l((function(){var o;return e&&!t?d(!0):!e&&t&&(o=setTimeout((function(){return d(!1)}),n)),function(){clearTimeout(o)}}),[n,e,t]),t}(x,500);return N||x?n(o,{children:d.createPortal(t("div",e({"aria-hidden":x?"false":"true",className:r(c.modal__container,(s={},s[c.open]=x,s[c["transition-end"]]=N,s)),onClick:function(e){var n;Y&&H.current&&(null===(n=H.current)||void 0===n?void 0:n.contains(e.target))&&f()}},{children:[t("div",e({className:r(c.modal,c[w]),role:"dialog"},{children:[b&&n("div",e({className:c["drawer-header"]},{children:n("button",e({className:c["drawer-close-btn__container"],onClick:function(e){f(e),p()}},{children:n(a,{className:c["close-icon"],crossColor:"#1A1A1A"})}))})),v]})),T&&n("div",e({"aria-hidden":x?"false":"true",className:"".concat(c.overlay),ref:H},{children:h}))]})),null==O?void 0:O.current)}):null};export{m as Drawer};
|
|
2
2
|
//# sourceMappingURL=ct-platform-drawer.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-platform-drawer",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.22",
|
|
4
4
|
"description": "Drawer Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/ct-platform-drawer.cjs.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@cleartrip/ct-design-icons": "7.0.0",
|
|
14
14
|
"classnames": "^2.5.1",
|
|
15
|
-
"@cleartrip/ct-platform-utils": "3.12.0-beta.
|
|
15
|
+
"@cleartrip/ct-platform-utils": "3.12.0-beta.22"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": ">=16.8.0",
|