@webority/ui-elements 0.122.0 → 0.124.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/WuiAutocomplete-DE9q2G-l.js +13 -0
- package/dist/{WuiCarousel-BbO8AoM6.js → WuiCarousel-C2NWcFxr.js} +1 -1
- package/dist/WuiCodeBlock-DafK2Kgc.js +1 -0
- package/dist/{WuiCommandPalette-CyMoB4RG.js → WuiCommandPalette-CiEj7qnn.js} +2 -2
- package/dist/WuiCommentThread-CjbH1bTm.js +1 -0
- package/dist/WuiConsentBanner-BF5ymoH5.js +1 -0
- package/dist/WuiContextMenu-C_u0AVna.js +1 -0
- package/dist/{WuiCountrySelect-Bhhry2JJ.js → WuiCountrySelect-kgShmlip.js} +1 -1
- package/dist/WuiDataTable-BICQ8DT7.js +1 -0
- package/dist/WuiDatePicker-CkBUk76L.js +31 -0
- package/dist/WuiDateRange-3NYNJiIa.js +25 -0
- package/dist/WuiDrawer-CCrbNdBV.js +1 -0
- package/dist/{WuiHoverCard-CKAPuJSF.js → WuiHoverCard-sq6EZZYD.js} +1 -1
- package/dist/{WuiImageCrop-CvXh791S.js → WuiImageCrop-DzzzPagi.js} +2 -2
- package/dist/WuiInlineEdit-CN0-5kdq.js +1 -0
- package/dist/WuiLightbox-D_7mpvkt.js +1 -0
- package/dist/WuiMarkdown-BxmKHb3T.js +4 -0
- package/dist/WuiMentionInput-46BVSsH_.js +1 -0
- package/dist/WuiMultiSelect-Brdm5tAI.js +25 -0
- package/dist/WuiNotificationCenter-DBSXYFYm.js +1 -0
- package/dist/{WuiOtp-DfhXc829.js → WuiOtp-Hw6srogj.js} +1 -1
- package/dist/WuiOverflow-Bn68qgAQ.js +1 -0
- package/dist/WuiPhone-DuMF_Dzx.js +16 -0
- package/dist/{WuiRecordPager-DRSJg2o9.js → WuiRecordPager-BOaFcs_W.js} +1 -1
- package/dist/WuiRelativeTime-9u8XG-nr.js +1 -0
- package/dist/{WuiResizable-CtwCQUWR.js → WuiResizable-mt9EMhjQ.js} +1 -1
- package/dist/WuiRollingNumber-C72xBgyG.js +1 -0
- package/dist/WuiSavedViews-DrJWvWuf.js +1 -0
- package/dist/WuiSelect-Bma_H42p.js +15 -0
- package/dist/WuiShortcuts-Cerbe67I.js +1 -0
- package/dist/WuiSlider-DXJGSJHP.js +48 -0
- package/dist/WuiSortable-r5iZtzM1.js +1 -0
- package/dist/WuiTagInput-C38b3LfS.js +6 -0
- package/dist/{WuiTimePicker-CAT3RHia.js → WuiTimePicker-Bw5BKBCD.js} +3 -3
- package/dist/WuiTour-DjR-6kr5.js +1 -0
- package/dist/WuiTree-BN-o92yj.js +1 -0
- package/dist/{WuiTruncate-Cxujs1Xt.js → WuiTruncate-DyDQWMBu.js} +1 -1
- package/dist/WuiWhatsNew-Biolggw8.js +1 -0
- package/dist/WuiWizardStep-DkEdAXc8.js +1 -0
- package/dist/dataTable-4RjZ1c5V.js +1 -0
- package/dist/elements/autocomplete.js +1 -1
- package/dist/elements/carousel.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/consent-banner.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/country-select.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/multiselect.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/otp.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/record-pager.js +1 -1
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/rolling-number.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/sortable.js +1 -1
- package/dist/elements/taginput.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/truncate.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/fileViewerImage-Bn5HCF30.js +3 -0
- package/dist/fileViewerMedia-zSDnvCSa.js +1 -0
- package/dist/{fileViewerPdf-Ck65ajvk.js → fileViewerPdf-C1QZnzCq.js} +10 -7
- package/dist/fileViewerUi-CHY-0j9d.js +1 -0
- package/dist/filterPopover-C8MVAfyI.js +1 -0
- package/dist/focusOrigin-BPTN3GY3.js +1 -0
- package/dist/{formMirror-BgY7zkC3.js → formMirror-BMQTenSi.js} +1 -1
- package/dist/formatters-7rx97Lnm.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/iconGlyphs.g-CQcMoS6_.js +1 -0
- package/dist/kanban-B4bOs1tX.js +1 -0
- package/dist/{max-CNrKnpEj.js → max-ByBKGsXq.js} +49 -13
- package/dist/notificationDays-CZNthz7L.js +1 -0
- package/dist/{optionLabel-BzSZIfTK.js → optionLabel-BaLjjB-0.js} +1 -1
- package/dist/shortcutKeys-CvxSh3bV.js +1 -0
- package/dist/themeTransition-lIK8WDpA.js +1 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-chart.global.js +11 -11
- package/dist/ui-chart.js +11 -11
- package/dist/ui-chat.global.js +6 -5
- package/dist/ui-chat.js +6 -5
- package/dist/ui-consent-banner.global.js +1 -1
- package/dist/ui-elements/autocomplete.global.js +6 -6
- 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 +2 -2
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +2 -2
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +3 -3
- package/dist/ui-elements/multiselect.global.js +15 -15
- package/dist/ui-elements/phone.global.js +2 -2
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/slider.global.js +2 -2
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/taginput.global.js +3 -3
- package/dist/ui-elements/timepicker.global.js +2 -2
- 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 +5 -5
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +9 -9
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-phone.global.js +6 -6
- package/dist/ui-rich-text.global.js +30 -30
- package/dist/ui-rich-text.js +32 -32
- package/dist/ui-tour.global.js +1 -1
- package/dist/wuiHttp-CHYHtqMj.js +1 -0
- package/package.json +6 -7
- package/dist/WuiAutocomplete-C3LuBiu4.js +0 -13
- package/dist/WuiCodeBlock-DDGAzbLY.js +0 -1
- package/dist/WuiCommentThread-2zTmGnYX.js +0 -1
- package/dist/WuiConsentBanner-hpbfnzFw.js +0 -1
- package/dist/WuiContextMenu-DT_dPAuA.js +0 -1
- package/dist/WuiDataTable-CoxLsrAF.js +0 -1
- package/dist/WuiDatePicker-D31sKod9.js +0 -31
- package/dist/WuiDateRange-Gp_j7d7m.js +0 -25
- package/dist/WuiDrawer-BDPrSmML.js +0 -1
- package/dist/WuiInlineEdit-DGNbQ3HR.js +0 -1
- package/dist/WuiLightbox-W0wf8oq_.js +0 -1
- package/dist/WuiMarkdown-DdsyCxS8.js +0 -4
- package/dist/WuiMentionInput-ChBBZ_6s.js +0 -1
- package/dist/WuiMultiSelect-B0wkS6Xo.js +0 -25
- package/dist/WuiNotificationCenter-D45IwPH0.js +0 -1
- package/dist/WuiOverflow-i_dzzIuJ.js +0 -1
- package/dist/WuiPhone-DUXUcwLA.js +0 -16
- package/dist/WuiRelativeTime-B5I84Rkz.js +0 -1
- package/dist/WuiRollingNumber-BVwFF7Ha.js +0 -1
- package/dist/WuiSavedViews-CYtzjqya.js +0 -1
- package/dist/WuiSelect-DBRq3AO3.js +0 -15
- package/dist/WuiShortcuts-BpR8npaI.js +0 -1
- package/dist/WuiSlider-IOqadOtK.js +0 -48
- package/dist/WuiSortable-CugtxycN.js +0 -1
- package/dist/WuiTagInput-H8-w6AgR.js +0 -6
- package/dist/WuiTour-BMGg8CQx.js +0 -1
- package/dist/WuiTree-Bqz4_0iV.js +0 -1
- package/dist/WuiWhatsNew-DkI69gjR.js +0 -1
- package/dist/WuiWizardStep-MuHvGIgJ.js +0 -1
- package/dist/dataTable-SKMmByaz.js +0 -1
- package/dist/fileViewerImage-CRHxKT23.js +0 -3
- package/dist/fileViewerMedia-CMvl6sZ2.js +0 -1
- package/dist/fileViewerUi-DILhcQ1D.js +0 -1
- package/dist/filterPopover-pkhDKdKR.js +0 -1
- package/dist/focusOrigin-2imUSs-u.js +0 -1
- package/dist/formatters-6DhcQIjT.js +0 -1
- package/dist/iconGlyphs.g-DyfWnfAm.js +0 -1
- package/dist/kanban-CCWe5NI1.js +0 -1
- package/dist/notificationDays-DOIBIwN5.js +0 -1
- package/dist/shortcutKeys-DdQ_0ops.js +0 -1
- package/dist/themeTransition-BY52mM_w.js +0 -1
- package/dist/types/chatClient.d.ts +0 -208
- package/dist/types/chatCore.d.ts +0 -21
- package/dist/types/chatLabels.d.ts +0 -70
- package/dist/types/sse.d.ts +0 -33
- package/dist/ui-chat-core.js +0 -7
- package/dist/wuiHttp-D6Qp9bRZ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.
|
|
1
|
+
(function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.124.0`)throw Error(`[webority-ui] date-range expects ui-elements 0.124.0 but the page loaded `+c+`.`);var l=`Asia/Kolkata`,u=3,d=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],f={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},p=e=>String(e).padStart(2,`0`),m=e=>`${e.getUTCFullYear()}-${p(e.getUTCMonth()+1)}-${p(e.getUTCDate())}`;function h(e=new Date){let t=new Intl.DateTimeFormat(`en-US`,{timeZone:l,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),n=e=>t.find(t=>t.type===e).value;return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}function g(e,t=new Date){let{y:n,m:i,d:a}=(0,r.parseIso)(h(t)),o=(e,t,n)=>m(new Date(Date.UTC(e,t,n))),s=f[e];switch(e){case`today`:return{label:s,start:o(n,i,a),end:o(n,i,a)};case`yesterday`:return{label:s,start:o(n,i,a-1),end:o(n,i,a-1)};case`last7Days`:return{label:s,start:o(n,i,a-6),end:o(n,i,a)};case`last30Days`:return{label:s,start:o(n,i,a-29),end:o(n,i,a)};case`thisMonth`:return{label:s,start:o(n,i,1),end:o(n,i+1,0)};case`lastMonth`:return{label:s,start:o(n,i-1,1),end:o(n,i,0)};case`thisFinancialYear`:{let e=i>=u?n:n-1;return{label:s,start:o(e,u,1),end:o(e+1,u,0)}}default:return null}}function _(e){(0,i.devWarn)(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function v(e,t=new Date){let n=String(e??``).trim();if(!n)return[];let i;if(n.startsWith(`[`))try{i=JSON.parse(n)}catch{return _(`the attribute is not valid JSON`),[]}else i=n.split(`,`).map(e=>e.trim());let a=[];for(let e of i)if(typeof e==`string`){let n=g(e,t);n?a.push(n):_(`"${e}" is not one of ${d.join(`, `)}`)}else e&&typeof e.label==`string`&&e.label&&(0,r.parseIso)(e.start)&&(0,r.parseIso)(e.end)?a.push({label:e.label,start:e.start,end:e.end}):_(`an item needs a label and ISO start and end dates, or a preset name`);return a}var y=class extends a.ElementBase{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return(0,r.firstWeekday)(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${(0,r.fmt)(this._start)||`Start`} to ${(0,r.fmt)(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=(0,r.parseIso)(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:i,empty:a}=this._label(),c=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
2
2
|
<div class="daterange">
|
|
3
3
|
<button type="button" class="input daterange-trigger${n}${a?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${c?` aria-label="${(0,s.escapeHtml)(c)}"`:``}${l?` aria-describedby="${(0,s.escapeHtml)(l)}"`:``}>
|
|
4
4
|
<span data-range-label class="${a?`search-select-placeholder`:``}">${(0,s.escapeHtml)(i)}</span>
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
<div class="datepicker-foot">
|
|
23
23
|
<span class="daterange-hint" data-range-hint></span>
|
|
24
24
|
<button type="button" class="datepicker-link" data-clear>Clear</button>
|
|
25
|
-
</div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${i}</div>`:i,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let i=n?new Date(n).getTime():null;for(let n of e.querySelectorAll(`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso).getTime(),r=t!=null&&e===t,a=i!=null&&e===i,o=t!=null&&i!=null&&e>t&&e<i;n.classList.toggle(`is-range-start`,r),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}e.querySelectorAll(`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=e.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?`${(0,r.fmt)(this._start)} to ${(0,r.fmt)(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){(0,n.anchorOverlay)(e,t,{clampHeight:!0})}_pick(e){
|
|
25
|
+
</div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${i}</div>`:i,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let i=n?new Date(n).getTime():null;for(let n of e.querySelectorAll(`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso).getTime(),r=t!=null&&e===t,a=i!=null&&e===i,o=t!=null&&i!=null&&e>t&&e<i;n.classList.toggle(`is-range-start`,r),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}e.querySelectorAll(`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=e.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?`${(0,r.fmt)(this._start)} to ${(0,r.fmt)(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){(0,n.anchorOverlay)(e,t,{clampHeight:!0})}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_wire(){this._teardown();let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),i=this.querySelector(`.daterange`);if(!e||!t)return;let a=()=>!t.hidden,o=()=>{a()&&this._position(e,t)};this._open=()=>{let a=(0,r.parseIso)(this._start);if(a)this._viewY=a.y,this._viewM=a.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=v(this.getAttribute(`presets`)),this._renderView(),t.hidden=!1,i?.classList.add(`open`),this._position(e,t),(0,n.bindReanchor)(this,o),e.setAttribute(`aria-expanded`,`true`)},this._close=()=>{t.hidden=!0,this._hover=``,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),(0,n.unbindReanchor)(this)},e.addEventListener(`click`,()=>a()?this._close():this._open()),t.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){let e=(0,r.clampMonth)(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(e.target.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let n=e.target.closest(`[data-preset]`);if(n&&!n.disabled){let e=this._presetList?.[Number(n.dataset.preset)];e&&this._applyPreset(e);return}let i=e.target.closest(`.datepicker-day[data-iso]`);i&&!i.disabled&&this._pick(i.dataset.iso)}),t.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.datepicker-day[data-iso]`);t&&this._start&&!this._end&&(this._hover=t.dataset.iso,this._paint())}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),this._onHostKey=e=>{a()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this._close())},this.addEventListener(`keydown`,this._onHostKey),a()&&(0,n.bindReanchor)(this,o)},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),this._onHostKey&&=(this.removeEventListener(`keydown`,this._onHostKey),null),(0,n.unbindReanchor)(this)}disconnectedCallback(){this._teardown()}};(0,t.defineElement)(`wui-date-range`,y),e.WuiDateRange=y})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.anchorOverlay,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.optionLabel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.124.0`)throw Error(`[webority-ui] drawer expects ui-elements 0.124.0 but the page loaded `+r+`.`);var i=[50,90],a=10,o=100;function s(e,t=i){let n=Array.isArray(e)?e:String(e??``).split(`,`),r=[];for(let e of n){if(typeof e==`string`&&e.trim()===``)return t;let n=Number(e);if(!Number.isFinite(n)||n<a||n>o)return t;r.includes(n)||r.push(n)}return r.length?r.sort((e,t)=>e-t):t}function c({points:e,index:t,visible:n,velocity:r,canDismiss:i}){let a=i?-1:0;if(Math.abs(r)>=.5)return r>0?Math.max(t-1,a):Math.min(t+1,e.length-1);if(i&&n<e[0]/2)return-1;let o=0;for(let t=1;t<e.length;t++)Math.abs(e[t]-n)<Math.abs(e[o]-n)&&(o=t);return o}var l=`(max-width: 767.98px)`,u=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,d=4,f=0,p=new WeakSet;function m(e){p.has(e)||(p.add(e),e.addEventListener(`click`,t=>{let n=t.target?.closest?.(`[data-wui-drawer-open]`);if(!n)return;let r=n.getAttribute(`data-wui-drawer-open`).replace(/^#/,``),i=e.getElementById(r);typeof i?.show==`function`&&(t.preventDefault(),i.show(n))}))}var h=class extends n.ElementBase{static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),this._doc=null,this._media=null,this._shown=!1,this._locked=!1,this._opener=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onClick=e=>this._click(e),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onHostKey=e=>{e.key===`Escape`&&this._keyDown(e)},this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this._announce()},this._announced=!1}connectedCallback(){this._doc=this.ownerDocument,m(this._doc),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(l):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)?this._open():this.setAttribute(`inert`,``)}disconnectedCallback(){this._endDrag(),this._shown&&this._release(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return s(this.getAttribute(`snap-points`),i)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!t)return;let n=e[this._snap];t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(n)),t.setAttribute(`aria-valuetext`,`${n}% of the screen`)}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;this._shown=!0;let e=this._doc;this._opener??=e.activeElement;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.removeAttribute(`inert`),this._locked||(this._locked=!0,f++,e.body.classList.add(`wui-drawer-locked`)),e.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onHostKey),this._focusIn(),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this.setAttribute(`inert`,``);let e=this._doc,t=this._opener,n=e.activeElement;this._release(),this._opener=null,t?.isConnected&&(n===e.body||this.contains(n))&&t.focus?.(),this._settle()}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._announced&&(this._announced=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_release(){this._shown=!1,this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onHostKey),this._locked&&(this._locked=!1,f--,f<=0&&(f=0,this._doc?.body.classList.remove(`wui-drawer-locked`)))}_panel(){return this.querySelector(`.wui-drawer-panel`)}_focusables(){let e=this._panel();return e?Array.from(e.querySelectorAll(u)).filter(e=>!e.closest(`[hidden],[inert]`)):[]}_focusIn(){let e=this._panel();if(!e)return;let t=e.querySelector(`[data-autofocus]`),n=this._sheet()?null:this._focusables().find(e=>e.closest(`.wui-drawer-body`));(t||n||e).focus?.()}_requestClose(){let e=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}));return e&&this.hide(),e}_click(e){if(!this.isOpen)return;let t=e.target;(t.closest?.(`[data-wui-drawer-close]`)||t.closest?.(`[data-wui-drawer-backdrop]`)&&!this.hasAttribute(`static`))&&this._requestClose()}_keyDown(e){if(e.key===`Escape`){if(e.defaultPrevented||this.hasAttribute(`static`)||this._doc.querySelector(`.modal.show`))return;e.preventDefault(),e.stopPropagation(),this._requestClose()}else e.key===`Tab`?this._trapTab(e):e.target?.closest?.(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_trapTab(e){let t=this._focusables(),n=this._panel();if(!t.length){e.preventDefault(),n?.focus?.();return}let r=t[0],i=t[t.length-1],a=this._doc.activeElement;!n?.contains(a)||a===n?(e.preventDefault(),(e.shiftKey?i:r).focus()):e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};e.key in n&&(e.preventDefault(),this._setSnap(n[e.key]))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target?.closest?.(`[data-wui-drawer-grip]`);t&&!e.target.closest(`button`)&&(this._drag={grip:t,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},t.setPointerCapture?.(e.pointerId),t.addEventListener(`pointermove`,this._onPointerMove),t.addEventListener(`pointerup`,this._onPointerUp),t.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){return this._doc.defaultView.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<d)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(i[i.length-1]-i[this._snap])/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let a=this._points(),o=this._viewport(),s=(a[this._snap]/100*o-i)/(o/100),l=!this.hasAttribute(`static`),u=c({points:a,index:this._snap,visible:s,velocity:r,canDismiss:l});u>=0?this._setSnap(u):this._requestClose()}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};(0,t.defineElement)(`wui-drawer`,h),e.WuiDrawer=h})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.124.0`)throw Error(`[webority-ui] image-crop expects ui-elements 0.124.0 but the page loaded `+r+`.`);var i=4096,a=[.92,.8,.65,.5],o=.8,s=8;function c(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function l(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function u(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function d(e,t,n,r,i){return u({...e,x:e.x+t,y:e.y+n},r,i)}function f(e,t){return Math.min(32,e,t)}function p(e,t){return t.w/e.w}function m(e,t){return Math.max(4,p(e,t))}function h(e,t,n,r,i){let a=Math.min(Math.max(n,1),m(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(f(r,i),f(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),d=l*o,p=e.x+e.w/2,h=e.y+e.h/2;return u({x:p-l/2,y:h-d/2,w:l,h:d},r,i)}var g=[`nw`,`ne`,`sw`,`se`];function _(e,t,n,r,i,a){let o=f(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),p=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),p=c?Math.min(p,u-o):Math.max(p,u+o),{x:Math.min(d,l),y:Math.min(p,u),w:Math.abs(d-l),h:Math.abs(p-u)}}function v(e,t=i){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function y(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function b(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function x(e,t,n){return u({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function S(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var C=[`image/png`,`image/jpeg`,`image/webp`],w={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function T(e){let t=String(e||``).toLowerCase();return C.includes(t)?t:`image/png`}function E(e,t){let n=String(e||`image`),r=w[t];return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function D(e,{width:t,height:n,type:r,maxBytes:i}){let c=r,l=t,u=n,d=null;for(let t=0;t<=s;t++){let n=c===`image/png`?[void 0]:t===0?a:[a[1]];for(let t of n){if(d=await e(l,u,c,t),!d||(d.type&&d.type!==c&&(c=d.type),!(i>0)||d.size<=i))return d;if(c===`image/png`)break}l=Math.max(1,Math.round(l*o)),u=Math.max(1,Math.round(u*o))}return d}var O=.05,k=.2,A={w:320,h:240},j={nw:`top left`,ne:`top right`,sw:`bottom left`,se:`bottom right`},M=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"/></svg>`,N=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14M12 5v14"/></svg>`,P=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,F=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>`,I=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),L=class extends n.ElementBase{static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return c(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?p(this._rect,this._base):1}set zoom(e){this._rect&&(this._rect=h(this._rect,this._base,Number(e)||1,this._natural.w,this._natural.h),this._paint(),this._announce())}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.innerHTML=`<div>
|
|
2
2
|
<div class="wui-crop-stage" tabindex="0" role="group" aria-label="Crop area. Drag the frame or use the arrow keys to move it, and plus or minus to zoom.">
|
|
3
3
|
<img class="wui-crop-img" alt="" draggable="false">
|
|
4
4
|
<div class="wui-crop-frame"></div>
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
</div>
|
|
15
15
|
<div class="wui-crop-previews" aria-hidden="true" hidden></div>
|
|
16
16
|
<div class="visually-hidden" data-wui-crop-live aria-live="polite"></div>
|
|
17
|
-
</div>`,this._stage=this.querySelector(`.wui-crop-stage`),this._img=this.querySelector(`.wui-crop-img`),this._frame=this.querySelector(`.wui-crop-frame`),this._slider=this.querySelector(`.wui-crop-zoom`),this._tools=this.querySelector(`.wui-crop-tools`),this._previewBox=this.querySelector(`.wui-crop-previews`),this._live=this.querySelector(`[data-wui-crop-live]`),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of g){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,`Resize ${j[e]} corner`),this._frame.appendChild(t)}}_renderPreviews(){let e=S(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=l(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=this._stage.clientWidth||A.w,t=this._stage.clientHeight||A.h,n=Math.min(e/this._natural.w,t/this._natural.h),r=this._natural.w*n,i=this._natural.h*n;return{scale:n,left:(e-r)/2,top:(t-i)/2,iw:r,ih:i}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=p(i,this._base),o=m(i,this._base);this._slider.max=String(o),this._slider.value=String(Math.min(Math.max(a,1),o)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(a*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=u(this._rect,this._natural.w,this._natural.h),t=typeof window<`u`&&window.devicePixelRatio||1;for(let n of this._previewBox.children){let r=Number(n.dataset.size),i=Math.max(1,Math.round(r*e.h/e.w));n.style.width=`${r}px`,n.style.height=`${i}px`,n.width=Math.round(r*t),n.height=Math.round(i*t);let a=n.getContext(`2d`);a&&this._drawCrop(a,e,n.width,n.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=this._source;e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(this._natural.w/2,this._natural.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=this._rect,t=this._rotation?`, turned ${this._rotation} degrees`:``,n=`Frame ${Math.round(e.w)} by ${Math.round(e.h)} pixels, ${Math.round(e.x)} from the left, ${Math.round(e.y)} from the top, zoom ${Math.round(p(e,this._base)*100)}%${t}.`;this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=x(this._rect,this._natural.w,this._natural.h);this._rotation=(this._rotation+90)%360,this._natural=b(this._source.w,this._source.h,this._rotation),this._base=l(this._natural.w,this._natural.h,this.aspect);let t=this.aspect;this._rect=t&&t!==1?{...this._base}:e,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._drag=null,this._pinch={distance:I(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=t.target.closest?.(`.wui-crop-handle`);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=[...this._pointers.values()],r=this._pinch.zoom*I(e,n)/this._pinch.distance;this._rect=h(this._rect,this._base,r,this._natural.w,this._natural.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=this._natural;if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=_(this._rect,n.corner,s,c,i,a)}else this._rect=d(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag
|
|
17
|
+
</div>`,this._stage=this.querySelector(`.wui-crop-stage`),this._img=this.querySelector(`.wui-crop-img`),this._frame=this.querySelector(`.wui-crop-frame`),this._slider=this.querySelector(`.wui-crop-zoom`),this._tools=this.querySelector(`.wui-crop-tools`),this._previewBox=this.querySelector(`.wui-crop-previews`),this._live=this.querySelector(`[data-wui-crop-live]`),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of g){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,`Resize ${j[e]} corner`),this._frame.appendChild(t)}}_renderPreviews(){let e=S(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=l(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=this._stage.clientWidth||A.w,t=this._stage.clientHeight||A.h,n=Math.min(e/this._natural.w,t/this._natural.h),r=this._natural.w*n,i=this._natural.h*n;return{scale:n,left:(e-r)/2,top:(t-i)/2,iw:r,ih:i}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=p(i,this._base),o=m(i,this._base);this._slider.max=String(o),this._slider.value=String(Math.min(Math.max(a,1),o)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(a*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=u(this._rect,this._natural.w,this._natural.h),t=typeof window<`u`&&window.devicePixelRatio||1;for(let n of this._previewBox.children){let r=Number(n.dataset.size),i=Math.max(1,Math.round(r*e.h/e.w));n.style.width=`${r}px`,n.style.height=`${i}px`,n.width=Math.round(r*t),n.height=Math.round(i*t);let a=n.getContext(`2d`);a&&this._drawCrop(a,e,n.width,n.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=this._source;e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(this._natural.w/2,this._natural.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=this._rect,t=this._rotation?`, turned ${this._rotation} degrees`:``,n=`Frame ${Math.round(e.w)} by ${Math.round(e.h)} pixels, ${Math.round(e.x)} from the left, ${Math.round(e.y)} from the top, zoom ${Math.round(p(e,this._base)*100)}%${t}.`;this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=x(this._rect,this._natural.w,this._natural.h);this._rotation=(this._rotation+90)%360,this._natural=b(this._source.w,this._source.h,this._rotation),this._base=l(this._natural.w,this._natural.h,this.aspect);let t=this.aspect;this._rect=t&&t!==1?{...this._base}:e,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._drag=null,this._pinch={distance:I(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=t.target.closest?.(`.wui-crop-handle`);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=[...this._pointers.values()],r=this._pinch.zoom*I(e,n)/this._pinch.distance;this._rect=h(this._rect,this._base,r,this._natural.w,this._natural.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=this._natural;if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=_(this._rect,n.corner,s,c,i,a)}else this._rect=d(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`))e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8});this.querySelector(`[data-crop-action="rotate"]`).addEventListener(`click`,()=>this.rotate()),this.querySelector(`[data-crop-action="reset"]`).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=this._natural;if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?k:O,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=e.target.closest?.(`.wui-crop-handle`)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=_(e,o,s,c,t,n)}else this._rect=d(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=T(e),i=u(this._rect,this._natural.w,this._natural.h),{width:a,height:o}=n>0?y(i,n):v(i);return D((e,t,n,r)=>new Promise(a=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,i,e,t),o.toBlob(a,n,r)):a(null)}),{width:a,height:o,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],E(e,i.type),{type:i.type}):null}};(0,t.defineElement)(`wui-image-crop`,L),e.WuiImageCrop=L})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.
|
|
1
|
+
(function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.124.0`)throw Error(`[webority-ui] inline-edit expects ui-elements 0.124.0 but the page loaded `+o+`.`);var s=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),c=2e3,l=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function u(e,{type:t=`text`,options:r,placeholder:a}={}){let o=e==null?``:String(e);if(o===``)return{text:a||i.EMPTY_VALUE,empty:!0};if(t===`date`)return{text:(0,n.fmt)(o)||o,empty:!1};if(t===`select`){let e=r?.find(e=>String(e.value)===o);return{text:typeof e?.label==`string`?e.label:o,empty:!1}}return{text:o,empty:!1}}var d=`[data-wui-display]`,f=`[data-wui-value]`,p=`[data-wui-editor]`,m=`[data-wui-control]`,h=`[data-wui-error]`,g=`[data-wui-live]`,_=`[aria-expanded="true"]`,v=new Set([`select`,`date`]),y=e=>typeof e?.message==`string`&&e.message?e.message:l.failed.server,b=class extends r.ElementBase{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(d),t=this.querySelector(p),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(d)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(p)?.querySelector(_))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||v.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!v.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(l.saved(o)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(l.notSaved(o,a.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:y(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await(0,a.wuiFetch)(n,{method:`POST`,body:r});return i.ok?{ok:!0,text:i.html.trim()}:{ok:!1,kind:i.kind,message:i.message||l.failed[i.kind]||l.failed.server}}_close(){let e=this.querySelector(d),t=this.querySelector(p),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(_)?.click(),n&&e?.focus()}_focusControl(e){if(!v.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||i.EMPTY_VALUE,!0);return}let t=this._type(),r=e;if(t===`date`)r=(0,n.fmt)(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(r=t.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(f);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(f);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(f);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(h),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(g);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(m)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return s.includes(e)?e:`text`}};(0,t.defineElement)(`wui-inline-edit`,b),e.INLINE_EDIT_SAVED_MS=c,e.INLINE_EDIT_TEXT=l,e.INLINE_EDIT_TYPES=s,e.WuiInlineEdit=b,e.inlineEditText=u})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.wuiHttp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.122.0`)throw Error(`[webority-ui] kanban expects ui-elements 0.122.0 but the page loaded `+s+`.`);var c=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),l=Object.freeze([`number`,`currency`,`compact`]),u=`wui-kanban:`,d=`(max-width: 767.98px)`,f=400,p=6,m=Object.freeze({help:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,empty:`Nothing here`,collapse:e=>`Collapse ${e}`,expand:e=>`Expand ${e}`,lifted:(e,t)=>`Picked up ${e} in ${t}. Use the Left and Right arrow keys to choose a column.`,over:(e,t)=>`${e}, ${t===1?`1 card`:`${t} cards`}. Drop allowed.`,overSource:e=>`${e}, where the card started.`,overRefused:(e,t)=>`${e}. ${t}`,dropHere:(e,t)=>`Drop here to move ${e} to ${t}.`,refused:(e,t)=>`Cards in ${e} cannot move to ${t}.`,moved:(e,t)=>`Moved ${e} to ${t}.`,saving:(e,t)=>`Moving ${e} to ${t}.`,cancelled:e=>`${e} was not moved.`,rolledBack:(e,t)=>`${e} went back to ${t}.`,locked:e=>`${e} cannot be moved.`,more:e=>`Show ${e} more`,fewer:`Show fewer`,loadMore:e=>`Show more (${e})`,loading:`Loading…`,loadFailed:`More cards could not be loaded. Try again.`,swipeHint:`Swipe sideways or tap a column`,busy:`This card is still saving. Try again in a moment.`,failed:Object.freeze({forbidden:`You do not have permission to move this card.`,client:`This card could not be moved. Refresh the board and try again.`,validation:`This card could not be moved. Refresh the board and try again.`,server:`Something went wrong on our side, so the card went back. Try again in a moment.`,network:`Could not reach the server, so the card went back. Check your connection and try again.`})}),h=`[data-wui-column]`,g=`[data-wui-body]`,_=`[data-wui-card]`,v=`[data-wui-count]`,y=`[data-wui-summary]`,b=`[data-wui-empty]`,x=`[data-wui-drop-note]`,S=`[data-wui-live]`,C=`[data-wui-help]`,w=`[data-wui-switch]`,T=`[data-wui-scroller]`,E=`[data-wui-collapse]`,D=`[data-wui-more]`,O=`data-wui-visible-limit`,k=`data-wui-overflow`,A=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,j=`[data-wui-load-more]`,M=`data-wui-more-url`,N=`data-wui-total`,P=`data-wui-unloaded`,F=48,I=16,L=160,R=e=>e.getAttribute(`data-wui-column`),z=e=>e.getAttribute(`data-wui-card`),B=e=>e.hidden||e.hasAttribute(`hidden`),V=e=>B(e)||e.hasAttribute(k);function H(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function U(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function W(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||z(e)||`Card`}function G(e){return e?`${u}${e}`:null}function K(e,t=globalThis.localStorage){let n=G(e);if(!n||!t)return{};try{let e=JSON.parse(t.getItem(n)||`null`);return e&&typeof e.collapsed==`object`&&e.collapsed?e.collapsed:{}}catch{return{}}}function q(e,t,n,r=globalThis.localStorage){let i=G(e);if(!i||!r)return;let a={...K(e,r),[t]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch{}}function J(e,t){if(!l.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${l.join(`, `)}.`);if(t!=null&&t!==``&&!i.MONEY_UNITS.includes(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:i.CURRENCIES[0],unit:t||`rupees`}:{style:`number`,decimals:0}}function Y(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var X=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},Z=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>this._loadOnScroll(e.target),!0),this.addEventListener(`dragstart`,e=>{e.target.closest?.(_)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e.nodeType===1&&e.matches(_)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(g))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=R(t),r=H(t.getAttribute(O)),a=[],o=[];for(let e of this._cardsIn(t)){if(this._filter&&(e.hidden=this._filter(e)===!1),B(e)){e.removeAttribute(k);continue}a.push(e),o.push(e.getAttribute(`data-wui-value`))}let s=this._expanded.has(n),c=U(a.map(z),r,s,this._revealed);for(let e of a)e.toggleAttribute(k,c.has(z(e)));let l=this._unloadedIn(t),u=String(a.length+l);for(let e of this._countsOf(t))e.textContent!==u&&(e.textContent=u);let d=t.querySelector(b);if(d&&(d.hidden=a.length>0),e){let n=t.querySelector(y);n&&(n.textContent=(0,i.formatValue)(Y(o),e))}let f=t.querySelector(D);if(f){f.hidden=r==null||(s?a.length<=r:c.size===0),f.setAttribute(`aria-expanded`,s?`true`:`false`);let e=s?m.fewer:m.more(c.size);f.textContent!==e&&(f.textContent=e)}let p=t.querySelector(j);if(p&&(p.hidden=l<=0,!t.hasAttribute(`data-wui-loading`))){p.disabled=!1;let e=m.loadMore(l);p.textContent!==e&&(p.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return[...this.querySelectorAll(h)]}_columnByKey(e){return this._columns().find(t=>R(t)===e)||null}_columnOf(e){return e.closest(h)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||R(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return e.querySelector(g)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e.matches(_)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!V(e))}_allCards(){return[...this.querySelectorAll(`${g} > ${_}`)]}_cardByKey(e){return this._allCards().find(t=>z(t)===e)||null}_countsOf(e){let t=R(e),n=[...this.querySelectorAll(w)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(v),...n.flatMap(e=>[...e.querySelectorAll(v)])]}_scroller(){return this.querySelector(T)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?J(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(C);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=this.querySelector(S);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=W(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(m.locked(t)),this._fire(`wui:kanban:locked`,{key:z(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)===`true`?(this._announce(m.busy),X(m.busy,`info`),!1):!0}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=m.refused(r?this._titleOf(r):t,i?this._titleOf(i):n),o=i?.getAttribute(`data-accept-from`);if(o!=null&&!o.split(/\s+/).filter(Boolean).includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=W(e),r=new Map;for(let i of this._columns()){let a=R(i),o=this._check(e,t,a);r.set(a,o),i.setAttribute(`data-wui-drop`,o.source?`source`:o.ok?`ok`:`refused`);let s=i.querySelector(x);s&&!o.source&&(s.textContent=o.ok?m.dropHere(n,this._titleOf(i)):o.reason,s.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=e.querySelector(x);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e),i=R(r),a=this._columnByKey(t),s=W(e);if(i===t||!this._canLift(e))return!1;let c=this._check(e,i,t);if(!c.ok)return this._announce(c.reason),X(c.reason,`info`),!1;let l=this._cardsIn(a),u=Number.isInteger(n)?Math.max(0,Math.min(n,l.length)):l.length,d={key:z(e),card:e,from:i,to:t,index:u},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(m.moved(s,this._titleOf(a))),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=a.hasAttribute(O)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p};this._bodyOf(a).insertBefore(e,l[u]||null),f&&this._focusMoved(e),this.refresh();let g=a.getAttribute(`data-wui-step`);if(g)return this._runStep(e,d,h,g,a.getAttribute(`data-wui-step-size`));let _=this.getAttribute(`move-url`);if(!_)return this._announce(m.moved(s,this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(m.saving(s,this._titleOf(a)));let v=await(0,o.wuiFetch)(_,{method:`POST`,body:new URLSearchParams({card:d.key,from:i,to:t,index:String(u)})});if(this._lock(e,!1),v.kind===`session`)return!1;if(v.ok){let t=this._applyFragment(v.html)||e;return X(v.message,`success`),this._announce(m.moved(W(t),this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,card:t,result:v}),!0}return this._rollback(e,h),v.kind!==`aborted`&&X(v.message||m.failed[v.kind]||m.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:v.kind,status:v.status,message:v.message}),!1}async _runStep(e,t,n,r,i){let s=W(e),c=this._columnByKey(t.to),l=new URLSearchParams({card:t.key,from:t.from,to:t.to}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+l;this._lock(e,!0);let d;try{d=await(await(0,a.loadRemoteModal)(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),r?.name!==`AbortError`&&X(m.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:r?.message??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(m.cancelled(s)),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,o.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:t.key})}`);n.ok&&(f=this._applyFragment(n.html)||e)}return this._lock(f,!1),this._announce(m.moved(W(f),this._titleOf(c))),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;t.revealed&&this._revealed.delete(z(e)),t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(m.rolledBack(W(e),this._titleOf(t.column)))}_applyFragment(e){if(!e)return null;let t=document.createElement(`template`);t.innerHTML=e;for(let e of t.content.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of[...t.content.querySelectorAll(_)]){if(e.closest(`template`))continue;let t=this._cardByKey(z(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of t.content.querySelectorAll(`template[data-wui-kanban-summary]`))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(y)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),window.WUI?.refresh?.(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=e.target.closest?.(_);if(!t||!this.contains(t)||e.target.closest(A))return;let n={card:t,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=n,e.pointerType===`touch`&&(n.timer=setTimeout(()=>{this._press===n&&this._startDrag(n,n.x,n.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(!(!t||e.pointerId!==t.id)){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){!this._press||e.pointerId!==this._press.id||this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=R(this._columnOf(r)),a=r.getBoundingClientRect(),o=r.cloneNode(!0);for(let e of[o,...o.querySelectorAll(`[id]`)])e.removeAttribute(`id`);o.removeAttribute(`data-wui-card`),o.removeAttribute(`tabindex`),o.setAttribute(`aria-hidden`,`true`),o.classList.add(`wui-kanban-ghost`),o.style.width=`${a.width}px`,this.appendChild(o),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:i,ghost:o,dx:t-a.left,dy:n-a.top,over:null,verdicts:this._markTargets(r,i)},this._announce(m.lifted(W(r),this._titleOf(this._columnOf(r)))),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+F?r.scrollBy?.({left:-16}):e>t.right-F&&r.scrollBy?.({left:I}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<F?window.scrollBy?.({top:-16}):t>i-F&&window.scrollBy?.({top:I}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+F&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-F&&n.scrollTop+n.clientHeight<n.scrollHeight-1?(n.scrollBy?.({top:I}),!0):!1}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce(m.cancelled(W(n.card)));return}let i=R(r),a=n.verdicts.get(i);if(a?.source){this._announce(m.cancelled(W(n.card)));return}if(!a?.ok){this._announce(a?.reason),X(a?.reason,`info`);return}this._commit(n.card,i,this._indexAt(r,n.y))}_click(e){if(this._suppressClick&&e.target.closest?.(_)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let t=e.target.closest?.(E);if(t&&this.contains(t)){let e=t.closest(h);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let n=e.target.closest?.(j);if(n&&this.contains(n)){this._controlled()||this._loadMore(n.closest(h));return}let r=e.target.closest?.(D);if(r&&this.contains(r)){this._controlled()||this._toggleMore(r.closest(h));return}let i=e.target.closest?.(w);i&&this.contains(i)&&this._showColumn(i.getAttribute(`data-wui-switch`))}_keyDown(e){if(this._kbd){this._liftedKey(e);return}let t=e.target;if(!t.matches?.(_)||!this.contains(t))return;let n=this._columnOf(t);switch(e.key){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(t))return;let r=R(n),i=this._columns();this._kbd={card:t,from:r,target:i.indexOf(n),verdicts:this._markTargets(t,r)},t.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),n.setAttribute(`data-wui-target`,``),this._announce(m.lifted(W(t),this._titleOf(n)));return}case`ArrowDown`:case`ArrowUp`:{let r=this._visibleCardsIn(n),i=r[r.indexOf(t)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),r=e.key===`ArrowRight`?1:-1;for(let i=t.indexOf(n)+r;i>=0&&i<t.length;i+=r){let n=this._visibleCardsIn(t[i])[0];if(n&&!t[i].hasAttribute(`data-collapsed`)){e.preventDefault(),n.focus();return}}return}default:}}_liftedKey(e){let t=this._kbd,n=this._columns();switch(e.key){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let r=t.target+(e.key===`ArrowRight`?1:-1);if(r<0||r>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=r;let i=n[r];i.setAttribute(`data-wui-target`,``),this._showColumn(R(i),!1);let a=t.verdicts.get(R(i)),o=this._titleOf(i);this._announce(a.source?m.overSource(o):a.ok?m.over(o,this._cardsIn(i).filter(e=>!B(e)).length):m.overRefused(o,a.reason));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target],i=R(r),a=t.verdicts.get(i);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(m.cancelled(W(t.card))):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce(m.cancelled(W(t.card)));return;default:}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=K(this.getAttribute(`board-id`));for(let t of this._columns()){let n=R(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,n)&&this._setCollapsed(t,e[n],!1)}}_setCollapsed(e,t,n){let r=R(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(E))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?m.expand(i):m.collapse(i));n&&(q(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=R(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(z(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(M)?(e.hasAttribute(P)||e.setAttribute(P,String(Math.max(0,Number(e.getAttribute(N))-this._cardsIn(e).length))),Number(e.getAttribute(P))):0}async _loadMore(e){let t=Number(e.getAttribute(P));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=e.querySelector(j);r&&(r.disabled=!0,r.textContent=m.loading);let i=new URL(e.getAttribute(M),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,s=!1;try{let n=await(0,o.wuiFetch)(i.toString());if(n.ok){let r=document.createElement(`template`);r.innerHTML=n.html;let i=this._bodyOf(e);for(let e of[...r.content.children])!e.matches(_)||this._cardByKey(z(e))||(i.append(e),a++);let o=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(P,String(/^\d+$/.test(o)?Number(o):Math.max(0,t-a))),s=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),s?this._fire(`wui:kanban:loaded`,{key:R(e),added:a}):X(m.loadFailed,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(g))return;let t=e.closest(h);t?.hasAttribute(M)&&e.scrollTop+e.clientHeight>=e.scrollHeight-L&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(w))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(w))e.getAttribute(`data-wui-switch`)===R(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,Z),e.KANBAN_DRAG_THRESHOLD_PX=p,e.KANBAN_LONG_PRESS_MS=f,e.KANBAN_PHONE_QUERY=d,e.KANBAN_STORAGE_PREFIX=u,e.KANBAN_SUMMARY_FORMATS=l,e.KANBAN_TEXT=m,e.KANBAN_TONES=c,e.WuiKanban=Z,e.kanbanCardLabel=W,e.kanbanOverflow=U,e.kanbanStorageKey=G,e.kanbanSummaryFormat=J,e.kanbanVisibleLimit=H,e.readKanbanCollapsed=K,e.sumKanbanValues=Y,e.writeKanbanCollapsed=q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.remoteModal,WeborityUiElementsInternal.modules.wuiHttp);
|
|
1
|
+
(function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.124.0`)throw Error(`[webority-ui] kanban expects ui-elements 0.124.0 but the page loaded `+s+`.`);var c=Object.freeze([`neutral`,`primary`,`info`,`success`,`warning`,`danger`]),l=Object.freeze([`number`,`currency`,`compact`]),u=`wui-kanban:`,d=`(max-width: 767.98px)`,f=400,p=6,m=Object.freeze({help:`Press Space to pick up the card. Use the Left and Right arrow keys to choose a column, then Space to drop it, or Escape to cancel.`,empty:`Nothing here`,collapse:e=>`Collapse ${e}`,expand:e=>`Expand ${e}`,lifted:(e,t)=>`Picked up ${e} in ${t}. Use the Left and Right arrow keys to choose a column.`,over:(e,t)=>`${e}, ${t===1?`1 card`:`${t} cards`}. Drop allowed.`,overSource:e=>`${e}, where the card started.`,overRefused:(e,t)=>`${e}. ${t}`,dropHere:(e,t)=>`Drop here to move ${e} to ${t}.`,refused:(e,t)=>`Cards in ${e} cannot move to ${t}.`,moved:(e,t)=>`Moved ${e} to ${t}.`,saving:(e,t)=>`Moving ${e} to ${t}.`,cancelled:e=>`${e} was not moved.`,rolledBack:(e,t)=>`${e} went back to ${t}.`,locked:e=>`${e} cannot be moved.`,more:e=>`Show ${e} more`,fewer:`Show fewer`,loadMore:e=>`Show more (${e})`,loading:`Loading…`,loadFailed:`More cards could not be loaded. Try again.`,swipeHint:`Swipe sideways or tap a column`,busy:`This card is still saving. Try again in a moment.`,failed:Object.freeze({forbidden:`You do not have permission to move this card.`,client:`This card could not be moved. Refresh the board and try again.`,validation:`This card could not be moved. Refresh the board and try again.`,server:`Something went wrong on our side, so the card went back. Try again in a moment.`,network:`Could not reach the server, so the card went back. Check your connection and try again.`})}),h=`[data-wui-column]`,g=`[data-wui-body]`,_=`[data-wui-card]`,v=`[data-wui-count]`,y=`[data-wui-summary]`,b=`[data-wui-empty]`,x=`[data-wui-drop-note]`,S=`[data-wui-live]`,C=`[data-wui-help]`,w=`[data-wui-switch]`,T=`[data-wui-scroller]`,E=`[data-wui-collapse]`,D=`[data-wui-more]`,O=`data-wui-visible-limit`,k=`data-wui-overflow`,A=`input, select, textarea, [contenteditable=""], [contenteditable="true"], [data-wui-no-drag]`,j=`[data-wui-load-more]`,M=`data-wui-more-url`,N=`data-wui-total`,P=`data-wui-unloaded`,F=48,I=16,L=160,R=e=>e.getAttribute(`data-wui-column`),z=e=>e.getAttribute(`data-wui-card`),B=e=>e.hidden||e.hasAttribute(`hidden`),V=e=>B(e)||e.hasAttribute(k);function H(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);if(!Number.isInteger(t)||t<1)throw TypeError(`Unsupported kanban visible limit "${String(e)}". Use a whole number of 1 or more.`);return t}function U(e,t,n,r){let i=new Set;if(t==null||n)return i;let a=0;for(let n of e)r.has(n)||(a<t?a++:i.add(n));return i}function W(e){let t=(e.getAttribute(`aria-label`)||e.textContent||``).replace(/\s+/g,` `).trim();return t.length>80?`${t.slice(0,79)}…`:t||z(e)||`Card`}function G(e){return e?`${u}${e}`:null}function K(e,t=globalThis.localStorage){let n=G(e);if(!n||!t)return{};try{let e=JSON.parse(t.getItem(n)||`null`);return e&&typeof e.collapsed==`object`&&e.collapsed?e.collapsed:{}}catch{return{}}}function q(e,t,n,r=globalThis.localStorage){let i=G(e);if(!i||!r)return;let a={...K(e,r),[t]:!!n};try{r.setItem(i,JSON.stringify({collapsed:a}))}catch{}}function J(e,t){if(!l.includes(e))throw TypeError(`Unsupported kanban summary format "${String(e)}". Use ${l.join(`, `)}.`);if(t!=null&&t!==``&&!i.MONEY_UNITS.includes(t))throw TypeError(`Unsupported kanban summary unit "${String(t)}". Use ${i.MONEY_UNITS.join(`, `)}.`);return e===`currency`?{style:`currency`,unit:t||`rupees`}:e===`compact`?{style:`compact`,currency:i.CURRENCIES[0],unit:t||`rupees`}:{style:`number`,decimals:0}}function Y(e){let t=0;for(let n of e){if(n==null||n===``)continue;let e=typeof n==`number`?n:Number(n);Number.isFinite(e)&&(t+=e)}return t}var X=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},Z=class extends r.ElementBase{constructor(){super(),this._wired=!1,this._filter=null,this._expanded=new Set,this._revealed=new Set,this._press=null,this._drag=null,this._kbd=null,this._suppressClick=!1,this._observer=null,this._refreshQueued=!1,this._scrollTimer=0,this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onPointerCancel=()=>this._endPointer(!1),this._onDocKeyDown=e=>{e.key===`Escape`&&this._drag&&(e.preventDefault(),this._endPointer(!1))},this._onScroll=()=>{clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>this._syncSwitcherFromScroll(),80)},this.addEventListener(`pointerdown`,e=>this._pointerDown(e)),this.addEventListener(`keydown`,e=>this._keyDown(e)),this.addEventListener(`click`,e=>this._click(e),!0),this.addEventListener(`scroll`,e=>this._loadOnScroll(e.target),!0),this.addEventListener(`dragstart`,e=>{e.target.closest?.(_)&&e.preventDefault()}),this.addEventListener(`touchmove`,e=>{this._drag&&e.preventDefault()},{passive:!1})}_controlled(){return this.hasAttribute(`controlled`)}connectedCallback(){if(!this._wired){this._wired=!0,this._scroller()?.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._restoreCollapsed();for(let e of this._allCards())this._prepareCard(e);if(typeof MutationObserver==`function`){this._observer=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e.nodeType===1&&e.matches(_)&&this._prepareCard(e);this._queueRefresh()});for(let e of this.querySelectorAll(g))this._observer.observe(e,{childList:!0})}this.refresh()}}disconnectedCallback(){this._endPointer(!1),this._observer?.disconnect(),this._observer=null,this._scroller()?.removeEventListener(`scroll`,this._onScroll),clearTimeout(this._scrollTimer),this._wired=!1}setFilter(e){if(e!=null&&typeof e!=`function`)throw TypeError(`wui-kanban setFilter: pass a function or null.`);if(this._filter=e,!e)for(let e of this._allCards())e.hidden=!1;this.refresh()}refresh(){if(this._controlled())return;this._refreshQueued=!1;let e=this._summaryFormat();for(let t of this._columns()){let n=R(t),r=H(t.getAttribute(O)),a=[],o=[];for(let e of this._cardsIn(t))this._filter&&(e.hidden=this._filter(e)===!1),B(e)?e.removeAttribute(k):(a.push(e),o.push(e.getAttribute(`data-wui-value`)));let s=this._expanded.has(n),c=U(a.map(z),r,s,this._revealed);for(let e of a)e.toggleAttribute(k,c.has(z(e)));let l=this._unloadedIn(t),u=String(a.length+l);for(let e of this._countsOf(t))e.textContent!==u&&(e.textContent=u);let d=t.querySelector(b);if(d&&(d.hidden=a.length>0),e){let n=t.querySelector(y);n&&(n.textContent=(0,i.formatValue)(Y(o),e))}let f=t.querySelector(D);if(f){f.hidden=r==null||(s?a.length<=r:c.size===0),f.setAttribute(`aria-expanded`,s?`true`:`false`);let e=s?m.fewer:m.more(c.size);f.textContent!==e&&(f.textContent=e)}let p=t.querySelector(j);if(p&&(p.hidden=l<=0,!t.hasAttribute(`data-wui-loading`))){p.disabled=!1;let e=m.loadMore(l);p.textContent!==e&&(p.textContent=e)}}}moveCard(e,t,n){let r=this._cardByKey(e);if(!r)throw Error(`wui-kanban moveCard: no card "${String(e)}" on this board.`);if(!this._columnByKey(t))throw Error(`wui-kanban moveCard: no column "${String(t)}" on this board.`);return this._commit(r,t,n)}_columns(){return[...this.querySelectorAll(h)]}_columnByKey(e){return this._columns().find(t=>R(t)===e)||null}_columnOf(e){return e.closest(h)}_titleOf(e){return(e.querySelector(`.wui-kanban-title`)?.textContent||R(e)||``).replace(/\s+/g,` `).trim()}_bodyOf(e){return e.querySelector(g)}_cardsIn(e){let t=this._bodyOf(e);return t?[...t.children].filter(e=>e.matches(_)):[]}_visibleCardsIn(e){return this._cardsIn(e).filter(e=>!V(e))}_allCards(){return[...this.querySelectorAll(`${g} > ${_}`)]}_cardByKey(e){return this._allCards().find(t=>z(t)===e)||null}_countsOf(e){let t=R(e),n=[...this.querySelectorAll(w)].filter(e=>e.getAttribute(`data-wui-switch`)===t);return[...e.querySelectorAll(v),...n.flatMap(e=>[...e.querySelectorAll(v)])]}_scroller(){return this.querySelector(T)}_summaryFormat(){let e=this.getAttribute(`summary-format`);return e?J(e,this.getAttribute(`summary-unit`)):null}_queueRefresh(){this._refreshQueued||(this._refreshQueued=!0,queueMicrotask(()=>{this._refreshQueued&&this.refresh()}))}_prepareCard(e){let t=this.querySelector(C);t?.id&&!e.hasAttribute(`aria-describedby`)&&e.setAttribute(`aria-describedby`,t.id),e.hasAttribute(`tabindex`)||(e.tabIndex=0)}_announce(e){let t=this.querySelector(S);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t,n=!1){return this.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:n,detail:t}))}_canLift(e){let t=W(e),n=this.hasAttribute(`readonly`);return n||e.hasAttribute(`data-wui-locked`)?(this._announce(m.locked(t)),this._fire(`wui:kanban:locked`,{key:z(e),card:e,reason:n?`readonly`:`locked`},!0),!1):e.getAttribute(`aria-busy`)!==`true`||(this._announce(m.busy),X(m.busy,`info`),!1)}_check(e,t,n){if(t===n)return{ok:!1,source:!0,reason:null};let r=this._columnByKey(t),i=this._columnByKey(n),a=m.refused(r?this._titleOf(r):t,i?this._titleOf(i):n),o=i?.getAttribute(`data-accept-from`);if(o!=null&&!o.split(/\s+/).filter(Boolean).includes(t))return{ok:!1,reason:a};if(typeof this.accept==`function`){let r=this.accept(e,t,n);if(r===!1)return{ok:!1,reason:a};if(typeof r==`string`&&r)return{ok:!1,reason:r}}return{ok:!0,reason:null}}_markTargets(e,t){let n=W(e),r=new Map;for(let i of this._columns()){let a=R(i),o=this._check(e,t,a);r.set(a,o),i.setAttribute(`data-wui-drop`,o.source?`source`:o.ok?`ok`:`refused`);let s=i.querySelector(x);s&&!o.source&&(s.textContent=o.ok?m.dropHere(n,this._titleOf(i)):o.reason,s.hidden=!1)}return r}_clearTargets(){for(let e of this._columns()){e.removeAttribute(`data-wui-drop`),e.removeAttribute(`data-wui-over`),e.removeAttribute(`data-wui-target`);let t=e.querySelector(x);t&&(t.hidden=!0,t.textContent=``)}}async _commit(e,t,n){let r=this._columnOf(e),i=R(r),a=this._columnByKey(t),s=W(e);if(i===t||!this._canLift(e))return!1;let c=this._check(e,i,t);if(!c.ok)return this._announce(c.reason),X(c.reason,`info`),!1;let l=this._cardsIn(a),u=Number.isInteger(n)?Math.max(0,Math.min(n,l.length)):l.length,d={key:z(e),card:e,from:i,to:t,index:u},f=e.contains(document.activeElement);if(this._controlled())return this._fire(`wui:kanban:move`,d),this._announce(m.moved(s,this._titleOf(a))),f&&this._refocusSoon(d.key),!0;if(!this._fire(`wui:kanban:move`,d,!0))return!1;let p=a.hasAttribute(O)&&!this._revealed.has(d.key);p&&this._revealed.add(d.key);let h={parent:e.parentNode,next:e.nextSibling,column:r,revealed:p};this._bodyOf(a).insertBefore(e,l[u]||null),f&&this._focusMoved(e),this.refresh();let g=a.getAttribute(`data-wui-step`);if(g)return this._runStep(e,d,h,g,a.getAttribute(`data-wui-step-size`));let _=this.getAttribute(`move-url`);if(!_)return this._announce(m.moved(s,this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,result:null}),!0;this._lock(e,!0),this._announce(m.saving(s,this._titleOf(a)));let v=new URLSearchParams({card:d.key,from:i,to:t,index:String(u)}),y=await(0,o.wuiFetch)(_,{method:`POST`,body:v});if(this._lock(e,!1),y.kind===`session`)return!1;if(y.ok){let t=this._applyFragment(y.html)||e;return X(y.message,`success`),this._announce(m.moved(W(t),this._titleOf(a))),this._fire(`wui:kanban:moved`,{...d,card:t,result:y}),!0}return this._rollback(e,h),y.kind!==`aborted`&&X(y.message||m.failed[y.kind]||m.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...d,kind:y.kind,status:y.status,message:y.message}),!1}async _runStep(e,t,n,r,i){let s=W(e),c=this._columnByKey(t.to),l=new URLSearchParams({card:t.key,from:t.from,to:t.to}).toString(),u=r+(r.includes(`?`)?`&`:`?`)+l;this._lock(e,!0);let d;try{d=await(await(0,a.loadRemoteModal)(u,{trigger:e,size:i||void 0})).closed}catch(r){return this._lock(e,!1),this._rollback(e,n),r?.name!==`AbortError`&&X(m.failed.server,`danger`),this._fire(`wui:kanban:failed`,{...t,kind:`step`,status:0,message:r?.message??null}),!1}if(d?.status!==`success`)return this._lock(e,!1),this._rollback(e,n),this._announce(m.cancelled(s)),this._fire(`wui:kanban:failed`,{...t,kind:`dismissed`,status:0,message:null}),!1;let f=e,p=this.getAttribute(`card-url`);if(p){let n=await(0,o.wuiFetch)(`${p}${p.includes(`?`)?`&`:`?`}${new URLSearchParams({card:t.key})}`);n.ok&&(f=this._applyFragment(n.html)||e)}return this._lock(f,!1),this._announce(m.moved(W(f),this._titleOf(c))),this._fire(`wui:kanban:moved`,{...t,card:f,result:d}),!0}_lock(e,t){t?(e.setAttribute(`aria-busy`,`true`),e.setAttribute(`data-wui-saving`,``)):(e.removeAttribute(`aria-busy`),e.removeAttribute(`data-wui-saving`))}_rollback(e,t){let n=e.contains(document.activeElement),r=t.next&&t.next.parentNode===t.parent?t.next:null;t.revealed&&this._revealed.delete(z(e)),t.parent.insertBefore(e,r),n&&e.focus(),this.refresh(),this._announce(m.rolledBack(W(e),this._titleOf(t.column)))}_applyFragment(e){if(!e)return null;let t=document.createElement(`template`);t.innerHTML=e;for(let e of t.content.querySelectorAll(`script`))(0,n.devWarn)(`[@webority/ui-elements] A kanban fragment carried a script tag; it was removed, not run.`),e.remove();let r=null;for(let e of[...t.content.querySelectorAll(_)]){if(e.closest(`template`))continue;let t=this._cardByKey(z(e));if(!t)continue;let n=t.contains(document.activeElement);t.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),t.hidden&&(e.hidden=!0),t.replaceWith(e),this._prepareCard(e),n&&e.focus(),r??=e}for(let e of t.content.querySelectorAll(`template[data-wui-kanban-summary]`))this._columnByKey(e.getAttribute(`data-wui-kanban-summary`))?.querySelector(y)?.replaceChildren(e.content.cloneNode(!0));return this.refresh(),window.WUI?.refresh?.(),r}_refocusSoon(e){let t=()=>{let t=this._cardByKey(e);t&&this._focusMoved(t)};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}_focusMoved(e){e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`nearest`})}_pointerDown(e){if(e.button!==0||e.isPrimary===!1||this._drag||this._kbd)return;let t=e.target.closest?.(_);if(!t||!this.contains(t)||e.target.closest(A))return;let n={card:t,id:e.pointerId,x:e.clientX,y:e.clientY,type:e.pointerType,timer:0};this._press=n,e.pointerType===`touch`&&(n.timer=setTimeout(()=>{this._press===n&&this._startDrag(n,n.x,n.y)},400)),window.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp),window.addEventListener(`pointercancel`,this._onPointerCancel)}_pointerMove(e){let t=this._press;if(t&&e.pointerId===t.id){if(!this._drag){if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>6))return;if(t.type===`touch`){this._endPointer(!1);return}if(this._startDrag(t,e.clientX,e.clientY),!this._drag)return}this._dragTo(e.clientX,e.clientY)}}_pointerUp(e){this._press&&e.pointerId===this._press.id&&this._endPointer(!!this._drag)}_startDrag(e,t,n){let r=e.card;if(!this._canLift(r)){this._endPointer(!1);return}let i=R(this._columnOf(r)),a=r.getBoundingClientRect(),o=r.cloneNode(!0);for(let e of[o,...o.querySelectorAll(`[id]`)])e.removeAttribute(`id`);o.removeAttribute(`data-wui-card`),o.removeAttribute(`tabindex`),o.setAttribute(`aria-hidden`,`true`),o.classList.add(`wui-kanban-ghost`),o.style.width=`${a.width}px`,this.appendChild(o),r.setAttribute(`data-wui-dragging`,``),this.setAttribute(`data-wui-dragging`,``),this._drag={card:r,from:i,ghost:o,dx:t-a.left,dy:n-a.top,over:null,verdicts:this._markTargets(r,i)},this._announce(m.lifted(W(r),this._titleOf(this._columnOf(r)))),document.addEventListener(`keydown`,this._onDocKeyDown),this._dragTo(t,n)}_dragTo(e,t){let n=this._drag;n.x=e,n.y=t,n.ghost.style.transform=`translate(${e-n.dx}px, ${t-n.dy}px)`;let r=this._columnAt(e,t);r!==n.over&&(n.over?.removeAttribute(`data-wui-over`),r?.setAttribute(`data-wui-over`,``),n.over=r),this._autoScroll(e,t,r)}_columnAt(e,t){for(let n of this._columns()){let r=n.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom)return n}return null}_indexAt(e,t){let n=this._visibleCardsIn(e).filter(e=>e!==this._drag?.card).find(e=>{let n=e.getBoundingClientRect();return t<n.top+n.height/2}),r=this._cardsIn(e).filter(e=>e!==this._drag?.card);return n?r.indexOf(n):r.length}_autoScroll(e,t,n){let r=this._scroller();if(r){let t=r.getBoundingClientRect();t.width>0&&(e<t.left+F?r.scrollBy?.({left:-16}):e>t.right-F&&r.scrollBy?.({left:I}))}if(n&&this._scrollColumn(n,t))return;let i=window.innerHeight||0;i>0&&(t<F?window.scrollBy?.({top:-16}):t>i-F&&window.scrollBy?.({top:I}))}_scrollColumn(e,t){let n=this._bodyOf(e);if(!n||e.hasAttribute(`data-collapsed`)||n.scrollHeight<=n.clientHeight)return!1;let r=n.getBoundingClientRect();return t<r.top+F&&n.scrollTop>0?(n.scrollBy?.({top:-16}),!0):t>r.bottom-F&&n.scrollTop+n.clientHeight<n.scrollHeight-1&&(n.scrollBy?.({top:I}),!0)}_endPointer(e){let t=this._press,n=this._drag;if(t&&clearTimeout(t.timer),this._press=null,this._drag=null,window.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),window.removeEventListener(`pointercancel`,this._onPointerCancel),document.removeEventListener(`keydown`,this._onDocKeyDown),!n)return;n.ghost.remove(),n.card.removeAttribute(`data-wui-dragging`),this.removeAttribute(`data-wui-dragging`),this._suppressClick=!0,setTimeout(()=>{this._suppressClick=!1},0);let r=n.over;if(this._clearTargets(),!e||!r){this._announce(m.cancelled(W(n.card)));return}let i=R(r),a=n.verdicts.get(i);a?.source?this._announce(m.cancelled(W(n.card))):a?.ok?this._commit(n.card,i,this._indexAt(r,n.y)):(this._announce(a?.reason),X(a?.reason,`info`))}_click(e){if(this._suppressClick&&e.target.closest?.(_)){e.preventDefault(),e.stopPropagation(),this._suppressClick=!1;return}let t=e.target.closest?.(E);if(t&&this.contains(t)){let e=t.closest(h);e&&this._setCollapsed(e,!e.hasAttribute(`data-collapsed`),!0);return}let n=e.target.closest?.(j);if(n&&this.contains(n)){this._controlled()||this._loadMore(n.closest(h));return}let r=e.target.closest?.(D);if(r&&this.contains(r)){this._controlled()||this._toggleMore(r.closest(h));return}let i=e.target.closest?.(w);i&&this.contains(i)&&this._showColumn(i.getAttribute(`data-wui-switch`))}_keyDown(e){if(this._kbd){this._liftedKey(e);return}let t=e.target;if(!t.matches?.(_)||!this.contains(t))return;let n=this._columnOf(t);switch(e.key){case` `:case`Spacebar`:{if(e.preventDefault(),!this._canLift(t))return;let r=R(n),i=this._columns();this._kbd={card:t,from:r,target:i.indexOf(n),verdicts:this._markTargets(t,r)},t.setAttribute(`data-wui-lifted`,``),this.setAttribute(`data-wui-dragging`,``),n.setAttribute(`data-wui-target`,``),this._announce(m.lifted(W(t),this._titleOf(n)));return}case`ArrowDown`:case`ArrowUp`:{let r=this._visibleCardsIn(n),i=r[r.indexOf(t)+(e.key===`ArrowDown`?1:-1)];i&&(e.preventDefault(),i.focus());return}case`ArrowLeft`:case`ArrowRight`:{let t=this._columns(),r=e.key===`ArrowRight`?1:-1;for(let i=t.indexOf(n)+r;i>=0&&i<t.length;i+=r){let n=this._visibleCardsIn(t[i])[0];if(n&&!t[i].hasAttribute(`data-collapsed`)){e.preventDefault(),n.focus();return}}return}}}_liftedKey(e){let t=this._kbd,n=this._columns();switch(e.key){case`ArrowLeft`:case`ArrowRight`:{e.preventDefault();let r=t.target+(e.key===`ArrowRight`?1:-1);if(r<0||r>=n.length)return;n[t.target]?.removeAttribute(`data-wui-target`),t.target=r;let i=n[r];i.setAttribute(`data-wui-target`,``),this._showColumn(R(i),!1);let a=t.verdicts.get(R(i)),o=this._titleOf(i);this._announce(a.source?m.overSource(o):a.ok?m.over(o,this._cardsIn(i).filter(e=>!B(e)).length):m.overRefused(o,a.reason));return}case` `:case`Spacebar`:case`Enter`:{e.preventDefault();let r=n[t.target],i=R(r),a=t.verdicts.get(i);if(!a.source&&!a.ok){this._announce(a.reason);return}this._endKeyboard(),a.source?this._announce(m.cancelled(W(t.card))):this._commit(t.card,i);return}case`Escape`:case`Tab`:e.key===`Escape`&&e.preventDefault(),this._endKeyboard(),this._showColumn(t.from,!1),this._announce(m.cancelled(W(t.card)));return}}_endKeyboard(){let e=this._kbd;this._kbd=null,e&&(e.card.removeAttribute(`data-wui-lifted`),this.removeAttribute(`data-wui-dragging`),this._clearTargets())}_restoreCollapsed(){let e=K(this.getAttribute(`board-id`));for(let t of this._columns()){let n=R(t);t.hasAttribute(`data-collapsible`)&&Object.hasOwn(e,n)&&this._setCollapsed(t,e[n],!1)}}_setCollapsed(e,t,n){let r=R(e);e.toggleAttribute(`data-collapsed`,t);let i=this._titleOf(e);for(let n of e.querySelectorAll(E))n.setAttribute(`aria-expanded`,t?`false`:`true`),n.setAttribute(`aria-label`,t?m.expand(i):m.collapse(i));n&&(q(this.getAttribute(`board-id`),r,t),this._fire(`wui:kanban:collapse`,{column:r,collapsed:t}))}_toggleMore(e){if(!e)return;let t=R(e);if(this._expanded.delete(t))for(let t of this._cardsIn(e))this._revealed.delete(z(t));else this._expanded.add(t);this.refresh()}_unloadedIn(e){return e.hasAttribute(M)?(e.hasAttribute(P)||e.setAttribute(P,String(Math.max(0,Number(e.getAttribute(N))-this._cardsIn(e).length))),Number(e.getAttribute(P))):0}async _loadMore(e){let t=Number(e.getAttribute(P));if(e.hasAttribute(`data-wui-loading`)||!(t>0))return;e.setAttribute(`data-wui-loading`,``);let r=e.querySelector(j);r&&(r.disabled=!0,r.textContent=m.loading);let i=new URL(e.getAttribute(M),document.baseURI);i.searchParams.set(`skip`,String(this._cardsIn(e).length));let a=0,s=!1;try{let n=await(0,o.wuiFetch)(i.toString());if(n.ok){let r=document.createElement(`template`);r.innerHTML=n.html;let i=this._bodyOf(e);for(let e of[...r.content.children])e.matches(_)&&!this._cardByKey(z(e))&&(i.append(e),a++);let o=n.response?.headers.get(`Wui-Kanban-Remaining`)??``;e.setAttribute(P,String(/^\d+$/.test(o)?Number(o):Math.max(0,t-a))),s=!0}}catch(e){(0,n.devError)(`[@webority/ui-elements] A kanban column could not load its next cards.`,e)}e.removeAttribute(`data-wui-loading`),this.refresh(),s?this._fire(`wui:kanban:loaded`,{key:R(e),added:a}):X(m.loadFailed,`danger`)}_loadOnScroll(e){if(this._controlled()||!e.matches(g))return;let t=e.closest(h);t?.hasAttribute(M)&&e.scrollTop+e.clientHeight>=e.scrollHeight-L&&this._loadMore(t)}_isPhone(){return typeof matchMedia==`function`&&matchMedia(`(max-width: 767.98px)`).matches}_showColumn(e,t=!0){for(let t of this.querySelectorAll(w))t.getAttribute(`data-wui-switch`)===e?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`);let n=this._columnByKey(e),r=this._scroller();if(!n||!r||!t&&!this._isPhone())return;let i=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollTo?.({left:n.offsetLeft-r.offsetLeft,behavior:i?`auto`:`smooth`})}_syncSwitcherFromScroll(){let e=this._scroller();if(!e||!this._isPhone())return;let t=e.clientWidth||1,n=this._columns()[Math.round(e.scrollLeft/t)];if(n)for(let e of this.querySelectorAll(w))e.getAttribute(`data-wui-switch`)===R(n)?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}};(0,t.defineElement)(`wui-kanban`,Z),e.KANBAN_DRAG_THRESHOLD_PX=p,e.KANBAN_LONG_PRESS_MS=f,e.KANBAN_PHONE_QUERY=d,e.KANBAN_STORAGE_PREFIX=u,e.KANBAN_SUMMARY_FORMATS=l,e.KANBAN_TEXT=m,e.KANBAN_TONES=c,e.WuiKanban=Z,e.kanbanCardLabel=W,e.kanbanOverflow=U,e.kanbanStorageKey=G,e.kanbanSummaryFormat=J,e.kanbanVisibleLimit=H,e.readKanbanCollapsed=K,e.sumKanbanValues=Y,e.writeKanbanCollapsed=q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.remoteModal,WeborityUiElementsInternal.modules.wuiHttp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.
|
|
1
|
+
(function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.124.0`)throw Error(`[webority-ui] lightbox expects ui-elements 0.124.0 but the page loaded `+a+`.`);var o=`a.wui-lightbox-item`,s=1,c=4,l=.5,u=2,d=50,f=6,p=300,m=300;function h(e){return Number.isFinite(e)?Math.min(c,Math.max(s,e)):s}function g(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function _(e,t){return Math.abs(e)<d||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function v(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function y(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function b(e,t,n){let r=y(`button`,`u-action wui-lightbox-btn ${n}`,{type:`button`,"aria-label":t,title:t});return r.style.setProperty(`--wui-action-size`,`40px`),r.innerHTML=(0,i.glyphSvg)(e,{size:20}),r}var x=class extends n.ElementBase{static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=s,this._pan={x:0,y:0},this._pointers=new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(o);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(o)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||v(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=y(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=y(`div`,`wui-lightbox-bar`),n=y(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),r=y(`div`,`wui-lightbox-tools`),a=b(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),o=b(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),s=y(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});s.style.setProperty(`--wui-action-size`,`40px`),s.innerHTML=(0,i.glyphSvg)(`download`,{size:20}),s.hidden=!this.download;let c=b(`x`,`Close`,`wui-lightbox-close`);r.append(a,o,s,c),t.append(n,r);let u=y(`div`,`wui-lightbox-stage`),d=b(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=b(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=y(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=y(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=y(`p`,`wui-lightbox-caption`);e.append(t,u,h);let g={root:e,count:n,zoomOut:a,zoomIn:o,download:s,close:c,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=g,c.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-l)),o.addEventListener(`click`,()=>this._setZoom(this._zoom+l)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===g&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===g&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,t){let n=this._ui,i=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[i],o=i!==this._index||!n.image.getAttribute(`src`);if(this._index=i,this._zoom=s,this._pan={x:0,y:0},n.count.textContent=`${(0,r.formatNumber)(i+1,{decimals:0})} of ${(0,r.formatNumber)(t.length,{decimals:0})}`,n.caption.textContent=a.caption,n.caption.hidden=!a.caption,n.download.href=a.src,n.download.setAttribute(`download`,a.name),n.prev.hidden=n.next.hidden=t.length<2,n.stage.setAttribute(`aria-busy`,`true`),n.status.textContent=``,n.image.hidden=!1,n.image.alt=a.alt||a.caption,n.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1)for(let e of[t[(i+1)%t.length],t[(i-1+t.length)%t.length]])new Image().src=e.src;o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:i}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=s,this._ui.zoomIn.disabled=this._zoom>=c;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=h(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return g(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>s)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+l)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-l)):e.key===`0`&&(e.preventDefault(),this._setZoom(s))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):e.shiftKey||i!==r&&this._ui.root.contains(i)||(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`)){if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>f&&(t.moved=!0),this._zoom>s&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===s&&this.step(_(r,i)):e.timeStamp-n.startTime>p||(n.onImage?e.timeStamp-this._lastTap<m?(this._lastTap=-1/0,this._setZoom(this._zoom>s?s:u)):this._lastTap=e.timeStamp:this.close())}};(0,t.defineElement)(`wui-lightbox`,x),e.WuiLightbox=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.
|
|
1
|
+
(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.124.0`)throw Error(`[webority-ui] markdown expects ui-elements 0.124.0 but the page loaded `+r+`.`);var i=/\[([^[\]\n]+)\](?!\()/g,a=new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),o=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,s=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,c=new RegExp(i.source,`y`),l=e=>/[\p{L}\p{N}]/u.test(e);function u(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function d(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),s=n===`_`&&l(e.charAt(i+n.length));if(a&&!o&&!s&&!u(e,i))return i}return-1}function f(e,t){let n=t?.isCitation,r=[],i=``,u=()=>{i&&=(r.push({type:`text`,text:i}),``)},p=0;for(;p<e.length;){let m=e.charAt(p),h=e.charAt(p+1);if(m===`\\`&&a.has(h)){i+=h,p+=2;continue}if(m==="`"){let t=e.indexOf("`",p+1);if(t>p+1){u(),r.push({type:`code`,text:e.slice(p+1,t)}),p=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=d(e,p+2,g);if(n!==-1&&!(g===`__`&&l(e.charAt(p-1)))){u();let i=f(e.slice(p+2,n),t);g===`~~`?r.push({type:`strike`,children:i}):r.push({type:`strong`,children:i}),p=n+2;continue}i+=g,p+=2}else{if(m===`*`||m===`_`){let n=d(e,p+1,m);if(n!==-1&&!(m===`_`&&l(e.charAt(p-1)))){u(),r.push({type:`em`,children:f(e.slice(p+1,n),t)}),p=n+1;continue}}if(m===`[`){o.lastIndex=p;let t=o.exec(e);if(t){u(),r.push({type:`link`,href:t[2],children:f(t[1])}),p+=t[0].length;continue}if(n){c.lastIndex=p;let t=c.exec(e);if(t&&n(t[1])){u(),r.push({type:`citation`,text:t[1]}),p+=t[0].length;continue}}}if(m===`!`){s.lastIndex=p;let t=s.exec(e);if(t){u(),r.push({type:`image`,children:f(t[1])}),p+=t[0].length;continue}}i+=m,p+=1}}return u(),r.map((e,t)=>({...e,key:t}))}var p=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,m=/^https?:/i,h=/^(mailto|tel):/i;function g(e,t,n){if(n&&p.test(e)){let t=n(e);if(t!=null)return{kind:`app`,target:t}}return t===`app`?null:m.test(e)?{kind:`web`,href:e}:h.test(e)?{kind:`contact`,href:e}:null}function _(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var v=/^\s*```/,y=/^\s*```\s*(\S*)/,b=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,x=/^\s*([-*_])(\s*\1){2,}\s*$/,S=/^(\s*)[-*+]\s+(.*)$/,C=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,w=/^\s*>\s?(.*)$/,T=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,E=e=>e.includes(`|`);function D(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function O(e,t){return E(e[t])&&t+1<e.length&&e[t+1].includes(`|`)&&T.test(e[t+1])}function k(e,t){let n=e[t];return v.test(n)||w.test(n)||S.test(n)||C.test(n)||b.test(n)||x.test(n)||O(e,t)}function A(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function j(e){let t=C.exec(e);if(t)return{text:t[3],depth:A(t[1]),ordered:!0,number:Number(t[2])};let n=S.exec(e);return n?{text:n[2],depth:A(n[1]),ordered:!1,number:0}:null}function M(e){let t=(e??``).replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(
|
|
4
|
-
`),language:i});continue}if(
|
|
3
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(v.test(e)){let i=y.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length&&!v.test(t[r]);)a.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:a.join(`
|
|
4
|
+
`),language:i});continue}if(O(t,r)){let i=D(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&E(t[r]);)a.push(D(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(x.test(e)){n.push({type:`rule`}),r+=1;continue}let i=b.exec(e);if(i){n.push({type:`heading`,level:i[1].length,text:i[2]}),r+=1;continue}if(w.test(e)){let e=[];for(;r<t.length;){let n=w.exec(t[r]);if(!n)break;e.push(n[1]),r+=1}n.push({type:`quote`,lines:e});continue}let a=j(e);if(a){let e=[];for(;r<t.length&&t[r].trim();){let n=j(t[r]);if(n){if(n.depth===0&&n.ordered!==a.ordered)break;e.push(n)}else if(k(t,r))break;else e[e.length-1].text+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!k(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var N=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`];function P(e,t,n,r,i=null){let a=F(e.ownerDocument,n,r).map((e,n)=>{let r=t[n]?.sig===e.sig?t[n].nodes:null;return{sig:e.sig,nodes:r??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.remove();let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function F(e,t,n){let r={doc:e,links:n.links===`app`?`app`:`web`,headings:n.headings===`text`?`text`:`outline`,resolveLink:n.resolveLink,isCitation:n.isCitation},i=n.resolverGeneration??0;return M(t).map(e=>({sig:`${JSON.stringify(e)}|${r.links}|${r.headings}|${i}`,build:()=>R(r,e)}))}var I=class extends n.ElementBase{static get observedAttributes(){return[`links`,`headings`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=P(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function L(e,t,n=[]){let r=e.createElement(t);return r.append(...n),r}function R(e,t){switch(t.type){case`paragraph`:return[L(e.doc,`p`,z(e,t.lines))];case`heading`:return[B(e,t)];case`list`:return V(e,t.items);case`table`:return[U(e,t)];case`code`:return[W(e.doc,t)];case`quote`:return[L(e.doc,`blockquote`,z(e,t.lines))];case`rule`:return[e.doc.createElement(`hr`)];default:return[]}}function z(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(e.doc.createElement(`br`)),n.push(...G(e,t))}),n}function B(e,t){let n=G(e,t.text);if(e.headings===`text`){let t=L(e.doc,`p`,n);return t.className=`fw-semibold`,t}return L(e.doc,`h2`,n)}function V(e,t){let n=[];for(let r=0;r<t.length;){let i=H(e,t,r);n.push(i.list),r=i.next}return n}function H(e,t,n){let{depth:r,ordered:i,number:a}=t[n],o=e.doc.createElement(i?`ol`:`ul`);i&&a!==1&&o.setAttribute(`start`,String(a));let s=null,c=n;for(;c<t.length&&t[c].depth>=r;)if(t[c].depth===r)s=L(e.doc,`li`,G(e,t[c].text)),o.append(s),c+=1;else{let n=H(e,t,c);s.append(n.list),c=n.next}return{list:o,next:c}}function U(e,t){let n=t.header.map(t=>{let n=L(e.doc,`th`,G(e,t));return n.setAttribute(`scope`,`col`),n}),r=t.rows.map(n=>L(e.doc,`tr`,t.header.map((t,r)=>L(e.doc,`td`,G(e,n[r]??``))))),i=L(e.doc,`table`,[L(e.doc,`thead`,[L(e.doc,`tr`,n)]),L(e.doc,`tbody`,r)]);i.className=`table`;let a=L(e.doc,`div`,[i]);return a.className=`table-responsive`,a}function W(e,t){let n=L(e,`pre`,[L(e,`code`,[e.createTextNode(t.text)])]);n.className=`wui-code-source`;let r=L(e,`wui-code-block`,[n]);return r.className=`wui-code-block`,r.setAttribute(`language`,N.includes(t.language)?t.language:`text`),r}function G(e,t){return K(e,f(t,{isCitation:e.isCitation}))}function K(e,t){return t.flatMap(t=>q(e,t))}function q(e,t){let{doc:n}=e;switch(t.type){case`code`:return[L(n,`code`,[n.createTextNode(t.text)])];case`strong`:return[L(n,`strong`,K(e,t.children))];case`em`:return[L(n,`em`,K(e,t.children))];case`strike`:return[L(n,`del`,K(e,t.children))];case`image`:return[n.createTextNode(`[`),...K(e,t.children),n.createTextNode(`]`)];case`link`:return J(e,t);case`citation`:return[Y(n,t.text)];default:return[n.createTextNode(t.text)]}}function J(e,t){let n=K(e,t.children),r=g(t.href,e.links,e.resolveLink);if(!r)return n;if(r.kind===`app`){let t=_(r.target);return t?[X(e.doc,t,n,!1)]:n}return[X(e.doc,r.href,n,r.kind===`web`)]}function Y(e,t){let n=e.createElement(`span`);n.className=`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,n.setAttribute(`data-wui`,`AppChip`);let r=e.createElement(`button`);r.type=`button`,r.className=`chip-body`,r.setAttribute(`aria-label`,t),r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:t}}))});let i=e.createElement(`span`);return i.className=`chip-label`,i.textContent=t,r.append(i),n.append(r),n}function X(e,t,n,r){let i=L(e,`span`,n);i.className=`wui-link__label`;let a=L(e,`a`,[i]);return a.className=`wui-link wui-link--static`,a.setAttribute(`data-wui`,`AppLink`),a.setAttribute(`href`,t),r&&(a.setAttribute(`target`,`_blank`),a.setAttribute(`rel`,`noopener noreferrer`)),a}(0,t.defineElement)(`wui-markdown`,I),e.WuiMarkdown=I})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.
|
|
2
|
-
<div class="search-select${
|
|
1
|
+
(function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.124.0`)throw Error(`[webority-ui] multiselect expects ui-elements 0.124.0 but the page loaded `+l+`.`);var u=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:``},d=(e,t=`wui-opt-avatar`)=>{let n=u(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${(0,r.escapeHtml)(e.initials??``)}</span>${n?`<img class="avatar-img" src="${f(n)}" alt="" />`:``}</span>`},f=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),p=!1,m=!1;function h(){m||typeof document>`u`||(m=!0,document.addEventListener(`keydown`,e=>{p=e.key===`Tab`},!0),document.addEventListener(`keyup`,()=>{p=!1},!0))}function g(){return p}function _(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 v=(e,t)=>t.some(t=>String(e??``).includes(t)),y=class extends a.ElementBase{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(this._rendered)this._bindGlobal?.();else{if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render()}}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){e===`aria-invalid`?this._syncInvalid():e!==`custom-pattern`&&e!==`custom-invalid-message`&&this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],(0,o.syncFormMirrors)(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom?(this._renderControl(),this._renderOptions(this._query())):this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[r.TRUSTED_HTML]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of x){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?(0,r.optionText)(t):(0,r.stripTags)(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?(0,r.optionLabelHtml)(t):(0,r.escapeHtml)(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),a=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;(0,o.syncFormMirrors)(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let c=`${this.id}-listbox`;this._listboxId=c;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
|
|
2
|
+
<div class="search-select${a}">
|
|
3
3
|
<div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:``}>
|
|
4
|
-
${r?(0,
|
|
5
|
-
<div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
6
|
-
${(0,
|
|
4
|
+
${r?(0,s.glyphSvg)(r,{className:`search-select-icon`}):``}
|
|
5
|
+
<div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${E(c)}" aria-label="${E(this._accessibleName())}" aria-describedby="${E(e)}" autocomplete="off"${l?` disabled`:``} /></div>
|
|
6
|
+
${(0,s.glyphSvg)(`chevron-down`,{className:`search-select-caret`})}
|
|
7
7
|
</div>
|
|
8
8
|
<div class="search-select-menu search-select-menu-fixed" hidden>
|
|
9
|
-
<div class="search-select-options" role="listbox" id="${
|
|
9
|
+
<div class="search-select-options" role="listbox" id="${E(c)}" aria-multiselectable="true" tabindex="-1"></div>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
|
-
<div class="field-error wui-ms-custom-error" id="${
|
|
13
|
-
<div class="search-select${
|
|
14
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
15
|
-
${r?(0,
|
|
12
|
+
<div class="field-error wui-ms-custom-error" id="${E(e)}" aria-live="polite" hidden></div>`}else this.innerHTML=`
|
|
13
|
+
<div class="search-select${a}">
|
|
14
|
+
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${E(c)}" aria-label="${E(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:` tabindex="0"`}>
|
|
15
|
+
${r?(0,s.glyphSvg)(r,{className:`search-select-icon`}):``}
|
|
16
16
|
<div class="ms-chips" data-chips></div>
|
|
17
|
-
${(0,
|
|
17
|
+
${(0,s.glyphSvg)(`chevron-down`,{className:`search-select-caret`})}
|
|
18
18
|
</div>
|
|
19
19
|
<div class="search-select-menu search-select-menu-fixed" hidden>
|
|
20
|
-
${t?`<div class="search-select-search">${(0,
|
|
21
|
-
<div class="search-select-options" role="listbox" id="${
|
|
20
|
+
${t?`<div class="search-select-search">${(0,s.glyphSvg)(`search`)}<input class="search-select-input" placeholder="${E(n)}" aria-label="${E(n)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${(0,s.glyphSvg)(`x`)}</button></div>`:``}
|
|
21
|
+
<div class="search-select-options" role="listbox" id="${E(c)}" aria-multiselectable="true" tabindex="-1"></div>
|
|
22
22
|
<div class="search-select-empty" hidden>No matches</div>
|
|
23
23
|
</div>
|
|
24
|
-
</div>`;this._rendered=!0,this._customError=``,(0,
|
|
25
|
-
`,` `],
|
|
24
|
+
</div>`;this._rendered=!0,this._customError=``,(0,o.syncFormMirrors)(this,this._values),this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,i=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${E(e)}" aria-label="Remove ${E(this._labelFor(e))}">${(0,s.glyphSvg)(`x`)}</button></span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,i),n.placeholder=this._values.length?``:t,this._collapseChips()}else this._values.length?(e.innerHTML=i,this._collapseChips()):e.innerHTML=`<span class="search-select-placeholder">${(0,r.escapeHtml)(t)}</span>`}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return(0,r.optionText)(e).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||(0,r.optionText)(e).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let i=(e||``).trim(),a=i.toLowerCase(),o=this._readOptions();a&&(o=o.filter(e=>this._matches(e,a)));let c=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,l=this._allowCustom&&i&&!this._optionNamed(i),u=o.map((e,t)=>{let n=this._values.includes(String(e.value)),i=`${c}-opt-${t}`;return S(e)?C(e,i,n):`<button type="button" role="option" id="${E(i)}" class="search-select-option${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${(0,r.optionLabelHtml)(e)}</span><span class="ms-check">${(0,s.glyphSvg)(`check`)}</span></button>`});l&&u.push(`<button type="button" role="option" id="${E(`${c}-opt-${o.length}`)}" class="search-select-option search-select-option-custom" data-value="${E(i)}" data-custom="true" aria-selected="false">Add “${(0,r.escapeHtml)(i)}”</button>`),t.innerHTML=u.join(``),n&&(n.hidden=o.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=T(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),t=this.querySelector(`.search-select-menu`),r=this.querySelector(`.search-select-input`),i=this.querySelector(`.search-select-clear`),a=this.querySelector(`.search-select-options`),s=this._allowCustom,l=s?this.querySelector(`[data-input]`):null,u=l||e;if(!e||!t)return;let d=()=>this.hasAttribute(`disabled`),f=()=>(0,n.anchorOverlay)(e,t,{matchWidth:!0}),p=()=>[...this.querySelectorAll(`.search-select-option`)],m=()=>p().filter(e=>!e.hidden),y=(e,{reveal:t=!0}={})=>{let n=m();this._active=e,(0,c.moveActiveRow)(a,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),u.setAttribute(`aria-activedescendant`,n[e].id)):u.removeAttribute(`aria-activedescendant`)},x=!1,S=()=>s?x:!t.hidden,C=()=>{let n=x&&p().length>0,r=t.hidden;t.hidden=!n,u.setAttribute(`aria-expanded`,String(n)),e.classList.toggle(`open`,n),n&&r&&f()};this._syncCustomMenu=s?C:null;let w=()=>{S()&&f()},T=()=>{d()||((0,n.bindReanchor)(this,w),s?(x=!0,C()):(t.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),f(),r&&(r.value=``,this._renderOptions(``),r.focus())))},E=()=>{let r=s?x:e.getAttribute(`aria-expanded`)===`true`;s?(x=!1,C()):(t.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`)),y(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,(0,n.unbindReanchor)(this),r&&this.dispatchEvent(new Event(`wui-multiselect:close`,{bubbles:!0}))},D=()=>{(0,o.syncFormMirrors)(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},O=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(s&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),D()},k=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),D()},A=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=v(e,b)?_(e,b):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(l.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),D()),this._renderOptions(l.value))},j=e=>{e&&e.getAttribute(`aria-disabled`)!==`true`&&(e.dataset.custom===`true`?A(e.dataset.value):(O(e.dataset.value),l?.value&&(l.value=``,this._setCustomError(``),this._renderOptions(``))))};e.addEventListener(`click`,e=>{if(d())return;let t=e.target.closest(`[data-remove]`);if(t)e.stopPropagation(),k(t.dataset.remove),l?.focus();else if(l){let t=S();e.target!==l&&l.focus(),e.target===l||!t?T():E()}else S()?E():T()}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(j(t),(l||r)?.focus())}),a.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&y(m().indexOf(t),{reveal:!1})}),a.addEventListener(`mouseleave`,()=>y(-1)),a.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),r?.addEventListener(`input`,()=>{this._renderOptions(r.value),i&&(i.hidden=!r.value),y(-1)}),this._navHandler=(0,c.createListboxKeyNav)({getVisibleOptions:m,getActive:()=>this._active,setActive:e=>y(e),onEnter:e=>{e?j(e):l?.value.trim()&&A(l.value)},onEscape:()=>{this._navHandler.clearTypeahead(),E(),l||e.focus()}});let M=e=>{let t=l||r;e.key===`Backspace`&&!t?.value&&this._values.length?k(this._values[this._values.length-1]):(e.key===`Escape`&&S()&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e))};if(r?.addEventListener(`keydown`,M),i?.addEventListener(`click`,()=>{r.value=``,this._renderOptions(``),i.hidden=!0,r.focus()}),l){let t=e=>{e.target!==l&&e.preventDefault()};a.addEventListener(`mousedown`,t),e.addEventListener(`mousedown`,t),h(),l.addEventListener(`focus`,()=>{g()&&T()}),l.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(l.value),T()}),l.addEventListener(`keydown`,e=>{if(e.key===`,`&&l.value.trim())e.preventDefault(),A(l.value);else if(e.key===`Enter`){if(this._active<0&&!l.value.trim())return;this._navHandler.handler(e)}else e.key!==`ArrowDown`&&e.key!==`ArrowUp`||S()||T(),M(e)}),l.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text/plain`)??``;v(t,b)&&(e.preventDefault(),A(`${l.value}${t}`))}),l.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(l.value.trim()&&A(l.value,{quiet:!0}),E())})}else e.addEventListener(`keydown`,e=>{S()?M(e):(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{S()&&!this.contains(e.target)&&E()},document.addEventListener(`click`,this._onDocClick),S()&&(0,n.bindReanchor)(this,w)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),(0,n.unbindReanchor)(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},b=[`,`,`;`,`
|
|
25
|
+
`,` `],x=[[`description`,`description`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],S=e=>!!(e.description||e.avatar||e.initials||e.disabled||e.disabledHint),C=(e,t,n)=>{let i=!!e.disabled,a=e.description?`<span class="wui-opt-desc">${(0,r.escapeHtml)(e.description)}</span>`:``,o=e.disabledHint&&i?`<span class="wui-opt-hint">${(0,r.escapeHtml)(e.disabledHint)}</span>`:``;return`<button type="button" role="option" id="${E(t)}" class="search-select-option wui-opt-rich${n?` selected`:``}" data-value="${E(e.value)}" aria-selected="${n}"${i?` aria-disabled="true"`:``}><span class="ms-opt-label"><span class="wui-opt-name">${(0,r.optionLabelHtml)(e)}</span>${a}</span>${o}${d(e)}<span class="ms-check">${(0,s.glyphSvg)(`check`)}</span></button>`},w=new Map,T=e=>{if(w.has(e))return w.get(e);let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{(0,i.devWarn)(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`)}return w.set(e,t),t},E=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);(0,t.defineElement)(`wui-multiselect`,y),e.WuiMultiSelect=y})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.anchorOverlay,WeborityUiElementsInternal.modules.optionLabel,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.listboxKeyNav);
|