mensa 0.9.1 → 0.9.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 746ba9c00c7b9578ba6a54aed7d05cb0e3a4d97d39097f0bb20ee5741ad4c598
4
- data.tar.gz: febf42e4a305586f26bf0f8d738bec3e92125c13c900944a780a268e2a043ca8
3
+ metadata.gz: 651651e83e9d9140b6c5b0f63cc193afd84399ec3af2d511da59be36d56dae44
4
+ data.tar.gz: 443c135b4e673f6334db2b99690c60a2b8c7323d81a8c31b2d36f3e132856cff
5
5
  SHA512:
6
- metadata.gz: 78a2354e8bfdd6258a5b454dd83f6d42afbf0e1aebe0249833a805238a1e1a6d1b053032f51bd0a07f4b6b005423bc2d37c9253ddddefa97f2ec9391fb423b12
7
- data.tar.gz: 790b53409e027df4e5f9d06495321e7aa92008e4b297e709cda31d5044ff70fbb4ef5b7879d6f8914ee98071d37c54c3441444dd53b84e231d1a296b69262aa3
6
+ metadata.gz: ec46ba8fcc59ab4c193d4d912de77bdc9ebec4aac87c93983be02c1422d979a1558d9368a6f816d9ba9579b6c56fd928b412d73b39b9924838d62aff8a259467
7
+ data.tar.gz: '0491edbee70617b3293afcc8564f5fdb22379563bada952d74bcac0e40212fdf16a76e5e63c8d77258441779348c22147067c28b8fc222c938e45a5f29396dde'
data/.shipkit.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  ---
2
- previous_version: 0.9.0
2
+ previous_version: 0.9.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.2
4
+
5
+ - The table tour no longer needs the `driver.js` npm package. Mensa now ships
6
+ driver.js (1.10.1, MIT) itself in `app/components/mensa/table/driver.js` and
7
+ imports it as `mensa/components/table/driver`, so host apps that bundle
8
+ Mensa's JS with esbuild (jsbundling-rails) build again without adding
9
+ anything. In 0.9.0 and 0.9.1 those builds failed with
10
+ `Could not resolve "driver.js"`.
11
+ - driver.js is updated from 1.3.6 to 1.10.1; its CSS
12
+ (`app/assets/stylesheets/mensa/driver.css`) is updated to the same version.
13
+ - The table tour has a dark mode. It follows the host app's Tailwind dark mode
14
+ setting, like the rest of Mensa.
15
+ - The engine's importmap no longer pins `driver.js`. Host apps that import
16
+ `driver.js` themselves need their own pin or npm package.
17
+
3
18
  ## 0.8.0
4
19
 
5
20
  - **Behaviour change:** a column shows what was selected in SQL under its name
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mensa (0.9.0)
4
+ mensa (0.9.2)
5
5
  csv
6
6
  importmap-rails
7
7
  pagy (>= 43)
@@ -1,4 +1,5 @@
1
1
  @import "./driver.css";
2
+ @import "../../../components/mensa/table/tour.css";
2
3
  @import "../../../components/mensa/add_filter/component.css";
3
4
  @import "../../../components/mensa/column_customizer/component.css";
4
5
  @import "../../../components/mensa/cell/component.css";
