@telperion/elements 7.1.0 → 8.1.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/.build-manifest.json +12 -1
- package/README.md +64 -0
- package/custom-elements.json +1870 -129
- package/date/date-element.cjs +231 -0
- package/date/date-element.cjs.map +1 -0
- package/date/date-element.js +229 -0
- package/date/date-element.js.map +1 -0
- package/date/format-pattern.cjs +49 -0
- package/date/format-pattern.cjs.map +1 -0
- package/date/format-pattern.js +47 -0
- package/date/format-pattern.js.map +1 -0
- package/date/format.cjs +57 -0
- package/date/format.cjs.map +1 -0
- package/date/format.js +51 -0
- package/date/format.js.map +1 -0
- package/date/index.cjs +17 -0
- package/date/index.cjs.map +1 -0
- package/date/index.d.cts +171 -0
- package/date/index.d.ts +171 -0
- package/date/index.js +6 -0
- package/date/index.js.map +1 -0
- package/date/intl.cjs +36 -0
- package/date/intl.cjs.map +1 -0
- package/date/intl.js +32 -0
- package/date/intl.js.map +1 -0
- package/date/locale.cjs +36 -0
- package/date/locale.cjs.map +1 -0
- package/date/locale.js +34 -0
- package/date/locale.js.map +1 -0
- package/date/names.cjs +41 -0
- package/date/names.cjs.map +1 -0
- package/date/names.js +37 -0
- package/date/names.js.map +1 -0
- package/date/parse-fields.cjs +80 -0
- package/date/parse-fields.cjs.map +1 -0
- package/date/parse-fields.js +75 -0
- package/date/parse-fields.js.map +1 -0
- package/date/parse-iso.cjs +41 -0
- package/date/parse-iso.cjs.map +1 -0
- package/date/parse-iso.js +39 -0
- package/date/parse-iso.js.map +1 -0
- package/date/parse-numeric.cjs +53 -0
- package/date/parse-numeric.cjs.map +1 -0
- package/date/parse-numeric.js +50 -0
- package/date/parse-numeric.js.map +1 -0
- package/date/parse-pattern.cjs +123 -0
- package/date/parse-pattern.cjs.map +1 -0
- package/date/parse-pattern.js +121 -0
- package/date/parse-pattern.js.map +1 -0
- package/date/parse.cjs +35 -0
- package/date/parse.cjs.map +1 -0
- package/date/parse.js +33 -0
- package/date/parse.js.map +1 -0
- package/date/relative.cjs +47 -0
- package/date/relative.cjs.map +1 -0
- package/date/relative.js +44 -0
- package/date/relative.js.map +1 -0
- package/date/resolution.cjs +62 -0
- package/date/resolution.cjs.map +1 -0
- package/date/resolution.js +59 -0
- package/date/resolution.js.map +1 -0
- package/date/styles.cjs +21 -0
- package/date/styles.cjs.map +1 -0
- package/date/styles.js +19 -0
- package/date/styles.js.map +1 -0
- package/date/ticker.cjs +71 -0
- package/date/ticker.cjs.map +1 -0
- package/date/ticker.js +69 -0
- package/date/ticker.js.map +1 -0
- package/date/tokens.cjs +94 -0
- package/date/tokens.cjs.map +1 -0
- package/date/tokens.js +91 -0
- package/date/tokens.js.map +1 -0
- package/date/zone.cjs +110 -0
- package/date/zone.cjs.map +1 -0
- package/date/zone.js +101 -0
- package/date/zone.js.map +1 -0
- package/drag-drop/drag-drop-event.cjs +53 -0
- package/drag-drop/drag-drop-event.cjs.map +1 -0
- package/drag-drop/drag-drop-event.js +51 -0
- package/drag-drop/drag-drop-event.js.map +1 -0
- package/drag-drop/drag-element.cjs +44 -43
- package/drag-drop/drag-element.cjs.map +1 -1
- package/drag-drop/drag-element.js +44 -43
- package/drag-drop/drag-element.js.map +1 -1
- package/drag-drop/drag-handle-element.cjs +1 -1
- package/drag-drop/drag-handle-element.cjs.map +1 -1
- package/drag-drop/drag-handle-element.js +1 -1
- package/drag-drop/drag-handle-element.js.map +1 -1
- package/drag-drop/dropzone-element.cjs +21 -17
- package/drag-drop/dropzone-element.cjs.map +1 -1
- package/drag-drop/dropzone-element.js +21 -17
- package/drag-drop/dropzone-element.js.map +1 -1
- package/drag-drop/index.cjs +2 -2
- package/drag-drop/index.d.cts +136 -33
- package/drag-drop/index.d.ts +136 -33
- package/drag-drop/index.js +1 -1
- package/fesm/elements.mjs +1138 -65
- package/fesm/elements.mjs.map +1 -1
- package/iife/date/index.js +53 -0
- package/iife/date/index.js.map +1 -0
- package/iife/drag-drop/index.js +20 -20
- package/iife/drag-drop/index.js.map +1 -1
- package/iife/elements.js +62 -44
- package/iife/elements.js.map +1 -1
- package/index.cjs +13 -2
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +6 -1
- package/index.js.map +1 -1
- package/package.json +31 -3
- package/drag-drop/tha-drag-event.cjs +0 -36
- package/drag-drop/tha-drag-event.cjs.map +0 -1
- package/drag-drop/tha-drag-event.js +0 -34
- package/drag-drop/tha-drag-event.js.map +0 -1
package/fesm/elements.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
|
-
import { LitElement, css, html as html$1 } from 'lit';
|
|
2
|
+
import { LitElement, css, html as html$1, nothing } from 'lit';
|
|
3
3
|
import { property, customElement, state } from 'lit/decorators.js';
|
|
4
4
|
import { signal, computed, SignalWatcher, html } from '@lit-labs/signals';
|
|
5
5
|
import { noop } from '@telperion/js-utils/function/noop';
|
|
@@ -1752,9 +1752,14 @@ const REGISTER_HANDLE_PROP = Symbol('Register Handle');
|
|
|
1752
1752
|
const UNREGISTER_HANDLE_PROP = Symbol('Unregister Handle');
|
|
1753
1753
|
|
|
1754
1754
|
var _a$1;
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1755
|
+
/**
|
|
1756
|
+
* The event type of every `tp-drag-*` / `tp-dropzone-*` event. It extends `DragEvent`
|
|
1757
|
+
* (pointer coordinates, modifier keys, … come from the native event it wraps)
|
|
1758
|
+
* and bubbles like the native drag events do.
|
|
1759
|
+
*/
|
|
1760
|
+
class DragDropEvent extends DragEvent {
|
|
1761
|
+
static #DragElementEvents = ['tp-drag-move', 'tp-drag-start', 'tp-drag-end', 'tp-drag-zone-enter', 'tp-drag-zone-leave', 'tp-drag-zone-over', 'tp-drag-drop'];
|
|
1762
|
+
static #DropElementEvents = ['tp-dropzone-drop', 'tp-dropzone-drop-end', 'tp-dropzone-enter', 'tp-dropzone-leave', 'tp-dropzone-over'];
|
|
1758
1763
|
get #target() {
|
|
1759
1764
|
if (_a$1.#DropElementEvents.includes(this.type)) {
|
|
1760
1765
|
return this.dropzoneTarget;
|
|
@@ -1764,9 +1769,15 @@ class ThaDragEvent extends DragEvent {
|
|
|
1764
1769
|
}
|
|
1765
1770
|
return new WeakRef(this.target);
|
|
1766
1771
|
}
|
|
1772
|
+
/**
|
|
1773
|
+
* The `name` of the element the event is dispatched on: the drop zone's name for
|
|
1774
|
+
* drop zone events, the dragged element's name for drag element events.
|
|
1775
|
+
* Use `dragTarget.deref()?.name` for the dragged element's name in drop zone listeners.
|
|
1776
|
+
*/
|
|
1767
1777
|
get name() {
|
|
1768
1778
|
return this.#target.deref()?.name;
|
|
1769
1779
|
}
|
|
1780
|
+
/** The dragged element's `data-drag-*` values (see `DragElement.dragData`). */
|
|
1770
1781
|
get dragData() {
|
|
1771
1782
|
return this.dragTarget.deref()?.dragData;
|
|
1772
1783
|
}
|
|
@@ -1775,18 +1786,25 @@ class ThaDragEvent extends DragEvent {
|
|
|
1775
1786
|
this.dragTarget = dragTarget;
|
|
1776
1787
|
this.dropzoneTarget = dropzoneTarget;
|
|
1777
1788
|
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Accepts the drop on `dropzoneTarget`. Call it in a `tp-dropzone-drop` listener.
|
|
1791
|
+
* The dragged element then animates into `rect` (viewport coordinates, e.g. from
|
|
1792
|
+
* `getBoundingClientRect()`), or back to where it started without one, and
|
|
1793
|
+
* `tp-dropzone-drop-end` fires on the drop zone when the animation is over.
|
|
1794
|
+
*/
|
|
1778
1795
|
acceptDrop(rect) {
|
|
1779
1796
|
this.dragTarget.deref()?.[ACCEPT_DROP_PROP](this.dropzoneTarget, rect);
|
|
1780
1797
|
}
|
|
1781
1798
|
}
|
|
1782
|
-
_a$1 =
|
|
1799
|
+
_a$1 = DragDropEvent;
|
|
1783
1800
|
|
|
1784
1801
|
var DragElement_1;
|
|
1785
1802
|
let DragElement = class DragElement extends LitElement {
|
|
1786
1803
|
constructor() {
|
|
1787
1804
|
super(...arguments);
|
|
1788
1805
|
/**
|
|
1789
|
-
*
|
|
1806
|
+
* Values of the element's `data-drag-*` attributes, keyed without the prefix
|
|
1807
|
+
* (`data-drag-id="42"` → `{ id: "42" }`). Kept in sync with attribute changes.
|
|
1790
1808
|
*/
|
|
1791
1809
|
this.dragData = {};
|
|
1792
1810
|
/**
|
|
@@ -1814,8 +1832,8 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1814
1832
|
*/
|
|
1815
1833
|
this.#handles = new Set();
|
|
1816
1834
|
/**
|
|
1817
|
-
* The
|
|
1818
|
-
*
|
|
1835
|
+
* The `dataTransfer.effectAllowed` of the drag. Both values animate the same way;
|
|
1836
|
+
* the element itself always moves (nothing is copied).
|
|
1819
1837
|
*/
|
|
1820
1838
|
this.draggingStrategy = 'move';
|
|
1821
1839
|
/**
|
|
@@ -1860,7 +1878,7 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1860
1878
|
this.#clone = new WeakRef(clone);
|
|
1861
1879
|
this.parentElement.insertBefore(clone, this.nextSibling);
|
|
1862
1880
|
}
|
|
1863
|
-
this.dispatchEvent(new
|
|
1881
|
+
this.dispatchEvent(new DragDropEvent('tp-drag-start', { dragTarget: new WeakRef(this) }, event));
|
|
1864
1882
|
});
|
|
1865
1883
|
};
|
|
1866
1884
|
/**
|
|
@@ -1875,11 +1893,11 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1875
1893
|
if (this.replaceClone)
|
|
1876
1894
|
this.clone?.remove();
|
|
1877
1895
|
this.style.pointerEvents = this.preDragData.styles.pointerEvents;
|
|
1878
|
-
['--
|
|
1896
|
+
['--tp-drag-width', '--tp-drag-height', '--tp-drag-left', '--tp-drag-top', '--tp-drag-x', '--tp-drag-y', '--tp-drag-cx', '--tp-drag-cy'].forEach(prop => {
|
|
1879
1897
|
this.style.removeProperty(prop);
|
|
1880
1898
|
});
|
|
1881
1899
|
['width', 'height', 'left', 'right', 'top', 'bottom'].forEach(prop => {
|
|
1882
|
-
this.style.removeProperty(`--
|
|
1900
|
+
this.style.removeProperty(`--tp-drag-target-${prop}`);
|
|
1883
1901
|
});
|
|
1884
1902
|
const acceptedDropzone = this.#acceptedDropzone;
|
|
1885
1903
|
const dropAccepted = this.dropAccepted;
|
|
@@ -1889,9 +1907,9 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1889
1907
|
this.dropAccepted = false;
|
|
1890
1908
|
this.#acceptedDropzone = null;
|
|
1891
1909
|
if (dropAccepted && acceptedDropzone) {
|
|
1892
|
-
acceptedDropzone.deref()?.dispatchEvent(new
|
|
1910
|
+
acceptedDropzone.deref()?.dispatchEvent(new DragDropEvent('tp-dropzone-drop-end', { dragTarget: new WeakRef(this), dropzoneTarget: acceptedDropzone }, event));
|
|
1893
1911
|
}
|
|
1894
|
-
this.dispatchEvent(new
|
|
1912
|
+
this.dispatchEvent(new DragDropEvent('tp-drag-end', { dragTarget: new WeakRef(this) }, event));
|
|
1895
1913
|
};
|
|
1896
1914
|
if (hasTransition)
|
|
1897
1915
|
this.addEventListener('transitionend', clear, { once: true });
|
|
@@ -1905,13 +1923,13 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1905
1923
|
*/
|
|
1906
1924
|
this.#handleDrag = (event) => {
|
|
1907
1925
|
const { x, y } = event;
|
|
1908
|
-
this.style.setProperty('--
|
|
1909
|
-
this.style.setProperty('--
|
|
1926
|
+
this.style.setProperty('--tp-drag-cx', `${x}px`);
|
|
1927
|
+
this.style.setProperty('--tp-drag-cy', `${y}px`);
|
|
1910
1928
|
};
|
|
1911
1929
|
/**
|
|
1912
1930
|
* Handles the drop zone enter event.
|
|
1913
1931
|
* This updates the draggedOver property to indicate which drop zone the element is currently over.
|
|
1914
|
-
* @param event The
|
|
1932
|
+
* @param event The DragDropEvent for the drop zone enter.
|
|
1915
1933
|
*/
|
|
1916
1934
|
this.#handleDropZoneEnter = (event) => {
|
|
1917
1935
|
this.draggedOver = event.dropzoneTarget?.deref()?.name ?? '';
|
|
@@ -1919,7 +1937,7 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1919
1937
|
/**
|
|
1920
1938
|
* Handles the drop zone leave event.
|
|
1921
1939
|
* This clears the draggedOver property when the element leaves a drop zone.
|
|
1922
|
-
* @param event The
|
|
1940
|
+
* @param event The DragDropEvent for the drop zone leave.
|
|
1923
1941
|
*/
|
|
1924
1942
|
this.#handleDropZoneLeave = () => {
|
|
1925
1943
|
this.draggedOver = null;
|
|
@@ -1939,8 +1957,8 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1939
1957
|
}); }
|
|
1940
1958
|
static { this.styles = css `
|
|
1941
1959
|
:host {
|
|
1942
|
-
--
|
|
1943
|
-
--
|
|
1960
|
+
--tp-drag-diff-x: calc(var(--tp-drag-cx) - var(--tp-drag-x));
|
|
1961
|
+
--tp-drag-diff-y: calc(var(--tp-drag-cy) - var(--tp-drag-y));
|
|
1944
1962
|
}
|
|
1945
1963
|
|
|
1946
1964
|
:host([draggingstrategy="move"]),
|
|
@@ -1953,27 +1971,27 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1953
1971
|
:host([draggingstrategy="move"][dragging]),
|
|
1954
1972
|
:host([draggingstrategy="copyMove"][dragging]) {
|
|
1955
1973
|
position: fixed;
|
|
1956
|
-
width: var(--
|
|
1957
|
-
height: var(--
|
|
1958
|
-
left: calc(var(--
|
|
1959
|
-
top: calc(var(--
|
|
1960
|
-
transform-origin: calc(var(--
|
|
1974
|
+
width: var(--tp-drag-width);
|
|
1975
|
+
height: var(--tp-drag-height);
|
|
1976
|
+
left: calc(var(--tp-drag-left) + var(--tp-drag-diff-x) + var(--tp-drag-offset-x));
|
|
1977
|
+
top: calc(var(--tp-drag-top) + var(--tp-drag-diff-y) + var(--tp-drag-offset-y));
|
|
1978
|
+
transform-origin: calc(var(--tp-drag-x) - var(--tp-drag-left)) calc(var(--tp-drag-y) - var(--tp-drag-top));
|
|
1961
1979
|
z-index: 100;
|
|
1962
1980
|
}
|
|
1963
1981
|
|
|
1964
1982
|
:host([draggingstrategy="move"][dragend]),
|
|
1965
1983
|
:host([draggingstrategy="copyMove"][dragend]) {
|
|
1966
|
-
left: var(--
|
|
1967
|
-
top: var(--
|
|
1984
|
+
left: var(--tp-drag-left);
|
|
1985
|
+
top: var(--tp-drag-top);
|
|
1968
1986
|
transition-property: all;
|
|
1969
1987
|
}
|
|
1970
1988
|
|
|
1971
1989
|
:host([draggingstrategy="move"][dragend][dropaccepted]),
|
|
1972
1990
|
:host([draggingstrategy="copyMove"][dragend][dropaccepted]) {
|
|
1973
|
-
left: var(--
|
|
1974
|
-
top: var(--
|
|
1975
|
-
width: var(--
|
|
1976
|
-
height: var(--
|
|
1991
|
+
left: var(--tp-drag-target-left);
|
|
1992
|
+
top: var(--tp-drag-target-top);
|
|
1993
|
+
width: var(--tp-drag-target-width);
|
|
1994
|
+
height: var(--tp-drag-target-height);
|
|
1977
1995
|
}
|
|
1978
1996
|
`; }
|
|
1979
1997
|
static {
|
|
@@ -1981,13 +1999,13 @@ let DragElement = class DragElement extends LitElement {
|
|
|
1981
1999
|
this.TRANSPARENT_IMAGE.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==';
|
|
1982
2000
|
const style = this.GLOBAL_STYLE = document.createElement('style');
|
|
1983
2001
|
style.innerHTML = `
|
|
1984
|
-
@property --
|
|
2002
|
+
@property --tp-drag-offset-x {
|
|
1985
2003
|
syntax: '<length>';
|
|
1986
2004
|
initial-value: 0px;
|
|
1987
2005
|
inherits: true;
|
|
1988
2006
|
}
|
|
1989
2007
|
|
|
1990
|
-
@property --
|
|
2008
|
+
@property --tp-drag-offset-y {
|
|
1991
2009
|
syntax: '<length>';
|
|
1992
2010
|
initial-value: 0px;
|
|
1993
2011
|
inherits: true;
|
|
@@ -2024,8 +2042,8 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2024
2042
|
this.addEventListener('dragstart', this.#handleDragStart);
|
|
2025
2043
|
this.addEventListener('dragend', this.#handleDragEnd);
|
|
2026
2044
|
this.addEventListener('drag', this.#handleDrag);
|
|
2027
|
-
this.addEventListener('
|
|
2028
|
-
this.addEventListener('
|
|
2045
|
+
this.addEventListener('tp-drag-zone-enter', this.#handleDropZoneEnter);
|
|
2046
|
+
this.addEventListener('tp-drag-zone-leave', this.#handleDropZoneLeave);
|
|
2029
2047
|
}
|
|
2030
2048
|
disconnectedCallback() {
|
|
2031
2049
|
super.disconnectedCallback();
|
|
@@ -2033,8 +2051,8 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2033
2051
|
this.removeEventListener('dragstart', this.#handleDragStart);
|
|
2034
2052
|
this.removeEventListener('dragend', this.#handleDragEnd);
|
|
2035
2053
|
this.removeEventListener('drag', this.#handleDrag);
|
|
2036
|
-
this.removeEventListener('
|
|
2037
|
-
this.removeEventListener('
|
|
2054
|
+
this.removeEventListener('tp-drag-zone-enter', this.#handleDropZoneEnter);
|
|
2055
|
+
this.removeEventListener('tp-drag-zone-leave', this.#handleDropZoneLeave);
|
|
2038
2056
|
}
|
|
2039
2057
|
render() {
|
|
2040
2058
|
return html$1 `<slot></slot>`;
|
|
@@ -2052,7 +2070,7 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2052
2070
|
return;
|
|
2053
2071
|
const { width, height, left, right, top, bottom } = rect;
|
|
2054
2072
|
for (const prop in { width, height, left, right, top, bottom }) {
|
|
2055
|
-
this.style.setProperty(`--
|
|
2073
|
+
this.style.setProperty(`--tp-drag-target-${prop}`, `${rect[prop]}px`);
|
|
2056
2074
|
}
|
|
2057
2075
|
}
|
|
2058
2076
|
/**
|
|
@@ -2098,13 +2116,13 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2098
2116
|
/**
|
|
2099
2117
|
* Handles the drop zone enter event.
|
|
2100
2118
|
* This updates the draggedOver property to indicate which drop zone the element is currently over.
|
|
2101
|
-
* @param event The
|
|
2119
|
+
* @param event The DragDropEvent for the drop zone enter.
|
|
2102
2120
|
*/
|
|
2103
2121
|
#handleDropZoneEnter;
|
|
2104
2122
|
/**
|
|
2105
2123
|
* Handles the drop zone leave event.
|
|
2106
2124
|
* This clears the draggedOver property when the element leaves a drop zone.
|
|
2107
|
-
* @param event The
|
|
2125
|
+
* @param event The DragDropEvent for the drop zone leave.
|
|
2108
2126
|
*/
|
|
2109
2127
|
#handleDropZoneLeave;
|
|
2110
2128
|
/**
|
|
@@ -2113,7 +2131,7 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2113
2131
|
* @returns The cloned element.
|
|
2114
2132
|
*/
|
|
2115
2133
|
#createClone() {
|
|
2116
|
-
const container = document.createElement('
|
|
2134
|
+
const container = document.createElement('tp-drag-clone');
|
|
2117
2135
|
Object.values(this.attributes)
|
|
2118
2136
|
.filter(attr => !['dragging', 'replaceclone', 'draggable'].includes(attr.name))
|
|
2119
2137
|
.forEach(attr => {
|
|
@@ -2142,7 +2160,7 @@ let DragElement = class DragElement extends LitElement {
|
|
|
2142
2160
|
const { boundingRect: { width, height, left, top }, dragStartEvent: { x, y } } = this.preDragData;
|
|
2143
2161
|
const props = { width, height, left, top, x, y };
|
|
2144
2162
|
for (const prop in props) {
|
|
2145
|
-
this.style.setProperty(`--
|
|
2163
|
+
this.style.setProperty(`--tp-drag-${prop}`, `${props[prop]}px`);
|
|
2146
2164
|
}
|
|
2147
2165
|
}
|
|
2148
2166
|
/**
|
|
@@ -2174,15 +2192,15 @@ __decorate([
|
|
|
2174
2192
|
__metadata("design:type", String)
|
|
2175
2193
|
], DragElement.prototype, "name", void 0);
|
|
2176
2194
|
__decorate([
|
|
2177
|
-
property({ type: String, reflect: true }),
|
|
2195
|
+
property({ type: String, reflect: true, attribute: "draggingstrategy" }),
|
|
2178
2196
|
__metadata("design:type", String)
|
|
2179
2197
|
], DragElement.prototype, "draggingStrategy", void 0);
|
|
2180
2198
|
__decorate([
|
|
2181
|
-
property({ type: String }),
|
|
2199
|
+
property({ type: String, attribute: "draggroup" }),
|
|
2182
2200
|
__metadata("design:type", String)
|
|
2183
2201
|
], DragElement.prototype, "dragGroup", void 0);
|
|
2184
2202
|
__decorate([
|
|
2185
|
-
property({ type: Boolean }),
|
|
2203
|
+
property({ type: Boolean, attribute: "replaceclone" }),
|
|
2186
2204
|
__metadata("design:type", Boolean)
|
|
2187
2205
|
], DragElement.prototype, "replaceClone", void 0);
|
|
2188
2206
|
__decorate([
|
|
@@ -2194,11 +2212,11 @@ __decorate([
|
|
|
2194
2212
|
__metadata("design:type", Object)
|
|
2195
2213
|
], DragElement.prototype, "dragend", void 0);
|
|
2196
2214
|
__decorate([
|
|
2197
|
-
property({ type: String, reflect: true }),
|
|
2215
|
+
property({ type: String, reflect: true, attribute: "draggedover" }),
|
|
2198
2216
|
__metadata("design:type", Object)
|
|
2199
2217
|
], DragElement.prototype, "draggedOver", void 0);
|
|
2200
2218
|
__decorate([
|
|
2201
|
-
property({ type: Boolean, reflect: true }),
|
|
2219
|
+
property({ type: Boolean, reflect: true, attribute: "dropaccepted" }),
|
|
2202
2220
|
__metadata("design:type", Object)
|
|
2203
2221
|
], DragElement.prototype, "dropAccepted", void 0);
|
|
2204
2222
|
__decorate([
|
|
@@ -2206,20 +2224,24 @@ __decorate([
|
|
|
2206
2224
|
__metadata("design:type", Boolean)
|
|
2207
2225
|
], DragElement.prototype, "disabled", void 0);
|
|
2208
2226
|
DragElement = DragElement_1 = __decorate([
|
|
2209
|
-
customElement('
|
|
2227
|
+
customElement('tp-drag')
|
|
2210
2228
|
], DragElement);
|
|
2211
2229
|
|
|
2212
2230
|
let LAST_DRAG_EVENT;
|
|
2213
|
-
document.addEventListener('
|
|
2231
|
+
document.addEventListener('tp-drag-start', event => {
|
|
2214
2232
|
LAST_DRAG_EVENT = event;
|
|
2215
2233
|
});
|
|
2216
2234
|
let DropZoneElement = class DropZoneElement extends LitElement {
|
|
2217
2235
|
constructor() {
|
|
2218
2236
|
super(...arguments);
|
|
2219
2237
|
this.#enterCount = 0;
|
|
2238
|
+
/** `<tp-drag>` names this zone reacts to (`accept="task, bug"`). Empty: every name. */
|
|
2220
2239
|
this.accept = [];
|
|
2240
|
+
/** Identifies the zone; reflected on the dragged element as `draggedover`. */
|
|
2221
2241
|
this.name = '';
|
|
2242
|
+
/** The `name` of the accepted element currently over the zone, or `null`. */
|
|
2222
2243
|
this.itemDragged = null;
|
|
2244
|
+
/** Whether a drag this zone accepts is in progress anywhere on the page. */
|
|
2223
2245
|
this.acceptableDrag = false;
|
|
2224
2246
|
this.#handleGlobalDragStart = (event) => {
|
|
2225
2247
|
if (!this.accept.length || this.accept.includes(event.name)) {
|
|
@@ -2237,7 +2259,7 @@ let DropZoneElement = class DropZoneElement extends LitElement {
|
|
|
2237
2259
|
if (++this.#enterCount > 1)
|
|
2238
2260
|
return;
|
|
2239
2261
|
this.itemDragged = LAST_DRAG_EVENT.name ?? '';
|
|
2240
|
-
this.#dispatchEventWithCounter('
|
|
2262
|
+
this.#dispatchEventWithCounter('tp-dropzone-enter', 'tp-drag-zone-enter', event);
|
|
2241
2263
|
};
|
|
2242
2264
|
this.#handleDragLeave = (event) => {
|
|
2243
2265
|
if (!this.#isAcceptableDrag())
|
|
@@ -2245,17 +2267,17 @@ let DropZoneElement = class DropZoneElement extends LitElement {
|
|
|
2245
2267
|
if (--this.#enterCount > 0)
|
|
2246
2268
|
return;
|
|
2247
2269
|
this.itemDragged = null;
|
|
2248
|
-
this.#dispatchEventWithCounter('
|
|
2270
|
+
this.#dispatchEventWithCounter('tp-dropzone-leave', 'tp-drag-zone-leave', event);
|
|
2249
2271
|
};
|
|
2250
2272
|
this.#handleDragOver = (event) => {
|
|
2251
2273
|
if (!this.#isAcceptableDrag())
|
|
2252
2274
|
return;
|
|
2253
|
-
this.#dispatchEventWithCounter('
|
|
2275
|
+
this.#dispatchEventWithCounter('tp-dropzone-over', 'tp-drag-zone-over', event);
|
|
2254
2276
|
};
|
|
2255
2277
|
this.#handleDrop = (event) => {
|
|
2256
2278
|
if (!this.#isAcceptableDrag())
|
|
2257
2279
|
return;
|
|
2258
|
-
this.#dispatchEventWithCounter('
|
|
2280
|
+
this.#dispatchEventWithCounter('tp-dropzone-drop', 'tp-drag-drop', event);
|
|
2259
2281
|
};
|
|
2260
2282
|
}
|
|
2261
2283
|
static { this.styles = css ``; }
|
|
@@ -2265,9 +2287,9 @@ let DropZoneElement = class DropZoneElement extends LitElement {
|
|
|
2265
2287
|
}
|
|
2266
2288
|
connectedCallback() {
|
|
2267
2289
|
super.connectedCallback();
|
|
2268
|
-
document.addEventListener('
|
|
2269
|
-
document.addEventListener('
|
|
2270
|
-
document.addEventListener('
|
|
2290
|
+
document.addEventListener('tp-drag-start', this.#handleGlobalDragStart);
|
|
2291
|
+
document.addEventListener('tp-drag-end', this.#handleGlobalDragEnd);
|
|
2292
|
+
document.addEventListener('tp-dropzone-drop-end', this.#handleGlobalDragEnd);
|
|
2271
2293
|
this.addEventListener('dragenter', this.#handleDragEnter);
|
|
2272
2294
|
this.addEventListener('dragleave', this.#handleDragLeave);
|
|
2273
2295
|
this.addEventListener('dragover', this.#handleDragOver);
|
|
@@ -2275,9 +2297,9 @@ let DropZoneElement = class DropZoneElement extends LitElement {
|
|
|
2275
2297
|
}
|
|
2276
2298
|
disconnectedCallback() {
|
|
2277
2299
|
super.disconnectedCallback();
|
|
2278
|
-
document.removeEventListener('
|
|
2279
|
-
document.removeEventListener('
|
|
2280
|
-
document.removeEventListener('
|
|
2300
|
+
document.removeEventListener('tp-drag-start', this.#handleGlobalDragStart);
|
|
2301
|
+
document.removeEventListener('tp-drag-end', this.#handleGlobalDragEnd);
|
|
2302
|
+
document.removeEventListener('tp-dropzone-drop-end', this.#handleGlobalDragEnd);
|
|
2281
2303
|
this.removeEventListener('dragenter', this.#handleDragEnter);
|
|
2282
2304
|
this.removeEventListener('dragleave', this.#handleDragLeave);
|
|
2283
2305
|
this.removeEventListener('dragover', this.#handleDragOver);
|
|
@@ -2295,8 +2317,8 @@ let DropZoneElement = class DropZoneElement extends LitElement {
|
|
|
2295
2317
|
#dispatchEventWithCounter(eventName, counterEventName, event) {
|
|
2296
2318
|
const { dragTarget } = LAST_DRAG_EVENT;
|
|
2297
2319
|
const dropzoneTarget = new WeakRef(this);
|
|
2298
|
-
this.dispatchEvent(new
|
|
2299
|
-
dragTarget.deref()?.dispatchEvent(new
|
|
2320
|
+
this.dispatchEvent(new DragDropEvent(eventName, { dragTarget, dropzoneTarget }, event));
|
|
2321
|
+
dragTarget.deref()?.dispatchEvent(new DragDropEvent(counterEventName, { dragTarget, dropzoneTarget }, event));
|
|
2300
2322
|
}
|
|
2301
2323
|
};
|
|
2302
2324
|
__decorate([
|
|
@@ -2308,15 +2330,15 @@ __decorate([
|
|
|
2308
2330
|
__metadata("design:type", Object)
|
|
2309
2331
|
], DropZoneElement.prototype, "name", void 0);
|
|
2310
2332
|
__decorate([
|
|
2311
|
-
property({ type: String, reflect: true }),
|
|
2333
|
+
property({ type: String, reflect: true, attribute: "itemdragged" }),
|
|
2312
2334
|
__metadata("design:type", Object)
|
|
2313
2335
|
], DropZoneElement.prototype, "itemDragged", void 0);
|
|
2314
2336
|
__decorate([
|
|
2315
|
-
property({ type: Boolean, reflect: true }),
|
|
2337
|
+
property({ type: Boolean, reflect: true, attribute: "acceptabledrag" }),
|
|
2316
2338
|
__metadata("design:type", Object)
|
|
2317
2339
|
], DropZoneElement.prototype, "acceptableDrag", void 0);
|
|
2318
2340
|
DropZoneElement = __decorate([
|
|
2319
|
-
customElement('
|
|
2341
|
+
customElement('tp-dropzone')
|
|
2320
2342
|
], DropZoneElement);
|
|
2321
2343
|
|
|
2322
2344
|
let DragHandleElement = class DragHandleElement extends LitElement {
|
|
@@ -2342,7 +2364,7 @@ let DragHandleElement = class DragHandleElement extends LitElement {
|
|
|
2342
2364
|
}
|
|
2343
2365
|
};
|
|
2344
2366
|
DragHandleElement = __decorate([
|
|
2345
|
-
customElement("
|
|
2367
|
+
customElement("tp-drag-handle")
|
|
2346
2368
|
], DragHandleElement);
|
|
2347
2369
|
|
|
2348
2370
|
/**
|
|
@@ -4538,5 +4560,1056 @@ class PortalOutletFallbackElement extends HTMLElement {
|
|
|
4538
4560
|
if (!customElements.get("tp-portal-outlet-fallback"))
|
|
4539
4561
|
customElements.define("tp-portal-outlet-fallback", PortalOutletFallbackElement);
|
|
4540
4562
|
|
|
4541
|
-
|
|
4563
|
+
const dateTimeFormats = new Map();
|
|
4564
|
+
const relativeTimeFormats = new Map();
|
|
4565
|
+
/**
|
|
4566
|
+
* Cached `Intl.DateTimeFormat`. Constructing formatters is the expensive part
|
|
4567
|
+
* of `Intl`, and live dates re-format on every tick.
|
|
4568
|
+
*/
|
|
4569
|
+
function dateTimeFormat(locale, options) {
|
|
4570
|
+
const key = `${locale ?? ""}|${JSON.stringify(options)}`;
|
|
4571
|
+
let format = dateTimeFormats.get(key);
|
|
4572
|
+
if (!format) {
|
|
4573
|
+
format = new Intl.DateTimeFormat(locale, options);
|
|
4574
|
+
dateTimeFormats.set(key, format);
|
|
4575
|
+
}
|
|
4576
|
+
return format;
|
|
4577
|
+
}
|
|
4578
|
+
/** Cached `Intl.RelativeTimeFormat` with `numeric: "auto"` ("yesterday", "now"). */
|
|
4579
|
+
function relativeTimeFormat(locale) {
|
|
4580
|
+
const key = locale ?? "";
|
|
4581
|
+
let format = relativeTimeFormats.get(key);
|
|
4582
|
+
if (!format) {
|
|
4583
|
+
format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
4584
|
+
relativeTimeFormats.set(key, format);
|
|
4585
|
+
}
|
|
4586
|
+
return format;
|
|
4587
|
+
}
|
|
4588
|
+
/** Returns the value of the first part of `type`, if any. */
|
|
4589
|
+
function partValue(parts, type) {
|
|
4590
|
+
return parts.find(part => part.type === type)?.value;
|
|
4591
|
+
}
|
|
4592
|
+
|
|
4593
|
+
const cache$2 = new Map();
|
|
4594
|
+
function cached(key, build) {
|
|
4595
|
+
let names = cache$2.get(key);
|
|
4596
|
+
if (!names) {
|
|
4597
|
+
names = build();
|
|
4598
|
+
cache$2.set(key, names);
|
|
4599
|
+
}
|
|
4600
|
+
return names;
|
|
4601
|
+
}
|
|
4602
|
+
/** Localized month names, January first. Uses the "format" form (as in "22 January"). */
|
|
4603
|
+
function monthNames(locale, width) {
|
|
4604
|
+
return cached(`month|${locale}|${width}`, () => {
|
|
4605
|
+
const format = dateTimeFormat(locale, { timeZone: "UTC", day: "numeric", month: width });
|
|
4606
|
+
return Array.from({ length: 12 }, (_, month) => partValue(format.formatToParts(Date.UTC(2000, month, 15)), "month") ?? "");
|
|
4607
|
+
});
|
|
4608
|
+
}
|
|
4609
|
+
/** Localized weekday names, Sunday first. */
|
|
4610
|
+
function weekdayNames(locale, width) {
|
|
4611
|
+
return cached(`weekday|${locale}|${width}`, () => {
|
|
4612
|
+
const format = dateTimeFormat(locale, { timeZone: "UTC", weekday: width });
|
|
4613
|
+
// 2000-01-02 was a Sunday.
|
|
4614
|
+
return Array.from({ length: 7 }, (_, day) => format.format(Date.UTC(2000, 0, 2 + day)));
|
|
4615
|
+
});
|
|
4616
|
+
}
|
|
4617
|
+
/** Localized day periods as `[am, pm]`. Falls back to `AM` / `PM`. */
|
|
4618
|
+
function dayPeriods(locale) {
|
|
4619
|
+
return cached(`period|${locale}`, () => {
|
|
4620
|
+
const format = dateTimeFormat(locale, { timeZone: "UTC", hour: "numeric", hourCycle: "h12" });
|
|
4621
|
+
const read = (hour, fallback) => partValue(format.formatToParts(Date.UTC(2000, 0, 1, hour)), "dayPeriod") ?? fallback;
|
|
4622
|
+
return [read(9, "AM"), read(21, "PM")];
|
|
4623
|
+
});
|
|
4624
|
+
}
|
|
4625
|
+
|
|
4626
|
+
/**
|
|
4627
|
+
* Moment-style tokens shared by formatting (`format`) and parsing
|
|
4628
|
+
* (`input-format`). Ordered longest-first so the tokenizer is greedy.
|
|
4629
|
+
*
|
|
4630
|
+
* | Token | Meaning |
|
|
4631
|
+
* | ------------ | ------------------------------------ |
|
|
4632
|
+
* | `YYYY` `YY` | Year (4 digits / 2 digits) |
|
|
4633
|
+
* | `MMMM` `MMM` | Month name (long / short, localized) |
|
|
4634
|
+
* | `MM` `M` | Month number (padded / unpadded) |
|
|
4635
|
+
* | `DD` `D` | Day of month |
|
|
4636
|
+
* | `dddd` `ddd` | Weekday name (long / short) |
|
|
4637
|
+
* | `d` | Weekday number (0 = Sunday) |
|
|
4638
|
+
* | `HH` `H` | Hour 0-23 |
|
|
4639
|
+
* | `hh` `h` | Hour 1-12 |
|
|
4640
|
+
* | `mm` `m` | Minute |
|
|
4641
|
+
* | `ss` `s` | Second |
|
|
4642
|
+
* | `SSS` | Millisecond |
|
|
4643
|
+
* | `A` `a` | Day period (AM/PM, localized) |
|
|
4644
|
+
* | `ZZ` `Z` | UTC offset (`+0300` / `+03:00`) |
|
|
4645
|
+
* | `X` `x` | Unix seconds / milliseconds |
|
|
4646
|
+
*
|
|
4647
|
+
* Text in `[brackets]` is literal. Any other character is literal too.
|
|
4648
|
+
*/
|
|
4649
|
+
const TOKENS = [
|
|
4650
|
+
"YYYY",
|
|
4651
|
+
"MMMM",
|
|
4652
|
+
"dddd",
|
|
4653
|
+
"MMM",
|
|
4654
|
+
"ddd",
|
|
4655
|
+
"SSS",
|
|
4656
|
+
"YY",
|
|
4657
|
+
"MM",
|
|
4658
|
+
"DD",
|
|
4659
|
+
"HH",
|
|
4660
|
+
"hh",
|
|
4661
|
+
"mm",
|
|
4662
|
+
"ss",
|
|
4663
|
+
"ZZ",
|
|
4664
|
+
"M",
|
|
4665
|
+
"D",
|
|
4666
|
+
"d",
|
|
4667
|
+
"H",
|
|
4668
|
+
"h",
|
|
4669
|
+
"m",
|
|
4670
|
+
"s",
|
|
4671
|
+
"A",
|
|
4672
|
+
"a",
|
|
4673
|
+
"Z",
|
|
4674
|
+
"X",
|
|
4675
|
+
"x",
|
|
4676
|
+
];
|
|
4677
|
+
const cache$1 = new Map();
|
|
4678
|
+
/** Splits a pattern into tokens and literals. Results are cached per pattern. */
|
|
4679
|
+
function tokenize(pattern) {
|
|
4680
|
+
let parts = cache$1.get(pattern);
|
|
4681
|
+
if (parts)
|
|
4682
|
+
return parts;
|
|
4683
|
+
parts = [];
|
|
4684
|
+
let literal = "";
|
|
4685
|
+
let i = 0;
|
|
4686
|
+
const flush = () => {
|
|
4687
|
+
if (literal)
|
|
4688
|
+
parts.push({ literal });
|
|
4689
|
+
literal = "";
|
|
4690
|
+
};
|
|
4691
|
+
while (i < pattern.length) {
|
|
4692
|
+
if (pattern[i] === "[") {
|
|
4693
|
+
const end = pattern.indexOf("]", i + 1);
|
|
4694
|
+
if (end !== -1) {
|
|
4695
|
+
literal += pattern.slice(i + 1, end);
|
|
4696
|
+
i = end + 1;
|
|
4697
|
+
continue;
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
const token = TOKENS.find(candidate => pattern.startsWith(candidate, i));
|
|
4701
|
+
if (token) {
|
|
4702
|
+
flush();
|
|
4703
|
+
parts.push({ token });
|
|
4704
|
+
i += token.length;
|
|
4705
|
+
}
|
|
4706
|
+
else {
|
|
4707
|
+
literal += pattern[i++];
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
flush();
|
|
4711
|
+
cache$1.set(pattern, parts);
|
|
4712
|
+
return parts;
|
|
4713
|
+
}
|
|
4714
|
+
|
|
4715
|
+
const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
4716
|
+
/**
|
|
4717
|
+
* Wall-clock fields of `date` in `timeZone` (an IANA name such as
|
|
4718
|
+
* `Europe/Istanbul`). Without a time zone the runtime's local zone is used.
|
|
4719
|
+
*/
|
|
4720
|
+
function getFields(date, timeZone) {
|
|
4721
|
+
if (!timeZone) {
|
|
4722
|
+
return {
|
|
4723
|
+
year: date.getFullYear(),
|
|
4724
|
+
month: date.getMonth() + 1,
|
|
4725
|
+
day: date.getDate(),
|
|
4726
|
+
hour: date.getHours(),
|
|
4727
|
+
minute: date.getMinutes(),
|
|
4728
|
+
second: date.getSeconds(),
|
|
4729
|
+
millisecond: date.getMilliseconds(),
|
|
4730
|
+
weekday: date.getDay(),
|
|
4731
|
+
};
|
|
4732
|
+
}
|
|
4733
|
+
const parts = dateTimeFormat("en-US", {
|
|
4734
|
+
timeZone,
|
|
4735
|
+
hourCycle: "h23",
|
|
4736
|
+
era: "short",
|
|
4737
|
+
year: "numeric",
|
|
4738
|
+
month: "numeric",
|
|
4739
|
+
day: "numeric",
|
|
4740
|
+
hour: "numeric",
|
|
4741
|
+
minute: "numeric",
|
|
4742
|
+
second: "numeric",
|
|
4743
|
+
weekday: "short",
|
|
4744
|
+
}).formatToParts(date);
|
|
4745
|
+
const read = (type) => Number(partValue(parts, type));
|
|
4746
|
+
const year = read("year");
|
|
4747
|
+
return {
|
|
4748
|
+
year: partValue(parts, "era") === "BC" ? 1 - year : year,
|
|
4749
|
+
month: read("month"),
|
|
4750
|
+
day: read("day"),
|
|
4751
|
+
hour: read("hour"),
|
|
4752
|
+
minute: read("minute"),
|
|
4753
|
+
second: read("second"),
|
|
4754
|
+
millisecond: date.getUTCMilliseconds(),
|
|
4755
|
+
weekday: WEEKDAYS.indexOf(partValue(parts, "weekday") ?? ""),
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
/** UTC timestamp of the given wall-clock fields, as if they were in UTC. Handles years 0-99. */
|
|
4759
|
+
function utcFromFields(fields) {
|
|
4760
|
+
const date = new Date(0);
|
|
4761
|
+
date.setUTCFullYear(fields.year, fields.month - 1, fields.day);
|
|
4762
|
+
date.setUTCHours(fields.hour, fields.minute, fields.second, fields.millisecond);
|
|
4763
|
+
return date.getTime();
|
|
4764
|
+
}
|
|
4765
|
+
/** Offset of `timeZone` from UTC at `date`, in minutes (east positive, e.g. `+180` for Istanbul). */
|
|
4766
|
+
function offsetMinutes(date, timeZone) {
|
|
4767
|
+
if (!timeZone)
|
|
4768
|
+
return -date.getTimezoneOffset();
|
|
4769
|
+
return Math.round((utcFromFields(getFields(date, timeZone)) - date.getTime()) / 60_000);
|
|
4770
|
+
}
|
|
4771
|
+
/**
|
|
4772
|
+
* The instant at which the wall clock in `timeZone` shows `fields`. In a DST
|
|
4773
|
+
* gap the time is shifted forward, matching how `Date` handles local times.
|
|
4774
|
+
*/
|
|
4775
|
+
function fromFields(fields, timeZone) {
|
|
4776
|
+
if (!timeZone) {
|
|
4777
|
+
const date = new Date(0);
|
|
4778
|
+
date.setFullYear(fields.year, fields.month - 1, fields.day);
|
|
4779
|
+
date.setHours(fields.hour, fields.minute, fields.second, fields.millisecond);
|
|
4780
|
+
return date;
|
|
4781
|
+
}
|
|
4782
|
+
const guess = utcFromFields(fields);
|
|
4783
|
+
const first = offsetMinutes(new Date(guess), timeZone);
|
|
4784
|
+
const time = guess - first * 60_000;
|
|
4785
|
+
const second = offsetMinutes(new Date(time), timeZone);
|
|
4786
|
+
return new Date(second === first ? time : guess - second * 60_000);
|
|
4787
|
+
}
|
|
4788
|
+
/** Number of days in a month (`month` is 1-12). */
|
|
4789
|
+
function daysInMonth(year, month) {
|
|
4790
|
+
return new Date(utcFromFields({ year, month: month + 1, day: 0, hour: 0, minute: 0, second: 0, millisecond: 0 })).getUTCDate();
|
|
4791
|
+
}
|
|
4792
|
+
/** Formats an offset in minutes as `+03:00` (or `+0300` without a separator). */
|
|
4793
|
+
function formatOffset(minutes, separator = ":") {
|
|
4794
|
+
const sign = minutes < 0 ? "-" : "+";
|
|
4795
|
+
const abs = Math.abs(minutes);
|
|
4796
|
+
return `${sign}${pad(Math.floor(abs / 60))}${separator}${pad(abs % 60)}`;
|
|
4797
|
+
}
|
|
4798
|
+
/** `true` when `timeZone` is a zone the runtime's `Intl` understands. */
|
|
4799
|
+
function isValidTimeZone(timeZone) {
|
|
4800
|
+
try {
|
|
4801
|
+
dateTimeFormat(undefined, { timeZone });
|
|
4802
|
+
return true;
|
|
4803
|
+
}
|
|
4804
|
+
catch {
|
|
4805
|
+
return false;
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
function pad(value, length = 2) {
|
|
4809
|
+
return String(Math.abs(value)).padStart(length, "0");
|
|
4810
|
+
}
|
|
4811
|
+
|
|
4812
|
+
const hour12 = (hour) => hour % 12 || 12;
|
|
4813
|
+
const FORMATTERS = {
|
|
4814
|
+
YYYY: ({ fields }) => (fields.year < 0 ? "-" : "") + pad(fields.year, 4),
|
|
4815
|
+
YY: ({ fields }) => pad(fields.year % 100),
|
|
4816
|
+
MMMM: ({ fields, locale }) => monthNames(locale, "long")[fields.month - 1],
|
|
4817
|
+
MMM: ({ fields, locale }) => monthNames(locale, "short")[fields.month - 1],
|
|
4818
|
+
MM: ({ fields }) => pad(fields.month),
|
|
4819
|
+
M: ({ fields }) => String(fields.month),
|
|
4820
|
+
DD: ({ fields }) => pad(fields.day),
|
|
4821
|
+
D: ({ fields }) => String(fields.day),
|
|
4822
|
+
dddd: ({ fields, locale }) => weekdayNames(locale, "long")[fields.weekday],
|
|
4823
|
+
ddd: ({ fields, locale }) => weekdayNames(locale, "short")[fields.weekday],
|
|
4824
|
+
d: ({ fields }) => String(fields.weekday),
|
|
4825
|
+
HH: ({ fields }) => pad(fields.hour),
|
|
4826
|
+
H: ({ fields }) => String(fields.hour),
|
|
4827
|
+
hh: ({ fields }) => pad(hour12(fields.hour)),
|
|
4828
|
+
h: ({ fields }) => String(hour12(fields.hour)),
|
|
4829
|
+
mm: ({ fields }) => pad(fields.minute),
|
|
4830
|
+
m: ({ fields }) => String(fields.minute),
|
|
4831
|
+
ss: ({ fields }) => pad(fields.second),
|
|
4832
|
+
s: ({ fields }) => String(fields.second),
|
|
4833
|
+
SSS: ({ fields }) => pad(fields.millisecond, 3),
|
|
4834
|
+
A: ({ fields, locale }) => dayPeriods(locale)[fields.hour < 12 ? 0 : 1],
|
|
4835
|
+
a: ({ fields, locale }) => dayPeriods(locale)[fields.hour < 12 ? 0 : 1].toLocaleLowerCase(locale),
|
|
4836
|
+
ZZ: ({ date, timeZone }) => formatOffset(offsetMinutes(date, timeZone), ""),
|
|
4837
|
+
Z: ({ date, timeZone }) => formatOffset(offsetMinutes(date, timeZone)),
|
|
4838
|
+
X: ({ date }) => String(Math.floor(date.getTime() / 1000)),
|
|
4839
|
+
x: ({ date }) => String(date.getTime()),
|
|
4840
|
+
};
|
|
4841
|
+
/**
|
|
4842
|
+
* Formats `date` with a moment-style pattern (see `tokens.ts`). Numbers are
|
|
4843
|
+
* always Latin digits; month, weekday and day-period names come from `Intl`
|
|
4844
|
+
* in the given locale.
|
|
4845
|
+
*/
|
|
4846
|
+
function formatPattern(date, pattern, locale, timeZone) {
|
|
4847
|
+
const context = { date, fields: getFields(date, timeZone), locale, timeZone };
|
|
4848
|
+
return tokenize(pattern)
|
|
4849
|
+
.map(part => ("token" in part ? FORMATTERS[part.token](context) : part.literal))
|
|
4850
|
+
.join("");
|
|
4851
|
+
}
|
|
4852
|
+
|
|
4853
|
+
const SECOND$1 = 1000;
|
|
4854
|
+
const MINUTE$1 = 60 * SECOND$1;
|
|
4855
|
+
const HOUR = 60 * MINUTE$1;
|
|
4856
|
+
const DAY = 24 * HOUR;
|
|
4857
|
+
const WEEK = 7 * DAY;
|
|
4858
|
+
const MONTH = 30 * DAY;
|
|
4859
|
+
const YEAR = 365 * DAY;
|
|
4860
|
+
const UNITS = [
|
|
4861
|
+
["year", YEAR],
|
|
4862
|
+
["month", MONTH],
|
|
4863
|
+
["week", WEEK],
|
|
4864
|
+
["day", DAY],
|
|
4865
|
+
["hour", HOUR],
|
|
4866
|
+
["minute", MINUTE$1],
|
|
4867
|
+
];
|
|
4868
|
+
/**
|
|
4869
|
+
* Formats `date` relative to `now` ("3 minutes ago", "in 2 days", "now").
|
|
4870
|
+
* Picks the largest unit that fits and truncates toward zero, so "5 minutes
|
|
4871
|
+
* ago" holds until the sixth minute has passed.
|
|
4872
|
+
*/
|
|
4873
|
+
function formatRelative(date, now, locale) {
|
|
4874
|
+
const diff = date.getTime() - now;
|
|
4875
|
+
const abs = Math.abs(diff);
|
|
4876
|
+
const [unit, size] = UNITS.find(([, size]) => abs >= size) ?? ["second", SECOND$1];
|
|
4877
|
+
// `|| 0` turns -0 into 0, which formats as "now" instead of "0 seconds ago".
|
|
4878
|
+
return relativeTimeFormat(locale).format(Math.trunc(diff / size) || 0, unit);
|
|
4879
|
+
}
|
|
4880
|
+
/**
|
|
4881
|
+
* How often a relative date needs re-rendering. Labels change fastest close to
|
|
4882
|
+
* now, so the cadence slows down as the date gets further away.
|
|
4883
|
+
*/
|
|
4884
|
+
function relativePeriod(date, now) {
|
|
4885
|
+
const abs = Math.abs(date.getTime() - now);
|
|
4886
|
+
if (abs < HOUR)
|
|
4887
|
+
return SECOND$1;
|
|
4888
|
+
if (abs < DAY)
|
|
4889
|
+
return MINUTE$1;
|
|
4890
|
+
return 15 * MINUTE$1;
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4893
|
+
const PRESETS = ["short", "medium", "long", "full"];
|
|
4894
|
+
const DEFAULT_PRESET = "medium";
|
|
4895
|
+
/**
|
|
4896
|
+
* Interprets the `format`, `date-style` and `time-style` attributes.
|
|
4897
|
+
*
|
|
4898
|
+
* - `relative` → relative time ("3 minutes ago").
|
|
4899
|
+
* - A preset name (`short`, `medium`, `long`, `full`) or empty → `Intl`
|
|
4900
|
+
* `dateStyle` + `timeStyle`, each overridable (or omitted with `none`).
|
|
4901
|
+
* - Anything else → a moment-style token pattern.
|
|
4902
|
+
*/
|
|
4903
|
+
function resolveFormat(format, dateStyle, timeStyle) {
|
|
4904
|
+
const value = format.trim();
|
|
4905
|
+
if (value === "relative")
|
|
4906
|
+
return { kind: "relative" };
|
|
4907
|
+
if (value && !PRESETS.includes(value))
|
|
4908
|
+
return { kind: "pattern", pattern: format };
|
|
4909
|
+
const preset = (value || DEFAULT_PRESET);
|
|
4910
|
+
const date = pickStyle(dateStyle, preset);
|
|
4911
|
+
const time = pickStyle(timeStyle, preset);
|
|
4912
|
+
// Both parts omitted would render nothing; keep the date.
|
|
4913
|
+
if (!date && !time)
|
|
4914
|
+
return { kind: "preset", dateStyle: preset };
|
|
4915
|
+
return { kind: "preset", dateStyle: date, timeStyle: time };
|
|
4916
|
+
}
|
|
4917
|
+
function pickStyle(override, preset) {
|
|
4918
|
+
if (override === "none")
|
|
4919
|
+
return undefined;
|
|
4920
|
+
return override && PRESETS.includes(override) ? override : preset;
|
|
4921
|
+
}
|
|
4922
|
+
/** Renders `date` according to a resolved format. */
|
|
4923
|
+
function formatDate(date, spec, { locale, timeZone, now }) {
|
|
4924
|
+
switch (spec.kind) {
|
|
4925
|
+
case "relative":
|
|
4926
|
+
return formatRelative(date, now, locale);
|
|
4927
|
+
case "pattern":
|
|
4928
|
+
return formatPattern(date, spec.pattern, locale, timeZone);
|
|
4929
|
+
case "preset":
|
|
4930
|
+
return dateTimeFormat(locale, { dateStyle: spec.dateStyle, timeStyle: spec.timeStyle, timeZone }).format(date);
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
/** A full, unambiguous rendering used for the tooltip of relative dates. */
|
|
4934
|
+
function formatFull(date, locale, timeZone) {
|
|
4935
|
+
return dateTimeFormat(locale, { dateStyle: "full", timeStyle: "long", timeZone }).format(date);
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
/**
|
|
4939
|
+
* Resolves the locale for an element: its `locale` attribute, then the
|
|
4940
|
+
* nearest `lang` attribute (crossing shadow roots), then the browser default
|
|
4941
|
+
* (`undefined`). Invalid tags are skipped.
|
|
4942
|
+
*/
|
|
4943
|
+
function resolveLocale(host, explicit) {
|
|
4944
|
+
return canonical(explicit) ?? canonical(closestLang(host));
|
|
4945
|
+
}
|
|
4946
|
+
function closestLang(host) {
|
|
4947
|
+
let node = host;
|
|
4948
|
+
while (node) {
|
|
4949
|
+
if (node instanceof Element) {
|
|
4950
|
+
const lang = node.closest("[lang]")?.getAttribute("lang");
|
|
4951
|
+
if (lang)
|
|
4952
|
+
return lang;
|
|
4953
|
+
}
|
|
4954
|
+
const root = node.getRootNode();
|
|
4955
|
+
node = root instanceof ShadowRoot ? root.host : null;
|
|
4956
|
+
}
|
|
4957
|
+
return "";
|
|
4958
|
+
}
|
|
4959
|
+
function canonical(tag) {
|
|
4960
|
+
if (!tag?.trim())
|
|
4961
|
+
return undefined;
|
|
4962
|
+
try {
|
|
4963
|
+
return Intl.getCanonicalLocales(tag.trim())[0];
|
|
4964
|
+
}
|
|
4965
|
+
catch {
|
|
4966
|
+
return undefined;
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
/**
|
|
4971
|
+
* Turns parsed fields into an instant, or `undefined` when a field is out of
|
|
4972
|
+
* range (e.g. month 13 or 31 February).
|
|
4973
|
+
*
|
|
4974
|
+
* Defaults follow moment: a missing year is the current one; when no date
|
|
4975
|
+
* part was given at all the date is today; a missing month/day is 1; missing
|
|
4976
|
+
* time fields are 0. Wall times are read in `timeZone` (local when unset)
|
|
4977
|
+
* unless the input carried its own offset.
|
|
4978
|
+
*/
|
|
4979
|
+
function assemble(parsed, { timeZone, now }) {
|
|
4980
|
+
if (parsed.timestamp !== undefined)
|
|
4981
|
+
return Number.isFinite(parsed.timestamp) ? new Date(parsed.timestamp) : undefined;
|
|
4982
|
+
const today = getFields(new Date(now), timeZone);
|
|
4983
|
+
const hasDate = parsed.year !== undefined || parsed.month !== undefined || parsed.day !== undefined;
|
|
4984
|
+
const fields = {
|
|
4985
|
+
year: parsed.year ?? today.year,
|
|
4986
|
+
month: parsed.month ?? (hasDate ? 1 : today.month),
|
|
4987
|
+
day: parsed.day ?? (hasDate ? 1 : today.day),
|
|
4988
|
+
hour: parsed.hour ?? 0,
|
|
4989
|
+
minute: parsed.minute ?? 0,
|
|
4990
|
+
second: parsed.second ?? 0,
|
|
4991
|
+
millisecond: parsed.millisecond ?? 0,
|
|
4992
|
+
};
|
|
4993
|
+
if (parsed.pm !== undefined) {
|
|
4994
|
+
if (fields.hour < 1 || fields.hour > 12)
|
|
4995
|
+
return undefined;
|
|
4996
|
+
fields.hour = (fields.hour % 12) + (parsed.pm ? 12 : 0);
|
|
4997
|
+
}
|
|
4998
|
+
if (!inRange(fields))
|
|
4999
|
+
return undefined;
|
|
5000
|
+
if (parsed.offset !== undefined)
|
|
5001
|
+
return new Date(utcFromFields(fields) - parsed.offset * 60_000);
|
|
5002
|
+
return fromFields(fields, timeZone);
|
|
5003
|
+
}
|
|
5004
|
+
function inRange(f) {
|
|
5005
|
+
return (Object.values(f).every(Number.isInteger) &&
|
|
5006
|
+
f.month >= 1 &&
|
|
5007
|
+
f.month <= 12 &&
|
|
5008
|
+
f.day >= 1 &&
|
|
5009
|
+
f.day <= daysInMonth(f.year, f.month) &&
|
|
5010
|
+
f.hour >= 0 &&
|
|
5011
|
+
f.hour <= 23 &&
|
|
5012
|
+
f.minute >= 0 &&
|
|
5013
|
+
f.minute <= 59 &&
|
|
5014
|
+
f.second >= 0 &&
|
|
5015
|
+
f.second <= 59 &&
|
|
5016
|
+
f.millisecond >= 0 &&
|
|
5017
|
+
f.millisecond <= 999);
|
|
5018
|
+
}
|
|
5019
|
+
/** Two-digit years: `00`-`68` → 2000s, `69`-`99` → 1900s (same pivot as moment). */
|
|
5020
|
+
function expandYear(digits) {
|
|
5021
|
+
const value = Number(digits);
|
|
5022
|
+
if (digits.length > 2)
|
|
5023
|
+
return value;
|
|
5024
|
+
return value + (value <= 68 ? 2000 : 1900);
|
|
5025
|
+
}
|
|
5026
|
+
/** Fractional seconds (`5`, `50`, `500`, `500123`) → milliseconds. */
|
|
5027
|
+
function fractionToMs(digits) {
|
|
5028
|
+
return Number(digits.slice(0, 3).padEnd(3, "0"));
|
|
5029
|
+
}
|
|
5030
|
+
/** `Z`, `+03:00`, `+0300` or `+03` → minutes east of UTC. */
|
|
5031
|
+
function parseOffset(value) {
|
|
5032
|
+
if (/^z$/i.test(value))
|
|
5033
|
+
return 0;
|
|
5034
|
+
const match = /^([+-])(\d{2}):?(\d{2})?$/.exec(value);
|
|
5035
|
+
if (!match)
|
|
5036
|
+
return undefined;
|
|
5037
|
+
const minutes = Number(match[2]) * 60 + Number(match[3] ?? 0);
|
|
5038
|
+
return match[1] === "-" ? -minutes : minutes;
|
|
5039
|
+
}
|
|
5040
|
+
|
|
5041
|
+
const ISO = /^([+-]\d{6}|\d{4})-(\d{2})(?:-(\d{2}))?(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:[.,](\d+))?)?\s*(Z|[+-]\d{2}(?::?\d{2})?)?)?$/i;
|
|
5042
|
+
const EPOCH = /^-?\d+$/;
|
|
5043
|
+
/**
|
|
5044
|
+
* Parses ISO 8601 (`2024-01-22`, `2024-01-22T14:30`, `2024-01-22T14:30:05.123+03:00`)
|
|
5045
|
+
* and epoch milliseconds (`1705923000000`).
|
|
5046
|
+
*
|
|
5047
|
+
* Unlike `Date.parse`, a date-only ISO string is a local (or `time-zone`) date
|
|
5048
|
+
* rather than UTC midnight, so `2024-01-22` never renders as the 21st.
|
|
5049
|
+
*/
|
|
5050
|
+
function parseIso(input) {
|
|
5051
|
+
if (EPOCH.test(input) && input.replace("-", "").length > 4)
|
|
5052
|
+
return { timestamp: Number(input) };
|
|
5053
|
+
const match = ISO.exec(input);
|
|
5054
|
+
if (!match)
|
|
5055
|
+
return undefined;
|
|
5056
|
+
const [, year, month, day, hour, minute, second, fraction, offset] = match;
|
|
5057
|
+
const parsed = {
|
|
5058
|
+
year: expandYear(year),
|
|
5059
|
+
month: Number(month),
|
|
5060
|
+
day: day === undefined ? 1 : Number(day),
|
|
5061
|
+
};
|
|
5062
|
+
if (hour !== undefined) {
|
|
5063
|
+
parsed.hour = Number(hour);
|
|
5064
|
+
parsed.minute = Number(minute);
|
|
5065
|
+
parsed.second = second === undefined ? 0 : Number(second);
|
|
5066
|
+
parsed.millisecond = fraction === undefined ? 0 : fractionToMs(fraction);
|
|
5067
|
+
}
|
|
5068
|
+
if (offset !== undefined) {
|
|
5069
|
+
parsed.offset = parseOffset(offset.toUpperCase());
|
|
5070
|
+
if (parsed.offset === undefined)
|
|
5071
|
+
return undefined;
|
|
5072
|
+
}
|
|
5073
|
+
return parsed;
|
|
5074
|
+
}
|
|
5075
|
+
|
|
5076
|
+
const NUMERIC = /^(\d{1,4})\s*[./-]\s*(\d{1,4})\s*[./-]\s*(\d{1,4})(?:(?:\s+|\s*[T,]\s*)(\d{1,2})[:.](\d{2})(?:[:.](\d{2}))?\s*(am|pm)?)?$/i;
|
|
5077
|
+
const orders = new Map();
|
|
5078
|
+
/**
|
|
5079
|
+
* Order of day, month and year in the locale's numeric date
|
|
5080
|
+
* (`en-US` → month/day/year, `tr`/`en-GB` → day/month/year, `ja` → year/month/day).
|
|
5081
|
+
*/
|
|
5082
|
+
function localeDateOrder(locale) {
|
|
5083
|
+
const key = locale ?? "";
|
|
5084
|
+
let order = orders.get(key);
|
|
5085
|
+
if (!order) {
|
|
5086
|
+
order = dateTimeFormat(locale, { timeZone: "UTC", year: "numeric", month: "numeric", day: "numeric" })
|
|
5087
|
+
.formatToParts(Date.UTC(2000, 0, 2))
|
|
5088
|
+
.map(part => part.type)
|
|
5089
|
+
.filter((type) => type === "year" || type === "month" || type === "day");
|
|
5090
|
+
orders.set(key, order);
|
|
5091
|
+
}
|
|
5092
|
+
return order;
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Fallback for numeric dates without an `input-format`, such as `22/01/2024`
|
|
5096
|
+
* or `22.01.2024 14:30`. Day, month and year are read in the locale's order,
|
|
5097
|
+
* so `01/02/2024` is 1 February in `tr` and January 2 in `en-US`. Values that
|
|
5098
|
+
* don't fit that order (day 22 as a US month) are rejected, never swapped.
|
|
5099
|
+
*/
|
|
5100
|
+
function parseNumeric(input, locale) {
|
|
5101
|
+
const match = NUMERIC.exec(input);
|
|
5102
|
+
const order = localeDateOrder(locale);
|
|
5103
|
+
if (!match || order.length !== 3)
|
|
5104
|
+
return undefined;
|
|
5105
|
+
const [, first, second, third, hour, minute, seconds, period] = match;
|
|
5106
|
+
const parsed = {};
|
|
5107
|
+
[first, second, third].forEach((value, index) => {
|
|
5108
|
+
const part = order[index];
|
|
5109
|
+
parsed[part] = part === "year" ? expandYear(value) : Number(value);
|
|
5110
|
+
});
|
|
5111
|
+
if (hour !== undefined) {
|
|
5112
|
+
parsed.hour = Number(hour);
|
|
5113
|
+
parsed.minute = Number(minute);
|
|
5114
|
+
parsed.second = seconds === undefined ? 0 : Number(seconds);
|
|
5115
|
+
if (period)
|
|
5116
|
+
parsed.pm = period.toLowerCase() === "pm";
|
|
5117
|
+
}
|
|
5118
|
+
return parsed;
|
|
5119
|
+
}
|
|
5120
|
+
|
|
5121
|
+
const number = (source, key) => ({
|
|
5122
|
+
source: () => source,
|
|
5123
|
+
apply: (parsed, value) => {
|
|
5124
|
+
parsed[key] = Number(value);
|
|
5125
|
+
},
|
|
5126
|
+
});
|
|
5127
|
+
const names = (list, key) => ({
|
|
5128
|
+
source: locale => alternation(list(locale)),
|
|
5129
|
+
apply: (parsed, value, locale) => {
|
|
5130
|
+
if (!key)
|
|
5131
|
+
return true;
|
|
5132
|
+
const index = indexOfName(list(locale), value, locale);
|
|
5133
|
+
if (index === -1)
|
|
5134
|
+
return false;
|
|
5135
|
+
parsed[key] = index + 1;
|
|
5136
|
+
return true;
|
|
5137
|
+
},
|
|
5138
|
+
});
|
|
5139
|
+
const period = {
|
|
5140
|
+
source: locale => alternation([...dayPeriods(locale), "am", "pm"]),
|
|
5141
|
+
apply: (parsed, value, locale) => {
|
|
5142
|
+
const [am, pm] = dayPeriods(locale).map(name => name.toLocaleLowerCase(locale));
|
|
5143
|
+
const lower = value.toLocaleLowerCase(locale);
|
|
5144
|
+
parsed.pm = lower === pm || lower === "pm" ? true : lower === am || lower === "am" ? false : undefined;
|
|
5145
|
+
},
|
|
5146
|
+
};
|
|
5147
|
+
const offset = {
|
|
5148
|
+
source: () => "Z|[+-]\\d{2}:?\\d{2}",
|
|
5149
|
+
apply: (parsed, value) => {
|
|
5150
|
+
parsed.offset = parseOffset(value.toUpperCase());
|
|
5151
|
+
},
|
|
5152
|
+
};
|
|
5153
|
+
/** Parsing is lenient like moment: padded tokens also accept one digit. */
|
|
5154
|
+
const RULES = {
|
|
5155
|
+
YYYY: { source: () => "[+-]?\\d{4,6}", apply: (parsed, value) => void (parsed.year = Number(value)) },
|
|
5156
|
+
YY: { source: () => "\\d{2}", apply: (parsed, value) => void (parsed.year = expandYear(value)) },
|
|
5157
|
+
MMMM: names(locale => monthNames(locale, "long"), "month"),
|
|
5158
|
+
MMM: names(locale => monthNames(locale, "short"), "month"),
|
|
5159
|
+
MM: number("\\d{1,2}", "month"),
|
|
5160
|
+
M: number("\\d{1,2}", "month"),
|
|
5161
|
+
DD: number("\\d{1,2}", "day"),
|
|
5162
|
+
D: number("\\d{1,2}", "day"),
|
|
5163
|
+
dddd: names(locale => weekdayNames(locale, "long")),
|
|
5164
|
+
ddd: names(locale => weekdayNames(locale, "short")),
|
|
5165
|
+
d: { source: () => "[0-6]", apply: () => undefined },
|
|
5166
|
+
HH: number("\\d{1,2}", "hour"),
|
|
5167
|
+
H: number("\\d{1,2}", "hour"),
|
|
5168
|
+
hh: number("\\d{1,2}", "hour"),
|
|
5169
|
+
h: number("\\d{1,2}", "hour"),
|
|
5170
|
+
mm: number("\\d{1,2}", "minute"),
|
|
5171
|
+
m: number("\\d{1,2}", "minute"),
|
|
5172
|
+
ss: number("\\d{1,2}", "second"),
|
|
5173
|
+
s: number("\\d{1,2}", "second"),
|
|
5174
|
+
SSS: { source: () => "\\d{1,9}", apply: (parsed, value) => void (parsed.millisecond = fractionToMs(value)) },
|
|
5175
|
+
A: period,
|
|
5176
|
+
a: period,
|
|
5177
|
+
ZZ: offset,
|
|
5178
|
+
Z: offset,
|
|
5179
|
+
X: { source: () => "-?\\d+(?:\\.\\d+)?", apply: (parsed, value) => void (parsed.timestamp = Math.round(Number(value) * 1000)) },
|
|
5180
|
+
x: { source: () => "-?\\d+", apply: (parsed, value) => void (parsed.timestamp = Number(value)) },
|
|
5181
|
+
};
|
|
5182
|
+
const cache = new Map();
|
|
5183
|
+
function compile(pattern, locale) {
|
|
5184
|
+
const key = `${locale ?? ""}|${pattern}`;
|
|
5185
|
+
let compiled = cache.get(key);
|
|
5186
|
+
if (!compiled) {
|
|
5187
|
+
const tokens = [];
|
|
5188
|
+
const source = tokenize(pattern)
|
|
5189
|
+
.map(part => {
|
|
5190
|
+
if ("literal" in part)
|
|
5191
|
+
return escape(part.literal).replace(/\s+/g, "\\s+");
|
|
5192
|
+
tokens.push(part.token);
|
|
5193
|
+
return `(${RULES[part.token].source(locale)})`;
|
|
5194
|
+
})
|
|
5195
|
+
.join("");
|
|
5196
|
+
compiled = { regex: new RegExp(`^${source}$`, "iu"), tokens };
|
|
5197
|
+
cache.set(key, compiled);
|
|
5198
|
+
}
|
|
5199
|
+
return compiled;
|
|
5200
|
+
}
|
|
5201
|
+
/**
|
|
5202
|
+
* Parses `input` with a moment-style pattern (`DD/MM/YYYY HH:mm`). Month,
|
|
5203
|
+
* weekday and AM/PM names are matched case-insensitively in `locale`;
|
|
5204
|
+
* whitespace in the pattern matches any run of whitespace.
|
|
5205
|
+
*/
|
|
5206
|
+
function parsePattern(input, pattern, locale) {
|
|
5207
|
+
const { regex, tokens } = compile(pattern, locale);
|
|
5208
|
+
const match = regex.exec(input);
|
|
5209
|
+
if (!match)
|
|
5210
|
+
return undefined;
|
|
5211
|
+
const parsed = {};
|
|
5212
|
+
for (const [index, token] of tokens.entries()) {
|
|
5213
|
+
if (RULES[token].apply(parsed, match[index + 1], locale) === false)
|
|
5214
|
+
return undefined;
|
|
5215
|
+
}
|
|
5216
|
+
if (parsed.pm !== undefined && !tokens.some(token => token === "h" || token === "hh")) {
|
|
5217
|
+
// AM/PM next to a 24-hour token: trust the 24-hour value.
|
|
5218
|
+
parsed.pm = undefined;
|
|
5219
|
+
}
|
|
5220
|
+
return parsed;
|
|
5221
|
+
}
|
|
5222
|
+
function alternation(list) {
|
|
5223
|
+
return [...new Set(list.filter(Boolean))]
|
|
5224
|
+
.sort((a, b) => b.length - a.length)
|
|
5225
|
+
.map(escape)
|
|
5226
|
+
.join("|");
|
|
5227
|
+
}
|
|
5228
|
+
function indexOfName(list, value, locale) {
|
|
5229
|
+
const lower = value.toLocaleLowerCase(locale);
|
|
5230
|
+
return list.findIndex(name => name.toLocaleLowerCase(locale) === lower);
|
|
5231
|
+
}
|
|
5232
|
+
function escape(text) {
|
|
5233
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5234
|
+
}
|
|
5235
|
+
|
|
5236
|
+
/**
|
|
5237
|
+
* Parses a date input. Returns `undefined` for empty or invalid input.
|
|
5238
|
+
*
|
|
5239
|
+
* - `Date` → used as is (if valid). `number` → epoch milliseconds.
|
|
5240
|
+
* - Strings with `inputFormat` → that pattern only.
|
|
5241
|
+
* - Other strings → ISO 8601 / epoch ms, then a numeric date in the locale's
|
|
5242
|
+
* day/month/year order (`22/01/2024`, `22.01.2024 14:30`).
|
|
5243
|
+
*/
|
|
5244
|
+
function parseDate(input, options) {
|
|
5245
|
+
if (input instanceof Date)
|
|
5246
|
+
return valid(new Date(input.getTime()));
|
|
5247
|
+
if (typeof input === "number")
|
|
5248
|
+
return valid(new Date(input));
|
|
5249
|
+
const text = input?.trim();
|
|
5250
|
+
if (!text)
|
|
5251
|
+
return undefined;
|
|
5252
|
+
const parsed = options.inputFormat?.trim()
|
|
5253
|
+
? parsePattern(text, options.inputFormat, options.locale)
|
|
5254
|
+
: (parseIso(text) ?? parseNumeric(text, options.locale));
|
|
5255
|
+
return valid(parsed && assemble(parsed, options));
|
|
5256
|
+
}
|
|
5257
|
+
/** Drops `Invalid Date`s (NaN, or beyond the ±8.64e15 ms range `Date` supports). */
|
|
5258
|
+
function valid(date) {
|
|
5259
|
+
return date && !Number.isNaN(date.getTime()) ? date : undefined;
|
|
5260
|
+
}
|
|
5261
|
+
|
|
5262
|
+
const SECOND = 1000;
|
|
5263
|
+
const MINUTE = 60 * SECOND;
|
|
5264
|
+
/**
|
|
5265
|
+
* Tick periods per unit. Hour and day changes are checked every 15 minutes:
|
|
5266
|
+
* every current UTC offset is a multiple of 15 minutes, so a 15-minute,
|
|
5267
|
+
* epoch-aligned tick lands exactly on every zone's hour and midnight.
|
|
5268
|
+
* Milliseconds tick at ~20 fps; faster is invisible.
|
|
5269
|
+
*/
|
|
5270
|
+
const PERIODS = {
|
|
5271
|
+
millisecond: 50,
|
|
5272
|
+
second: SECOND,
|
|
5273
|
+
minute: MINUTE,
|
|
5274
|
+
hour: 15 * MINUTE,
|
|
5275
|
+
day: 15 * MINUTE,
|
|
5276
|
+
};
|
|
5277
|
+
const TOKEN_UNITS = {
|
|
5278
|
+
SSS: "millisecond",
|
|
5279
|
+
x: "millisecond",
|
|
5280
|
+
ss: "second",
|
|
5281
|
+
s: "second",
|
|
5282
|
+
X: "second",
|
|
5283
|
+
mm: "minute",
|
|
5284
|
+
m: "minute",
|
|
5285
|
+
HH: "hour",
|
|
5286
|
+
H: "hour",
|
|
5287
|
+
hh: "hour",
|
|
5288
|
+
h: "hour",
|
|
5289
|
+
A: "hour",
|
|
5290
|
+
a: "hour",
|
|
5291
|
+
// Offsets change at DST transitions, which happen on the hour.
|
|
5292
|
+
ZZ: "hour",
|
|
5293
|
+
Z: "hour",
|
|
5294
|
+
};
|
|
5295
|
+
const TIME_STYLE_UNITS = {
|
|
5296
|
+
short: "minute",
|
|
5297
|
+
medium: "second",
|
|
5298
|
+
long: "second",
|
|
5299
|
+
full: "second",
|
|
5300
|
+
};
|
|
5301
|
+
/**
|
|
5302
|
+
* How often (ms) a date rendered with `spec` can change. Ticks are aligned to
|
|
5303
|
+
* multiples of this period, so second/minute changes show up exactly on time.
|
|
5304
|
+
*/
|
|
5305
|
+
function tickPeriod(spec, date, now) {
|
|
5306
|
+
switch (spec.kind) {
|
|
5307
|
+
case "relative":
|
|
5308
|
+
return relativePeriod(date, now);
|
|
5309
|
+
case "preset":
|
|
5310
|
+
return PERIODS[spec.timeStyle ? TIME_STYLE_UNITS[spec.timeStyle] : "day"];
|
|
5311
|
+
case "pattern":
|
|
5312
|
+
return Math.min(PERIODS.day, ...tokenize(spec.pattern).map(part => ("token" in part ? PERIODS[TOKEN_UNITS[part.token] ?? "day"] : PERIODS.day)));
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
|
|
5316
|
+
const dateStyles = css `
|
|
5317
|
+
:host {
|
|
5318
|
+
display: inline;
|
|
5319
|
+
}
|
|
5320
|
+
|
|
5321
|
+
:host([hidden]) {
|
|
5322
|
+
display: none;
|
|
5323
|
+
}
|
|
5324
|
+
|
|
5325
|
+
/* Tabular digits keep live dates from jittering as numbers change. */
|
|
5326
|
+
time {
|
|
5327
|
+
font-variant-numeric: var(--tp-date-numeric, tabular-nums);
|
|
5328
|
+
}
|
|
5329
|
+
`;
|
|
5330
|
+
|
|
5331
|
+
/**
|
|
5332
|
+
* One shared clock for every `<tp-date>`. Elements subscribe with the period
|
|
5333
|
+
* they need; each period gets a single timer aligned to its boundaries (e.g.
|
|
5334
|
+
* the start of every minute), so a page full of dates updates in sync with a
|
|
5335
|
+
* handful of timers. `setTimeout` is re-armed from the real clock on every
|
|
5336
|
+
* tick, so it never drifts the way `setInterval` does.
|
|
5337
|
+
*
|
|
5338
|
+
* Timers stop while the document is hidden and every subscriber is notified
|
|
5339
|
+
* right away when it becomes visible again.
|
|
5340
|
+
*/
|
|
5341
|
+
const channels = new Map();
|
|
5342
|
+
let visibilityBound = false;
|
|
5343
|
+
/** Subscribes `listener` to ticks every `period` ms. Returns the unsubscribe function. */
|
|
5344
|
+
function subscribe(period, listener) {
|
|
5345
|
+
let channel = channels.get(period);
|
|
5346
|
+
if (!channel) {
|
|
5347
|
+
channel = { listeners: new Set() };
|
|
5348
|
+
channels.set(period, channel);
|
|
5349
|
+
}
|
|
5350
|
+
channel.listeners.add(listener);
|
|
5351
|
+
bindVisibility();
|
|
5352
|
+
arm(period, channel);
|
|
5353
|
+
return () => {
|
|
5354
|
+
channel.listeners.delete(listener);
|
|
5355
|
+
if (channel.listeners.size === 0) {
|
|
5356
|
+
clearTimeout(channel.timer);
|
|
5357
|
+
channels.delete(period);
|
|
5358
|
+
}
|
|
5359
|
+
};
|
|
5360
|
+
}
|
|
5361
|
+
function arm(period, channel) {
|
|
5362
|
+
if (channel.timer !== undefined || isHidden())
|
|
5363
|
+
return;
|
|
5364
|
+
channel.timer = setTimeout(() => {
|
|
5365
|
+
channel.timer = undefined;
|
|
5366
|
+
notify(channel);
|
|
5367
|
+
if (channels.get(period) === channel)
|
|
5368
|
+
arm(period, channel);
|
|
5369
|
+
}, period - (Date.now() % period));
|
|
5370
|
+
}
|
|
5371
|
+
function notify(channel) {
|
|
5372
|
+
for (const listener of [...channel.listeners])
|
|
5373
|
+
listener();
|
|
5374
|
+
}
|
|
5375
|
+
function isHidden() {
|
|
5376
|
+
return typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
5377
|
+
}
|
|
5378
|
+
function bindVisibility() {
|
|
5379
|
+
if (visibilityBound || typeof document === "undefined")
|
|
5380
|
+
return;
|
|
5381
|
+
visibilityBound = true;
|
|
5382
|
+
document.addEventListener("visibilitychange", () => {
|
|
5383
|
+
// Snapshot: listeners may move to another period while being notified.
|
|
5384
|
+
for (const [period, channel] of [...channels]) {
|
|
5385
|
+
if (isHidden()) {
|
|
5386
|
+
clearTimeout(channel.timer);
|
|
5387
|
+
channel.timer = undefined;
|
|
5388
|
+
}
|
|
5389
|
+
else {
|
|
5390
|
+
notify(channel);
|
|
5391
|
+
if (channels.get(period) === channel)
|
|
5392
|
+
arm(period, channel);
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5395
|
+
});
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
/** Lower bound for a custom `interval`, roughly one frame. */
|
|
5399
|
+
const MIN_INTERVAL = 16;
|
|
5400
|
+
/** Inputs that change which instant is shown. */
|
|
5401
|
+
const SOURCE_KEYS = ["value", "datetime", "text", "inputFormat", "locale", "timeZone"];
|
|
5402
|
+
/**
|
|
5403
|
+
* `<tp-date>` — a localized, optionally live date/time.
|
|
5404
|
+
*
|
|
5405
|
+
* - **Source** (first non-empty wins): the `value` property, the `datetime`
|
|
5406
|
+
* attribute, the text content. Accepts ISO 8601, epoch milliseconds, or a
|
|
5407
|
+
* numeric date in the locale's order (`22/01/2024` in `tr`); `input-format`
|
|
5408
|
+
* pins a moment-style pattern instead.
|
|
5409
|
+
* - **Fallback**: empty or invalid input renders the current time. Invalid
|
|
5410
|
+
* input also sets the `invalid` attribute and fires `tp-date-invalid`.
|
|
5411
|
+
* - **Format**: a preset (`short` / `medium` / `long` / `full`, via `Intl`),
|
|
5412
|
+
* `relative`, or a moment-style pattern such as `DD/MM/YYYY HH:mm`.
|
|
5413
|
+
* - **Live updates**: the current time and relative dates re-render on a
|
|
5414
|
+
* shared, boundary-aligned clock at the cadence the format needs (each
|
|
5415
|
+
* second for `ss`, each minute for `mm`, ...). Fixed dates in an absolute
|
|
5416
|
+
* format never tick. Ticking pauses while the tab is hidden.
|
|
5417
|
+
* - The text content stays in light DOM as the no-JS / pre-upgrade fallback;
|
|
5418
|
+
* the rendered value is a `<time datetime>` in shadow DOM.
|
|
5419
|
+
*
|
|
5420
|
+
* @element tp-date
|
|
5421
|
+
*
|
|
5422
|
+
* @attr {string} [format=""] - `short`, `medium` (default), `long`, `full`, `relative`, or a moment-style pattern.
|
|
5423
|
+
* @attr {"short" | "medium" | "long" | "full" | "none"} date-style - Presets only. Overrides the date part; `none` omits it.
|
|
5424
|
+
* @attr {"short" | "medium" | "long" | "full" | "none"} time-style - Presets only. Overrides the time part; `none` omits it.
|
|
5425
|
+
* @attr {string} [input-format=""] - Moment-style pattern used to parse the input, e.g. `DD/MM/YYYY`.
|
|
5426
|
+
* @attr {string} [datetime=""] - The date to show. Takes precedence over the text content.
|
|
5427
|
+
* @attr {string} [locale=""] - BCP 47 locale. Defaults to the nearest `lang` attribute, then the browser.
|
|
5428
|
+
* @attr {string} [time-zone=""] - IANA time zone (`UTC`, `Europe/Istanbul`) for display and for parsing wall times. Defaults to local.
|
|
5429
|
+
* @attr {boolean} [live=false] - Forces ticking even for a fixed date in an absolute format.
|
|
5430
|
+
* @attr {number} [interval=0] - Custom tick period in ms. `0` derives it from the format.
|
|
5431
|
+
* @attr {boolean} invalid - Read-only. Present when the input could not be parsed.
|
|
5432
|
+
*
|
|
5433
|
+
* @fires tp-date-invalid - When a non-empty input cannot be parsed. `detail: { input }`.
|
|
5434
|
+
*
|
|
5435
|
+
* @csspart time - The rendered `<time>` element.
|
|
5436
|
+
*
|
|
5437
|
+
* @cssprop --tp-date-numeric - `font-variant-numeric` of the output. Defaults to `tabular-nums`.
|
|
5438
|
+
*/
|
|
5439
|
+
class DateElement extends LitElement {
|
|
5440
|
+
constructor() {
|
|
5441
|
+
super(...arguments);
|
|
5442
|
+
/** `short`, `medium` (default), `long`, `full`, `relative`, or a moment-style pattern. */
|
|
5443
|
+
this.format = "";
|
|
5444
|
+
/** Moment-style pattern used to parse string input. */
|
|
5445
|
+
this.inputFormat = "";
|
|
5446
|
+
/** The date to show as a string. Takes precedence over the text content. */
|
|
5447
|
+
this.datetime = "";
|
|
5448
|
+
/** BCP 47 locale. Defaults to the nearest `lang` attribute, then the browser. */
|
|
5449
|
+
this.locale = "";
|
|
5450
|
+
/** IANA time zone. Defaults to the local zone. */
|
|
5451
|
+
this.timeZone = "";
|
|
5452
|
+
/** Forces ticking even for a fixed date in an absolute format. */
|
|
5453
|
+
this.live = false;
|
|
5454
|
+
/** Custom tick period in ms. `0` derives it from the format. */
|
|
5455
|
+
this.interval = 0;
|
|
5456
|
+
/** Read-only. `true` when the input could not be parsed (the current time is shown instead). */
|
|
5457
|
+
this.invalid = false;
|
|
5458
|
+
/** Text content of the light DOM. */
|
|
5459
|
+
this.text = "";
|
|
5460
|
+
this.#now = Date.now();
|
|
5461
|
+
this.#period = 0;
|
|
5462
|
+
}
|
|
5463
|
+
static { this.styles = dateStyles; }
|
|
5464
|
+
#fixed;
|
|
5465
|
+
#now;
|
|
5466
|
+
#observer;
|
|
5467
|
+
#unsubscribe;
|
|
5468
|
+
#period;
|
|
5469
|
+
#invalidInput;
|
|
5470
|
+
#lastInvalid;
|
|
5471
|
+
/** The instant currently shown (the parsed input, or the current time). */
|
|
5472
|
+
get date() {
|
|
5473
|
+
return new Date(this.#fixed?.getTime() ?? this.#now);
|
|
5474
|
+
}
|
|
5475
|
+
connectedCallback() {
|
|
5476
|
+
super.connectedCallback();
|
|
5477
|
+
this.#observer ??= new MutationObserver(() => this.#syncText());
|
|
5478
|
+
this.#observer.observe(this, { childList: true, characterData: true, subtree: true });
|
|
5479
|
+
this.#syncText();
|
|
5480
|
+
// Re-subscribe to the ticker after a reconnect.
|
|
5481
|
+
this.requestUpdate();
|
|
5482
|
+
}
|
|
5483
|
+
disconnectedCallback() {
|
|
5484
|
+
super.disconnectedCallback();
|
|
5485
|
+
this.#observer?.disconnect();
|
|
5486
|
+
this.#setPeriod(0);
|
|
5487
|
+
}
|
|
5488
|
+
willUpdate(changed) {
|
|
5489
|
+
this.#now = Date.now();
|
|
5490
|
+
if (SOURCE_KEYS.some(key => changed.has(key)))
|
|
5491
|
+
this.#parse();
|
|
5492
|
+
}
|
|
5493
|
+
render() {
|
|
5494
|
+
const spec = this.#spec();
|
|
5495
|
+
const date = this.date;
|
|
5496
|
+
const locale = this.#locale();
|
|
5497
|
+
const timeZone = this.#timeZone();
|
|
5498
|
+
return html$1 `<time
|
|
5499
|
+
part="time"
|
|
5500
|
+
datetime=${date.toISOString()}
|
|
5501
|
+
title=${spec.kind === "relative" ? formatFull(date, locale, timeZone) : nothing}
|
|
5502
|
+
>${formatDate(date, spec, { locale, timeZone, now: this.#now })}</time
|
|
5503
|
+
>`;
|
|
5504
|
+
}
|
|
5505
|
+
updated() {
|
|
5506
|
+
this.#schedule();
|
|
5507
|
+
if (this.#invalidInput !== undefined) {
|
|
5508
|
+
const input = this.#invalidInput;
|
|
5509
|
+
this.#invalidInput = undefined;
|
|
5510
|
+
this.dispatchEvent(new CustomEvent("tp-date-invalid", { bubbles: true, composed: true, detail: { input } }));
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
#parse() {
|
|
5514
|
+
const input = this.value ?? (this.datetime.trim() || this.text);
|
|
5515
|
+
const fixed = parseDate(input, {
|
|
5516
|
+
inputFormat: this.inputFormat,
|
|
5517
|
+
locale: this.#locale(),
|
|
5518
|
+
timeZone: this.#timeZone(),
|
|
5519
|
+
now: this.#now,
|
|
5520
|
+
});
|
|
5521
|
+
const empty = input === null || input === undefined || (typeof input === "string" && !input.trim());
|
|
5522
|
+
const invalid = !fixed && !empty;
|
|
5523
|
+
const key = String(input);
|
|
5524
|
+
// Fire once per distinct invalid input, not on every re-parse.
|
|
5525
|
+
if (invalid && key !== this.#lastInvalid)
|
|
5526
|
+
this.#invalidInput = key;
|
|
5527
|
+
this.#lastInvalid = invalid ? key : undefined;
|
|
5528
|
+
this.#fixed = fixed;
|
|
5529
|
+
this.invalid = invalid;
|
|
5530
|
+
}
|
|
5531
|
+
#spec() {
|
|
5532
|
+
return resolveFormat(this.format, this.dateStyle, this.timeStyle);
|
|
5533
|
+
}
|
|
5534
|
+
#locale() {
|
|
5535
|
+
return resolveLocale(this, this.locale);
|
|
5536
|
+
}
|
|
5537
|
+
#timeZone() {
|
|
5538
|
+
const zone = this.timeZone.trim();
|
|
5539
|
+
return zone && isValidTimeZone(zone) ? zone : undefined;
|
|
5540
|
+
}
|
|
5541
|
+
/** Subscribes to the shared ticker at the cadence the current format needs, or not at all. */
|
|
5542
|
+
#schedule() {
|
|
5543
|
+
const spec = this.#spec();
|
|
5544
|
+
const live = this.live || !this.#fixed || spec.kind === "relative";
|
|
5545
|
+
if (!this.isConnected || !live)
|
|
5546
|
+
return this.#setPeriod(0);
|
|
5547
|
+
const interval = Number(this.interval);
|
|
5548
|
+
this.#setPeriod(interval > 0 ? Math.max(interval, MIN_INTERVAL) : tickPeriod(spec, this.date, this.#now));
|
|
5549
|
+
}
|
|
5550
|
+
#setPeriod(period) {
|
|
5551
|
+
if (period === this.#period)
|
|
5552
|
+
return;
|
|
5553
|
+
this.#unsubscribe?.();
|
|
5554
|
+
this.#unsubscribe = undefined;
|
|
5555
|
+
this.#period = period;
|
|
5556
|
+
if (period)
|
|
5557
|
+
this.#unsubscribe = subscribe(period, () => this.requestUpdate());
|
|
5558
|
+
}
|
|
5559
|
+
#syncText() {
|
|
5560
|
+
this.text = (this.textContent ?? "").trim();
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
__decorate([
|
|
5564
|
+
property(),
|
|
5565
|
+
__metadata("design:type", Object)
|
|
5566
|
+
], DateElement.prototype, "format", void 0);
|
|
5567
|
+
__decorate([
|
|
5568
|
+
property({ attribute: "date-style" }),
|
|
5569
|
+
__metadata("design:type", String)
|
|
5570
|
+
], DateElement.prototype, "dateStyle", void 0);
|
|
5571
|
+
__decorate([
|
|
5572
|
+
property({ attribute: "time-style" }),
|
|
5573
|
+
__metadata("design:type", String)
|
|
5574
|
+
], DateElement.prototype, "timeStyle", void 0);
|
|
5575
|
+
__decorate([
|
|
5576
|
+
property({ attribute: "input-format" }),
|
|
5577
|
+
__metadata("design:type", Object)
|
|
5578
|
+
], DateElement.prototype, "inputFormat", void 0);
|
|
5579
|
+
__decorate([
|
|
5580
|
+
property(),
|
|
5581
|
+
__metadata("design:type", Object)
|
|
5582
|
+
], DateElement.prototype, "datetime", void 0);
|
|
5583
|
+
__decorate([
|
|
5584
|
+
property(),
|
|
5585
|
+
__metadata("design:type", Object)
|
|
5586
|
+
], DateElement.prototype, "locale", void 0);
|
|
5587
|
+
__decorate([
|
|
5588
|
+
property({ attribute: "time-zone" }),
|
|
5589
|
+
__metadata("design:type", Object)
|
|
5590
|
+
], DateElement.prototype, "timeZone", void 0);
|
|
5591
|
+
__decorate([
|
|
5592
|
+
property({ type: Boolean, reflect: true }),
|
|
5593
|
+
__metadata("design:type", Object)
|
|
5594
|
+
], DateElement.prototype, "live", void 0);
|
|
5595
|
+
__decorate([
|
|
5596
|
+
property({ type: Number }),
|
|
5597
|
+
__metadata("design:type", Object)
|
|
5598
|
+
], DateElement.prototype, "interval", void 0);
|
|
5599
|
+
__decorate([
|
|
5600
|
+
property({ attribute: false }),
|
|
5601
|
+
__metadata("design:type", Object)
|
|
5602
|
+
], DateElement.prototype, "value", void 0);
|
|
5603
|
+
__decorate([
|
|
5604
|
+
property({ type: Boolean, reflect: true }),
|
|
5605
|
+
__metadata("design:type", Object)
|
|
5606
|
+
], DateElement.prototype, "invalid", void 0);
|
|
5607
|
+
__decorate([
|
|
5608
|
+
state(),
|
|
5609
|
+
__metadata("design:type", Object)
|
|
5610
|
+
], DateElement.prototype, "text", void 0);
|
|
5611
|
+
if (!customElements.get("tp-date"))
|
|
5612
|
+
customElements.define("tp-date", DateElement);
|
|
5613
|
+
|
|
5614
|
+
export { ButtonElement, DateElement, DetailsSetElement, DragDropEvent, DragElement, DragHandleElement, DropZoneElement, OptionElement, PopoverElement, PortalElement, PortalOutletElement, PortalOutletFallbackElement, ROUTE_ERROR_EVENT, ROUTE_LOAD_EVENT, RouteElement, RouterConfigElement, RouterElement, RouterLinkElement, RouterOutletElement, RouterParamElement, SelectChangeEvent, SelectElement, SelectedContentElement, defaultRouteSourceLoader, formatDate, formatPattern, formatRelative, parseDate, resolveFormat };
|
|
4542
5615
|
//# sourceMappingURL=elements.mjs.map
|