@webority/ui-elements 0.191.3 → 0.193.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WuiCodeBlock-C4GqrGyO.js → WuiCodeBlock-BnRpTBm_.js} +1 -1
- package/dist/{WuiCommandPalette-CNwakljH.js → WuiCommandPalette-BSWDxEPw.js} +1 -1
- package/dist/{WuiDataTable-DKfTPdsn.js → WuiDataTable-D_9TWU-r.js} +1 -1
- package/dist/{WuiDatePicker-gZUfaTkZ.js → WuiDatePicker-B77M2_E7.js} +1 -1
- package/dist/{WuiDateRange-CNDyrPUT.js → WuiDateRange-BQ1GH9Mu.js} +1 -1
- package/dist/{WuiGantt-iEbrAdTQ.js → WuiGantt-wx8VSXiZ.js} +1 -1
- package/dist/WuiImageCrop-Cl97BHN4.js +1 -0
- package/dist/{WuiLightbox-DqAm2n8s.js → WuiLightbox-DFaHN2Fb.js} +1 -1
- package/dist/{WuiPhone-9dBrkfZf.js → WuiPhone-qw_6W3Q2.js} +1 -1
- package/dist/{WuiSelect-bvcpSY50.js → WuiSelect-DqHu2OW_.js} +1 -1
- package/dist/{WuiTimePicker-BIuLkZqU.js → WuiTimePicker-Bl3GcIS_.js} +1 -1
- package/dist/{WuiTour-CFRs1xE-.js → WuiTour-BS7Jd1Tt.js} +1 -1
- package/dist/{WuiTree-MMiIcWOJ.js → WuiTree-Qno7SM6z.js} +1 -1
- package/dist/{WuiTreePicker-CCkoPctd.js → WuiTreePicker-DWCLntLz.js} +1 -1
- package/dist/{WuiWizardStep-Cnc0DYg1.js → WuiWizardStep-CSS4B8g4.js} +1 -1
- package/dist/a.g-BUrXZ0Qj.js +1 -0
- package/dist/b.g-c7AZ9uVu.js +1 -0
- package/dist/c.g-1tKnlc4e.js +1 -0
- package/dist/{chips-DZpPt2SC.js → chips-DCkeuEvb.js} +1 -1
- package/dist/d.g-Cl1m1hN-.js +1 -0
- package/dist/{drawerDiscard-BsVbaCgB.js → drawerDiscard-mFYviRfI.js} +1 -1
- package/dist/e.g-BvqbeKNX.js +1 -0
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/gantt.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/status-icon.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree-picker.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/f.g-CNmxMCET.js +1 -0
- package/dist/fileViewer.g-DnuE1_o9.js +1 -0
- package/dist/{fileViewerImage-DnzDd-rQ.js → fileViewerImage-BxvHyZ4w.js} +1 -1
- package/dist/{fileViewerMedia-Dm99qAjY.js → fileViewerMedia-I9wn32xJ.js} +1 -1
- package/dist/{fileViewerPdf-BET_tiP6.js → fileViewerPdf-COm4n8i7.js} +1 -1
- package/dist/g.g-B-tbDuHa.js +1 -0
- package/dist/h.g-D63tQoPL.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/i.g-DRCcFvgj.js +1 -0
- package/dist/iconGlyphs.g-DRNDTVOs.js +1 -0
- package/dist/j.g-6OVN_siI.js +1 -0
- package/dist/k.g-BWqvhE7s.js +1 -0
- package/dist/l.g-BHoPnVck.js +1 -0
- package/dist/loader-sSdQNOg6.js +1 -0
- package/dist/m.g-BVQq45TF.js +1 -0
- package/dist/n.g-CFb-ps6H.js +1 -0
- package/dist/o.g-CGJASwcf.js +1 -0
- package/dist/{optionLabel-wbpl8OTJ.js → optionLabel-CuShfg_A.js} +1 -1
- package/dist/p.g-DRXC-OFe.js +1 -0
- package/dist/q.g-CIah8JGo.js +1 -0
- package/dist/r.g-BlQw7Aox.js +1 -0
- package/dist/s.g-DwIkkKgS.js +1 -0
- package/dist/{search-BtwgxJ0e.js → search-OPWGeniZ.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/statusIcons-DISKRFbg.js +1 -0
- package/dist/{svgNodes-CyPS2oFH.js → svgNodes-CaPMDvv7.js} +1 -1
- package/dist/t.g-045-l40U.js +1 -0
- package/dist/u.g-CK8fmXKY.js +1 -0
- package/dist/ui-elements/calendar-views.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +2 -2
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/dashboard-grid.global.js +1 -1
- package/dist/ui-elements/data-table.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -1
- package/dist/ui-elements/date-time.global.js +1 -1
- package/dist/ui-elements/datepicker.global.js +1 -1
- package/dist/ui-elements/dock.global.js +1 -1
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs-a.global.js +1 -0
- package/dist/ui-elements/glyphs-b.global.js +1 -0
- package/dist/ui-elements/glyphs-c.global.js +1 -0
- package/dist/ui-elements/glyphs-d.global.js +1 -0
- package/dist/ui-elements/glyphs-e.global.js +1 -0
- package/dist/ui-elements/glyphs-f.global.js +1 -0
- package/dist/ui-elements/glyphs-g.global.js +1 -0
- package/dist/ui-elements/glyphs-h.global.js +1 -0
- package/dist/ui-elements/glyphs-i.global.js +1 -0
- package/dist/ui-elements/glyphs-j.global.js +1 -0
- package/dist/ui-elements/glyphs-k.global.js +1 -0
- package/dist/ui-elements/glyphs-l.global.js +1 -0
- package/dist/ui-elements/glyphs-m.global.js +1 -0
- package/dist/ui-elements/glyphs-n.global.js +1 -0
- package/dist/ui-elements/glyphs-o.global.js +1 -0
- package/dist/ui-elements/glyphs-p.global.js +1 -0
- package/dist/ui-elements/glyphs-q.global.js +1 -0
- package/dist/ui-elements/glyphs-r.global.js +1 -0
- package/dist/ui-elements/glyphs-s.global.js +1 -0
- package/dist/ui-elements/glyphs-t.global.js +1 -0
- package/dist/ui-elements/glyphs-u.global.js +1 -0
- package/dist/ui-elements/glyphs-v.global.js +1 -0
- package/dist/ui-elements/glyphs-w.global.js +1 -0
- package/dist/ui-elements/glyphs-x.global.js +1 -0
- package/dist/ui-elements/glyphs-z.global.js +1 -0
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/hover-card.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -1
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +1 -1
- package/dist/ui-elements/mini-calendar.global.js +1 -1
- package/dist/ui-elements/navigation-menu.global.js +1 -1
- package/dist/ui-elements/notification-center.global.js +1 -1
- package/dist/ui-elements/offline-banner.global.js +1 -1
- package/dist/ui-elements/onboarding-checklist.global.js +1 -1
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/otp.global.js +1 -1
- package/dist/ui-elements/overflow.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -1
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/rating.global.js +1 -1
- package/dist/ui-elements/record-pager.global.js +1 -1
- package/dist/ui-elements/relative-time.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +1 -1
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/server.global.js +1 -1
- package/dist/ui-elements/shell.global.js +1 -1
- package/dist/ui-elements/shortcuts.global.js +1 -1
- package/dist/ui-elements/show-more.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -1
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/table-export.global.js +1 -1
- package/dist/ui-elements/timepicker.global.js +1 -1
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/truncate.global.js +1 -1
- package/dist/ui-elements/whats-new.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -1
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +10 -10
- package/dist/ui-file-viewer.js +1 -1
- package/dist/v.g-BpLD1c9M.js +1 -0
- package/dist/w.g-CDqV9dT6.js +1 -0
- package/dist/x.g-T5k9qAoo.js +1 -0
- package/dist/z.g-B8smtOck.js +1 -0
- package/package.json +5 -5
- package/types/global/glyphChunks.g.d.ts +1 -0
- package/types/global/glyphs.d.ts +9 -12
- package/types/global/parts/glyphs-a.g.d.ts +1 -0
- package/types/global/parts/glyphs-b.g.d.ts +1 -0
- package/types/global/parts/glyphs-c.g.d.ts +1 -0
- package/types/global/parts/glyphs-d.g.d.ts +1 -0
- package/types/global/parts/glyphs-e.g.d.ts +1 -0
- package/types/global/parts/glyphs-f.g.d.ts +1 -0
- package/types/global/parts/glyphs-g.g.d.ts +1 -0
- package/types/global/parts/glyphs-h.g.d.ts +1 -0
- package/types/global/parts/glyphs-i.g.d.ts +1 -0
- package/types/global/parts/glyphs-j.g.d.ts +1 -0
- package/types/global/parts/glyphs-k.g.d.ts +1 -0
- package/types/global/parts/glyphs-l.g.d.ts +1 -0
- package/types/global/parts/glyphs-m.g.d.ts +1 -0
- package/types/global/parts/glyphs-n.g.d.ts +1 -0
- package/types/global/parts/glyphs-o.g.d.ts +1 -0
- package/types/global/parts/glyphs-p.g.d.ts +1 -0
- package/types/global/parts/glyphs-q.g.d.ts +1 -0
- package/types/global/parts/glyphs-r.g.d.ts +1 -0
- package/types/global/parts/glyphs-s.g.d.ts +1 -0
- package/types/global/parts/glyphs-t.g.d.ts +1 -0
- package/types/global/parts/glyphs-u.g.d.ts +1 -0
- package/types/global/parts/glyphs-v.g.d.ts +1 -0
- package/types/global/parts/glyphs-w.g.d.ts +1 -0
- package/types/global/parts/glyphs-x.g.d.ts +1 -0
- package/types/global/parts/glyphs-z.g.d.ts +1 -0
- package/types/glyphTable.d.ts +23 -0
- package/types/iconCatalog/a.g.d.ts +2 -0
- package/types/iconCatalog/b.g.d.ts +2 -0
- package/types/iconCatalog/c.g.d.ts +2 -0
- package/types/iconCatalog/d.g.d.ts +2 -0
- package/types/iconCatalog/e.g.d.ts +2 -0
- package/types/iconCatalog/f.g.d.ts +2 -0
- package/types/iconCatalog/g.g.d.ts +2 -0
- package/types/iconCatalog/h.g.d.ts +2 -0
- package/types/iconCatalog/i.g.d.ts +2 -0
- package/types/iconCatalog/j.g.d.ts +2 -0
- package/types/iconCatalog/k.g.d.ts +2 -0
- package/types/iconCatalog/l.g.d.ts +2 -0
- package/types/iconCatalog/m.g.d.ts +2 -0
- package/types/iconCatalog/n.g.d.ts +2 -0
- package/types/iconCatalog/o.g.d.ts +2 -0
- package/types/iconCatalog/p.g.d.ts +2 -0
- package/types/iconCatalog/q.g.d.ts +2 -0
- package/types/iconCatalog/r.g.d.ts +2 -0
- package/types/iconCatalog/s.g.d.ts +2 -0
- package/types/iconCatalog/t.g.d.ts +2 -0
- package/types/iconCatalog/u.g.d.ts +2 -0
- package/types/iconCatalog/v.g.d.ts +2 -0
- package/types/iconCatalog/w.g.d.ts +2 -0
- package/types/iconCatalog/x.g.d.ts +2 -0
- package/types/iconCatalog/z.g.d.ts +2 -0
- package/types/iconCatalogNames.g.d.ts +1 -0
- package/types/iconGlyphs.g.d.ts +3 -6
- package/dist/WuiImageCrop-97d50aEw.js +0 -1
- package/dist/fileViewer.g-D_zLw_p-.js +0 -1
- package/dist/iconGlyphs.g-a9FtjPXh.js +0 -1
- package/dist/loader-X2uBXCDm.js +0 -1
- package/dist/statusIcons-Cd3GJcBR.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./hasOwn-CJsplJ62.js";import{n as r,t as i}from"./copyText-sHWcpcPm.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{t as o}from"./iconGlyphs.g-
|
|
1
|
+
import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./hasOwn-CJsplJ62.js";import{n as r,t as i}from"./copyText-sHWcpcPm.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{t as o}from"./iconGlyphs.g-DRNDTVOs.js";import{r as s}from"./textStore-Dh5iyZSR.js";import{t as c}from"./codeBlock.g-BCF2IlK-.js";Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var l=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),u=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),d=`(?![\\s\\S])`,f=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${d})`).source,p=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,u([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],m=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,u(/* @__PURE__ */ `async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,u([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,u(/* @__PURE__ */ `abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,u([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],g=[[`comment`,RegExp(`--[^\\n]*|${f}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,u(/* @__PURE__ */ `add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,u([`true`,`false`])],[`type`,u([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],_=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,u([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,u(/* @__PURE__ */ `awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],v=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],y=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${d})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],b={json:p,js:m,cs:h,sql:g,bash:_,http:v,css:[[`comment`,new RegExp(f)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:y,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},x=e=>n(b,e),S=/* @__PURE__ */ new Map;function C(e){let t=S.get(e);if(!t){let n=b[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},S.set(e,t)}return t}function w(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function T(e,t,n=[]){let{re:r,types:i}=C(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;w(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?T(`htmlTag`,r,n):w(n,i[s]??`plain`,r),a=o.index+r.length}return w(n,`plain`,t.slice(a)),n}function E(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return T(`http`,e);let n=t[0]??``,r=T(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?T(`json`,i,r):a===`<`?T(`html`,i,r):(w(r,`plain`,i),r)}function D(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return E(n);let r=t===`razor`?`html`:t;return!x(r)||r===`htmlTag`?[[`plain`,n]]:T(r,n)}function O(e,t){let n=[],r=[n];for(let[i,a]of D(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var k=()=>s(`codeBlock`,c);function A(e){return n(l,e)}var j=class extends a{_title;_view;_codeEl;_copyIcon;_copyText;_chrome=null;_copied=!1;_observer=null;_timer=0;_cancelFrame=null;constructor(){super();let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=t!==null&&A(t)?t:`text`,r=this.getAttribute(`label`)||``,i=O(this._code(),n);this._title.textContent=r||l[n],this._view.setAttribute(`aria-label`,r||k().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>M(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(n){let a=n.createElement(`div`);a.className=`wui-code-bar`;let o=n.createElement(`button`);return o.type=`button`,o.className=`${e(`primary`,`ghost`,`sm`)} wui-code-copy`,o.dataset.wui=t,o.setAttribute(`aria-live`,`polite`),this._setCopied(!1),o.append(this._copyIcon,this._copyText),o.addEventListener(`click`,async()=>{await r(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),i))}),a.append(this._title,o),a}_setCopied(e){this._copied=e;let t=o(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||k().copiedLabel:this.getAttribute(`copy-label`)||k().copyLabel}};function M(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}export{j as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-Dh5iyZSR.js";import{t as r}from"./commandPalette.g-DP-Zl8SU.js";import{t as i}from"./textMatch-wdY7XLIc.js";var a=`[role="option"]`,o=()=>n(`commandPalette`,r),s=5,c=20,l=`.wui-cmd-back, [data-depth]`,u=`[data-group-tab]`,d=`.wui-cmd-error-retry`,f=0;function p(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var m=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},h=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),g=class extends t{_path;_group;_crumbSig;_modal;_recentsId;_onModalClosed;_activeId;_lastQuery;_lastIds;_userChose;_onKeyDown;_onClick;_onMouseDown;_onMouseMove;_onInput;static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++f}`,this._onModalClosed=()=>{this._setKeyboard(!1),this._reset(),this.hasAttribute(`path`)&&this._restart()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=p(e.target,d);if(t&&this.contains(t)){this.dispatchEvent(new CustomEvent(`wui-command-palette:retry`,{bubbles:!0}));return}let n=p(e.target,l);if(n&&this.contains(n)){let e=n.matches(`.wui-cmd-back`)?this._path.length-1:Number(n.dataset.depth);this._goTo(this._path.slice(0,e));return}let r=p(e.target,u);if(r&&this.contains(r)){this._pickGroup(r.dataset.groupTab||null);return}let i=this._optionFrom(e.target);i&&this._select(i)},this._onMouseDown=e=>{let t=p(e.target,l),n=p(e.target,u);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`wui-modal`),this._modal?.addEventListener(`wui-modal-closed`,this._onModalClosed),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??o().emptyText}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
|
|
2
|
-
`),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=p(e,a);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(p(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return h(this,a,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of h(this,a,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=h(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return h(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=m(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=m(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??o().rootLabel,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=m(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return m(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return h(this,a,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o().recentsLabel,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(p(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path[this._path.length-1]?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let t=this._input(),n=(t?t.value:``).trim(),r=n.toLowerCase(),o=this.highlight,s=h(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path[this._path.length-1]?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let t of this._realOptions()){let a=m(t,`.wui-cmd-item-label`,HTMLElement),s=t.dataset.label??a?.textContent??``,l=(t.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!r||s.toLowerCase().includes(r)||l.some(e=>e.toLowerCase().includes(r)),p=this._inScope(t,c)&&(!u||t.dataset.groupKey===u)&&f;t.hidden=!p,p&&d++,a&&a.replaceChildren(...i(s,o?n:``).map(t=>t.match?e(`mark`,{class:`wui-cmd-mark`},t.text):t.text))}let f=this._recentsHost();for(let e of h(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!h(e,a,HTMLElement).some(e=>!e.hidden));let p=m(this,`[role="listbox"]`,HTMLElement);p&&(p.hidden=d===0);let g=m(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=r&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`wui-modal-closed`,this._onModalClosed),this._modal=null}};export{g as t};
|
|
2
|
+
`),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1,this._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=p(e,a);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden!==!1||(p(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return h(this,a,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of h(this,a,HTMLElement))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=h(this,`.wui-cmd-page`,HTMLElement).find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_tabs(){return h(this,u,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=m(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=m(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??o().rootLabel,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=m(e,`.wui-cmd-trail`,HTMLElement);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return m(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return h(this,a,HTMLElement).filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,c):s}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let s=`${this._recentsId}-label`,c=document.createElement(`div`);c.className=`wui-cmd-group`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-labelledby`,s);let l=document.createElement(`div`);l.className=`wui-cmd-group-label`,l.setAttribute(`role`,`presentation`),l.id=s,l.textContent=this.getAttribute(`recents-label`)??o().recentsLabel,c.append(l);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),c.append(t)}e.replaceChildren(c)}_inScope(e,t){return!t||(p(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path[this._path.length-1]?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let t=this._input(),n=(t?t.value:``).trim(),r=n.toLowerCase(),o=this.highlight,s=h(this,`.wui-cmd-page`,HTMLElement),c=s.length>0,l=this._path[this._path.length-1]?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=this._groupActive()?this._group:null,d=0;for(let t of this._realOptions()){let a=m(t,`.wui-cmd-item-label`,HTMLElement),s=t.dataset.label??a?.textContent??``,l=(t.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!r||s.toLowerCase().includes(r)||l.some(e=>e.toLowerCase().includes(r)),p=this._inScope(t,c)&&(!u||t.dataset.groupKey===u)&&f;t.hidden=!p,p&&d++,a&&a.replaceChildren(...i(s,o?n:``).map(t=>t.match?e(`mark`,{class:`wui-cmd-mark`},t.text):t.text))}let f=this._recentsHost();for(let e of h(this,`[role="group"]`,HTMLElement))f?.contains(e)||(e.hidden=!h(e,a,HTMLElement).some(e=>!e.hidden));let p=m(this,`[role="listbox"]`,HTMLElement);p&&(p.hidden=d===0||m(this,`.wui-cmd-error`,HTMLElement)!==null);let g=m(this,`.wui-cmd-empty`,HTMLElement);g&&(g.textContent=r&&d===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`wui-modal-closed`,this._onModalClosed),this._modal=null}};export{g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,F as t,I as n,L as r,O as i,S as a,T as o,_ as s,g as c,h as l,m as u,r as d,s as f,t as p,u as m,w as h,x as g}from"./dataTable-D48Rwq1a.js";import{t as _}from"./dom-DMQu--xV.js";import{t as v}from"./elementBase-Cxeyx0tU.js";import{n as y}from"./imeSafeEnter-DeO_3lXy.js";import{t as b}from"./svgNodes-CyPS2oFH.js";import{o as x,s as S}from"./tableSelect-B2lLTEj1.js";function C(){return import(`./tableExport-D1OdFVQj.js`).then(e=>e.r)}var w=`.wui-col-resize`,T=`.wui-group-row, .wui-virtual-spacer`,E=`.wui-select-cell, .wui-expand-cell`;function D(){return b({class:`wui-icon`,"data-icon":`chevron-down`,"data-wui":`AppIcon`,width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[[`path`,{stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":`10`,"stroke-width":`1.5`,d:`M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95`}]])}function O(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function k(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var A=e=>{let t=_(e,w);return t instanceof HTMLElement?t:null},j=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),M=class extends v{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=A(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=e(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._paintSaves(),this._schedule()}_paintSaves(){this.querySelectorAll(`tbody > tr[data-wui-save-state]`).forEach(e=>{e instanceof HTMLTableRowElement&&g(e,e.getAttribute(m))})}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,t){let n=this._headCells(e),r=n.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(E)?`lead`:null});if(!r.some(e=>e===`start`||e===`end`))return;let i=o(r);i.forEach((e,t)=>{e&&this._ro?.observe(O(n[t]))});let s=e=>O(n[e]).getBoundingClientRect().width,c=0;i.forEach((t,n)=>{t?.side===`start`&&(this._setVar(e,h(`start`,t.ordinal),c),c+=s(n))}),c=0;for(let t=i.length-1;t>=0;t--){let n=i[t];n?.side===`end`&&(this._setVar(e,h(`end`,n.ordinal),c),c+=s(t))}if(t)for(let t of e.rows)t.matches(`${T}, .wui-row-expanded`)||t.cells.length!==n.length||i.forEach((e,n)=>{if(!e)return;let r=O(t.cells[n]);r.classList.contains(`wui-pin-${e.side}`)||r.classList.add(`wui-pin-${e.side}`),e.edge&&!r.classList.contains(`wui-pin-${e.side}-edge`)&&r.classList.add(`wui-pin-${e.side}-edge`);let i=a(e.side,e.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(d,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(E))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(w))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(p)),r.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();r.setAttribute(`aria-label`,i(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(T)&&!j(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(w);n&&this._handleValue(n,u(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(E))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=u(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(w);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,n(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(O(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},r(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let n=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,r(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[n.indexOf(e)]||0),this._fitTable(t,n),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=A(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=A(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(y(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=O(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(w)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}let n=_(e.target,`[data-wui-table-export], [data-wui-density]`);if(n&&this.contains(n)){e.preventDefault(),n.hasAttribute(`data-wui-density`)?this._setDensity(n.getAttribute(`data-wui-density`)??``):this._export(n.getAttribute(`data-wui-table-export`)??``);return}if(!this.hasAttribute(`group-by`))return;let r=_(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(r instanceof HTMLTableRowElement)||!this.contains(r))return;let i=r.dataset.groupKey;this._collapsed.has(i)?this._collapsed.delete(i):this._collapsed.add(i),this._showGroup(r,!this._collapsed.has(i));let a=this._table;a&&this.hasAttribute(`virtual`)&&(this._virtual(a,!0),this._mo?.takeRecords())}async _export(e){if(e!==`csv`&&e!==`xlsx`)return;let t=this.querySelector(`:scope > table`);if(!(t instanceof HTMLTableElement))return;let n=Array.from(t.tBodies[0]?.rows??[]).filter(e=>!e.hidden&&!e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`)&&!j(e)),r=/* @__PURE__ */ new Set;for(let e of n)for(let[t,n]of Array.from(e.cells).entries())(n.matches(E)||n.querySelector(`.u-row-actions`))&&r.add(t);let i=e=>Array.from(e).filter((e,t)=>!r.has(t)).map(e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;for(let e of t.querySelectorAll(`.visually-hidden, .wui-col-resize, .infotip`))e.remove();return(t.textContent??``).replace(/\s+/g,` `).trim()}),a=i(t.tHead?.rows[0]?.cells??[]),o=n.map(e=>i(e.cells)),s=this.getAttribute(`export-name`)??`table`,{downloadTable:c,tableCsv:l,tableXlsx:u}=await C();e===`csv`?c([l(a,o)],`text/csv;charset=utf-8`,`${s}.csv`):c([u(a,o)],`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`${s}.xlsx`)}_setDensity(e){let t=this.querySelector(`:scope > table`);if(t instanceof HTMLTableElement){t.classList.remove(`wui-table-cozy`,`wui-table-compact`),(e===`cozy`||e===`compact`)&&t.classList.add(`wui-table-${e}`);for(let t of this.querySelectorAll(`[data-wui-density]`))t.setAttribute(`aria-pressed`,String(t.getAttribute(`data-wui-density`)===e))}}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let i=e.tBodies[0];if(!i)return;let a=[...i.rows].filter(e=>!e.matches(T));if(a.some(j))return;let o=this.ownerDocument,u=/* @__PURE__ */ new Map;for(let e of i.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&u.set(e.dataset.groupKey,e);let d=this.closest(`[data-wui-server]`)?[]:this._groupOrder,f=c(a,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,d);this._groupOrder=f.map(e=>e.key);let p=o.createDocumentFragment(),m=e.hasAttribute(`data-app-datatable-selectable`),h=f.map(e=>{let t=u.get(e.key)??this._groupRow(o,e.key);u.delete(e.key);let r=k(t.querySelector(`.wui-group-cell`),HTMLTableCellElement);return m&&!t.querySelector(`.wui-group-select`)&&t.insertBefore(x(o,e.key),r),r.colSpan=m?n.length-1:n.length,k(t.querySelector(`.wui-group-count`),HTMLElement).textContent=l(e.items.length),k(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${s(e.items.length)}`,p.append(t,...e.items),[t,e.key]});for(let e of u.values())e.remove();i.insertBefore(p,this._bottom?.parentNode===i?this._bottom:null);for(let[e,t]of h)this._showGroup(e,!this._collapsed.has(t));m&&S(e)}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.replaceChildren(D());let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(T);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,n){let r=e.tBodies[0];if(!r)return;if(n){this._top=this._spacer(r,this._top),this._bottom=this._spacer(r,this._bottom),r.firstElementChild!==this._top&&r.insertBefore(this._top,r.firstChild),r.lastElementChild!==this._bottom&&r.append(this._bottom);let t=Math.max(1,this._headCells(e).length);O(this._top.cells[0]).colSpan=t,O(this._bottom.cells[0]).colSpan=t,this._items=[...r.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let i=e.tHead?.getBoundingClientRect().height||0,a=t({scrollTop:this.scrollTop-i,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===a.start&&o.end===a.end)return;let s=o?Math.min(o.start,a.start):0,c=o?Math.max(o.end,a.end):this._items.length;for(let e=s;e<c;e++){let t=e<a.start||e>=a.end,n=O(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=a;let l=O(this._top),u=O(this._bottom);l.hidden=a.before===0,u.hidden=a.after===0,O(l.cells[0]).style.height=`${a.before}px`,O(u.cells[0]).style.height=`${a.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?f.compact:e.classList.contains(`wui-table-cozy`)?f.cozy:f.comfortable}};export{M as t};
|
|
1
|
+
import{D as e,F as t,I as n,L as r,O as i,S as a,T as o,_ as s,g as c,h as l,m as u,r as d,s as f,t as p,u as m,w as h,x as g}from"./dataTable-D48Rwq1a.js";import{t as _}from"./dom-DMQu--xV.js";import{t as v}from"./elementBase-Cxeyx0tU.js";import{n as y}from"./imeSafeEnter-DeO_3lXy.js";import{n as b}from"./svgNodes-CaPMDvv7.js";import{o as x,s as S}from"./tableSelect-B2lLTEj1.js";function C(){return import(`./tableExport-D1OdFVQj.js`).then(e=>e.r)}var w=`.wui-col-resize`,T=`.wui-group-row, .wui-virtual-spacer`,E=`.wui-select-cell, .wui-expand-cell`;function D(){return b({class:`wui-icon`,"data-icon":`chevron-down`,"data-wui":`AppIcon`,width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[[`path`,{stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":`10`,"stroke-width":`1.5`,d:`M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95`}]])}function O(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function k(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var A=e=>{let t=_(e,w);return t instanceof HTMLElement?t:null},j=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),M=class extends v{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=A(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=e(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._paintSaves(),this._schedule()}_paintSaves(){this.querySelectorAll(`tbody > tr[data-wui-save-state]`).forEach(e=>{e instanceof HTMLTableRowElement&&g(e,e.getAttribute(m))})}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,t){let n=this._headCells(e),r=n.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(E)?`lead`:null});if(!r.some(e=>e===`start`||e===`end`))return;let i=o(r);i.forEach((e,t)=>{e&&this._ro?.observe(O(n[t]))});let s=e=>O(n[e]).getBoundingClientRect().width,c=0;i.forEach((t,n)=>{t?.side===`start`&&(this._setVar(e,h(`start`,t.ordinal),c),c+=s(n))}),c=0;for(let t=i.length-1;t>=0;t--){let n=i[t];n?.side===`end`&&(this._setVar(e,h(`end`,n.ordinal),c),c+=s(t))}if(t)for(let t of e.rows)t.matches(`${T}, .wui-row-expanded`)||t.cells.length!==n.length||i.forEach((e,n)=>{if(!e)return;let r=O(t.cells[n]);r.classList.contains(`wui-pin-${e.side}`)||r.classList.add(`wui-pin-${e.side}`),e.edge&&!r.classList.contains(`wui-pin-${e.side}-edge`)&&r.classList.add(`wui-pin-${e.side}-edge`);let i=a(e.side,e.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(d,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(E))}_handles(e){let t=this._headCells(e),n=this._resizable(t);t.forEach((e,t)=>{if(!n[t]||e.querySelector(w))return;let r=e.ownerDocument.createElement(`span`);r.className=`wui-col-resize`,r.setAttribute(`role`,`separator`),r.setAttribute(`aria-orientation`,`vertical`),r.setAttribute(`aria-valuemin`,`48`),r.setAttribute(`aria-valuemax`,String(p)),r.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();r.setAttribute(`aria-label`,i(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(r)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(T)&&!j(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(w);n&&this._handleValue(n,u(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(E))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=u(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(w);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,n(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(O(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},r(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let n=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,r(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[n.indexOf(e)]||0),this._fitTable(t,n),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=A(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=A(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(y(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=O(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(w)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}let n=_(e.target,`[data-wui-table-export], [data-wui-density]`);if(n&&this.contains(n)){e.preventDefault(),n.hasAttribute(`data-wui-density`)?this._setDensity(n.getAttribute(`data-wui-density`)??``):this._export(n.getAttribute(`data-wui-table-export`)??``);return}if(!this.hasAttribute(`group-by`))return;let r=_(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(r instanceof HTMLTableRowElement)||!this.contains(r))return;let i=r.dataset.groupKey;this._collapsed.has(i)?this._collapsed.delete(i):this._collapsed.add(i),this._showGroup(r,!this._collapsed.has(i));let a=this._table;a&&this.hasAttribute(`virtual`)&&(this._virtual(a,!0),this._mo?.takeRecords())}async _export(e){if(e!==`csv`&&e!==`xlsx`)return;let t=this.querySelector(`:scope > table`);if(!(t instanceof HTMLTableElement))return;let n=Array.from(t.tBodies[0]?.rows??[]).filter(e=>!e.hidden&&!e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`)&&!j(e)),r=/* @__PURE__ */ new Set;for(let e of n)for(let[t,n]of Array.from(e.cells).entries())(n.matches(E)||n.querySelector(`.u-row-actions`))&&r.add(t);let i=e=>Array.from(e).filter((e,t)=>!r.has(t)).map(e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;for(let e of t.querySelectorAll(`.visually-hidden, .wui-col-resize, .infotip`))e.remove();return(t.textContent??``).replace(/\s+/g,` `).trim()}),a=i(t.tHead?.rows[0]?.cells??[]),o=n.map(e=>i(e.cells)),s=this.getAttribute(`export-name`)??`table`,{downloadTable:c,tableCsv:l,tableXlsx:u}=await C();e===`csv`?c([l(a,o)],`text/csv;charset=utf-8`,`${s}.csv`):c([u(a,o)],`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`${s}.xlsx`)}_setDensity(e){let t=this.querySelector(`:scope > table`);if(t instanceof HTMLTableElement){t.classList.remove(`wui-table-cozy`,`wui-table-compact`),(e===`cozy`||e===`compact`)&&t.classList.add(`wui-table-${e}`);for(let t of this.querySelectorAll(`[data-wui-density]`))t.setAttribute(`aria-pressed`,String(t.getAttribute(`data-wui-density`)===e))}}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let i=e.tBodies[0];if(!i)return;let a=[...i.rows].filter(e=>!e.matches(T));if(a.some(j))return;let o=this.ownerDocument,u=/* @__PURE__ */ new Map;for(let e of i.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&u.set(e.dataset.groupKey,e);let d=this.closest(`[data-wui-server]`)?[]:this._groupOrder,f=c(a,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,d);this._groupOrder=f.map(e=>e.key);let p=o.createDocumentFragment(),m=e.hasAttribute(`data-app-datatable-selectable`),h=f.map(e=>{let t=u.get(e.key)??this._groupRow(o,e.key);u.delete(e.key);let r=k(t.querySelector(`.wui-group-cell`),HTMLTableCellElement);return m&&!t.querySelector(`.wui-group-select`)&&t.insertBefore(x(o,e.key),r),r.colSpan=m?n.length-1:n.length,k(t.querySelector(`.wui-group-count`),HTMLElement).textContent=l(e.items.length),k(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${s(e.items.length)}`,p.append(t,...e.items),[t,e.key]});for(let e of u.values())e.remove();i.insertBefore(p,this._bottom?.parentNode===i?this._bottom:null);for(let[e,t]of h)this._showGroup(e,!this._collapsed.has(t));m&&S(e)}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.replaceChildren(D());let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(T);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,n){let r=e.tBodies[0];if(!r)return;if(n){this._top=this._spacer(r,this._top),this._bottom=this._spacer(r,this._bottom),r.firstElementChild!==this._top&&r.insertBefore(this._top,r.firstChild),r.lastElementChild!==this._bottom&&r.append(this._bottom);let t=Math.max(1,this._headCells(e).length);O(this._top.cells[0]).colSpan=t,O(this._bottom.cells[0]).colSpan=t,this._items=[...r.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let i=e.tHead?.getBoundingClientRect().height||0,a=t({scrollTop:this.scrollTop-i,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===a.start&&o.end===a.end)return;let s=o?Math.min(o.start,a.start):0,c=o?Math.max(o.end,a.end):this._items.length;for(let e=s;e<c;e++){let t=e<a.start||e>=a.end,n=O(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=a;let l=O(this._top),u=O(this._bottom);l.hidden=a.before===0,u.hidden=a.after===0,O(l.cells[0]).style.height=`${a.before}px`,O(u.cells[0]).style.height=`${a.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?f.compact:e.classList.contains(`wui-table-cozy`)?f.cozy:f.comfortable}};export{M as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./calendarMath-CeawKuZQ.js";import{i as f,r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v,g as y}from"./formatters-CXMylefd.js";import{t as b}from"./formMirror-9IpSgeZb.js";import{t as x}from"./iconGlyphs.g-a9FtjPXh.js";import{a as S,l as C,s as w}from"./nativeOverlay-BHD2QV02.js";import{n as T,t as E}from"./rtl-g7G8Bsib.js";import{r as D}from"./textStore-Dh5iyZSR.js";import{t as O}from"./datePicker.g-sGQE8c3n.js";var k=()=>D(`datePicker`,O),A=e=>e-(e%10+10)%10-1,j=class extends m{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return f(this._openFn,`open missing`)}get _close(){return f(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&w(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,b(this,this._value),this._syncTrigger()}_firstDay(){return c(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=a(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return l(e);let n=t(this._monthKey(e));return n?{y:n.y,m:n.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?k().yearPlaceholder:this._monthOnly()?k().monthPlaceholder:k().placeholder)}_label(t){let n=this.getAttribute(`display-format`);return this._yearOnly()?s(t,n):this._monthOnly()?e(this._monthKey(t)||``,n):i(t,n)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this.getAttribute(`aria-label`),a=this.getAttribute(`aria-describedby`);this.replaceChildren(p(`div`,{class:`datepicker`},p(`button`,{type:`button`,class:`form-control datepicker-trigger${r}${t?` has-value`:``}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":i,"aria-describedby":a},p(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),x(`calendar-dots`)),p(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,h(this,this.querySelector(`.datepicker-trigger`)),b(this,this._value),this._wire()}_syncFormValue(){b(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`)),h(this,e)}_limits(){if(this._yearOnly()){let e=a(this.getAttribute(`min`)),t=a(this.getAttribute(`max`)),n=e?e.y:-1/0,r=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<n||e>r}}if(this._monthOnly()){let e=t(this._monthKey(this.getAttribute(`min`))),n=t(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=n?n.y*12+n.m:1/0,a=e?e.y:-1/0,o=n?n.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=l(this.getAttribute(`min`)),n=l(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=n?new Date(n.y,n.m,n.d).getTime():1/0,s=/* @__PURE__ */ new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&s.add(Number(t))}return{dayDisabled:(e,t,n)=>{let a=new Date(e,t,n),o=a.getTime();return o<r||o>i||s.has(a.getDay())},monthDisabled:(e,t)=>{let n=new Date(e,t,1).getTime();return new Date(e,t,o(e,t)).getTime()<r||n>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{S(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=o(this._viewY,this._viewM),r=l(this._value),i=/* @__PURE__ */ new Date,{dayDisabled:a}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},c=(e,t,n,o)=>{let c=d(e,t,n),l=r&&r.y===e&&r.m===t&&r.d===n,u=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,m=a(e,t,n),h=[`datepicker-day`,o?`is-outside`:``,u?`is-today`:``,l?`is-selected`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:h,"data-iso":c,role:`gridcell`,tabindex:f&&!m?`0`:`-1`,"aria-selected":l?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},n)},f=[],m=u(this._viewY,this._viewM-1),h=o(m.y,m.m);for(let e=t-1;e>=0;e--)f.push(c(m.y,m.m,h-e,!0));for(let e=1;e<=n;e++)f.push(c(this._viewY,this._viewM,e,!1));let y=u(this._viewY,this._viewM+1),b=(7-(t+n)%7)%7;for(let e=1;e<=b;e++)f.push(c(y.y,y.m,e,!0));let S=a(i.getFullYear(),i.getMonth(),i.getDate()),C=g(this)?null:p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel),w=Array.from({length:7},(t,n)=>p(`span`,null,v((n+e)%7,`min`)));return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":k().previousMonth},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":k().chooseMonthYearLabel},`${_(this._viewM)} ${this._viewY}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":k().nextMonth},x(`chevron-right`))),p(`div`,{class:`datepicker-weekdays`},...w),p(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...f),p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:S?!0:void 0},k().todayLabel),C)]}_clearFoot(e){return!e||g(this)?[]:[p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=/* @__PURE__ */ new Date,{monthDisabled:n}=this._limits(),r=[];for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r.push(p(`button`,{type:`button`,class:c,"data-month":i,tabindex:this._monthOnly()?this._viewY*12+i===this._gridFocus&&!s?0:-1:void 0,disabled:s?!0:void 0},y(i)))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":k().previousYearLabel},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":k().chooseYearLabel},this._viewY),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":k().nextYearLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...r),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=(/* @__PURE__ */ new Date()).getFullYear(),{yearDisabled:n}=this._limits(),r=A(this._viewY),i=[];for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push(p(`button`,{type:`button`,class:u,"data-year":o,tabindex:this._yearOnly()?o===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},o))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":k().previousDecadeLabel},x(`chevron-left`)),p(`span`,{class:`datepicker-month`},`${r+1} to ${r+10}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":k().nextDecadeLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored(n(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:A,unit:e=>e,cell:e=>e,disabled:e,iso:r}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=/* @__PURE__ */ new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,n,r){let{y:i,m:a}=u(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``;let s=this.querySelector(`.datepicker-day[data-iso="${d(i,a,n)}"]`);s instanceof HTMLButtonElement&&s.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch(T(e.key,E(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let n=this._focus||l(this._value)||{y:this._viewY,m:this._viewM,d:1},r=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},i=(t,i,a=t<0?-1:1)=>{e.preventDefault(),r(n.y,n.m,n.d+t,a,i)};switch(T(e.key,E(this))){case`ArrowLeft`:i(-1,`slide-prev`);break;case`ArrowRight`:i(1,`slide-next`);break;case`ArrowUp`:i(-7,`slide-prev`);break;case`ArrowDown`:i(7,`slide-next`);break;case`Home`:i(-((new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:i(6-(new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=u(n.y,n.m-(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=u(n.y,n.m+(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(n.y,n.m,n.d)||(this.value=d(n.y,n.m,n.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>w(t),o=()=>{i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if(g(this))return;let n=/* @__PURE__ */ new Date,r=this._parts(this._value),s=this._gridKind();if(s)this._viewY=r?r.y:n.getFullYear(),this._mode=s.view,this._focus=null,this._gridFocus=this._gridFocusCell(s);else{(r||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=r&&r.y===this._viewY&&r.m===this._viewM;if(this._focus=t?r:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),C(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!a())return;i?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let c=t.querySelector(`[tabindex="0"]`);c instanceof HTMLElement&&c.focus()},this._closeFn=()=>{S(t)},e.addEventListener(`click`,()=>a()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let i=t.closest(`[data-nav]`);if(i instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(i.dataset.nav)<0?`slide-prev`:`slide-next`;let e=u(this._viewY,this._viewM+Number(i.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let a=t.closest(`[data-nav-year]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navYear),this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-nav-decade]`);if(o instanceof HTMLElement){this._viewY+=Number(o.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let s=t.closest(`[data-view]`);if(s instanceof HTMLElement){this._mode=s.dataset.view,this._renderView();return}let c=t.closest(`[data-month]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._monthOnly()){this.value=this._monthStored(n(this._viewY,Number(c.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(c.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let l=t.closest(`[data-year]`);if(l instanceof HTMLButtonElement&&!l.disabled){if(this._yearOnly()){this.value=r(Number(l.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(l.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=/* @__PURE__ */ new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=d(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let f=t.closest(`.datepicker-day[data-iso]`);f instanceof HTMLButtonElement&&!f.disabled&&(this.value=f.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};export{j as t};
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./calendarMath-CeawKuZQ.js";import{i as f,r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v,g as y}from"./formatters-CXMylefd.js";import{t as b}from"./formMirror-9IpSgeZb.js";import{t as x}from"./iconGlyphs.g-DRNDTVOs.js";import{a as S,l as C,s as w}from"./nativeOverlay-BHD2QV02.js";import{n as T,t as E}from"./rtl-g7G8Bsib.js";import{r as D}from"./textStore-Dh5iyZSR.js";import{t as O}from"./datePicker.g-sGQE8c3n.js";var k=()=>D(`datePicker`,O),A=e=>e-(e%10+10)%10-1,j=class extends m{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return f(this._openFn,`open missing`)}get _close(){return f(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&w(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,b(this,this._value),this._syncTrigger()}_firstDay(){return c(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=a(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return l(e);let n=t(this._monthKey(e));return n?{y:n.y,m:n.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?k().yearPlaceholder:this._monthOnly()?k().monthPlaceholder:k().placeholder)}_label(t){let n=this.getAttribute(`display-format`);return this._yearOnly()?s(t,n):this._monthOnly()?e(this._monthKey(t)||``,n):i(t,n)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this.getAttribute(`aria-label`),a=this.getAttribute(`aria-describedby`);this.replaceChildren(p(`div`,{class:`datepicker`},p(`button`,{type:`button`,class:`form-control datepicker-trigger${r}${t?` has-value`:``}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":i,"aria-describedby":a},p(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),x(`calendar-dots`)),p(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,h(this,this.querySelector(`.datepicker-trigger`)),b(this,this._value),this._wire()}_syncFormValue(){b(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`)),h(this,e)}_limits(){if(this._yearOnly()){let e=a(this.getAttribute(`min`)),t=a(this.getAttribute(`max`)),n=e?e.y:-1/0,r=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<n||e>r}}if(this._monthOnly()){let e=t(this._monthKey(this.getAttribute(`min`))),n=t(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=n?n.y*12+n.m:1/0,a=e?e.y:-1/0,o=n?n.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=l(this.getAttribute(`min`)),n=l(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=n?new Date(n.y,n.m,n.d).getTime():1/0,s=/* @__PURE__ */ new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&s.add(Number(t))}return{dayDisabled:(e,t,n)=>{let a=new Date(e,t,n),o=a.getTime();return o<r||o>i||s.has(a.getDay())},monthDisabled:(e,t)=>{let n=new Date(e,t,1).getTime();return new Date(e,t,o(e,t)).getTime()<r||n>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{S(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=o(this._viewY,this._viewM),r=l(this._value),i=/* @__PURE__ */ new Date,{dayDisabled:a}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},c=(e,t,n,o)=>{let c=d(e,t,n),l=r&&r.y===e&&r.m===t&&r.d===n,u=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,m=a(e,t,n),h=[`datepicker-day`,o?`is-outside`:``,u?`is-today`:``,l?`is-selected`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:h,"data-iso":c,role:`gridcell`,tabindex:f&&!m?`0`:`-1`,"aria-selected":l?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},n)},f=[],m=u(this._viewY,this._viewM-1),h=o(m.y,m.m);for(let e=t-1;e>=0;e--)f.push(c(m.y,m.m,h-e,!0));for(let e=1;e<=n;e++)f.push(c(this._viewY,this._viewM,e,!1));let y=u(this._viewY,this._viewM+1),b=(7-(t+n)%7)%7;for(let e=1;e<=b;e++)f.push(c(y.y,y.m,e,!0));let S=a(i.getFullYear(),i.getMonth(),i.getDate()),C=g(this)?null:p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel),w=Array.from({length:7},(t,n)=>p(`span`,null,v((n+e)%7,`min`)));return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":k().previousMonth},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":k().chooseMonthYearLabel},`${_(this._viewM)} ${this._viewY}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":k().nextMonth},x(`chevron-right`))),p(`div`,{class:`datepicker-weekdays`},...w),p(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...f),p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:S?!0:void 0},k().todayLabel),C)]}_clearFoot(e){return!e||g(this)?[]:[p(`div`,{class:`datepicker-foot`},p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},k().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=/* @__PURE__ */ new Date,{monthDisabled:n}=this._limits(),r=[];for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r.push(p(`button`,{type:`button`,class:c,"data-month":i,tabindex:this._monthOnly()?this._viewY*12+i===this._gridFocus&&!s?0:-1:void 0,disabled:s?!0:void 0},y(i)))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":k().previousYearLabel},x(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":k().chooseYearLabel},this._viewY),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":k().nextYearLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...r),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=(/* @__PURE__ */ new Date()).getFullYear(),{yearDisabled:n}=this._limits(),r=A(this._viewY),i=[];for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push(p(`button`,{type:`button`,class:u,"data-year":o,tabindex:this._yearOnly()?o===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},o))}return[p(`div`,{class:`datepicker-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":k().previousDecadeLabel},x(`chevron-left`)),p(`span`,{class:`datepicker-month`},`${r+1} to ${r+10}`),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":k().nextDecadeLabel},x(`chevron-right`))),p(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored(n(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:A,unit:e=>e,cell:e=>e,disabled:e,iso:r}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=/* @__PURE__ */ new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,n,r){let{y:i,m:a}=u(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``;let s=this.querySelector(`.datepicker-day[data-iso="${d(i,a,n)}"]`);s instanceof HTMLButtonElement&&s.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch(T(e.key,E(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let n=this._focus||l(this._value)||{y:this._viewY,m:this._viewM,d:1},r=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},i=(t,i,a=t<0?-1:1)=>{e.preventDefault(),r(n.y,n.m,n.d+t,a,i)};switch(T(e.key,E(this))){case`ArrowLeft`:i(-1,`slide-prev`);break;case`ArrowRight`:i(1,`slide-next`);break;case`ArrowUp`:i(-7,`slide-prev`);break;case`ArrowDown`:i(7,`slide-next`);break;case`Home`:i(-((new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:i(6-(new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=u(n.y,n.m-(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=u(n.y,n.m+(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(n.y,n.m,n.d)||(this.value=d(n.y,n.m,n.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>w(t),o=()=>{i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if(g(this))return;let n=/* @__PURE__ */ new Date,r=this._parts(this._value),s=this._gridKind();if(s)this._viewY=r?r.y:n.getFullYear(),this._mode=s.view,this._focus=null,this._gridFocus=this._gridFocusCell(s);else{(r||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=r&&r.y===this._viewY&&r.m===this._viewM;if(this._focus=t?r:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),C(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!a())return;i?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let c=t.querySelector(`[tabindex="0"]`);c instanceof HTMLElement&&c.focus()},this._closeFn=()=>{S(t)},e.addEventListener(`click`,()=>a()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let i=t.closest(`[data-nav]`);if(i instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(i.dataset.nav)<0?`slide-prev`:`slide-next`;let e=u(this._viewY,this._viewM+Number(i.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let a=t.closest(`[data-nav-year]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navYear),this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-nav-decade]`);if(o instanceof HTMLElement){this._viewY+=Number(o.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let s=t.closest(`[data-view]`);if(s instanceof HTMLElement){this._mode=s.dataset.view,this._renderView();return}let c=t.closest(`[data-month]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._monthOnly()){this.value=this._monthStored(n(this._viewY,Number(c.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(c.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let l=t.closest(`[data-year]`);if(l instanceof HTMLButtonElement&&!l.disabled){if(this._yearOnly()){this.value=r(Number(l.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(l.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=/* @__PURE__ */ new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=d(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let f=t.closest(`.datepicker-day[data-iso]`);f instanceof HTMLButtonElement&&!f.disabled&&(this.value=f.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};export{j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-CeawKuZQ.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-Dh5iyZSR.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{n as u,r as d,t as f}from"./zone-BR02ZkHF.js";import{r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v}from"./formatters-CXMylefd.js";import{t as y}from"./iconGlyphs.g-a9FtjPXh.js";import{a as b,l as x,s as S}from"./nativeOverlay-BHD2QV02.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=f,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(d(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d:u}=a,p=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),m=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:m,start:p(o,c,u),end:p(o,c,u)};case`yesterday`:return{label:m,start:p(o,c,u-1),end:p(o,c,u-1)};case`last7Days`:return{label:m,start:p(o,c,u-6),end:p(o,c,u)};case`last30Days`:return{label:m,start:p(o,c,u-29),end:p(o,c,u)};case`thisMonth`:return{label:m,start:p(o,c,1),end:p(o,c+1,0)};case`lastMonth`:return{label:m,start:p(o,c-1,1),end:p(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:m,start:p(t,e,1),end:p(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var I=class extends m{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!g(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`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.render()}disconnectedCallback(){this._dropPanel()}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 n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().endLabel}),empty:!1}}render(){this._dropPanel(),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=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),s=this.getAttribute(`aria-describedby`),c=p(`button`,{type:`button`,class:`form-control daterange-trigger${n}${a?``:` has-value`}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":o||null,"aria-describedby":s||null},p(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),y(`calendar`));this.replaceChildren(p(`div`,{class:`daterange`},c,p(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),h(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p(`span`,null,v((t+r)%7,`min`))),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n),s=[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:s,"data-iso":i,disabled:o},n)},d=[],f=i(e,n-1),m=t(f.y,f.m);for(let e=o-1;e>=0;e--)d.push(u(f.y,f.m,m-e,!0));for(let t=1;t<=s;t++)d.push(u(e,n,t,!1));let h=i(e,n+1),g=(7-(o+s)%7)%7;for(let e=1;e<=g;e++)d.push(u(h.y,h.m,e,!0));return p(`div`,{class:`daterange-cal`},p(`div`,{class:`datepicker-month-label`},`${_(n)} ${e}`),p(`div`,{class:`datepicker-weekdays`},...l),p(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=f;e!==null&&(u(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>p(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return p(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":N().quickRangesLabel},...n)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=[p(`div`,{class:`daterange-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":N().previousMonthLabel},y(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":N().nextMonthLabel},y(`chevron-right`))),p(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),p(`div`,{class:`datepicker-foot`},p(`span`,{class:`daterange-hint`,"data-range-hint":!0}),p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},N().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,n!==null),e.replaceChildren(...n?[n,p(`div`,{class:`wui-daterange-main`},...r)]:r),this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[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=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_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()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&b(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>S(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),x(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{b(t)},e.addEventListener(`click`,()=>{a()?this._close():g(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
|
|
1
|
+
import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-CeawKuZQ.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-Dh5iyZSR.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{n as u,r as d,t as f}from"./zone-BR02ZkHF.js";import{r as p}from"./dom-DMQu--xV.js";import{t as m}from"./elementBase-Cxeyx0tU.js";import{r as h,t as g}from"./fieldState-D-zQcXUS.js";import{_,b as v}from"./formatters-CXMylefd.js";import{t as y}from"./iconGlyphs.g-DRNDTVOs.js";import{a as b,l as x,s as S}from"./nativeOverlay-BHD2QV02.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=f,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(d(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d:u}=a,p=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),m=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:m,start:p(o,c,u),end:p(o,c,u)};case`yesterday`:return{label:m,start:p(o,c,u-1),end:p(o,c,u-1)};case`last7Days`:return{label:m,start:p(o,c,u-6),end:p(o,c,u)};case`last30Days`:return{label:m,start:p(o,c,u-29),end:p(o,c,u)};case`thisMonth`:return{label:m,start:p(o,c,1),end:p(o,c+1,0)};case`lastMonth`:return{label:m,start:p(o,c-1,1),end:p(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:m,start:p(t,e,1),end:p(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var I=class extends m{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!g(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`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.render()}disconnectedCallback(){this._dropPanel()}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 n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().endLabel}),empty:!1}}render(){this._dropPanel(),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=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),s=this.getAttribute(`aria-describedby`),c=p(`button`,{type:`button`,class:`form-control daterange-trigger${n}${a?``:` has-value`}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":o||null,"aria-describedby":s||null},p(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),y(`calendar`));this.replaceChildren(p(`div`,{class:`daterange`},c,p(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),h(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p(`span`,null,v((t+r)%7,`min`))),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n),s=[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `);return p(`button`,{type:`button`,class:s,"data-iso":i,disabled:o},n)},d=[],f=i(e,n-1),m=t(f.y,f.m);for(let e=o-1;e>=0;e--)d.push(u(f.y,f.m,m-e,!0));for(let t=1;t<=s;t++)d.push(u(e,n,t,!1));let h=i(e,n+1),g=(7-(o+s)%7)%7;for(let e=1;e<=g;e++)d.push(u(h.y,h.m,e,!0));return p(`div`,{class:`daterange-cal`},p(`div`,{class:`datepicker-month-label`},`${_(n)} ${e}`),p(`div`,{class:`datepicker-weekdays`},...l),p(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=f;e!==null&&(u(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>p(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return p(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":N().quickRangesLabel},...n)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=[p(`div`,{class:`daterange-head`},p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":N().previousMonthLabel},y(`chevron-left`)),p(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":N().nextMonthLabel},y(`chevron-right`))),p(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),p(`div`,{class:`datepicker-foot`},p(`span`,{class:`daterange-hint`,"data-range-hint":!0}),p(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},N().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,n!==null),e.replaceChildren(...n?[n,p(`div`,{class:`wui-daterange-main`},...r)]:r),this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[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=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_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()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&b(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>S(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),x(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{b(t)},e.addEventListener(`click`,()=>{a()?this._close():g(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./buttonClass-C8BRtTk8.js";import{t}from"./devWarn-DXdRWZs3.js";import{i as n,r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{a,c as o,d as s,f as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,s as g,t as _,u as v}from"./initials-DKg3IeUa.js";import{t as y}from"./avatarNode-BaEvz5Xr.js";import{t as b}from"./iconGlyphs.g-a9FtjPXh.js";import{n as x,r as S,t as C}from"./textStore-Dh5iyZSR.js";import{t as w}from"./hasOwn-CJsplJ62.js";import{a as T,l as E}from"./nativeOverlay-BHD2QV02.js";import{n as D,t as O}from"./rtl-g7G8Bsib.js";import{t as k}from"./gantt.g-CWvMXwBR.js";var A=`data-wui-gantt-pick`,j=e=>`${e}px`,M=(e,t,n)=>{let i=r(`div`,{class:`wui-gantt-table-cell`},n);return i.setAttribute(`role`,t),i.dataset.col=e,i};function N(e){let t=e.text,n=r(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let i=r(`div`);i.setAttribute(`role`,`rowgroup`);let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=j(e.headHeight),a.append(M(`name`,`columnheader`,t.tableName),M(`owner`,`columnheader`,t.detailsOwner),M(`start`,`columnheader`,t.tableStart),M(`end`,`columnheader`,t.tableEnd),M(`done`,`columnheader`,t.detailsDone)),i.append(a);let o=r(`div`);o.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let i=n.row;if(n.kind===`group`){let i=n.group;if(!i)continue;let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=i.name,a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=r(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});s.setAttribute(`role`,`rowheader`);let c=r(`button`,{class:`wui-gantt-group-toggle`});c.type=`button`,c.setAttribute(`aria-expanded`,String(!i.folded)),c.setAttribute(`aria-label`,C(i.folded?t.unfoldLabel:t.foldLabel,{group:i.name})),c.setAttribute(e.focusAttr,`group:${i.name}`);let l=b(i.folded?`chevron-right`:`chevron-down`,{size:16});c.replaceChildren(...l?[l]:[]),s.append(c,r(`span`,null,i.name),r(`span`,null,x(t,`groupSummary`,i.count,{percent:i.percent}))),a.append(s),o.append(a);continue}let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=i.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=i.key,a.dataset.wuiGanttPick=i.key,i.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=M(`name`,`rowheader`,i.name);s.title=i.name;let c=M(`owner`,`cell`,``);i.owner&&(c.title=i.owner,c.replaceChildren(...[y({initials:_(i.owner)},`avatar-xs`)].filter(e=>e!==null)),c.append(r(`span`,{class:`visually-hidden`},i.owner)));let l=M(`start`,`cell`,i.start===void 0?``:m(v(i.start))),u=M(`end`,`cell`,i.end===void 0?``:m(v(i.end))),d=M(`done`,`cell`,i.end===void 0?``:`${i.progress??0}%`);a.append(s,c,l,u,d),o.append(a)}let s=e.skeleton;for(let e=0;s&&e<s.rows;e+=1){let e=r(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=j(s.rowHeight);let t=r(`span`,{class:`wui-gantt-skeleton`});t.style.height=j(s.barHeight),e.append(t),o.append(e)}return n.append(i,o),n}var P=()=>S(`gantt`,k),F=`wui-gantt:zoom-change`,I=`wui-gantt:from-change`,L=`wui-gantt:fold-change`,R=`wui-gantt:select`,z=`wui-gantt:add-task`,B=`wui-gantt:retry`,V=`data-wui-gantt-focus`,H=`bar:`,U=`http://www.w3.org/2000/svg`,W=[`day`,`week`,`month`],G=3,K=16,q=300,J=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Y=0,X=e=>`${e}px`;function ee(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Z(e){let t=P();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Q=e=>e.progress??0,$=e=>e.status??`notStarted`,te=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),ne=class extends i{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=/* @__PURE__ */ new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),Y+=1,this.uid=`wui-gantt-${Y}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if(w(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=(T(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return t(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?v(e.from):null),n(!te(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(F,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:c(e,this._fromMs),this._draw())}_setFrom(e){this._emit(I,{from:o(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(L,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(R,{key:e}),this._focusAfter=`${H}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=W.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${V}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(V)??``,n);return}let r=t.closest(`[${A}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(H)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(z):e===`retry`?this._emit(B):n&&e===`nav:earlier`?this._setFrom(s(n.zoom,n.fromMs,-1,n.weeks)):n&&e===`nav:later`?this._setFrom(s(n.zoom,n.fromMs,1,n.weeks)):n&&e===`nav:today`?this._setFrom(n.weeks===void 0?l(n.zoom,n.todayMs):c(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${V}^="${H}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!J.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(V)?.startsWith(H))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),D(e.key,O(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n[n.length-1]);break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(V)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(V):null}_draw(){if(this._card&&=(T(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let r;try{r=this._compose()}catch(e){t(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),r=[this._stateBlock(`error`,P().errorText)]}if(this.replaceChildren(...r),this._card){let e=n(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),E(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let i=[...this.querySelectorAll(`[${V}]`)].find(t=>t.getAttribute(V)===e);i instanceof HTMLElement&&(e.startsWith(H)?this._focusBar(i):i.focus())}_compose(){let e=this._spec;if(!ee(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),f(e);let t=e.layout??`table`,n=u[t],i=P(),o=v(e.today??h()),s=this._zoom,m=s===`week`&&t===`lanes`?e.weeks:void 0,_=g(e.holidays),y=c(s,this._fromMs??(m===void 0?l(s,o):c(s,o))),b={layout:t,zoom:s,fromMs:y,todayMs:o,weeks:m,holidays:_};this._resolved=b,this._specRows=e.rows;let x=e.rows.some(e=>e.start!==void 0||e.bars!==void 0),S=(e.state??`ready`)===`ready`&&!x?`empty`:e.state??`ready`;this.dataset.state=S,this.dataset.zoom=s,this.dataset.layout=t,S===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let C=S===`ready`?d({...e,folded:[...this._folded],selected:this._selected},b):null,w=C?.axis??a(t,s,y,{weeks:m,holidays:_}),T=r(`div`,{class:`wui-gantt-lane`});T.style.width=X(w.width),C?this._fillLane(T,e,C):S===`loading`&&(T.style.height=X(G*n.rowH));let E=[];S===`loading`&&E.push(this._fillSkeleton(T,e,n)),S===`empty`&&E.push(this._emptyBlock(e)),S===`error`&&E.push(this._stateBlock(`error`,e.errorText||i.errorText));let D=this._head(w),O=r(`div`,{class:`wui-gantt-plot`});O.append(D,T);let k=r(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=N({title:e.title,rows:C?.rows??[],headHeight:2*p.tierH,selected:this._selected,text:i,focusAttr:V,skeleton:S===`loading`?{rows:G,rowHeight:n.rowH,barHeight:n.barH}:void 0});k.append(t,O)}else{let t=C?this._nameColumn(C,e):null;k.append(...t?[t]:[],O)}return[this._toolbar(e,S===`ready`),k,...E,this._legend(t)]}_nameColumn(e,t){let n=e.rows.filter(e=>e.kind===`lane`);if(e.count===null&&n.length===0)return null;let i=r(`div`,{class:`wui-gantt-names`});i.setAttribute(`aria-hidden`,`true`),i.style.paddingTop=X(2*p.tierH);let a=r(`div`,{class:`wui-gantt-names-rows`});a.style.height=X(e.height),e.count&&a.append(this._nameCell(e.count.top,e.count.height,t.countLabel||P().countLabel));for(let e of n)a.append(this._nameCell(e.top,e.height,e.row.name));return i.append(a),i}_nameCell(e,t,n){let i=r(`div`,{class:`wui-gantt-name`},n);return i.style.top=X(e),i.style.height=X(t),i}_countRow(e,t){let n=e.count,i=r(`div`,{class:`wui-gantt-counts`});return i.setAttribute(`role`,`listitem`),i.setAttribute(`aria-label`,t.countLabel||P().countLabel),i.style.top=X(n?.top??0),i.style.height=X(n?.height??0),i.style.width=X(e.axis.width),(n?.counts??[]).forEach((t,n)=>{if(t===0)return;let a=r(`span`,{class:`wui-gantt-count-cell`},String(t));a.style.left=X(e.axis.x(e.axis.startMs)+n*e.axis.ppd),a.style.width=X(e.axis.ppd),i.append(a)}),i}_drawLane(e,t,n){let i=P();e.setAttribute(`aria-label`,t.row.name);for(let a of t.clashes??[]){let o=r(`div`,{class:`wui-gantt-clash`},n.clashLabel||i.clashLabel);o.setAttribute(`aria-hidden`,`true`),o.style.left=X(a.x),o.style.top=X(t.top),o.style.width=X(a.w),o.style.height=X(t.height),e.append(o)}for(let n of t.bars??[]){if(n.hidden)continue;let t=r(`span`,{class:`wui-gantt-lane-bar`},n.label);t.dataset.tone=n.tone,n.half!==void 0&&(t.dataset.half=n.half),t.title=n.label,t.style.left=X(n.x),t.style.top=X(n.top),t.style.width=X(n.w),t.style.height=X(n.height),e.append(t)}}_toolbar(e,t){let n=r(`div`,{class:`wui-gantt-toolbar`});return t&&n.append(r(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=P(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,v(e.start??``)),a=Math.max(a,v(e.end??e.start??``));return[x(t,`summaryTasks`,n.length-r),x(t,`summaryMilestones`,r),C(t.summaryRange,{from:m(i),to:m(a)})].join(`, `)}_scale(){let e=P(),t=r(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(r(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of W){let i=r(`label`,{class:`segmented-option`}),a=r(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(V,`zoom:${e}`),i.append(a,n[e]),t.append(i)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=X(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let t=P(),n=r(`div`,{class:`wui-gantt-nav`}),i=(t,n,i)=>{let a=r(`button`,{class:e(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,n),a.setAttribute(V,t);let o=b(i,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=r(`button`,{class:e(`neutral`,`soft`,`sm`)},t.todayLabel);return a.type=`button`,a.setAttribute(V,`nav:today`),n.append(i(`nav:earlier`,t.earlierLabel,`chevron-left`),i(`nav:later`,t.laterLabel,`chevron-right`),a),n}_head(e){let t=r(`div`,{class:`wui-gantt-head`});t.style.width=X(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=r(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=r(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=X(t.x),e.style.width=X(t.w),t.sub&&e.append(r(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=P(),n=r(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let i=(e,t)=>{let i=r(`span`,null);i.setAttribute(`role`,`listitem`),i.append(e,t),n.append(i)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=r(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,i(t,Z(e))}let a=r(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,i(a,t.milestoneLabel),e===`table`){let e=r(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(t,n){let i=P(),a=r(`div`,{class:`wui-gantt-state`});if(t===`error`){a.setAttribute(`role`,`alert`),a.append(r(`p`,null,n));let t=r(`button`,{class:e(`neutral`,`soft`,`sm`)},i.retryLabel);t.type=`button`,t.setAttribute(V,`retry`),a.append(t)}else a.append(r(`p`,null,n));return a}_emptyBlock(t){let n=P(),i=r(`div`,{class:`wui-gantt-state`});if(i.append(r(`p`,{class:`fw-semibold`},n.emptyTitle),r(`p`,null,t.emptyText||n.emptyText)),t.addTask){let t=r(`button`,{class:e(`primary`,`solid`,`sm`)},n.addTaskLabel);t.type=`button`,t.setAttribute(V,`add`),i.append(t)}return i}_fillSkeleton(e,t,n){let i=r(`div`,{class:`visually-hidden`},t.loadingText||P().loadingText);i.setAttribute(`role`,`status`);for(let t=0;t<G;t+=1){let i=r(`div`,{class:`wui-gantt-skeleton`});i.style.top=X(t*n.rowH+n.barTop),i.style.left=X(40+t*60),i.style.width=X(240),i.style.height=X(n.barH),i.setAttribute(`aria-hidden`,`true`),e.append(i)}return i}_fillLane(e,t,n){let i=P(),{axis:a}=n,o=n.layout===`table`;e.style.height=X(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=r(`p`,{class:`visually-hidden`},o?i.helpTextTable:i.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,i,a)=>{let o=r(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=X(t),o.style.top=X(n),o.style.width=X(i),o.style.height=X(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=r(`div`,{class:`wui-gantt-today-flag rounded-pill`},i.todayLabel);e.style.left=X(n.today.x),l.push(e)}n.count&&l.push(this._countRow(n,t));let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let i=r(`div`,{class:`wui-gantt-item`});i.setAttribute(`role`,`listitem`),i.style.display=`contents`,e.kind===`group`?this._drawGroup(i,e,n):e.kind===`milestone`?this._drawMilestone(i,e,u,n):e.kind===`lane`?this._drawLane(i,e,t):this._drawBar(i,e,u,n),l.push(i)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${V}^="${H}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=P(),r=this._names(e,t);if(e.end===void 0){let t=m(v(e.start??``));return r?C(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=C(n.barLabel,{name:e.name,start:m(v(e.start??``)),end:m(v(e.end)),percent:Q(e),status:Z($(e)).toLowerCase()});return r?C(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,i){let a=r(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=$(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(V,`${H}${e.key}`),i?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,i){let a=r(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=X(t),a.style.top=X(n),a.style.height=X(i),a}_drawBar(e,t,n,i){let{row:a}=t,{geometry:o}=i,s=i.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=X(t.x),c.style.width=X(t.w),c.style.top=X(l),c.style.height=X(o.barH);let u=Q(a),d=r(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append(r(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+K,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=p.milestone/2,c=t.top+(a.rowH-p.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=X(t.x-s),l.style.top=X(c),l.style.width=X(p.milestone),l.style.height=X(p.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${m(v(i.start??``))}`,t.x+p.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=X(r.axis.width-(t.x-p.milestone))),e.append(u)}_drawGroup(e,t,n){let i=P(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=r(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=X(8),n.style.top=X(t.top+6);let o=r(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,C(a.folded?i.unfoldLabel:i.foldLabel,{group:a.name})),o.setAttribute(V,`group:${a.name}`);let s=b(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...s?[s]:[]),n.append(o,r(`span`,null,a.name),r(`span`,null,x(i,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=r(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=X(t.x),o.style.width=X(t.w),o.style.top=X(t.top+n.geometry.groupBarTop),o.style.height=X(p.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(U,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(U,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(U,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(t,n){let i=this._selected,a=i===null?void 0:t.rows.find(e=>e.row.key===i&&(e.kind===`bar`||e.kind===`milestone`)&&!e.hidden);if(!a)return null;let o=P(),{row:s}=a,c=r(`div`,{class:`wui-gantt-details`});c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,s.name),c.style.width=X(q);let l=r(`dl`),u=(e,t)=>{l.append(r(`dt`,null,e),r(`dd`,null,t))},d=m(v(s.start??``));s.owner&&u(o.detailsOwner,s.owner),u(o.detailsDates,s.end===void 0?d:C(o.detailsRange,{start:d,end:m(v(s.end))})),s.end!==void 0&&u(o.detailsDone,`${Q(s)}%, ${Z($(s))}`);let f=this._names(s,n);f&&u(o.detailsStartsAfter,f);let p=r(`button`,{class:e(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return p.type=`button`,p.setAttribute(V,`close`),c.append(r(`h3`,{class:`h6`},s.name),l,p),c}};export{ne as t};
|
|
1
|
+
import{n as e}from"./buttonClass-C8BRtTk8.js";import{t}from"./devWarn-DXdRWZs3.js";import{i as n,r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{a,c as o,d as s,f as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,s as g,t as _,u as v}from"./initials-DKg3IeUa.js";import{t as y}from"./avatarNode-BaEvz5Xr.js";import{t as b}from"./iconGlyphs.g-DRNDTVOs.js";import{n as x,r as S,t as C}from"./textStore-Dh5iyZSR.js";import{t as w}from"./hasOwn-CJsplJ62.js";import{a as T,l as E}from"./nativeOverlay-BHD2QV02.js";import{n as D,t as O}from"./rtl-g7G8Bsib.js";import{t as k}from"./gantt.g-CWvMXwBR.js";var A=`data-wui-gantt-pick`,j=e=>`${e}px`,M=(e,t,n)=>{let i=r(`div`,{class:`wui-gantt-table-cell`},n);return i.setAttribute(`role`,t),i.dataset.col=e,i};function N(e){let t=e.text,n=r(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let i=r(`div`);i.setAttribute(`role`,`rowgroup`);let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=j(e.headHeight),a.append(M(`name`,`columnheader`,t.tableName),M(`owner`,`columnheader`,t.detailsOwner),M(`start`,`columnheader`,t.tableStart),M(`end`,`columnheader`,t.tableEnd),M(`done`,`columnheader`,t.detailsDone)),i.append(a);let o=r(`div`);o.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let i=n.row;if(n.kind===`group`){let i=n.group;if(!i)continue;let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=i.name,a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=r(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});s.setAttribute(`role`,`rowheader`);let c=r(`button`,{class:`wui-gantt-group-toggle`});c.type=`button`,c.setAttribute(`aria-expanded`,String(!i.folded)),c.setAttribute(`aria-label`,C(i.folded?t.unfoldLabel:t.foldLabel,{group:i.name})),c.setAttribute(e.focusAttr,`group:${i.name}`);let l=b(i.folded?`chevron-right`:`chevron-down`,{size:16});c.replaceChildren(...l?[l]:[]),s.append(c,r(`span`,null,i.name),r(`span`,null,x(t,`groupSummary`,i.count,{percent:i.percent}))),a.append(s),o.append(a);continue}let a=r(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=i.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=i.key,a.dataset.wuiGanttPick=i.key,i.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=j(n.height);let s=M(`name`,`rowheader`,i.name);s.title=i.name;let c=M(`owner`,`cell`,``);i.owner&&(c.title=i.owner,c.replaceChildren(...[y({initials:_(i.owner)},`avatar-xs`)].filter(e=>e!==null)),c.append(r(`span`,{class:`visually-hidden`},i.owner)));let l=M(`start`,`cell`,i.start===void 0?``:m(v(i.start))),u=M(`end`,`cell`,i.end===void 0?``:m(v(i.end))),d=M(`done`,`cell`,i.end===void 0?``:`${i.progress??0}%`);a.append(s,c,l,u,d),o.append(a)}let s=e.skeleton;for(let e=0;s&&e<s.rows;e+=1){let e=r(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=j(s.rowHeight);let t=r(`span`,{class:`wui-gantt-skeleton`});t.style.height=j(s.barHeight),e.append(t),o.append(e)}return n.append(i,o),n}var P=()=>S(`gantt`,k),F=`wui-gantt:zoom-change`,I=`wui-gantt:from-change`,L=`wui-gantt:fold-change`,R=`wui-gantt:select`,z=`wui-gantt:add-task`,B=`wui-gantt:retry`,V=`data-wui-gantt-focus`,H=`bar:`,U=`http://www.w3.org/2000/svg`,W=[`day`,`week`,`month`],G=3,K=16,q=300,J=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Y=0,X=e=>`${e}px`;function ee(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Z(e){let t=P();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Q=e=>e.progress??0,$=e=>e.status??`notStarted`,te=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),ne=class extends i{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=/* @__PURE__ */ new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),Y+=1,this.uid=`wui-gantt-${Y}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if(w(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=(T(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return t(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?v(e.from):null),n(!te(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(F,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:c(e,this._fromMs),this._draw())}_setFrom(e){this._emit(I,{from:o(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(L,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(R,{key:e}),this._focusAfter=`${H}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=W.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${V}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(V)??``,n);return}let r=t.closest(`[${A}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(H)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(z):e===`retry`?this._emit(B):n&&e===`nav:earlier`?this._setFrom(s(n.zoom,n.fromMs,-1,n.weeks)):n&&e===`nav:later`?this._setFrom(s(n.zoom,n.fromMs,1,n.weeks)):n&&e===`nav:today`?this._setFrom(n.weeks===void 0?l(n.zoom,n.todayMs):c(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${V}^="${H}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!J.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(V)?.startsWith(H))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),D(e.key,O(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n[n.length-1]);break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(V)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(V):null}_draw(){if(this._card&&=(T(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let r;try{r=this._compose()}catch(e){t(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),r=[this._stateBlock(`error`,P().errorText)]}if(this.replaceChildren(...r),this._card){let e=n(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),E(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let i=[...this.querySelectorAll(`[${V}]`)].find(t=>t.getAttribute(V)===e);i instanceof HTMLElement&&(e.startsWith(H)?this._focusBar(i):i.focus())}_compose(){let e=this._spec;if(!ee(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),f(e);let t=e.layout??`table`,n=u[t],i=P(),o=v(e.today??h()),s=this._zoom,m=s===`week`&&t===`lanes`?e.weeks:void 0,_=g(e.holidays),y=c(s,this._fromMs??(m===void 0?l(s,o):c(s,o))),b={layout:t,zoom:s,fromMs:y,todayMs:o,weeks:m,holidays:_};this._resolved=b,this._specRows=e.rows;let x=e.rows.some(e=>e.start!==void 0||e.bars!==void 0),S=(e.state??`ready`)===`ready`&&!x?`empty`:e.state??`ready`;this.dataset.state=S,this.dataset.zoom=s,this.dataset.layout=t,S===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let C=S===`ready`?d({...e,folded:[...this._folded],selected:this._selected},b):null,w=C?.axis??a(t,s,y,{weeks:m,holidays:_}),T=r(`div`,{class:`wui-gantt-lane`});T.style.width=X(w.width),C?this._fillLane(T,e,C):S===`loading`&&(T.style.height=X(G*n.rowH));let E=[];S===`loading`&&E.push(this._fillSkeleton(T,e,n)),S===`empty`&&E.push(this._emptyBlock(e)),S===`error`&&E.push(this._stateBlock(`error`,e.errorText||i.errorText));let D=this._head(w),O=r(`div`,{class:`wui-gantt-plot`});O.append(D,T);let k=r(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=N({title:e.title,rows:C?.rows??[],headHeight:2*p.tierH,selected:this._selected,text:i,focusAttr:V,skeleton:S===`loading`?{rows:G,rowHeight:n.rowH,barHeight:n.barH}:void 0});k.append(t,O)}else{let t=C?this._nameColumn(C,e):null;k.append(...t?[t]:[],O)}return[this._toolbar(e,S===`ready`),k,...E,this._legend(t)]}_nameColumn(e,t){let n=e.rows.filter(e=>e.kind===`lane`);if(e.count===null&&n.length===0)return null;let i=r(`div`,{class:`wui-gantt-names`});i.setAttribute(`aria-hidden`,`true`),i.style.paddingTop=X(2*p.tierH);let a=r(`div`,{class:`wui-gantt-names-rows`});a.style.height=X(e.height),e.count&&a.append(this._nameCell(e.count.top,e.count.height,t.countLabel||P().countLabel));for(let e of n)a.append(this._nameCell(e.top,e.height,e.row.name));return i.append(a),i}_nameCell(e,t,n){let i=r(`div`,{class:`wui-gantt-name`},n);return i.style.top=X(e),i.style.height=X(t),i}_countRow(e,t){let n=e.count,i=r(`div`,{class:`wui-gantt-counts`});return i.setAttribute(`role`,`listitem`),i.setAttribute(`aria-label`,t.countLabel||P().countLabel),i.style.top=X(n?.top??0),i.style.height=X(n?.height??0),i.style.width=X(e.axis.width),(n?.counts??[]).forEach((t,n)=>{if(t===0)return;let a=r(`span`,{class:`wui-gantt-count-cell`},String(t));a.style.left=X(e.axis.x(e.axis.startMs)+n*e.axis.ppd),a.style.width=X(e.axis.ppd),i.append(a)}),i}_drawLane(e,t,n){let i=P();e.setAttribute(`aria-label`,t.row.name);for(let a of t.clashes??[]){let o=r(`div`,{class:`wui-gantt-clash`},n.clashLabel||i.clashLabel);o.setAttribute(`aria-hidden`,`true`),o.style.left=X(a.x),o.style.top=X(t.top),o.style.width=X(a.w),o.style.height=X(t.height),e.append(o)}for(let n of t.bars??[]){if(n.hidden)continue;let t=r(`span`,{class:`wui-gantt-lane-bar`},n.label);t.dataset.tone=n.tone,n.half!==void 0&&(t.dataset.half=n.half),t.title=n.label,t.style.left=X(n.x),t.style.top=X(n.top),t.style.width=X(n.w),t.style.height=X(n.height),e.append(t)}}_toolbar(e,t){let n=r(`div`,{class:`wui-gantt-toolbar`});return t&&n.append(r(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=P(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,v(e.start??``)),a=Math.max(a,v(e.end??e.start??``));return[x(t,`summaryTasks`,n.length-r),x(t,`summaryMilestones`,r),C(t.summaryRange,{from:m(i),to:m(a)})].join(`, `)}_scale(){let e=P(),t=r(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(r(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of W){let i=r(`label`,{class:`segmented-option`}),a=r(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(V,`zoom:${e}`),i.append(a,n[e]),t.append(i)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=X(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let t=P(),n=r(`div`,{class:`wui-gantt-nav`}),i=(t,n,i)=>{let a=r(`button`,{class:e(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,n),a.setAttribute(V,t);let o=b(i,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=r(`button`,{class:e(`neutral`,`soft`,`sm`)},t.todayLabel);return a.type=`button`,a.setAttribute(V,`nav:today`),n.append(i(`nav:earlier`,t.earlierLabel,`chevron-left`),i(`nav:later`,t.laterLabel,`chevron-right`),a),n}_head(e){let t=r(`div`,{class:`wui-gantt-head`});t.style.width=X(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=r(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=r(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=X(t.x),e.style.width=X(t.w),t.sub&&e.append(r(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=P(),n=r(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let i=(e,t)=>{let i=r(`span`,null);i.setAttribute(`role`,`listitem`),i.append(e,t),n.append(i)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=r(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,i(t,Z(e))}let a=r(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,i(a,t.milestoneLabel),e===`table`){let e=r(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(t,n){let i=P(),a=r(`div`,{class:`wui-gantt-state`});if(t===`error`){a.setAttribute(`role`,`alert`),a.append(r(`p`,null,n));let t=r(`button`,{class:e(`neutral`,`soft`,`sm`)},i.retryLabel);t.type=`button`,t.setAttribute(V,`retry`),a.append(t)}else a.append(r(`p`,null,n));return a}_emptyBlock(t){let n=P(),i=r(`div`,{class:`wui-gantt-state`});if(i.append(r(`p`,{class:`fw-semibold`},n.emptyTitle),r(`p`,null,t.emptyText||n.emptyText)),t.addTask){let t=r(`button`,{class:e(`primary`,`solid`,`sm`)},n.addTaskLabel);t.type=`button`,t.setAttribute(V,`add`),i.append(t)}return i}_fillSkeleton(e,t,n){let i=r(`div`,{class:`visually-hidden`},t.loadingText||P().loadingText);i.setAttribute(`role`,`status`);for(let t=0;t<G;t+=1){let i=r(`div`,{class:`wui-gantt-skeleton`});i.style.top=X(t*n.rowH+n.barTop),i.style.left=X(40+t*60),i.style.width=X(240),i.style.height=X(n.barH),i.setAttribute(`aria-hidden`,`true`),e.append(i)}return i}_fillLane(e,t,n){let i=P(),{axis:a}=n,o=n.layout===`table`;e.style.height=X(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=r(`p`,{class:`visually-hidden`},o?i.helpTextTable:i.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,i,a)=>{let o=r(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=X(t),o.style.top=X(n),o.style.width=X(i),o.style.height=X(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=r(`div`,{class:`wui-gantt-today-flag rounded-pill`},i.todayLabel);e.style.left=X(n.today.x),l.push(e)}n.count&&l.push(this._countRow(n,t));let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let i=r(`div`,{class:`wui-gantt-item`});i.setAttribute(`role`,`listitem`),i.style.display=`contents`,e.kind===`group`?this._drawGroup(i,e,n):e.kind===`milestone`?this._drawMilestone(i,e,u,n):e.kind===`lane`?this._drawLane(i,e,t):this._drawBar(i,e,u,n),l.push(i)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${V}^="${H}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=P(),r=this._names(e,t);if(e.end===void 0){let t=m(v(e.start??``));return r?C(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=C(n.barLabel,{name:e.name,start:m(v(e.start??``)),end:m(v(e.end)),percent:Q(e),status:Z($(e)).toLowerCase()});return r?C(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,i){let a=r(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=$(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(V,`${H}${e.key}`),i?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,i){let a=r(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=X(t),a.style.top=X(n),a.style.height=X(i),a}_drawBar(e,t,n,i){let{row:a}=t,{geometry:o}=i,s=i.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=X(t.x),c.style.width=X(t.w),c.style.top=X(l),c.style.height=X(o.barH);let u=Q(a),d=r(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append(r(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+K,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=p.milestone/2,c=t.top+(a.rowH-p.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=X(t.x-s),l.style.top=X(c),l.style.width=X(p.milestone),l.style.height=X(p.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${m(v(i.start??``))}`,t.x+p.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=X(r.axis.width-(t.x-p.milestone))),e.append(u)}_drawGroup(e,t,n){let i=P(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=r(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=X(8),n.style.top=X(t.top+6);let o=r(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,C(a.folded?i.unfoldLabel:i.foldLabel,{group:a.name})),o.setAttribute(V,`group:${a.name}`);let s=b(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...s?[s]:[]),n.append(o,r(`span`,null,a.name),r(`span`,null,x(i,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=r(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=X(t.x),o.style.width=X(t.w),o.style.top=X(t.top+n.geometry.groupBarTop),o.style.height=X(p.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(U,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(U,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(U,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(t,n){let i=this._selected,a=i===null?void 0:t.rows.find(e=>e.row.key===i&&(e.kind===`bar`||e.kind===`milestone`)&&!e.hidden);if(!a)return null;let o=P(),{row:s}=a,c=r(`div`,{class:`wui-gantt-details`});c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,s.name),c.style.width=X(q);let l=r(`dl`),u=(e,t)=>{l.append(r(`dt`,null,e),r(`dd`,null,t))},d=m(v(s.start??``));s.owner&&u(o.detailsOwner,s.owner),u(o.detailsDates,s.end===void 0?d:C(o.detailsRange,{start:d,end:m(v(s.end))})),s.end!==void 0&&u(o.detailsDone,`${Q(s)}%, ${Z($(s))}`);let f=this._names(s,n);f&&u(o.detailsStartsAfter,f);let p=r(`button`,{class:e(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return p.type=`button`,p.setAttribute(V,`close`),c.append(r(`h3`,{class:`h6`},s.name),l,p),c}};export{ne as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n}from"./svgNodes-CaPMDvv7.js";import{r,t as i}from"./textStore-Dh5iyZSR.js";import{t as a}from"./imageCrop.g-BnbAeH2Q.js";var o=4096,s=[.92,.8,.65,.5],c=.8,l=8;function u(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 d(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 f(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 p(e,t,n,r,i){return f({...e,x:e.x+t,y:e.y+n},r,i)}function m(e,t){return Math.min(32,e,t)}function h(e,t){return t.w/e.w}function g(e,t){return Math.max(4,h(e,t))}function _(e,t,n,r,i){let a=Math.min(Math.max(n,1),g(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(m(r,i),m(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),u=l*o,d=e.x+e.w/2,p=e.y+e.h/2;return f({x:d-l/2,y:p-u/2,w:l,h:u},r,i)}var v=[`nw`,`ne`,`sw`,`se`];function y(e,t,n,r,i,a){let o=m(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),f=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),f=c?Math.min(f,u-o):Math.max(f,u+o),{x:Math.min(d,l),y:Math.min(f,u),w:Math.abs(d-l),h:Math.abs(f-u)}}function b(e,t=o){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 x(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 S(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function C(e,t,n){return f({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function w(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var T=[`image/png`,`image/jpeg`,`image/webp`],E={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function D(e){let t=String(e||``).toLowerCase();return T.includes(t)?t:`image/png`}function O(e,t){let n=String(e||`image`),r=E[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function k(e,{width:t,height:n,type:r,maxBytes:i}){let a=r,o=t,u=n,d=null;for(let t=0;t<=l;t++){let n=a===`image/png`?[void 0]:t===0?s:[s[1]];for(let t of n){if(d=await e(o,u,a,t),!d||(d.type&&d.type!==a&&(a=d.type),!(i>0)||d.size<=i))return d;if(a===`image/png`)break}o=Math.max(1,Math.round(o*c)),u=Math.max(1,Math.round(u*c))}return d}var A=.05,j=.2,M={w:320,h:240},N={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},P=()=>r(`imageCrop`,a),F=e=>{let t=N[e];return t?P()[t]:e};function I(e,t=!1){return n({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,...t?{"stroke-linejoin":`round`}:{},"aria-hidden":`true`},e.map(e=>[`path`,{d:e}]))}var L=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function R(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function z(e,t){if(e===null)throw Error(`${t} missing`);return e}function B(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function V(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var H=class extends t{_rect;_base;_natural;_source;_rotation;_drag;_pointers;_pinch;_previewPending;_resizeObserver;_rendered;_stageEl;_imgEl;_frameEl;_sliderEl;_toolsEl;_previewBoxEl;_liveEl;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=/* @__PURE__ */ new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return z(this._stageEl,`stage`)}get _img(){return z(this._imgEl,`image`)}get _frame(){return z(this._frameEl,`frame`)}get _slider(){return z(this._sliderEl,`zoom slider`)}get _tools(){return z(this._toolsEl,`tools`)}get _previewBox(){return z(this._previewBoxEl,`previews`)}get _live(){return z(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return u(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?h(this._rect,z(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=z(this._natural,`natural size`);this._rect=_(this._rect,z(this._base,`base frame`),Number(e)||1,t.w,t.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.replaceChildren(e(`div`,null,e(`div`,{class:`wui-crop-stage`,tabindex:`0`,role:`group`,"aria-label":P().cropAreaText},e(`img`,{class:`wui-crop-img`,alt:``,draggable:`false`}),e(`div`,{class:`wui-crop-frame`})),e(`div`,{class:`wui-crop-controls`},e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`out`,"aria-label":P().zoomOutLabel},I([`M5 12h14`])),e(`input`,{type:`range`,class:`form-range wui-crop-zoom`,min:1,max:4,step:`0.01`,value:1,"aria-label":P().zoomLabel}),e(`button`,{type:`button`,class:`wui-crop-zoombtn`,"data-zoom":`in`,"aria-label":P().zoomInLabel},I([`M5 12h14M12 5v14`]))),e(`div`,{class:`wui-crop-tools`,hidden:!0},e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`rotate`,"aria-label":P().rotateClockwiseLabel},I([`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,`M21 3v5h-5`],!0),e(`span`,null,P().rotateLabel)),e(`button`,{type:`button`,class:`wui-crop-toolbtn`,"data-crop-action":`reset`,"aria-label":P().resetCropLabel},I([`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`],!0),e(`span`,null,P().resetLabel))),e(`div`,{class:`wui-crop-previews`,"aria-hidden":`true`,hidden:!0}),e(`div`,{class:`visually-hidden`,"data-wui-crop-live":!0,"aria-live":`polite`}))),this._stageEl=B(this,`.wui-crop-stage`,HTMLElement),this._imgEl=B(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=B(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=B(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=B(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=B(this,`.wui-crop-previews`,HTMLElement),this._liveEl=B(this,`[data-wui-crop-live]`,HTMLElement),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 v){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`,i(P().resizeCornerText,{corner:F(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=w(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=d(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=z(this._natural,`natural size`),t=this._stage.clientWidth||M.w,n=this._stage.clientHeight||M.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_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=z(this._base,`base frame`),o=h(i,a),s=g(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*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=z(this._natural,`natural size`),t=f(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.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=z(this._source,`source size`),a=z(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.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=z(this._rect,`frame`),t=this._rotation?i(P().turnedText,{rotation:this._rotation}):``,n=i(P().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(h(e,z(this._base,`base frame`))*100),turned:t});this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=z(this._natural,`natural size`),t=C(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=z(this._source,`source size`);this._natural=S(n.w,n.h,this._rotation),this._base=d(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,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]=R(this._pointers);this._drag=null,this._pinch={distance:L(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=V(t.target);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]=R(this._pointers),r=this._pinch.zoom*L(e,n)/this._pinch.distance,i=z(this._natural,`natural size`);this._rect=_(z(this._rect,`frame`),z(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=z(this._natural,`natural size`);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=y(z(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=p(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`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}B(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),B(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=z(this._natural,`natural size`);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?j:A,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=V(e.target)?.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=y(e,o,s,c,t,n)}else this._rect=p(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=D(e),i=z(this._natural,`natural size`),a=f(this._rect,i.w,i.h),{width:o,height:s}=n>0?x(a,n):b(a);return k((e,t,n,r)=>new Promise(i=>{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,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,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],O(e,i.type),{type:i.type}):null}};export{H as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{f as n}from"./formatters-CXMylefd.js";import{t as r}from"./iconGlyphs.g-
|
|
1
|
+
import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{f as n}from"./formatters-CXMylefd.js";import{t as r}from"./iconGlyphs.g-DRNDTVOs.js";import{u as i}from"./nativeOverlay-BHD2QV02.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";import{r as s,t as c}from"./textStore-Dh5iyZSR.js";import{t as l}from"./lightbox.g-DDrycPou.js";var u=`a.wui-lightbox-item`,d=1,f=4,p=.5,m=2,h=50,g=6,_=300,v=300;function y(e){return Number.isFinite(e)?Math.min(f,Math.max(d,e)):d}function b(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 x(e,t){return Math.abs(e)<h||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function S(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var C=()=>s(`lightbox`,l);function w(t,n,i){let a=e(`button`,{class:`u-action wui-lightbox-btn ${i}`,type:`button`,"aria-label":n,title:n});a.style.setProperty(`--wui-action-size`,`40px`);let o=r(t,{size:20});return a.replaceChildren(...o?[o]:[]),a}var T=class extends t{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=d,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(u):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||C().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${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(u)].filter(e=>e instanceof HTMLAnchorElement)}_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||S(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}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._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let t=e(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),n=e(`div`,{class:`wui-lightbox-bar`}),a=e(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),o=e(`div`,{class:`wui-lightbox-tools`}),s=w(`zoom-out`,C().zoomOutLabel,`wui-lightbox-zoom-out`),c=w(`zoom-in`,C().zoomInLabel,`wui-lightbox-zoom-in`),l=e(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":C().downloadLabel,title:C().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=r(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=w(`x`,C().closeLabel,`wui-lightbox-close`);o.append(s,c,l,d),n.append(a,o);let f=e(`div`,{class:`wui-lightbox-stage`}),m=w(`chevron-left`,C().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),h=w(`chevron-right`,C().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),g=e(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),_=e(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(g,_,m,h);let v=e(`p`,{class:`wui-lightbox-caption`});t.append(n,f,v);let y={root:t,count:a,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:m,next:h,image:g,status:_,caption:v};this._ui=y,d.addEventListener(`click`,()=>this.close()),m.addEventListener(`click`,()=>this.step(-1)),h.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-p)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+p)),t.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),g.addEventListener(`load`,()=>{this._ui===y&&(_.textContent=``,f.removeAttribute(`aria-busy`),g.hidden=!1,this._applyTransform())}),g.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),g.hidden=!0,_.textContent=C().imageFailedMessage)}),this.append(t),this._release=i(t,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}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 r=this._view,i=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[i];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=i!==this._index||!r.image.getAttribute(`src`);if(this._index=i,this._zoom=d,this._pan={x:0,y:0},r.count.textContent=c(C().countText,{position:n(i+1,{decimals:0}),total:n(t.length,{decimals:0})}),r.caption.textContent=a.caption,r.caption.hidden=!a.caption,r.download.href=a.src,r.download.setAttribute(`download`,a.name),r.prev.hidden=r.next.hidden=t.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=a.alt||a.caption,r.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(i+1)%t.length],n=t[(i-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:i}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=d,e.zoomIn.disabled=this._zoom>=f;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=y(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return b(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>d)}_onKeyDown(e){let t=a(e.key,o(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`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+p)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-p)):e.key===`0`&&(e.preventDefault(),this._setZoom(d))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.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===n.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=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>g&&(t.moved=!0),this._zoom>d&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.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===d&&this.step(x(r,i)):e.timeStamp-n.startTime>_||(n.onImage?e.timeStamp-this._lastTap<v?(this._lastTap=-1/0,this._setZoom(this._zoom>d?d:m)):this._lastTap=e.timeStamp:this.close())}};export{T as t};
|