@@ -1 +1,4 @@
1
- .driver-active .driver-overlay,.driver-active *{pointer-events:none}.driver-active .driver-active-element,.driver-active .driver-active-element *,.driver-popover,.driver-popover *{pointer-events:auto}@keyframes animate-fade-in{0%{opacity:0}to{opacity:1}}.driver-fade .driver-overlay{animation:animate-fade-in .2s ease-in-out}.driver-fade .driver-popover{animation:animate-fade-in .2s}.driver-popover{all:unset;box-sizing:border-box;color:#2d2d2d;margin:0;padding:15px;border-radius:5px;min-width:250px;max-width:300px;box-shadow:0 1px 10px #0006;z-index:1000000000;position:fixed;top:0;right:0;background-color:#fff}.driver-popover *{font-family:Helvetica Neue,Inter,ui-sans-serif,"Apple Color Emoji",Helvetica,Arial,sans-serif}.driver-popover-title{font:19px/normal sans-serif;font-weight:700;display:block;position:relative;line-height:1.5;zoom:1;margin:0}.driver-popover-close-btn{all:unset;position:absolute;top:0;right:0;width:32px;height:28px;cursor:pointer;font-size:18px;font-weight:500;color:#d2d2d2;z-index:1;text-align:center;transition:color;transition-duration:.2s}.driver-popover-close-btn:hover,.driver-popover-close-btn:focus{color:#2d2d2d}.driver-popover-title[style*=block]+.driver-popover-description{margin-top:5px}.driver-popover-description{margin-bottom:0;font:14px/normal sans-serif;line-height:1.5;font-weight:400;zoom:1}.driver-popover-footer{margin-top:15px;text-align:right;zoom:1;display:flex;align-items:center;justify-content:space-between}.driver-popover-progress-text{font-size:13px;font-weight:400;color:#727272;zoom:1}.driver-popover-footer button{all:unset;display:inline-block;box-sizing:border-box;padding:3px 7px;text-decoration:none;text-shadow:1px 1px 0 #fff;background-color:#fff;color:#2d2d2d;font:12px/normal sans-serif;cursor:pointer;outline:0;zoom:1;line-height:1.3;border:1px solid #ccc;border-radius:3px}.driver-popover-footer .driver-popover-btn-disabled{opacity:.5;pointer-events:none}:not(body):has(>.driver-active-element){overflow:hidden!important}.driver-no-interaction,.driver-no-interaction *{pointer-events:none!important}.driver-popover-footer button:hover,.driver-popover-footer button:focus{background-color:#f7f7f7}.driver-popover-navigation-btns{display:flex;flex-grow:1;justify-content:flex-end}.driver-popover-navigation-btns button+button{margin-left:4px}.driver-popover-arrow{content:"";position:absolute;border:5px solid #fff}.driver-popover-arrow-side-over{display:none}.driver-popover-arrow-side-left{left:100%;border-right-color:transparent;border-bottom-color:transparent;border-top-color:transparent}.driver-popover-arrow-side-right{right:100%;border-left-color:transparent;border-bottom-color:transparent;border-top-color:transparent}.driver-popover-arrow-side-top{top:100%;border-right-color:transparent;border-bottom-color:transparent;border-left-color:transparent}.driver-popover-arrow-side-bottom{bottom:100%;border-left-color:transparent;border-top-color:transparent;border-right-color:transparent}.driver-popover-arrow-side-center{display:none}.driver-popover-arrow-side-left.driver-popover-arrow-align-start,.driver-popover-arrow-side-right.driver-popover-arrow-align-start{top:15px}.driver-popover-arrow-side-top.driver-popover-arrow-align-start,.driver-popover-arrow-side-bottom.driver-popover-arrow-align-start{left:15px}.driver-popover-arrow-align-end.driver-popover-arrow-side-left,.driver-popover-arrow-align-end.driver-popover-arrow-side-right{bottom:15px}.driver-popover-arrow-side-top.driver-popover-arrow-align-end,.driver-popover-arrow-side-bottom.driver-popover-arrow-align-end{right:15px}.driver-popover-arrow-side-left.driver-popover-arrow-align-center,.driver-popover-arrow-side-right.driver-popover-arrow-align-center{top:50%;margin-top:-5px}.driver-popover-arrow-side-top.driver-popover-arrow-align-center,.driver-popover-arrow-side-bottom.driver-popover-arrow-align-center{left:50%;margin-left:-5px}.driver-popover-arrow-none{display:none}
1
+ /*! driver.js 1.10.1 | https://github.com/kamranahmedse/driver.js | MIT License | Copyright (c) Kamran Ahmed */
2
+ /* Vendored from the driver.js npm package (dist/driver.css), unmodified. Keep in sync with
3
+ app/components/mensa/table/driver.js, which comes from the same version. */
4
+ .driver-popover{all:unset;font-family:var(--driver-popover-font-family,"Helvetica Neue", Inter, ui-sans-serif, "Apple Color Emoji", Helvetica, Arial, sans-serif);box-sizing:border-box;color:#2d2d2d;z-index:1000000000;background-color:#fff;border-radius:5px;min-width:250px;max-width:300px;margin:0;padding:15px;position:fixed;top:0;right:0;box-shadow:0 1px 10px #0006}.driver-popover-title{zoom:1;margin:0;font-size:19px;font-weight:700;line-height:1.5;display:block;position:relative}.driver-popover-close-btn{all:unset;cursor:pointer;color:#d2d2d2;z-index:1;text-align:center;width:32px;height:28px;font-size:18px;font-weight:500;transition:color .2s;position:absolute;top:0;right:0}.driver-popover-close-btn:hover,.driver-popover-close-btn:focus-visible{color:#2d2d2d}.driver-popover-title[style*=block]+.driver-popover-description{margin-top:5px}.driver-popover-description{zoom:1;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.5}.driver-popover-footer{text-align:right;zoom:1;justify-content:space-between;align-items:center;margin-top:15px;display:flex}.driver-popover-progress-text{color:#727272;zoom:1;font-size:13px;font-weight:400}.driver-popover-footer-btn{all:unset;box-sizing:border-box;color:#2d2d2d;cursor:pointer;zoom:1;background-color:#fff;border:1px solid #ccc;border-radius:3px;outline:0;padding:3px 7px;font-size:12px;line-height:1.3;text-decoration:none;display:inline-block}.driver-popover-footer .driver-popover-btn-disabled{opacity:.5;pointer-events:none}.driver-popover-footer-btn:hover,.driver-popover-footer-btn:focus{background-color:#f7f7f7}.driver-popover-navigation-btns{flex-grow:1;justify-content:flex-end;display:flex}.driver-popover-navigation-btns button+button{margin-left:4px}.driver-popover-arrow{content:"";border:5px solid #fff;position:absolute}.driver-popover-arrow-side-over{display:none}.driver-popover-arrow-side-left{border-top-color:#0000;border-bottom-color:#0000;border-right-color:#0000;left:100%}.driver-popover-arrow-side-right{border-top-color:#0000;border-bottom-color:#0000;border-left-color:#0000;right:100%}.driver-popover-arrow-side-top{border-bottom-color:#0000;border-left-color:#0000;border-right-color:#0000;top:100%}.driver-popover-arrow-side-bottom{border-top-color:#0000;border-left-color:#0000;border-right-color:#0000;bottom:100%}.driver-popover-arrow-side-center,.driver-popover-arrow-none{display:none}.driver-active .driver-overlay{pointer-events:none}.driver-active.driver-no-scroll{overflow:hidden}.driver-active *{pointer-events:none}.driver-active .driver-active-element,.driver-active .driver-active-element *,.driver-popover,.driver-popover *{pointer-events:auto}@keyframes animate-fade-in{0%{opacity:0}to{opacity:1}}.driver-fade .driver-overlay{animation:animate-fade-in var(--driver-animation-duration,.4s) ease-in-out}.driver-fade .driver-popover{animation:animate-fade-in var(--driver-animation-duration,.4s)}.driver-active-element-parent-no-scroll{overflow:hidden!important}.driver-no-interaction,.driver-no-interaction *{pointer-events:none!important}
@@ -0,0 +1,5 @@
1
+ /*! driver.js 1.10.1 | https://github.com/kamranahmedse/driver.js | MIT License | Copyright (c) Kamran Ahmed */
2
+ // Vendored from the driver.js npm package (dist/driver.js.mjs), unmodified. Keep in sync
3
+ // with app/assets/stylesheets/mensa/driver.css, which comes from the same version.
4
+ const e=[`pointerdown`,`mousedown`,`pointerup`,`mouseup`,`click`],t=new WeakMap;function n(n,i,a){r(n);let o=e=>{let t=e.target;n.contains(t)&&((!a||a(t))&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()),e.type===`click`&&i?.(e))};for(let t of e)document.addEventListener(t,o,!0);t.set(n,o)}function r(n){let r=t.get(n);if(r){for(let t of e)document.removeEventListener(t,r,!0);t.delete(n)}}function i(e,t){let n=e.wrapper.getBoundingClientRect();return{width:n.width+t,height:n.height+t,realWidth:n.width,realHeight:n.height}}function a(e,t){let{elementDimensions:n,popoverDimensions:r,popoverPadding:i,popoverArrowDimensions:a}=t;return e===`start`?Math.max(Math.min(n.top-i,window.innerHeight-r.realHeight-a.width),a.width):e===`end`?Math.max(Math.min(n.top-r?.realHeight+n.height+i,window.innerHeight-r?.realHeight-a.width),a.width):e===`center`?Math.max(Math.min(n.top+n.height/2-r?.realHeight/2,window.innerHeight-r?.realHeight-a.width),a.width):0}function o(e,t){let{elementDimensions:n,popoverDimensions:r,popoverPadding:i,popoverArrowDimensions:a}=t;return e===`start`?Math.max(Math.min(n.left-i,window.innerWidth-r.realWidth-a.width),a.width):e===`end`?Math.max(Math.min(n.left-r?.realWidth+n.width+i,window.innerWidth-r?.realWidth-a.width),a.width):e===`center`?Math.max(Math.min(n.left+n.width/2-r?.realWidth/2,window.innerWidth-r?.realWidth-a.width),a.width):0}function s(e,t,n){let{align:r,side:s}=n,c=n.centered?`over`:s,l=n.padding,u=i(e,n.offset),f=e.arrow.getBoundingClientRect(),p=t.getBoundingClientRect(),m=p.top-u.height,h=m>=0,g=window.innerHeight-(p.bottom+u.height),_=g>=0,v=p.left-u.width,y=v>=0,b=window.innerWidth-(p.right+u.width),x=b>=0,S=!h&&!_&&!y&&!x,C=c;if(c===`top`&&h?x=y=_=!1:c===`bottom`&&_?x=y=h=!1:c===`left`&&y?x=h=_=!1:c===`right`&&x&&(y=h=_=!1),c===`over`){let t=window.innerWidth/2-u.realWidth/2,n=window.innerHeight/2-u.realHeight/2;e.wrapper.style.left=`${t}px`,e.wrapper.style.right=`auto`,e.wrapper.style.top=`${n}px`,e.wrapper.style.bottom=`auto`}else if(S){let t=window.innerWidth/2-u?.realWidth/2;e.wrapper.style.left=`${t}px`,e.wrapper.style.right=`auto`,e.wrapper.style.bottom=`10px`,e.wrapper.style.top=`auto`}else if(y){let t=Math.min(v,window.innerWidth-u?.realWidth-f.width),n=a(r,{elementDimensions:p,popoverDimensions:u,popoverPadding:l,popoverArrowDimensions:f});e.wrapper.style.left=`${t}px`,e.wrapper.style.top=`${n}px`,e.wrapper.style.bottom=`auto`,e.wrapper.style.right=`auto`,C=`left`}else if(x){let t=Math.min(b,window.innerWidth-u?.realWidth-f.width),n=a(r,{elementDimensions:p,popoverDimensions:u,popoverPadding:l,popoverArrowDimensions:f});e.wrapper.style.right=`${t}px`,e.wrapper.style.top=`${n}px`,e.wrapper.style.bottom=`auto`,e.wrapper.style.left=`auto`,C=`right`}else if(h){let t=Math.min(m,window.innerHeight-u.realHeight-f.width),n=o(r,{elementDimensions:p,popoverDimensions:u,popoverPadding:l,popoverArrowDimensions:f});e.wrapper.style.top=`${t}px`,e.wrapper.style.left=`${n}px`,e.wrapper.style.bottom=`auto`,e.wrapper.style.right=`auto`,C=`top`}else if(_){let t=Math.min(g,window.innerHeight-u?.realHeight-f.width),n=o(r,{elementDimensions:p,popoverDimensions:u,popoverPadding:l,popoverArrowDimensions:f});e.wrapper.style.left=`${n}px`,e.wrapper.style.bottom=`${t}px`,e.wrapper.style.top=`auto`,e.wrapper.style.right=`auto`,C=`bottom`}d(e,S?`over`:C,r,t),[...e.wrapper.classList].filter(e=>e.startsWith(`driver-popover-side-`)||e.startsWith(`driver-popover-align-`)).forEach(t=>e.wrapper.classList.remove(t)),e.wrapper.classList.add(`driver-popover-side-${C}`),e.wrapper.classList.add(`driver-popover-align-${r}`)}function c(e,t,n,r,i,a=10){let o=r-n;return e<=n&&t>=r?i===`start`?15+a/2:i===`end`?o-15-a/2:o/2:(Math.min(Math.max(e,n),r)+Math.min(Math.max(t,n),r))/2-n}function l(e,t,n=10){let r=t-15-n;if(r<15)return Math.max(0,(t-n)/2);let i=e-n/2;return Math.min(Math.max(i,15),r)}function u(e,t,n){return e===`left`||e===`right`?t.bottom>n.top&&t.top<n.bottom?e:t.bottom<=n.top?`bottom`:`top`:t.right>n.left&&t.left<n.right?e:t.right<=n.left?`right`:`left`}function d(e,t,n,r){let i=e.arrow;if(i.className=`driver-popover-arrow`,i.style.top=``,i.style.right=``,i.style.bottom=``,i.style.left=``,t===`over`){i.classList.add(`driver-popover-arrow-none`);return}let a=r.getBoundingClientRect(),o=e.wrapper.getBoundingClientRect(),s=u(t,a,o);i.classList.add(`driver-popover-arrow-side-${s}`);let d=i.getBoundingClientRect().width||10;if(s===`left`||s===`right`){let e=c(a.top,a.bottom,o.top,o.bottom,n,d);i.style.top=`${l(e,o.height,d)}px`}else{let e=c(a.left,a.right,o.left,o.right,n,d);i.style.left=`${l(e,o.width,d)}px`}}function f(e){return typeof e==`function`?e():typeof e==`string`?document.querySelector(e):e}function p(e){let t=window.getComputedStyle(e);return[t.overflow,t.overflowX,t.overflowY].some(e=>e===`auto`||e===`scroll`)}function m(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function h(e){let t=`a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])`;return e.flatMap(e=>{let n=e.matches(t),r=Array.from(e.querySelectorAll(t));return[...n?[e]:[],...r]}).filter(e=>getComputedStyle(e).pointerEvents!==`none`&&y(e))}function g(e,t){if(!e||v(e))return;let n=e.offsetHeight>window.innerHeight;e.scrollIntoView({behavior:!t||_(e)?`auto`:`smooth`,inline:`center`,block:n?`start`:`center`})}function _(e){if(!e||!e.parentElement)return;let t=e.parentElement;return t.scrollHeight>t.clientHeight}function v(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function y(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function b(e){return e.closest(`dialog[open]`)??document.body}function x(e){e&&(e.wrapper.style.display=`none`)}function S(e,t){let r=w();b(e).appendChild(r.wrapper);let{title:i,description:a,showButtons:o,disableButtons:c,showProgress:l,nextBtnText:u,prevBtnText:d,progressText:f}=t;r.nextButton.innerHTML=u,r.previousButton.innerHTML=d,r.progress.innerHTML=f,r.closeButton.setAttribute(`aria-label`,t.closeBtnLabel),t.doneButton&&r.nextButton.classList.add(`driver-popover-done-btn`),i?(r.title.innerHTML=i,r.title.style.display=`block`):r.title.style.display=`none`,a?(r.description.innerHTML=a,r.description.style.display=`block`):r.description.style.display=`none`;let p=o.includes(`next`)||o.includes(`previous`)||l;r.closeButton.style.display=o.includes(`close`)?`block`:`none`,p?(r.footer.style.display=`flex`,r.progress.style.display=l?`block`:`none`,r.nextButton.style.display=o.includes(`next`)?`block`:`none`,r.previousButton.style.display=o.includes(`previous`)?`block`:`none`):r.footer.style.display=`none`,c.includes(`next`)&&(r.nextButton.disabled=!0,r.nextButton.classList.add(`driver-popover-btn-disabled`)),c.includes(`previous`)&&(r.previousButton.disabled=!0,r.previousButton.classList.add(`driver-popover-btn-disabled`)),c.includes(`close`)&&(r.closeButton.disabled=!0,r.closeButton.classList.add(`driver-popover-btn-disabled`));let m=r.wrapper;m.style.display=`block`,m.style.left=``,m.style.top=``,m.style.bottom=``,m.style.right=``,m.id=`driver-popover-content`,m.setAttribute(`role`,`dialog`),m.setAttribute(`aria-labelledby`,`driver-popover-title`),m.setAttribute(`aria-describedby`,`driver-popover-description`);let _=r.arrow;_.className=`driver-popover-arrow`,m.className=`driver-popover ${t.popoverClass||``}`.trim(),n(r.wrapper,e=>{let n=e.target instanceof Element?e.target:e.target?.parentElement;if(n){if(n.closest(`.driver-popover-next-btn`))return t.onNextClick?.();if(n.closest(`.driver-popover-prev-btn`))return t.onPrevClick?.();if(n.closest(`.driver-popover-close-btn`))return t.onCloseClick?.()}},e=>r.description.contains(e)||r.title.contains(e)?!1:!!e.closest(`.driver-popover-prev-btn, .driver-popover-next-btn, .driver-popover-close-btn`)),t.onRender?.(r),s(r,e,t.position),C(r,e,t.position),g(m,t.smoothScroll);let v=h([m,e]);return v.length>0&&v[0].focus(),r}function C(e,t,n){e.wrapper.querySelectorAll(`img`).forEach(r=>{if(r.complete)return;let i=()=>s(e,t,n);r.addEventListener(`load`,i,{once:!0}),r.addEventListener(`error`,i,{once:!0})})}function w(){let e=document.createElement(`div`);e.classList.add(`driver-popover`);let t=document.createElement(`div`);t.classList.add(`driver-popover-arrow`);let n=document.createElement(`header`);n.id=`driver-popover-title`,n.classList.add(`driver-popover-title`),n.style.display=`none`,n.innerText=`Popover Title`;let r=document.createElement(`div`);r.id=`driver-popover-description`,r.classList.add(`driver-popover-description`),r.style.display=`none`,r.innerText=`Popover description is here`;let i=document.createElement(`button`);i.type=`button`,i.classList.add(`driver-popover-close-btn`),i.innerHTML=`&times;`;let a=document.createElement(`footer`);a.classList.add(`driver-popover-footer`);let o=document.createElement(`span`);o.classList.add(`driver-popover-progress-text`),o.innerText=``;let s=document.createElement(`span`);s.classList.add(`driver-popover-navigation-btns`);let c=document.createElement(`button`);c.type=`button`,c.classList.add(`driver-popover-prev-btn`,`driver-popover-footer-btn`),c.innerHTML=`Previous`;let l=document.createElement(`button`);return l.type=`button`,l.classList.add(`driver-popover-next-btn`,`driver-popover-footer-btn`),l.innerHTML=`Next`,s.appendChild(c),s.appendChild(l),a.appendChild(o),a.appendChild(s),e.appendChild(i),e.appendChild(t),e.appendChild(n),e.appendChild(r),e.appendChild(a),{wrapper:e,arrow:t,title:n,description:r,footer:a,previousButton:c,nextButton:l,closeButton:i,footerButtons:s,progress:o}}function T(e){e&&(r(e.wrapper),e.wrapper.parentElement?.removeChild(e.wrapper))}function E(e,t){let n=window.innerWidth,r=window.innerHeight,i=t.padding,a=t.radius,o=e.width+i*2,s=e.height+i*2,c=Math.min(a,o/2,s/2),l=Math.floor(Math.max(c,0)),u=e.x-i+l,d=e.y-i,f=o-l*2,p=s-l*2;return`M${n},0L0,0L0,${r}L${n},${r}L${n},0Z
5
+ M${u},${d} h${f} a${l},${l} 0 0 1 ${l},${l} v${p} a${l},${l} 0 0 1 -${l},${l} h-${f} a${l},${l} 0 0 1 -${l},-${l} v-${p} a${l},${l} 0 0 1 ${l},-${l} z`}function D(e,t,n,r,i){let a=e.getState(`__activeStagePosition`),o=a||r.getBoundingClientRect(),s=i.getBoundingClientRect();a={x:m(t,o.x,s.x-o.x,n),y:m(t,o.y,s.y-o.y,n),width:m(t,o.width,s.width-o.width,n),height:m(t,o.height,s.height-o.height,n)},k(e,a),e.setState(`__activeStagePosition`,a)}function O(e,t){if(!t)return;let n=t.getBoundingClientRect(),r={x:n.x,y:n.y,width:n.width,height:n.height};e.setState(`__activeStagePosition`,r),k(e,r)}function ee(e){let t=e.getState(`__activeStagePosition`),n=e.getState(`__overlaySvg`);if(!t)return;if(!n){console.warn(`No stage svg found.`);return}let r=window.innerWidth,i=window.innerHeight;n.setAttribute(`viewBox`,`0 0 ${r} ${i}`)}function te(e,t){let r=j(e,t);document.body.appendChild(r),n(r,t=>{t.target.tagName===`path`&&e.emit(`overlayClick`)}),e.setState(`__overlaySvg`,r)}function k(e,t){let n=e.getState(`__overlaySvg`);if(!n){te(e,t);return}let r=n.firstElementChild;if(r?.tagName!==`path`)throw Error(`no path element found in stage svg`);r.setAttribute(`d`,E(t,A(e)))}function A(e){return e.getState(`activeElement`)?.id===`driver-dummy-element`?{padding:0,radius:0}:{padding:e.getConfig(`stagePadding`)||0,radius:e.getConfig(`stageRadius`)||0}}function j(e,t){let n=window.innerWidth,r=window.innerHeight,i=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);i.classList.add(`driver-overlay`,`driver-overlay-animated`),i.setAttribute(`viewBox`,`0 0 ${n} ${r}`),i.setAttribute(`xmlSpace`,`preserve`),i.setAttribute(`xmlnsXlink`,`http://www.w3.org/1999/xlink`),i.setAttribute(`version`,`1.1`),i.setAttribute(`preserveAspectRatio`,`xMinYMin slice`),i.style.fillRule=`evenodd`,i.style.clipRule=`evenodd`,i.style.strokeLinejoin=`round`,i.style.strokeMiterlimit=`2`,i.style.zIndex=`10000`,i.style.position=`fixed`,i.style.top=`0`,i.style.left=`0`,i.style.width=`100%`,i.style.height=`100%`;let a=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return a.setAttribute(`d`,E(t,A(e))),a.style.fill=e.getConfig(`overlayColor`)||`rgb(0,0,0)`,a.style.opacity=`${e.getConfig(`overlayOpacity`)}`,a.style.pointerEvents=`auto`,a.style.cursor=`auto`,i.appendChild(a),i}function M(e){let t=e.getState(`__overlaySvg`);t&&(r(t),t.remove())}const N=`{{current}} of {{total}}`;function P(e,t){return!(t.skipMissingElement??e.getConfig(`skipMissingElement`))||!t.element?!1:!f(t.element)}function F(e,t,n){let r=e.getConfig(`steps`)||[];for(let i=t;i>=0&&i<r.length;i+=n)if(!P(e,r[i]))return i}function I(e,t){let n=e.getState(`activeIndex`),r=n!==void 0&&F(e,n+1,1)===void 0,i=t?.popover?.onDoneClick||e.getConfig(`onDoneClick`);return r&&i?i:t?.popover?.onNextClick||e.getConfig(`onNextClick`)}function L(e,t){return t?.popover?.onPrevClick||e.getConfig(`onPrevClick`)}function R(e,t){return t?.popover?.onCloseClick||e.getConfig(`onCloseClick`)}function z(e,t,n){let r=e.getConfig(`steps`)||[],i=r[t],a=i.popover||{},o=F(e,t+1,1)!==void 0,s=F(e,t-1,-1)!==void 0,c=a.doneBtnText||e.getConfig(`doneBtnText`)||`Done`,l=e.getConfig(`allowClose`),u=a.showProgress===void 0?e.getConfig(`showProgress`):a.showProgress,d=(a.progressText||e.getConfig(`progressText`)||N).replace(`{{current}}`,`${t+1}`).replace(`{{total}}`,`${r.length}`),f=a.showButtons||e.getConfig(`showButtons`),p=[`next`,`previous`,...l?[`close`]:[]].filter(e=>!f?.length||f.includes(e)),m=a.onNextClick||e.getConfig(`onNextClick`),h=a.onPrevClick||e.getConfig(`onPrevClick`),g=a.onCloseClick||e.getConfig(`onCloseClick`);return{...i,popover:{showButtons:p,nextBtnText:o?void 0:c,disableButtons:[...e.getConfig(`disableButtons`)||[],...s?[]:[`previous`]],showProgress:u,onNextClick:m||n.onNextClick,onPrevClick:h||n.onPrevClick,onCloseClick:g||n.onCloseClick,...a,progressText:d}}}function B(e,t){return{showButtons:t?.popover?.showButtons||e.getConfig(`showButtons`)||[],disableButtons:t?.popover?.disableButtons||e.getConfig(`disableButtons`)||[]}}function V(e,t,n){let r=e.getConfig(`stagePadding`)||0;return{side:n.popover?.side||`bottom`,align:n.popover?.align||`start`,offset:r+(e.getConfig(`popoverOffset`)||0),padding:r,centered:t.id===`driver-dummy-element`}}function H(e,t,n){let r=n.popover||{},i=e.getState(`activeIndex`),a=i!==void 0&&F(e,i+1,1)===void 0;return{title:r.title,description:r.description,...B(e,n),showProgress:r.showProgress||e.getConfig(`showProgress`)||!1,progressText:r.progressText??(e.getConfig(`progressText`)||N),nextBtnText:r.nextBtnText??(e.getConfig(`nextBtnText`)||`Next`),prevBtnText:r.prevBtnText??(e.getConfig(`prevBtnText`)||`Previous`),closeBtnLabel:r.closeBtnLabel??(e.getConfig(`closeBtnLabel`)||`Close`),doneButton:a,popoverClass:r.popoverClass||e.getConfig(`popoverClass`)||``,smoothScroll:e.getConfig(`smoothScroll`),onNextClick:()=>{a&&e.setState(`__destroyReason`,`done`);let r=I(e,n);return r?r(t,n,e.getHookOpts()):e.emit(`nextClick`)},onPrevClick:()=>{let r=L(e,n);return r?r(t,n,e.getHookOpts()):e.emit(`prevClick`)},onCloseClick:()=>{e.setState(`__destroyReason`,`close`);let r=R(e,n);return r?r(t,n,e.getHookOpts()):e.emit(`closeClick`)},onRender:t=>{e.setState(`popover`,t),(r.onPopoverRender||e.getConfig(`onPopoverRender`))?.(t,e.getHookOpts())},position:V(e,t,n)}}function U(e,t,n){T(e.getState(`popover`)),S(t,H(e,t,n))}function W(e,t,n){let r=e.getState(`popover`);r&&s(r,t,V(e,t,n))}const G={"aria-haspopup":`dialog`,"aria-expanded":`true`,"aria-controls":`driver-popover-content`},K=new WeakMap;function q(e){if(!K.has(e)){let t=Object.fromEntries(Object.keys(G).map(t=>[t,e.getAttribute(t)]));K.set(e,t)}for(let[t,n]of Object.entries(G))e.setAttribute(t,n)}function J(e){let t=K.get(e);if(t){for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);K.delete(e)}}function Y(){let e=document.getElementById(`driver-dummy-element`);if(e)return e;let t=document.createElement(`div`);return t.id=`driver-dummy-element`,t.style.width=`0`,t.style.height=`0`,t.style.pointerEvents=`none`,t.style.opacity=`0`,t.style.position=`fixed`,t.style.top=`50%`,t.style.left=`50%`,document.body.appendChild(t),t}function X(e,t){let n=f(t.element);n||(n=Y()),ne(e,n,t)}function Z(e){let t=e.getState(`__activeElement`),n=e.getState(`__activeStep`);t&&(O(e,t),ee(e),W(e,t,n))}function ne(e,t,n){let r=e.getConfig(`duration`)||400,i=Date.now(),a=e.getState(`__activeStep`),o=e.getState(`__activeElement`)||t,s=!o||o===t,c=t.id===`driver-dummy-element`,l=o.id===`driver-dummy-element`,u=e.getConfig(`animate`),d=n.onHighlightStarted||e.getConfig(`onHighlightStarted`),f=n?.onHighlighted||e.getConfig(`onHighlighted`),m=a?.onDeselected||e.getConfig(`onDeselected`),h=e.getHookOpts();a&&a!==n&&m&&m(l?void 0:o,a,h),d&&d(c?void 0:t,n,h);let _=!s&&u,v=!1;x(e.getState(`popover`)),e.setState(`previousStep`,a),e.setState(`previousElement`,o),e.setState(`activeStep`,n),e.setState(`activeElement`,t);let y=()=>{if(e.getState(`__transitionCallback`)!==y)return;let s=Date.now()-i,l=r-s<=r/2;n.popover&&l&&!v&&_&&(U(e,t,n),v=!0),e.getConfig(`animate`)&&s<r?D(e,s,r,o,t):(O(e,t),f&&f(c?void 0:t,n,e.getHookOpts()),e.setState(`__transitionCallback`,void 0),e.setState(`__previousStep`,a),e.setState(`__previousElement`,o),e.setState(`__activeStep`,n),e.setState(`__activeElement`,t)),window.requestAnimationFrame(y)};e.setState(`__transitionCallback`,y),window.requestAnimationFrame(y),g(t,e.getConfig(`smoothScroll`)),!_&&n.popover&&U(e,t,n),document.querySelectorAll(`.driver-active-element-parent`).forEach(e=>{e.classList.remove(`driver-active-element-parent`,`driver-active-element-parent-no-scroll`)}),document.querySelectorAll(`.driver-active-element`).forEach(e=>{e.classList.remove(`driver-active-element`,`driver-no-interaction`),J(e)}),(n.disableActiveInteraction??e.getConfig(`disableActiveInteraction`))&&t.classList.add(`driver-no-interaction`);let b=t.parentElement;b&&b!==document.body&&(b.classList.add(`driver-active-element-parent`),p(b)&&b.classList.add(`driver-active-element-parent-no-scroll`)),t.classList.add(`driver-active-element`),q(t)}function re(){document.getElementById(`driver-dummy-element`)?.remove(),document.querySelectorAll(`.driver-active-element`).forEach(e=>{let t=e.parentElement;t&&t!==document.body&&t.classList.remove(`driver-active-element-parent`,`driver-active-element-parent-no-scroll`),e.classList.remove(`driver-active-element`,`driver-no-interaction`),J(e)})}function Q(e){let t=e.getState(`__resizeTimeout`);t&&window.cancelAnimationFrame(t),e.setState(`__resizeTimeout`,window.requestAnimationFrame(()=>Z(e)))}function ie(e,t){if(!e.getState(`isInitialized`)||!(t.key===`Tab`||t.keyCode===9))return;let n=e.getState(`__activeElement`),r=e.getState(`popover`)?.wrapper,i=h([...r?[r]:[],...n?[n]:[]]),a=i[0],o=i[i.length-1];t.preventDefault(),t.shiftKey?(i[i.indexOf(document.activeElement)-1]||o)?.focus():(i[i.indexOf(document.activeElement)+1]||a)?.focus()}function ae(e,t){(e.getConfig(`allowKeyboardControl`)??!0)&&(t.key===`Escape`?e.emit(`escapePress`):t.key===`ArrowRight`?e.emit(`arrowRightPress`):t.key===`ArrowLeft`&&e.emit(`arrowLeftPress`))}function oe(e,t){let n=e.getState(`__activeElement`),r=t.target;!n||!r||!n.contains(r)||e.emit(`activeElementClick`)}function se(e){let t=t=>ae(e,t),n=t=>ie(e,t),r=()=>Q(e),i=()=>Q(e),a=t=>oe(e,t);e.setState(`__events`,{onKeyup:t,onKeydown:n,onResize:r,onScroll:i,onClick:a}),window.addEventListener(`keyup`,t,!1),window.addEventListener(`keydown`,n,!1),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i),document.addEventListener(`click`,a,!1)}function ce(e){let t=e.getState(`__events`);t&&(window.removeEventListener(`keyup`,t.onKeyup),window.removeEventListener(`keydown`,t.onKeydown),window.removeEventListener(`resize`,t.onResize),window.removeEventListener(`scroll`,t.onScroll),document.removeEventListener(`click`,t.onClick,!1))}function le(){let e={};function t(t={}){e={animate:!0,duration:400,allowClose:!0,allowScroll:!0,overlayClickBehavior:`close`,overlayOpacity:.7,smoothScroll:!1,disableActiveInteraction:!1,advanceOnClick:!1,skipMissingElement:!1,waitForElement:0,showProgress:!1,stagePadding:10,stageRadius:5,popoverOffset:10,showButtons:[`next`,`previous`,`close`],disableButtons:[],overlayColor:`#000`,...t}}return t(),{getConfig:(t=>t?e[t]:e),configure:t}}function ue(){let e={},t=(t=>t?e[t]:e),n=(t,n)=>{e[t]=n};function r(){e={}}return{getState:t,setState:n,resetState:r}}function de(){let e={};function t(t,n){e[t]=n}function n(t){e[t]?.()}function r(){e={}}return{listen:t,emit:n,reset:r}}function fe(e={}){let t=le();t.configure(e);let n=ue(),r=de(),i;return{getConfig:t.getConfig,setConfig:t.configure,getState:n.getState,setState:n.setState,resetState:n.resetState,listen:r.listen,emit:r.emit,resetEmitter:r.reset,getDriver:()=>i,setDriver:e=>{i=e},getHookOpts:(e,r)=>{let a=e||n.getState();return{config:t.getConfig(),state:a,driver:i,index:a.activeIndex,...r?{reason:r}:{}}}}}let $;function pe(e={}){let t=fe(e),n=()=>y(`replaced`,!1);function r(e=`close`){t.getConfig(`allowClose`)&&y(e)}function i(){let e=t.getState(`activeIndex`);e!==void 0&&F(t,e+1,1)===void 0&&t.setState(`__destroyReason`,`done`)}function a(){let{disableButtons:e}=B(t,t.getState(`__activeStep`));e.includes(`close`)||r(`escape`)}function o(e){let{showButtons:n,disableButtons:r}=B(t,t.getState(`__activeStep`));return n.includes(e)&&!r.includes(e)}function s(){let e=t.getConfig(`overlayClickBehavior`);if(t.getConfig(`allowClose`)&&e===`close`){y(`overlay`);return}if(typeof e==`function`){t.setState(`__destroyReason`,`overlay`);let n=t.getState(`__activeStep`);e(t.getState(`__activeElement`),n,t.getHookOpts());return}if(e===`nextStep`){let e=t.getState(`activeStep`),n=t.getState(`activeElement`),r=I(t,e);if(r){i(),r(n,e,t.getHookOpts());return}c()}}function c(){let e=t.getState(`activeIndex`),n=t.getConfig(`steps`)||[];if(e===void 0)return;let r=e+1;n[r]?v(r):y(`done`)}function l(){let e=t.getState(`activeIndex`),n=t.getConfig(`steps`)||[];if(e===void 0)return;let r=e-1;n[r]?v(r):y(`api`)}function u(e){(t.getConfig(`steps`)||[])[e]?v(e):y(`api`)}function d(){if(t.getState(`__transitionCallback`))return;let e=t.getState(`__activeStep`);if(!e||!(e.advanceOnClick??t.getConfig(`advanceOnClick`)))return;let n=t.getState(`__activeElement`),r=I(t,e);if(r){i(),r(n,e,t.getHookOpts());return}c()}function p(){if(t.getState(`__transitionCallback`))return;let e=t.getState(`activeIndex`),n=t.getState(`__activeStep`),r=t.getState(`__activeElement`);if(e===void 0||n===void 0||!(t.getConfig(`steps`)||[])[e-1]||!o(`previous`))return;let i=L(t,n);if(i)return i(r,n,t.getHookOpts());l()}function m(){if(t.getState(`__transitionCallback`))return;let e=t.getState(`activeIndex`),n=t.getState(`__activeStep`),r=t.getState(`__activeElement`);if(e===void 0||n===void 0||!o(`next`))return;let a=I(t,n);if(a)return i(),a(r,n,t.getHookOpts());c()}function h(){t.getState(`isInitialized`)||($&&$!==n&&$(),$=n,t.setState(`isInitialized`,!0),document.body.classList.add(`driver-active`,t.getConfig(`animate`)?`driver-fade`:`driver-simple`),t.getConfig(`allowScroll`)||document.body.classList.add(`driver-no-scroll`),document.body.style.setProperty(`--driver-animation-duration`,`${t.getConfig(`duration`)||400}ms`),se(t),t.listen(`overlayClick`,s),t.listen(`activeElementClick`,d),t.listen(`escapePress`,a),t.listen(`closeClick`,r),t.listen(`arrowLeftPress`,p),t.listen(`arrowRightPress`,m))}function g(){let e=t.getState(`__pendingWaitCancel`);e&&(t.setState(`__pendingWaitCancel`,void 0),e())}function _(e,n,r){let i=()=>{a.disconnect(),window.clearTimeout(o),t.setState(`__pendingWaitCancel`,void 0),r()},a=new MutationObserver(()=>{f(e.element)&&i()}),o=window.setTimeout(i,n);t.setState(`__pendingWaitCancel`,()=>{a.disconnect(),window.clearTimeout(o)}),a.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})}function v(e=0,n=!1){g(),t.setState(`__destroyReason`,void 0);let r=t.getConfig(`steps`);if(!r){console.error(`No steps to drive through`),y(`api`);return}if(!r[e]){y(`api`);return}let i=r[e],a=i.waitForElement??t.getConfig(`waitForElement`)??0;if(!n&&a>0&&i.element&&!f(i.element)){x(t.getState(`popover`)),_(i,a,()=>v(e,!0));return}if(P(t,i)){let n=t.getState(`activeIndex`),i=typeof n==`number`&&e<n?-1:1;r[e+i]?v(e+i):i===1&&y(`done`);return}t.setState(`__activeOnDestroyed`,document.activeElement),t.setState(`activeIndex`,e);let o=r[e+1];X(t,z(t,e,{onNextClick:()=>{o?v(e+1):y(`done`)},onPrevClick:()=>{v(e-1)},onCloseClick:()=>{y(`close`)}}))}function y(e,r=!0){if(!t.getState(`isInitialized`))return;e===`api`&&(e=t.getState(`__destroyReason`)??`api`);let i=t.getState(`__activeElement`),a=t.getState(`__activeStep`),o=t.getState(`__activeOnDestroyed`),s=t.getConfig(`onDestroyStarted`);if(r&&s){t.setState(`__destroyReason`,e),s(!i||i?.id===`driver-dummy-element`?void 0:i,a,t.getHookOpts(void 0,e));return}$===n&&($=void 0);let c=a?.onDeselected||t.getConfig(`onDeselected`),l=t.getConfig(`onDestroyed`);document.body.classList.remove(`driver-active`,`driver-fade`,`driver-simple`,`driver-no-scroll`),document.body.style.removeProperty(`--driver-animation-duration`),g(),ce(t),T(t.getState(`popover`)),re(),M(t),t.resetEmitter();let u=t.getState();if(t.resetState(),i&&a){let n=i.id===`driver-dummy-element`;c&&c(n?void 0:i,a,t.getHookOpts(u,e)),l&&l(n?void 0:i,a,t.getHookOpts(u,e))}o&&o.focus()}let b={isActive:()=>t.getState(`isInitialized`)||!1,refresh:()=>Q(t),drive:(e=0)=>{h(),v(e)},setConfig:t.setConfig,setSteps:e=>{g(),t.resetState(),t.setConfig({...t.getConfig(),steps:e})},getConfig:t.getConfig,getState:t.getState,getActiveIndex:()=>t.getState(`activeIndex`),isFirstStep:()=>{let e=t.getState(`activeIndex`);return e!==void 0&&F(t,e-1,-1)===void 0},isLastStep:()=>{let e=t.getState(`activeIndex`);return e!==void 0&&F(t,e+1,1)===void 0},getActiveStep:()=>t.getState(`activeStep`),getActiveElement:()=>t.getState(`activeElement`),getPreviousElement:()=>t.getState(`previousElement`),getPreviousStep:()=>t.getState(`previousStep`),getNextStep:()=>{let e=t.getConfig(`steps`)||[],n=t.getState(`activeIndex`);if(n===void 0)return;let r=F(t,n+1,1);return r===void 0?void 0:e[r]},moveNext:c,movePrevious:l,moveTo:u,hasNextStep:()=>{let e=t.getState(`activeIndex`);return e!==void 0&&F(t,e+1,1)!==void 0},hasPreviousStep:()=>{let e=t.getState(`activeIndex`);return e!==void 0&&F(t,e-1,-1)!==void 0},highlight:e=>{h(),t.setState(`__destroyReason`,void 0),X(t,{...e,popover:e.popover?{showButtons:[],showProgress:!1,progressText:``,...e.popover}:void 0})},destroy:()=>{y(`api`,!1)}};return t.setDriver(b),b}export{pe as driver};
@@ -0,0 +1,39 @@
1
+ /* Dark mode for the driver.js tour popover. driver.css is vendored unmodified, so the
2
+ overrides live here and must be imported after it. */
3
+ .driver-popover {
4
+ @apply dark:bg-gray-800 dark:text-gray-100 dark:ring-1 dark:ring-white/10;
5
+ }
6
+
7
+ .driver-popover-description {
8
+ @apply dark:text-gray-300;
9
+ }
10
+
11
+ .driver-popover-progress-text {
12
+ @apply dark:text-gray-400;
13
+ }
14
+
15
+ .driver-popover-close-btn {
16
+ @apply dark:text-gray-500 dark:hover:text-gray-200 dark:focus:text-gray-200;
17
+ }
18
+
19
+ .driver-popover-footer button {
20
+ @apply dark:bg-gray-700 dark:text-gray-100 dark:border-gray-600 dark:[text-shadow:none] dark:hover:bg-gray-600 dark:focus:bg-gray-600;
21
+ }
22
+
23
+ /* The arrow is a border triangle: only the side pointing at the element is coloured,
24
+ the other three stay transparent. */
25
+ .driver-popover-arrow-side-left {
26
+ @apply dark:border-l-gray-800;
27
+ }
28
+
29
+ .driver-popover-arrow-side-right {
30
+ @apply dark:border-r-gray-800;
31
+ }
32
+
33
+ .driver-popover-arrow-side-top {
34
+ @apply dark:border-t-gray-800;
35
+ }
36
+
37
+ .driver-popover-arrow-side-bottom {
38
+ @apply dark:border-b-gray-800;
39
+ }
@@ -1,5 +1,5 @@
1
1
  import ApplicationController from "mensa/controllers/application_controller";
