versoly-ui 2.2.0 → 2.3.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.
- package/.oxfmtrc.json +3 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/launch.json +4 -4
- package/.vscode/settings.json +23 -0
- package/dist/versoly-ui.cjs +12 -0
- package/dist/versoly-ui.iife.js +4 -4
- package/dist/versoly-ui.mjs +4 -4
- package/index.html +5 -4
- package/package.json +20 -10
- package/src/index.ts +3 -3
- package/src/plugins/accordion.ts +26 -26
- package/src/plugins/collapse.ts +15 -15
- package/src/plugins/dismiss.ts +4 -4
- package/src/plugins/dropdown.ts +26 -16
- package/src/plugins/index.ts +7 -7
- package/src/plugins/modal.ts +19 -16
- package/src/plugins/tabs.ts +13 -13
- package/src/types.d.ts +1 -2
- package/src/utils/index.ts +14 -12
- package/tsconfig.json +9 -4
- package/tsdown.config.ts +18 -9
- package/vite.config.ts +13 -0
- package/.vscode/settings.template.json +0 -4
- package/dist/versoly-ui.js +0 -12
- package/eslint.config.ts +0 -11
- package/prettier.config.js +0 -20
- package/vite.config.js +0 -35
package/.oxfmtrc.json
ADDED
package/.vscode/launch.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"program": "${file}",
|
|
12
12
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/tsx",
|
|
13
13
|
"cwd": "${workspaceRoot}",
|
|
14
|
-
"skipFiles": ["<node_internals>/**", "node_modules/**"]
|
|
14
|
+
"skipFiles": ["<node_internals>/**", "node_modules/**"]
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"name": "Debug Current Test File",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"args": ["run", "${relativeFile}"],
|
|
23
23
|
"smartStep": true,
|
|
24
24
|
"console": "integratedTerminal",
|
|
25
|
-
"skipFiles": ["<node_internals>/**", "**/node_modules/**"]
|
|
26
|
-
}
|
|
27
|
-
]
|
|
25
|
+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
28
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"oxc.typeAware": true,
|
|
3
|
+
"oxc.fmt.configPath": ".oxfmtrc.json",
|
|
4
|
+
"prettier.enable": false,
|
|
5
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
6
|
+
"editor.formatOnSave": true,
|
|
7
|
+
"editor.codeActionsOnSave": {
|
|
8
|
+
"source.fixAll.oxc": "always",
|
|
9
|
+
"source.fixAll.prettier": "never"
|
|
10
|
+
},
|
|
11
|
+
"[javascript]": {
|
|
12
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
13
|
+
},
|
|
14
|
+
"[typescript]": {
|
|
15
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
16
|
+
},
|
|
17
|
+
"[jsonc]": {
|
|
18
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
19
|
+
},
|
|
20
|
+
"[html]": {
|
|
21
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?parseFloat(t.replace(`s`,``))*1e3+1:0},i=e=>e.getAttribute(`aria-expanded`)===`true`,a=(e,t,n)=>{t.forEach(t=>{e.addEventListener(t,n)})},o=e=>{document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e()})},s=(e,n,r)=>()=>t(e).forEach(e=>{e.addEventListener(n,()=>r(e))}),c=()=>{window.addEventListener(`resize`,()=>{t(`[data-toggle="collapse"]`).forEach(e=>{let t=n(e);t&&(e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),t.classList.remove(`block`),t.style.height=`auto`,t.style.overflow=``)})})},l=t=>new Promise(n=>{if(e(t))return n(e(t));let r=new MutationObserver(()=>{e(t)&&(n(e(t)),r.disconnect())});r.observe(document.body,{childList:!0,subtree:!0})}),u=e=>{let t=e.dataset.options;if(!t)return{};try{return JSON.parse(t.replaceAll(`'`,`"`))}catch{return{}}},d=e=>t(`[data-toggle="${e}"]`),f=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),t.classList.remove(`hidden`),window.setTimeout(()=>{t.style.height=`${t.scrollHeight}px`},33),window.setTimeout(()=>{t.style.overflow=`clip`},n)},p=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),window.setTimeout(()=>{t.classList.remove(`block`),t.classList.add(`hidden`)},n)},m=e=>{let{min:n,max:o}={min:0,max:null,...u(e)},s=o===null,c=t(`.accordion-item [aria-expanded]`,e).reduce((e,t)=>{let n=t.closest(`.accordion-item`),r=n?.querySelector(`.accordion-collapse`);return n&&r instanceof HTMLElement&&e.push({trigger:t,target:r}),e},[]),l=()=>c.filter(({trigger:e})=>i(e)).length,d=({trigger:e,target:t})=>{let a=i(e),o=r(t);s===!1&&l()===n&&a||(a||f(e,t,o),s===!1?c.forEach(t=>{!a&&t.trigger===e||p(t.trigger,t.target,o)}):a&&p(e,t,o))};c.forEach(e=>{a(e.trigger,[`click`],()=>d(e))}),n===1&&l()===0&&c.length>0&&c[0].trigger.click()},h=()=>{t(`.accordion-header[data-toggle=accordion]`).forEach(e=>{let t=e.closest(`.accordion`);if(t){t.setAttribute(`data-toggle`,`accordion`),e.hasAttribute(`data-parent`)&&!t.hasAttribute(`data-options`)&&t.setAttribute(`data-options`,`{'min': 1, 'max': 1}`);return}e.removeAttribute(`data-toggle`)}),d(`accordion`).forEach(m)},g=s(`[data-dismiss]`,`click`,e=>{let t=n(e);t||=e.closest(`.${e.getAttribute(`data-dismiss`)}`),t&&(t.classList.add(`opacity-0`),setTimeout(()=>t.remove(),r(t)))}),_=s(`[data-toggle="collapse"]`,`click`,e=>{let t=n(e);if(!t)return;let a=r(t);if(t.style.overflow=`hidden`,t.style.height=`0px`,i(e)){e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),setTimeout(()=>t.classList.remove(`block`),a);return}e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),setTimeout(()=>{t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.add(`hidden`));let e=t.scrollHeight;t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.remove(`hidden`)),t.style.height=`${e}px`},32),setTimeout(()=>t.style.overflow=``,a)}),v=e=>{let{computePosition:t,shift:n,offset:r}=window.FloatingUIDOM,i=e.nextElementSibling,s=e.parentElement;if(!i||!s||!(i instanceof HTMLElement)||!(s instanceof HTMLElement))return;let c=u(e),l=[r(6),n({padding:5})];function d(){t(e,i,{placement:c.placement||`bottom`,middleware:l}).then(({x:e,y:t})=>{Object.assign(i.style,{left:`${e}px`,top:`${t}px`})})}let f=()=>{i.style.display=`block`,e.setAttribute(`aria-expanded`,`true`),window.requestAnimationFrame(()=>{i.classList.add(`opacity-100`,`visible`)}),d()},p=()=>{i.style.display=``,e.setAttribute(`aria-expanded`,`false`),i.classList.remove(`opacity-100`,`visible`)};s.addEventListener(`focusout`,e=>{let t=!e.relatedTarget,n=e.relatedTarget&&!s.contains(e.relatedTarget);(t||n)&&document.hasFocus()&&p()}),a(e,[`click`],()=>{if(i.style.display===`block`){p();return}f()}),o(p)},y=()=>d(`dropdown`).forEach(v),b={closeButton:`fixed right-0 top-0 z-50 text-white px-5 close`},x=async e=>{let{size:t,beforeShown:n,id:r,imgSrc:i,iframeSrc:a}={id:`v-modal`,size:void 0,beforeShown:void 0,imgSrc:void 0,iframeSrc:void 0,...u(e)},s=e.dataset.html||``;i&&(s=`<img src="${i}">`),a&&(s=`<iframe allow="autoplay" class="aspect-video w-full" src="${a}" allowfullscreen="" autoplay=""></iframe>`);let c=`<div class="modal" id="${r}">
|
|
2
|
+
<div class="modal-content ${t?`modal-${t}`:``}">
|
|
3
|
+
${s}
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<button class="${b.closeButton}" onclick="removeModal('${r}')" type="button" data-dismiss="modal" aria-label="Close">
|
|
7
|
+
<span class="text-4xl" aria-hidden="true">×</span>
|
|
8
|
+
</button>
|
|
9
|
+
|
|
10
|
+
<div class="modal-bg" onclick="removeModal('${r}')"></div>
|
|
11
|
+
</div>
|
|
12
|
+
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),await l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},S=(e=`v-modal`)=>{let t=document.getElementById(e);t&&(t.classList.remove(`opacity-100`),window.setTimeout(()=>{t.remove(),document.body.style.overflow=``},500))};window.removeModal=S;const C=s(`[data-toggle="modal"]`,`click`,x),w=s(`[role="tab"]`,`click`,t=>{if(t.getAttribute(`aria-selected`)===`true`)return null;let n=e(`[aria-labelledby="${t.getAttribute(`aria-controls`)}"]`);if(!n)return null;let r=t.classList.value,i=t.parentNode;for(;i&&(!(i instanceof HTMLElement)||i.getAttribute(`role`)!==`tablist`);)i=i.parentNode;if(!(i instanceof HTMLElement))return null;let a=i.querySelectorAll(`[aria-selected="true"]`);if(!a||a.length===0)return null;let o=a[0].classList.value;if(i.querySelectorAll(`[role="tab"]`).forEach(e=>{e.classList=r,e.setAttribute(`aria-selected`,`false`)}),t.classList=o,t.setAttribute(`aria-selected`,`true`),n.getAttribute(`role`)===`tabcontent`){Array.from(n.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.remove(`hidden`)});return}if(!n.parentNode)return null;Array.from(n.parentNode.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.add(`hidden`)}),n.classList.remove(`hidden`)});(function(){window.vInitialized=!1,window.initializeVUI=()=>{window.vInitialized||(window.vInitialized=!0,h(),_(),g(),y(),C(),w(),c())},document.addEventListener(`DOMContentLoaded`,window.initializeVUI),document.readyState!==`loading`&&window.initializeVUI()})();
|
package/dist/versoly-ui.iife.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(){let e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?
|
|
1
|
+
(function(){let e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?parseFloat(t.replace(`s`,``))*1e3+1:0},i=e=>e.getAttribute(`aria-expanded`)===`true`,a=(e,t,n)=>{t.forEach(t=>{e.addEventListener(t,n)})},o=e=>{document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e()})},s=(e,n,r)=>()=>t(e).forEach(e=>{e.addEventListener(n,()=>r(e))}),c=()=>{window.addEventListener(`resize`,()=>{t(`[data-toggle="collapse"]`).forEach(e=>{let t=n(e);t&&(e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),t.classList.remove(`block`),t.style.height=`auto`,t.style.overflow=``)})})},l=t=>new Promise(n=>{if(e(t))return n(e(t));let r=new MutationObserver(()=>{e(t)&&(n(e(t)),r.disconnect())});r.observe(document.body,{childList:!0,subtree:!0})}),u=e=>{let t=e.dataset.options;if(!t)return{};try{return JSON.parse(t.replaceAll(`'`,`"`))}catch{return{}}},d=e=>t(`[data-toggle="${e}"]`),f=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),t.classList.remove(`hidden`),window.setTimeout(()=>{t.style.height=`${t.scrollHeight}px`},33),window.setTimeout(()=>{t.style.overflow=`clip`},n)},p=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),window.setTimeout(()=>{t.classList.remove(`block`),t.classList.add(`hidden`)},n)},m=e=>{let{min:n,max:o}={min:0,max:null,...u(e)},s=o===null,c=t(`.accordion-item [aria-expanded]`,e).reduce((e,t)=>{let n=t.closest(`.accordion-item`),r=n?.querySelector(`.accordion-collapse`);return n&&r instanceof HTMLElement&&e.push({trigger:t,target:r}),e},[]),l=()=>c.filter(({trigger:e})=>i(e)).length,d=({trigger:e,target:t})=>{let a=i(e),o=r(t);s===!1&&l()===n&&a||(a||f(e,t,o),s===!1?c.forEach(t=>{!a&&t.trigger===e||p(t.trigger,t.target,o)}):a&&p(e,t,o))};c.forEach(e=>{a(e.trigger,[`click`],()=>d(e))}),n===1&&l()===0&&c.length>0&&c[0].trigger.click()},h=()=>{t(`.accordion-header[data-toggle=accordion]`).forEach(e=>{let t=e.closest(`.accordion`);if(t){t.setAttribute(`data-toggle`,`accordion`),e.hasAttribute(`data-parent`)&&!t.hasAttribute(`data-options`)&&t.setAttribute(`data-options`,`{'min': 1, 'max': 1}`);return}e.removeAttribute(`data-toggle`)}),d(`accordion`).forEach(m)},g=s(`[data-dismiss]`,`click`,e=>{let t=n(e);t||=e.closest(`.${e.getAttribute(`data-dismiss`)}`),t&&(t.classList.add(`opacity-0`),setTimeout(()=>t.remove(),r(t)))}),_=s(`[data-toggle="collapse"]`,`click`,e=>{let t=n(e);if(!t)return;let a=r(t);if(t.style.overflow=`hidden`,t.style.height=`0px`,i(e)){e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),setTimeout(()=>t.classList.remove(`block`),a);return}e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),setTimeout(()=>{t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.add(`hidden`));let e=t.scrollHeight;t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.remove(`hidden`)),t.style.height=`${e}px`},32),setTimeout(()=>t.style.overflow=``,a)}),v=e=>{let{computePosition:t,shift:n,offset:r}=window.FloatingUIDOM,i=e.nextElementSibling,s=e.parentElement;if(!i||!s||!(i instanceof HTMLElement)||!(s instanceof HTMLElement))return;let c=u(e),l=[r(6),n({padding:5})];function d(){t(e,i,{placement:c.placement||`bottom`,middleware:l}).then(({x:e,y:t})=>{Object.assign(i.style,{left:`${e}px`,top:`${t}px`})})}let f=()=>{i.style.display=`block`,e.setAttribute(`aria-expanded`,`true`),window.requestAnimationFrame(()=>{i.classList.add(`opacity-100`,`visible`)}),d()},p=()=>{i.style.display=``,e.setAttribute(`aria-expanded`,`false`),i.classList.remove(`opacity-100`,`visible`)};s.addEventListener(`focusout`,e=>{let t=!e.relatedTarget,n=e.relatedTarget&&!s.contains(e.relatedTarget);(t||n)&&document.hasFocus()&&p()}),a(e,[`click`],()=>{if(i.style.display===`block`){p();return}f()}),o(p)},y=()=>d(`dropdown`).forEach(v),b={closeButton:`fixed right-0 top-0 z-50 text-white px-5 close`},x=async e=>{let{size:t,beforeShown:n,id:r,imgSrc:i,iframeSrc:a}={id:`v-modal`,size:void 0,beforeShown:void 0,imgSrc:void 0,iframeSrc:void 0,...u(e)},s=e.dataset.html||``;i&&(s=`<img src="${i}">`),a&&(s=`<iframe allow="autoplay" class="aspect-video w-full" src="${a}" allowfullscreen="" autoplay=""></iframe>`);let c=`<div class="modal" id="${r}">
|
|
2
2
|
<div class="modal-content ${t?`modal-${t}`:``}">
|
|
3
3
|
${s}
|
|
4
4
|
</div>
|
|
5
|
-
|
|
6
|
-
<button onclick="removeModal('${r}')" type="button"
|
|
5
|
+
|
|
6
|
+
<button class="${b.closeButton}" onclick="removeModal('${r}')" type="button" data-dismiss="modal" aria-label="Close">
|
|
7
7
|
<span class="text-4xl" aria-hidden="true">×</span>
|
|
8
8
|
</button>
|
|
9
9
|
|
|
10
10
|
<div class="modal-bg" onclick="removeModal('${r}')"></div>
|
|
11
11
|
</div>
|
|
12
|
-
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},
|
|
12
|
+
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),await l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},S=(e=`v-modal`)=>{let t=document.getElementById(e);t&&(t.classList.remove(`opacity-100`),window.setTimeout(()=>{t.remove(),document.body.style.overflow=``},500))};window.removeModal=S;let C=s(`[data-toggle="modal"]`,`click`,x),w=s(`[role="tab"]`,`click`,t=>{if(t.getAttribute(`aria-selected`)===`true`)return null;let n=e(`[aria-labelledby="${t.getAttribute(`aria-controls`)}"]`);if(!n)return null;let r=t.classList.value,i=t.parentNode;for(;i&&(!(i instanceof HTMLElement)||i.getAttribute(`role`)!==`tablist`);)i=i.parentNode;if(!(i instanceof HTMLElement))return null;let a=i.querySelectorAll(`[aria-selected="true"]`);if(!a||a.length===0)return null;let o=a[0].classList.value;if(i.querySelectorAll(`[role="tab"]`).forEach(e=>{e.classList=r,e.setAttribute(`aria-selected`,`false`)}),t.classList=o,t.setAttribute(`aria-selected`,`true`),n.getAttribute(`role`)===`tabcontent`){Array.from(n.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.remove(`hidden`)});return}if(!n.parentNode)return null;Array.from(n.parentNode.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.add(`hidden`)}),n.classList.remove(`hidden`)});(function(){window.vInitialized=!1,window.initializeVUI=()=>{window.vInitialized||(window.vInitialized=!0,h(),_(),g(),y(),C(),w(),c())},document.addEventListener(`DOMContentLoaded`,window.initializeVUI),document.readyState!==`loading`&&window.initializeVUI()})()})();
|
package/dist/versoly-ui.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?
|
|
1
|
+
const e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?parseFloat(t.replace(`s`,``))*1e3+1:0},i=e=>e.getAttribute(`aria-expanded`)===`true`,a=(e,t,n)=>{t.forEach(t=>{e.addEventListener(t,n)})},o=e=>{document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e()})},s=(e,n,r)=>()=>t(e).forEach(e=>{e.addEventListener(n,()=>r(e))}),c=()=>{window.addEventListener(`resize`,()=>{t(`[data-toggle="collapse"]`).forEach(e=>{let t=n(e);t&&(e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),t.classList.remove(`block`),t.style.height=`auto`,t.style.overflow=``)})})},l=t=>new Promise(n=>{if(e(t))return n(e(t));let r=new MutationObserver(()=>{e(t)&&(n(e(t)),r.disconnect())});r.observe(document.body,{childList:!0,subtree:!0})}),u=e=>{let t=e.dataset.options;if(!t)return{};try{return JSON.parse(t.replaceAll(`'`,`"`))}catch{return{}}},d=e=>t(`[data-toggle="${e}"]`),f=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),t.classList.remove(`hidden`),window.setTimeout(()=>{t.style.height=`${t.scrollHeight}px`},33),window.setTimeout(()=>{t.style.overflow=`clip`},n)},p=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),window.setTimeout(()=>{t.classList.remove(`block`),t.classList.add(`hidden`)},n)},m=e=>{let{min:n,max:o}={min:0,max:null,...u(e)},s=o===null,c=t(`.accordion-item [aria-expanded]`,e).reduce((e,t)=>{let n=t.closest(`.accordion-item`),r=n?.querySelector(`.accordion-collapse`);return n&&r instanceof HTMLElement&&e.push({trigger:t,target:r}),e},[]),l=()=>c.filter(({trigger:e})=>i(e)).length,d=({trigger:e,target:t})=>{let a=i(e),o=r(t);s===!1&&l()===n&&a||(a||f(e,t,o),s===!1?c.forEach(t=>{!a&&t.trigger===e||p(t.trigger,t.target,o)}):a&&p(e,t,o))};c.forEach(e=>{a(e.trigger,[`click`],()=>d(e))}),n===1&&l()===0&&c.length>0&&c[0].trigger.click()},h=()=>{t(`.accordion-header[data-toggle=accordion]`).forEach(e=>{let t=e.closest(`.accordion`);if(t){t.setAttribute(`data-toggle`,`accordion`),e.hasAttribute(`data-parent`)&&!t.hasAttribute(`data-options`)&&t.setAttribute(`data-options`,`{'min': 1, 'max': 1}`);return}e.removeAttribute(`data-toggle`)}),d(`accordion`).forEach(m)},g=s(`[data-dismiss]`,`click`,e=>{let t=n(e);t||=e.closest(`.${e.getAttribute(`data-dismiss`)}`),t&&(t.classList.add(`opacity-0`),setTimeout(()=>t.remove(),r(t)))}),_=s(`[data-toggle="collapse"]`,`click`,e=>{let t=n(e);if(!t)return;let a=r(t);if(t.style.overflow=`hidden`,t.style.height=`0px`,i(e)){e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),setTimeout(()=>t.classList.remove(`block`),a);return}e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),setTimeout(()=>{t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.add(`hidden`));let e=t.scrollHeight;t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.remove(`hidden`)),t.style.height=`${e}px`},32),setTimeout(()=>t.style.overflow=``,a)}),v=e=>{let{computePosition:t,shift:n,offset:r}=window.FloatingUIDOM,i=e.nextElementSibling,s=e.parentElement;if(!i||!s||!(i instanceof HTMLElement)||!(s instanceof HTMLElement))return;let c=u(e),l=[r(6),n({padding:5})];function d(){t(e,i,{placement:c.placement||`bottom`,middleware:l}).then(({x:e,y:t})=>{Object.assign(i.style,{left:`${e}px`,top:`${t}px`})})}let f=()=>{i.style.display=`block`,e.setAttribute(`aria-expanded`,`true`),window.requestAnimationFrame(()=>{i.classList.add(`opacity-100`,`visible`)}),d()},p=()=>{i.style.display=``,e.setAttribute(`aria-expanded`,`false`),i.classList.remove(`opacity-100`,`visible`)};s.addEventListener(`focusout`,e=>{let t=!e.relatedTarget,n=e.relatedTarget&&!s.contains(e.relatedTarget);(t||n)&&document.hasFocus()&&p()}),a(e,[`click`],()=>{if(i.style.display===`block`){p();return}f()}),o(p)},y=()=>d(`dropdown`).forEach(v),b={closeButton:`fixed right-0 top-0 z-50 text-white px-5 close`},x=async e=>{let{size:t,beforeShown:n,id:r,imgSrc:i,iframeSrc:a}={id:`v-modal`,size:void 0,beforeShown:void 0,imgSrc:void 0,iframeSrc:void 0,...u(e)},s=e.dataset.html||``;i&&(s=`<img src="${i}">`),a&&(s=`<iframe allow="autoplay" class="aspect-video w-full" src="${a}" allowfullscreen="" autoplay=""></iframe>`);let c=`<div class="modal" id="${r}">
|
|
2
2
|
<div class="modal-content ${t?`modal-${t}`:``}">
|
|
3
3
|
${s}
|
|
4
4
|
</div>
|
|
5
|
-
|
|
6
|
-
<button onclick="removeModal('${r}')" type="button"
|
|
5
|
+
|
|
6
|
+
<button class="${b.closeButton}" onclick="removeModal('${r}')" type="button" data-dismiss="modal" aria-label="Close">
|
|
7
7
|
<span class="text-4xl" aria-hidden="true">×</span>
|
|
8
8
|
</button>
|
|
9
9
|
|
|
10
10
|
<div class="modal-bg" onclick="removeModal('${r}')"></div>
|
|
11
11
|
</div>
|
|
12
|
-
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},S=(e=`v-modal`)=>{let t=document.getElementById(e);t&&(t.classList.remove(`opacity-100`),window.setTimeout(()=>{t.remove(),document.body.style.overflow=``},500))};window.removeModal=S;const C=s(`[data-toggle="modal"]`,`click`,x),w=s(`[role="tab"]`,`click`,t=>{if(t.getAttribute(`aria-selected`)===`true`)return null;let n=e(`[aria-labelledby="${t.getAttribute(`aria-controls`)}"]`);if(!n)return null;let r=t.classList.value,i=t.parentNode;for(;i&&(!(i instanceof HTMLElement)||i.getAttribute(`role`)!==`tablist`);)i=i.parentNode;if(!(i instanceof HTMLElement))return null;let a=i.querySelectorAll(`[aria-selected="true"]`);if(!a||a.length===0)return null;let o=a[0].classList.value;if(i.querySelectorAll(`[role="tab"]`).forEach(e=>{e.classList=r,e.setAttribute(`aria-selected`,`false`)}),t.classList=o,t.setAttribute(`aria-selected`,`true`),n.getAttribute(`role`)===`tabcontent`){Array.from(n.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.remove(`hidden`)});return}if(!n.parentNode)return null;Array.from(n.parentNode.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.add(`hidden`)}),n.classList.remove(`hidden`)});(function(){window.vInitialized=!1,window.initializeVUI=()=>{window.vInitialized||(window.vInitialized=!0,h(),_(),g(),y(),C(),w(),c())},document.addEventListener(`DOMContentLoaded`,window.initializeVUI),document.readyState!==`loading`&&window.initializeVUI()})();
|
|
12
|
+
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),await l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},S=(e=`v-modal`)=>{let t=document.getElementById(e);t&&(t.classList.remove(`opacity-100`),window.setTimeout(()=>{t.remove(),document.body.style.overflow=``},500))};window.removeModal=S;const C=s(`[data-toggle="modal"]`,`click`,x),w=s(`[role="tab"]`,`click`,t=>{if(t.getAttribute(`aria-selected`)===`true`)return null;let n=e(`[aria-labelledby="${t.getAttribute(`aria-controls`)}"]`);if(!n)return null;let r=t.classList.value,i=t.parentNode;for(;i&&(!(i instanceof HTMLElement)||i.getAttribute(`role`)!==`tablist`);)i=i.parentNode;if(!(i instanceof HTMLElement))return null;let a=i.querySelectorAll(`[aria-selected="true"]`);if(!a||a.length===0)return null;let o=a[0].classList.value;if(i.querySelectorAll(`[role="tab"]`).forEach(e=>{e.classList=r,e.setAttribute(`aria-selected`,`false`)}),t.classList=o,t.setAttribute(`aria-selected`,`true`),n.getAttribute(`role`)===`tabcontent`){Array.from(n.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.remove(`hidden`)});return}if(!n.parentNode)return null;Array.from(n.parentNode.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.add(`hidden`)}),n.classList.remove(`hidden`)});(function(){window.vInitialized=!1,window.initializeVUI=()=>{window.vInitialized||(window.vInitialized=!0,h(),_(),g(),y(),C(),w(),c())},document.addEventListener(`DOMContentLoaded`,window.initializeVUI),document.readyState!==`loading`&&window.initializeVUI()})();
|
package/index.html
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Versoly UI</title>
|
|
7
|
-
<script src="https://cdn.tailwindcss
|
|
8
|
-
<style></style>
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
8
|
+
<style type="text/tailwindcss"></style>
|
|
9
9
|
</head>
|
|
10
10
|
|
|
11
11
|
<body>
|
|
12
|
-
<script src="https://
|
|
13
|
-
<script src="
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/npm/@floating-ui/core@1.7.4"></script>
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.7.4"></script>
|
|
14
|
+
<script src="./dist/versoly-ui.iife.js"></script>
|
|
14
15
|
</body>
|
|
15
16
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versoly-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Versoly UI - Tailwind CSS framework based on Bootstrap",
|
|
5
5
|
"author": "Versoly",
|
|
6
6
|
"keywords": [
|
|
@@ -14,12 +14,16 @@
|
|
|
14
14
|
"dropdown Floating UI"
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"main": "./dist/versoly-ui.
|
|
17
|
+
"main": "./dist/versoly-ui.cjs",
|
|
18
18
|
"unpkg": "dist/versoly-ui.iife.js",
|
|
19
19
|
"jsdelivr": "dist/versoly-ui.iife.js",
|
|
20
20
|
"module": "./dist/versoly-ui.mjs",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"exports": {
|
|
22
|
-
".":
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/versoly-ui.mjs",
|
|
25
|
+
"require": "./dist/versoly-ui.cjs"
|
|
26
|
+
},
|
|
23
27
|
"./package.json": "./package.json"
|
|
24
28
|
},
|
|
25
29
|
"repository": {
|
|
@@ -36,16 +40,22 @@
|
|
|
36
40
|
"scripts": {
|
|
37
41
|
"dev": "vite",
|
|
38
42
|
"build": "tsdown",
|
|
39
|
-
"build:watch": "tsdown --watch"
|
|
43
|
+
"build:watch": "tsdown --watch",
|
|
44
|
+
"fmt": "oxfmt",
|
|
45
|
+
"fmt:check": "oxfmt --check",
|
|
46
|
+
"lint": "oxlint",
|
|
47
|
+
"lint:fix": "oxlint --fix",
|
|
48
|
+
"prepack": "pnpm run build"
|
|
40
49
|
},
|
|
41
50
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"prettier": "^3.6.2",
|
|
46
|
-
"tsdown": "^0.15.1",
|
|
51
|
+
"oxfmt": "^0.32.0",
|
|
52
|
+
"oxlint": "^1.47.0",
|
|
53
|
+
"tsdown": "^0.20.3",
|
|
47
54
|
"type-fest": "^4.41.0",
|
|
48
55
|
"typescript": "^5.9.2",
|
|
49
|
-
"vite": "
|
|
56
|
+
"vite": "v8.0.0-beta.13"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
50
60
|
}
|
|
51
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accordion, collapse, dismiss, dropdown, modal, tabs, handleResize } from
|
|
1
|
+
import { accordion, collapse, dismiss, dropdown, modal, tabs, handleResize } from "./plugins/index";
|
|
2
2
|
|
|
3
3
|
(function () {
|
|
4
4
|
window.vInitialized = false;
|
|
@@ -18,8 +18,8 @@ import { accordion, collapse, dismiss, dropdown, modal, tabs, handleResize } fro
|
|
|
18
18
|
handleResize();
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
document.addEventListener(
|
|
22
|
-
if (document.readyState !==
|
|
21
|
+
document.addEventListener("DOMContentLoaded", window.initializeVUI);
|
|
22
|
+
if (document.readyState !== "loading") {
|
|
23
23
|
window.initializeVUI();
|
|
24
24
|
}
|
|
25
25
|
})();
|
package/src/plugins/accordion.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAccordionOptions } from
|
|
1
|
+
import type { IAccordionOptions } from "../types";
|
|
2
2
|
import {
|
|
3
3
|
addEventListeners,
|
|
4
4
|
getDuration,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getElementsByToggle,
|
|
7
7
|
getIsAriaExpanded,
|
|
8
8
|
parseElementOptions,
|
|
9
|
-
} from
|
|
9
|
+
} from "../utils/index";
|
|
10
10
|
|
|
11
11
|
interface IAccordionItem {
|
|
12
12
|
trigger: HTMLElement;
|
|
@@ -14,33 +14,33 @@ interface IAccordionItem {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const handleOpen = (trigger: HTMLElement, target: HTMLElement, duration: number) => {
|
|
17
|
-
target.style.overflow =
|
|
18
|
-
target.style.height =
|
|
17
|
+
target.style.overflow = "hidden";
|
|
18
|
+
target.style.height = "0";
|
|
19
19
|
|
|
20
|
-
trigger.setAttribute(
|
|
21
|
-
target.classList.add(
|
|
22
|
-
target.classList.add(
|
|
23
|
-
target.classList.remove(
|
|
20
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
21
|
+
target.classList.add("block");
|
|
22
|
+
target.classList.add("show");
|
|
23
|
+
target.classList.remove("hidden");
|
|
24
24
|
|
|
25
25
|
window.setTimeout(() => {
|
|
26
26
|
target.style.height = `${target.scrollHeight}px`;
|
|
27
27
|
}, 33);
|
|
28
28
|
|
|
29
29
|
window.setTimeout(() => {
|
|
30
|
-
target.style.overflow =
|
|
30
|
+
target.style.overflow = "clip";
|
|
31
31
|
}, duration);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const handleClose = (trigger: HTMLElement, target: HTMLElement, duration: number) => {
|
|
35
|
-
target.style.overflow =
|
|
36
|
-
target.style.height =
|
|
35
|
+
target.style.overflow = "hidden";
|
|
36
|
+
target.style.height = "0";
|
|
37
37
|
|
|
38
|
-
trigger.setAttribute(
|
|
39
|
-
target.classList.remove(
|
|
38
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
39
|
+
target.classList.remove("show");
|
|
40
40
|
|
|
41
41
|
window.setTimeout(() => {
|
|
42
|
-
target.classList.remove(
|
|
43
|
-
target.classList.add(
|
|
42
|
+
target.classList.remove("block");
|
|
43
|
+
target.classList.add("hidden");
|
|
44
44
|
}, duration);
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -54,10 +54,10 @@ const Accordion = (element: HTMLElement) => {
|
|
|
54
54
|
|
|
55
55
|
const canOpenMultiple = max === null;
|
|
56
56
|
|
|
57
|
-
const items: IAccordionItem[] = getElementsBySelectors(
|
|
57
|
+
const items: IAccordionItem[] = getElementsBySelectors(".accordion-item [aria-expanded]", element).reduce(
|
|
58
58
|
(acc: IAccordionItem[], trigger) => {
|
|
59
|
-
const item = trigger.closest(
|
|
60
|
-
const target = item?.querySelector(
|
|
59
|
+
const item = trigger.closest(".accordion-item");
|
|
60
|
+
const target = item?.querySelector(".accordion-collapse");
|
|
61
61
|
if (item && target instanceof HTMLElement) {
|
|
62
62
|
acc.push({ trigger, target });
|
|
63
63
|
}
|
|
@@ -93,7 +93,7 @@ const Accordion = (element: HTMLElement) => {
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
items.forEach((item) => {
|
|
96
|
-
addEventListeners(item.trigger, [
|
|
96
|
+
addEventListeners(item.trigger, ["click"], () => toggle(item));
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
if (min === 1 && getOpenCount() === 0 && items.length > 0) {
|
|
@@ -103,19 +103,19 @@ const Accordion = (element: HTMLElement) => {
|
|
|
103
103
|
|
|
104
104
|
export const accordion = () => {
|
|
105
105
|
// legacy support for accordion via data attributes on headers
|
|
106
|
-
getElementsBySelectors(
|
|
107
|
-
const parentAccordion = element.closest(
|
|
106
|
+
getElementsBySelectors(".accordion-header[data-toggle=accordion]").forEach((element) => {
|
|
107
|
+
const parentAccordion = element.closest(".accordion");
|
|
108
108
|
if (parentAccordion) {
|
|
109
|
-
parentAccordion.setAttribute(
|
|
109
|
+
parentAccordion.setAttribute("data-toggle", "accordion");
|
|
110
110
|
|
|
111
|
-
if (element.hasAttribute(
|
|
112
|
-
parentAccordion.setAttribute(
|
|
111
|
+
if (element.hasAttribute("data-parent") && !parentAccordion.hasAttribute("data-options")) {
|
|
112
|
+
parentAccordion.setAttribute("data-options", "{'min': 1, 'max': 1}");
|
|
113
113
|
}
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
element.removeAttribute(
|
|
117
|
+
element.removeAttribute("data-toggle");
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
getElementsByToggle(
|
|
120
|
+
getElementsByToggle("accordion").forEach(Accordion);
|
|
121
121
|
};
|
package/src/plugins/collapse.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDuration, getTarget, addEventListenerToSelector } from
|
|
1
|
+
import { getDuration, getTarget, addEventListenerToSelector, getIsAriaExpanded } from "../utils/index";
|
|
2
2
|
|
|
3
3
|
const Collapse = (element: HTMLElement) => {
|
|
4
4
|
const target = getTarget(element);
|
|
@@ -7,29 +7,29 @@ const Collapse = (element: HTMLElement) => {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const duration = getDuration(target);
|
|
10
|
-
target.style.overflow =
|
|
11
|
-
target.style.height =
|
|
10
|
+
target.style.overflow = "hidden";
|
|
11
|
+
target.style.height = "0px";
|
|
12
12
|
|
|
13
|
-
if (element
|
|
14
|
-
element.setAttribute(
|
|
15
|
-
target.classList.remove(
|
|
13
|
+
if (getIsAriaExpanded(element)) {
|
|
14
|
+
element.setAttribute("aria-expanded", "false");
|
|
15
|
+
target.classList.remove("show");
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
setTimeout(() => target.classList.remove("block"), duration);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
element.setAttribute(
|
|
22
|
-
target.classList.add(
|
|
23
|
-
target.classList.add(
|
|
21
|
+
element.setAttribute("aria-expanded", "true");
|
|
22
|
+
target.classList.add("block");
|
|
23
|
+
target.classList.add("show");
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
target.querySelectorAll(
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
target.querySelectorAll(".dropdown-menu").forEach((m) => m.classList.add("hidden"));
|
|
27
27
|
const navHeight = target.scrollHeight;
|
|
28
|
-
target.querySelectorAll(
|
|
28
|
+
target.querySelectorAll(".dropdown-menu").forEach((m) => m.classList.remove("hidden"));
|
|
29
29
|
target.style.height = `${navHeight}px`;
|
|
30
30
|
}, 32);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
setTimeout(() => (target.style.overflow = ""), duration);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export const collapse = addEventListenerToSelector('[data-toggle="collapse"]',
|
|
35
|
+
export const collapse = addEventListenerToSelector('[data-toggle="collapse"]', "click", Collapse);
|
package/src/plugins/dismiss.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { getDuration, getTarget, addEventListenerToSelector } from
|
|
1
|
+
import { getDuration, getTarget, addEventListenerToSelector } from "../utils/index";
|
|
2
2
|
|
|
3
3
|
const Dismiss = (element: HTMLElement) => {
|
|
4
4
|
let target = getTarget(element);
|
|
5
5
|
if (!target) {
|
|
6
|
-
target = element.closest(`.${element.getAttribute(
|
|
6
|
+
target = element.closest(`.${element.getAttribute("data-dismiss")}`);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
if (!target) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
target.classList.add(
|
|
13
|
+
target.classList.add("opacity-0");
|
|
14
14
|
setTimeout(() => target.remove(), getDuration(target));
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const dismiss = addEventListenerToSelector(
|
|
17
|
+
export const dismiss = addEventListenerToSelector("[data-dismiss]", "click", Dismiss);
|
package/src/plugins/dropdown.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addEventListeners, addEscapeListener, getElementsByToggle, parseElementOptions } from
|
|
1
|
+
import { addEventListeners, addEscapeListener, getElementsByToggle, parseElementOptions } from "../utils/index";
|
|
2
2
|
|
|
3
3
|
const Dropdown = (trigger: HTMLElement) => {
|
|
4
4
|
const { computePosition, shift, offset } = window.FloatingUIDOM;
|
|
@@ -20,7 +20,7 @@ const Dropdown = (trigger: HTMLElement) => {
|
|
|
20
20
|
|
|
21
21
|
function update() {
|
|
22
22
|
computePosition(trigger, target, {
|
|
23
|
-
placement: options.placement ||
|
|
23
|
+
placement: options.placement || "bottom",
|
|
24
24
|
middleware,
|
|
25
25
|
}).then(({ x, y }: { x: number; y: number }) => {
|
|
26
26
|
Object.assign(target.style, {
|
|
@@ -31,37 +31,47 @@ const Dropdown = (trigger: HTMLElement) => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const show = () => {
|
|
34
|
-
target.style.display =
|
|
34
|
+
target.style.display = "block";
|
|
35
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
36
|
+
|
|
35
37
|
window.requestAnimationFrame(() => {
|
|
36
|
-
target.classList.add(
|
|
38
|
+
target.classList.add("opacity-100", "visible");
|
|
37
39
|
});
|
|
38
40
|
update();
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
const hide = () => {
|
|
42
|
-
target.style.display =
|
|
43
|
-
|
|
44
|
+
target.style.display = "";
|
|
45
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
46
|
+
target.classList.remove("opacity-100", "visible");
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
const toggle = () => {
|
|
47
|
-
if (target.style.display ===
|
|
50
|
+
if (target.style.display === "block") {
|
|
48
51
|
hide();
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
54
|
show();
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
parent.addEventListener(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
parent.addEventListener("focusout", (event) => {
|
|
58
|
+
// If relatedTarget is null, the user clicked a non-focusable area (background)
|
|
59
|
+
// or left the document entirely. Both should usually trigger a close.
|
|
60
|
+
const isClickOutside = !event.relatedTarget;
|
|
61
|
+
|
|
62
|
+
// Check if focus moved to something outside the parent
|
|
63
|
+
const isFocusMovingOutside = event.relatedTarget && !parent.contains(event.relatedTarget as Node);
|
|
64
|
+
|
|
65
|
+
if (isClickOutside || isFocusMovingOutside) {
|
|
66
|
+
// Optional: Only hide if the document still has focus to avoid
|
|
67
|
+
// closing when the user just switched browser tabs
|
|
68
|
+
if (document.hasFocus()) {
|
|
69
|
+
hide();
|
|
70
|
+
}
|
|
60
71
|
}
|
|
61
|
-
hide();
|
|
62
72
|
});
|
|
63
|
-
addEventListeners(trigger, [
|
|
73
|
+
addEventListeners(trigger, ["click"], toggle);
|
|
64
74
|
addEscapeListener(hide);
|
|
65
75
|
};
|
|
66
76
|
|
|
67
|
-
export const dropdown = () => getElementsByToggle(
|
|
77
|
+
export const dropdown = () => getElementsByToggle("dropdown").forEach(Dropdown);
|
package/src/plugins/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { accordion } from
|
|
2
|
-
export { dismiss } from
|
|
3
|
-
export { collapse } from
|
|
4
|
-
export { dropdown } from
|
|
5
|
-
export { modal } from
|
|
6
|
-
export { tabs } from
|
|
7
|
-
export { handleResize } from
|
|
1
|
+
export { accordion } from "./accordion";
|
|
2
|
+
export { dismiss } from "./dismiss";
|
|
3
|
+
export { collapse } from "./collapse";
|
|
4
|
+
export { dropdown } from "./dropdown";
|
|
5
|
+
export { modal } from "./modal";
|
|
6
|
+
export { tabs } from "./tabs";
|
|
7
|
+
export { handleResize } from "../utils";
|
package/src/plugins/modal.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IModalOptions } from
|
|
2
|
-
import { waitForElement, parseElementOptions, addEventListenerToSelector, addEscapeListener } from
|
|
1
|
+
import type { IModalOptions } from "../types";
|
|
2
|
+
import { waitForElement, parseElementOptions, addEventListenerToSelector, addEscapeListener } from "../utils";
|
|
3
3
|
|
|
4
4
|
const defaults = {
|
|
5
|
-
closeButton:
|
|
5
|
+
closeButton: "fixed right-0 top-0 z-50 text-white px-5 close",
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// if (element.getAttribute('aria-label')) {
|
|
@@ -10,9 +10,9 @@ const defaults = {
|
|
|
10
10
|
// }
|
|
11
11
|
// element.setAttribute('aria-label', 'modal')
|
|
12
12
|
|
|
13
|
-
const Modal = (element: HTMLElement) => {
|
|
13
|
+
const Modal = async (element: HTMLElement) => {
|
|
14
14
|
const options: IModalOptions = {
|
|
15
|
-
id:
|
|
15
|
+
id: "v-modal",
|
|
16
16
|
size: undefined,
|
|
17
17
|
beforeShown: undefined,
|
|
18
18
|
imgSrc: undefined,
|
|
@@ -22,7 +22,7 @@ const Modal = (element: HTMLElement) => {
|
|
|
22
22
|
|
|
23
23
|
const { size, beforeShown, id, imgSrc, iframeSrc } = options;
|
|
24
24
|
|
|
25
|
-
let content = element.dataset.html ||
|
|
25
|
+
let content = element.dataset.html || "";
|
|
26
26
|
|
|
27
27
|
if (imgSrc) {
|
|
28
28
|
content = `<img src="${imgSrc}">`;
|
|
@@ -32,7 +32,7 @@ const Modal = (element: HTMLElement) => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const modalHTML = `<div class="modal" id="${id}">
|
|
35
|
-
<div class="modal-content ${size ? `modal-${size}` :
|
|
35
|
+
<div class="modal-content ${size ? `modal-${size}` : ""}">
|
|
36
36
|
${content}
|
|
37
37
|
</div>
|
|
38
38
|
|
|
@@ -45,29 +45,32 @@ const Modal = (element: HTMLElement) => {
|
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
47
|
addEscapeListener(() => window.removeModal(id));
|
|
48
|
-
document.body.style.overflow =
|
|
49
|
-
document.body.insertAdjacentHTML(
|
|
48
|
+
document.body.style.overflow = "hidden";
|
|
49
|
+
document.body.insertAdjacentHTML("beforeend", modalHTML);
|
|
50
50
|
|
|
51
|
-
waitForElement(`#${id}`).then((ele) => {
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
await waitForElement(`#${id}`).then((ele) => {
|
|
52
|
+
if (beforeShown) {
|
|
53
|
+
(window as any)[beforeShown]();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
window.setTimeout(() => ele.classList.add("opacity-100"), 32);
|
|
54
57
|
});
|
|
55
58
|
};
|
|
56
59
|
|
|
57
|
-
const removeModal = (id =
|
|
60
|
+
const removeModal = (id = "v-modal") => {
|
|
58
61
|
const modal = document.getElementById(id);
|
|
59
62
|
|
|
60
63
|
if (!modal) {
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
modal.classList.remove(
|
|
67
|
+
modal.classList.remove("opacity-100");
|
|
65
68
|
window.setTimeout(() => {
|
|
66
69
|
modal.remove();
|
|
67
|
-
document.body.style.overflow =
|
|
70
|
+
document.body.style.overflow = "";
|
|
68
71
|
}, 500);
|
|
69
72
|
};
|
|
70
73
|
|
|
71
74
|
window.removeModal = removeModal;
|
|
72
75
|
|
|
73
|
-
export const modal = addEventListenerToSelector('[data-toggle="modal"]',
|
|
76
|
+
export const modal = addEventListenerToSelector('[data-toggle="modal"]', "click", Modal);
|
package/src/plugins/tabs.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { addEventListenerToSelector, getElementBySelector } from
|
|
1
|
+
import { addEventListenerToSelector, getElementBySelector } from "../utils/index";
|
|
2
2
|
|
|
3
3
|
const Tabs = (element: HTMLElement) => {
|
|
4
|
-
if (element.getAttribute(
|
|
4
|
+
if (element.getAttribute("aria-selected") === "true") {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const target = getElementBySelector(`[aria-labelledby="${element.getAttribute(
|
|
8
|
+
const target = getElementBySelector(`[aria-labelledby="${element.getAttribute("aria-controls")}"]`);
|
|
9
9
|
if (!target) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
@@ -13,7 +13,7 @@ const Tabs = (element: HTMLElement) => {
|
|
|
13
13
|
const inactiveClass = element.classList.value;
|
|
14
14
|
|
|
15
15
|
let tablist: ParentNode | null = element.parentNode;
|
|
16
|
-
while (tablist && (!(tablist instanceof HTMLElement) || tablist.getAttribute(
|
|
16
|
+
while (tablist && (!(tablist instanceof HTMLElement) || tablist.getAttribute("role") !== "tablist")) {
|
|
17
17
|
tablist = tablist.parentNode;
|
|
18
18
|
}
|
|
19
19
|
if (!(tablist instanceof HTMLElement)) {
|
|
@@ -28,16 +28,16 @@ const Tabs = (element: HTMLElement) => {
|
|
|
28
28
|
|
|
29
29
|
tablist.querySelectorAll('[role="tab"]').forEach((tab) => {
|
|
30
30
|
tab.classList = inactiveClass;
|
|
31
|
-
tab.setAttribute(
|
|
31
|
+
tab.setAttribute("aria-selected", "false");
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
element.classList = activeClass;
|
|
35
|
-
element.setAttribute(
|
|
35
|
+
element.setAttribute("aria-selected", "true");
|
|
36
36
|
|
|
37
|
-
if (target.getAttribute(
|
|
37
|
+
if (target.getAttribute("role") === "tabcontent") {
|
|
38
38
|
Array.from(target.children).forEach((n) => {
|
|
39
|
-
if (n.getAttribute(
|
|
40
|
-
n.classList.remove(
|
|
39
|
+
if (n.getAttribute("role") === "tabpanel") {
|
|
40
|
+
n.classList.remove("hidden");
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
return;
|
|
@@ -48,12 +48,12 @@ const Tabs = (element: HTMLElement) => {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
Array.from(target.parentNode.children).forEach((n) => {
|
|
51
|
-
if (n.getAttribute(
|
|
52
|
-
n.classList.add(
|
|
51
|
+
if (n.getAttribute("role") === "tabpanel") {
|
|
52
|
+
n.classList.add("hidden");
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
target.classList.remove(
|
|
56
|
+
target.classList.remove("hidden");
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
export const tabs = addEventListenerToSelector('[role="tab"]',
|
|
59
|
+
export const tabs = addEventListenerToSelector('[role="tab"]', "click", Tabs);
|
package/src/types.d.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const getElementBySelector = (selector: string) => document.querySelector(selector) as HTMLElement;
|
|
2
|
+
|
|
2
3
|
export const getElementsBySelectors = (selector: string, element: Document | HTMLElement = document) =>
|
|
3
4
|
Array.from(element.querySelectorAll(selector)) as HTMLElement[];
|
|
4
5
|
|
|
@@ -11,16 +12,16 @@ export const getTarget = (element: HTMLElement) => {
|
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export const getDuration = (element: HTMLElement) => {
|
|
14
|
-
const duration = window.getComputedStyle(element).getPropertyValue(
|
|
15
|
+
const duration = window.getComputedStyle(element).getPropertyValue("transition-duration");
|
|
15
16
|
|
|
16
17
|
if (!duration) {
|
|
17
18
|
return 0;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
return
|
|
21
|
+
return parseFloat(duration.replace("s", "")) * 1000 + 1;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
export const getIsAriaExpanded = (element: HTMLElement) => element.getAttribute(
|
|
24
|
+
export const getIsAriaExpanded = (element: HTMLElement) => element.getAttribute("aria-expanded") === "true";
|
|
24
25
|
|
|
25
26
|
export const addEventListeners = (
|
|
26
27
|
element: HTMLElement,
|
|
@@ -33,8 +34,8 @@ export const addEventListeners = (
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export const addEscapeListener = (callback: () => void) => {
|
|
36
|
-
document.addEventListener(
|
|
37
|
-
if (e.key ===
|
|
37
|
+
document.addEventListener("keydown", (e) => {
|
|
38
|
+
if (e.key === "Escape") {
|
|
38
39
|
callback();
|
|
39
40
|
}
|
|
40
41
|
});
|
|
@@ -51,8 +52,8 @@ export const addEventListenerToSelector = (
|
|
|
51
52
|
});
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
export const handleResize = () =>
|
|
55
|
-
window.addEventListener(
|
|
55
|
+
export const handleResize = () => {
|
|
56
|
+
window.addEventListener("resize", () => {
|
|
56
57
|
getElementsBySelectors('[data-toggle="collapse"]').forEach((element) => {
|
|
57
58
|
const target = getTarget(element);
|
|
58
59
|
|
|
@@ -60,13 +61,14 @@ export const handleResize = () =>
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
element.setAttribute(
|
|
64
|
-
target.classList.remove(
|
|
65
|
-
target.classList.remove(
|
|
66
|
-
target.style.height =
|
|
67
|
-
target.style.overflow =
|
|
64
|
+
element.setAttribute("aria-expanded", "false");
|
|
65
|
+
target.classList.remove("show");
|
|
66
|
+
target.classList.remove("block");
|
|
67
|
+
target.style.height = "auto";
|
|
68
|
+
target.style.overflow = "";
|
|
68
69
|
});
|
|
69
70
|
});
|
|
71
|
+
};
|
|
70
72
|
|
|
71
73
|
export const waitForElement = (s: string): Promise<HTMLElement> => {
|
|
72
74
|
return new Promise((resolve) => {
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"baseUrl": ".",
|
|
3
|
+
"target": "ES2022",
|
|
5
4
|
"module": "ESNext",
|
|
6
|
-
"lib": ["
|
|
5
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
6
|
"moduleResolution": "Bundler",
|
|
8
7
|
"strict": true,
|
|
9
8
|
"esModuleInterop": true,
|
|
10
9
|
"skipLibCheck": true,
|
|
11
10
|
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
|
|
12
|
+
/* Modern Additions */
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"useDefineForClassFields": true,
|
|
16
|
+
"noEmit": true
|
|
12
17
|
},
|
|
13
|
-
"include": ["src"]
|
|
18
|
+
"include": ["src"]
|
|
14
19
|
}
|
package/tsdown.config.ts
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
import pkg from "./package.json" with { type: "json" };
|
|
3
|
+
|
|
4
|
+
const { name } = pkg;
|
|
5
|
+
const getPackageName = () => {
|
|
6
|
+
return (name.includes("@") ? name.split("/")[1] : name).replace(".", "-");
|
|
7
|
+
};
|
|
2
8
|
|
|
3
9
|
const sharedConfig = {
|
|
4
10
|
exports: true,
|
|
5
11
|
minify: true,
|
|
6
12
|
entry: {
|
|
7
|
-
|
|
13
|
+
[getPackageName()]: "./src/index.ts",
|
|
8
14
|
},
|
|
9
|
-
platform:
|
|
15
|
+
platform: "browser",
|
|
10
16
|
} as const;
|
|
11
17
|
|
|
18
|
+
const browserTargets = ["chrome" + "109", "firefox" + "135", "safari" + "17", "edge" + "135"];
|
|
19
|
+
|
|
12
20
|
export default defineConfig([
|
|
13
21
|
{
|
|
14
22
|
...sharedConfig,
|
|
15
|
-
target:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
...sharedConfig,
|
|
20
|
-
format: ['esm'],
|
|
23
|
+
target: browserTargets,
|
|
24
|
+
fixedExtension: true,
|
|
25
|
+
format: ["esm", "cjs", "iife"],
|
|
21
26
|
},
|
|
27
|
+
// {
|
|
28
|
+
// ...sharedConfig,
|
|
29
|
+
// format: ["esm"],
|
|
30
|
+
// },
|
|
22
31
|
]);
|
package/vite.config.ts
ADDED
package/dist/versoly-ui.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const e=e=>document.querySelector(e),t=(e,t=document)=>Array.from(t.querySelectorAll(e)),n=t=>{let n=t.dataset.target;return n?e(n):null},r=e=>{let t=window.getComputedStyle(e).getPropertyValue(`transition-duration`);return t?parseInt(t.replace(`s`,``))*1e3+1:0},i=e=>e.getAttribute(`aria-expanded`)===`true`,a=(e,t,n)=>{t.forEach(t=>{e.addEventListener(t,n)})},o=e=>{document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e()})},s=(e,n,r)=>()=>t(e).forEach(e=>{e.addEventListener(n,()=>r(e))}),c=()=>window.addEventListener(`resize`,()=>{t(`[data-toggle="collapse"]`).forEach(e=>{let t=n(e);t&&(e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),t.classList.remove(`block`),t.style.height=`auto`,t.style.overflow=``)})}),l=t=>new Promise(n=>{if(e(t))return n(e(t));let r=new MutationObserver(()=>{e(t)&&(n(e(t)),r.disconnect())});r.observe(document.body,{childList:!0,subtree:!0})}),u=e=>{let t=e.dataset.options;if(!t)return{};try{return JSON.parse(t.replaceAll(`'`,`"`))}catch(e){return{}}},d=e=>{let n=`[data-toggle="${e}"]`;return t(n)};function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?g(Object(n),!0).forEach(function(t){h(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const v=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),t.classList.remove(`hidden`),window.setTimeout(()=>{t.style.height=`${t.scrollHeight}px`},33),window.setTimeout(()=>{t.style.overflow=``},n)},y=(e,t,n)=>{t.style.overflow=`hidden`,t.style.height=`0`,e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),window.setTimeout(()=>{t.classList.remove(`block`),t.classList.add(`hidden`)},n)},b=e=>{let{min:n,max:o}=_({min:0,max:null},u(e)),s=o===null,c=t(`.accordion-item [aria-expanded]`,e).reduce((e,t)=>{let n=t.closest(`.accordion-item`),r=n==null?void 0:n.querySelector(`.accordion-collapse`);return n&&r instanceof HTMLElement&&e.push({trigger:t,target:r}),e},[]),l=()=>c.filter(({trigger:e})=>i(e)).length,d=({trigger:e,target:t})=>{let a=i(e),o=r(t);s===!1&&l()===n&&a||(a||v(e,t,o),s===!1?c.forEach(t=>{!a&&t.trigger===e||y(t.trigger,t.target,o)}):a&&y(e,t,o))};c.forEach(e=>{a(e.trigger,[`click`],()=>d(e))}),n===1&&l()===0&&c.length>0&&c[0].trigger.click()},x=()=>{t(`.accordion-header[data-toggle=accordion]`).forEach(e=>{console.log(e);let t=e.closest(`.accordion`);if(t){t.setAttribute(`data-toggle`,`accordion`),e.hasAttribute(`data-parent`)&&!t.hasAttribute(`data-options`)&&t.setAttribute(`data-options`,`{'min': 1, 'max': 1}`);return}e.removeAttribute(`data-toggle`)}),d(`accordion`).forEach(b)},S=e=>{let t=n(e);t||(t=e.closest(`.${e.getAttribute(`data-dismiss`)}`)),t&&(t.classList.add(`opacity-0`),setTimeout(()=>t.remove(),r(t)))},C=s(`[data-dismiss]`,`click`,S),w=e=>{let t=n(e);if(!t)return;let i=r(t);if(t.style.overflow=`hidden`,t.style.height=`0px`,e.getAttribute(`aria-expanded`)===`true`){e.setAttribute(`aria-expanded`,`false`),t.classList.remove(`show`),window.setTimeout(()=>t.classList.remove(`block`),i);return}e.setAttribute(`aria-expanded`,`true`),t.classList.add(`block`),t.classList.add(`show`),window.setTimeout(()=>{t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.add(`hidden`));let e=t.scrollHeight;t.querySelectorAll(`.dropdown-menu`).forEach(e=>e.classList.remove(`hidden`)),t.style.height=`${e}px`},32),window.setTimeout(()=>t.style.overflow=``,i)},T=s(`[data-toggle="collapse"]`,`click`,w),E=e=>{let{computePosition:t,shift:n,offset:r}=window.FloatingUIDOM,i=e.nextElementSibling,s=e.parentElement;if(!i||!s||!(i instanceof HTMLElement)||!(s instanceof HTMLElement))return;let c=u(e),l=[r(6),n({padding:5})];function d(){t(e,i,{placement:c.placement||`bottom`,middleware:l}).then(({x:e,y:t})=>{Object.assign(i.style,{left:`${e}px`,top:`${t}px`})})}let f=()=>{i.style.display=`block`,window.requestAnimationFrame(()=>{i.classList.add(`opacity-100`,`visible`)}),d()},p=()=>{i.style.display=``,i.classList.remove(`opacity-100`,`visible`)};s.addEventListener(`focusout`,e=>{e!=null&&e.relatedTarget&&(s.contains(e.relatedTarget)||!document.hasFocus()||p())}),a(e,[`click`],()=>{if(i.style.display===`block`){p();return}f()}),o(p)},D=()=>d(`dropdown`).forEach(E),O={closeButton:`fixed right-0 top-0 z-50 text-white px-5 close`},k=e=>{let{size:t,beforeShown:n,id:r,imgSrc:i,iframeSrc:a}=_({id:`v-modal`,size:void 0,beforeShown:void 0,imgSrc:void 0,iframeSrc:void 0},u(e)),s=e.dataset.html||``;i&&(s=`<img src="${i}">`),a&&(s=`<iframe allow="autoplay" class="aspect-video w-full" src="${a}" allowfullscreen="" autoplay=""></iframe>`);let c=`<div class="modal" id="${r}">
|
|
2
|
-
<div class="modal-content ${t?`modal-${t}`:``}">
|
|
3
|
-
${s}
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
<button onclick="removeModal('${r}')" type="button" class="${O.closeButton}" data-dismiss="modal" aria-label="Close">
|
|
7
|
-
<span class="text-4xl" aria-hidden="true">×</span>
|
|
8
|
-
</button>
|
|
9
|
-
|
|
10
|
-
<div class="modal-bg" onclick="removeModal('${r}')"></div>
|
|
11
|
-
</div>
|
|
12
|
-
`;o(()=>window.removeModal(r)),document.body.style.overflow=`hidden`,document.body.insertAdjacentHTML(`beforeend`,c),l(`#${r}`).then(e=>{n&&window[n](),window.setTimeout(()=>e.classList.add(`opacity-100`),32)})},A=(e=`v-modal`)=>{let t=document.getElementById(e);t&&(t.classList.remove(`opacity-100`),window.setTimeout(()=>{t.remove(),document.body.style.overflow=``},500))};window.removeModal=A;const j=s(`[data-toggle="modal"]`,`click`,k),M=t=>{if(t.getAttribute(`aria-selected`)===`true`)return null;let n=e(`[aria-labelledby="${t.getAttribute(`aria-controls`)}"]`);if(!n)return null;let r=t.classList.value,i=t.parentNode;for(;i&&(!(i instanceof HTMLElement)||i.getAttribute(`role`)!==`tablist`);)i=i.parentNode;if(!(i instanceof HTMLElement))return null;let a=i.querySelectorAll(`[aria-selected="true"]`);if(!a||a.length===0)return null;let o=a[0].classList.value;if(i.querySelectorAll(`[role="tab"]`).forEach(e=>{e.classList=r,e.setAttribute(`aria-selected`,`false`)}),t.classList=o,t.setAttribute(`aria-selected`,`true`),n.getAttribute(`role`)===`tabcontent`){Array.from(n.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.remove(`hidden`)});return}if(!n.parentNode)return null;Array.from(n.parentNode.children).forEach(e=>{e.getAttribute(`role`)===`tabpanel`&&e.classList.add(`hidden`)}),n.classList.remove(`hidden`)},N=s(`[role="tab"]`,`click`,M);(function(){window.vInitialized=!1,window.initializeVUI=()=>{window.vInitialized||(window.vInitialized=!0,x(),T(),C(),D(),j(),N(),c())},document.addEventListener(`DOMContentLoaded`,window.initializeVUI),document.readyState!==`loading`&&window.initializeVUI()})();
|
package/eslint.config.ts
DELETED
package/prettier.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** @type {import('prettier').Config} */
|
|
2
|
-
export default {
|
|
3
|
-
printWidth: 120,
|
|
4
|
-
singleQuote: true,
|
|
5
|
-
proseWrap: 'never',
|
|
6
|
-
overrides: [
|
|
7
|
-
{
|
|
8
|
-
files: '**/*.json',
|
|
9
|
-
options: {
|
|
10
|
-
parser: 'json-stringify',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
files: ['.vscode/*.json', '**/tsconfig.json'],
|
|
15
|
-
options: {
|
|
16
|
-
parser: 'jsonc',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
package/vite.config.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { name } from './package.json';
|
|
3
|
-
|
|
4
|
-
const getPackageName = () => {
|
|
5
|
-
return (name.includes('@') ? name.split('/')[1] : name).replace('.', '-');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const NAME = 'VersolyUI';
|
|
9
|
-
|
|
10
|
-
const fileName = {
|
|
11
|
-
es: `${getPackageName()}.mjs`,
|
|
12
|
-
cjs: `${getPackageName()}.cjs`,
|
|
13
|
-
iife: `${getPackageName()}.js`,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const config = {
|
|
17
|
-
build: {
|
|
18
|
-
target: ['chrome58', 'firefox57', 'safari11', 'edge79'],
|
|
19
|
-
lib: {
|
|
20
|
-
entry: resolve(__dirname, 'src/index.js'),
|
|
21
|
-
name: NAME,
|
|
22
|
-
formats: ['es', 'cjs', 'iife'],
|
|
23
|
-
fileName: (format) => fileName[format],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
server: {
|
|
27
|
-
port: 3005,
|
|
28
|
-
hmr: true,
|
|
29
|
-
watch: {
|
|
30
|
-
usePolling: true,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default config;
|