moey-ui 0.1.0 → 0.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/dist/moey.min.js CHANGED
@@ -1,5 +1,5 @@
1
- /*! Moey v0.1.0 | MIT License */
2
- /*! Moey v0.1.0 | MIT License */
1
+ /*! Moey v0.3.0 | MIT License */
2
+ /*! Moey v0.3.0 | MIT License */
3
3
 
4
4
  (()=>{
5
5
  'use strict';
@@ -18,6 +18,21 @@ const onEnd=(e)=>{if(e.target===el)finish();};
18
18
  el.addEventListener('transitionend',onEnd);
19
19
  setTimeout(finish,ms+50);
20
20
  }
21
+ doc.addEventListener('click',(e)=>{
22
+ const a=e.target.closest?.('a[href*="#"]');
23
+ if(!a||e.defaultPrevented||e.button||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||reducedMotion())return;
24
+ if((a.target&&a.target!=='_self')||a.hasAttribute('download')||!a.hash||a.origin!==location.origin||
25
+ a.pathname!==location.pathname||a.search!==location.search)return;
26
+ const html=doc.documentElement;
27
+ html.classList.add('mo-smooth-scroll');
28
+ let timer=0;
29
+ const off=()=>{clearTimeout(timer);removeEventListener('scrollend',off);html.classList.remove('mo-smooth-scroll');};
30
+ setTimeout(()=>{
31
+ if(e.defaultPrevented)return off();
32
+ addEventListener('scrollend',off,{once:true});
33
+ timer=setTimeout(off,1500);
34
+ });
35
+ });
21
36
  const DIALOG='dialog.dialog, dialog.drawer, dialog.sheet, dialog.palette';
22
37
  const CLOSABLE=`.alert, .toast, ${DIALOG}, .menu[popover], .popover`;
23
38
  function dismiss(el){
@@ -234,7 +249,7 @@ if(e.newState==='open')closedOnce.delete(e.target);else onDialogClosed(e.target)
234
249
  const PHONE=matchMedia('(width < 576px)');
235
250
  const sheetState=new WeakMap();
236
251
  const isSheet=(d)=>d.matches('dialog.sheet')||
237
- (PHONE.matches&&d.matches('dialog.dialog:not(.dialog-center, .dialog-fullscreen)'));
252
+ (PHONE.matches&&d.matches('dialog.dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone)'));
238
253
  const canDrag=(d)=>d.open&&d.dataset.moeyDrag!=='false'&&isSheet(d);
239
254
  function snapPoints(d){
240
255
  const full=d.offsetHeight,vh=innerHeight;
@@ -519,8 +534,8 @@ if(!menu)return;
519
534
  setupMenu(menu,trigger);
520
535
  if(isOpen(menu)||!emit(menu,'open',{trigger}))return;
521
536
  menuState.set(menu,{trigger,point});
522
- try{menu.showPopover({source:trigger});}catch{menu.showPopover();}
523
537
  const asSheet=!isSubmenu(menu)&&adaptAs(menu,trigger,menu.getAttribute('aria-label')||(trigger&&(trigger.getAttribute('aria-label')||trigger.textContent.replace(/\s+/g,' ').trim())));
538
+ try{menu.showPopover({source:trigger});}catch{menu.showPopover();}
524
539
  if(!asSheet){menu.classList.remove('is-sheet');placeMenu(menu);}
525
540
  trigger?.setAttribute('aria-expanded','true');
526
541
  const list=items(menu);
@@ -1240,6 +1255,12 @@ if(link.target)copy.target=link.target;
1240
1255
  }else copy.type='button';
1241
1256
  copy.innerHTML=`<span class="menu-item-label">${link.innerHTML}</span>`;
1242
1257
  copy.querySelectorAll('[id]').forEach((n)=>n.removeAttribute('id'));
1258
+ const lab=copy.firstElementChild;
1259
+ const lead=[...lab.childNodes].find((n)=>n.nodeType!==3||n.textContent.trim());
1260
+ if(lead&&lead.nodeType===1&&lead.matches('.mi, svg')){
1261
+ copy.prepend(lead);
1262
+ lab.innerHTML=lab.innerHTML.trim();
1263
+ }
1243
1264
  if(link.matches(':disabled, .disabled, [aria-disabled="true"]'))copy.setAttribute('aria-disabled','true');
1244
1265
  if(copy.tagName==='BUTTON'||st.tabs)copy.addEventListener('click',(e)=>{e.preventDefault();link.click();requestAnimationFrame(()=>navFit(st));});
1245
1266
  menu.append(copy);
@@ -2404,6 +2425,7 @@ function selOpen(sel){
2404
2425
  const st=selState.get(sel);
2405
2426
  if(sel.disabled||st.menu.matches(':popover-open'))return;
2406
2427
  selBuildMenu(sel);
2428
+ adaptAs(st.menu,st.btn,sheetTitle(sel));
2407
2429
  st.menu.showPopover();
2408
2430
  st.btn.setAttribute('aria-expanded','true');
2409
2431
  st.search=st.menu.querySelector('.select-search input');
@@ -2412,7 +2434,6 @@ st.search.setAttribute('role','combobox');
2412
2434
  st.search.setAttribute('aria-controls',st.menu.id);
2413
2435
  st.search.setAttribute('aria-expanded','true');
2414
2436
  }
2415
- adaptAs(st.menu,st.btn,sheetTitle(sel));
2416
2437
  selPlace(sel);
2417
2438
  const current=selItems(st).find((i)=>i.getAttribute('aria-selected')==='true'&&i.getAttribute('aria-disabled')!=='true')||selEnabled(st)[0];
2418
2439
  selSetActive(sel,current);
@@ -3643,6 +3664,14 @@ scroll.addEventListener('scroll',again,{passive:true});
3643
3664
  new ResizeObserver(()=>{st.winDirty=true;again();}).observe(scroll);
3644
3665
  }
3645
3666
  dtHead(st);
3667
+ const measure=()=>{
3668
+ const head=table.tHead,first=head?.rows[0]?.cells[0];
3669
+ if(!head||!head.offsetParent)return;
3670
+ root.style.setProperty('--mo-datatable-head',`${head.getBoundingClientRect().height}px`);
3671
+ if(first)root.style.setProperty('--mo-datatable-first',`${first.getBoundingClientRect().width}px`);
3672
+ };
3673
+ new ResizeObserver(measure).observe(table.tHead);
3674
+ new ResizeObserver(measure).observe(table);
3646
3675
  dtFillFilters(st);
3647
3676
  dtStates.set(root,st);
3648
3677
  st.url||st.fetcher?dtLoad(st):dtRender(st);
@@ -4775,8 +4804,8 @@ st.view=dpMonth(f);
4775
4804
  st.mode='days';
4776
4805
  st.picking=false;
4777
4806
  st.hover=null;
4778
- st.pop.showPopover();
4779
4807
  adaptAs(st.pop,st.btn,sheetTitle(st.range?st.host:st.inputs[0]));
4808
+ st.pop.showPopover();
4780
4809
  st.btn.setAttribute('aria-expanded','true');
4781
4810
  dpRender(st,{focus:true});
4782
4811
  }