2
- import { driver } from "driver.js";
2
+ import { driver } from "mensa/components/table/driver";
3
3
 
4
4
  // Explains the table's features the first time each one is seen. Every feature is
5
5
  // its own segment, remembered in localStorage, so a feature missing on one table is
data/config/importmap.rb CHANGED
@@ -4,5 +4,4 @@ pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
4
4
  pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
5
5
  pin_all_from Mensa::Engine.root.join("app/javascript/mensa/controllers"), under: "mensa/controllers", to: "mensa/controllers", preload: false
6
6
  pin_all_from Mensa::Engine.root.join("app/components/mensa"), under: "mensa/components", to: "mensa", preload: false
7
- pin "driver.js", to: "driver.js.js" # @1.3.6
8
7
  pin "@rails/request.js", to: "@rails--request.js.js" # @0.0.9
data/lib/mensa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mensa
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mensa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
@@ -240,6 +240,8 @@ files:
240
240
  - app/components/mensa/table/component.html.erb
241
241
  - app/components/mensa/table/component.rb
242
242
  - app/components/mensa/table/component_controller.js
243
+ - app/components/mensa/table/driver.js
244
+ - app/components/mensa/table/tour.css
243
245
  - app/components/mensa/table/tour_controller.js
244
246
  - app/components/mensa/table_row/component.css
