@webority/ui-elements 0.153.0 → 0.154.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/{WuiCodeBlock-DHpmEskS.js → WuiCodeBlock-cLLbSBK4.js} +1 -1
- package/dist/{WuiCommandPalette-DqHh4lH6.js → WuiCommandPalette-Dpz0DXKJ.js} +1 -1
- package/dist/{WuiDataTable-B4BYCd_s.js → WuiDataTable-8nQDiTHE.js} +1 -1
- package/dist/{WuiLeadPopup-YN4YCbOe.js → WuiLeadPopup-BmZG0Fk_.js} +1 -1
- package/dist/{WuiOnboardingChecklist-Cx-TgpBY.js → WuiOnboardingChecklist-C-nllg2h.js} +1 -1
- package/dist/{WuiResizable-DQZdQVCz.js → WuiResizable-KvfLtbCw.js} +1 -1
- package/dist/{WuiSavedViews-UaiP6YNG.js → WuiSavedViews-Br9YKOVU.js} +1 -1
- package/dist/{WuiSelect-DBPre2oe.js → WuiSelect-BPWPI07i.js} +1 -1
- package/dist/{chips-Dony2fgq.js → chips-Dr_W3avk.js} +1 -1
- package/dist/copyText-Q-QZKBmx.js +1 -0
- package/dist/dataTable-CcH1lBIM.js +1 -0
- package/dist/{drawerDiscard-C0yRSl1I.js → drawerDiscard-Cra-QhD5.js} +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lead-popup.js +1 -1
- package/dist/elements/onboarding-checklist.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/filterPopover-CaHWe9V0.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/{kanban-Dz8m-17x.js → kanban-CDaks135.js} +1 -1
- package/dist/{kanbanModel-C2IOPJ8L.js → kanbanModel-BaT75e-b.js} +1 -1
- package/dist/recents-Dcw-b5cB.js +1 -0
- package/dist/{search-C8xIzt6h.js → search-PZCXpBAn.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/{themeTransition-9LQC6fx8.js → themeTransition-CfrJtERx.js} +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +2 -2
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +2 -2
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +3 -3
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +1 -1
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-lead-popup.global.js +1 -1
- package/package.json +4 -4
- package/types/copyText.d.ts +1 -1
- package/types/themeTransition.d.ts +1 -1
- package/dist/copyText-DM5HhXjf.js +0 -1
- package/dist/dataTable-B-7oAeii.js +0 -1
- package/dist/filterPopover-D8BOb-Hz.js +0 -1
- package/dist/recents-CmLLdV8O.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n,t as r}from"./copyText-
|
|
1
|
+
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n,t as r}from"./copyText-Q-QZKBmx.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{t as a}from"./iconGlyphs.g-DPqoOoXy.js";Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]);var o=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),s=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),c=`(?![\\s\\S])`,l=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${c})`).source,u=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,s([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],d=[[`comment`,RegExp(`//[^\\n]*|${l}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,s(/* @__PURE__ */ `async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,s([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],f=[[`comment`,RegExp(`//[^\\n]*|${l}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,s(/* @__PURE__ */ `abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,s([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],p=[[`comment`,RegExp(`--[^\\n]*|${l}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,s(/* @__PURE__ */ `add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,s([`true`,`false`])],[`type`,s([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],m=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,s([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,s(/* @__PURE__ */ `awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],h=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],g=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${c})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],_={json:u,js:d,cs:f,sql:p,bash:m,http:h,css:[[`comment`,new RegExp(l)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:g,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},v=e=>Object.hasOwn(_,e),y=/* @__PURE__ */ new Map;function b(e){let t=y.get(e);if(!t){let n=_[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},y.set(e,t)}return t}function x(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function S(e,t,n=[]){let{re:r,types:i}=b(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;x(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?S(`htmlTag`,r,n):x(n,i[s]??`plain`,r),a=o.index+r.length}return x(n,`plain`,t.slice(a)),n}function C(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return S(`http`,e);let n=t[0]??``,r=S(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?S(`json`,i,r):a===`<`?S(`html`,i,r):(x(r,`plain`,i),r)}function w(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?C(n):!v(t)||t===`htmlTag`?[[`plain`,n]]:S(t,n)}function T(e,t){let n=[],r=[n];for(let[i,a]of w(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}function E(e){return Object.hasOwn(o,e)}var D=class extends i{_title;_view;_codeEl;_copyIcon;_copyText;_chrome=null;_copied=!1;_observer=null;_timer=0;_cancelFrame=null;constructor(){super();let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&E(t)?t:`text`,r=this.getAttribute(`label`)||``,i=T(this._code(),n);this._title.textContent=r||o[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>O(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(i){let a=i.createElement(`div`);a.className=`wui-code-bar`;let o=i.createElement(`button`);return o.type=`button`,o.className=`${e(`primary`,`ghost`,`sm`)} wui-code-copy`,o.dataset.wui=t,o.setAttribute(`aria-live`,`polite`),this._setCopied(!1),o.append(this._copyIcon,this._copyText),o.addEventListener(`click`,async()=>{await n(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),r))}),a.append(this._title,o),a}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=a(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function O(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}export{D as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./optionLabel-4xjXWy74.js";import{t as n}from"./textMatch-wdY7XLIc.js";var r=`[role="option"]`,i=`No results`,a=`All`,o=`Recent`,s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=`[data-group-tab]`,d=0;function f(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var p=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},m=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),h=class extends e{_path;_group;_crumbSig;_modal;_recentsId;_onModalHidden;_activeId;_lastQuery;_lastIds;_userChose;_onKeyDown;_onClick;_onMouseDown;_onMouseMove;_onInput;static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++d}`,this._onModalHidden=()=>{this._setKeyboard(!1),this._reset()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=f(e.target,l);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=f(e.target,u);if(n&&this.contains(n)){this._pickGroup(n.dataset.groupTab||null);return}let r=this._optionFrom(e.target);r&&this._select(r)},this._onMouseDown=e=>{let t=f(e.target,l),n=f(e.target,u);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`.modal`),this._modal?.addEventListener(`hidden.bs.modal`,this._onModalHidden),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??i}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
|
|
2
|
-
`),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=f(e,r);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(f(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return m(this,r,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of m(this,r,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=m(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return m(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=p(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=p(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??a,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=p(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return p(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return m(this,r,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch{}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(f(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path.at(-1)?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),i=(e?e.value:``).trim(),a=i.toLowerCase(),o=this.highlight,s=m(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path.at(-1)?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let e of this._realOptions()){let r=p(e,`.wui-cmd-item-label`,HTMLElement),s=e.dataset.label??r?.textContent??``,l=(e.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!a||s.toLowerCase().includes(a)||l.some(e=>e.toLowerCase().includes(a)),m=this._inScope(e,c)&&(!u||e.dataset.groupKey===u)&&f;e.hidden=!m,m&&d++,r&&(r.innerHTML=n(s,o?i:``).map(e=>e.match?`<mark class="wui-cmd-mark">${t(e.text)}</mark>`:t(e.text)).join(``))}let f=this._recentsHost();for(let e of m(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!m(e,r,HTMLElement).some(e=>!e.hidden));let h=p(this,`[role="listbox"]`,HTMLElement);h&&(h.hidden=d===0);let g=p(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=a&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`hidden.bs.modal`,this._onModalHidden),this._modal=null}};export{h as t};
|
|
2
|
+
`),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=f(e,r);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(f(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return m(this,r,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of m(this,r,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=m(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return m(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=p(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=p(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??a,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=p(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return p(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return m(this,r,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(f(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path.at(-1)?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),i=(e?e.value:``).trim(),a=i.toLowerCase(),o=this.highlight,s=m(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path.at(-1)?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let e of this._realOptions()){let r=p(e,`.wui-cmd-item-label`,HTMLElement),s=e.dataset.label??r?.textContent??``,l=(e.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!a||s.toLowerCase().includes(a)||l.some(e=>e.toLowerCase().includes(a)),m=this._inScope(e,c)&&(!u||e.dataset.groupKey===u)&&f;e.hidden=!m,m&&d++,r&&(r.innerHTML=n(s,o?i:``).map(e=>e.match?`<mark class="wui-cmd-mark">${t(e.text)}</mark>`:t(e.text)).join(``))}let f=this._recentsHost();for(let e of m(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!m(e,r,HTMLElement).some(e=>!e.hidden));let h=p(this,`[role="listbox"]`,HTMLElement);h&&(h.hidden=d===0);let g=p(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=a&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`hidden.bs.modal`,this._onModalHidden),this._modal=null}};export{h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,M as t,S as n,T as r,_ as i,b as a,c as o,g as s,h as c,i as l,j as u,r as d,t as f}from"./dataTable-B-7oAeii.js";import{t as p}from"./dom-Do1pAA12.js";import{t as m}from"./elementBase-Cxeyx0tU.js";var h=`.wui-col-resize`,g=`.wui-group-row, .wui-virtual-spacer`,_=`.wui-select-cell, .wui-expand-cell`,v=`<svg class="wui-icon" data-icon="chevron-down" data-wui="AppIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`;function y(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function b(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var x=e=>{let t=p(e,h);return t instanceof HTMLElement?t:null},S=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),C=class extends m{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=x(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=r(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(t,r){let i=this._headCells(t),o=i.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(_)?`lead`:null});if(!o.some(e=>e===`start`||e===`end`))return;let s=e(o);s.forEach((e,t)=>{e&&this._ro?.observe(y(i[t]))});let c=e=>y(i[e]).getBoundingClientRect().width,u=0;s.forEach((e,r)=>{e?.side===`start`&&(this._setVar(t,n(`start`,e.ordinal),u),u+=c(r))}),u=0;for(let e=s.length-1;e>=0;e--){let r=s[e];r?.side===`end`&&(this._setVar(t,n(`end`,r.ordinal),u),u+=c(e))}if(r)for(let e of t.rows)e.matches(`${g}, .wui-row-expanded`)||e.cells.length!==i.length||s.forEach((t,n)=>{if(!t)return;let r=y(e.cells[n]);r.classList.contains(`wui-pin-${t.side}`)||r.classList.add(`wui-pin-${t.side}`),t.edge&&!r.classList.contains(`wui-pin-${t.side}-edge`)&&r.classList.add(`wui-pin-${t.side}-edge`);let i=a(t.side,t.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(l,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(_))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(h))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(f)),r.setAttribute(`tabindex`,`0`);let i=(e.textContent??``).trim();r.setAttribute(`aria-label`,d.resize(i)),i&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,i),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(g)&&!S(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(h);n&&this._handleValue(n,c(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(_))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=c(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(h);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,d.width(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(y(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let n=e.dataset.key;n&&(this._widths={...this._widths,[n]:Number.parseFloat(e.style.width)},t(this.getAttribute(`view-key`),this._widths))}_reset(e){let n=this._table;if(!e||!n)return;let r=this._ensureFrozen(n);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...n}=this._widths;this._widths=n,t(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(n,r),this._pins(n,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=x(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=x(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=y(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(h)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=p(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(n instanceof HTMLTableRowElement)||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(g));if(o.some(S))return;let c=this.ownerDocument,l=/* @__PURE__ */ new Map;for(let e of a.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&l.set(e.dataset.groupKey,e);let u=i(o,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,this._groupOrder);this._groupOrder=u.map(e=>e.key);let f=c.createDocumentFragment(),p=u.map(e=>{let t=l.get(e.key)??this._groupRow(c,e.key);return l.delete(e.key),b(t.querySelector(`.wui-group-cell`),HTMLTableCellElement).colSpan=n.length,b(t.querySelector(`.wui-group-count`),HTMLElement).textContent=s(e.items.length),b(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${d.rows(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of p)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=v;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(g);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);y(this._top.cells[0]).colSpan=t,y(this._bottom.cells[0]).colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=u({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),a=this._range;if(a&&a.start===i.start&&a.end===i.end)return;let o=a?Math.min(a.start,i.start):0,s=a?Math.max(a.end,i.end):this._items.length;for(let e=o;e<s;e++){let t=e<i.start||e>=i.end,n=y(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i;let c=y(this._top),l=y(this._bottom);c.hidden=i.before===0,l.hidden=i.after===0,y(c.cells[0]).style.height=`${i.before}px`,y(l.cells[0]).style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?o.compact:e.classList.contains(`wui-table-cozy`)?o.cozy:o.comfortable}};export{C as t};
|
|
1
|
+
import{C as e,M as t,S as n,T as r,_ as i,b as a,c as o,g as s,h as c,i as l,j as u,r as d,t as f}from"./dataTable-CcH1lBIM.js";import{t as p}from"./dom-Do1pAA12.js";import{t as m}from"./elementBase-Cxeyx0tU.js";var h=`.wui-col-resize`,g=`.wui-group-row, .wui-virtual-spacer`,_=`.wui-select-cell, .wui-expand-cell`,v=`<svg class="wui-icon" data-icon="chevron-down" data-wui="AppIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`;function y(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function b(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var x=e=>{let t=p(e,h);return t instanceof HTMLElement?t:null},S=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),C=class extends m{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=x(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=r(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(t,r){let i=this._headCells(t),o=i.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(_)?`lead`:null});if(!o.some(e=>e===`start`||e===`end`))return;let s=e(o);s.forEach((e,t)=>{e&&this._ro?.observe(y(i[t]))});let c=e=>y(i[e]).getBoundingClientRect().width,u=0;s.forEach((e,r)=>{e?.side===`start`&&(this._setVar(t,n(`start`,e.ordinal),u),u+=c(r))}),u=0;for(let e=s.length-1;e>=0;e--){let r=s[e];r?.side===`end`&&(this._setVar(t,n(`end`,r.ordinal),u),u+=c(e))}if(r)for(let e of t.rows)e.matches(`${g}, .wui-row-expanded`)||e.cells.length!==i.length||s.forEach((t,n)=>{if(!t)return;let r=y(e.cells[n]);r.classList.contains(`wui-pin-${t.side}`)||r.classList.add(`wui-pin-${t.side}`),t.edge&&!r.classList.contains(`wui-pin-${t.side}-edge`)&&r.classList.add(`wui-pin-${t.side}-edge`);let i=a(t.side,t.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(l,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(_))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(h))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(f)),r.setAttribute(`tabindex`,`0`);let i=(e.textContent??``).trim();r.setAttribute(`aria-label`,d.resize(i)),i&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,i),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(g)&&!S(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(h);n&&this._handleValue(n,c(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(_))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=c(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(h);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,d.width(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(y(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let n=e.dataset.key;n&&(this._widths={...this._widths,[n]:Number.parseFloat(e.style.width)},t(this.getAttribute(`view-key`),this._widths))}_reset(e){let n=this._table;if(!e||!n)return;let r=this._ensureFrozen(n);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...n}=this._widths;this._widths=n,t(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(n,r),this._pins(n,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=x(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=x(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(e.key===`Enter`||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=y(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(h)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=p(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(n instanceof HTMLTableRowElement)||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(g));if(o.some(S))return;let c=this.ownerDocument,l=/* @__PURE__ */ new Map;for(let e of a.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&l.set(e.dataset.groupKey,e);let u=i(o,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,this._groupOrder);this._groupOrder=u.map(e=>e.key);let f=c.createDocumentFragment(),p=u.map(e=>{let t=l.get(e.key)??this._groupRow(c,e.key);return l.delete(e.key),b(t.querySelector(`.wui-group-cell`),HTMLTableCellElement).colSpan=n.length,b(t.querySelector(`.wui-group-count`),HTMLElement).textContent=s(e.items.length),b(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${d.rows(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of p)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=v;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(g);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);y(this._top.cells[0]).colSpan=t,y(this._bottom.cells[0]).colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=u({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),a=this._range;if(a&&a.start===i.start&&a.end===i.end)return;let o=a?Math.min(a.start,i.start):0,s=a?Math.max(a.end,i.end):this._items.length;for(let e=o;e<s;e++){let t=e<i.start||e>=i.end,n=y(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i;let c=y(this._top),l=y(this._bottom);c.hidden=i.before===0,l.hidden=i.after===0,y(c.cells[0]).style.height=`${i.before}px`,y(l.cells[0]).style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?o.compact:e.classList.contains(`wui-table-cozy`)?o.cozy:o.comfortable}};export{C as t};
|
|
@@ -379,4 +379,4 @@ textarea.wlp-input {
|
|
|
379
379
|
<label class="wlp-label" for="${n}">${D(i)}${o}</label>
|
|
380
380
|
${l}
|
|
381
381
|
<p class="wlp-error" id="${r}" hidden></p>
|
|
382
|
-
</div>`}_wire(){let e=this._dialog();e.addEventListener(`cancel`,e=>{e.preventDefault(),this.close(`escape`)}),e.addEventListener(`click`,t=>{t.target===e&&this.close(`backdrop`)}),e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`||!this._modal)return;let n=Array.from(e.querySelectorAll(d)).filter(e=>e instanceof HTMLElement&&!(`disabled`in e&&e.disabled===!0)&&e.getClientRects().length>0);if(!n.length)return;let r=this._root().activeElement,i=r instanceof HTMLElement?n.indexOf(r):-1;t.preventDefault();let a=n[i===-1?t.shiftKey?n.length-1:0:(i+(t.shiftKey?-1:1)+n.length)%n.length];if(!a)throw Error(`tab stop missing`);a.focus()});for(let t of e.querySelectorAll(`[data-wlp-close]`))t.addEventListener(`click`,()=>this.close(`dismiss`));e.querySelector(`[data-wlp-done]`)?.addEventListener(`click`,()=>this.close(`submitted`)),e.querySelector(`[data-wlp-secondary]`)?.addEventListener(`click`,()=>this.close(`secondary`)),N(e.querySelector(`[data-wlp-form]`),HTMLFormElement,`form`).addEventListener(`submit`,e=>this._onSubmit(e))}_showForm(){let e=this._root();N(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!1,N(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`).hidden=!0}_showSuccess(){let e=this._root();N(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!0;let t=N(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`);t.hidden=!1,N(e.querySelector(`[data-wlp-success-title]`),HTMLElement,`success title`).focus()}_setFieldError(e,t){let n=this._root(),r=N(n.querySelector(`[data-wlp-input="${e}"]`),HTMLElement,`${e} field`),i=N(n.querySelector(`#${this._uid}-e-${e}`),HTMLElement,`${e} error`);return i.textContent=t,i.hidden=!t,t?(r.setAttribute(`aria-invalid`,`true`),r.setAttribute(`aria-describedby`,i.id)):(r.removeAttribute(`aria-invalid`),r.removeAttribute(`aria-describedby`)),r}_validate(){let e=new Set(this._requiredKeys()),t=null,n={};for(let r of this._fieldKeys()){let i=this._root().querySelector(`[data-wlp-input="${r}"]`);if(!(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement))throw Error(`${r} field missing`);let a=r===`consent`&&i instanceof HTMLInputElement?i.checked:i.value.trim();n[r]=a;let o=``;!a&&e.has(r)?o=r===`consent`?b:`Enter your ${this._label(r).toLowerCase()}`:r===`email`&&a&&!p.test(String(a))&&(o=`Enter a valid email address`);let s=this._setFieldError(r,o);o&&!t&&(t=s)}return t?(t.focus(),null):n}_setBusy(e){this._posting=e;let t=N(this._root().querySelector(`[data-wlp-form]`),HTMLElement,`form`);e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`),N(this._root().querySelector(`[data-wlp-submit]`),HTMLButtonElement,`submit button`).disabled=e}_fail(e,t){this._setBusy(!1);let n=N(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`);n.textContent=t,n.hidden=!t,this._emit(`wui-lead-popup-error`,{message:t,reason:e})}async _onSubmit(e){if(e.preventDefault(),this._posting)return;N(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`).hidden=!0;let t=this._validate();t&&!this.preview&&await this._post(t)}async _post(e){let n=globalThis.WeborityPublicForms;if(!n){C(`gate`,`[@webority/ui-elements] <wui-lead-popup> needs window.WeborityPublicForms. Load Webority.Security.Razor's public-form.js.`),this._fail(`gate`,this._text(`error-text`,y));return}let r=this._text(`error-text`,y),i=this._text(`public-form`);this._setBusy(!0);let a,o;try{a=await n.session(),o=await n.mintToken(i)}catch(e){this._fail(`gate`,A(e,r));return}let s=this._root(),c=new FormData;for(let t of this._fieldKeys())c.append(this._postedName(t),String(e[t]));c.set(g,a.token),c.set(_,a.formStamp),c.set(v,o),c.set(h,N(s.querySelector(`[data-wlp-honeypot]`),HTMLInputElement,`honeypot`).value),this._emit(`wui-lead-popup-before-submit`,{formData:c});let l;try{l=await fetch(this._text(`action`),{method:`POST`,body:c,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}})}catch{this._fail(`network`,r);return}let u;try{u=await this._readJson(l)}catch(e){t(`<wui-lead-popup> could not read the response body`,e),this._fail(`server`,r);return}if(l.ok)this._succeed(e,u);else{let e=typeof u==`object`&&u&&`detail`in u&&typeof u.detail==`string`?u.detail.trim():``;this._fail(`server`,e||r)}}async _readJson(e){return e.json()}_succeed(e,t){this._setBusy(!1),this._remember(`submitted`),this._emit(`wui-lead-popup-submitted`,{values:e,response:t}),this._showSuccess();let n=this._number(`success-close-seconds`,5);n>0&&(this._closeTimer=setTimeout(()=>this.close(`submitted`),n*1e3))}_arm(){if(this._armed)return;this._armed=!0;let e=this._triggers();if(!e.length)return;this._session=this._loadSession();let t=location.pathname+location.search;if(this._session.pages.includes(t)||this._session.pages.push(t),this._saveSession(),e.includes(`exit`)&&(document.documentElement.addEventListener(`mouseleave`,this._onMouseLeave),document.addEventListener(`visibilitychange`,this._onVisibility)),e.includes(`delay`)){let e=Math.max(0,this._number(`delay-seconds`,30)*1e3-(Date.now()-this._session.start));this._delayTimer=setTimeout(()=>this.open(`delay`),e)}e.includes(`scroll`)&&(window.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackScroll()),e.includes(`pages`)&&this._session.pages.length>this._number(`pages-viewed`,2)&&this.open(`pages`)}_disarm(){this._armed=!1,clearTimeout(this._delayTimer??void 0),clearTimeout(this._closeTimer??void 0),document.documentElement.removeEventListener(`mouseleave`,this._onMouseLeave),document.removeEventListener(`visibilitychange`,this._onVisibility),window.removeEventListener(`scroll`,this._onScroll)}_trackScroll(){let e=document.documentElement.scrollHeight;if(this._session&&e>0){let t=(window.scrollY+window.innerHeight)/e*100;t>this._session.maxScroll&&(this._session.maxScroll=t,this._saveSession()),this._session.maxScroll>this._number(`scroll-percent`,50)&&this.open(`scroll`)}}_fine(){return typeof matchMedia!=`function`||matchMedia(`(pointer: fine)`).matches}_engaged(){let e=this._session;return e?Date.now()-e.start>this._number(`delay-seconds`,30)*1e3||e.maxScroll>this._number(`scroll-percent`,50)||e.pages.length>this._number(`pages-viewed`,2):!1}_sessionKey(){return`wui-lead-popup:${this.getAttribute(`storage-key`)}`}_loadSession(){let e={start:Date.now(),maxScroll:0,pages:[]};try{let e=sessionStorage.getItem(this._sessionKey());if(e){let t=JSON.parse(e);if(Number.isFinite(t.start)&&Number.isFinite(t.maxScroll)&&Array.isArray(t.pages))return t}}catch{return e}return e}_saveSession(){try{sessionStorage.setItem(this._sessionKey(),JSON.stringify(this._session))}catch{}}_readMemory(){let e=this.getAttribute(`storage-key`);if(!e)return null;try{let t=JSON.parse(localStorage.getItem(e)??`null`);if((t?.state===`shown`||t?.state===`submitted`)&&Number.isFinite(Date.parse(t.at)))return t}catch{return null}return null}_blocked(){let e=this._readMemory();if(!e)return!1;let t=e.state===`shown`?this._number(`dismiss-days`,30):this._number(`submitted-days`,365);return Date.now()-Date.parse(e.at)<t*m}_remember(e){let t=this.getAttribute(`storage-key`);if(t&&!this.preview)try{localStorage.setItem(t,JSON.stringify({state:e,at:(/* @__PURE__ */ new Date()).toISOString()}))}catch{}}};export{P as t};
|
|
382
|
+
</div>`}_wire(){let e=this._dialog();e.addEventListener(`cancel`,e=>{e.preventDefault(),this.close(`escape`)}),e.addEventListener(`click`,t=>{t.target===e&&this.close(`backdrop`)}),e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`||!this._modal)return;let n=Array.from(e.querySelectorAll(d)).filter(e=>e instanceof HTMLElement&&!(`disabled`in e&&e.disabled===!0)&&e.getClientRects().length>0);if(!n.length)return;let r=this._root().activeElement,i=r instanceof HTMLElement?n.indexOf(r):-1;t.preventDefault();let a=n[i===-1?t.shiftKey?n.length-1:0:(i+(t.shiftKey?-1:1)+n.length)%n.length];if(!a)throw Error(`tab stop missing`);a.focus()});for(let t of e.querySelectorAll(`[data-wlp-close]`))t.addEventListener(`click`,()=>this.close(`dismiss`));e.querySelector(`[data-wlp-done]`)?.addEventListener(`click`,()=>this.close(`submitted`)),e.querySelector(`[data-wlp-secondary]`)?.addEventListener(`click`,()=>this.close(`secondary`)),N(e.querySelector(`[data-wlp-form]`),HTMLFormElement,`form`).addEventListener(`submit`,e=>this._onSubmit(e))}_showForm(){let e=this._root();N(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!1,N(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`).hidden=!0}_showSuccess(){let e=this._root();N(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!0;let t=N(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`);t.hidden=!1,N(e.querySelector(`[data-wlp-success-title]`),HTMLElement,`success title`).focus()}_setFieldError(e,t){let n=this._root(),r=N(n.querySelector(`[data-wlp-input="${e}"]`),HTMLElement,`${e} field`),i=N(n.querySelector(`#${this._uid}-e-${e}`),HTMLElement,`${e} error`);return i.textContent=t,i.hidden=!t,t?(r.setAttribute(`aria-invalid`,`true`),r.setAttribute(`aria-describedby`,i.id)):(r.removeAttribute(`aria-invalid`),r.removeAttribute(`aria-describedby`)),r}_validate(){let e=new Set(this._requiredKeys()),t=null,n={};for(let r of this._fieldKeys()){let i=this._root().querySelector(`[data-wlp-input="${r}"]`);if(!(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement))throw Error(`${r} field missing`);let a=r===`consent`&&i instanceof HTMLInputElement?i.checked:i.value.trim();n[r]=a;let o=``;!a&&e.has(r)?o=r===`consent`?b:`Enter your ${this._label(r).toLowerCase()}`:r===`email`&&a&&!p.test(String(a))&&(o=`Enter a valid email address`);let s=this._setFieldError(r,o);o&&!t&&(t=s)}return t?(t.focus(),null):n}_setBusy(e){this._posting=e;let t=N(this._root().querySelector(`[data-wlp-form]`),HTMLElement,`form`);e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`),N(this._root().querySelector(`[data-wlp-submit]`),HTMLButtonElement,`submit button`).disabled=e}_fail(e,t){this._setBusy(!1);let n=N(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`);n.textContent=t,n.hidden=!t,this._emit(`wui-lead-popup-error`,{message:t,reason:e})}async _onSubmit(e){if(e.preventDefault(),this._posting)return;N(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`).hidden=!0;let t=this._validate();t&&!this.preview&&await this._post(t)}async _post(e){let n=globalThis.WeborityPublicForms;if(!n){C(`gate`,`[@webority/ui-elements] <wui-lead-popup> needs window.WeborityPublicForms. Load Webority.Security.Razor's public-form.js.`),this._fail(`gate`,this._text(`error-text`,y));return}let r=this._text(`error-text`,y),i=this._text(`public-form`);this._setBusy(!0);let a,o;try{a=await n.session(),o=await n.mintToken(i)}catch(e){this._fail(`gate`,A(e,r));return}let s=this._root(),c=new FormData;for(let t of this._fieldKeys())c.append(this._postedName(t),String(e[t]));c.set(g,a.token),c.set(_,a.formStamp),c.set(v,o),c.set(h,N(s.querySelector(`[data-wlp-honeypot]`),HTMLInputElement,`honeypot`).value),this._emit(`wui-lead-popup-before-submit`,{formData:c});let l;try{l=await fetch(this._text(`action`),{method:`POST`,body:c,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}})}catch{this._fail(`network`,r);return}let u;try{u=await this._readJson(l)}catch(e){t(`<wui-lead-popup> could not read the response body`,e),this._fail(`server`,r);return}if(l.ok)this._succeed(e,u);else{let e=typeof u==`object`&&u&&`detail`in u&&typeof u.detail==`string`?u.detail.trim():``;this._fail(`server`,e||r)}}async _readJson(e){return e.json()}_succeed(e,t){this._setBusy(!1),this._remember(`submitted`),this._emit(`wui-lead-popup-submitted`,{values:e,response:t}),this._showSuccess();let n=this._number(`success-close-seconds`,5);n>0&&(this._closeTimer=setTimeout(()=>this.close(`submitted`),n*1e3))}_arm(){if(this._armed)return;this._armed=!0;let e=this._triggers();if(!e.length)return;this._session=this._loadSession();let t=location.pathname+location.search;if(this._session.pages.includes(t)||this._session.pages.push(t),this._saveSession(),e.includes(`exit`)&&(document.documentElement.addEventListener(`mouseleave`,this._onMouseLeave),document.addEventListener(`visibilitychange`,this._onVisibility)),e.includes(`delay`)){let e=Math.max(0,this._number(`delay-seconds`,30)*1e3-(Date.now()-this._session.start));this._delayTimer=setTimeout(()=>this.open(`delay`),e)}e.includes(`scroll`)&&(window.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackScroll()),e.includes(`pages`)&&this._session.pages.length>this._number(`pages-viewed`,2)&&this.open(`pages`)}_disarm(){this._armed=!1,clearTimeout(this._delayTimer??void 0),clearTimeout(this._closeTimer??void 0),document.documentElement.removeEventListener(`mouseleave`,this._onMouseLeave),document.removeEventListener(`visibilitychange`,this._onVisibility),window.removeEventListener(`scroll`,this._onScroll)}_trackScroll(){let e=document.documentElement.scrollHeight;if(this._session&&e>0){let t=(window.scrollY+window.innerHeight)/e*100;t>this._session.maxScroll&&(this._session.maxScroll=t,this._saveSession()),this._session.maxScroll>this._number(`scroll-percent`,50)&&this.open(`scroll`)}}_fine(){return typeof matchMedia!=`function`||matchMedia(`(pointer: fine)`).matches}_engaged(){let e=this._session;return e?Date.now()-e.start>this._number(`delay-seconds`,30)*1e3||e.maxScroll>this._number(`scroll-percent`,50)||e.pages.length>this._number(`pages-viewed`,2):!1}_sessionKey(){return`wui-lead-popup:${this.getAttribute(`storage-key`)}`}_loadSession(){let e={start:Date.now(),maxScroll:0,pages:[]};try{let e=sessionStorage.getItem(this._sessionKey());if(e){let t=JSON.parse(e);if(Number.isFinite(t.start)&&Number.isFinite(t.maxScroll)&&Array.isArray(t.pages))return t}}catch{return e}return e}_saveSession(){try{sessionStorage.setItem(this._sessionKey(),JSON.stringify(this._session))}catch(e){if(!(e instanceof DOMException))throw e}}_readMemory(){let e=this.getAttribute(`storage-key`);if(!e)return null;try{let t=JSON.parse(localStorage.getItem(e)??`null`);if((t?.state===`shown`||t?.state===`submitted`)&&Number.isFinite(Date.parse(t.at)))return t}catch{return null}return null}_blocked(){let e=this._readMemory();if(!e)return!1;let t=e.state===`shown`?this._number(`dismiss-days`,30):this._number(`submitted-days`,365);return Date.now()-Date.parse(e.at)<t*m}_remember(e){let t=this.getAttribute(`storage-key`);if(t&&!this.preview)try{localStorage.setItem(t,JSON.stringify({state:e,at:(/* @__PURE__ */ new Date()).toISOString()}))}catch(e){if(!(e instanceof DOMException))throw e}}};export{P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=`.wui-onboarding-card`,n=`.wui-onboarding-steps`,r=`.wui-onboarding-toggle`,i=`.wui-onboarding-dismiss`,a=`.wui-onboarding-restore`,o=`wui-onboarding:`,s=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},c=class extends e{constructor(){super(),this._onClick=e=>{let t=e.target instanceof Element?e.target:null;t&&(t.closest(i)?this.dismiss():t.closest(a)?this.restore():t.closest(r)&&this.toggle())}}connectedCallback(){this.addEventListener(`click`,this._onClick),this._stored()===`dismissed`&&this._setDismissed(!0)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick)}get dismissed(){return s(this,t)?.hidden===!0}get collapsed(){return s(this,n)?.hidden===!0}dismiss(){this.dismissed||(this._setDismissed(!0),this._store(`dismissed`),s(this,a)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:dismiss`,{bubbles:!0})))}restore(){this.dismissed&&(this._setDismissed(!1),this._store(null),s(this,r)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:restore`,{bubbles:!0})))}toggle(){let e=s(this,n);if(!e)return;let t=!e.hidden;e.hidden=t,this.querySelector(r)?.setAttribute(`aria-expanded`,String(!t)),this.dispatchEvent(new CustomEvent(`wui:onboarding:collapse`,{bubbles:!0,detail:{collapsed:t}}))}_setDismissed(e){let n=s(this,t),r=s(this,a);n&&(n.hidden=e),r&&(r.hidden=!e)}_key(){let e=this.getAttribute(`storage-key`);return e?o+e:null}_stored(){let e=this._key();if(!e)return null;try{return window.localStorage.getItem(e)}catch{return null}}_store(e){let t=this._key();if(t)try{e?window.localStorage.setItem(t,e):window.localStorage.removeItem(t)}catch{}}};export{c as t};
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=`.wui-onboarding-card`,n=`.wui-onboarding-steps`,r=`.wui-onboarding-toggle`,i=`.wui-onboarding-dismiss`,a=`.wui-onboarding-restore`,o=`wui-onboarding:`,s=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},c=class extends e{constructor(){super(),this._onClick=e=>{let t=e.target instanceof Element?e.target:null;t&&(t.closest(i)?this.dismiss():t.closest(a)?this.restore():t.closest(r)&&this.toggle())}}connectedCallback(){this.addEventListener(`click`,this._onClick),this._stored()===`dismissed`&&this._setDismissed(!0)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick)}get dismissed(){return s(this,t)?.hidden===!0}get collapsed(){return s(this,n)?.hidden===!0}dismiss(){this.dismissed||(this._setDismissed(!0),this._store(`dismissed`),s(this,a)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:dismiss`,{bubbles:!0})))}restore(){this.dismissed&&(this._setDismissed(!1),this._store(null),s(this,r)?.focus(),this.dispatchEvent(new CustomEvent(`wui:onboarding:restore`,{bubbles:!0})))}toggle(){let e=s(this,n);if(!e)return;let t=!e.hidden;e.hidden=t,this.querySelector(r)?.setAttribute(`aria-expanded`,String(!t)),this.dispatchEvent(new CustomEvent(`wui:onboarding:collapse`,{bubbles:!0,detail:{collapsed:t}}))}_setDismissed(e){let n=s(this,t),r=s(this,a);n&&(n.hidden=e),r&&(r.hidden=!e)}_key(){let e=this.getAttribute(`storage-key`);return e?o+e:null}_stored(){let e=this._key();if(!e)return null;try{return window.localStorage.getItem(e)}catch{return null}}_store(e){let t=this._key();if(t)try{e?window.localStorage.setItem(t,e):window.localStorage.removeItem(t)}catch(e){if(!(e instanceof DOMException))throw e}}};export{c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=`wui-resizable-panel`,n=`wui-resizable-handle`,r=5,i=20,a=10,o=`wui-resizable:`,s=.001,c=0,l=e=>e.reduce((e,t)=>e+t,0),u=(e,t,n)=>Math.min(Math.max(e,t),n),d=e=>Math.round(e*10)/10,f=(e,t)=>e[t]??NaN,p=(e,t)=>e.length===t.length&&e.every((e,n)=>Math.abs(e-f(t,n))<s);function m(e,t,n){let r=e.map((e,r)=>u(e,f(t,r),f(n,r)));for(let e=0;e<r.length;e++){let e=100-l(r);if(Math.abs(e)<s)break;let i=r.map((r,i)=>e>0?f(n,i)-r:r-f(t,i)),a=l(i);if(a<=0)break;let o=Math.min(Math.abs(e),a);r=r.map((t,n)=>t+Math.sign(e)*o*f(i,n)/a)}return r}function h(e,t,n,r){let i=f(e,t)+f(e,t+1);return[Math.max(f(n,t),i-f(r,t+1)),Math.min(f(r,t),i-f(n,t+1))]}function g(e,t,n,r,i){let[a,o]=h(e,t,r,i);if(a>o)return e;let s=f(e,t)+f(e,t+1),c=u(f(e,t)+n,a,o),l=[...e];return l[t]=c,l[t+1]=s-c,l}function _(e){let t=e.filter(e=>e===null).length,n=l(e.filter(e=>e!==null));if(t>0&&n<100)return e.map(e=>e??(100-n)/t);let r=e.map(e=>e??1),i=l(r);return r.map(e=>e*100/i)}var v=e=>Array.isArray(e)&&e.every(e=>typeof e==`number`),y=(e,t)=>{let n=Number.parseFloat(e.getAttribute(t)??``);return Number.isFinite(n)&&n>0?n:null},b=class extends e{_panels;_handles;_mins;_maxs;_defaults;_sizes;_drag;_observer;_onPointerDown;_onPointerMove;_onPointerUp;_onPointerCancel;_onKeyDown;_onDoubleClick;constructor(){super(),this._panels=[],this._handles=[],this._mins=[],this._maxs=[],this._defaults=[],this._sizes=null,this._drag=null,this._observer=null,this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e,!1),this._onPointerCancel=e=>this._pointerUp(e,!0),this._onKeyDown=e=>this._keyDown(e),this._onDoubleClick=e=>this._reset(e)}connectedCallback(){this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`pointermove`,this._onPointerMove),this.addEventListener(`pointerup`,this._onPointerUp),this.addEventListener(`pointercancel`,this._onPointerCancel),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`dblclick`,this._onDoubleClick),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(()=>this._sync()),this._observer.observe(this,{childList:!0})),this._sync()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`pointermove`,this._onPointerMove),this.removeEventListener(`pointerup`,this._onPointerUp),this.removeEventListener(`pointercancel`,this._onPointerCancel),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`dblclick`,this._onDoubleClick),this._observer?.disconnect(),this._observer=null,this._drag=null}get sizes(){return this._sizes?[...this._sizes]:[]}get _vertical(){return this.getAttribute(`direction`)===`vertical`}_sync(){let e=[...this.children];this._panels=e.filter(e=>e instanceof HTMLElement&&e.classList.contains(t)),this._handles=e.filter(e=>e instanceof HTMLElement&&e.classList.contains(n));let r=this._panels.length;if(r===0)return;this._mins=this._panels.map(e=>y(e,`data-min-size`)??a),this._maxs=this._panels.map(e=>y(e,`data-max-size`)??100),this._defaults=m(_(this._panels.map(e=>y(e,`data-default-size`))),this._mins,this._maxs);let i=this._sizes&&this._sizes.length===r?this._sizes:null;this._sizes=m(i??this._load(r)??this._defaults,this._mins,this._maxs);for(let e of this._panels)e.id||=`wui-resizable-panel-${++c}`;this._render()}_render(){let e=this._sizes??[];this._panels.forEach((t,n)=>{t.style.flex=`${d(e[n]??0)} 1 0px`});for(let t of this._handles){let n=this._indexOf(t);if(n<0)continue;let[r,i]=h(e,n,this._mins,this._maxs),a=this._panels[n];a&&(t.setAttribute(`aria-controls`,a.id),t.setAttribute(`aria-valuenow`,String(Math.round(e[n]??0))),t.setAttribute(`aria-valuemin`,String(Math.ceil(r-s))),t.setAttribute(`aria-valuemax`,String(Math.floor(i+s))))}}_indexOf(e){let t=e.previousElementSibling,n=t instanceof HTMLElement?this._panels.indexOf(t):-1;return n>=0&&e.nextElementSibling===this._panels[n+1]?n:-1}_handleFor(e){let t=e.target instanceof Element?e.target.closest(`.${n}`):null;if(!(t instanceof HTMLElement)||t.parentElement!==this)return null;let r=this._indexOf(t);return r<0?null:{handle:t,index:r}}_storageKey(){let e=this.getAttribute(`storage-key`);return e?o+e:null}_load(e){let t=this._storageKey();if(!t)return null;try{let n=JSON.parse(globalThis.localStorage?.getItem(t)??`null`);return v(n)&&n.length===e&&n.every((e,t)=>Number.isFinite(e)&&e>=f(this._mins,t)-s&&e<=f(this._maxs,t)+s)&&Math.abs(l(n)-100)<.5?n:null}catch{return null}}_save(){let e=this._storageKey();if(e)try{globalThis.localStorage?.setItem(e,JSON.stringify((this._sizes??[]).map(d)))}catch{}}_commit(e){p(e,this._sizes??[])||(this._save(),this.dispatchEvent(new CustomEvent(`wui-resizable:change`,{bubbles:!0,detail:{sizes:this.sizes}})))}_pointerDown(e){let t=this._handleFor(e);if(!t||e.pointerType===`mouse`&&e.button!==0)return;let n=this._panels.reduce((e,t)=>{let n=t.getBoundingClientRect();return e+(this._vertical?n.height:n.width)},0);n<=0||(e.preventDefault(),t.handle.setPointerCapture?.(e.pointerId),t.handle.focus?.({preventScroll:!0}),this._drag={...t,pointerId:e.pointerId,start:this._vertical?e.clientY:e.clientX,before:[...this._sizes??[]],room:n,flip:!this._vertical&&getComputedStyle(this).direction===`rtl`},this.classList.add(`is-dragging`),t.handle.classList.add(`is-active`))}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.pointerId)return;let n=(this._vertical?e.clientY:e.clientX)-t.start,r=(t.flip?-n:n)*100/t.room;this._sizes=g(t.before,t.index,r,this._mins,this._maxs),this._render()}_pointerUp(e,t){let n=this._drag;n&&e.pointerId===n.pointerId&&(this._drag=null,this.classList.remove(`is-dragging`),n.handle.classList.remove(`is-active`),n.handle.releasePointerCapture?.(e.pointerId),t?(this._sizes=n.before,this._render()):this._commit(n.before))}_keyDown(e){let t=this._handleFor(e);if(!t||e.altKey||e.ctrlKey||e.metaKey)return;let[n,a]=this._vertical?[`ArrowUp`,`ArrowDown`]:[`ArrowLeft`,`ArrowRight`],o=!this._vertical&&getComputedStyle(this).direction===`rtl`,s=e.shiftKey?i:r,c;if(e.key===n)c=o?s:-s;else if(e.key===a)c=o?-s:s;else if(e.key===`Home`)c=-1/0;else if(e.key===`End`)c=1/0;else return;e.preventDefault();let l=[...this._sizes??[]];this._sizes=g(l,t.index,c,this._mins,this._maxs),this._render(),this._commit(l)}_reset(e){if(!this._handleFor(e))return;let t=[...this._sizes??[]];this._sizes=[...this._defaults],this._render(),this._commit(t)}};export{b as t};
|
|
1
|
+
import{t as e}from"./elementBase-Cxeyx0tU.js";var t=`wui-resizable-panel`,n=`wui-resizable-handle`,r=5,i=20,a=10,o=`wui-resizable:`,s=.001,c=0,l=e=>e.reduce((e,t)=>e+t,0),u=(e,t,n)=>Math.min(Math.max(e,t),n),d=e=>Math.round(e*10)/10,f=(e,t)=>e[t]??NaN,p=(e,t)=>e.length===t.length&&e.every((e,n)=>Math.abs(e-f(t,n))<s);function m(e,t,n){let r=e.map((e,r)=>u(e,f(t,r),f(n,r)));for(let e=0;e<r.length;e++){let e=100-l(r);if(Math.abs(e)<s)break;let i=r.map((r,i)=>e>0?f(n,i)-r:r-f(t,i)),a=l(i);if(a<=0)break;let o=Math.min(Math.abs(e),a);r=r.map((t,n)=>t+Math.sign(e)*o*f(i,n)/a)}return r}function h(e,t,n,r){let i=f(e,t)+f(e,t+1);return[Math.max(f(n,t),i-f(r,t+1)),Math.min(f(r,t),i-f(n,t+1))]}function g(e,t,n,r,i){let[a,o]=h(e,t,r,i);if(a>o)return e;let s=f(e,t)+f(e,t+1),c=u(f(e,t)+n,a,o),l=[...e];return l[t]=c,l[t+1]=s-c,l}function _(e){let t=e.filter(e=>e===null).length,n=l(e.filter(e=>e!==null));if(t>0&&n<100)return e.map(e=>e??(100-n)/t);let r=e.map(e=>e??1),i=l(r);return r.map(e=>e*100/i)}var v=e=>Array.isArray(e)&&e.every(e=>typeof e==`number`),y=(e,t)=>{let n=Number.parseFloat(e.getAttribute(t)??``);return Number.isFinite(n)&&n>0?n:null},b=class extends e{_panels;_handles;_mins;_maxs;_defaults;_sizes;_drag;_observer;_onPointerDown;_onPointerMove;_onPointerUp;_onPointerCancel;_onKeyDown;_onDoubleClick;constructor(){super(),this._panels=[],this._handles=[],this._mins=[],this._maxs=[],this._defaults=[],this._sizes=null,this._drag=null,this._observer=null,this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e,!1),this._onPointerCancel=e=>this._pointerUp(e,!0),this._onKeyDown=e=>this._keyDown(e),this._onDoubleClick=e=>this._reset(e)}connectedCallback(){this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`pointermove`,this._onPointerMove),this.addEventListener(`pointerup`,this._onPointerUp),this.addEventListener(`pointercancel`,this._onPointerCancel),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`dblclick`,this._onDoubleClick),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(()=>this._sync()),this._observer.observe(this,{childList:!0})),this._sync()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`pointermove`,this._onPointerMove),this.removeEventListener(`pointerup`,this._onPointerUp),this.removeEventListener(`pointercancel`,this._onPointerCancel),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`dblclick`,this._onDoubleClick),this._observer?.disconnect(),this._observer=null,this._drag=null}get sizes(){return this._sizes?[...this._sizes]:[]}get _vertical(){return this.getAttribute(`direction`)===`vertical`}_sync(){let e=[...this.children];this._panels=e.filter(e=>e instanceof HTMLElement&&e.classList.contains(t)),this._handles=e.filter(e=>e instanceof HTMLElement&&e.classList.contains(n));let r=this._panels.length;if(r===0)return;this._mins=this._panels.map(e=>y(e,`data-min-size`)??a),this._maxs=this._panels.map(e=>y(e,`data-max-size`)??100),this._defaults=m(_(this._panels.map(e=>y(e,`data-default-size`))),this._mins,this._maxs);let i=this._sizes&&this._sizes.length===r?this._sizes:null;this._sizes=m(i??this._load(r)??this._defaults,this._mins,this._maxs);for(let e of this._panels)e.id||=`wui-resizable-panel-${++c}`;this._render()}_render(){let e=this._sizes??[];this._panels.forEach((t,n)=>{t.style.flex=`${d(e[n]??0)} 1 0px`});for(let t of this._handles){let n=this._indexOf(t);if(n<0)continue;let[r,i]=h(e,n,this._mins,this._maxs),a=this._panels[n];a&&(t.setAttribute(`aria-controls`,a.id),t.setAttribute(`aria-valuenow`,String(Math.round(e[n]??0))),t.setAttribute(`aria-valuemin`,String(Math.ceil(r-s))),t.setAttribute(`aria-valuemax`,String(Math.floor(i+s))))}}_indexOf(e){let t=e.previousElementSibling,n=t instanceof HTMLElement?this._panels.indexOf(t):-1;return n>=0&&e.nextElementSibling===this._panels[n+1]?n:-1}_handleFor(e){let t=e.target instanceof Element?e.target.closest(`.${n}`):null;if(!(t instanceof HTMLElement)||t.parentElement!==this)return null;let r=this._indexOf(t);return r<0?null:{handle:t,index:r}}_storageKey(){let e=this.getAttribute(`storage-key`);return e?o+e:null}_load(e){let t=this._storageKey();if(!t)return null;try{let n=JSON.parse(globalThis.localStorage?.getItem(t)??`null`);return v(n)&&n.length===e&&n.every((e,t)=>Number.isFinite(e)&&e>=f(this._mins,t)-s&&e<=f(this._maxs,t)+s)&&Math.abs(l(n)-100)<.5?n:null}catch{return null}}_save(){let e=this._storageKey();if(e)try{globalThis.localStorage?.setItem(e,JSON.stringify((this._sizes??[]).map(d)))}catch(e){if(!(e instanceof DOMException))throw e}}_commit(e){p(e,this._sizes??[])||(this._save(),this.dispatchEvent(new CustomEvent(`wui-resizable:change`,{bubbles:!0,detail:{sizes:this.sizes}})))}_pointerDown(e){let t=this._handleFor(e);if(!t||e.pointerType===`mouse`&&e.button!==0)return;let n=this._panels.reduce((e,t)=>{let n=t.getBoundingClientRect();return e+(this._vertical?n.height:n.width)},0);n<=0||(e.preventDefault(),t.handle.setPointerCapture?.(e.pointerId),t.handle.focus?.({preventScroll:!0}),this._drag={...t,pointerId:e.pointerId,start:this._vertical?e.clientY:e.clientX,before:[...this._sizes??[]],room:n,flip:!this._vertical&&getComputedStyle(this).direction===`rtl`},this.classList.add(`is-dragging`),t.handle.classList.add(`is-active`))}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.pointerId)return;let n=(this._vertical?e.clientY:e.clientX)-t.start,r=(t.flip?-n:n)*100/t.room;this._sizes=g(t.before,t.index,r,this._mins,this._maxs),this._render()}_pointerUp(e,t){let n=this._drag;n&&e.pointerId===n.pointerId&&(this._drag=null,this.classList.remove(`is-dragging`),n.handle.classList.remove(`is-active`),n.handle.releasePointerCapture?.(e.pointerId),t?(this._sizes=n.before,this._render()):this._commit(n.before))}_keyDown(e){let t=this._handleFor(e);if(!t||e.altKey||e.ctrlKey||e.metaKey)return;let[n,a]=this._vertical?[`ArrowUp`,`ArrowDown`]:[`ArrowLeft`,`ArrowRight`],o=!this._vertical&&getComputedStyle(this).direction===`rtl`,s=e.shiftKey?i:r,c;if(e.key===n)c=o?s:-s;else if(e.key===a)c=o?-s:s;else if(e.key===`Home`)c=-1/0;else if(e.key===`End`)c=1/0;else return;e.preventDefault();let l=[...this._sizes??[]];this._sizes=g(l,t.index,c,this._mins,this._maxs),this._render(),this._commit(l)}_reset(e){if(!this._handleFor(e))return;let t=[...this._sizes??[]];this._sizes=[...this._defaults],this._render(),this._commit(t)}};export{b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{l as r}from"./wuiHttp-DGbD7Fra.js";var i=`wui-saved-views:`,a=20,o=0,s=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,c=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,i=this.getAttribute(`key`)??``,a=n,o;e===`list`?a+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):o={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let c=await r(a,o);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=new DOMParser().parseFromString(c.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(s),this._error=null,this._render(),!0}return this._error=c.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control form-control-sm`,a.setAttribute(`aria-label`,`View name`),a.placeholder=`Name this view`;let s=n.createElement(`button`);s.type=`submit`,s.className=e(`primary`,`solid`,`sm`),s.dataset.wui=t,s.textContent=`Save this view`;let c=n.createElement(`form`);c.className=`d-flex gap-2 px-3 py-2`,c.append(a,s),c.addEventListener(`submit`,this._onSubmit);let l=n.createElement(`input`);l.type=`checkbox`,l.className=`form-check-input`,l.setAttribute(`role`,`switch`),l.id=`wui-saved-views-share-${o++}`;let u=n.createElement(`label`);u.className=`form-check-label`,u.htmlFor=l.id,u.textContent=`Share with the team`;let d=n.createElement(`div`);d.className=`form-check form-switch mb-0`,d.append(l,u);let f=n.createElement(`div`);f.className=`px-3 pb-2`,f.hidden=!0,f.append(d),this._dom={menu:r,divider:i,form:c,input:a,save:s,shareRow:f,share:l},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=`Shared`,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${t.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:i+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(s).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch{}}};export{c as t};
|
|
1
|
+
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{l as r}from"./wuiHttp-DGbD7Fra.js";var i=`wui-saved-views:`,a=20,o=0,s=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,c=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,i=this.getAttribute(`key`)??``,a=n,o;e===`list`?a+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):o={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let c=await r(a,o);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=new DOMParser().parseFromString(c.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(s),this._error=null,this._render(),!0}return this._error=c.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control form-control-sm`,a.setAttribute(`aria-label`,`View name`),a.placeholder=`Name this view`;let s=n.createElement(`button`);s.type=`submit`,s.className=e(`primary`,`solid`,`sm`),s.dataset.wui=t,s.textContent=`Save this view`;let c=n.createElement(`form`);c.className=`d-flex gap-2 px-3 py-2`,c.append(a,s),c.addEventListener(`submit`,this._onSubmit);let l=n.createElement(`input`);l.type=`checkbox`,l.className=`form-check-input`,l.setAttribute(`role`,`switch`),l.id=`wui-saved-views-share-${o++}`;let u=n.createElement(`label`);u.className=`form-check-label`,u.htmlFor=l.id,u.textContent=`Share with the team`;let d=n.createElement(`div`);d.className=`form-check form-switch mb-0`,d.append(l,u);let f=n.createElement(`div`);f.className=`px-3 pb-2`,f.hidden=!0,f.append(d),this._dom={menu:r,divider:i,form:c,input:a,save:s,shareRow:f,share:l},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=`Shared`,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${t.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:i+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(s).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{c as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{i as r,n as i,r as a,t as o}from"./optionLabel-4xjXWy74.js";import{n as s}from"./devWarn-DXdRWZs3.js";import{r as c}from"./dom-Do1pAA12.js";import{t as l}from"./elementBase-Cxeyx0tU.js";import{r as u,t as d}from"./fieldState-D-zQcXUS.js";import{n as f,t as p}from"./formMirror-9IpSgeZb.js";import{n as m}from"./loader-ByHAB1wi.js";import{t as h}from"./iconGlyphs.g-DPqoOoXy.js";import{n as g,t as _}from"./listboxKeyNav-4LeEjKq6.js";var v=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},y=(e,t=`wui-opt-avatar`)=>{let n=v(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${i(e.initials??``)}</span>${n?`<img class="avatar-img" src="${b(n)}" alt="" />`:``}</span>`},b=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);function x(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[r(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var S=/* @__PURE__ */ new WeakMap;function C(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=`No matches`,searchingText:c=`Searching…`,hintText:l=`Type to search…`,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=x(t,a),m=e.id,h=0,g=()=>`${m}-opt-${h++}`,_=e=>`<button type="button" role="option" id="${i(g())}" class="wui-select-option wui-select-add" data-value="${i(e.value)}" data-custom="true" aria-selected="false">${i(e.label)}</button>`,v=u.filter(e=>e.position===`top`).map(_).join(``),y=d?.options.length?`<div class="wui-select-group">${i(d.label)}</div>${d.options.map(e=>w(e,g(),f.has(String(e.value)))).join(``)}<div class="wui-select-sep" aria-hidden="true"></div>`:``,b=``,C=``;for(let e of p)e.group&&e.group!==b&&(C+=`<div class="wui-select-group">${i(e.group)}</div>`),b=e.group??``,C+=w(e,g(),f.has(String(e.value)));let T=u.filter(e=>e.position===`bottom`).map(_).join(``),E=``;o===`loading`?E=`<div class="wui-select-loading"><span class="wui-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>${i(c)}</div>`:o===`hint`?E=`<div class="wui-select-hint">${i(l)}</div>`:(o===`empty`||p.length===0&&u.length===0)&&(E=`<div class="wui-select-empty">${i(s)}</div>`);let D=v+y+C+T+E;S.get(e)!==D&&(S.set(e,D),e.innerHTML=D)}function w(e,t,n){let r=!!e.disabled,o=r&&e.disabledHint?` title="${i(e.disabledHint)}"`:``,s=`id="${i(t)}" role="option" data-value="${i(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}${o}`,c=`<span class="wui-select-check" aria-hidden="true">${h(`check`)}</span>`;if(!e.description&&!e.meta)return`<button type="button" class="wui-select-option${n?` selected`:``}" ${s}>${y(e)}<span class="wui-select-opt-name">${a(e)}</span>${c}</button>`;let l=e.description?`<span class="wui-select-opt-desc">${i(e.description)}</span>`:``,u=e.meta?`<span class="wui-select-opt-meta">${i(e.meta)}</span>`:``;return`<div class="wui-select-option wui-select-option-rich${n?` selected`:``}" ${s}>${y(e)}<span class="wui-select-option-text"><span class="wui-opt-label">${a(e)}</span>${l}</span>${u}${c}</div>`}var T=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),E=e=>e===`multiple`||e===`tag`,D={recents:()=>import(`./recents-CmLLdV8O.js`),chips:()=>import(`./chips-Dony2fgq.js`),search:()=>import(`./search-C8xIzt6h.js`),country:()=>import(`./country-x5lqC5Xu.js`)};function O(e){let t=Object.hasOwn(D,e)?D[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var k=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),A=class extends l{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_reposition;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_onDocClick;_bindGlobal=()=>{throw Error(`The select is not wired.`)};_reanchor;_reanchorScroll;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._reposition=()=>{this._menuOpen()&&this._place()},this._hoverTimer=null,this._hoverOpened=!1,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},P)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},F)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered?this._bindGlobal():this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=V(n,E(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():(e===`mode`&&(this._value=V(this._value,E(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),z.has(e)?this._rendered&&(this._drawValue(),this.renderList()):R.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:M(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,s(`<wui-select> mode "${e}" is not one of ${T.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||N.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,s(`<wui-select> density "${e}" is not one of ${N.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=V(e,E(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){d(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();e.list&&(C(e.list,this._listOptions(),{selected:this._selectedValues(),query:this._ownsFilter?``:this._query,status:this._status,emptyText:this.getAttribute(`empty-text`)||`No matches`,searchingText:this.getAttribute(`searching-text`)||`Searching…`,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:this._actionRows(),recents:this._recents()}),this._active>=this._visible().length&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._menuOpen()&&this._place())}render(){let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=E(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=V(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=V(this._value,n));let o=this.getAttribute(`size`),s=o===`sm`?` wui-select-sm`:o===`lg`?` wui-select-lg`:``,c=this.getAttribute(`icon`),l=this.getAttribute(`prefix`),d=this.hasAttribute(`clearable`),f=this.hasAttribute(`disabled`);this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let p=`${this.id}-listbox`,m=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${m}`:m,v=this.hasAttribute(`aria-invalid`)||this._error?` aria-invalid="true"`:``,y=this.hasAttribute(`required`)&&!a?` aria-required="true"`:``,b=` aria-label="${i(this._accessibleName())}" aria-describedby="${i(_)}"${v}${y}`,x=a?``:` role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${i(p)}"`,S=n?`<div class="input wui-select-control wui-select-multi"${x}${b}${f?` aria-disabled="true"`:r?``:` tabindex="0"`}>`:`<button type="button" class="input wui-select-control"${x}${b}${f?` disabled`:``}>`,C=`${c?h(c,{className:`wui-select-icon`}):``}${l?`<span class="wui-select-prefix">${i(l)}</span>`:``}<span class="wui-select-value" data-label></span>${d?`<span class="wui-select-reset" role="button" aria-label="Clear selection" hidden>${h(`x`)}</span>`:``}${h(`chevron-down`,{className:`wui-select-caret`})}`,w=this.getAttribute(`searchable`),T=w===null?t===`multiple`||t===`country`||this._autoSearch():w!==`false`,D=t===`search`||T&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?`Search countries…`:`Search…`),k=D?`<div class="wui-select-search">${h(`search`)}<input class="wui-select-input" placeholder="${i(O)}" aria-label="${i(O)}" aria-autocomplete="list" /><button type="button" class="wui-select-clear" aria-label="Clear search" hidden>${h(`x`)}</button></div>`:``;this.innerHTML=`
|
|
1
|
+
import{n as e,r as t,t as n}from"./anchorOverlay-CXnWfezA.js";import{i as r,n as i,r as a,t as o}from"./optionLabel-4xjXWy74.js";import{n as s}from"./devWarn-DXdRWZs3.js";import{r as c}from"./dom-Do1pAA12.js";import{t as l}from"./elementBase-Cxeyx0tU.js";import{r as u,t as d}from"./fieldState-D-zQcXUS.js";import{n as f,t as p}from"./formMirror-9IpSgeZb.js";import{n as m}from"./loader-ByHAB1wi.js";import{t as h}from"./iconGlyphs.g-DPqoOoXy.js";import{n as g,t as _}from"./listboxKeyNav-4LeEjKq6.js";var v=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},y=(e,t=`wui-opt-avatar`)=>{let n=v(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${i(e.initials??``)}</span>${n?`<img class="avatar-img" src="${b(n)}" alt="" />`:``}</span>`},b=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);function x(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[r(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var S=/* @__PURE__ */ new WeakMap;function C(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=`No matches`,searchingText:c=`Searching…`,hintText:l=`Type to search…`,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=x(t,a),m=e.id,h=0,g=()=>`${m}-opt-${h++}`,_=e=>`<button type="button" role="option" id="${i(g())}" class="wui-select-option wui-select-add" data-value="${i(e.value)}" data-custom="true" aria-selected="false">${i(e.label)}</button>`,v=u.filter(e=>e.position===`top`).map(_).join(``),y=d?.options.length?`<div class="wui-select-group">${i(d.label)}</div>${d.options.map(e=>w(e,g(),f.has(String(e.value)))).join(``)}<div class="wui-select-sep" aria-hidden="true"></div>`:``,b=``,C=``;for(let e of p)e.group&&e.group!==b&&(C+=`<div class="wui-select-group">${i(e.group)}</div>`),b=e.group??``,C+=w(e,g(),f.has(String(e.value)));let T=u.filter(e=>e.position===`bottom`).map(_).join(``),E=``;o===`loading`?E=`<div class="wui-select-loading"><span class="wui-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>${i(c)}</div>`:o===`hint`?E=`<div class="wui-select-hint">${i(l)}</div>`:(o===`empty`||p.length===0&&u.length===0)&&(E=`<div class="wui-select-empty">${i(s)}</div>`);let D=v+y+C+T+E;S.get(e)!==D&&(S.set(e,D),e.innerHTML=D)}function w(e,t,n){let r=!!e.disabled,o=r&&e.disabledHint?` title="${i(e.disabledHint)}"`:``,s=`id="${i(t)}" role="option" data-value="${i(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}${o}`,c=`<span class="wui-select-check" aria-hidden="true">${h(`check`)}</span>`;if(!e.description&&!e.meta)return`<button type="button" class="wui-select-option${n?` selected`:``}" ${s}>${y(e)}<span class="wui-select-opt-name">${a(e)}</span>${c}</button>`;let l=e.description?`<span class="wui-select-opt-desc">${i(e.description)}</span>`:``,u=e.meta?`<span class="wui-select-opt-meta">${i(e.meta)}</span>`:``;return`<div class="wui-select-option wui-select-option-rich${n?` selected`:``}" ${s}>${y(e)}<span class="wui-select-option-text"><span class="wui-opt-label">${a(e)}</span>${l}</span>${u}${c}</div>`}var T=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),E=e=>e===`multiple`||e===`tag`,D={recents:()=>import(`./recents-Dcw-b5cB.js`),chips:()=>import(`./chips-Dr_W3avk.js`),search:()=>import(`./search-PZCXpBAn.js`),country:()=>import(`./country-x5lqC5Xu.js`)};function O(e){let t=Object.hasOwn(D,e)?D[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var k=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),A=class extends l{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_reposition;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_onDocClick;_bindGlobal=()=>{throw Error(`The select is not wired.`)};_reanchor;_reanchorScroll;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._reposition=()=>{this._menuOpen()&&this._place()},this._hoverTimer=null,this._hoverOpened=!1,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},P)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},F)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered?this._bindGlobal():this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=V(n,E(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():(e===`mode`&&(this._value=V(this._value,E(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),z.has(e)?this._rendered&&(this._drawValue(),this.renderList()):R.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:M(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,s(`<wui-select> mode "${e}" is not one of ${T.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||N.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,s(`<wui-select> density "${e}" is not one of ${N.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=V(e,E(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){d(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();e.list&&(C(e.list,this._listOptions(),{selected:this._selectedValues(),query:this._ownsFilter?``:this._query,status:this._status,emptyText:this.getAttribute(`empty-text`)||`No matches`,searchingText:this.getAttribute(`searching-text`)||`Searching…`,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:this._actionRows(),recents:this._recents()}),this._active>=this._visible().length&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._menuOpen()&&this._place())}render(){let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=E(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=V(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=V(this._value,n));let o=this.getAttribute(`size`),s=o===`sm`?` wui-select-sm`:o===`lg`?` wui-select-lg`:``,c=this.getAttribute(`icon`),l=this.getAttribute(`prefix`),d=this.hasAttribute(`clearable`),f=this.hasAttribute(`disabled`);this.id||=`wui-select-${Math.random().toString(36).slice(2,9)}`;let p=`${this.id}-listbox`,m=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${m}`:m,v=this.hasAttribute(`aria-invalid`)||this._error?` aria-invalid="true"`:``,y=this.hasAttribute(`required`)&&!a?` aria-required="true"`:``,b=` aria-label="${i(this._accessibleName())}" aria-describedby="${i(_)}"${v}${y}`,x=a?``:` role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${i(p)}"`,S=n?`<div class="input wui-select-control wui-select-multi"${x}${b}${f?` aria-disabled="true"`:r?``:` tabindex="0"`}>`:`<button type="button" class="input wui-select-control"${x}${b}${f?` disabled`:``}>`,C=`${c?h(c,{className:`wui-select-icon`}):``}${l?`<span class="wui-select-prefix">${i(l)}</span>`:``}<span class="wui-select-value" data-label></span>${d?`<span class="wui-select-reset" role="button" aria-label="Clear selection" hidden>${h(`x`)}</span>`:``}${h(`chevron-down`,{className:`wui-select-caret`})}`,w=this.getAttribute(`searchable`),T=w===null?t===`multiple`||t===`country`||this._autoSearch():w!==`false`,D=t===`search`||T&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?`Search countries…`:`Search…`),k=D?`<div class="wui-select-search">${h(`search`)}<input class="wui-select-input" placeholder="${i(O)}" aria-label="${i(O)}" aria-autocomplete="list" /><button type="button" class="wui-select-clear" aria-label="Clear search" hidden>${h(`x`)}</button></div>`:``;this.innerHTML=`
|
|
2
2
|
<div class="wui-select${s}">
|
|
3
3
|
${S}${C}${n?`</div>`:`</button>`}
|
|
4
4
|
<div class="wui-select-menu wui-select-menu-fixed" hidden>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-DPqoOoXy.js";import{a as r,i,n as a,r as o}from"./optionLabel-4xjXWy74.js";import{t as s}from"./customRule-Chp7YwFb.js";import{r as c}from"./WuiSelect-
|
|
1
|
+
import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-DPqoOoXy.js";import{a as r,i,n as a,r as o}from"./optionLabel-4xjXWy74.js";import{t as s}from"./customRule-Chp7YwFb.js";import{r as c}from"./WuiSelect-BPWPI07i.js";var l={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},u={enter:`
|
|
2
2
|
`,comma:`,`,space:` `,tab:` `},d=e=>l[e],ee=e=>u[e];function te(e,t){let n=[String(e??``)];for(let e of t)n=n.flatMap(t=>t.split(e));return n.map(e=>e.trim()).filter(Boolean)}var ne=(e,t)=>t.some(t=>String(e??``).includes(t));function f(e,t){if(e===null)throw TypeError(`The chip row needs ${t}, and it is not mounted.`);return e}var p=(e,t)=>{let n=document.createElement(e);return n.className=t,n};function m(){let l,u,m=null,h=null,g=null,_=null,v=null,y=null,b=null,x=null,S=!1,C=()=>f(h,`the draft input`),w=()=>l.mode===`tag`,T=()=>Array.isArray(l.value)?l.value.slice():[],E=()=>(l.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),re=()=>new Set(E().map(d).filter(Boolean)),D=()=>{let e=parseInt(l.getAttribute(`max-tags`)??``,10);return e>0?e:0},O=()=>{let e=D();return e>0&&T().length>=e},k=(e,t)=>!l.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),A=e=>(l.options||[]).find(t=>String(t.value)===String(e)),j=e=>{let t=e.trim().toLowerCase();return(l.options||[]).find(e=>String(e.value??``).toLowerCase()===t||i(e).trim().toLowerCase()===t)},ie=e=>{for(let t of E()){let n=ee(t)??t;if(ne(e,[n]))return te(e,[n])}return[e.trim()]},M=()=>h?h.value:l._query||``,ae=()=>w()||l.hasAttribute(`allow-custom`),N=()=>l.getAttribute(`placeholder`)||(w()?`Add…`:`Select…`),P=()=>{let e=l.getAttribute(`aria-label`);if(e)return e;let t=l.closest(`label`)?.textContent?.trim();if(t)return t;let n=l.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e instanceof HTMLLabelElement&&e.htmlFor===n):void 0)?.textContent?.trim()||(w()?`Add tags`:`Select`)},F=()=>{h&&(h.setAttribute(`aria-expanded`,String(!u.menu.hidden)),u.list.id&&h.setAttribute(`aria-controls`,u.list.id),h.setAttribute(`aria-label`,P()))},oe=()=>!e(l)&&!l.hasAttribute(`loading`),se=e=>{S=!0,C().setAttribute(`aria-invalid`,`true`),l.setError(e)},I=()=>{S&&(S=!1,C().removeAttribute(`aria-invalid`),l.setError(null))},L=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=T(),i=r.slice(),a=D(),o=[],c=``,u=!1;for(let t of e){let e=(n?t.trim().replace(/,+$/,``):t).trim();if(!e)continue;if(a&&i.length>=a)break;let r=j(e);if(r){if(r.disabled){o.push(e),c||=r.disabledHint||l.getAttribute(`invalid-message`)||`That option is not available.`;continue}k(i,String(r.value))||i.push(String(r.value));continue}let d=s(l,e);d?(o.push(e),c||=d):k(i,e)||(i.push(e),u=!0)}i.length!==r.length&&(u?l.commit(i,{isCustom:!0}):l.commit(i)),C().value=o.join(`, `),c?t||se(c):I()},R=e=>{t(l)||L([C().value],e)},z=e=>l.commit(T().filter(t=>t!==e)),ce=()=>{let e=p(`span`,`wui-select-placeholder`);return e.textContent=l.getAttribute(`placeholder`)||`Select…`,e},B=e=>{let t=A(e),s=p(`span`,`chip chip-sm`),c=p(`span`,`chip-label`);if(c.innerHTML=t?o(t):a(e),s.append(c),oe()){let a=p(`button`,`chip-remove`);a.type=`button`,a.dataset.remove=e;let o=t?i(t):r(e);a.setAttribute(`aria-label`,`Remove ${o}`),a.innerHTML=n(`x`),s.append(a)}return s};function V(){if(!m)return;m.querySelector(`:scope > .chip-more`)?.remove();let e=[...m.querySelectorAll(`:scope > .chip`)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`The chip row holds a node that is not an element.`);return e});for(let t of e)t.style.display=``;let t=e.at(-1);if(!l.hasAttribute(`collapse-chips`)||!t)return;let n=m.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t)<=n)return;let i=p(`span`,`chip chip-sm chip-more`);i.textContent=`+${e.length}`,t.after(i);let a=i.offsetWidth+6,o=0;for(let t of e)if(r(t)<=n-a)o+=1;else break;o<1&&(o=1);for(let t of e.slice(o))t.style.display=`none`;i.textContent=`+${e.length-o}`}function H(){if(!m)return!1;m.parentNode!==u.value&&u.value.append(m);for(let e of m.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=T(),n=m,r=e=>{h?n.insertBefore(e,h):n.append(e)};w()||h||e.length||r(ce());for(let t of e)r(B(t));return h&&(h.placeholder=w()||!e.length?N():``,h.disabled=l.hasAttribute(`disabled`),h.readOnly=t(l),F()),w()||(f(_,`the footer text`).textContent=(l.getAttribute(`selected-text`)||`{n} selected`).replace(`{n}`,()=>String(e.length)),f(v,`the clear-all button`).textContent=l.getAttribute(`clear-all-label`)||`Clear all`),V(),!0}function U(e){if(e.key===`Backspace`){let t=h?!M():!M()&&!u.menu.hidden,n=T().at(-1);return!t||n===void 0?!1:(e.preventDefault(),z(n),!0)}if(!h)return!1;let t=h.value;if(e.key===`Escape`){if(!w())return!1;let n=!u.menu.hidden;return!n&&!t?!1:(n&&(e.preventDefault(),e.stopPropagation()),h.value=``,I(),l.closeMenu({focusControl:!1}),!0)}let n=!w()&&!t.trim(),r=re();return e.key===`Enter`&&r.has(`Enter`)?n||u.list.querySelector(`.is-active`)?!1:(e.preventDefault(),R(),!0):e.key===`,`&&r.has(`,`)?!n&&(e.preventDefault(),R({strip:!0}),!0):e.key===` `&&r.has(` `)&&t.trim()||e.key===`Tab`&&r.has(`Tab`)&&!n?(e.preventDefault(),R(),!0):!1}function W(e){let t=String(e.value);if(w()||h&&!A(t))return L([t]),!0;let n=T();return n.includes(t)?l.commit(n.filter(e=>e!==t)):h?L([t]):l.commit([...n,t]),h?.value&&(h.value=``,I()),!0}function G(e){if(!h)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||O()||j(t)||k(T(),t))return null;let n=l.getAttribute(`create-label`)||`Create '{text}'`;return{position:w()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let n=e.target,r=n instanceof Element?n.closest(`[data-remove]`):null;if(r instanceof HTMLElement){if(t(l))return;e.stopPropagation(),z(r.dataset.remove??``),h?.focus()}else h&&!t(l)&&h.focus()}function q(){I();let e=C().value.trim();!w()&&e&&u.menu.hidden&&(G(e)||c(l.options||[],e).length)&&l.openMenu()}function J(e){e.preventDefault(),t(l)||L(ie(e.clipboardData?.getData(`text/plain`)??``))}function Y(){C().value.trim()&&R({quiet:!0,strip:!0}),l.closeMenu({focusControl:!1})}function X(e){e.relatedTarget instanceof Node&&l.contains(e.relatedTarget)||Y()}function le(){return h?(Y(),!0):!1}function Z(){C().value.trim()&&R({strip:!0})}function Q(){t(l)||l.commit([])}function $(e){e.target!==h&&e.preventDefault()}function ue(e,t,n={}){l=e,u=t,m=p(`div`,`wui-select-chips`),m.addEventListener(`click`,K),u.value.append(m),ae()&&(h=p(`input`,`wui-select-draft`),h.type=`text`,h.setAttribute(`autocomplete`,`off`),h.setAttribute(`role`,`combobox`),h.setAttribute(`aria-autocomplete`,`list`),l.hasAttribute(`required`)&&h.setAttribute(`aria-required`,`true`),x=new MutationObserver(F),x.observe(u.menu,{attributes:!0,attributeFilter:[`hidden`]}),m.append(h),h.value=n.carry?.draft??``,u.input=h,h.addEventListener(`input`,q),h.addEventListener(`paste`,J),h.addEventListener(`blur`,X),m.addEventListener(`mousedown`,$),y=l.closest(`form`),y?.addEventListener(`submit`,Z,!0)),w()||(g=p(`div`,`wui-select-footer`),_=document.createElement(`span`),v=p(`button`,`wui-select-clear-all`),v.type=`button`,v.addEventListener(`click`,Q),g.append(_,v),u.menu.append(g)),typeof ResizeObserver<`u`&&(b=new ResizeObserver(V),b.observe(m)),H()}function de(){m?.removeEventListener(`click`,K),m?.removeEventListener(`mousedown`,$),h&&(h.removeEventListener(`input`,q),h.removeEventListener(`paste`,J),h.removeEventListener(`blur`,X),u.input=null),v&&v.removeEventListener(`click`,Q),y?.removeEventListener(`submit`,Z,!0),y=null,b?.disconnect(),b=null,x?.disconnect(),x=null,g?.remove(),m?.remove(),m=null,h=null,g=null,S=!1}return{mount:ue,onKey:U,onPick:W,renderValue:H,actionRow:G,onQuery:()=>!1,onBlur:le,teardown:de}}export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=2e3;async function t(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch(e){if(!(e instanceof DOMException))throw e}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),!!n}catch(e){if(!(e instanceof DOMException))throw e;return!1}}export{t as n,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as e}from"./formatters-ljfITOZ3.js";var t=48,n=1200,r=10,i=50,a=[`start`,`end`],o=8,s={comfortable:72,cozy:48,compact:40},c={resize:e=>e?`Resize ${e} column`:`Resize column`,width:e=>`${e} pixels`,rows:t=>`${e(t,{decimals:0})} ${t===1?`row`:`rows`}`,saved:e=>e?`${e} saved.`:`Row saved.`,savedMany:t=>`${e(t,{decimals:0})} rows saved.`,notSaved:(e,t)=>`${e?`${e} was not saved.`:`Row was not saved.`}${t?` ${t}`:``}`},l=t=>e(t,{decimals:0}),u=e=>Math.min(n,Math.max(48,Math.round(Number(e)||0)));function d(e,t,n=[]){let r=new Map(n.map(e=>[e,[]]));return e.forEach((e,n)=>{let i=t(e,n),a=r.get(i);a||(a=[],r.set(i,a)),a.push(e)}),[...r].filter(([,e])=>e.length>0).map(([e,t])=>({key:e,items:t}))}function f({scrollTop:e,viewport:t,rowHeight:n,count:r,overscan:i=8}){let a=n>0?n:s.comfortable,o=Math.floor(Math.max(0,e)/a),c=Math.max(0,o-i);c-=c%2;let l=Math.min(r,o+Math.ceil(Math.max(0,t)/a)+i),u=Math.min(c,l);return{start:u,end:l,before:u*a,after:Math.max(0,r-l)*a}}var p=e=>`wui-widths:${e}`;function m(e){if(!e)return{};try{let t=JSON.parse(window.localStorage.getItem(p(e))||`{}`),n={};if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))Number.isFinite(r)&&(n[e]=u(r));return n}catch{return{}}}function h(e,t){if(e)try{Object.keys(t).length?window.localStorage.setItem(p(e),JSON.stringify(t)):window.localStorage.removeItem(p(e))}catch(e){if(!(e instanceof DOMException))throw e}}var g=(e,t)=>`--wui-pin-${e}-${t}`,_=`--wui-pin-at`,v=(e,t)=>`var(${g(e,t)}, 0px)`;function y(e){let t=e.map(()=>null),n=-1;e.forEach((e,t)=>{e===`start`&&(n=t)});let r=0;for(let i=0;i<=n;i++)(e[i]===`start`||e[i]===`lead`)&&(t[i]={side:`start`,ordinal:r++,edge:!1});let i=t[n];i&&(i.edge=!0);let a=-1;r=0;for(let n=e.length-1;n>=0;n--)e[n]===`end`&&(t[n]={side:`end`,ordinal:r++,edge:!1},a=n);let o=t[a];return o&&(o.edge=!0),t}var b=e=>e?`wui-pin-${e.side}${e.edge?` wui-pin-${e.side}-edge`:``}`:``,x=200,S=220,C=`cubic-bezier(0.22, 1, 0.36, 1)`,w=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,T=e=>e.getAttribute(`data-row-key`)??e;function E(e){let t=[...e];if(t.length>200)return null;let n=/* @__PURE__ */ new Map;for(let e of t)e.hidden||n.set(T(e),e.offsetTop);return n}function D(e,t){let n=[...e];if(!t||n.length>200||w())return 0;let r=0;for(let e of n){if(e.hidden||typeof e.animate!=`function`)continue;let n=t.get(T(e));if(n===void 0)continue;let i=n-e.offsetTop;Math.abs(i)<1||(e.animate([{transform:`translateY(${i}px)`},{transform:`translateY(0)`}],{duration:220,easing:C}),r++)}return r}function O(e,t){if(!e||!t)return!1;let n=new Set(t),r=new Set(e),i=e.filter(e=>n.has(e)),a=t.filter(e=>r.has(e));return i.some((e,t)=>e!==a[t])}var k=[`saving`,`error`],A=`data-wui-save-state`,j=`wui-row-save-error`,M=e=>{let t=e.querySelector(`:scope > .wui-name-cell`);return t instanceof HTMLTableCellElement?t:[...e.cells].find(e=>!e.matches(`.wui-select-cell, .wui-expand-cell`))??null};function N(e){let t=M(e);if(!t)return``;let n=t.querySelector(`.u-name`);if(n)return(n.textContent??``).trim();let r=``;for(let e of t.childNodes)e instanceof Element&&e.classList.contains(`wui-row-save-error`)||(r+=e.textContent??``);return r.replace(/\s+/g,` `).trim()}function P(e,t,n=``){if(t!==null&&!k.includes(t))throw Error(`A row's save state is ${k.join(` or `)} (or null to clear it), not "${t}".`);e.querySelector(`:scope > * > .${j}`)?.remove(),t===null?e.removeAttribute(A):e.setAttribute(A,t),t===`saving`?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let r=t===`error`&&n?M(e):null;if(r){let t=e.ownerDocument.createElement(`span`);t.className=j,t.textContent=n,r.append(t)}}function F(e,t){let n=[];if(!e)return n;for(let[r,i]of e){let e=t.get(r);i.state===`saving`&&e&&e.state!==`saving`&&n.push({label:e.label,ok:e.state!==`error`,message:e.message||``})}return n}function I(e){let t=e.filter(e=>e.ok),n=[],[r]=t;t.length===1&&r?n.push(c.saved(r.label)):t.length>1&&n.push(c.savedMany(t.length));for(let t of e)t.ok||n.push(c.notSaved(t.label,t.message));return n.join(` `)}export{F as A,y as C,O as D,N as E,h as M,I as O,g as S,m as T,d as _,a,v as b,s as c,A as d,j as f,l as g,u as h,_ as i,f as j,P as k,x as l,o as m,t as n,r as o,k as p,c as r,i as s,n as t,S as u,M as v,D as w,b as x,E as y};
|