orion-design 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -5
- package/dist/Throne/index.js +30 -14
- package/dist/Throne/index.js.map +1 -1
- package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
- package/dist/components/Button/index.js +40 -33
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Flex/index.js +122 -89
- package/dist/components/Flex/index.js.map +1 -1
- package/dist/components/Form/Form.js +2 -2
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/LovInput/LovInput.js +2 -2
- package/dist/components/Form/LovInput/LovInput.js.map +1 -1
- package/dist/components/Form/LovInput/hooks/useLov.js +5 -5
- package/dist/components/Form/LovInput/hooks/useLov.js.map +1 -1
- package/dist/components/Form/LovInput/index.js +4 -4
- package/dist/components/Form/hooks/FormItemValidateTrigger.js +2 -2
- package/dist/components/Form/hooks/FormItemValidateTrigger.js.map +1 -1
- package/dist/components/Form/hooks/index.js +128 -66
- package/dist/components/Form/hooks/index.js.map +1 -1
- package/dist/components/Form/index.js +836 -656
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/Form/utils/index.js +30 -18
- package/dist/components/Form/utils/index.js.map +1 -1
- package/dist/components/LovTable/index.js +179 -105
- package/dist/components/LovTable/index.js.map +1 -1
- package/dist/components/Modal/index.js +111 -56
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/types.js +4 -3
- package/dist/components/Modal/types.js.map +1 -1
- package/dist/components/Modal/useModal.js +5 -5
- package/dist/components/Modal/useModal.js.map +1 -1
- package/dist/components/Pagetable/hooks/useColumns.js +88 -80
- package/dist/components/Pagetable/hooks/useColumns.js.map +1 -1
- package/dist/components/Pagetable/index.js +687 -542
- package/dist/components/Pagetable/index.js.map +1 -1
- package/dist/components/Pagetable/utils/index.js +92 -54
- package/dist/components/Pagetable/utils/index.js.map +1 -1
- package/dist/components/Querytable/hooks/useColumns.js +82 -74
- package/dist/components/Querytable/hooks/useColumns.js.map +1 -1
- package/dist/components/Querytable/index.js +579 -469
- package/dist/components/Querytable/index.js.map +1 -1
- package/dist/components/Querytable/utils/index.js +92 -54
- package/dist/components/Querytable/utils/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.js +100 -74
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/Tabs/constants.js +2 -2
- package/dist/components/Tabs/constants.js.map +1 -1
- package/dist/components/Tabs/index.js +603 -358
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/tab-bar.js +6 -6
- package/dist/components/Tabs/tab-bar.js.map +1 -1
- package/dist/components/Tabs/tab-pane.js +3 -3
- package/dist/components/Tabs/tab-pane.js.map +1 -1
- package/dist/components/_constants/aria.js +2 -2
- package/dist/components/_constants/aria.js.map +1 -1
- package/dist/components/_constants/event.js +6 -4
- package/dist/components/_constants/event.js.map +1 -1
- package/dist/components/_constants/index.js +6 -6
- package/dist/components/_hooks/index.js +7 -7
- package/dist/components/_hooks/use-namespace/index.js +74 -39
- package/dist/components/_hooks/use-namespace/index.js.map +1 -1
- package/dist/components/_hooks/use-ordered-children/index.js +29 -19
- package/dist/components/_hooks/use-ordered-children/index.js.map +1 -1
- package/dist/components/_util/arrays.js +9 -5
- package/dist/components/_util/arrays.js.map +1 -1
- package/dist/components/_util/browser.js +6 -6
- package/dist/components/_util/browser.js.map +1 -1
- package/dist/components/_util/classNames.js +22 -17
- package/dist/components/_util/classNames.js.map +1 -1
- package/dist/components/_util/dom/aria.js +74 -39
- package/dist/components/_util/dom/aria.js.map +1 -1
- package/dist/components/_util/dom/element.js +9 -8
- package/dist/components/_util/dom/element.js.map +1 -1
- package/dist/components/_util/dom/event.js +14 -7
- package/dist/components/_util/dom/event.js.map +1 -1
- package/dist/components/_util/dom/index.js +36 -36
- package/dist/components/_util/dom/position.js +49 -25
- package/dist/components/_util/dom/position.js.map +1 -1
- package/dist/components/_util/dom/scroll.js +103 -61
- package/dist/components/_util/dom/scroll.js.map +1 -1
- package/dist/components/_util/dom/style.js +65 -50
- package/dist/components/_util/dom/style.js.map +1 -1
- package/dist/components/_util/easings.js +8 -4
- package/dist/components/_util/easings.js.map +1 -1
- package/dist/components/_util/error.js +12 -11
- package/dist/components/_util/error.js.map +1 -1
- package/dist/components/_util/functions.js +3 -3
- package/dist/components/_util/i18n.js +2 -2
- package/dist/components/_util/i18n.js.map +1 -1
- package/dist/components/_util/index.js +137 -137
- package/dist/components/_util/isValid.js +4 -2
- package/dist/components/_util/isValid.js.map +1 -1
- package/dist/components/_util/objects.js +18 -14
- package/dist/components/_util/objects.js.map +1 -1
- package/dist/components/_util/props-util/index.js +46 -20
- package/dist/components/_util/props-util/index.js.map +1 -1
- package/dist/components/_util/props-util/initDefaultProps.js +18 -10
- package/dist/components/_util/props-util/initDefaultProps.js.map +1 -1
- package/dist/components/_util/raf.js +5 -4
- package/dist/components/_util/raf.js.map +1 -1
- package/dist/components/_util/rand.js +4 -3
- package/dist/components/_util/rand.js.map +1 -1
- package/dist/components/_util/strings.js +9 -8
- package/dist/components/_util/strings.js.map +1 -1
- package/dist/components/_util/throttleByRaf.js +16 -10
- package/dist/components/_util/throttleByRaf.js.map +1 -1
- package/dist/components/_util/type.js +41 -38
- package/dist/components/_util/type.js.map +1 -1
- package/dist/components/_util/types.js +41 -22
- package/dist/components/_util/types.js.map +1 -1
- package/dist/components/_util/typescript.js +2 -2
- package/dist/components/_util/typescript.js.map +1 -1
- package/dist/components/_util/util.js +85 -43
- package/dist/components/_util/util.js.map +1 -1
- package/dist/components/_util/vue/global-node.js +27 -15
- package/dist/components/_util/vue/global-node.js.map +1 -1
- package/dist/components/_util/vue/icon.js +29 -25
- package/dist/components/_util/vue/icon.js.map +1 -1
- package/dist/components/_util/vue/index.js +41 -41
- package/dist/components/_util/vue/install.js +35 -18
- package/dist/components/_util/vue/install.js.map +1 -1
- package/dist/components/_util/vue/props/index.js +6 -6
- package/dist/components/_util/vue/props/runtime.js +46 -30
- package/dist/components/_util/vue/props/runtime.js.map +1 -1
- package/dist/components/_util/vue/refs.js +12 -6
- package/dist/components/_util/vue/refs.js.map +1 -1
- package/dist/components/_util/vue/size.js +5 -3
- package/dist/components/_util/vue/size.js.map +1 -1
- package/dist/components/_util/vue/validator.js +5 -4
- package/dist/components/_util/vue/validator.js.map +1 -1
- package/dist/components/_util/vue/vnode.js +100 -54
- package/dist/components/_util/vue/vnode.js.map +1 -1
- package/dist/components/_util/vue-types/index.js +231 -220
- package/dist/components/_util/vue-types/index.js.map +1 -1
- package/dist/components/components.js +20 -20
- package/dist/components/index.js +38 -35
- package/dist/components/index.js.map +1 -1
- package/dist/components-B3d9m_tn.js +27 -0
- package/dist/components-B3d9m_tn.js.map +1 -0
- package/dist/error/OrionError.js +8 -4
- package/dist/error/OrionError.js.map +1 -1
- package/dist/functions-BeMkokbY.js +63 -0
- package/dist/functions-BeMkokbY.js.map +1 -0
- package/dist/index-BOKLZnqH.js +54 -0
- package/dist/index-BOKLZnqH.js.map +1 -0
- package/dist/index-D1m0KTpK.js +69 -0
- package/dist/index-D1m0KTpK.js.map +1 -0
- package/dist/index-DR5ZP7mD.js +160 -0
- package/dist/index-DR5ZP7mD.js.map +1 -0
- package/dist/index-DkwIULcN.js +200 -0
- package/dist/index-DkwIULcN.js.map +1 -0
- package/dist/index.css +797 -1
- package/dist/index.js +36 -36
- package/dist/print/LodopFuncs.js +101 -43
- package/dist/print/LodopFuncs.js.map +1 -1
- package/dist/print/index.js +200 -108
- package/dist/print/index.js.map +1 -1
- package/dist/request/ErrorHandlerChain.js +17 -14
- package/dist/request/ErrorHandlerChain.js.map +1 -1
- package/dist/request/RequestFilterChain.js +16 -13
- package/dist/request/RequestFilterChain.js.map +1 -1
- package/dist/request/ResponseParserChain.js +17 -14
- package/dist/request/ResponseParserChain.js.map +1 -1
- package/dist/request/disivion/DateSerializer.js +47 -22
- package/dist/request/disivion/DateSerializer.js.map +1 -1
- package/dist/request/disivion/DivisionErrorHandler.js +40 -25
- package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
- package/dist/request/disivion/DivisionResponseParser.js +16 -10
- package/dist/request/disivion/DivisionResponseParser.js.map +1 -1
- package/dist/request/disivion/index.js +305 -201
- package/dist/request/disivion/index.js.map +1 -1
- package/dist/request/error/BizExceptionResponseError.js +11 -5
- package/dist/request/error/BizExceptionResponseError.js.map +1 -1
- package/dist/request/error/ExceptionResponseError.js +11 -5
- package/dist/request/error/ExceptionResponseError.js.map +1 -1
- package/dist/request/error/ResponseError.js +9 -4
- package/dist/request/error/ResponseError.js.map +1 -1
- package/dist/request/error/SessionExceptionResponseError.js +11 -5
- package/dist/request/error/SessionExceptionResponseError.js.map +1 -1
- package/dist/request/index.js +11 -11
- package/dist/utils/DateUtil.js +48 -33
- package/dist/utils/DateUtil.js.map +1 -1
- package/dist/utils/NumberUtil.js +6 -6
- package/dist/utils/NumberUtil.js.map +1 -1
- package/dist/utils/cloneDeep.js +2 -2
- package/dist/utils/delay.js +3 -3
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/functions.js +3 -3
- package/dist/utils/index.js +12 -12
- package/dist/utils/md5.js +191 -93
- package/dist/utils/md5.js.map +1 -1
- package/dist/utils/uuid.js +35 -25
- package/dist/utils/uuid.js.map +1 -1
- package/dist/version/index.js +2 -2
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +2 -2
- package/dist/version/version.js.map +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"aria.js","sources":["../../../../src/components/_util/dom/aria.ts"],"sourcesContent":["const FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex=\"-1\"]),input:not([disabled]),input:not([type=\"hidden\"]),select:not([disabled]),textarea:not([disabled])`\r\n\r\n/**\r\n * Determine if the testing element is visible on screen no matter if its on the viewport or not\r\n */\r\nexport const isVisible = (element: HTMLElement) => {\r\n if (process.env.NODE_ENV === 'test') return true\r\n const computed = getComputedStyle(element)\r\n // element.offsetParent won't work on fix positioned\r\n // WARNING: potential issue here, going to need some expert advices on this issue\r\n return computed.position === 'fixed' ? false : element.offsetParent !== null\r\n}\r\n\r\nexport const obtainAllFocusableElements = (\r\n element: HTMLElement\r\n): HTMLElement[] => {\r\n return Array.from(\r\n element.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENT_SELECTORS)\r\n ).filter((item: HTMLElement) => isFocusable(item) && isVisible(item))\r\n}\r\n\r\n/**\r\n * @desc Determine if target element is focusable\r\n * @param element {HTMLElement}\r\n * @returns {Boolean} true if it is focusable\r\n */\r\nexport const isFocusable = (element: HTMLElement): boolean => {\r\n if (\r\n element.tabIndex > 0 ||\r\n (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)\r\n ) {\r\n return true\r\n }\r\n // HTMLButtonElement has disabled\r\n if ((element as HTMLButtonElement).disabled) {\r\n return false\r\n }\r\n\r\n switch (element.nodeName) {\r\n case 'A': {\r\n // casting current element to Specific HTMLElement in order to be more type precise\r\n return (\r\n !!(element as HTMLAnchorElement).href &&\r\n (element as HTMLAnchorElement).rel !== 'ignore'\r\n )\r\n }\r\n case 'INPUT': {\r\n return !(\r\n (element as HTMLInputElement).type === 'hidden' ||\r\n (element as HTMLInputElement).type === 'file'\r\n )\r\n }\r\n case 'BUTTON':\r\n case 'SELECT':\r\n case 'TEXTAREA': {\r\n return true\r\n }\r\n default: {\r\n return false\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @desc Set Attempt to set focus on the current node.\r\n * @param element\r\n * The node to attempt to focus on.\r\n * @returns\r\n * true if element is focused.\r\n */\r\nexport const attemptFocus = (element: HTMLElement): boolean => {\r\n if (!isFocusable(element)) {\r\n return false\r\n }\r\n // Remove the old try catch block since there will be no error to be thrown\r\n element.focus?.()\r\n return document.activeElement === element\r\n}\r\n\r\n/**\r\n * Trigger an event\r\n * mouseenter, mouseleave, mouseover, keyup, change, click, etc.\r\n * @param {HTMLElement} elm\r\n * @param {String} name\r\n * @param {*} opts\r\n */\r\nexport const triggerEvent = function (\r\n elm: HTMLElement,\r\n name: string,\r\n ...opts: Array<boolean>\r\n): HTMLElement {\r\n let eventName: string\r\n\r\n if (name.includes('mouse') || name.includes('click')) {\r\n eventName = 'MouseEvents'\r\n } else if (name.includes('key')) {\r\n eventName = 'KeyboardEvent'\r\n } else {\r\n eventName = 'HTMLEvents'\r\n }\r\n const evt = document.createEvent(eventName)\r\n\r\n evt.initEvent(name, ...opts)\r\n elm.dispatchEvent(evt)\r\n return elm\r\n}\r\n\r\nexport const isLeaf = (el: HTMLElement) => !el.getAttribute('aria-owns')\r\n\r\nexport const getSibling = (\r\n el: HTMLElement,\r\n distance: number,\r\n elClass: string\r\n) => {\r\n const { parentNode } = el\r\n if (!parentNode) return null\r\n const siblings = parentNode.querySelectorAll(elClass)\r\n const index = Array.prototype.indexOf.call(siblings, el)\r\n return siblings[index + distance] || null\r\n}\r\n\r\nexport const focusNode = (el: HTMLElement) => {\r\n if (!el) return\r\n el.focus()\r\n !isLeaf(el) && el.click()\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"aria.js","sources":["../../../../src/components/_util/dom/aria.ts"],"sourcesContent":["const FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex=\"-1\"]),input:not([disabled]),input:not([type=\"hidden\"]),select:not([disabled]),textarea:not([disabled])`\r\n\r\n/**\r\n * Determine if the testing element is visible on screen no matter if its on the viewport or not\r\n */\r\nexport const isVisible = (element: HTMLElement) => {\r\n if (process.env.NODE_ENV === 'test') return true\r\n const computed = getComputedStyle(element)\r\n // element.offsetParent won't work on fix positioned\r\n // WARNING: potential issue here, going to need some expert advices on this issue\r\n return computed.position === 'fixed' ? false : element.offsetParent !== null\r\n}\r\n\r\nexport const obtainAllFocusableElements = (\r\n element: HTMLElement\r\n): HTMLElement[] => {\r\n return Array.from(\r\n element.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENT_SELECTORS)\r\n ).filter((item: HTMLElement) => isFocusable(item) && isVisible(item))\r\n}\r\n\r\n/**\r\n * @desc Determine if target element is focusable\r\n * @param element {HTMLElement}\r\n * @returns {Boolean} true if it is focusable\r\n */\r\nexport const isFocusable = (element: HTMLElement): boolean => {\r\n if (\r\n element.tabIndex > 0 ||\r\n (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)\r\n ) {\r\n return true\r\n }\r\n // HTMLButtonElement has disabled\r\n if ((element as HTMLButtonElement).disabled) {\r\n return false\r\n }\r\n\r\n switch (element.nodeName) {\r\n case 'A': {\r\n // casting current element to Specific HTMLElement in order to be more type precise\r\n return (\r\n !!(element as HTMLAnchorElement).href &&\r\n (element as HTMLAnchorElement).rel !== 'ignore'\r\n )\r\n }\r\n case 'INPUT': {\r\n return !(\r\n (element as HTMLInputElement).type === 'hidden' ||\r\n (element as HTMLInputElement).type === 'file'\r\n )\r\n }\r\n case 'BUTTON':\r\n case 'SELECT':\r\n case 'TEXTAREA': {\r\n return true\r\n }\r\n default: {\r\n return false\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @desc Set Attempt to set focus on the current node.\r\n * @param element\r\n * The node to attempt to focus on.\r\n * @returns\r\n * true if element is focused.\r\n */\r\nexport const attemptFocus = (element: HTMLElement): boolean => {\r\n if (!isFocusable(element)) {\r\n return false\r\n }\r\n // Remove the old try catch block since there will be no error to be thrown\r\n element.focus?.()\r\n return document.activeElement === element\r\n}\r\n\r\n/**\r\n * Trigger an event\r\n * mouseenter, mouseleave, mouseover, keyup, change, click, etc.\r\n * @param {HTMLElement} elm\r\n * @param {String} name\r\n * @param {*} opts\r\n */\r\nexport const triggerEvent = function (\r\n elm: HTMLElement,\r\n name: string,\r\n ...opts: Array<boolean>\r\n): HTMLElement {\r\n let eventName: string\r\n\r\n if (name.includes('mouse') || name.includes('click')) {\r\n eventName = 'MouseEvents'\r\n } else if (name.includes('key')) {\r\n eventName = 'KeyboardEvent'\r\n } else {\r\n eventName = 'HTMLEvents'\r\n }\r\n const evt = document.createEvent(eventName)\r\n\r\n evt.initEvent(name, ...opts)\r\n elm.dispatchEvent(evt)\r\n return elm\r\n}\r\n\r\nexport const isLeaf = (el: HTMLElement) => !el.getAttribute('aria-owns')\r\n\r\nexport const getSibling = (\r\n el: HTMLElement,\r\n distance: number,\r\n elClass: string\r\n) => {\r\n const { parentNode } = el\r\n if (!parentNode) return null\r\n const siblings = parentNode.querySelectorAll(elClass)\r\n const index = Array.prototype.indexOf.call(siblings, el)\r\n return siblings[index + distance] || null\r\n}\r\n\r\nexport const focusNode = (el: HTMLElement) => {\r\n if (!el) return\r\n el.focus()\r\n !isLeaf(el) && el.click()\r\n}\r\n"],"names":[],"mappings":"AAAA,MAAM,8BAA8B;AAKvB,MAAA,YAAY,CAAC,YAAyB;AACjD,MAAI,QAAQ,IAAI,aAAa,OAAe,QAAA;AACtC,QAAA,WAAW,iBAAiB,OAAO;AAGzC,SAAO,SAAS,aAAa,UAAU,QAAQ,QAAQ,iBAAiB;AAC1E;AAEa,MAAA,6BAA6B,CACxC,YACkB;AAClB,SAAO,MAAM;AAAA,IACX,QAAQ,iBAA8B,2BAA2B;AAAA,EAAA,EACjE,OAAO,CAAC,SAAsB,YAAY,IAAI,KAAK,UAAU,IAAI,CAAC;AACtE;AAOa,MAAA,cAAc,CAAC,YAAkC;AAE1D,MAAA,QAAQ,WAAW,KAClB,QAAQ,aAAa,KAAK,QAAQ,aAAa,UAAU,MAAM,MAChE;AACO,WAAA;AAAA,EACT;AAEA,MAAK,QAA8B,UAAU;AACpC,WAAA;AAAA,EACT;AAEA,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK,KAAK;AAER,aACE,CAAC,CAAE,QAA8B,QAChC,QAA8B,QAAQ;AAAA,IAE3C;AAAA,IACA,KAAK,SAAS;AACZ,aAAO,EACJ,QAA6B,SAAS,YACtC,QAA6B,SAAS;AAAA,IAE3C;AAAA,IACA,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,YAAY;AACR,aAAA;AAAA,IACT;AAAA,IACA,SAAS;AACA,aAAA;AAAA,IACT;AAAA,EACF;AACF;AASa,MAAA,eAAe,CAAC,YAAkC;AAtE/D;AAuEM,MAAA,CAAC,YAAY,OAAO,GAAG;AAClB,WAAA;AAAA,EACT;AAEA,gBAAQ,UAAR;AACA,SAAO,SAAS,kBAAkB;AACpC;AASO,MAAM,eAAe,SAC1B,KACA,SACG,MACU;AACT,MAAA;AAEJ,MAAI,KAAK,SAAS,OAAO,KAAK,KAAK,SAAS,OAAO,GAAG;AACxC,gBAAA;AAAA,EACH,WAAA,KAAK,SAAS,KAAK,GAAG;AACnB,gBAAA;AAAA,EAAA,OACP;AACO,gBAAA;AAAA,EACd;AACM,QAAA,MAAM,SAAS,YAAY,SAAS;AAEtC,MAAA,UAAU,MAAM,GAAG,IAAI;AAC3B,MAAI,cAAc,GAAG;AACd,SAAA;AACT;AAEO,MAAM,SAAS,CAAC,OAAoB,CAAC,GAAG,aAAa,WAAW;AAEhE,MAAM,aAAa,CACxB,IACA,UACA,YACG;AACG,QAAA,EAAE,WAAe,IAAA;AACnB,MAAA,CAAC,WAAmB,QAAA;AAClB,QAAA,WAAW,WAAW,iBAAiB,OAAO;AACpD,QAAM,QAAQ,MAAM,UAAU,QAAQ,KAAK,UAAU,EAAE;AAChD,SAAA,SAAS,QAAQ,QAAQ,KAAK;AACvC;AAEa,MAAA,YAAY,CAAC,OAAoB;AAC5C,MAAI,CAAC,GAAI;AACT,KAAG,MAAM;AACT,GAAC,OAAO,EAAE,KAAK,GAAG,MAAM;AAC1B;"}
|
@@ -1,18 +1,19 @@
|
|
1
|
-
import { e as
|
1
|
+
import { e as isString } from "../../../functions-BeMkokbY.js";
|
2
2
|
import "lodash-es";
|
3
3
|
import "vue";
|
4
|
-
import { i as
|
5
|
-
const
|
6
|
-
if (!
|
7
|
-
if (
|
4
|
+
import { i as isClient } from "../../../index-D1m0KTpK.js";
|
5
|
+
const getElement = (target) => {
|
6
|
+
if (!isClient || target === "") return null;
|
7
|
+
if (isString(target)) {
|
8
8
|
try {
|
9
|
-
return document.querySelector(
|
9
|
+
return document.querySelector(target);
|
10
10
|
} catch {
|
11
11
|
return null;
|
12
12
|
}
|
13
|
-
|
13
|
+
}
|
14
|
+
return target;
|
14
15
|
};
|
15
16
|
export {
|
16
|
-
|
17
|
+
getElement
|
17
18
|
};
|
18
19
|
//# sourceMappingURL=element.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"element.js","sources":["../../../../src/components/_util/dom/element.ts"],"sourcesContent":["import { isString } from '../types'\r\nimport { isClient } from '../browser'\r\n\r\ntype GetElement = <T extends string | HTMLElement | Window | null | undefined>(\r\n target: T\r\n) => T extends string ? HTMLElement | null : T\r\n\r\nexport const getElement = ((\r\n target: string | HTMLElement | Window | null | undefined\r\n) => {\r\n if (!isClient || target === '') return null\r\n if (isString(target)) {\r\n try {\r\n return document.querySelector<HTMLElement>(target)\r\n } catch {\r\n return null\r\n }\r\n }\r\n return target\r\n}) as GetElement\r\n"],"names":[
|
1
|
+
{"version":3,"file":"element.js","sources":["../../../../src/components/_util/dom/element.ts"],"sourcesContent":["import { isString } from '../types'\r\nimport { isClient } from '../browser'\r\n\r\ntype GetElement = <T extends string | HTMLElement | Window | null | undefined>(\r\n target: T\r\n) => T extends string ? HTMLElement | null : T\r\n\r\nexport const getElement = ((\r\n target: string | HTMLElement | Window | null | undefined\r\n) => {\r\n if (!isClient || target === '') return null\r\n if (isString(target)) {\r\n try {\r\n return document.querySelector<HTMLElement>(target)\r\n } catch {\r\n return null\r\n }\r\n }\r\n return target\r\n}) as GetElement\r\n"],"names":[],"mappings":";;;;AAOa,MAAA,aAAc,CACzB,WACG;AACH,MAAI,CAAC,YAAY,WAAW,GAAW,QAAA;AACnC,MAAA,SAAS,MAAM,GAAG;AAChB,QAAA;AACK,aAAA,SAAS,cAA2B,MAAM;AAAA,IAAA,QAC3C;AACC,aAAA;AAAA,IACT;AAAA,EACF;AACO,SAAA;AACT;"}
|
@@ -1,10 +1,17 @@
|
|
1
|
-
const
|
2
|
-
const
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
|
2
|
+
const handleEvent = (event) => {
|
3
|
+
const shouldPrevent = theirsHandler == null ? void 0 : theirsHandler(event);
|
4
|
+
if (checkForDefaultPrevented === false || !shouldPrevent) {
|
5
|
+
return oursHandler == null ? void 0 : oursHandler(event);
|
6
|
+
}
|
7
|
+
};
|
8
|
+
return handleEvent;
|
9
|
+
};
|
10
|
+
const whenMouse = (handler) => {
|
11
|
+
return (e) => e.pointerType === "mouse" ? handler(e) : void 0;
|
12
|
+
};
|
6
13
|
export {
|
7
|
-
|
8
|
-
|
14
|
+
composeEventHandlers,
|
15
|
+
whenMouse
|
9
16
|
};
|
10
17
|
//# sourceMappingURL=event.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"event.js","sources":["../../../../src/components/_util/dom/event.ts"],"sourcesContent":["export const composeEventHandlers = <E>(\r\n theirsHandler?: (event: E) => boolean | void,\r\n oursHandler?: (event: E) => void,\r\n { checkForDefaultPrevented = true } = {}\r\n) => {\r\n const handleEvent = (event: E) => {\r\n const shouldPrevent = theirsHandler?.(event)\r\n\r\n if (checkForDefaultPrevented === false || !shouldPrevent) {\r\n return oursHandler?.(event)\r\n }\r\n }\r\n return handleEvent\r\n}\r\n\r\ntype WhenMouseHandler = (e: PointerEvent) => any\r\nexport const whenMouse = (handler: WhenMouseHandler): WhenMouseHandler => {\r\n return (e: PointerEvent) =>\r\n e.pointerType === 'mouse' ? handler(e) : undefined\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"event.js","sources":["../../../../src/components/_util/dom/event.ts"],"sourcesContent":["export const composeEventHandlers = <E>(\r\n theirsHandler?: (event: E) => boolean | void,\r\n oursHandler?: (event: E) => void,\r\n { checkForDefaultPrevented = true } = {}\r\n) => {\r\n const handleEvent = (event: E) => {\r\n const shouldPrevent = theirsHandler?.(event)\r\n\r\n if (checkForDefaultPrevented === false || !shouldPrevent) {\r\n return oursHandler?.(event)\r\n }\r\n }\r\n return handleEvent\r\n}\r\n\r\ntype WhenMouseHandler = (e: PointerEvent) => any\r\nexport const whenMouse = (handler: WhenMouseHandler): WhenMouseHandler => {\r\n return (e: PointerEvent) =>\r\n e.pointerType === 'mouse' ? handler(e) : undefined\r\n}\r\n"],"names":[],"mappings":"AAAa,MAAA,uBAAuB,CAClC,eACA,aACA,EAAE,2BAA2B,KAAS,IAAA,OACnC;AACG,QAAA,cAAc,CAAC,UAAa;AAC1B,UAAA,gBAAgB,+CAAgB;AAElC,QAAA,6BAA6B,SAAS,CAAC,eAAe;AACxD,aAAO,2CAAc;AAAA,IACvB;AAAA,EAAA;AAEK,SAAA;AACT;AAGa,MAAA,YAAY,CAAC,YAAgD;AACxE,SAAO,CAAC,MACN,EAAE,gBAAgB,UAAU,QAAQ,CAAC,IAAI;AAC7C;"}
|
@@ -1,39 +1,39 @@
|
|
1
|
-
import { attemptFocus
|
2
|
-
import { composeEventHandlers
|
3
|
-
import { getClientXY
|
4
|
-
import { animateScrollTo
|
5
|
-
import { addClass
|
6
|
-
import { getElement
|
1
|
+
import { attemptFocus, focusNode, getSibling, isFocusable, isLeaf, isVisible, obtainAllFocusableElements, triggerEvent } from "./aria.js";
|
2
|
+
import { composeEventHandlers, whenMouse } from "./event.js";
|
3
|
+
import { getClientXY, getOffsetTop, getOffsetTopDistance, isInContainer } from "./position.js";
|
4
|
+
import { animateScrollTo, getScrollBarWidth, getScrollContainer, getScrollElement, getScrollTop, isScroll, scrollIntoView } from "./scroll.js";
|
5
|
+
import { addClass, addUnit, classNameToArray, getStyle, hasClass, removeClass, removeStyle, setStyle } from "./style.js";
|
6
|
+
import { getElement } from "./element.js";
|
7
7
|
export {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
8
|
+
addClass,
|
9
|
+
addUnit,
|
10
|
+
animateScrollTo,
|
11
|
+
attemptFocus,
|
12
|
+
classNameToArray,
|
13
|
+
composeEventHandlers,
|
14
|
+
focusNode,
|
15
|
+
getClientXY,
|
16
|
+
getElement,
|
17
|
+
getOffsetTop,
|
18
|
+
getOffsetTopDistance,
|
19
|
+
getScrollBarWidth,
|
20
|
+
getScrollContainer,
|
21
|
+
getScrollElement,
|
22
|
+
getScrollTop,
|
23
|
+
getSibling,
|
24
|
+
getStyle,
|
25
|
+
hasClass,
|
26
|
+
isFocusable,
|
27
|
+
isInContainer,
|
28
|
+
isLeaf,
|
29
|
+
isScroll,
|
30
|
+
isVisible,
|
31
|
+
obtainAllFocusableElements,
|
32
|
+
removeClass,
|
33
|
+
removeStyle,
|
34
|
+
scrollIntoView,
|
35
|
+
setStyle,
|
36
|
+
triggerEvent,
|
37
|
+
whenMouse
|
38
38
|
};
|
39
39
|
//# sourceMappingURL=index.js.map
|
@@ -1,30 +1,54 @@
|
|
1
|
-
import { i as
|
2
|
-
const
|
3
|
-
if (!
|
4
|
-
const
|
5
|
-
let
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
return
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
import { i as isClient } from "../../../index-D1m0KTpK.js";
|
2
|
+
const isInContainer = (el, container) => {
|
3
|
+
if (!isClient || !el || !container) return false;
|
4
|
+
const elRect = el.getBoundingClientRect();
|
5
|
+
let containerRect;
|
6
|
+
if (container instanceof Element) {
|
7
|
+
containerRect = container.getBoundingClientRect();
|
8
|
+
} else {
|
9
|
+
containerRect = {
|
10
|
+
top: 0,
|
11
|
+
right: window.innerWidth,
|
12
|
+
bottom: window.innerHeight,
|
13
|
+
left: 0
|
14
|
+
};
|
15
|
+
}
|
16
|
+
return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right;
|
17
|
+
};
|
18
|
+
const getOffsetTop = (el) => {
|
19
|
+
let offset = 0;
|
20
|
+
let parent = el;
|
21
|
+
while (parent) {
|
22
|
+
offset += parent.offsetTop;
|
23
|
+
parent = parent.offsetParent;
|
24
|
+
}
|
25
|
+
return offset;
|
26
|
+
};
|
27
|
+
const getOffsetTopDistance = (el, containerEl) => {
|
28
|
+
return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl));
|
29
|
+
};
|
30
|
+
const getClientXY = (event) => {
|
31
|
+
let clientX;
|
32
|
+
let clientY;
|
33
|
+
if (event.type === "touchend") {
|
34
|
+
clientY = event.changedTouches[0].clientY;
|
35
|
+
clientX = event.changedTouches[0].clientX;
|
36
|
+
} else if (event.type.startsWith("touch")) {
|
37
|
+
clientY = event.touches[0].clientY;
|
38
|
+
clientX = event.touches[0].clientX;
|
39
|
+
} else {
|
40
|
+
clientY = event.clientY;
|
41
|
+
clientX = event.clientX;
|
42
|
+
}
|
43
|
+
return {
|
44
|
+
clientX,
|
45
|
+
clientY
|
22
46
|
};
|
23
47
|
};
|
24
48
|
export {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
49
|
+
getClientXY,
|
50
|
+
getOffsetTop,
|
51
|
+
getOffsetTopDistance,
|
52
|
+
isInContainer
|
29
53
|
};
|
30
54
|
//# sourceMappingURL=position.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"position.js","sources":["../../../../src/components/_util/dom/position.ts"],"sourcesContent":["import { isClient } from '../browser'\r\n\r\nexport const isInContainer = (\r\n el?: Element,\r\n container?: Element | Window\r\n): boolean => {\r\n if (!isClient || !el || !container) return false\r\n\r\n const elRect = el.getBoundingClientRect()\r\n\r\n let containerRect: Pick<DOMRect, 'top' | 'bottom' | 'left' | 'right'>\r\n if (container instanceof Element) {\r\n containerRect = container.getBoundingClientRect()\r\n } else {\r\n containerRect = {\r\n top: 0,\r\n right: window.innerWidth,\r\n bottom: window.innerHeight,\r\n left: 0,\r\n }\r\n }\r\n return (\r\n elRect.top < containerRect.bottom &&\r\n elRect.bottom > containerRect.top &&\r\n elRect.right > containerRect.left &&\r\n elRect.left < containerRect.right\r\n )\r\n}\r\n\r\nexport const getOffsetTop = (el: HTMLElement) => {\r\n let offset = 0\r\n let parent = el\r\n\r\n while (parent) {\r\n offset += parent.offsetTop\r\n parent = parent.offsetParent as HTMLElement\r\n }\r\n\r\n return offset\r\n}\r\n\r\nexport const getOffsetTopDistance = (\r\n el: HTMLElement,\r\n containerEl: HTMLElement\r\n) => {\r\n return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl))\r\n}\r\n\r\nexport const getClientXY = (event: MouseEvent | TouchEvent) => {\r\n let clientX: number\r\n let clientY: number\r\n if (event.type === 'touchend') {\r\n clientY = (event as TouchEvent).changedTouches[0].clientY\r\n clientX = (event as TouchEvent).changedTouches[0].clientX\r\n } else if (event.type.startsWith('touch')) {\r\n clientY = (event as TouchEvent).touches[0].clientY\r\n clientX = (event as TouchEvent).touches[0].clientX\r\n } else {\r\n clientY = (event as MouseEvent).clientY\r\n clientX = (event as MouseEvent).clientX\r\n }\r\n return {\r\n clientX,\r\n clientY,\r\n }\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"position.js","sources":["../../../../src/components/_util/dom/position.ts"],"sourcesContent":["import { isClient } from '../browser'\r\n\r\nexport const isInContainer = (\r\n el?: Element,\r\n container?: Element | Window\r\n): boolean => {\r\n if (!isClient || !el || !container) return false\r\n\r\n const elRect = el.getBoundingClientRect()\r\n\r\n let containerRect: Pick<DOMRect, 'top' | 'bottom' | 'left' | 'right'>\r\n if (container instanceof Element) {\r\n containerRect = container.getBoundingClientRect()\r\n } else {\r\n containerRect = {\r\n top: 0,\r\n right: window.innerWidth,\r\n bottom: window.innerHeight,\r\n left: 0,\r\n }\r\n }\r\n return (\r\n elRect.top < containerRect.bottom &&\r\n elRect.bottom > containerRect.top &&\r\n elRect.right > containerRect.left &&\r\n elRect.left < containerRect.right\r\n )\r\n}\r\n\r\nexport const getOffsetTop = (el: HTMLElement) => {\r\n let offset = 0\r\n let parent = el\r\n\r\n while (parent) {\r\n offset += parent.offsetTop\r\n parent = parent.offsetParent as HTMLElement\r\n }\r\n\r\n return offset\r\n}\r\n\r\nexport const getOffsetTopDistance = (\r\n el: HTMLElement,\r\n containerEl: HTMLElement\r\n) => {\r\n return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl))\r\n}\r\n\r\nexport const getClientXY = (event: MouseEvent | TouchEvent) => {\r\n let clientX: number\r\n let clientY: number\r\n if (event.type === 'touchend') {\r\n clientY = (event as TouchEvent).changedTouches[0].clientY\r\n clientX = (event as TouchEvent).changedTouches[0].clientX\r\n } else if (event.type.startsWith('touch')) {\r\n clientY = (event as TouchEvent).touches[0].clientY\r\n clientX = (event as TouchEvent).touches[0].clientX\r\n } else {\r\n clientY = (event as MouseEvent).clientY\r\n clientX = (event as MouseEvent).clientX\r\n }\r\n return {\r\n clientX,\r\n clientY,\r\n }\r\n}\r\n"],"names":[],"mappings":";AAEa,MAAA,gBAAgB,CAC3B,IACA,cACY;AACZ,MAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAkB,QAAA;AAErC,QAAA,SAAS,GAAG;AAEd,MAAA;AACJ,MAAI,qBAAqB,SAAS;AAChC,oBAAgB,UAAU;EAAsB,OAC3C;AACW,oBAAA;AAAA,MACd,KAAK;AAAA,MACL,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf,MAAM;AAAA,IAAA;AAAA,EAEV;AACA,SACE,OAAO,MAAM,cAAc,UAC3B,OAAO,SAAS,cAAc,OAC9B,OAAO,QAAQ,cAAc,QAC7B,OAAO,OAAO,cAAc;AAEhC;AAEa,MAAA,eAAe,CAAC,OAAoB;AAC/C,MAAI,SAAS;AACb,MAAI,SAAS;AAEb,SAAO,QAAQ;AACb,cAAU,OAAO;AACjB,aAAS,OAAO;AAAA,EAClB;AAEO,SAAA;AACT;AAEa,MAAA,uBAAuB,CAClC,IACA,gBACG;AACH,SAAO,KAAK,IAAI,aAAa,EAAE,IAAI,aAAa,WAAW,CAAC;AAC9D;AAEa,MAAA,cAAc,CAAC,UAAmC;AACzD,MAAA;AACA,MAAA;AACA,MAAA,MAAM,SAAS,YAAY;AAClB,cAAA,MAAqB,eAAe,CAAC,EAAE;AACvC,cAAA,MAAqB,eAAe,CAAC,EAAE;AAAA,EACzC,WAAA,MAAM,KAAK,WAAW,OAAO,GAAG;AAC9B,cAAA,MAAqB,QAAQ,CAAC,EAAE;AAChC,cAAA,MAAqB,QAAQ,CAAC,EAAE;AAAA,EAAA,OACtC;AACL,cAAW,MAAqB;AAChC,cAAW,MAAqB;AAAA,EAClC;AACO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
@@ -1,78 +1,120 @@
|
|
1
|
-
import { easeInOutCubic
|
2
|
-
import { isWindow
|
3
|
-
import { rAF
|
4
|
-
import { getStyle
|
5
|
-
import { i as
|
6
|
-
const
|
7
|
-
if (!
|
8
|
-
const
|
1
|
+
import { easeInOutCubic } from "../easings.js";
|
2
|
+
import { isWindow } from "../types.js";
|
3
|
+
import { rAF, cAF } from "../raf.js";
|
4
|
+
import { getStyle } from "./style.js";
|
5
|
+
import { i as isClient } from "../../../index-D1m0KTpK.js";
|
6
|
+
const isScroll = (el, isVertical) => {
|
7
|
+
if (!isClient) return false;
|
8
|
+
const key = {
|
9
9
|
undefined: "overflow",
|
10
10
|
true: "overflow-y",
|
11
11
|
false: "overflow-x"
|
12
|
-
}[String(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
}[String(isVertical)];
|
13
|
+
const overflow = getStyle(el, key);
|
14
|
+
return ["scroll", "auto", "overlay"].some((s) => overflow.includes(s));
|
15
|
+
};
|
16
|
+
const getScrollContainer = (el, isVertical) => {
|
17
|
+
if (!isClient) return;
|
18
|
+
let parent = el;
|
19
|
+
while (parent) {
|
20
|
+
if ([window, document, document.documentElement].includes(parent))
|
19
21
|
return window;
|
20
|
-
if (
|
21
|
-
|
22
|
+
if (isScroll(parent, isVertical)) return parent;
|
23
|
+
parent = parent.parentNode;
|
22
24
|
}
|
23
|
-
return
|
25
|
+
return parent;
|
24
26
|
};
|
25
|
-
let
|
26
|
-
const
|
27
|
-
var
|
28
|
-
if (!
|
29
|
-
if (
|
30
|
-
const
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
let scrollBarWidth;
|
28
|
+
const getScrollBarWidth = (namespace) => {
|
29
|
+
var _a;
|
30
|
+
if (!isClient) return 0;
|
31
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
32
|
+
const outer = document.createElement("div");
|
33
|
+
outer.className = `${namespace}-scrollbar__wrap`;
|
34
|
+
outer.style.visibility = "hidden";
|
35
|
+
outer.style.width = "100px";
|
36
|
+
outer.style.position = "absolute";
|
37
|
+
outer.style.top = "-9999px";
|
38
|
+
document.body.appendChild(outer);
|
39
|
+
const widthNoScroll = outer.offsetWidth;
|
40
|
+
outer.style.overflow = "scroll";
|
41
|
+
const inner = document.createElement("div");
|
42
|
+
inner.style.width = "100%";
|
43
|
+
outer.appendChild(inner);
|
44
|
+
const widthWithScroll = inner.offsetWidth;
|
45
|
+
(_a = outer.parentNode) == null ? void 0 : _a.removeChild(outer);
|
46
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
47
|
+
return scrollBarWidth;
|
38
48
|
};
|
39
|
-
function
|
40
|
-
if (!
|
41
|
-
if (!
|
42
|
-
|
49
|
+
function scrollIntoView(container, selected) {
|
50
|
+
if (!isClient) return;
|
51
|
+
if (!selected) {
|
52
|
+
container.scrollTop = 0;
|
43
53
|
return;
|
44
54
|
}
|
45
|
-
const
|
46
|
-
let
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
const offsetParents = [];
|
56
|
+
let pointer = selected.offsetParent;
|
57
|
+
while (pointer !== null && container !== pointer && container.contains(pointer)) {
|
58
|
+
offsetParents.push(pointer);
|
59
|
+
pointer = pointer.offsetParent;
|
60
|
+
}
|
61
|
+
const top = selected.offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
|
62
|
+
const bottom = top + selected.offsetHeight;
|
63
|
+
const viewRectTop = container.scrollTop;
|
64
|
+
const viewRectBottom = viewRectTop + container.clientHeight;
|
65
|
+
if (top < viewRectTop) {
|
66
|
+
container.scrollTop = top;
|
67
|
+
} else if (bottom > viewRectBottom) {
|
68
|
+
container.scrollTop = bottom - container.clientHeight;
|
69
|
+
}
|
51
70
|
}
|
52
|
-
function
|
53
|
-
const
|
54
|
-
let
|
55
|
-
const
|
56
|
-
const
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
71
|
+
function animateScrollTo(container, from, to, duration, callback) {
|
72
|
+
const startTime = Date.now();
|
73
|
+
let handle;
|
74
|
+
const scroll = () => {
|
75
|
+
const timestamp = Date.now();
|
76
|
+
const time = timestamp - startTime;
|
77
|
+
const nextScrollTop = easeInOutCubic(
|
78
|
+
time > duration ? duration : time,
|
79
|
+
from,
|
80
|
+
to,
|
81
|
+
duration
|
61
82
|
);
|
62
|
-
|
83
|
+
if (isWindow(container)) {
|
84
|
+
container.scrollTo(window.pageXOffset, nextScrollTop);
|
85
|
+
} else {
|
86
|
+
container.scrollTop = nextScrollTop;
|
87
|
+
}
|
88
|
+
if (time < duration) {
|
89
|
+
handle = rAF(scroll);
|
90
|
+
} else if (typeof callback === "function") {
|
91
|
+
callback();
|
92
|
+
}
|
63
93
|
};
|
64
|
-
|
65
|
-
|
94
|
+
scroll();
|
95
|
+
return () => {
|
96
|
+
handle && cAF(handle);
|
66
97
|
};
|
67
98
|
}
|
68
|
-
const
|
99
|
+
const getScrollElement = (target, container) => {
|
100
|
+
if (isWindow(container)) {
|
101
|
+
return target.ownerDocument.documentElement;
|
102
|
+
}
|
103
|
+
return container;
|
104
|
+
};
|
105
|
+
const getScrollTop = (container) => {
|
106
|
+
if (isWindow(container)) {
|
107
|
+
return window.scrollY;
|
108
|
+
}
|
109
|
+
return container.scrollTop;
|
110
|
+
};
|
69
111
|
export {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
112
|
+
animateScrollTo,
|
113
|
+
getScrollBarWidth,
|
114
|
+
getScrollContainer,
|
115
|
+
getScrollElement,
|
116
|
+
getScrollTop,
|
117
|
+
isScroll,
|
118
|
+
scrollIntoView
|
77
119
|
};
|
78
120
|
//# sourceMappingURL=scroll.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scroll.js","sources":["../../../../src/components/_util/dom/scroll.ts"],"sourcesContent":["import { isClient } from '../browser'\r\nimport { easeInOutCubic } from '../easings'\r\nimport { isWindow } from '../types'\r\nimport { cAF, rAF } from '../raf'\r\nimport { getStyle } from './style'\r\n\r\nexport const isScroll = (el: HTMLElement, isVertical?: boolean): boolean => {\r\n if (!isClient) return false\r\n\r\n const key = (\r\n {\r\n undefined: 'overflow',\r\n true: 'overflow-y',\r\n false: 'overflow-x',\r\n } as const\r\n )[String(isVertical)]!\r\n const overflow = getStyle(el, key)\r\n return ['scroll', 'auto', 'overlay'].some((s) => overflow.includes(s))\r\n}\r\n\r\nexport const getScrollContainer = (\r\n el: HTMLElement,\r\n isVertical?: boolean\r\n): Window | HTMLElement | undefined => {\r\n if (!isClient) return\r\n\r\n let parent: HTMLElement = el\r\n while (parent) {\r\n if ([window, document, document.documentElement].includes(parent))\r\n return window\r\n\r\n if (isScroll(parent, isVertical)) return parent\r\n\r\n parent = parent.parentNode as HTMLElement\r\n }\r\n\r\n return parent\r\n}\r\n\r\nlet scrollBarWidth: number\r\nexport const getScrollBarWidth = (namespace: string): number => {\r\n if (!isClient) return 0\r\n if (scrollBarWidth !== undefined) return scrollBarWidth\r\n\r\n const outer = document.createElement('div')\r\n outer.className = `${namespace}-scrollbar__wrap`\r\n outer.style.visibility = 'hidden'\r\n outer.style.width = '100px'\r\n outer.style.position = 'absolute'\r\n outer.style.top = '-9999px'\r\n document.body.appendChild(outer)\r\n\r\n const widthNoScroll = outer.offsetWidth\r\n outer.style.overflow = 'scroll'\r\n\r\n const inner = document.createElement('div')\r\n inner.style.width = '100%'\r\n outer.appendChild(inner)\r\n\r\n const widthWithScroll = inner.offsetWidth\r\n outer.parentNode?.removeChild(outer)\r\n scrollBarWidth = widthNoScroll - widthWithScroll\r\n\r\n return scrollBarWidth\r\n}\r\n\r\n/**\r\n * Scroll with in the container element, positioning the **selected** element at the top\r\n * of the container\r\n */\r\nexport function scrollIntoView(\r\n container: HTMLElement,\r\n selected: HTMLElement\r\n): void {\r\n if (!isClient) return\r\n\r\n if (!selected) {\r\n container.scrollTop = 0\r\n return\r\n }\r\n\r\n const offsetParents: HTMLElement[] = []\r\n let pointer = selected.offsetParent\r\n while (\r\n pointer !== null &&\r\n container !== pointer &&\r\n container.contains(pointer)\r\n ) {\r\n offsetParents.push(pointer as HTMLElement)\r\n pointer = (pointer as HTMLElement).offsetParent\r\n }\r\n const top =\r\n selected.offsetTop +\r\n offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0)\r\n const bottom = top + selected.offsetHeight\r\n const viewRectTop = container.scrollTop\r\n const viewRectBottom = viewRectTop + container.clientHeight\r\n\r\n if (top < viewRectTop) {\r\n container.scrollTop = top\r\n } else if (bottom > viewRectBottom) {\r\n container.scrollTop = bottom - container.clientHeight\r\n }\r\n}\r\n\r\nexport function animateScrollTo(\r\n container: HTMLElement | Window,\r\n from: number,\r\n to: number,\r\n duration: number,\r\n callback?: unknown\r\n) {\r\n const startTime = Date.now()\r\n\r\n let handle: number | undefined\r\n const scroll = () => {\r\n const timestamp = Date.now()\r\n const time = timestamp - startTime\r\n const nextScrollTop = easeInOutCubic(\r\n time > duration ? duration : time,\r\n from,\r\n to,\r\n duration\r\n )\r\n\r\n if (isWindow(container)) {\r\n container.scrollTo(window.pageXOffset, nextScrollTop)\r\n } else {\r\n container.scrollTop = nextScrollTop\r\n }\r\n if (time < duration) {\r\n handle = rAF(scroll)\r\n } else if (typeof callback === 'function') {\r\n callback()\r\n }\r\n }\r\n\r\n scroll()\r\n\r\n return () => {\r\n handle && cAF(handle)\r\n }\r\n}\r\n\r\nexport const getScrollElement = (\r\n target: HTMLElement,\r\n container: HTMLElement | Window\r\n) => {\r\n if (isWindow(container)) {\r\n return target.ownerDocument.documentElement\r\n }\r\n return container\r\n}\r\n\r\nexport const getScrollTop = (container: HTMLElement | Window) => {\r\n if (isWindow(container)) {\r\n return window.scrollY\r\n }\r\n return container.scrollTop\r\n}\r\n"],"names":[
|
1
|
+
{"version":3,"file":"scroll.js","sources":["../../../../src/components/_util/dom/scroll.ts"],"sourcesContent":["import { isClient } from '../browser'\r\nimport { easeInOutCubic } from '../easings'\r\nimport { isWindow } from '../types'\r\nimport { cAF, rAF } from '../raf'\r\nimport { getStyle } from './style'\r\n\r\nexport const isScroll = (el: HTMLElement, isVertical?: boolean): boolean => {\r\n if (!isClient) return false\r\n\r\n const key = (\r\n {\r\n undefined: 'overflow',\r\n true: 'overflow-y',\r\n false: 'overflow-x',\r\n } as const\r\n )[String(isVertical)]!\r\n const overflow = getStyle(el, key)\r\n return ['scroll', 'auto', 'overlay'].some((s) => overflow.includes(s))\r\n}\r\n\r\nexport const getScrollContainer = (\r\n el: HTMLElement,\r\n isVertical?: boolean\r\n): Window | HTMLElement | undefined => {\r\n if (!isClient) return\r\n\r\n let parent: HTMLElement = el\r\n while (parent) {\r\n if ([window, document, document.documentElement].includes(parent))\r\n return window\r\n\r\n if (isScroll(parent, isVertical)) return parent\r\n\r\n parent = parent.parentNode as HTMLElement\r\n }\r\n\r\n return parent\r\n}\r\n\r\nlet scrollBarWidth: number\r\nexport const getScrollBarWidth = (namespace: string): number => {\r\n if (!isClient) return 0\r\n if (scrollBarWidth !== undefined) return scrollBarWidth\r\n\r\n const outer = document.createElement('div')\r\n outer.className = `${namespace}-scrollbar__wrap`\r\n outer.style.visibility = 'hidden'\r\n outer.style.width = '100px'\r\n outer.style.position = 'absolute'\r\n outer.style.top = '-9999px'\r\n document.body.appendChild(outer)\r\n\r\n const widthNoScroll = outer.offsetWidth\r\n outer.style.overflow = 'scroll'\r\n\r\n const inner = document.createElement('div')\r\n inner.style.width = '100%'\r\n outer.appendChild(inner)\r\n\r\n const widthWithScroll = inner.offsetWidth\r\n outer.parentNode?.removeChild(outer)\r\n scrollBarWidth = widthNoScroll - widthWithScroll\r\n\r\n return scrollBarWidth\r\n}\r\n\r\n/**\r\n * Scroll with in the container element, positioning the **selected** element at the top\r\n * of the container\r\n */\r\nexport function scrollIntoView(\r\n container: HTMLElement,\r\n selected: HTMLElement\r\n): void {\r\n if (!isClient) return\r\n\r\n if (!selected) {\r\n container.scrollTop = 0\r\n return\r\n }\r\n\r\n const offsetParents: HTMLElement[] = []\r\n let pointer = selected.offsetParent\r\n while (\r\n pointer !== null &&\r\n container !== pointer &&\r\n container.contains(pointer)\r\n ) {\r\n offsetParents.push(pointer as HTMLElement)\r\n pointer = (pointer as HTMLElement).offsetParent\r\n }\r\n const top =\r\n selected.offsetTop +\r\n offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0)\r\n const bottom = top + selected.offsetHeight\r\n const viewRectTop = container.scrollTop\r\n const viewRectBottom = viewRectTop + container.clientHeight\r\n\r\n if (top < viewRectTop) {\r\n container.scrollTop = top\r\n } else if (bottom > viewRectBottom) {\r\n container.scrollTop = bottom - container.clientHeight\r\n }\r\n}\r\n\r\nexport function animateScrollTo(\r\n container: HTMLElement | Window,\r\n from: number,\r\n to: number,\r\n duration: number,\r\n callback?: unknown\r\n) {\r\n const startTime = Date.now()\r\n\r\n let handle: number | undefined\r\n const scroll = () => {\r\n const timestamp = Date.now()\r\n const time = timestamp - startTime\r\n const nextScrollTop = easeInOutCubic(\r\n time > duration ? duration : time,\r\n from,\r\n to,\r\n duration\r\n )\r\n\r\n if (isWindow(container)) {\r\n container.scrollTo(window.pageXOffset, nextScrollTop)\r\n } else {\r\n container.scrollTop = nextScrollTop\r\n }\r\n if (time < duration) {\r\n handle = rAF(scroll)\r\n } else if (typeof callback === 'function') {\r\n callback()\r\n }\r\n }\r\n\r\n scroll()\r\n\r\n return () => {\r\n handle && cAF(handle)\r\n }\r\n}\r\n\r\nexport const getScrollElement = (\r\n target: HTMLElement,\r\n container: HTMLElement | Window\r\n) => {\r\n if (isWindow(container)) {\r\n return target.ownerDocument.documentElement\r\n }\r\n return container\r\n}\r\n\r\nexport const getScrollTop = (container: HTMLElement | Window) => {\r\n if (isWindow(container)) {\r\n return window.scrollY\r\n }\r\n return container.scrollTop\r\n}\r\n"],"names":[],"mappings":"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"}
|