245
247
  - app/components/mensa/table_row/component.html.erb
@@ -345,7 +347,6 @@ files:
345
347
  - package-lock.json
346
348
  - package.json
347
349
  - vendor/javascript/@rails--request.js.js
348
- - vendor/javascript/driver.js.js
349
350
  homepage: https://github.com/entdec/mensa
350
351
  licenses:
351
352
  - MIT
@@ -1,666 +0,0 @@
1
- let z = {}, J;
2
- function F(e = {}) {
3
- z = {
4
- animate: !0,
5
- allowClose: !0,
6
- overlayClickBehavior: "close",
7
- overlayOpacity: 0.7,
8
- smoothScroll: !1,
9
- disableActiveInteraction: !1,
10
- showProgress: !1,
11
- stagePadding: 10,
12
- stageRadius: 5,
13
- popoverOffset: 10,
14
- showButtons: ["next", "previous", "close"],
15
- disableButtons: [],
16
- overlayColor: "#000",
17
- ...e
18
- };
19
- }
20
- function s(e) {
21
- return e ? z[e] : z;
22
- }
23
- function le(e) {
24
- J = e;
25
- }
26
- function _() {
27
- return J;
28
- }
29
- let I = {};
30
- function N(e, o) {
31
- I[e] = o;
32
- }
33
- function L(e) {
34
- var o;
35
- (o = I[e]) == null || o.call(I);
36
- }
37
- function de() {
38
- I = {};
39
- }
40
- function O(e, o, t, i) {
41
- return (e /= i / 2) < 1 ? t / 2 * e * e + o : -t / 2 * (--e * (e - 2) - 1) + o;
42
- }
43
- function U(e) {
44
- const o = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';
45
- return e.flatMap((t) => {
46
- const i = t.matches(o), d = Array.from(t.querySelectorAll(o));
47
- return [...i ? [t] : [], ...d];
48
- }).filter((t) => getComputedStyle(t).pointerEvents !== "none" && ve(t));
49
- }
50
- function ee(e) {
51
- if (!e || ue(e))
52
- return;
53
- const o = s("smoothScroll"), t = e.offsetHeight > window.innerHeight;
54
- e.scrollIntoView({
55
- // Removing the smooth scrolling for elements which exist inside the scrollable parent
56
- // This was causing the highlight to not properly render
57
- behavior: !o || pe(e) ? "auto" : "smooth",
58
- inline: "center",
59
- block: t ? "start" : "center"
60
- });
61
- }
62
- function pe(e) {
63
- if (!e || !e.parentElement)
64
- return;
65
- const o = e.parentElement;
66
- return o.scrollHeight > o.clientHeight;
67
- }
68
- function ue(e) {
69
- const o = e.getBoundingClientRect();
70
- return o.top >= 0 && o.left >= 0 && o.bottom <= (window.innerHeight || document.documentElement.clientHeight) && o.right <= (window.innerWidth || document.documentElement.clientWidth);
71
- }
72
- function ve(e) {
73
- return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
74
- }
75
- let D = {};
76
- function k(e, o) {
77
- D[e] = o;
78
- }
79
- function l(e) {
80
- return e ? D[e] : D;
81
- }
82
- function X() {
83
- D = {};
84
- }
85
- function fe(e, o, t, i) {
86
- let d = l("__activeStagePosition");
87
- const n = d || t.getBoundingClientRect(), f = i.getBoundingClientRect(), w = O(e, n.x, f.x - n.x, o), r = O(e, n.y, f.y - n.y, o), v = O(e, n.width, f.width - n.width, o), g = O(e, n.height, f.height - n.height, o);
88
- d = {
89
- x: w,
90
- y: r,
91
- width: v,
92
- height: g
93
- }, oe(d), k("__activeStagePosition", d);
94
- }
95
- function te(e) {
96
- if (!e)
97
- return;
98
- const o = e.getBoundingClientRect(), t = {
99
- x: o.x,
100
- y: o.y,
101
- width: o.width,
102
- height: o.height
103
- };
104
- k("__activeStagePosition", t), oe(t);
105
- }
106
- function he() {
107
- const e = l("__activeStagePosition"), o = l("__overlaySvg");
108
- if (!e)
109
- return;
110
- if (!o) {
111
- console.warn("No stage svg found.");
112
- return;
113
- }
114
- const t = window.innerWidth, i = window.innerHeight;
115
- o.setAttribute("viewBox", `0 0 ${t} ${i}`);
116
- }
117
- function ge(e) {
118
- const o = we(e);
119
- document.body.appendChild(o), re(o, (t) => {
120
- t.target.tagName === "path" && L("overlayClick");
121
- }), k("__overlaySvg", o);
122
- }
123
- function oe(e) {
124
- const o = l("__overlaySvg");
125
- if (!o) {
126
- ge(e);
127
- return;
128
- }
129
- const t = o.firstElementChild;
130
- if ((t == null ? void 0 : t.tagName) !== "path")
131
- throw new Error("no path element found in stage svg");
132
- t.setAttribute("d", ie(e));
133
- }
134
- function we(e) {
135
- const o = window.innerWidth, t = window.innerHeight, i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
136
- i.classList.add("driver-overlay", "driver-overlay-animated"), i.setAttribute("viewBox", `0 0 ${o} ${t}`), i.setAttribute("xmlSpace", "preserve"), i.setAttribute("xmlnsXlink", "http://www.w3.org/1999/xlink"), i.setAttribute("version", "1.1"), i.setAttribute("preserveAspectRatio", "xMinYMin slice"), i.style.fillRule = "evenodd", i.style.clipRule = "evenodd", i.style.strokeLinejoin = "round", i.style.strokeMiterlimit = "2", i.style.zIndex = "10000", i.style.position = "fixed", i.style.top = "0", i.style.left = "0", i.style.width = "100%", i.style.height = "100%";
137
- const d = document.createElementNS("http://www.w3.org/2000/svg", "path");
138
- return d.setAttribute("d", ie(e)), d.style.fill = s("overlayColor") || "rgb(0,0,0)", d.style.opacity = `${s("overlayOpacity")}`, d.style.pointerEvents = "auto", d.style.cursor = "auto", i.appendChild(d), i;
139
- }
140
- function ie(e) {
141
- const o = window.innerWidth, t = window.innerHeight, i = s("stagePadding") || 0, d = s("stageRadius") || 0, n = e.width + i * 2, f = e.height + i * 2, w = Math.min(d, n / 2, f / 2), r = Math.floor(Math.max(w, 0)), v = e.x - i + r, g = e.y - i, y = n - r * 2, a = f - r * 2;
142
- return `M${o},0L0,0L0,${t}L${o},${t}L${o},0Z
143
- M${v},${g} h${y} a${r},${r} 0 0 1 ${r},${r} v${a} a${r},${r} 0 0 1 -${r},${r} h-${y} a${r},${r} 0 0 1 -${r},-${r} v-${a} a${r},${r} 0 0 1 ${r},-${r} z`;
144
- }
145
- function me() {
146
- const e = l("__overlaySvg");
147
- e && e.remove();
148
- }
149
- function ye() {
150
- const e = document.getElementById("driver-dummy-element");
151
- if (e)
152
- return e;
153
- let o = document.createElement("div");
154
- return o.id = "driver-dummy-element", o.style.width = "0", o.style.height = "0", o.style.pointerEvents = "none", o.style.opacity = "0", o.style.position = "fixed", o.style.top = "50%", o.style.left = "50%", document.body.appendChild(o), o;
155
- }
156
- function j(e) {
157
- const { element: o } = e;
158
- let t = typeof o == "function" ? o() : typeof o == "string" ? document.querySelector(o) : o;
159
- t || (t = ye()), be(t, e);
160
- }
161
- function xe() {
162
- const e = l("__activeElement"), o = l("__activeStep");
163
- e && (te(e), he(), ae(e, o));
164
- }
165
- function be(e, o) {
166
- var C;
167
- const i = Date.now(), d = l("__activeStep"), n = l("__activeElement") || e, f = !n || n === e, w = e.id === "driver-dummy-element", r = n.id === "driver-dummy-element", v = s("animate"), g = o.onHighlightStarted || s("onHighlightStarted"), y = (o == null ? void 0 : o.onHighlighted) || s("onHighlighted"), a = (d == null ? void 0 : d.onDeselected) || s("onDeselected"), p = s(), c = l();
168
- !f && a && a(r ? void 0 : n, d, {
169
- config: p,
170
- state: c,
171
- driver: _()
172
- }), g && g(w ? void 0 : e, o, {
173
- config: p,
174
- state: c,
175
- driver: _()
176
- });
177
- const u = !f && v;
178
- let h = !1;
179
- _e(), k("previousStep", d), k("previousElement", n), k("activeStep", o), k("activeElement", e);
180
- const m = () => {
181
- if (l("__transitionCallback") !== m)
182
- return;
183
- const b = Date.now() - i, E = 400 - b <= 400 / 2;
184
- o.popover && E && !h && u && (Q(e, o), h = !0), s("animate") && b < 400 ? fe(b, 400, n, e) : (te(e), y && y(w ? void 0 : e, o, {
185
- config: s(),
186
- state: l(),
187
- driver: _()
188
- }), k("__transitionCallback", void 0), k("__previousStep", d), k("__previousElement", n), k("__activeStep", o), k("__activeElement", e)), window.requestAnimationFrame(m);
189
- };
190
- k("__transitionCallback", m), window.requestAnimationFrame(m), ee(e), !u && o.popover && Q(e, o), n.classList.remove("driver-active-element", "driver-no-interaction"), n.removeAttribute("aria-haspopup"), n.removeAttribute("aria-expanded"), n.removeAttribute("aria-controls"), ((C = o.disableActiveInteraction) != null ? C : s("disableActiveInteraction")) && e.classList.add("driver-no-interaction"), e.classList.add("driver-active-element"), e.setAttribute("aria-haspopup", "dialog"), e.setAttribute("aria-expanded", "true"), e.setAttribute("aria-controls", "driver-popover-content");
191
- }
192
- function Ce() {
193
- var e;
194
- (e = document.getElementById("driver-dummy-element")) == null || e.remove(), document.querySelectorAll(".driver-active-element").forEach((o) => {
195
- o.classList.remove("driver-active-element", "driver-no-interaction"), o.removeAttribute("aria-haspopup"), o.removeAttribute("aria-expanded"), o.removeAttribute("aria-controls");
196
- });
197
- }
198
- function M() {
199
- const e = l("__resizeTimeout");
200
- e && window.cancelAnimationFrame(e), k("__resizeTimeout", window.requestAnimationFrame(xe));
201
- }
202
- function Pe(e) {
203
- var r;
204
- if (!l("isInitialized") || !(e.key === "Tab" || e.keyCode === 9))
205
- return;
206
- const i = l("__activeElement"), d = (r = l("popover")) == null ? void 0 : r.wrapper, n = U([
207
- ...d ? [d] : [],
208
- ...i ? [i] : []
209
- ]), f = n[0], w = n[n.length - 1];
210
- if (e.preventDefault(), e.shiftKey) {
211
- const v = n[n.indexOf(document.activeElement) - 1] || w;
212
- v == null || v.focus();
213
- } else {
214
- const v = n[n.indexOf(document.activeElement) + 1] || f;
215
- v == null || v.focus();
216
- }
217
- }
218
- function ne(e) {
219
- var t;
220
- ((t = s("allowKeyboardControl")) == null || t) && (e.key === "Escape" ? L("escapePress") : e.key === "ArrowRight" ? L("arrowRightPress") : e.key === "ArrowLeft" && L("arrowLeftPress"));
221
- }
222
- function re(e, o, t) {
223
- const i = (n, f) => {
224
- const w = n.target;
225
- e.contains(w) && ((!t || t(w)) && (n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation()), f == null || f(n));
226
- };
227
- document.addEventListener("pointerdown", i, !0), document.addEventListener("mousedown", i, !0), document.addEventListener("pointerup", i, !0), document.addEventListener("mouseup", i, !0), document.addEventListener(
228
- "click",
229
- (n) => {
230
- i(n, o);
231
- },
232
- !0
233
- );
234
- }
235
- function ke() {
236
- window.addEventListener("keyup", ne, !1), window.addEventListener("keydown", Pe, !1), window.addEventListener("resize", M), window.addEventListener("scroll", M);
237
- }
238
- function Se() {
239
- window.removeEventListener("keyup", ne), window.removeEventListener("resize", M), window.removeEventListener("scroll", M);
240
- }
241
- function _e() {
242
- const e = l("popover");
243
- e && (e.wrapper.style.display = "none");
244
- }
245
- function Q(e, o) {
246
- var b, P;
247
- let t = l("popover");
248
- t && document.body.removeChild(t.wrapper), t = Le(), document.body.appendChild(t.wrapper);
249
- const {
250
- title: i,
251
- description: d,
252
- showButtons: n,
253
- disableButtons: f,
254
- showProgress: w,
255
- nextBtnText: r = s("nextBtnText") || "Next &rarr;",
256
- prevBtnText: v = s("prevBtnText") || "&larr; Previous",
257
- progressText: g = s("progressText") || "{current} of {total}"
258
- } = o.popover || {};
259
- t.nextButton.innerHTML = r, t.previousButton.innerHTML = v, t.progress.innerHTML = g, i ? (t.title.innerHTML = i, t.title.style.display = "block") : t.title.style.display = "none", d ? (t.description.innerHTML = d, t.description.style.display = "block") : t.description.style.display = "none";
260
- const y = n || s("showButtons"), a = w || s("showProgress") || !1, p = (y == null ? void 0 : y.includes("next")) || (y == null ? void 0 : y.includes("previous")) || a;
261
- t.closeButton.style.display = y.includes("close") ? "block" : "none", p ? (t.footer.style.display = "flex", t.progress.style.display = a ? "block" : "none", t.nextButton.style.display = y.includes("next") ? "block" : "none", t.previousButton.style.display = y.includes("previous") ? "block" : "none") : t.footer.style.display = "none";
262
- const c = f || s("disableButtons") || [];
263
- c != null && c.includes("next") && (t.nextButton.disabled = !0, t.nextButton.classList.add("driver-popover-btn-disabled")), c != null && c.includes("previous") && (t.previousButton.disabled = !0, t.previousButton.classList.add("driver-popover-btn-disabled")), c != null && c.includes("close") && (t.closeButton.disabled = !0, t.closeButton.classList.add("driver-popover-btn-disabled"));
264
- const u = t.wrapper;
265
- u.style.display = "block", u.style.left = "", u.style.top = "", u.style.bottom = "", u.style.right = "", u.id = "driver-popover-content", u.setAttribute("role", "dialog"), u.setAttribute("aria-labelledby", "driver-popover-title"), u.setAttribute("aria-describedby", "driver-popover-description");
266
- const h = t.arrow;
267
- h.className = "driver-popover-arrow";
268
- const m = ((b = o.popover) == null ? void 0 : b.popoverClass) || s("popoverClass") || "";
269
- u.className = `driver-popover ${m}`.trim(), re(
270
- t.wrapper,
271
- (E) => {
272
- var B, R, W;
273
- const T = E.target, A = ((B = o.popover) == null ? void 0 : B.onNextClick) || s("onNextClick"), H = ((R = o.popover) == null ? void 0 : R.onPrevClick) || s("onPrevClick"), $ = ((W = o.popover) == null ? void 0 : W.onCloseClick) || s("onCloseClick");
274
- if (T.closest(".driver-popover-next-btn"))
275
- return A ? A(e, o, {
276
- config: s(),
277
- state: l(),
278
- driver: _()
279
- }) : L("nextClick");
280
- if (T.closest(".driver-popover-prev-btn"))
281
- return H ? H(e, o, {
282
- config: s(),
283
- state: l(),
284
- driver: _()
285
- }) : L("prevClick");
286
- if (T.closest(".driver-popover-close-btn"))
287
- return $ ? $(e, o, {
288
- config: s(),
289
- state: l(),
290
- driver: _()
291
- }) : L("closeClick");
292
- },
293
- (E) => !(t != null && t.description.contains(E)) && !(t != null && t.title.contains(E)) && typeof E.className == "string" && E.className.includes("driver-popover")
294
- ), k("popover", t);
295
- const x = ((P = o.popover) == null ? void 0 : P.onPopoverRender) || s("onPopoverRender");
296
- x && x(t, {
297
- config: s(),
298
- state: l(),
299
- driver: _()
300
- }), ae(e, o), ee(u);
301
- const C = e.classList.contains("driver-dummy-element"), S = U([u, ...C ? [] : [e]]);
302
- S.length > 0 && S[0].focus();
303
- }
304
- function se() {
305
- const e = l("popover");
306
- if (!(e != null && e.wrapper))
307
- return;
308
- const o = e.wrapper.getBoundingClientRect(), t = s("stagePadding") || 0, i = s("popoverOffset") || 0;
309
- return {
310
- width: o.width + t + i,
311
- height: o.height + t + i,
312
- realWidth: o.width,
313
- realHeight: o.height
314
- };
315
- }
316
- function Z(e, o) {
317
- const { elementDimensions: t, popoverDimensions: i, popoverPadding: d, popoverArrowDimensions: n } = o;
318
- return e === "start" ? Math.max(
319
- Math.min(
320
- t.top - d,
321
- window.innerHeight - i.realHeight - n.width
322
- ),
323
- n.width
324
- ) : e === "end" ? Math.max(
325
- Math.min(
326
- t.top - (i == null ? void 0 : i.realHeight) + t.height + d,
327
- window.innerHeight - (i == null ? void 0 : i.realHeight) - n.width
328
- ),
329
- n.width
330
- ) : e === "center" ? Math.max(
331
- Math.min(
332
- t.top + t.height / 2 - (i == null ? void 0 : i.realHeight) / 2,
333
- window.innerHeight - (i == null ? void 0 : i.realHeight) - n.width
334
- ),
335
- n.width
336
- ) : 0;
337
- }
338
- function G(e, o) {
339
- const { elementDimensions: t, popoverDimensions: i, popoverPadding: d, popoverArrowDimensions: n } = o;
340
- return e === "start" ? Math.max(
341
- Math.min(
342
- t.left - d,
343
- window.innerWidth - i.realWidth - n.width
344
- ),
345
- n.width
346
- ) : e === "end" ? Math.max(
347
- Math.min(
348
- t.left - (i == null ? void 0 : i.realWidth) + t.width + d,
349
- window.innerWidth - (i == null ? void 0 : i.realWidth) - n.width
350
- ),
351
- n.width
352
- ) : e === "center" ? Math.max(
353
- Math.min(
354
- t.left + t.width / 2 - (i == null ? void 0 : i.realWidth) / 2,
355
- window.innerWidth - (i == null ? void 0 : i.realWidth) - n.width
356
- ),
357
- n.width
358
- ) : 0;
359
- }
360
- function ae(e, o) {
361
- const t = l("popover");
362
- if (!t)
363
- return;
364
- const { align: i = "start", side: d = "left" } = (o == null ? void 0 : o.popover) || {}, n = i, f = e.id === "driver-dummy-element" ? "over" : d, w = s("stagePadding") || 0, r = se(), v = t.arrow.getBoundingClientRect(), g = e.getBoundingClientRect(), y = g.top - r.height;
365
- let a = y >= 0;
366
- const p = window.innerHeight - (g.bottom + r.height);
367
- let c = p >= 0;
368
- const u = g.left - r.width;
369
- let h = u >= 0;
370
- const m = window.innerWidth - (g.right + r.width);
371
- let x = m >= 0;
372
- const C = !a && !c && !h && !x;
373
- let S = f;
374
- if (f === "top" && a ? x = h = c = !1 : f === "bottom" && c ? x = h = a = !1 : f === "left" && h ? x = a = c = !1 : f === "right" && x && (h = a = c = !1), f === "over") {
375
- const b = window.innerWidth / 2 - r.realWidth / 2, P = window.innerHeight / 2 - r.realHeight / 2;
376
- t.wrapper.style.left = `${b}px`, t.wrapper.style.right = "auto", t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto";
377
- } else if (C) {
378
- const b = window.innerWidth / 2 - (r == null ? void 0 : r.realWidth) / 2, P = 10;
379
- t.wrapper.style.left = `${b}px`, t.wrapper.style.right = "auto", t.wrapper.style.bottom = `${P}px`, t.wrapper.style.top = "auto";
380
- } else if (h) {
381
- const b = Math.min(
382
- u,
383
- window.innerWidth - (r == null ? void 0 : r.realWidth) - v.width
384
- ), P = Z(n, {
385
- elementDimensions: g,
386
- popoverDimensions: r,
387
- popoverPadding: w,
388
- popoverArrowDimensions: v
389
- });
390
- t.wrapper.style.left = `${b}px`, t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", S = "left";
391
- } else if (x) {
392
- const b = Math.min(
393
- m,
394
- window.innerWidth - (r == null ? void 0 : r.realWidth) - v.width
395
- ), P = Z(n, {
396
- elementDimensions: g,
397
- popoverDimensions: r,
398
- popoverPadding: w,
399
- popoverArrowDimensions: v
400
- });
401
- t.wrapper.style.right = `${b}px`, t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.left = "auto", S = "right";
402
- } else if (a) {
403
- const b = Math.min(
404
- y,
405
- window.innerHeight - r.realHeight - v.width
406
- );
407
- let P = G(n, {
408
- elementDimensions: g,
409
- popoverDimensions: r,
410
- popoverPadding: w,
411
- popoverArrowDimensions: v
412
- });
413
- t.wrapper.style.top = `${b}px`, t.wrapper.style.left = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", S = "top";
414
- } else if (c) {
415
- const b = Math.min(
416
- p,
417
- window.innerHeight - (r == null ? void 0 : r.realHeight) - v.width
418
- );
419
- let P = G(n, {
420
- elementDimensions: g,
421
- popoverDimensions: r,
422
- popoverPadding: w,
423
- popoverArrowDimensions: v
424
- });
425
- t.wrapper.style.left = `${P}px`, t.wrapper.style.bottom = `${b}px`, t.wrapper.style.top = "auto", t.wrapper.style.right = "auto", S = "bottom";
426
- }
427
- C ? t.arrow.classList.add("driver-popover-arrow-none") : Ee(n, S, e);
428
- }
429
- function Ee(e, o, t) {
430
- const i = l("popover");
431
- if (!i)
432
- return;
433
- const d = t.getBoundingClientRect(), n = se(), f = i.arrow, w = n.width, r = window.innerWidth, v = d.width, g = d.left, y = n.height, a = window.innerHeight, p = d.top, c = d.height;
434
- f.className = "driver-popover-arrow";
435
- let u = o, h = e;
436
- if (o === "top" ? (g + v <= 0 ? (u = "right", h = "end") : g + v - w <= 0 && (u = "top", h = "start"), g >= r ? (u = "left", h = "end") : g + w >= r && (u = "top", h = "end")) : o === "bottom" ? (g + v <= 0 ? (u = "right", h = "start") : g + v - w <= 0 && (u = "bottom", h = "start"), g >= r ? (u = "left", h = "start") : g + w >= r && (u = "bottom", h = "end")) : o === "left" ? (p + c <= 0 ? (u = "bottom", h = "end") : p + c - y <= 0 && (u = "left", h = "start"), p >= a ? (u = "top", h = "end") : p + y >= a && (u = "left", h = "end")) : o === "right" && (p + c <= 0 ? (u = "bottom", h = "start") : p + c - y <= 0 && (u = "right", h = "start"), p >= a ? (u = "top", h = "start") : p + y >= a && (u = "right", h = "end")), !u)
437
- f.classList.add("driver-popover-arrow-none");
438
- else {
439
- f.classList.add(`driver-popover-arrow-side-${u}`), f.classList.add(`driver-popover-arrow-align-${h}`);
440
- const m = t.getBoundingClientRect(), x = f.getBoundingClientRect(), C = s("stagePadding") || 0, S = m.left - C < window.innerWidth && m.right + C > 0 && m.top - C < window.innerHeight && m.bottom + C > 0;
441
- o === "bottom" && S && (x.x > m.x && x.x + x.width < m.x + m.width ? i.wrapper.style.transform = "translateY(0)" : (f.classList.remove(`driver-popover-arrow-align-${h}`), f.classList.add("driver-popover-arrow-none"), i.wrapper.style.transform = `translateY(-${C / 2}px)`));
442
- }
443
- }
444
- function Le() {
445
- const e = document.createElement("div");
446
- e.classList.add("driver-popover");
447
- const o = document.createElement("div");
448
- o.classList.add("driver-popover-arrow");
449
- const t = document.createElement("header");
450
- t.id = "driver-popover-title", t.classList.add("driver-popover-title"), t.style.display = "none", t.innerText = "Popover Title";
451
- const i = document.createElement("div");
452
- i.id = "driver-popover-description", i.classList.add("driver-popover-description"), i.style.display = "none", i.innerText = "Popover description is here";
453
- const d = document.createElement("button");
454
- d.type = "button", d.classList.add("driver-popover-close-btn"), d.setAttribute("aria-label", "Close"), d.innerHTML = "&times;";
455
- const n = document.createElement("footer");
456
- n.classList.add("driver-popover-footer");
457
- const f = document.createElement("span");
458
- f.classList.add("driver-popover-progress-text"), f.innerText = "";
459
- const w = document.createElement("span");
460
- w.classList.add("driver-popover-navigation-btns");
461
- const r = document.createElement("button");
462
- r.type = "button", r.classList.add("driver-popover-prev-btn"), r.innerHTML = "&larr; Previous";
463
- const v = document.createElement("button");
464
- return v.type = "button", v.classList.add("driver-popover-next-btn"), v.innerHTML = "Next &rarr;", w.appendChild(r), w.appendChild(v), n.appendChild(f), n.appendChild(w), e.appendChild(d), e.appendChild(o), e.appendChild(t), e.appendChild(i), e.appendChild(n), {
465
- wrapper: e,
466
- arrow: o,
467
- title: t,
468
- description: i,
469
- footer: n,
470
- previousButton: r,
471
- nextButton: v,
472
- closeButton: d,
473
- footerButtons: w,
474
- progress: f
475
- };
476
- }
477
- function Te() {
478
- var o;
479
- const e = l("popover");
480
- e && ((o = e.wrapper.parentElement) == null || o.removeChild(e.wrapper));
481
- }
482
- function Ae(e = {}) {
483
- F(e);
484
- function o() {
485
- s("allowClose") && g();
486
- }
487
- function t() {
488
- const a = s("overlayClickBehavior");
489
- if (s("allowClose") && a === "close") {
490
- g();
491
- return;
492
- }
493
- a === "nextStep" && i();
494
- }
495
- function i() {
496
- const a = l("activeIndex"), p = s("steps") || [];
497
- if (typeof a == "undefined")
498
- return;
499
- const c = a + 1;
500
- p[c] ? v(c) : g();
501
- }
502
- function d() {
503
- const a = l("activeIndex"), p = s("steps") || [];
504
- if (typeof a == "undefined")
505
- return;
506
- const c = a - 1;
507
- p[c] ? v(c) : g();
508
- }
509
- function n(a) {
510
- (s("steps") || [])[a] ? v(a) : g();
511
- }
512
- function f() {
513
- var x;
514
- if (l("__transitionCallback"))
515
- return;
516
- const p = l("activeIndex"), c = l("__activeStep"), u = l("__activeElement");
517
- if (typeof p == "undefined" || typeof c == "undefined" || typeof l("activeIndex") == "undefined")
518
- return;
519
- const m = ((x = c.popover) == null ? void 0 : x.onPrevClick) || s("onPrevClick");
520
- if (m)
521
- return m(u, c, {
522
- config: s(),
523
- state: l(),
524
- driver: _()
525
- });
526
- d();
527
- }
528
- function w() {
529
- var m;
530
- if (l("__transitionCallback"))
531
- return;
532
- const p = l("activeIndex"), c = l("__activeStep"), u = l("__activeElement");
533
- if (typeof p == "undefined" || typeof c == "undefined")
534
- return;
535
- const h = ((m = c.popover) == null ? void 0 : m.onNextClick) || s("onNextClick");
536
- if (h)
537
- return h(u, c, {
538
- config: s(),
539
- state: l(),
540
- driver: _()
541
- });
542
- i();
543
- }
544
- function r() {
545
- l("isInitialized") || (k("isInitialized", !0), document.body.classList.add("driver-active", s("animate") ? "driver-fade" : "driver-simple"), ke(), N("overlayClick", t), N("escapePress", o), N("arrowLeftPress", f), N("arrowRightPress", w));
546
- }
547
- function v(a = 0) {
548
- var $, B, R, W, V, q, K, Y;
549
- const p = s("steps");
550
- if (!p) {
551
- console.error("No steps to drive through"), g();
552
- return;
553
- }
554
- if (!p[a]) {
555
- g();
556
- return;
557
- }
558
- k("__activeOnDestroyed", document.activeElement), k("activeIndex", a);
559
- const c = p[a], u = p[a + 1], h = p[a - 1], m = (($ = c.popover) == null ? void 0 : $.doneBtnText) || s("doneBtnText") || "Done", x = s("allowClose"), C = typeof ((B = c.popover) == null ? void 0 : B.showProgress) != "undefined" ? (R = c.popover) == null ? void 0 : R.showProgress : s("showProgress"), b = (((W = c.popover) == null ? void 0 : W.progressText) || s("progressText") || "{{current}} of {{total}}").replace("{{current}}", `${a + 1}`).replace("{{total}}", `${p.length}`), P = ((V = c.popover) == null ? void 0 : V.showButtons) || s("showButtons"), E = [
560
- "next",
561
- "previous",
562
- ...x ? ["close"] : []
563
- ].filter((ce) => !(P != null && P.length) || P.includes(ce)), T = ((q = c.popover) == null ? void 0 : q.onNextClick) || s("onNextClick"), A = ((K = c.popover) == null ? void 0 : K.onPrevClick) || s("onPrevClick"), H = ((Y = c.popover) == null ? void 0 : Y.onCloseClick) || s("onCloseClick");
564
- j({
565
- ...c,
566
- popover: {
567
- showButtons: E,
568
- nextBtnText: u ? void 0 : m,
569
- disableButtons: [...h ? [] : ["previous"]],
570
- showProgress: C,
571
- progressText: b,
572
- onNextClick: T || (() => {
573
- u ? v(a + 1) : g();
574
- }),
575
- onPrevClick: A || (() => {
576
- v(a - 1);
577
- }),
578
- onCloseClick: H || (() => {
579
- g();
580
- }),
581
- ...(c == null ? void 0 : c.popover) || {}
582
- }
583
- });
584
- }
585
- function g(a = !0) {
586
- const p = l("__activeElement"), c = l("__activeStep"), u = l("__activeOnDestroyed"), h = s("onDestroyStarted");
587
- if (a && h) {
588
- const C = !p || (p == null ? void 0 : p.id) === "driver-dummy-element";
589
- h(C ? void 0 : p, c, {
590
- config: s(),
591
- state: l(),
592
- driver: _()
593
- });
594
- return;
595
- }
596
- const m = (c == null ? void 0 : c.onDeselected) || s("onDeselected"), x = s("onDestroyed");
597
- if (document.body.classList.remove("driver-active", "driver-fade", "driver-simple"), Se(), Te(), Ce(), me(), de(), X(), p && c) {
598
- const C = p.id === "driver-dummy-element";
599
- m && m(C ? void 0 : p, c, {
600
- config: s(),
601
- state: l(),
602
- driver: _()
603
- }), x && x(C ? void 0 : p, c, {
604
- config: s(),
605
- state: l(),
606
- driver: _()
607
- });
608
- }
609
- u && u.focus();
610
- }
611
- const y = {
612
- isActive: () => l("isInitialized") || !1,
613
- refresh: M,
614
- drive: (a = 0) => {
615
- r(), v(a);
616
- },
617
- setConfig: F,
618
- setSteps: (a) => {
619
- X(), F({
620
- ...s(),
621
- steps: a
622
- });
623
- },
624
- getConfig: s,
625
- getState: l,
626
- getActiveIndex: () => l("activeIndex"),
627
- isFirstStep: () => l("activeIndex") === 0,
628
- isLastStep: () => {
629
- const a = s("steps") || [], p = l("activeIndex");
630
- return p !== void 0 && p === a.length - 1;
631
- },
632
- getActiveStep: () => l("activeStep"),
633
- getActiveElement: () => l("activeElement"),
634
- getPreviousElement: () => l("previousElement"),
635
- getPreviousStep: () => l("previousStep"),
636
- moveNext: i,
637
- movePrevious: d,
638
- moveTo: n,
639
- hasNextStep: () => {
640
- const a = s("steps") || [], p = l("activeIndex");
641
- return p !== void 0 && !!a[p + 1];
642
- },
643
- hasPreviousStep: () => {
644
- const a = s("steps") || [], p = l("activeIndex");
645
- return p !== void 0 && !!a[p - 1];
646
- },
647
- highlight: (a) => {
648
- r(), j({
649
- ...a,
650
- popover: a.popover ? {
651
- showButtons: [],
652
- showProgress: !1,
653
- progressText: "",
654
- ...a.popover
655
- } : void 0
656
- });
657
- },
658
- destroy: () => {
659
- g(!1);
660
- }
661
- };
662
- return le(y), y;
663
- }
664
- export {
665
- Ae as driver
666
- };