@@ -6939,11 +6968,13 @@ const sortName=(it)=>(it.querySelector('.sort-label, .list-group-title, .kanban-
6939
6968
  const sortHorizontal=(list)=>{const its=sortItems(list);if(its.length<2)return false;const a=its[0].getBoundingClientRect(),b=its[1].getBoundingClientRect();return Math.abs(a.top-b.top)<a.height/2;};
6940
6969
  let sortFlipUntil=0;
6941
6970
  function sortFlip(lists,change){
6942
- if(reducedMotion()){change();return;}
6971
+ const relayout=()=>lists.forEach((l)=>msStates.has(l)&&msLayout(msStates.get(l)));
6972
+ if(reducedMotion()){change();relayout();return;}
6943
6973
  sortFlipUntil=performance.now()+170;
6944
6974
  const els=lists.flatMap((l)=>sortItems(l)).filter((x)=>!x.classList.contains('is-sorting'));
6945
6975
  const before=new Map(els.map((x)=>[x,x.getBoundingClientRect()]));
6946
6976
  change();
6977
+ relayout();
6947
6978
  els.forEach((x)=>{const a=before.get(x),b=x.getBoundingClientRect();if(a.left!==b.left||a.top!==b.top)x.animate([{translate:`${a.left-b.left}px ${a.top-b.top}px`},{translate:'0 0'}],{duration:160,easing:'cubic-bezier(.2,0,0,1)'});});
6948
6979
  }
6949
6980
  function sortGroup(list){const g=list.dataset.moeySortable;return g&&g!==''&&g!=='true'?[...doc.querySelectorAll(`[data-moey-sortable="${CSS.escape(g)}"]`)]:[list];}
@@ -7207,8 +7238,9 @@ function tpOpen(st){
7207
7238
  if(st.field.disabled||st.menu.matches(':popover-open'))return;
7208
7239
  tpRender(st);
7209
7240
  menuState.set(st.menu,{trigger:st.wrap});
7241
+ const asSheet=adaptAs(st.menu,st.field,sheetTitle(st.input)||'Time');
7210
7242
  st.menu.showPopover();
7211
- if(!adaptAs(st.menu,st.field,sheetTitle(st.input)||'Time'))placeMenu(st.menu);
7243
+ if(!asSheet)placeMenu(st.menu);
7212
7244
  st.field.setAttribute('aria-expanded','true');
7213
7245
  tpActive(st,st.active);
7214
7246
  }
@@ -7925,37 +7957,84 @@ new MutationObserver((muts)=>{for(const m of muts)for(const n of m.addedNodes)if
7925
7957
  };
7926
7958
  const msStates=new WeakMap();
7927
7959
  const MS_NATIVE=CSS.supports?.('grid-template-rows','masonry');
7960
+ const GRIDDY='[data-moey-griddy], [data-moey-masonry]';
7961
+ const msHeight=(it)=>{
7962
+ const c=getComputedStyle(it),px=(v)=>parseFloat(v)||0;
7963
+ const box=c.boxSizing==='border-box'?0:px(c.paddingTop)+px(c.paddingBottom)+px(c.borderTopWidth)+px(c.borderBottomWidth);
7964
+ return px(c.height)+box+px(c.marginTop)+px(c.marginBottom);
7965
+ };
7966
+ const msSpan=(it,n)=>{
7967
+ const c=getComputedStyle(it),m=/span\s+(\d+)/.exec(`${c.gridColumnStart} ${c.gridColumnEnd}`);
7968
+ if(m)return Math.min(n,+m[1]);
7969
+ return c.gridColumnEnd==='-1'?n:1;
7970
+ };
7928
7971
  function msLayout(st){
7929
7972
  const{el}=st;
7930
7973
  if(MS_NATIVE)return;
7931
- el.classList.remove('is-ready');
7932
- const gap=parseFloat(getComputedStyle(el).rowGap)||0;
7933
- el.classList.add('is-ready');
7934
- el.style.setProperty('--mo-masonry-gap-y',`${gap}px`);
7935
- [...el.children].forEach((it)=>{
7936
- if(it.hidden||getComputedStyle(it).display==='none')return;
7937
- it.style.gridRowEnd='auto';
7938
- const h=it.getBoundingClientRect().height;
7939
- it.style.gridRowEnd=`span ${Math.max(1,Math.ceil(h+gap))}`;
7940
- });
7941
- }
7942
- function setupMasonry(el){
7974
+ if(!el.classList.contains('is-ready'))el.classList.add('is-ready');
7975
+ const cs=getComputedStyle(el);
7976
+ const tracks=(cs.gridTemplateColumns.match(/[\d.]+px/g)||[]).map(parseFloat);
7977
+ const n=Math.max(1,tracks.length),colGap=parseFloat(cs.columnGap)||0,rowGap=parseFloat(cs.rowGap)||0;
7978
+ if(!tracks.length)tracks.push(el.clientWidth);
7979
+ const xs=tracks.map((_,i)=>tracks.slice(0,i).reduce((a,b)=>a+b,0)+colGap*i);
7980
+ const dense=/dense/.test(cs.gridAutoFlow);
7981
+ const padStart=parseFloat(cs.paddingInlineStart)||0,padTop=parseFloat(cs.paddingTop)||0;
7982
+ const all=[...el.children],items=all.filter((it)=>!it.hidden&&getComputedStyle(it).display!=='none');
7983
+ all.forEach((it)=>{if(!items.includes(it))st.placed.delete(it);});
7984
+ const fresh=items.filter((it)=>!st.placed.has(it));
7985
+ fresh.forEach((it)=>{st.placed.add(it);it.style.transition='none';});
7986
+ const spans=items.map((it)=>{
7987
+ const k=msSpan(it,n);
7988
+ it.style.width=`${tracks.slice(0,k).reduce((a,b)=>a+b,0)+colGap*(k-1)}px`;
7989
+ return k;
7990
+ });
7991
+ const heights=items.map(msHeight);
7992
+ const cols=Array(n).fill(0),holes=[];
7993
+ items.forEach((it,i)=>{
7994
+ const k=spans[i],h=heights[i];
7995
+ let c=-1,y=0;
7996
+ if(dense&&k===1){
7997
+ const hole=holes.filter((o)=>o.top+h<=o.limit+.5).sort((a,b)=>a.top-b.top||a.c-b.c)[0];
7998
+ if(hole){c=hole.c;y=hole.top;hole.top+=h+rowGap;if(hole.top>=hole.limit)holes.splice(holes.indexOf(hole),1);}
7999
+ }
8000
+ if(c<0){
8001
+ let best=Infinity;
8002
+ for(let j=0;j+k<=n;j++){const top=Math.max(...cols.slice(j,j+k));if(top<best-.5){best=top;c=j;}}
8003
+ y=best;
8004
+ for(let j=c;j<c+k;j++){if(dense&&cols[j]<y-.5)holes.push({c:j,top:cols[j],limit:y-rowGap});cols[j]=y+h+rowGap;}
8005
+ }
8006
+ it.style.insetInlineStart=`${xs[c]+(/^\d/.test(getComputedStyle(it).gridColumnStart)?0:padStart)}px`;
8007
+ it.style.top=`${y+padTop}px`;
8008
+ });
8009
+ const content=items.length?Math.max(...cols)-rowGap:0;
8010
+ const extra=cs.boxSizing==='border-box'?(parseFloat(cs.paddingTop)||0)+(parseFloat(cs.paddingBottom)||0)+(parseFloat(cs.borderTopWidth)||0)+(parseFloat(cs.borderBottomWidth)||0):0;
8011
+ el.style.height=`${Math.max(0,content)+extra}px`;
8012
+ if(fresh.length){void el.offsetWidth;fresh.forEach((it)=>{it.style.transition='';});}
8013
+ }
8014
+ function setupGriddy(el){
7943
8015
  if(msStates.has(el))return msStates.get(el).api;
7944
- el.classList.add('masonry');
7945
- const st={el,raf:0};
8016
+ el.classList.add('griddy');
8017
+ const st={el,raf:0,placed:new WeakSet()};
7946
8018
  const again=()=>{if(!st.raf)st.raf=requestAnimationFrame(()=>{st.raf=0;msLayout(st);});};
7947
8019
  st.ro=new ResizeObserver(again);
7948
8020
  const watch=(it)=>{st.ro.observe(it);it.querySelectorAll('img').forEach((img)=>{if(!img.complete)img.addEventListener('load',again,{once:true});});};
7949
8021
  st.ro.observe(el);
7950
8022
  [...el.children].forEach(watch);
7951
- new MutationObserver((muts)=>{muts.forEach((m)=>m.addedNodes.forEach((n)=>{if(n.nodeType===1&&n.parentElement===el)watch(n);}));again();})
7952
- .observe(el,{childList:true,attributes:true,subtree:true,attributeFilter:['hidden']});
8023
+ doc.fonts?.ready.then(again);
8024
+ new MutationObserver((muts)=>{
8025
+ let redo=false;
8026
+ muts.forEach((m)=>{
8027
+ m.addedNodes.forEach((n)=>{if(n.nodeType===1&&n.parentElement===el)watch(n);});
8028
+ if(m.type==='childList'||m.attributeName==='hidden'||m.target===el||m.target.parentElement===el)redo=true;
8029
+ });
8030
+ if(redo)msLayout(st);
8031
+ }).observe(el,{childList:true,attributes:true,subtree:true,attributeFilter:['hidden','class']});
7953
8032
  st.api={el,layout:()=>msLayout(st)};
7954
8033
  msStates.set(el,st);
7955
8034
  msLayout(st);
7956
8035
  return st.api;
7957
8036
  }
7958
- const masonry=(el)=>{el=typeof el==='string'?doc.querySelector(el):el;return el?setupMasonry(el):null;};
8037
+ const griddy=(el)=>{el=typeof el==='string'?doc.querySelector(el):el;return el?setupGriddy(el):null;};
7959
8038
  const flStates=new WeakMap();
7960
8039
  function flState(box){
7961
8040
  if(!flStates.has(box))flStates.set(box,{box,tags:new Set(),query:'',sort:null,dir:1});
@@ -8023,42 +8102,55 @@ const filter=(box,o={})=>{box=typeof box==='string'?doc.querySelector(box):box;i
8023
8102
  const ifStates=new WeakMap();
8024
8103
  function setupInfinite(box){
8025
8104
  if(ifStates.has(box))return ifStates.get(box).api;
8026
- const st={box,loads:0,busy:false,ended:false,auto:box.dataset.moeyInfinite==='button'?0:+(box.dataset.moeyInfiniteAuto??3)};
8105
+ const mode=box.dataset.moeyInfinite;
8106
+ const autoN=()=>{const v=box.dataset.moeyInfiniteAuto;return v==='all'?Infinity:Math.max(0,+(v??3)||0);};
8107
+ const st={box,loads:0,busy:false,ended:false,viaButton:false,auto:mode==='button'||mode==='once'?0:autoN()};
8027
8108
  const status=Object.assign(doc.createElement('div'),{className:'infinite-status'});
8028
8109
  status.setAttribute('role','status');
8029
- status.innerHTML='<span class="spinner spinner-sm" hidden></span><span class="infinite-text"></span><button type="button" class="btn btn-sm infinite-more" hidden>Load more</button>';
8110
+ status.innerHTML='<span class="spinner spinner-sm" hidden></span><span class="infinite-text"></span><button type="button" class="btn btn-sm infinite-more" hidden></button>';
8030
8111
  box.after(status);
8031
8112
  const sentinel=Object.assign(doc.createElement('div'),{className:'infinite-sentinel'});
8032
8113
  sentinel.setAttribute('aria-hidden','true');
8033
8114
  status.after(sentinel);
8034
8115
  const text=status.querySelector('.infinite-text'),spin=status.querySelector('.spinner'),more=status.querySelector('.infinite-more');
8116
+ const label=box.dataset.moeyInfiniteMore||'Load more';
8035
8117
  const sync=()=>{
8036
- spin.hidden=!st.busy;
8037
- more.hidden=st.busy||st.ended||st.loads<st.auto;
8038
- text.textContent=st.ended?(box.dataset.moeyInfiniteEnd||"That's everything"):st.busy?'Loading…':'';
8039
- };
8040
- const load=()=>{
8118
+ const inButton=st.busy&&st.viaButton;
8119
+ spin.hidden=!st.busy||inButton;
8120
+ more.hidden=!inButton&&(st.busy||st.ended||st.loads<st.auto);
8121
+ more.disabled=inButton;
8122
+ more.toggleAttribute('aria-busy',inButton);
8123
+ more.innerHTML=inButton?'<span class="spinner spinner-sm" aria-hidden="true"></span>Loading…':'';
8124
+ if(!inButton)more.textContent=label;
8125
+ text.textContent=st.ended?(box.dataset.moeyInfiniteEnd||"That's everything"):st.busy&&!inButton?'Loading…':'';
8126
+ };
8127
+ const load=(viaButton=false)=>{
8041
8128
  if(st.busy||st.ended)return;
8042
- st.busy=true;sync();
8129
+ st.busy=true;st.viaButton=viaButton;sync();
8043
8130
  const count=flItems(box).length;
8044
8131
  const waits=[];
8045
8132
  let ended=false;
8046
8133
  emit(box,'load',{page:st.loads+1,waitUntil:(p)=>waits.push(Promise.resolve(p)),done:()=>{ended=true;}});
8047
8134
  (waits.length?Promise.allSettled(waits):Promise.resolve()).then(()=>{
8048
- st.loads++;st.busy=false;st.ended=ended;
8135
+ const hadFocus=viaButton&&doc.activeElement===more;
8136
+ st.loads++;st.busy=false;st.viaButton=false;st.ended=ended;
8049
8137
  const added=flItems(box).length-count;
8050
8138
  if(!ended&&added<=0&&!waits.length)st.ended=true;
8051
8139
  sync();
8052
8140
  if(added>0&&!st.ended)text.textContent=`${added} more loaded`;
8053
8141
  if(flStates.has(box))flApply(flStates.get(box));
8054
8142
  else if(msStates.has(box))msLayout(msStates.get(box));
8143
+ if(hadFocus&&more.hidden){const first=flItems(box)[count];if(first){if(!first.matches('a, button, [tabindex]'))first.tabIndex=-1;first.focus({preventScroll:true});}}
8055
8144
  if(!st.ended&&st.loads<st.auto)requestAnimationFrame(()=>{const r=sentinel.getBoundingClientRect();if(r.top<innerHeight+400)load();});
8056
8145
  });
8057
8146
  };
8058
- more.addEventListener('click',()=>{st.auto=st.loads+(+(box.dataset.moeyInfiniteAuto??3)||0);load();});
8147
+ more.addEventListener('click',()=>{
8148
+ if(mode!=='button')st.auto=st.loads+autoN();
8149
+ load(true);
8150
+ });
8059
8151
  new IntersectionObserver((es)=>{if(es.some((x)=>x.isIntersecting)&&st.loads<st.auto)load();},{rootMargin:'0px 0px 400px 0px'}).observe(sentinel);
8060
8152
  sync();
8061
- st.api={el:box,load,reset:()=>{st.loads=0;st.ended=false;sync();}};
8153
+ st.api={el:box,load:()=>load(),reset:()=>{st.loads=0;st.ended=false;st.auto=mode==='button'||mode==='once'?0:autoN();sync();}};
8062
8154
  ifStates.set(box,st);
8063
8155
  return st.api;
8064
8156
  }
@@ -8067,8 +8159,6 @@ const LB_TYPES={jpg:'image',jpeg:'image',png:'image',gif:'image',webp:'image',av
8067
8159
  function lbType(src,el){
8068
8160
  const t=el?.dataset.type;
8069
8161
  if(t)return t;
8070
- if(/youtu\.?be/.test(src))return'youtube';
8071
- if(/vimeo\.com/.test(src))return'vimeo';
8072
8162
  if(src.startsWith('#'))return'inline';
8073
8163
  const ext=(src.split(/[?#]/)[0].split('.').pop()||'').toLowerCase();
8074
8164
  return LB_TYPES[ext]||(el?.querySelector('img')?'image':'iframe');
@@ -8158,8 +8248,7 @@ if(it.type==='image')return`<img class="lightbox-media" src="${esc(it.src)}"${it
8158
8248
  if(!active)return`<div class="lightbox-media lightbox-placeholder">${it.thumb?`<img src="${esc(it.thumb)}" alt="">`:''}</div>`;
8159
8249
  if(it.type==='video')return`<video class="lightbox-media" src="${esc(it.src)}" controls playsinline preload="metadata"${it.poster?` poster="${esc(it.poster)}"`:''}></video>`;
8160
8250
  if(it.type==='audio')return`<figure class="lightbox-media lightbox-audio">${it.poster?`<img src="${esc(it.poster)}" alt="">`:`<span class="lightbox-audio-icon">${lbIcon('music')}</span>`}<audio src="${esc(it.src)}" controls preload="metadata"></audio></figure>`;
8161
- if(it.type==='youtube'){const id=(it.src.match(/(?:v=|youtu\.be\/|embed\/|shorts\/)([\w-]{6,})/)||[])[1];return`<div class="lightbox-media lightbox-frame"><iframe src="https://www.youtube-nocookie.com/embed/${esc(id||'')}?autoplay=1&rel=0" title="${esc(it.caption||'Video')}" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen></iframe></div>`;}
8162
- if(it.type==='vimeo'){const id=(it.src.match(/vimeo\.com\/(?:video\/)?(\d+)/)||[])[1];return`<div class="lightbox-media lightbox-frame"><iframe src="https://player.vimeo.com/video/${esc(id||'')}?autoplay=1&dnt=1" title="${esc(it.caption||'Video')}" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div>`;}
8251
+ if(it.type==='embed')return`<div class="lightbox-media lightbox-frame"><iframe src="${esc(it.src)}" title="${esc(it.caption||'Video')}" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen></iframe></div>`;
8163
8252
  if(it.type==='inline'){const t=doc.querySelector(it.src);return`<div class="lightbox-media lightbox-html">${t?(t.tagName==='TEMPLATE'?t.innerHTML:t.innerHTML):''}</div>`;}
8164
8253
  return`<div class="lightbox-media lightbox-frame lightbox-frame-page"><iframe src="${esc(it.src)}" title="${esc(it.caption||'Content')}" loading="lazy"></iframe></div>`;
8165
8254
  }
@@ -8186,7 +8275,7 @@ const cap=box.querySelector('.lightbox-caption');
8186
8275
  cap.textContent=it.caption||'';
8187
8276
  cap.hidden=!o.caption||!it.caption;
8188
8277
  const dl=box.querySelector('[data-lb="download"]');
8189
- dl.hidden=!o.download||it.type==='youtube'||it.type==='vimeo'||it.type==='inline';
8278
+ dl.hidden=!o.download||it.type==='embed'||it.type==='inline';
8190
8279
  dl.href=it.src;
8191
8280
  box.querySelector('[data-lb="share"]').hidden=!o.share;
8192
8281
  box.querySelector('[data-lb="zoom"]').hidden=!o.zoom||it.type!=='image';
@@ -8346,7 +8435,7 @@ const b=Object.assign(doc.createElement('button'),{type:'button'});
8346
8435
  b.dataset.i=k;
8347
8436
  b.setAttribute('aria-label',`${x.caption||`Item ${k+1}`}`);
8348
8437
  if(x.thumb)b.append(Object.assign(doc.createElement('img'),{src:x.thumb,alt:''}));
8349
- else b.innerHTML=lbIcon({video:'play',audio:'music',youtube:'play',vimeo:'play'}[x.type]||'file');
8438
+ else b.innerHTML=lbIcon({video:'play',audio:'music',embed:'play'}[x.type]||'file');
8350
8439
  return b;
8351
8440
  }):[]));
8352
8441
  box.classList.remove('is-bare');
@@ -8390,13 +8479,41 @@ if(a)a.click();
8390
8479
  close:()=>lbClose(),next:()=>lbGo(lb.i+1,1),prev:()=>lbGo(lb.i-1,-1),go:(i)=>lbGo(i),
8391
8480
  get index(){return lb.i;},
8392
8481
  });
8482
+ const enterSeen=new WeakSet();
8483
+ const ENTER_SKIP='.filter-empty, .infinite-status, template, script, style';
8484
+ function enterPlay(box,nodes){
8485
+ if(reducedMotion())return;
8486
+ let i=0;
8487
+ nodes.forEach((n)=>{
8488
+ if(n.nodeType!==1||n.parentElement!==box||n.hidden||n.matches(ENTER_SKIP))return;
8489
+ n.classList.remove('is-entering');
8490
+ void n.offsetWidth;
8491
+ n.style.setProperty('--mo-enter-index',i++);
8492
+ n.classList.add('is-entering');
8493
+ clearTimeout(n.moeyEnterT);
8494
+ const done=(e)=>{if(e&&e.target!==n)return;clearTimeout(n.moeyEnterT);n.removeEventListener('animationend',done);n.classList.remove('is-entering');n.style.removeProperty('--mo-enter-index');};
8495
+ n.addEventListener('animationend',done);
8496
+ n.moeyEnterT=setTimeout(done,3000);
8497
+ });
8498
+ }
8499
+ function setupEnter(box){
8500
+ if(enterSeen.has(box))return;
8501
+ enterSeen.add(box);
8502
+ new MutationObserver((muts)=>{
8503
+ const moved=new Set(muts.flatMap((m)=>[...m.removedNodes]));
8504
+ enterPlay(box,muts.flatMap((m)=>[...m.addedNodes]).filter((n)=>!moved.has(n)));
8505
+ }).observe(box,{childList:true});
8506
+ if(box.hasAttribute('data-moey-enter-first'))enterPlay(box,[...box.children]);
8507
+ }
8508
+ const enter=(box,items)=>{box=typeof box==='string'?doc.querySelector(box):box;if(!box)return;setupEnter(box);enterPlay(box,items?[...items]:[...box.children]);};
8393
8509
  const initGallery=()=>{
8394
8510
  const scan=(root)=>{
8395
- root.querySelectorAll?.('[data-moey-masonry]').forEach(setupMasonry);
8511
+ root.querySelectorAll?.(GRIDDY).forEach(setupGriddy);
8396
8512
  root.querySelectorAll?.('[data-moey-infinite]').forEach(setupInfinite);
8513
+ root.querySelectorAll?.('[data-moey-enter]').forEach(setupEnter);
8397
8514
  };
8398
8515
  scan(doc);
8399
- new MutationObserver((muts)=>{for(const m of muts)for(const n of m.addedNodes)if(n.nodeType===1){if(n.matches('[data-moey-masonry]'))setupMasonry(n);if(n.matches('[data-moey-infinite]'))setupInfinite(n);scan(n);}})
8516
+ new MutationObserver((muts)=>{for(const m of muts)for(const n of m.addedNodes)if(n.nodeType===1){if(n.matches(GRIDDY))setupGriddy(n);if(n.matches('[data-moey-infinite]'))setupInfinite(n);if(n.matches('[data-moey-enter]'))setupEnter(n);scan(n);}})
8400
8517
  .observe(doc.body,{childList:true,subtree:true});
8401
8518
  };
8402
8519
  const plStates=new WeakMap();
@@ -8512,14 +8629,7 @@ plStates.set(el,st);
8512
8629
  return st.api;
8513
8630
  }
8514
8631
  const player=(el)=>{el=typeof el==='string'?doc.querySelector(el):el;return el?setupPlayer(el):null;};
8515
- function embedSrc(a){
8516
- const href=a.dataset.src||a.getAttribute('href')||'';
8517
- const yt=href.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{6,})/);
8518
- if(yt)return`https://www.youtube-nocookie.com/embed/${yt[1]}?autoplay=1&rel=0`;
8519
- const vm=href.match(/vimeo\.com\/(?:video\/)?(\d+)/);
8520
- if(vm)return`https://player.vimeo.com/video/${vm[1]}?autoplay=1&dnt=1`;
8521
- return href;
8522
- }
8632
+ const embedSrc=(a)=>a.dataset.src||a.getAttribute('href')||'';
8523
8633
  doc.addEventListener('click',(e)=>{
8524
8634
  const a=e.target.closest?.('[data-moey-embed]');
8525
8635
  if(!a||a.classList.contains('is-loaded')||e.metaKey||e.ctrlKey||e.shiftKey)return;
@@ -8539,5 +8649,5 @@ new MutationObserver((muts)=>{for(const m of muts)for(const n of m.addedNodes)if
8539
8649
  };
8540
8650
  const initLate=()=>{initSelects();initDatatables();initDatepickers();initComboboxes();initOtp();initCopy();initPasswords();initDirty();initFloating();initTimepickers();initCharts();initKanbans();initSplits();initCalendars();initTabbars();initSwipes();initRefresh();initSortables();initChats();initShortcuts();initMarquees();initGallery();initPlayers();};
8541
8651
  if(doc.readyState==='loading')doc.addEventListener('DOMContentLoaded',initLate);else initLate();
8542
- window.Moey=Object.freeze({version:'0.1.0',dismiss,open,close,openMenu,closeMenu,tooltip:showTip,toast,tab:(t)=>selectTab(t,{focus:false}),paginate,popover,sortTable,palette,collapse,toggle,tags,chips,dropzone,tree,notify,datatable,select,spy,carousel,datepicker,combobox,countdown,confirm:askConfirm,alert:askAlert,prompt:askPrompt,strength,clean,chart,kanban,split,calendar,swipe,refresh,sortable,timepicker,chat,shortcuts,tour,marquee,masonry,filter,infinite,lightbox,player});
8652
+ window.Moey=Object.freeze({version:'0.3.0',dismiss,open,close,openMenu,closeMenu,tooltip:showTip,toast,tab:(t)=>selectTab(t,{focus:false}),paginate,popover,sortTable,palette,collapse,toggle,tags,chips,dropzone,tree,notify,datatable,select,spy,carousel,datepicker,combobox,countdown,confirm:askConfirm,alert:askAlert,prompt:askPrompt,strength,clean,chart,kanban,split,calendar,swipe,refresh,sortable,timepicker,chat,shortcuts,tour,marquee,griddy,masonry:griddy,enter,filter,infinite,lightbox,player});
8543
8653
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moey-ui",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "A clean, mobile-first front-end framework for admin dashboards, productivity apps and websites — one stylesheet, one script, no dependencies.",
5
5
  "keywords": [
6
6
  "css",
@@ -16,7 +16,7 @@
16
16
  "oklch",
17
17
  "no-dependencies"
18
18
  ],
19
- "homepage": "https://nakedtuxedo.com",
19
+ "homepage": "https://moey.dev",
20
20
  "license": "MIT",
21
21
  "type": "module",
22
22
  "main": "dist/moey.js",
@@ -49,6 +49,7 @@
49
49
  "build": "node build.mjs",
50
50
  "build:icons": "node icons/build.mjs",
51
51
  "build:all": "node build.mjs && node icons/build.mjs",
52
- "deploy:icons": "node icons/build.mjs && node icons/deploy.mjs && npx wrangler pages deploy icons/site-dist --project-name moey-icons --branch main --commit-dirty=true"
52
+ "deploy:icons": "node icons/build.mjs && node icons/deploy.mjs && npx wrangler pages deploy icons/site-dist --project-name moey-icons --branch main --commit-dirty=true",
53
+ "build:live": "node build.mjs && node build-live.mjs"
53
54
  }
54
55
  }
package/src/css/adapt.css CHANGED
@@ -67,12 +67,24 @@ html:has(.is-sheet:popover-open) { overflow: hidden; }
67
67
  .datepicker.is-sheet .datepicker-main { margin-inline: auto; }
68
68
  .datepicker.is-sheet .datepicker-foot > .btn { min-height: 2.5rem; }
69
69
 
70
- /* Slide up (the menu's own zoom is switched off) */
70
+ /* Slide up to open, slide back down to close (the pop-up's own zoom and fade are switched off).
71
+ Closing is a transition too, so the sheet keeps its size and layout until it's gone. */
71
72
  @media (prefers-reduced-motion: no-preference) {
72
- .is-sheet[popover]:popover-open { animation: mo-adapt-up .24s cubic-bezier(.2, .8, .2, 1); }
73
- .menu.is-sheet[popover] { transition: none; }
74
- .is-sheet[popover].is-dragging { animation: none; }
75
- @keyframes mo-adapt-up { from { translate: 0 100%; } }
73
+ .is-sheet[popover],
74
+ .is-sheet[popover]::backdrop {
75
+ transition:
76
+ translate .24s cubic-bezier(.2, .8, .2, 1),
77
+ opacity .24s cubic-bezier(.2, .8, .2, 1),
78
+ overlay .24s allow-discrete,
79
+ display .24s allow-discrete;
80
+ }
81
+ .is-sheet[popover]:popover-open { animation: none; }
82
+ .is-sheet[popover]:not(:popover-open) { opacity: 1; scale: none; translate: 0 100%; }
83
+ .is-sheet[popover]:not(:popover-open)::backdrop { opacity: 0; }
84
+ @starting-style {
85
+ .is-sheet[popover]:popover-open { opacity: 1; scale: none; translate: 0 100%; }
86
+ .is-sheet[popover]:popover-open::backdrop { opacity: 0; }
87
+ }
76
88
  }
77
89
  .is-sheet[popover].is-dragging { transition: none; user-select: none; }
78
90
  .is-sheet[popover].is-settling { transition: translate .2s ease; }
package/src/css/app.css CHANGED
@@ -19,7 +19,7 @@
19
19
  --mo-sidebar-width: 16rem;
20
20
  --mo-sidebar-width-collapsed: 4.25rem;
21
21
  --mo-topbar-height: 3.75rem;
22
- --mo-topbar-bg: color-mix(in oklab, var(--mo-bg-body) 85%, transparent);
22
+ --mo-topbar-bg: var(--mo-bg-body); /* shown --mo-glass see-through (.frosted on the header: frosted glass) */
23
23
  --mo-app-padding: 1rem;
24
24
  display: flex;
25
25
  min-height: var(--mo-app-height, 100dvh);
@@ -283,8 +283,7 @@
283
283
  gap: .75rem;
284
284
  height: var(--mo-topbar-height);
285
285
  padding-inline: var(--mo-app-padding);
286
- background: var(--mo-topbar-bg);
287
- backdrop-filter: blur(12px) saturate(1.5);
286
+ background: color-mix(in oklab, var(--mo-topbar-bg) var(--mo-glass), transparent);
288
287
  --mo-badge-ring: var(--mo-bg-body); /* notification badges blend into the bar */
289
288
  }
290
289
 
package/src/css/card.css CHANGED
@@ -163,17 +163,19 @@
163
163
  <div class="stat-value">$48,210</div>
164
164
  <div class="stat-trend theme-green"><i class="mi mi-trending-up"></i> 12.4% <span>vs last month</span></div>
165
165
  </div></div> */
166
- .stat { display: grid; gap: .25rem; align-content: start; }
166
+ .stat { display: grid; gap: .25rem; align-content: start; min-width: 0; }
167
167
  .stat-label {
168
168
  display: flex;
169
+ flex-wrap: wrap; /* a narrow tile (two on a small phone): the icon moves under the label */
169
170
  align-items: center;
170
171
  gap: .5rem;
172
+ min-width: 0;
171
173
  font-size: var(--mo-font-size-sm);
172
174
  font-weight: var(--mo-font-weight-medium);
173
175
  color: var(--mo-fg-3);
174
176
  }
175
177
  .stat-value {
176
- font-size: 1.75rem;
178
+ font-size: clamp(1.125rem, 7vw, 1.75rem); /* a little smaller on small phones, so $48,210 fits two to a row at 280px */
177
179
  font-weight: var(--mo-font-weight-semibold);
178
180
  line-height: 1.2;
179
181
  letter-spacing: -.025em;
@@ -196,6 +198,7 @@
196
198
  place-items: center;
197
199
  width: 2.25rem;
198
200
  height: 2.25rem;
201
+ flex: none;
199
202
  margin-inline-start: auto;
200
203
  font-size: 1.125rem;
201
204
  color: var(--mo-theme-fg-emphasis);
package/src/css/chat.css CHANGED
@@ -66,8 +66,7 @@ html.mo-keyboard .chat-full { position: fixed; inset-inline: 0; top: var(--mo-vv
66
66
  font-size: .75rem;
67
67
  font-weight: var(--mo-font-weight-medium);
68
68
  color: var(--mo-fg-2);
69
- background: color-mix(in oklab, var(--mo-bg-2) 90%, transparent);
70
- backdrop-filter: blur(8px);
69
+ background: color-mix(in oklab, var(--mo-bg-2) var(--mo-glass), transparent);
71
70
  border-radius: 999px;
72
71
  }
73
72
 
@@ -133,7 +133,9 @@
133
133
  /* First column stays put while scrolling sideways (data-moey-sticky-first) */
134
134
  .datatable-sticky-first :is(th, td):first-child { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--mo-bg-surface); }
135
135
  .datatable-sticky-first thead th:first-child { z-index: 3; }
136
- .datatable-sticky-first.has-select :is(th, td):nth-child(2) { position: sticky; inset-inline-start: 2.75rem; z-index: 1; background: var(--mo-bg-surface); }
136
+ /* with checkboxes, the name column stays too, right after the checkbox column (moey.js measures its width) */
137
+ .datatable-sticky-first.has-select :is(th, td):nth-child(2) { position: sticky; inset-inline-start: var(--mo-datatable-first, 2.75rem); z-index: 1; background: var(--mo-bg-surface); }
138
+ .datatable-sticky-first.has-select thead th:nth-child(2) { z-index: 3; } /* the header stays above the rows scrolling under it */
137
139
 
138
140
  /* Phones: rows become cards (data-moey-stack) */
139
141
  @media (width < 640px) {
@@ -190,7 +192,7 @@
190
192
  /* Expandable details: a chevron column, and an inset panel under the open row */
191
193
  .datatable :is(th, td).datatable-expand { width: 2.75rem; padding-inline: .5rem 0; }
192
194
  .datatable tr:has(+ .datatable-detail-row) > td { border-bottom-color: transparent; }
193
- .datatable .datatable-detail-row > td { padding: 0 .75rem .75rem; background: none; }
195
+ .datatable .datatable-detail-row > td { padding: .75rem; background: none; } /* the panel is inset evenly: 12px on every side */
194
196
  .datatable-detail { padding: 1rem 1.25rem; font-size: .875rem; background: var(--mo-bg-2); border-radius: var(--mo-radius-control); }
195
197
  .datatable-detail > :last-child { margin-bottom: 0; }
196
198
  .datatable-detail .table { margin: 0; background: transparent; }
@@ -14,7 +14,9 @@
14
14
 
15
15
  moey.js: opens with data-moey-open, closes on .btn-close / data-moey-dismiss /
16
16
  outside click / Esc (data-moey-static keeps it open).
17
- On phones a .dialog becomes a bottom sheet (.dialog-center keeps it centered).
17
+ On phones a .dialog becomes a bottom sheet (.dialog-center keeps it centered,
18
+ .dialog-fullscreen-phone makes it cover the screen there instead).
19
+ A page can set --mo-dialog-bg / --mo-dialog-fg (on :root, say) to color every dialog, drawer and sheet.
18
20
  ========================================================================== */
19
21
 
20
22
  /* Lock page scrolling while a modal is open */
@@ -24,24 +26,24 @@ html:has(:is(.dialog, .drawer, .sheet)[open]:modal) { overflow: hidden; }
24
26
  :is(.dialog, .drawer, .sheet) {
25
27
  --mo-dialog-padding: 1.5rem;
26
28
  --mo-dialog-footer-padding: .875rem; /* space above & below the footer buttons */
27
- --mo-dialog-bg: var(--mo-bg-raised);
28
29
  --mo-dialog-duration: .22s;
29
30
  max-width: none;
30
31
  max-height: none;
31
32
  padding: 0;
32
- color: var(--mo-fg-body);
33
- background: var(--mo-dialog-bg);
33
+ color: var(--mo-dialog-fg, var(--mo-fg-body)); /* --mo-dialog-bg / -fg: set them on the page to recolor them all */
34
+ background: var(--mo-dialog-bg, var(--mo-bg-raised));
34
35
  border: 0;
35
36
  box-shadow: var(--mo-shadow-overlay);
36
37
  }
37
- :is(.dialog, .drawer, .sheet)[open] { display: flex; flex-direction: column; }
38
+ :is(.dialog, .drawer, .sheet) { flex-direction: column; } /* also while closing: the parts stay stacked, nothing reflows */
39
+ :is(.dialog, .drawer, .sheet)[open] { display: flex; }
38
40
  /* While a modal is open the page keeps the space of its scrollbar (no layout jump), but
39
41
  fixed boxes stop short of it — so anything edge-to-edge is sized to the whole window (100vw). */
40
42
  :is(.dialog, .drawer, .sheet)::backdrop {
41
43
  inset-inline-end: auto;
42
44
  width: 100vw;
43
45
  background: oklch(14% .01 258 / .45);
44
- backdrop-filter: blur(2px);
46
+ /* (no backdrop blur: at 2px it was barely visible, but it stalled the first opening by ~0.1s and slowed every frame) */
45
47
  opacity: calc(1 - var(--mo-sheet-drag, 0)); /* fades while a sheet is dragged down */
46
48
  }
47
49
  :is(.dialog, .drawer, .sheet):focus-visible { outline: 0; }
@@ -115,9 +117,10 @@ html:has(:is(.dialog, .drawer, .sheet)[open]:modal) { overflow: hidden; }
115
117
  /* Fullscreen: covers the whole screen (content clears the notch / home bar) */
116
118
  .dialog-fullscreen { inset-inline: 0 auto; width: 100vw; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
117
119
 
118
- /* Phones: dialogs become bottom sheets (unless .dialog-center / .dialog-fullscreen) */
120
+ /* Phones: dialogs become bottom sheets (unless .dialog-center / .dialog-fullscreen / .dialog-fullscreen-phone) */
119
121
  @media (width < 576px) {
120
- .dialog:not(.dialog-center, .dialog-fullscreen) {
122
+ .dialog-fullscreen-phone { inset-inline: 0 auto; width: 100vw; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
123
+ .dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone) {
121
124
  inset-inline: 0 auto;
122
125
  width: 100vw;
123
126
  max-width: none;
@@ -254,7 +257,7 @@ html:has(:is(.dialog, .drawer, .sheet)[open]:modal) { overflow: hidden; }
254
257
  /* closed state (also the starting point of the exit) */
255
258
  :is(.dialog, .drawer, .sheet):not([open]),
256
259
  :is(.dialog, .drawer, .sheet):not([open])::backdrop { opacity: 0; }
257
- .dialog:not([open]) { scale: .96; translate: 0 .5rem; }
260
+ /* (a dialog opens with a small rise and closes with a plain fade) */
258
261
  .drawer:not([open]) { translate: 100% 0; }
259
262
  .drawer-start:not([open]) { translate: -100% 0; }
260
263
  .drawer-top:not([open]) { translate: 0 -100%; }
@@ -279,9 +282,9 @@ html:has(:is(.dialog, .drawer, .sheet)[open]:modal) { overflow: hidden; }
279
282
  @keyframes mo-sheet-bump { 50% { translate: 0 -.5rem; } }
280
283
 
281
284
  @media (width < 576px) {
282
- .dialog:not(.dialog-center, .dialog-fullscreen):not([open]) { scale: 1; translate: 0 100%; }
285
+ .dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone):not([open]) { scale: 1; translate: 0 100%; }
283
286
  @starting-style {
284
- .dialog:not(.dialog-center, .dialog-fullscreen)[open] { scale: 1; translate: 0 100%; }
287
+ .dialog:not(.dialog-center, .dialog-fullscreen, .dialog-fullscreen-phone)[open] { scale: 1; translate: 0 100%; }
285
288
  }
286
289
  }
287
290
 
@@ -70,10 +70,9 @@
70
70
  z-index: 5;
71
71
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
72
72
  margin-top: 1rem;
73
- background: color-mix(in oklab, var(--mo-bg-raised) 90%, transparent);
73
+ background: color-mix(in oklab, var(--mo-bg-raised) var(--mo-glass), transparent); /* .frosted: frosted glass */
74
74
  border-radius: var(--mo-radius-card);
75
75
  box-shadow: 0 -.25rem 1.5rem rgb(0 0 0 / .08), 0 0 0 var(--mo-border-width) var(--mo-border-color);
76
- backdrop-filter: blur(.5rem);
77
76
  }
78
77
 
79
78
  /* Only while there are unsaved changes */