UNPKG

@revolist/revogrid-column-date

Version:

Date format for RevoGrid system based on duetds-date-picker

1,582 lines 79 kB
import './main.css'; const svg = `<svg aria-hidden="true" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg"> <g fill="none" fill-rule="evenodd" transform="translate(2 2)"> <path d="m2.5.5h12c1.1045695 0 2 .8954305 2 2v12c0 1.1045695-.8954305 2-2 2h-12c-1.1045695 0-2-.8954305-2-2v-12c0-1.1045695.8954305-2 2-2z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path> <path d="m.5 4.5h16" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path> <g fill="currentColor"> <circle cx="8.5" cy="8.5" r="1"></circle> <circle cx="4.5" cy="8.5" r="1"></circle> <circle cx="12.5" cy="8.5" r="1"></circle> <circle cx="8.5" cy="12.5" r="1"></circle> <circle cx="4.5" cy="12.5" r="1"></circle> <circle cx="12.5" cy="12.5" r="1"></circle> </g> </g> </svg> `; const ColumnRenderer = (h2, { value }) => { return [ h2("div", { class: { "cell-value-wrapper": true } }, value == null ? void 0 : value.toString()), h2("button", { class: { calendar: true }, innerHTML: svg, onClick: (e) => { const ev = new MouseEvent("dblclick", { bubbles: true, cancelable: true, view: window }); e.target.dispatchEvent(ev); } }) ]; }; function updatePosition(cellPosition, inputElement, appendTo, calendar) { inputElement.style.transform = `translate(${cellPosition.left}px, ${cellPosition.top}px)`; inputElement.style.width = `${cellPosition.width}px`; inputElement.style.height = `${cellPosition.height}px`; appendTo.append(inputElement); calendar == null ? void 0 : calendar.show(); } class ColumnEditor { constructor(data, saveCallback) { this.data = data; this.saveCallback = saveCallback; } componentDidRender() { if (!this.element || !this.revoFloat) { return; } const appendTo = !this.data.column.appendTo || this.data.column.appendTo == "body" ? document.body : this.data.column.appendTo; updatePosition( this.element.getBoundingClientRect(), this.revoFloat, appendTo, this.calendar ); } isDate(value) { return Object.prototype.toString.call(value) === "[object Date]" && !isNaN(value.getTime()); } getValue() { var _a; return (_a = this.calendar) == null ? void 0 : _a.value; } disconnectedCallback() { var _a, _b; (_a = this.calendar) == null ? void 0 : _a.hide(); (_b = this.revoFloat) == null ? void 0 : _b.remove(); this.calendar = null; this.revoFloat = null; } render(h2) { var _a; let val = ""; if (this.editCell) { const model = this.editCell.model || {}; val = model[(_a = this.editCell) == null ? void 0 : _a.prop] || ""; } if (this.isDate(val)) { val = val.toISOString().split("T")[0]; } return h2("div", { class: "revo-holder" }, [ h2( "div", { class: "revo-float", onMouseUp: (e) => { e.stopPropagation(); }, ref: (e) => this.revoFloat = e }, [ h2("duet-date-picker", { ...this.data.column, ref: (e) => this.calendar = e, value: val, onDuetChange: ({ detail: { value, valueAsDate } }) => this.saveCallback(this.data.column.valueAsDate ? valueAsDate : value), onDuetOpen: () => { var _a2, _b; const { bottom } = ((_a2 = this.revoFloat) == null ? void 0 : _a2.getBoundingClientRect()) || {}; const { clientHeight } = document.body; const position = bottom + 300 > clientHeight ? "top" : "bottom"; (_b = this.calendar) == null ? void 0 : _b.setAttribute("position", position); } }) ] ) ]); } } const BUILD = { allRenderFn: false, cmpDidLoad: true, cmpDidUnload: false, cmpDidUpdate: true, cmpDidRender: true, cmpWillLoad: true, cmpWillUpdate: true, cmpWillRender: true, connectedCallback: true, disconnectedCallback: true, element: true, event: true, hasRenderFn: true, lifecycle: true, hostListener: true, hostListenerTargetWindow: true, hostListenerTargetDocument: true, hostListenerTargetBody: true, hostListenerTargetParent: false, hostListenerTarget: true, member: true, method: true, mode: true, observeAttribute: true, prop: true, propMutable: true, reflect: true, scoped: true, shadowDom: true, slot: true, cssAnnotations: true, state: true, style: true, svg: true, updatable: true, vdomAttribute: true, vdomXlink: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomRef: true, vdomPropOrAttr: true, vdomRender: true, vdomStyle: true, vdomText: true, watchCallback: true, taskQueue: true, hotModuleReplacement: false, isDebug: false, isDev: false, isTesting: false, hydrateServerSide: false, hydrateClientSide: false, lifecycleDOMEvents: false, lazyLoad: false, profile: false, slotRelocation: true, appendChildSlotFix: false, cloneNodeFix: false, hydratedAttribute: false, hydratedClass: true, safari10: false, scriptDataOpts: false, scopedSlotTextContentFix: false, shadowDomShim: false, slotChildNodesFix: false, invisiblePrehydration: true, propBoolean: true, propNumber: true, propString: true, cssVarShim: false, constructableCSS: true, cmpShouldUpdate: true, devTools: false, dynamicImportShim: false, shadowDelegatesFocus: true, initializeNextTick: false, asyncLoading: false, asyncQueue: false, transformTagName: false, attachStyles: true }; let scopeId; let contentRef; let hostTagName; let useNativeShadowDom = false; let checkSlotFallbackVisibility = false; let checkSlotRelocate = false; let isSvgMode = false; let renderingRef = null; let queuePending = false; const createTime = (fnName, tagName = "") => { { return () => { return; }; } }; const XLINK_NS = "http://www.w3.org/1999/xlink"; const EMPTY_OBJ = {}; const SVG_NS = "http://www.w3.org/2000/svg"; const HTML_NS = "http://www.w3.org/1999/xhtml"; const isDef = (v) => v != null; const isComplexType = (o) => { o = typeof o; return o === "object" || o === "function"; }; function queryNonceMetaTagContent(doc2) { var _a, _b, _c; return (_c = (_b = (_a = doc2.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute("content")) !== null && _c !== void 0 ? _c : void 0; } const h = (nodeName, vnodeData, ...children) => { let child = null; let key = null; let slotName = null; let simple = false; let lastSimple = false; const vNodeChildren = []; const walk = (c) => { for (let i = 0; i < c.length; i++) { child = c[i]; if (Array.isArray(child)) { walk(child); } else if (child != null && typeof child !== "boolean") { if (simple = typeof nodeName !== "function" && !isComplexType(child)) { child = String(child); } if (simple && lastSimple) { vNodeChildren[vNodeChildren.length - 1].$text$ += child; } else { vNodeChildren.push(simple ? newVNode(null, child) : child); } lastSimple = simple; } } }; walk(children); if (vnodeData) { if (vnodeData.key) { key = vnodeData.key; } if (vnodeData.name) { slotName = vnodeData.name; } { const classData = vnodeData.className || vnodeData.class; if (classData) { vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" "); } } } if (typeof nodeName === "function") { return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils); } const vnode = newVNode(nodeName, null); vnode.$attrs$ = vnodeData; if (vNodeChildren.length > 0) { vnode.$children$ = vNodeChildren; } { vnode.$key$ = key; } { vnode.$name$ = slotName; } return vnode; }; const newVNode = (tag, text) => { const vnode = { $flags$: 0, $tag$: tag, $text$: text, $elm$: null, $children$: null }; { vnode.$attrs$ = null; } { vnode.$key$ = null; } { vnode.$name$ = null; } return vnode; }; const Host = {}; const isHost = (node) => node && node.$tag$ === Host; const vdomFnUtils = { forEach: (children, cb) => children.map(convertToPublic).forEach(cb), map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate) }; const convertToPublic = (node) => ({ vattrs: node.$attrs$, vchildren: node.$children$, vkey: node.$key$, vname: node.$name$, vtag: node.$tag$, vtext: node.$text$ }); const convertToPrivate = (node) => { if (typeof node.vtag === "function") { const vnodeData = Object.assign({}, node.vattrs); if (node.vkey) { vnodeData.key = node.vkey; } if (node.vname) { vnodeData.name = node.vname; } return h(node.vtag, vnodeData, ...node.vchildren || []); } const vnode = newVNode(node.vtag, node.vtext); vnode.$attrs$ = node.vattrs; vnode.$children$ = node.vchildren; vnode.$key$ = node.vkey; vnode.$name$ = node.vname; return vnode; }; const computeMode = (elm) => modeResolutionChain.map((h2) => h2(elm)).find((m) => !!m); const parsePropertyValue = (propValue, propType) => { if (propValue != null && !isComplexType(propValue)) { if (propType & 4) { return propValue === "false" ? false : propValue === "" || !!propValue; } if (propType & 2) { return parseFloat(propValue); } if (propType & 1) { return String(propValue); } return propValue; } return propValue; }; const getElement = (ref) => ref; const createEvent = (ref, name, flags) => { const elm = getElement(ref); return { emit: (detail) => { return emitEvent(elm, name, { bubbles: !!(flags & 4), composed: !!(flags & 2), cancelable: !!(flags & 1), detail }); } }; }; const emitEvent = (elm, name, opts) => { const ev = plt.ce(name, opts); elm.dispatchEvent(ev); return ev; }; const rootAppliedStyles = /* @__PURE__ */ new WeakMap(); const registerStyle = (scopeId2, cssText, allowCS) => { let style = styles.get(scopeId2); if (supportsConstructableStylesheets && allowCS) { style = style || new CSSStyleSheet(); if (typeof style === "string") { style = cssText; } else { style.replaceSync(cssText); } } else { style = cssText; } styles.set(scopeId2, style); }; const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => { var _a; let scopeId2 = getScopeId(cmpMeta, mode); const style = styles.get(scopeId2); styleContainerNode = styleContainerNode.nodeType === 11 ? styleContainerNode : doc; if (style) { if (typeof style === "string") { styleContainerNode = styleContainerNode.head || styleContainerNode; let appliedStyles = rootAppliedStyles.get(styleContainerNode); let styleElm; if (!appliedStyles) { rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set()); } if (!appliedStyles.has(scopeId2)) { { { styleElm = doc.createElement("style"); styleElm.innerHTML = style; } const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc); if (nonce != null) { styleElm.setAttribute("nonce", nonce); } styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector("link")); } if (appliedStyles) { appliedStyles.add(scopeId2); } } } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) { styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style]; } } return scopeId2; }; const attachStyles = (hostRef) => { const cmpMeta = hostRef.$cmpMeta$; const elm = hostRef.$hostElement$; const flags = cmpMeta.$flags$; const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$); const scopeId2 = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$); if (flags & 10) { elm["s-sc"] = scopeId2; elm.classList.add(scopeId2 + "-h"); if (flags & 2) { elm.classList.add(scopeId2 + "-s"); } } endAttachStyles(); }; const getScopeId = (cmp, mode) => "sc-" + (mode && cmp.$flags$ & 32 ? cmp.$tagName$ + "-" + mode : cmp.$tagName$); const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => { if (oldValue !== newValue) { let isProp = isMemberInElement(elm, memberName); let ln = memberName.toLowerCase(); if (memberName === "class") { const classList = elm.classList; const oldClasses = parseClassList(oldValue); const newClasses = parseClassList(newValue); classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c))); classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c))); } else if (memberName === "style") { { for (const prop in oldValue) { if (!newValue || newValue[prop] == null) { if (prop.includes("-")) { elm.style.removeProperty(prop); } else { elm.style[prop] = ""; } } } } for (const prop in newValue) { if (!oldValue || newValue[prop] !== oldValue[prop]) { if (prop.includes("-")) { elm.style.setProperty(prop, newValue[prop]); } else { elm.style[prop] = newValue[prop]; } } } } else if (memberName === "key") ; else if (memberName === "ref") { if (newValue) { newValue(elm); } } else if (!elm.__lookupSetter__(memberName) && memberName[0] === "o" && memberName[1] === "n") { if (memberName[2] === "-") { memberName = memberName.slice(3); } else if (isMemberInElement(win, ln)) { memberName = ln.slice(2); } else { memberName = ln[2] + memberName.slice(3); } if (oldValue) { plt.rel(elm, memberName, oldValue, false); } if (newValue) { plt.ael(elm, memberName, newValue, false); } } else { const isComplex = isComplexType(newValue); if ((isProp || isComplex && newValue !== null) && !isSvg) { try { if (!elm.tagName.includes("-")) { const n = newValue == null ? "" : newValue; if (memberName === "list") { isProp = false; } else if (oldValue == null || elm[memberName] != n) { elm[memberName] = n; } } else { elm[memberName] = newValue; } } catch (e) { } } let xlink = false; { if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) { memberName = ln; xlink = true; } } if (newValue == null || newValue === false) { if (newValue !== false || elm.getAttribute(memberName) === "") { if (xlink) { elm.removeAttributeNS(XLINK_NS, memberName); } else { elm.removeAttribute(memberName); } } } else if ((!isProp || flags & 4 || isSvg) && !isComplex) { newValue = newValue === true ? "" : newValue; if (xlink) { elm.setAttributeNS(XLINK_NS, memberName, newValue); } else { elm.setAttribute(memberName, newValue); } } } } }; const parseClassListRegex = /\s/; const parseClassList = (value) => !value ? [] : value.split(parseClassListRegex); const updateElement = (oldVnode, newVnode, isSvgMode2, memberName) => { const elm = newVnode.$elm$.nodeType === 11 && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$; const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || EMPTY_OBJ; const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ; { for (memberName in oldVnodeAttrs) { if (!(memberName in newVnodeAttrs)) { setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$); } } } for (memberName in newVnodeAttrs) { setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$); } }; const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => { const newVNode2 = newParentVNode.$children$[childIndex]; let i = 0; let elm; let childNode; let oldVNode; if (!useNativeShadowDom) { checkSlotRelocate = true; if (newVNode2.$tag$ === "slot") { if (scopeId) { parentElm.classList.add(scopeId + "-s"); } newVNode2.$flags$ |= newVNode2.$children$ ? ( // slot element has fallback content 2 ) : ( // slot element does not have fallback content 1 ); } } if (newVNode2.$text$ !== null) { elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$); } else if (newVNode2.$flags$ & 1) { elm = newVNode2.$elm$ = doc.createTextNode(""); } else { if (!isSvgMode) { isSvgMode = newVNode2.$tag$ === "svg"; } elm = newVNode2.$elm$ = doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode2.$flags$ & 2 ? "slot-fb" : newVNode2.$tag$); if (isSvgMode && newVNode2.$tag$ === "foreignObject") { isSvgMode = false; } { updateElement(null, newVNode2, isSvgMode); } if (isDef(scopeId) && elm["s-si"] !== scopeId) { elm.classList.add(elm["s-si"] = scopeId); } if (newVNode2.$children$) { for (i = 0; i < newVNode2.$children$.length; ++i) { childNode = createElm(oldParentVNode, newVNode2, i, elm); if (childNode) { elm.appendChild(childNode); } } } { if (newVNode2.$tag$ === "svg") { isSvgMode = false; } else if (elm.tagName === "foreignObject") { isSvgMode = true; } } } { elm["s-hn"] = hostTagName; if (newVNode2.$flags$ & (2 | 1)) { elm["s-sr"] = true; elm["s-cr"] = contentRef; elm["s-sn"] = newVNode2.$name$ || ""; oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex]; if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) { putBackInOriginalLocation(oldParentVNode.$elm$, false); } } } return elm; }; const putBackInOriginalLocation = (parentElm, recursive) => { plt.$flags$ |= 1; const oldSlotChildNodes = parentElm.childNodes; for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) { const childNode = oldSlotChildNodes[i]; if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) { parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode)); childNode["s-ol"].remove(); childNode["s-ol"] = void 0; checkSlotRelocate = true; } if (recursive) { putBackInOriginalLocation(childNode, recursive); } } plt.$flags$ &= ~1; }; const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => { let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm; let childNode; if (containerElm.shadowRoot && containerElm.tagName === hostTagName) { containerElm = containerElm.shadowRoot; } for (; startIdx <= endIdx; ++startIdx) { if (vnodes[startIdx]) { childNode = createElm(null, parentVNode, startIdx, parentElm); if (childNode) { vnodes[startIdx].$elm$ = childNode; containerElm.insertBefore(childNode, referenceNode(before)); } } } }; const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => { for (; startIdx <= endIdx; ++startIdx) { if (vnode = vnodes[startIdx]) { elm = vnode.$elm$; callNodeRefs(vnode); { checkSlotFallbackVisibility = true; if (elm["s-ol"]) { elm["s-ol"].remove(); } else { putBackInOriginalLocation(elm, true); } } elm.remove(); } } }; const updateChildren = (parentElm, oldCh, newVNode2, newCh) => { let oldStartIdx = 0; let newStartIdx = 0; let idxInOld = 0; let i = 0; let oldEndIdx = oldCh.length - 1; let oldStartVnode = oldCh[0]; let oldEndVnode = oldCh[oldEndIdx]; let newEndIdx = newCh.length - 1; let newStartVnode = newCh[0]; let newEndVnode = newCh[newEndIdx]; let node; let elmToMove; while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { if (oldStartVnode == null) { oldStartVnode = oldCh[++oldStartIdx]; } else if (oldEndVnode == null) { oldEndVnode = oldCh[--oldEndIdx]; } else if (newStartVnode == null) { newStartVnode = newCh[++newStartIdx]; } else if (newEndVnode == null) { newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldStartVnode, newStartVnode)) { patch(oldStartVnode, newStartVnode); oldStartVnode = oldCh[++oldStartIdx]; newStartVnode = newCh[++newStartIdx]; } else if (isSameVnode(oldEndVnode, newEndVnode)) { patch(oldEndVnode, newEndVnode); oldEndVnode = oldCh[--oldEndIdx]; newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldStartVnode, newEndVnode)) { if (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot") { putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false); } patch(oldStartVnode, newEndVnode); parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling); oldStartVnode = oldCh[++oldStartIdx]; newEndVnode = newCh[--newEndIdx]; } else if (isSameVnode(oldEndVnode, newStartVnode)) { if (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot") { putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false); } patch(oldEndVnode, newStartVnode); parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$); oldEndVnode = oldCh[--oldEndIdx]; newStartVnode = newCh[++newStartIdx]; } else { idxInOld = -1; { for (i = oldStartIdx; i <= oldEndIdx; ++i) { if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) { idxInOld = i; break; } } } if (idxInOld >= 0) { elmToMove = oldCh[idxInOld]; if (elmToMove.$tag$ !== newStartVnode.$tag$) { node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld, parentElm); } else { patch(elmToMove, newStartVnode); oldCh[idxInOld] = void 0; node = elmToMove.$elm$; } newStartVnode = newCh[++newStartIdx]; } else { node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx, parentElm); newStartVnode = newCh[++newStartIdx]; } if (node) { { parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$)); } } } } if (oldStartIdx > oldEndIdx) { addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode2, newCh, newStartIdx, newEndIdx); } else if (newStartIdx > newEndIdx) { removeVnodes(oldCh, oldStartIdx, oldEndIdx); } }; const isSameVnode = (leftVNode, rightVNode) => { if (leftVNode.$tag$ === rightVNode.$tag$) { if (leftVNode.$tag$ === "slot") { return leftVNode.$name$ === rightVNode.$name$; } { return leftVNode.$key$ === rightVNode.$key$; } } return false; }; const referenceNode = (node) => { return node && node["s-ol"] || node; }; const parentReferenceNode = (node) => (node["s-ol"] ? node["s-ol"] : node).parentNode; const patch = (oldVNode, newVNode2) => { const elm = newVNode2.$elm$ = oldVNode.$elm$; const oldChildren = oldVNode.$children$; const newChildren = newVNode2.$children$; const tag = newVNode2.$tag$; const text = newVNode2.$text$; let defaultHolder; if (text === null) { { isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode; } { if (tag === "slot") ; else { updateElement(oldVNode, newVNode2, isSvgMode); } } if (oldChildren !== null && newChildren !== null) { updateChildren(elm, oldChildren, newVNode2, newChildren); } else if (newChildren !== null) { if (oldVNode.$text$ !== null) { elm.textContent = ""; } addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1); } else if (oldChildren !== null) { removeVnodes(oldChildren, 0, oldChildren.length - 1); } if (isSvgMode && tag === "svg") { isSvgMode = false; } } else if (defaultHolder = elm["s-cr"]) { defaultHolder.parentNode.textContent = text; } else if (oldVNode.$text$ !== text) { elm.data = text; } }; const updateFallbackSlotVisibility = (elm) => { const childNodes = elm.childNodes; let childNode; let i; let ilen; let j; let slotNameAttr; let nodeType; for (i = 0, ilen = childNodes.length; i < ilen; i++) { childNode = childNodes[i]; if (childNode.nodeType === 1) { if (childNode["s-sr"]) { slotNameAttr = childNode["s-sn"]; childNode.hidden = false; for (j = 0; j < ilen; j++) { nodeType = childNodes[j].nodeType; if (childNodes[j]["s-hn"] !== childNode["s-hn"] || slotNameAttr !== "") { if (nodeType === 1 && slotNameAttr === childNodes[j].getAttribute("slot")) { childNode.hidden = true; break; } } else { if (nodeType === 1 || nodeType === 3 && childNodes[j].textContent.trim() !== "") { childNode.hidden = true; break; } } } } updateFallbackSlotVisibility(childNode); } } }; const relocateNodes = []; const relocateSlotContent = (elm) => { let childNode; let node; let hostContentNodes; let slotNameAttr; let relocateNodeData; let j; let i = 0; const childNodes = elm.childNodes; const ilen = childNodes.length; for (; i < ilen; i++) { childNode = childNodes[i]; if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) { hostContentNodes = node.parentNode.childNodes; slotNameAttr = childNode["s-sn"]; for (j = hostContentNodes.length - 1; j >= 0; j--) { node = hostContentNodes[j]; if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"]) { if (isNodeLocatedInSlot(node, slotNameAttr)) { relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node); checkSlotFallbackVisibility = true; node["s-sn"] = node["s-sn"] || slotNameAttr; if (relocateNodeData) { relocateNodeData.$slotRefNode$ = childNode; } else { relocateNodes.push({ $slotRefNode$: childNode, $nodeToRelocate$: node }); } if (node["s-sr"]) { relocateNodes.map((relocateNode) => { if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) { relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node); if (relocateNodeData && !relocateNode.$slotRefNode$) { relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$; } } }); } } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) { relocateNodes.push({ $nodeToRelocate$: node }); } } } } if (childNode.nodeType === 1) { relocateSlotContent(childNode); } } }; const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => { if (nodeToRelocate.nodeType === 1) { if (nodeToRelocate.getAttribute("slot") === null && slotNameAttr === "") { return true; } if (nodeToRelocate.getAttribute("slot") === slotNameAttr) { return true; } return false; } if (nodeToRelocate["s-sn"] === slotNameAttr) { return true; } return slotNameAttr === ""; }; const callNodeRefs = (vNode) => { { vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null); vNode.$children$ && vNode.$children$.map(callNodeRefs); } }; const renderVdom = (hostRef, renderFnResults) => { const hostElm = hostRef.$hostElement$; const cmpMeta = hostRef.$cmpMeta$; const oldVNode = hostRef.$vnode$ || newVNode(null, null); const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults); hostTagName = hostElm.tagName; if (cmpMeta.$attrsToReflect$) { rootVnode.$attrs$ = rootVnode.$attrs$ || {}; cmpMeta.$attrsToReflect$.map(([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]); } rootVnode.$tag$ = null; rootVnode.$flags$ |= 4; hostRef.$vnode$ = rootVnode; rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm; { scopeId = hostElm["s-sc"]; } { contentRef = hostElm["s-cr"]; useNativeShadowDom = (cmpMeta.$flags$ & 1) !== 0; checkSlotFallbackVisibility = false; } patch(oldVNode, rootVnode); { plt.$flags$ |= 1; if (checkSlotRelocate) { relocateSlotContent(rootVnode.$elm$); let relocateData; let nodeToRelocate; let orgLocationNode; let parentNodeRef; let insertBeforeNode; let refNode; let i = 0; for (; i < relocateNodes.length; i++) { relocateData = relocateNodes[i]; nodeToRelocate = relocateData.$nodeToRelocate$; if (!nodeToRelocate["s-ol"]) { orgLocationNode = doc.createTextNode(""); orgLocationNode["s-nr"] = nodeToRelocate; nodeToRelocate.parentNode.insertBefore(nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate); } } for (i = 0; i < relocateNodes.length; i++) { relocateData = relocateNodes[i]; nodeToRelocate = relocateData.$nodeToRelocate$; if (relocateData.$slotRefNode$) { parentNodeRef = relocateData.$slotRefNode$.parentNode; insertBeforeNode = relocateData.$slotRefNode$.nextSibling; orgLocationNode = nodeToRelocate["s-ol"]; while (orgLocationNode = orgLocationNode.previousSibling) { refNode = orgLocationNode["s-nr"]; if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) { refNode = refNode.nextSibling; if (!refNode || !refNode["s-nr"]) { insertBeforeNode = refNode; break; } } } if (!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode || nodeToRelocate.nextSibling !== insertBeforeNode) { if (nodeToRelocate !== insertBeforeNode) { if (!nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) { nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName; } parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode); } } } else { if (nodeToRelocate.nodeType === 1) { nodeToRelocate.hidden = true; } } } } if (checkSlotFallbackVisibility) { updateFallbackSlotVisibility(rootVnode.$elm$); } plt.$flags$ &= ~1; relocateNodes.length = 0; } }; const attachToAncestor = (hostRef, ancestorComponent) => { }; const scheduleUpdate = (hostRef, isInitialLoad) => { { hostRef.$flags$ |= 16; } attachToAncestor(hostRef, hostRef.$ancestorComponent$); const dispatch = () => dispatchHooks(hostRef, isInitialLoad); return writeTask(dispatch); }; const dispatchHooks = (hostRef, isInitialLoad) => { const elm = hostRef.$hostElement$; const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$); const instance = elm; let promise; if (isInitialLoad) { { promise = safeCall(instance, "componentWillLoad"); } } else { { promise = safeCall(instance, "componentWillUpdate"); } } { promise = then(promise, () => safeCall(instance, "componentWillRender")); } endSchedule(); return then(promise, () => updateComponent(hostRef, instance, isInitialLoad)); }; const updateComponent = async (hostRef, instance, isInitialLoad) => { const elm = hostRef.$hostElement$; const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$); elm["s-rc"]; if (isInitialLoad) { attachStyles(hostRef); } const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$); { callRender(hostRef, instance, elm); } endRender(); endUpdate(); { postUpdateComponent(hostRef); } }; const callRender = (hostRef, instance, elm) => { const allRenderFn = false; const lazyLoad = false; const taskQueue = true; const updatable = true; try { renderingRef = instance; instance = allRenderFn ? instance.render() : instance.render && instance.render(); if (updatable && taskQueue) { hostRef.$flags$ &= ~16; } if (updatable || lazyLoad) { hostRef.$flags$ |= 2; } if (BUILD.hasRenderFn || BUILD.reflect) { if (BUILD.vdomRender || BUILD.reflect) { if (BUILD.hydrateServerSide) ; else { renderVdom(hostRef, instance); } } } } catch (e) { consoleError(e, hostRef.$hostElement$); } renderingRef = null; return null; }; const postUpdateComponent = (hostRef) => { const tagName = hostRef.$cmpMeta$.$tagName$; const elm = hostRef.$hostElement$; const endPostUpdate = createTime("postUpdate", tagName); const instance = elm; hostRef.$ancestorComponent$; { safeCall(instance, "componentDidRender"); } if (!(hostRef.$flags$ & 64)) { hostRef.$flags$ |= 64; { safeCall(instance, "componentDidLoad"); } endPostUpdate(); } else { { safeCall(instance, "componentDidUpdate"); } endPostUpdate(); } }; const safeCall = (instance, method, arg) => { if (instance && instance[method]) { try { return instance[method](arg); } catch (e) { consoleError(e); } } return void 0; }; const then = (promise, thenFn) => { return promise && promise.then ? promise.then(thenFn) : thenFn(); }; const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName); const setValue = (ref, propName, newVal, cmpMeta) => { const hostRef = getHostRef(ref); const elm = ref; const oldVal = hostRef.$instanceValues$.get(propName); const flags = hostRef.$flags$; const instance = elm; newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]); const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal); const didValueChange = newVal !== oldVal && !areBothNaN; if (didValueChange) { hostRef.$instanceValues$.set(propName, newVal); { if (cmpMeta.$watchers$ && flags & 128) { const watchMethods = cmpMeta.$watchers$[propName]; if (watchMethods) { watchMethods.map((watchMethodName) => { try { instance[watchMethodName](newVal, oldVal, propName); } catch (e) { consoleError(e, elm); } }); } } if ((flags & (2 | 16)) === 2) { if (instance.componentShouldUpdate) { if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) { return; } } scheduleUpdate(hostRef, false); } } } }; const proxyComponent = (Cstr, cmpMeta, flags) => { if (cmpMeta.$members$) { if (Cstr.watchers) { cmpMeta.$watchers$ = Cstr.watchers; } const members = Object.entries(cmpMeta.$members$); const prototype = Cstr.prototype; members.map(([memberName, [memberFlags]]) => { if (memberFlags & 31 || memberFlags & 32) { Object.defineProperty(prototype, memberName, { get() { return getValue(this, memberName); }, set(newValue) { setValue(this, memberName, newValue, cmpMeta); }, configurable: true, enumerable: true }); } }); { const attrNameToPropName = /* @__PURE__ */ new Map(); prototype.attributeChangedCallback = function(attrName, _oldValue, newValue) { plt.jmp(() => { const propName = attrNameToPropName.get(attrName); if (this.hasOwnProperty(propName)) { newValue = this[propName]; delete this[propName]; } else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && this[propName] == newValue) { return; } this[propName] = newValue === null && typeof this[propName] === "boolean" ? false : newValue; }); }; Cstr.observedAttributes = members.filter( ([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */ ).map(([propName, m]) => { const attrName = m[1] || propName; attrNameToPropName.set(attrName, propName); if (m[0] & 512) { cmpMeta.$attrsToReflect$.push([propName, attrName]); } return attrName; }); } } return Cstr; }; const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => { if ((hostRef.$flags$ & 32) === 0) { { Cstr = elm.constructor; hostRef.$flags$ |= 32; customElements.whenDefined(cmpMeta.$tagName$).then(() => hostRef.$flags$ |= 128); } if (Cstr.style) { let style = Cstr.style; if (typeof style !== "string") { style = style[hostRef.$modeName$ = computeMode(elm)]; } const scopeId2 = getScopeId(cmpMeta, hostRef.$modeName$); if (!styles.has(scopeId2)) { const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$); registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1)); endRegisterStyles(); } } } hostRef.$ancestorComponent$; const schedule = () => scheduleUpdate(hostRef, true); { schedule(); } }; const fireConnectedCallback = (instance) => { }; const connectedCallback = (elm) => { if ((plt.$flags$ & 1) === 0) { const hostRef = getHostRef(elm); const cmpMeta = hostRef.$cmpMeta$; const endConnected = createTime("connectedCallback", cmpMeta.$tagName$); if (!(hostRef.$flags$ & 1)) { hostRef.$flags$ |= 1; { if (cmpMeta.$flags$ & (4 | 8)) { setContentReference(elm); } } if (cmpMeta.$members$) { Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => { if (memberFlags & 31 && elm.hasOwnProperty(memberName)) { const value = elm[memberName]; delete elm[memberName]; elm[memberName] = value; } }); } { initializeComponent(elm, hostRef, cmpMeta); } } else { addHostEventListeners(elm, hostRef, cmpMeta.$listeners$); fireConnectedCallback(hostRef.$lazyInstance$); } endConnected(); } }; const setContentReference = (elm) => { const contentRefElm = elm["s-cr"] = doc.createComment(""); contentRefElm["s-cn"] = true; elm.insertBefore(contentRefElm, elm.firstChild); }; const disconnectedCallback = (elm) => { if ((plt.$flags$ & 1) === 0) { const hostRef = getHostRef(elm); { if (hostRef.$rmListeners$) { hostRef.$rmListeners$.map((rmListener) => rmListener()); hostRef.$rmListeners$ = void 0; } } } }; const proxyCustomElement = (Cstr, compactMeta) => { const cmpMeta = { $flags$: compactMeta[0], $tagName$: compactMeta[1] }; { cmpMeta.$members$ = compactMeta[2]; } { cmpMeta.$listeners$ = compactMeta[3]; } { cmpMeta.$watchers$ = Cstr.$watchers$; } { cmpMeta.$attrsToReflect$ = []; } const originalConnectedCallback = Cstr.prototype.connectedCallback; const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback; Object.assign(Cstr.prototype, { __registerHost() { registerHost(this, cmpMeta); }, connectedCallback() { connectedCallback(this); if (originalConnectedCallback) { originalConnectedCallback.call(this); } }, disconnectedCallback() { disconnectedCallback(this); if (originalDisconnectedCallback) { originalDisconnectedCallback.call(this); } }, __attachShadow() { { { this.attachShadow({ mode: "open", delegatesFocus: !!(cmpMeta.$flags$ & 16) }); } } } }); Cstr.is = cmpMeta.$tagName$; return proxyComponent(Cstr, cmpMeta); }; const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => { if (listeners) { listeners.map(([flags, name, method]) => { const target = getHostListenerTarget(elm, flags); const handler = hostListenerProxy(hostRef, method); const opts = hostListenerOpts(flags); plt.ael(target, name, handler, opts); (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts)); }); } }; const hostListenerProxy = (hostRef, methodName) => (ev) => { try { if (BUILD.lazyLoad) ; else { hostRef.$hostElement$[methodName](ev); } } catch (e) { consoleError(e); } }; const getHostListenerTarget = (elm, flags) => { if (flags & 4) return doc; if (flags & 8) return win; if (flags & 16) return doc.body; return elm; }; const hostListenerOpts = (flags) => supportsListenerOptions ? { passive: (flags & 1) !== 0, capture: (flags & 2) !== 0 } : (flags & 2) !== 0; const hostRefs = /* @__PURE__ */ new WeakMap(); const getHostRef = (ref) => hostRefs.get(ref); const registerHost = (elm, cmpMeta) => { const hostRef = { $flags$: 0, $hostElement$: elm, $cmpMeta$: cmpMeta, $instanceValues$: /* @__PURE__ */ new Map() }; addHostEventListeners(elm, hostRef, cmpMeta.$listeners$); return hostRefs.set(elm, hostRef); }; const isMemberInElement = (elm, memberName) => memberName in elm; const consoleError = (e, el) => (0, console.error)(e, el); const styles = /* @__PURE__ */ new Map(); const modeResolutionChain = []; const win = typeof window !== "undefined" ? window : {}; const doc = win.document || { head: {} }; win.HTMLElement || class { }; const plt = { $flags$: 0, $resourcesUrl$: "", jmp: (h2) => h2(), raf: (h2) => requestAnimationFrame(h2), ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts), rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts), ce: (eventName, opts) => new CustomEvent(eventName, opts) }; const supportsListenerOptions = /* @__PURE__ */ (() => { let supportsListenerOptions2 = false; try { doc.addEventListener("e", null, Object.defineProperty({}, "passive", { get() { supportsListenerOptions2 = true; } })); } catch (e) { } return supportsListenerOptions2; })(); const promiseResolve = (v) => Promise.resolve(v); const supportsConstructableStylesheets = /* @__PURE__ */ (() => { try { new CSSStyleSheet(); return typeof new CSSStyleSheet().replaceSync === "function"; } catch (e) { } return false; })(); const queueDomReads = []; const queueDomWrites = []; const queueTask = (queue, write) => (cb) => { queue.push(cb); if (!queuePending) { queuePending = true; if (write && plt.$flags$ & 4) { nextTick(flush); } else { plt.raf(flush); } } }; const consume = (queue) => { for (let i = 0; i < queue.length; i++) { try { queue[i](performance.now()); } catch (e) { consoleError(e); } } queue.length = 0; }; const flush = () => { consume(queueDomReads); { consume(queueDomWrites); if (queuePending = queueDomReads.length > 0) { plt.raf(flush); } } }; const nextTick = (cb) => promiseResolve().then(cb); const writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true); const ISO_DATE_FORMAT = /^(\d{4})-(\d{2})-(\d{2})$/; var DaysOfWeek; (function(DaysOfWeek2) { DaysOfWeek2[DaysOfWeek2["Sunday"] = 0] = "Sunday"; DaysOfWeek2[DaysOfWeek2["Monday"] = 1] = "Monday"; DaysOfWeek2[DaysOfWeek2["Tuesday"] = 2] = "Tuesday"; DaysOfWeek2[DaysOfWeek2["Wednesday"] = 3] = "Wednesday"; DaysOfWeek2[DaysOfWeek2["Thursday"] = 4] = "Thursday"; DaysOfWeek2[DaysOfWeek2["Friday"] = 5] = "Friday"; DaysOfWeek2[DaysOfWeek2["Saturday"] = 6] = "Saturday"; })(DaysOfWeek || (DaysOfWeek = {})); function createDate(year, month, day) { var dayInt = parseInt(day, 10); var monthInt = parseInt(month, 10); var yearInt = parseInt(year, 10); const isValid = Number.isInteger(yearInt) && // all parts should be integers Number.isInteger(monthInt) && Number.isInteger(dayInt) && monthInt > 0 && // month must be 1-12 monthInt <= 12 && dayInt > 0 && // day must be 1-31 dayInt <= 31 && yearInt > 0; if (isValid) { return new Date(yearInt, monthInt - 1, dayInt); } } function parseISODate(value) { if (!value) { return; } const matches = value.match(ISO_DATE_FORMAT); if (matches) { return createDate(matches[1], matches[2], matches[3]); } } function printISODate(date) { if (!date) { return ""; } var d = date.getDate().toString(10); var m = (date.getMonth() + 1).toString(10); var y = date.getFullYear().toString(10); if (date.getDate() < 10) { d = `0${d}`; } if (date.getMonth() < 9) { m = `0${m}`; } return `${y}-${m}-${d}`; } function isEqual(a, b) { if (a == null || b == null) { return false; } return isEqualMonth(a, b) && a.getDate() === b.getDate(); } function isEqualMonth(a, b) { if (a == null || b == null) { return false; } return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth(); } function addDays(date, days) { var d = new Date(date); d.setDate(d.getDate() + days); return d; } function startOfWeek(date, firstDayOfWeek = DaysOfWeek.Monday) { var d = new Date(date); var day = d.getDay(); var diff = (day < firstDayOfWeek ? 7 : 0) + day - firstDayOfWeek; d.setDate(d.getDate() - diff); return d; } function endOfWeek(date, firstDayOfWeek = DaysOfWeek.Monday) { var d = new Date(date); var day = d.getDay(); var diff = (day < firstDayOfWeek ? -7 : 0) + 6 - (day - firstDayOfWeek); d.setDate(d.getDate() + diff); return d; } function startOfMonth(date) { return new Date(date.getFullYear(), date.getMonth(), 1); } function endOfMonth(date) { return new Date(date.getFullYear(), date.getMonth() + 1, 0); } function setMonth(date, month) { const d = new Date(date); d.setMonth(month); return d; } function setYear(date, year) { const d = new Date(date); d.setFullYear(year); return d; } function inRange(date, min, max) { return clamp(date, min, max) === date; } function clamp(date, min, max) { const time = date.getTime(); if (min && min instanceof Date && time < min.getTime()) { return min; } if (max && max instanceof Date && time > max.getTime()) { return max; } return date; } function getDaysInRange(start, end) { const days = []; let current = start; while (!isEqual(current, end)) { days.push(current); current = addDays(current, 1); } days.push(current); return days; } function getViewOfMonth(date, firstDayOfWeek = DaysOfWeek.Monday) { const start = startOfWeek(startOfMonth(date), firstDayOfWeek); const end = endOfWeek(endOfMonth(date), firstDayOfWeek); return getDaysInRange(start, end); } function chr4() { return Math.random().toString(16).slice(-4); } function createIdentifier(prefix) { return `${prefix}-${chr4()}${chr4()}-${chr4()}-${chr4()}-${chr4()}-${chr4()}${chr4()}${chr4()}`; } const DatePickerInput = ({ onClick, dateFormatter, localization: localization2, name, formattedValue, valueAsDate, value, identifier, disabled, required, role, buttonRef, inputRef, onInput, onBlur, onFocus }) => { return h( "div", { class: "duet-date__input-wrapper" }, h("input", { class: "duet-date__input", value: formattedValue, placeholder: localization2.placeholder, id: identifier, disabled, role, required: required ? true : void 0, "aria-autocomplete": "none", onInput, onFocus, onBlur, autoComplete: "off", ref: inputRef }), h("input", { type: "hidden", name, value }), h( "button", { class: "duet-date__toggle", onClick, disabled, ref: buttonRef, type: "button" }, h( "span", { class: "duet-date__toggle-icon" }, h( "svg", { "aria-hidden": "true", height: "24", viewBox: "0 0 21 21", width: "24", xmlns: "http://www.w3.org/2000/svg" }, h( "g", { fill: "none", "fill-rule": "evenodd", transform: "translate(2 2)" }, h("path", { d: "m2.5.5h12c1.1045695 0 2 .8954305 2 2v12c0 1.1045695-.8954305 2-2 2h-12c-1.1045695 0-2-.8954305-2-2v-12c0-1.1045695.8954305-2 2-2z", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "m.5 4.5h16", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round" }), h( "g", { fill: "currentColor" }, h("circle", { cx: "8.5", cy: "8.5", r: "1" }), h("circle", { cx: "4.5", cy: "8.5", r: "1" }), h("circle", { cx: "12.5", cy: "8.5", r: "1" }), h("circle", { cx: "8.5", cy: "12.5", r: "1" }), h("circle", { cx: "4.5", cy: "12