cally 0.2.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/LICENSE +7 -0
- package/README.md +38 -0
- package/dist/cally.js +1163 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024-present Nick Williams
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Cally
|
|
2
|
+
|
|
3
|
+
Small, feature-rich of calendar components
|
|
4
|
+
|
|
5
|
+
- **Small bundle size** - less than 9kb min/gzip
|
|
6
|
+
- **Full feature set** - single dates, ranges, display multiple months
|
|
7
|
+
- **HTML-friendly** - easy to author, framework-independent
|
|
8
|
+
- **Minimal dependencies** - just one
|
|
9
|
+
- **Accessible** - keyboard and screen reader
|
|
10
|
+
- **Localizable** - `Intl.DateTimeFormat`, CSS logical properties, RTL support
|
|
11
|
+
- **Themeable** - CSS parts and custom properties to offer flexibility and power
|
|
12
|
+
- **Composable** - impose no DOM specific structure, play well with others
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install cally
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import "cally";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage with CDN
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<script src="https://unpkg.com/cally"></script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Docs
|
|
33
|
+
|
|
34
|
+
Coming soon.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
package/dist/cally.js
ADDED
|
@@ -0,0 +1,1163 @@
|
|
|
1
|
+
class ne {
|
|
2
|
+
/**
|
|
3
|
+
* @type {T}
|
|
4
|
+
*/
|
|
5
|
+
#t;
|
|
6
|
+
#e = /* @__PURE__ */ new Set();
|
|
7
|
+
/**
|
|
8
|
+
* @param {T} current
|
|
9
|
+
*/
|
|
10
|
+
constructor(t) {
|
|
11
|
+
this.#t = t;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @return {T}
|
|
15
|
+
*/
|
|
16
|
+
get current() {
|
|
17
|
+
return this.#t;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param {T} value
|
|
21
|
+
*/
|
|
22
|
+
set current(t) {
|
|
23
|
+
this.#t != t && (this.#t = t, this.#e.forEach((n) => n(t)));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @type {import("hooks").Ref["on"]}
|
|
27
|
+
*/
|
|
28
|
+
on(t) {
|
|
29
|
+
return this.#e.add(t), () => this.#e.delete(t);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const Ct = (e) => new ne(e), Q = Symbol.for("atomico.hooks");
|
|
33
|
+
globalThis[Q] = globalThis[Q] || {};
|
|
34
|
+
let M = globalThis[Q];
|
|
35
|
+
const se = Symbol.for("Atomico.suspense"), Nt = Symbol.for("Atomico.effect"), oe = Symbol.for("Atomico.layoutEffect"), Pt = Symbol.for("Atomico.insertionEffect"), A = (e, t, n) => {
|
|
36
|
+
const { i: s, hooks: o } = M.c, r = o[s] = o[s] || {};
|
|
37
|
+
return r.value = e(r.value), r.effect = t, r.tag = n, M.c.i++, o[s].value;
|
|
38
|
+
}, re = (e) => A((t = Ct(e)) => t), I = () => A((e = Ct(M.c.host)) => e), Mt = () => M.c.update, ie = (e, t, n = 0) => {
|
|
39
|
+
let s = {}, o = !1;
|
|
40
|
+
const r = () => o, i = (f, u) => {
|
|
41
|
+
for (const d in s) {
|
|
42
|
+
const c = s[d];
|
|
43
|
+
c.effect && c.tag === f && (c.value = c.effect(c.value, u));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return { load: (f) => {
|
|
47
|
+
M.c = { host: t, hooks: s, update: e, i: 0, id: n };
|
|
48
|
+
let u;
|
|
49
|
+
try {
|
|
50
|
+
o = !1, u = f();
|
|
51
|
+
} catch (d) {
|
|
52
|
+
if (d !== se)
|
|
53
|
+
throw d;
|
|
54
|
+
o = !0;
|
|
55
|
+
} finally {
|
|
56
|
+
M.c = null;
|
|
57
|
+
}
|
|
58
|
+
return u;
|
|
59
|
+
}, cleanEffects: (f) => (i(Pt, f), () => (i(oe, f), () => {
|
|
60
|
+
i(Nt, f);
|
|
61
|
+
})), isSuspense: r };
|
|
62
|
+
}, R = Symbol.for;
|
|
63
|
+
function At(e, t) {
|
|
64
|
+
const n = e.length;
|
|
65
|
+
if (n !== t.length)
|
|
66
|
+
return !1;
|
|
67
|
+
for (let s = 0; s < n; s++) {
|
|
68
|
+
let o = e[s], r = t[s];
|
|
69
|
+
if (o !== r)
|
|
70
|
+
return !1;
|
|
71
|
+
}
|
|
72
|
+
return !0;
|
|
73
|
+
}
|
|
74
|
+
const S = (e) => typeof e == "function", k = (e) => typeof e == "object", { isArray: ce } = Array, V = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
|
|
75
|
+
function Rt(e, t) {
|
|
76
|
+
let n;
|
|
77
|
+
const s = (o) => {
|
|
78
|
+
let { length: r } = o;
|
|
79
|
+
for (let i = 0; i < r; i++) {
|
|
80
|
+
const a = o[i];
|
|
81
|
+
if (a && Array.isArray(a))
|
|
82
|
+
s(a);
|
|
83
|
+
else {
|
|
84
|
+
const l = typeof a;
|
|
85
|
+
if (a == null || l === "function" || l === "boolean")
|
|
86
|
+
continue;
|
|
87
|
+
l === "string" || l === "number" ? (n == null && (n = ""), n += a) : (n != null && (t(n), n = null), t(a));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
s(e), n != null && t(n);
|
|
92
|
+
}
|
|
93
|
+
const Ft = (e, t, n) => (e.addEventListener(t, n), () => e.removeEventListener(t, n));
|
|
94
|
+
class Ot {
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {HTMLElement} target
|
|
98
|
+
* @param {string} message
|
|
99
|
+
* @param {string} value
|
|
100
|
+
*/
|
|
101
|
+
constructor(t, n, s) {
|
|
102
|
+
this.message = n, this.target = t, this.value = s;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
class kt extends Ot {
|
|
106
|
+
}
|
|
107
|
+
class ae extends Ot {
|
|
108
|
+
}
|
|
109
|
+
const Y = "Custom", ue = null, le = { true: 1, "": 1, 1: 1 };
|
|
110
|
+
function fe(e, t, n, s, o) {
|
|
111
|
+
const {
|
|
112
|
+
type: r,
|
|
113
|
+
reflect: i,
|
|
114
|
+
event: a,
|
|
115
|
+
value: l,
|
|
116
|
+
attr: f = de(t)
|
|
117
|
+
} = n?.name != Y && k(n) && n != ue ? n : { type: n }, u = r?.name === Y && r.map, d = l != null ? r == Function || !S(l) ? () => l : l : null;
|
|
118
|
+
Object.defineProperty(e, t, {
|
|
119
|
+
configurable: !0,
|
|
120
|
+
/**
|
|
121
|
+
* @this {import("dom").AtomicoThisInternal}
|
|
122
|
+
* @param {any} newValue
|
|
123
|
+
*/
|
|
124
|
+
set(c) {
|
|
125
|
+
const h = this[t];
|
|
126
|
+
d && r != Boolean && c == null && (c = d());
|
|
127
|
+
const { error: y, value: m } = (u ? ye : be)(
|
|
128
|
+
r,
|
|
129
|
+
c
|
|
130
|
+
);
|
|
131
|
+
if (y && m != null)
|
|
132
|
+
throw new kt(
|
|
133
|
+
this,
|
|
134
|
+
`The value defined for prop '${t}' must be of type '${r.name}'`,
|
|
135
|
+
m
|
|
136
|
+
);
|
|
137
|
+
h != m && (this._props[t] = m ?? void 0, this.update(), a && Ut(this, a), this.updated.then(() => {
|
|
138
|
+
i && (this._ignoreAttr = f, he(this, r, f, this[t]), this._ignoreAttr = null);
|
|
139
|
+
}));
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* @this {import("dom").AtomicoThisInternal}
|
|
143
|
+
*/
|
|
144
|
+
get() {
|
|
145
|
+
return this._props[t];
|
|
146
|
+
}
|
|
147
|
+
}), d && (o[t] = d()), s[f] = { prop: t, type: r };
|
|
148
|
+
}
|
|
149
|
+
const Ut = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), de = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), he = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute(
|
|
150
|
+
n,
|
|
151
|
+
t?.name === Y && t?.serialize ? t?.serialize(s) : k(s) ? JSON.stringify(s) : t == Boolean ? "" : s
|
|
152
|
+
), me = (e, t) => e == Boolean ? !!le[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == Y ? t : (
|
|
153
|
+
// TODO: If when defining reflect the prop can also be of type string?
|
|
154
|
+
new e(t)
|
|
155
|
+
), ye = ({ map: e }, t) => {
|
|
156
|
+
try {
|
|
157
|
+
return { value: e(t), error: !1 };
|
|
158
|
+
} catch {
|
|
159
|
+
return { value: t, error: !0 };
|
|
160
|
+
}
|
|
161
|
+
}, be = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
|
|
162
|
+
value: t,
|
|
163
|
+
error: {}.toString.call(t) !== `[object ${e.name}]`
|
|
164
|
+
} : t instanceof e ? {
|
|
165
|
+
value: t,
|
|
166
|
+
error: e == Number && Number.isNaN(t.valueOf())
|
|
167
|
+
} : e == String || e == Number || e == Boolean ? {
|
|
168
|
+
value: t,
|
|
169
|
+
error: e == Number ? typeof t != "number" ? !0 : Number.isNaN(t) : e == String ? typeof t != "string" : typeof t != "boolean"
|
|
170
|
+
} : { value: t, error: !0 };
|
|
171
|
+
let pe = 0;
|
|
172
|
+
const ge = (e) => {
|
|
173
|
+
const t = (e?.dataset || {})?.hydrate || "";
|
|
174
|
+
return t || "c" + pe++;
|
|
175
|
+
}, $ = (e, t = HTMLElement) => {
|
|
176
|
+
const n = {}, s = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: i, styles: a } = o ? e : t;
|
|
177
|
+
class l extends r {
|
|
178
|
+
constructor() {
|
|
179
|
+
super(), this._setup(), this._render = () => e({ ...this._props });
|
|
180
|
+
for (const u in s)
|
|
181
|
+
this[u] = s[u];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @returns {import("core").Sheets[]}
|
|
185
|
+
*/
|
|
186
|
+
static get styles() {
|
|
187
|
+
return [super.styles, a];
|
|
188
|
+
}
|
|
189
|
+
async _setup() {
|
|
190
|
+
if (this._props)
|
|
191
|
+
return;
|
|
192
|
+
this._props = {};
|
|
193
|
+
let u, d;
|
|
194
|
+
this.mounted = new Promise(
|
|
195
|
+
(D) => this.mount = () => {
|
|
196
|
+
D(), u != this.parentNode && (d != u ? this.unmounted.then(this.update) : this.update()), u = this.parentNode;
|
|
197
|
+
}
|
|
198
|
+
), this.unmounted = new Promise(
|
|
199
|
+
(D) => this.unmount = () => {
|
|
200
|
+
D(), (u != this.parentNode || !this.isConnected) && (c.cleanEffects(!0)()(), d = this.parentNode, u = null);
|
|
201
|
+
}
|
|
202
|
+
), this.symbolId = this.symbolId || Symbol(), this.symbolIdParent = Symbol();
|
|
203
|
+
const c = ie(
|
|
204
|
+
() => this.update(),
|
|
205
|
+
this,
|
|
206
|
+
ge(this)
|
|
207
|
+
);
|
|
208
|
+
let h, y = !0;
|
|
209
|
+
const m = V(this);
|
|
210
|
+
this.update = () => (h || (h = !0, this.updated = (this.updated || this.mounted).then(() => {
|
|
211
|
+
try {
|
|
212
|
+
const D = c.load(this._render), w = c.cleanEffects();
|
|
213
|
+
return D && //@ts-ignore
|
|
214
|
+
D.render(this, this.symbolId, m), h = !1, y && !c.isSuspense() && (y = !1, !m && De(this)), w();
|
|
215
|
+
} finally {
|
|
216
|
+
h = !1;
|
|
217
|
+
}
|
|
218
|
+
}).then(
|
|
219
|
+
/**
|
|
220
|
+
* @param {import("internal/hooks.js").CleanUseEffects} [cleanUseEffect]
|
|
221
|
+
*/
|
|
222
|
+
(D) => {
|
|
223
|
+
D && D();
|
|
224
|
+
}
|
|
225
|
+
)), this.updated), this.update();
|
|
226
|
+
}
|
|
227
|
+
connectedCallback() {
|
|
228
|
+
this.mount(), super.connectedCallback && super.connectedCallback();
|
|
229
|
+
}
|
|
230
|
+
disconnectedCallback() {
|
|
231
|
+
super.disconnectedCallback && super.disconnectedCallback(), this.unmount();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @this {import("dom").AtomicoThisInternal}
|
|
235
|
+
* @param {string} attr
|
|
236
|
+
* @param {(string|null)} oldValue
|
|
237
|
+
* @param {(string|null)} value
|
|
238
|
+
*/
|
|
239
|
+
attributeChangedCallback(u, d, c) {
|
|
240
|
+
if (n[u]) {
|
|
241
|
+
if (u === this._ignoreAttr || d === c)
|
|
242
|
+
return;
|
|
243
|
+
const { prop: h, type: y } = n[u];
|
|
244
|
+
try {
|
|
245
|
+
this[h] = me(y, c);
|
|
246
|
+
} catch {
|
|
247
|
+
throw new ae(
|
|
248
|
+
this,
|
|
249
|
+
`The value defined as attr '${u}' cannot be parsed by type '${y.name}'`,
|
|
250
|
+
c
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
} else
|
|
254
|
+
super.attributeChangedCallback(u, d, c);
|
|
255
|
+
}
|
|
256
|
+
static get props() {
|
|
257
|
+
return { ...super.props, ...i };
|
|
258
|
+
}
|
|
259
|
+
static get observedAttributes() {
|
|
260
|
+
const u = super.observedAttributes || [];
|
|
261
|
+
for (const d in i)
|
|
262
|
+
fe(this.prototype, d, i[d], n, s);
|
|
263
|
+
return Object.keys(n).concat(u);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return l;
|
|
267
|
+
};
|
|
268
|
+
function De(e) {
|
|
269
|
+
const { styles: t } = e.constructor, { shadowRoot: n } = e;
|
|
270
|
+
if (n && t.length) {
|
|
271
|
+
const s = [];
|
|
272
|
+
Rt(t, (o) => {
|
|
273
|
+
o && (o instanceof Element ? n.appendChild(o.cloneNode(!0)) : s.push(o));
|
|
274
|
+
}), s.length && (n.adoptedStyleSheets = s);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const It = (e) => (t, n) => {
|
|
278
|
+
A(
|
|
279
|
+
/**
|
|
280
|
+
* Clean the effect hook
|
|
281
|
+
* @type {import("internal/hooks.js").CollectorEffect}
|
|
282
|
+
*/
|
|
283
|
+
([s, o] = []) => ((o || !o) && (o && At(o, n) ? s = s || !0 : (S(s) && s(), s = null)), [s, n]),
|
|
284
|
+
/**
|
|
285
|
+
* @returns {any}
|
|
286
|
+
*/
|
|
287
|
+
([s, o], r) => r ? (S(s) && s(), []) : [s || t(), o],
|
|
288
|
+
e
|
|
289
|
+
);
|
|
290
|
+
}, j = It(Nt), we = It(Pt);
|
|
291
|
+
class xt extends Array {
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
* @param {any} initialState
|
|
295
|
+
* @param {(nextState: any, state:any[], mount: boolean )=>void} mapState
|
|
296
|
+
*/
|
|
297
|
+
constructor(t, n) {
|
|
298
|
+
let s = !0;
|
|
299
|
+
const o = (r) => {
|
|
300
|
+
try {
|
|
301
|
+
n(r, this, s);
|
|
302
|
+
} finally {
|
|
303
|
+
s = !1;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
super(void 0, o, n), o(t);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The following code allows a mutable approach to useState
|
|
310
|
+
* and useProp this with the idea of allowing an alternative
|
|
311
|
+
* approach similar to Vue or Qwik of state management
|
|
312
|
+
* @todo pending review with the community
|
|
313
|
+
*/
|
|
314
|
+
// get value() {
|
|
315
|
+
// return this[0];
|
|
316
|
+
// }
|
|
317
|
+
// set value(nextState) {
|
|
318
|
+
// this[2](nextState, this);
|
|
319
|
+
// }
|
|
320
|
+
}
|
|
321
|
+
const it = (e) => {
|
|
322
|
+
const t = Mt();
|
|
323
|
+
return A(
|
|
324
|
+
(n = new xt(e, (s, o, r) => {
|
|
325
|
+
s = S(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t());
|
|
326
|
+
})) => n
|
|
327
|
+
);
|
|
328
|
+
}, P = (e, t) => {
|
|
329
|
+
const [n] = A(([s, o, r = 0] = []) => ((!o || o && !At(o, t)) && (s = e()), [s, t, r]));
|
|
330
|
+
return n;
|
|
331
|
+
}, Lt = (e) => {
|
|
332
|
+
const { current: t } = I();
|
|
333
|
+
if (!(e in t))
|
|
334
|
+
throw new kt(
|
|
335
|
+
t,
|
|
336
|
+
`For useProp("${e}"), the prop does not exist on the host.`,
|
|
337
|
+
e
|
|
338
|
+
);
|
|
339
|
+
return A(
|
|
340
|
+
(n = new xt(t[e], (s, o) => {
|
|
341
|
+
s = S(s) ? s(t[e]) : s, t[e] = s;
|
|
342
|
+
})) => (n[0] = t[e], n)
|
|
343
|
+
);
|
|
344
|
+
}, N = (e, t = {}) => {
|
|
345
|
+
const n = I();
|
|
346
|
+
return n[e] || (n[e] = (s = t.detail) => Ut(n.current, {
|
|
347
|
+
type: e,
|
|
348
|
+
...t,
|
|
349
|
+
detail: s
|
|
350
|
+
})), n[e];
|
|
351
|
+
}, tt = R("atomico/options");
|
|
352
|
+
globalThis[tt] = globalThis[tt] || {
|
|
353
|
+
sheet: !!document.adoptedStyleSheets
|
|
354
|
+
};
|
|
355
|
+
const Yt = globalThis[tt], Ee = {
|
|
356
|
+
checked: 1,
|
|
357
|
+
value: 1,
|
|
358
|
+
selected: 1
|
|
359
|
+
}, Se = {
|
|
360
|
+
list: 1,
|
|
361
|
+
type: 1,
|
|
362
|
+
size: 1,
|
|
363
|
+
form: 1,
|
|
364
|
+
width: 1,
|
|
365
|
+
height: 1,
|
|
366
|
+
src: 1,
|
|
367
|
+
href: 1,
|
|
368
|
+
slot: 1
|
|
369
|
+
}, Te = {
|
|
370
|
+
shadowDom: 1,
|
|
371
|
+
staticNode: 1,
|
|
372
|
+
cloneNode: 1,
|
|
373
|
+
children: 1,
|
|
374
|
+
key: 1
|
|
375
|
+
}, L = {}, et = [];
|
|
376
|
+
class nt extends Text {
|
|
377
|
+
}
|
|
378
|
+
const ve = R("atomico/id"), U = R("atomico/type"), J = R("atomico/ref"), _t = R("atomico/vnode"), $t = () => {
|
|
379
|
+
};
|
|
380
|
+
function Ce(e, t, n) {
|
|
381
|
+
return qt(this, e, t, n);
|
|
382
|
+
}
|
|
383
|
+
const jt = (e, t, ...n) => {
|
|
384
|
+
const s = t || L;
|
|
385
|
+
let { children: o } = s;
|
|
386
|
+
if (o = o ?? (n.length ? n : et), e === $t)
|
|
387
|
+
return o;
|
|
388
|
+
const r = e ? e instanceof Node ? 1 : (
|
|
389
|
+
//@ts-ignore
|
|
390
|
+
e.prototype instanceof HTMLElement && 2
|
|
391
|
+
) : 0;
|
|
392
|
+
if (r === !1 && e instanceof Function)
|
|
393
|
+
return e(
|
|
394
|
+
o != et ? { children: o, ...s } : s
|
|
395
|
+
);
|
|
396
|
+
const i = Yt.render || Ce;
|
|
397
|
+
return {
|
|
398
|
+
[U]: _t,
|
|
399
|
+
type: e,
|
|
400
|
+
props: s,
|
|
401
|
+
children: o,
|
|
402
|
+
key: s.key,
|
|
403
|
+
// key for lists by keys
|
|
404
|
+
// define if the node declares its shadowDom
|
|
405
|
+
shadow: s.shadowDom,
|
|
406
|
+
// allows renderings to run only once
|
|
407
|
+
static: s.staticNode,
|
|
408
|
+
// defines whether the type is a childNode `1` or a constructor `2`
|
|
409
|
+
raw: r,
|
|
410
|
+
// defines whether to use the second parameter for document.createElement
|
|
411
|
+
is: s.is,
|
|
412
|
+
// clone the node if it comes from a reference
|
|
413
|
+
clone: s.cloneNode,
|
|
414
|
+
render: i
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
function qt(e, t, n = ve, s, o) {
|
|
418
|
+
let r;
|
|
419
|
+
if (t && t[n] && t[n].vnode == e || e[U] != _t)
|
|
420
|
+
return t;
|
|
421
|
+
(e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[J] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[J] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[J] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
|
|
422
|
+
"http://www.w3.org/2000/svg",
|
|
423
|
+
e.type
|
|
424
|
+
) : document.createElement(
|
|
425
|
+
e.type,
|
|
426
|
+
e.is ? { is: e.is } : void 0
|
|
427
|
+
)));
|
|
428
|
+
const i = t[n] ? t[n] : L, { vnode: a = L, cycle: l = 0 } = i;
|
|
429
|
+
let { fragment: f, handlers: u } = i;
|
|
430
|
+
const { children: d = et, props: c = L } = a;
|
|
431
|
+
if (u = r ? {} : u || {}, e.static && !r)
|
|
432
|
+
return t;
|
|
433
|
+
if (e.shadow && !t.shadowRoot && // @ts-ignore
|
|
434
|
+
t.attachShadow({ mode: "open", ...e.shadow }), e.props != c && Me(t, c, e.props, u, o), e.children !== d) {
|
|
435
|
+
const h = e.shadow ? t.shadowRoot : t;
|
|
436
|
+
f = Pe(
|
|
437
|
+
e.children,
|
|
438
|
+
/**
|
|
439
|
+
* @todo for hydration use attribute and send childNodes
|
|
440
|
+
*/
|
|
441
|
+
f,
|
|
442
|
+
h,
|
|
443
|
+
n,
|
|
444
|
+
// add support to foreignObject, children will escape from svg
|
|
445
|
+
!l && s,
|
|
446
|
+
o && e.type == "foreignObject" ? !1 : o
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
return t[n] = { vnode: e, handlers: u, fragment: f, cycle: l + 1 }, t;
|
|
450
|
+
}
|
|
451
|
+
function Ne(e, t) {
|
|
452
|
+
const n = new nt(""), s = new nt("");
|
|
453
|
+
let o;
|
|
454
|
+
if (e[t ? "prepend" : "append"](n), t) {
|
|
455
|
+
let { lastElementChild: r } = e;
|
|
456
|
+
for (; r; ) {
|
|
457
|
+
const { previousElementSibling: i } = r;
|
|
458
|
+
if (V(r, !0) && !V(i, !0)) {
|
|
459
|
+
o = r;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
r = i;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return o ? o.before(s) : e.append(s), {
|
|
466
|
+
markStart: n,
|
|
467
|
+
markEnd: s
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function Pe(e, t, n, s, o, r) {
|
|
471
|
+
e = e == null ? null : ce(e) ? e : [e];
|
|
472
|
+
const i = t || Ne(n, o), { markStart: a, markEnd: l, keyes: f } = i;
|
|
473
|
+
let u;
|
|
474
|
+
const d = f && /* @__PURE__ */ new Set();
|
|
475
|
+
let c = a;
|
|
476
|
+
if (e && Rt(e, (h) => {
|
|
477
|
+
if (typeof h == "object" && !h[U])
|
|
478
|
+
return;
|
|
479
|
+
const y = h[U] && h.key, m = f && y != null && f.get(y);
|
|
480
|
+
c != l && c === m ? d.delete(c) : c = c == l ? l : c.nextSibling;
|
|
481
|
+
const D = f ? m : c;
|
|
482
|
+
let w = D;
|
|
483
|
+
if (h[U])
|
|
484
|
+
w = qt(h, D, s, o, r);
|
|
485
|
+
else {
|
|
486
|
+
const F = h + "";
|
|
487
|
+
!(w instanceof Text) || w instanceof nt ? w = new Text(F) : w.data != F && (w.data = F);
|
|
488
|
+
}
|
|
489
|
+
w != c && (f && d.delete(w), !D || f ? (n.insertBefore(w, c), f && c != l && d.add(c)) : D == l ? n.insertBefore(w, l) : (n.replaceChild(w, D), c = w)), y != null && (u = u || /* @__PURE__ */ new Map(), u.set(y, w));
|
|
490
|
+
}), c = c == l ? l : c.nextSibling, t && c != l)
|
|
491
|
+
for (; c != l; ) {
|
|
492
|
+
const h = c;
|
|
493
|
+
c = c.nextSibling, h.remove();
|
|
494
|
+
}
|
|
495
|
+
return d && d.forEach((h) => h.remove()), i.keyes = u, i;
|
|
496
|
+
}
|
|
497
|
+
function Me(e, t, n, s, o) {
|
|
498
|
+
for (const r in t)
|
|
499
|
+
!(r in n) && pt(e, r, t[r], null, o, s);
|
|
500
|
+
for (const r in n)
|
|
501
|
+
pt(e, r, t[r], n[r], o, s);
|
|
502
|
+
}
|
|
503
|
+
function pt(e, t, n, s, o, r) {
|
|
504
|
+
if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Ee[t] && (n = e[t]), !(s === n || Te[t] || t[0] == "_"))
|
|
505
|
+
if (t[0] == "o" && t[1] == "n" && (S(s) || S(n)))
|
|
506
|
+
Ae(e, t.slice(2), s, r);
|
|
507
|
+
else if (t == "ref")
|
|
508
|
+
s && (S(s) ? s(e) : s.current = e);
|
|
509
|
+
else if (t == "style") {
|
|
510
|
+
const { style: i } = e;
|
|
511
|
+
n = n || "", s = s || "";
|
|
512
|
+
const a = k(n), l = k(s);
|
|
513
|
+
if (a)
|
|
514
|
+
for (const f in n)
|
|
515
|
+
if (l)
|
|
516
|
+
!(f in s) && gt(i, f, null);
|
|
517
|
+
else
|
|
518
|
+
break;
|
|
519
|
+
if (l)
|
|
520
|
+
for (const f in s) {
|
|
521
|
+
const u = s[f];
|
|
522
|
+
a && n[f] === u || gt(i, f, u);
|
|
523
|
+
}
|
|
524
|
+
else
|
|
525
|
+
i.cssText = s;
|
|
526
|
+
} else {
|
|
527
|
+
const i = t[0] == "$" ? t.slice(1) : t;
|
|
528
|
+
i === t && (!o && !Se[t] && t in e || S(s) || S(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(i) : e.setAttribute(
|
|
529
|
+
i,
|
|
530
|
+
k(s) ? JSON.stringify(s) : s
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function Ae(e, t, n, s) {
|
|
535
|
+
if (s.handleEvent || (s.handleEvent = (o) => s[o.type].call(e, o)), n) {
|
|
536
|
+
if (!s[t]) {
|
|
537
|
+
const o = n.capture || n.once || n.passive ? Object.assign({}, n) : null;
|
|
538
|
+
e.addEventListener(t, s, o);
|
|
539
|
+
}
|
|
540
|
+
s[t] = n;
|
|
541
|
+
} else
|
|
542
|
+
s[t] && (e.removeEventListener(t, s), delete s[t]);
|
|
543
|
+
}
|
|
544
|
+
function gt(e, t, n) {
|
|
545
|
+
let s = "setProperty";
|
|
546
|
+
n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n;
|
|
547
|
+
}
|
|
548
|
+
const Dt = {};
|
|
549
|
+
function ct(e, ...t) {
|
|
550
|
+
const n = (e.raw || e).reduce(
|
|
551
|
+
(s, o, r) => s + o + (t[r] || ""),
|
|
552
|
+
""
|
|
553
|
+
);
|
|
554
|
+
return Dt[n] = Dt[n] || Re(n);
|
|
555
|
+
}
|
|
556
|
+
function Re(e) {
|
|
557
|
+
if (Yt.sheet) {
|
|
558
|
+
const t = new CSSStyleSheet();
|
|
559
|
+
return t.replaceSync(e), t;
|
|
560
|
+
} else {
|
|
561
|
+
const t = document.createElement("style");
|
|
562
|
+
return t.textContent = e, t;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const Fe = jt("host", { style: "display: contents" }), X = R("atomico/context"), Oe = (e, t) => {
|
|
566
|
+
const n = I();
|
|
567
|
+
we(
|
|
568
|
+
() => Ft(
|
|
569
|
+
n.current,
|
|
570
|
+
"ConnectContext",
|
|
571
|
+
/**
|
|
572
|
+
* @param {CustomEvent<import("context").DetailConnectContext>} event
|
|
573
|
+
*/
|
|
574
|
+
(s) => {
|
|
575
|
+
e === s.detail.id && (s.stopPropagation(), s.detail.connect(t));
|
|
576
|
+
}
|
|
577
|
+
),
|
|
578
|
+
[e]
|
|
579
|
+
);
|
|
580
|
+
}, ke = (e) => {
|
|
581
|
+
const t = N("ConnectContext", {
|
|
582
|
+
bubbles: !0,
|
|
583
|
+
composed: !0
|
|
584
|
+
}), n = () => {
|
|
585
|
+
let r;
|
|
586
|
+
return t({
|
|
587
|
+
id: e,
|
|
588
|
+
connect(i) {
|
|
589
|
+
r = i;
|
|
590
|
+
}
|
|
591
|
+
}), r;
|
|
592
|
+
}, [s, o] = it(
|
|
593
|
+
n
|
|
594
|
+
);
|
|
595
|
+
return j(() => {
|
|
596
|
+
s || (e[X] || (e[X] = customElements.whenDefined(
|
|
597
|
+
new e().localName
|
|
598
|
+
)), e[X].then(
|
|
599
|
+
() => o(n)
|
|
600
|
+
));
|
|
601
|
+
}, [e]), s;
|
|
602
|
+
}, Ue = (e) => {
|
|
603
|
+
const t = ke(e), n = Mt();
|
|
604
|
+
return j(() => {
|
|
605
|
+
if (t)
|
|
606
|
+
return Ft(t, "UpdatedValue", n);
|
|
607
|
+
}, [t]), (t || e).value;
|
|
608
|
+
}, Ie = (e) => {
|
|
609
|
+
const t = $(
|
|
610
|
+
() => (Oe(t, I().current), Fe),
|
|
611
|
+
{
|
|
612
|
+
props: {
|
|
613
|
+
value: {
|
|
614
|
+
type: Object,
|
|
615
|
+
event: { type: "UpdatedValue" },
|
|
616
|
+
value: () => e
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
return t.value = e, t;
|
|
622
|
+
}, p = (e, t, n) => (t == null ? t = { key: n } : t.key = n, jt(e, t)), _ = p, Bt = ct`*,*:before,*:after{box-sizing:border-box}`;
|
|
623
|
+
function q() {
|
|
624
|
+
const e = new Date(Date.now());
|
|
625
|
+
return new b(e.getUTCFullYear(), e.getUTCMonth() + 1, e.getUTCDate());
|
|
626
|
+
}
|
|
627
|
+
function at(e, t = 0) {
|
|
628
|
+
const n = e.toDate(), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t;
|
|
629
|
+
return n.setUTCDate(n.getUTCDate() - o), b.from(n);
|
|
630
|
+
}
|
|
631
|
+
function Ht(e, t = 0) {
|
|
632
|
+
const n = e.toDate(), s = n.getUTCDay(), o = (s < t ? -7 : 0) + 6 - (s - t);
|
|
633
|
+
return n.setUTCDate(n.getUTCDate() + o), b.from(n);
|
|
634
|
+
}
|
|
635
|
+
function ut(e) {
|
|
636
|
+
return b.from(new Date(Date.UTC(e.year, e.month, 0)));
|
|
637
|
+
}
|
|
638
|
+
function zt(e, t) {
|
|
639
|
+
return e < t ? -1 : e > t ? 1 : 0;
|
|
640
|
+
}
|
|
641
|
+
function B(e, t, n) {
|
|
642
|
+
return t && b.compare(e, t) < 0 ? t : n && b.compare(e, n) > 0 ? n : e;
|
|
643
|
+
}
|
|
644
|
+
function st(e, t, n) {
|
|
645
|
+
return B(e, t, n) === e;
|
|
646
|
+
}
|
|
647
|
+
function xe(e, t) {
|
|
648
|
+
const n = { days: 1 }, s = [e];
|
|
649
|
+
for (; !e.equals(t); )
|
|
650
|
+
e = e.add(n), s.push(e);
|
|
651
|
+
return s;
|
|
652
|
+
}
|
|
653
|
+
function Le(e, t) {
|
|
654
|
+
const n = [];
|
|
655
|
+
for (let s = 0; s < e.length; s += t)
|
|
656
|
+
n.push(e.slice(s, s + t));
|
|
657
|
+
return n;
|
|
658
|
+
}
|
|
659
|
+
function Ye(e, t = 0) {
|
|
660
|
+
const n = at(e.toPlainDate(), t), s = Ht(ut(e), t);
|
|
661
|
+
return Le(xe(n, s), 7);
|
|
662
|
+
}
|
|
663
|
+
function _e(e, t, n) {
|
|
664
|
+
const s = [], o = { weekday: e }, r = at(q(), t).toDate(), i = new Intl.DateTimeFormat(n, o);
|
|
665
|
+
for (let a = 0; a < 7; a++)
|
|
666
|
+
s[a] = i.format(r), r.setDate(r.getDate() + 1);
|
|
667
|
+
return s;
|
|
668
|
+
}
|
|
669
|
+
function wt(e) {
|
|
670
|
+
return (e.months ?? 0) + (e.years ?? 0) * 12;
|
|
671
|
+
}
|
|
672
|
+
function Et(e, t) {
|
|
673
|
+
const n = e.toDate();
|
|
674
|
+
return n.setUTCMonth(n.getUTCMonth() + t), new T(n.getUTCFullYear(), n.getUTCMonth() + 1);
|
|
675
|
+
}
|
|
676
|
+
class T {
|
|
677
|
+
constructor(t, n) {
|
|
678
|
+
this.year = t, this.month = n;
|
|
679
|
+
}
|
|
680
|
+
add(t) {
|
|
681
|
+
return Et(this, wt(t));
|
|
682
|
+
}
|
|
683
|
+
subtract(t) {
|
|
684
|
+
return Et(this, -wt(t));
|
|
685
|
+
}
|
|
686
|
+
toDate() {
|
|
687
|
+
return new Date(Date.UTC(this.year, this.month - 1, 1));
|
|
688
|
+
}
|
|
689
|
+
equals(t) {
|
|
690
|
+
return this.year === t.year && this.month === t.month;
|
|
691
|
+
}
|
|
692
|
+
toPlainDate() {
|
|
693
|
+
return new b(this.year, this.month, 1);
|
|
694
|
+
}
|
|
695
|
+
static compare(t, n) {
|
|
696
|
+
const s = t instanceof b ? t.toPlainYearMonth() : t, o = n instanceof b ? n.toPlainYearMonth() : n;
|
|
697
|
+
return zt(s.toDate(), o.toDate());
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const $e = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Kt = "years", Wt = "months", Jt = "days";
|
|
701
|
+
function je(e) {
|
|
702
|
+
if (Kt in e)
|
|
703
|
+
return { years: -e.years };
|
|
704
|
+
if (Wt in e)
|
|
705
|
+
return { months: -e.months };
|
|
706
|
+
if (Jt in e)
|
|
707
|
+
return { days: -e.days };
|
|
708
|
+
throw new TypeError();
|
|
709
|
+
}
|
|
710
|
+
function qe(e, t) {
|
|
711
|
+
return b.from(new Date(Date.UTC(e.year, e.month - 1, t)));
|
|
712
|
+
}
|
|
713
|
+
function Be(e, t) {
|
|
714
|
+
const n = new b(t, e.month, 1), s = ut(n), o = e.toDate();
|
|
715
|
+
return o.setUTCFullYear(t), B(b.from(o), n, s);
|
|
716
|
+
}
|
|
717
|
+
function He(e, t) {
|
|
718
|
+
const n = new b(e.year, t, 1), s = ut(n), o = e.toDate();
|
|
719
|
+
return o.setUTCMonth(t - 1), B(b.from(o), n, s);
|
|
720
|
+
}
|
|
721
|
+
function St(e, t) {
|
|
722
|
+
return Jt in t ? qe(e, e.day + t.days) : Wt in t ? He(e, e.month + t.months) : Kt in t ? Be(e, e.year + t.years) : e;
|
|
723
|
+
}
|
|
724
|
+
const Z = (e, t) => e.toString().padStart(t, "0");
|
|
725
|
+
class b {
|
|
726
|
+
constructor(t, n, s) {
|
|
727
|
+
this.year = t, this.month = n, this.day = s;
|
|
728
|
+
}
|
|
729
|
+
add(t) {
|
|
730
|
+
return St(this, t);
|
|
731
|
+
}
|
|
732
|
+
subtract(t) {
|
|
733
|
+
return St(this, je(t));
|
|
734
|
+
}
|
|
735
|
+
toString() {
|
|
736
|
+
const { month: t, year: n, day: s } = this;
|
|
737
|
+
return `${Z(n, 4)}-${Z(t, 2)}-${Z(s, 2)}`;
|
|
738
|
+
}
|
|
739
|
+
toDate() {
|
|
740
|
+
return new Date(Date.UTC(this.year, this.month - 1, this.day, 0, 0, 0));
|
|
741
|
+
}
|
|
742
|
+
toPlainYearMonth() {
|
|
743
|
+
return new T(this.year, this.month);
|
|
744
|
+
}
|
|
745
|
+
equals(t) {
|
|
746
|
+
return this.year === t.year && this.month === t.month && this.day === t.day;
|
|
747
|
+
}
|
|
748
|
+
static compare(t, n) {
|
|
749
|
+
return zt(t.toDate(), n.toDate());
|
|
750
|
+
}
|
|
751
|
+
static from(t) {
|
|
752
|
+
return typeof t == "string" ? b.fromString(t) : b.fromDate(t);
|
|
753
|
+
}
|
|
754
|
+
static fromString(t) {
|
|
755
|
+
const n = t.match($e);
|
|
756
|
+
if (!n)
|
|
757
|
+
throw new TypeError(t);
|
|
758
|
+
const [, s, o, r] = n;
|
|
759
|
+
return new b(
|
|
760
|
+
parseInt(s, 10),
|
|
761
|
+
parseInt(o, 10),
|
|
762
|
+
parseInt(r, 10)
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
static fromDate(t) {
|
|
766
|
+
return new b(
|
|
767
|
+
t.getUTCFullYear(),
|
|
768
|
+
t.getUTCMonth() + 1,
|
|
769
|
+
t.getUTCDate()
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function ot(e, t) {
|
|
774
|
+
if (t)
|
|
775
|
+
try {
|
|
776
|
+
return e.from(t);
|
|
777
|
+
} catch {
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
function rt(e) {
|
|
781
|
+
const [t, n] = Lt(e);
|
|
782
|
+
return [P(() => ot(b, t), [t]), (r) => n(r.toString())];
|
|
783
|
+
}
|
|
784
|
+
function ze(e) {
|
|
785
|
+
if (e) {
|
|
786
|
+
const t = e.split("/"), n = ot(b, t[0]), s = ot(b, t[1]);
|
|
787
|
+
if (n && s)
|
|
788
|
+
return { start: n, end: s };
|
|
789
|
+
}
|
|
790
|
+
return { start: void 0, end: void 0 };
|
|
791
|
+
}
|
|
792
|
+
function Ke(e, t) {
|
|
793
|
+
return `${e || ""}/${t || ""}`;
|
|
794
|
+
}
|
|
795
|
+
function We(e) {
|
|
796
|
+
const [t, n] = Lt(e);
|
|
797
|
+
return [P(() => ze(t), [t]), (r, i) => n(Ke(r, i))];
|
|
798
|
+
}
|
|
799
|
+
function lt(e, { day: t, month: n, year: s } = {}) {
|
|
800
|
+
return P(
|
|
801
|
+
() => new Intl.DateTimeFormat(e, { day: t, month: n, year: s }),
|
|
802
|
+
[e, t, n, s]
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
function Tt(e, t, n) {
|
|
806
|
+
return P(
|
|
807
|
+
() => _e(e, t, n),
|
|
808
|
+
[e, t, n]
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
function Je(e) {
|
|
812
|
+
let t = "";
|
|
813
|
+
for (const n in e)
|
|
814
|
+
e[n] && (t += ` ${n}`);
|
|
815
|
+
return t;
|
|
816
|
+
}
|
|
817
|
+
const Xe = { month: "long", day: "numeric" }, G = { bubbles: !0 };
|
|
818
|
+
function Ze({ props: e, context: t }) {
|
|
819
|
+
const { offset: n } = e, {
|
|
820
|
+
firstDayOfWeek: s,
|
|
821
|
+
isDateDisallowed: o,
|
|
822
|
+
dir: r,
|
|
823
|
+
min: i,
|
|
824
|
+
max: a,
|
|
825
|
+
dateWindow: l,
|
|
826
|
+
locale: f
|
|
827
|
+
} = t, u = q(), d = Tt("long", s, f), c = Tt("narrow", s, f), h = lt(f, Xe), { focusedDate: y } = l, m = P(
|
|
828
|
+
() => l.start.add({ months: n }),
|
|
829
|
+
[l, n]
|
|
830
|
+
), D = P(
|
|
831
|
+
() => Ye(m, s),
|
|
832
|
+
[m, s]
|
|
833
|
+
), w = N("focusday", G), F = N("selectday", G), Vt = N("hoverday", G);
|
|
834
|
+
function dt(g) {
|
|
835
|
+
w(B(g, i, a));
|
|
836
|
+
}
|
|
837
|
+
function te(g) {
|
|
838
|
+
const v = r === "ltr";
|
|
839
|
+
let E;
|
|
840
|
+
switch (g.key) {
|
|
841
|
+
case "ArrowRight":
|
|
842
|
+
E = y.add({ days: v ? 1 : -1 });
|
|
843
|
+
break;
|
|
844
|
+
case "ArrowLeft":
|
|
845
|
+
E = y.add({ days: v ? -1 : 1 });
|
|
846
|
+
break;
|
|
847
|
+
case "ArrowDown":
|
|
848
|
+
E = y.add({ days: 7 });
|
|
849
|
+
break;
|
|
850
|
+
case "ArrowUp":
|
|
851
|
+
E = y.add({ days: -7 });
|
|
852
|
+
break;
|
|
853
|
+
case "PageUp":
|
|
854
|
+
E = y.add(g.shiftKey ? { years: -1 } : { months: -1 });
|
|
855
|
+
break;
|
|
856
|
+
case "PageDown":
|
|
857
|
+
E = y.add(g.shiftKey ? { years: 1 } : { months: 1 });
|
|
858
|
+
break;
|
|
859
|
+
case "Home":
|
|
860
|
+
E = at(y, s);
|
|
861
|
+
break;
|
|
862
|
+
case "End":
|
|
863
|
+
E = Ht(y, s);
|
|
864
|
+
break;
|
|
865
|
+
default:
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
dt(E), g.preventDefault();
|
|
869
|
+
}
|
|
870
|
+
function ee(g) {
|
|
871
|
+
const v = m.equals(g), E = g.equals(y), ht = g.equals(u), mt = g.toDate(), x = o?.(mt), yt = !st(g, i, a);
|
|
872
|
+
let O = !1, bt = !1, H = !1, z = !1;
|
|
873
|
+
if ("highlightedRange" in t) {
|
|
874
|
+
const { start: K, end: W } = t.highlightedRange;
|
|
875
|
+
bt = !0, H = K?.equals(g) ?? !1, z = W?.equals(g) ?? !1, O = K && W ? st(g, K, W) : !1;
|
|
876
|
+
} else
|
|
877
|
+
"value" in t && (O = t.value?.equals(g) ?? !1);
|
|
878
|
+
return {
|
|
879
|
+
part: Je({
|
|
880
|
+
button: !0,
|
|
881
|
+
day: !0,
|
|
882
|
+
selected: v && O,
|
|
883
|
+
today: ht,
|
|
884
|
+
disallowed: x,
|
|
885
|
+
outside: !v,
|
|
886
|
+
"range-start": H,
|
|
887
|
+
"range-end": z,
|
|
888
|
+
"range-inner": bt && O && !H && !z
|
|
889
|
+
}),
|
|
890
|
+
tabindex: v && E ? 0 : -1,
|
|
891
|
+
disabled: yt,
|
|
892
|
+
"aria-disabled": x ? "true" : void 0,
|
|
893
|
+
"aria-pressed": v && O,
|
|
894
|
+
"aria-current": ht ? "date" : void 0,
|
|
895
|
+
"aria-label": h.format(mt),
|
|
896
|
+
onkeydown: te,
|
|
897
|
+
onclick() {
|
|
898
|
+
x || F(g), dt(g);
|
|
899
|
+
},
|
|
900
|
+
onmouseover() {
|
|
901
|
+
!x && !yt && Vt(g);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
return {
|
|
906
|
+
weeks: D,
|
|
907
|
+
yearMonth: m,
|
|
908
|
+
dayNamesLong: d,
|
|
909
|
+
dayNamesShort: c,
|
|
910
|
+
getDayProps: ee
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
class C {
|
|
914
|
+
constructor(t, n, s) {
|
|
915
|
+
this.start = t, this.duration = n, this.focusedDate = s, this.end = t.add({ months: n.months - 1 });
|
|
916
|
+
}
|
|
917
|
+
end;
|
|
918
|
+
contains(t) {
|
|
919
|
+
return T.compare(t, this.start) >= 0 && T.compare(t, this.end) <= 0;
|
|
920
|
+
}
|
|
921
|
+
adjust(t) {
|
|
922
|
+
const { start: n, duration: s } = this, o = T.compare(n, t) > 0;
|
|
923
|
+
let r = new C(n, s, t);
|
|
924
|
+
for (; !r.contains(t); )
|
|
925
|
+
r = new C(
|
|
926
|
+
o ? r.start.subtract(s) : r.start.add(s),
|
|
927
|
+
s,
|
|
928
|
+
t
|
|
929
|
+
);
|
|
930
|
+
return r;
|
|
931
|
+
}
|
|
932
|
+
next() {
|
|
933
|
+
return new C(
|
|
934
|
+
this.start.add(this.duration),
|
|
935
|
+
this.duration,
|
|
936
|
+
this.focusedDate.add(this.duration)
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
prev() {
|
|
940
|
+
return new C(
|
|
941
|
+
this.start.subtract(this.duration),
|
|
942
|
+
this.duration,
|
|
943
|
+
this.focusedDate.subtract(this.duration)
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
const vt = q(), ft = Ie({
|
|
948
|
+
firstDayOfWeek: 0,
|
|
949
|
+
highlightedRange: {},
|
|
950
|
+
isDateDisallowed: () => !1,
|
|
951
|
+
dir: "ltr",
|
|
952
|
+
locale: void 0,
|
|
953
|
+
dateWindow: new C(vt.toPlainYearMonth(), { months: 1 }, vt)
|
|
954
|
+
});
|
|
955
|
+
customElements.define("calendar-month-ctx", ft);
|
|
956
|
+
const Ge = $(
|
|
957
|
+
(e) => {
|
|
958
|
+
const t = Ue(ft), n = re(), s = Ze({ props: e, context: t }), o = lt(t.locale, { month: "long" });
|
|
959
|
+
function r() {
|
|
960
|
+
n.current.querySelector("button[tabindex='0']")?.focus();
|
|
961
|
+
}
|
|
962
|
+
return /* @__PURE__ */ _("host", { shadowDom: !0, focus: r, children: [
|
|
963
|
+
/* @__PURE__ */ p("div", { id: "heading", part: "heading", children: o.format(s.yearMonth.toDate()) }),
|
|
964
|
+
/* @__PURE__ */ _("table", { ref: n, "aria-labelledby": "heading", part: "table", children: [
|
|
965
|
+
/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { part: "tr head", children: s.dayNamesLong.map((i, a) => /* @__PURE__ */ p("th", { part: "th", scope: "col", children: /* @__PURE__ */ p("span", { "aria-label": i, children: s.dayNamesShort[a] }) })) }) }),
|
|
966
|
+
/* @__PURE__ */ p("tbody", { children: s.weeks.map((i, a) => /* @__PURE__ */ p("tr", { part: "tr week", children: i.map((l, f) => {
|
|
967
|
+
const u = s.yearMonth.equals(l), d = t.showOutsideDays || u;
|
|
968
|
+
return /* @__PURE__ */ p("td", { part: "td", children: d && /* @__PURE__ */ p("button", { ...s.getDayProps(l), children: l.day }) }, f);
|
|
969
|
+
}) }, a)) })
|
|
970
|
+
] })
|
|
971
|
+
] });
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
props: {
|
|
975
|
+
offset: {
|
|
976
|
+
type: Number,
|
|
977
|
+
value: 0
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
styles: [
|
|
981
|
+
Bt,
|
|
982
|
+
ct`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;border-spacing:0;table-layout:fixed;inline-size:max-content;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0;padding-block:1px}button{color:inherit;background:transparent;border:0;cursor:pointer;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled)){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disabled){cursor:default;opacity:.5}`
|
|
983
|
+
]
|
|
984
|
+
}
|
|
985
|
+
);
|
|
986
|
+
customElements.define("calendar-month", Ge);
|
|
987
|
+
function Xt(e) {
|
|
988
|
+
return /* @__PURE__ */ _($t, { children: [
|
|
989
|
+
/* @__PURE__ */ _("div", { class: "header", children: [
|
|
990
|
+
/* @__PURE__ */ p(
|
|
991
|
+
"button",
|
|
992
|
+
{
|
|
993
|
+
part: `button previous ${e.previous ? "" : "disabled"}`,
|
|
994
|
+
onclick: e.previous,
|
|
995
|
+
"aria-disabled": e.previous ? null : "true",
|
|
996
|
+
children: /* @__PURE__ */ p("slot", { name: "button-previous", children: "Previous" })
|
|
997
|
+
}
|
|
998
|
+
),
|
|
999
|
+
/* @__PURE__ */ p("h2", { part: "heading", "aria-live": "polite", "aria-atomic": "true", children: e.formatter.formatRange(
|
|
1000
|
+
e.dateWindow.start.toDate(),
|
|
1001
|
+
e.dateWindow.end.toDate()
|
|
1002
|
+
) }),
|
|
1003
|
+
/* @__PURE__ */ p(
|
|
1004
|
+
"button",
|
|
1005
|
+
{
|
|
1006
|
+
part: `button next ${e.next ? "" : "disabled"}`,
|
|
1007
|
+
onclick: e.next,
|
|
1008
|
+
"aria-disabled": e.next ? null : "true",
|
|
1009
|
+
children: /* @__PURE__ */ p("slot", { name: "button-next", children: "Next" })
|
|
1010
|
+
}
|
|
1011
|
+
)
|
|
1012
|
+
] }),
|
|
1013
|
+
/* @__PURE__ */ p(
|
|
1014
|
+
ft,
|
|
1015
|
+
{
|
|
1016
|
+
value: e,
|
|
1017
|
+
onselectday: e.onSelect,
|
|
1018
|
+
onfocusday: e.onFocus,
|
|
1019
|
+
onhoverday: e.onHover,
|
|
1020
|
+
children: /* @__PURE__ */ p("slot", {})
|
|
1021
|
+
}
|
|
1022
|
+
)
|
|
1023
|
+
] });
|
|
1024
|
+
}
|
|
1025
|
+
const Zt = {
|
|
1026
|
+
value: {
|
|
1027
|
+
type: String,
|
|
1028
|
+
value: ""
|
|
1029
|
+
},
|
|
1030
|
+
min: {
|
|
1031
|
+
type: String,
|
|
1032
|
+
value: ""
|
|
1033
|
+
},
|
|
1034
|
+
max: {
|
|
1035
|
+
type: String,
|
|
1036
|
+
value: ""
|
|
1037
|
+
},
|
|
1038
|
+
dir: {
|
|
1039
|
+
type: String,
|
|
1040
|
+
value: () => "ltr"
|
|
1041
|
+
},
|
|
1042
|
+
isDateDisallowed: {
|
|
1043
|
+
type: Function,
|
|
1044
|
+
value: (e) => !1
|
|
1045
|
+
},
|
|
1046
|
+
firstDayOfWeek: {
|
|
1047
|
+
type: Number,
|
|
1048
|
+
value: () => 0
|
|
1049
|
+
},
|
|
1050
|
+
showOutsideDays: {
|
|
1051
|
+
type: Boolean,
|
|
1052
|
+
value: () => !1
|
|
1053
|
+
},
|
|
1054
|
+
locale: {
|
|
1055
|
+
type: String,
|
|
1056
|
+
value: () => {
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
months: {
|
|
1060
|
+
type: Number,
|
|
1061
|
+
value: 1
|
|
1062
|
+
}
|
|
1063
|
+
}, Gt = [
|
|
1064
|
+
Bt,
|
|
1065
|
+
ct`:host{display:flex;flex-direction:column;gap:1em}.header{display:flex;align-items:center;justify-content:space-between}h2{margin:0;font-size:1.25em;text-align:center}button{cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.4}`
|
|
1066
|
+
];
|
|
1067
|
+
function Qt({ months: e, locale: t }) {
|
|
1068
|
+
const [n] = rt("min"), [s] = rt("max"), o = N("focusday"), r = q(), i = r.toPlainYearMonth(), [a, l] = it(
|
|
1069
|
+
new C(
|
|
1070
|
+
e === 12 ? new T(i.year, 1) : i,
|
|
1071
|
+
{ months: e },
|
|
1072
|
+
r
|
|
1073
|
+
)
|
|
1074
|
+
);
|
|
1075
|
+
function f() {
|
|
1076
|
+
const m = a.next();
|
|
1077
|
+
l(m), o(m.focusedDate.toString());
|
|
1078
|
+
}
|
|
1079
|
+
function u() {
|
|
1080
|
+
const m = a.prev();
|
|
1081
|
+
l(m), o(m.focusedDate.toString());
|
|
1082
|
+
}
|
|
1083
|
+
const d = I(), c = lt(t, { year: "numeric" }), h = s == null || T.compare(s, a.end) > 0, y = n == null || T.compare(n, a.start) < 0;
|
|
1084
|
+
return {
|
|
1085
|
+
formatter: c,
|
|
1086
|
+
dateWindow: a,
|
|
1087
|
+
setFocusedDate(m) {
|
|
1088
|
+
l(a.adjust(m));
|
|
1089
|
+
},
|
|
1090
|
+
min: n,
|
|
1091
|
+
max: s,
|
|
1092
|
+
next: h ? f : void 0,
|
|
1093
|
+
previous: y ? u : void 0,
|
|
1094
|
+
focus() {
|
|
1095
|
+
d.current.querySelectorAll("calendar-month").forEach((m) => m.focus());
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
const Qe = $(
|
|
1100
|
+
(e) => {
|
|
1101
|
+
const [t, n] = rt("value"), s = N("change"), o = Qt(e);
|
|
1102
|
+
j(() => {
|
|
1103
|
+
t && o.setFocusedDate(t);
|
|
1104
|
+
}, [t]);
|
|
1105
|
+
async function r(a) {
|
|
1106
|
+
o.setFocusedDate(a.detail), setTimeout(() => o.focus());
|
|
1107
|
+
}
|
|
1108
|
+
function i(a) {
|
|
1109
|
+
n(a.detail), s();
|
|
1110
|
+
}
|
|
1111
|
+
return /* @__PURE__ */ p("host", { shadowDom: !0, focus: o.focus, children: /* @__PURE__ */ p(
|
|
1112
|
+
Xt,
|
|
1113
|
+
{
|
|
1114
|
+
...e,
|
|
1115
|
+
...o,
|
|
1116
|
+
value: t,
|
|
1117
|
+
onFocus: r,
|
|
1118
|
+
onSelect: i
|
|
1119
|
+
}
|
|
1120
|
+
) });
|
|
1121
|
+
},
|
|
1122
|
+
{ props: Zt, styles: Gt }
|
|
1123
|
+
);
|
|
1124
|
+
customElements.define("calendar-date", Qe);
|
|
1125
|
+
const Ve = $(
|
|
1126
|
+
(e) => {
|
|
1127
|
+
const [t, n] = We("value"), s = N("change"), o = Qt(e), [r, i] = it(), a = P(() => {
|
|
1128
|
+
if (r)
|
|
1129
|
+
return [r.first, r.second].sort(b.compare);
|
|
1130
|
+
}, [r]);
|
|
1131
|
+
j(() => {
|
|
1132
|
+
t.end && !st(o.dateWindow.focusedDate, t.start, t.end) && o.setFocusedDate(t.end);
|
|
1133
|
+
}, [t]);
|
|
1134
|
+
async function l(c) {
|
|
1135
|
+
o.setFocusedDate(c.detail), f(c), setTimeout(() => o.focus());
|
|
1136
|
+
}
|
|
1137
|
+
function f(c) {
|
|
1138
|
+
i((h) => h && { ...h, second: c.detail });
|
|
1139
|
+
}
|
|
1140
|
+
function u(c) {
|
|
1141
|
+
a ? (n(a[0], a[1]), i(void 0), s()) : i({ first: c.detail, second: c.detail });
|
|
1142
|
+
}
|
|
1143
|
+
const d = a ? { start: a[0], end: a[1] } : t;
|
|
1144
|
+
return /* @__PURE__ */ p("host", { shadowDom: !0, focus: o.focus, children: /* @__PURE__ */ p(
|
|
1145
|
+
Xt,
|
|
1146
|
+
{
|
|
1147
|
+
...e,
|
|
1148
|
+
...o,
|
|
1149
|
+
highlightedRange: d,
|
|
1150
|
+
onFocus: l,
|
|
1151
|
+
onHover: f,
|
|
1152
|
+
onSelect: u
|
|
1153
|
+
}
|
|
1154
|
+
) });
|
|
1155
|
+
},
|
|
1156
|
+
{ props: Zt, styles: Gt }
|
|
1157
|
+
);
|
|
1158
|
+
customElements.define("calendar-range", Ve);
|
|
1159
|
+
export {
|
|
1160
|
+
Qe as CalendarDate,
|
|
1161
|
+
Ge as CalendarMonth,
|
|
1162
|
+
Ve as CalendarRange
|
|
1163
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cally",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "small, feature-rich calendar components",
|
|
5
|
+
"module": "dist/cally.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/WickyNilliams/cally"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"start": "vite",
|
|
17
|
+
"build": "vite build && npm run astro:build",
|
|
18
|
+
"test": "wtr",
|
|
19
|
+
"astro:dev": "astro dev --root ./docs",
|
|
20
|
+
"preastro:build": "rm -rf ./docs/dist",
|
|
21
|
+
"astro:build": "astro check --root ./docs && astro build --root ./docs",
|
|
22
|
+
"astro:preview": "astro preview --root ./docs",
|
|
23
|
+
"preversion": "npm test",
|
|
24
|
+
"version": "npm run build",
|
|
25
|
+
"postversion": "git push origin main --tags && npm publish"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@astrojs/check": "^0.5.9",
|
|
29
|
+
"@atomico/tsconfig": "^1.1.2",
|
|
30
|
+
"@atomico/vite": "^2.17.8",
|
|
31
|
+
"@open-wc/testing": "^4.0.0",
|
|
32
|
+
"@types/mocha": "^10.0.6",
|
|
33
|
+
"@web/dev-server-esbuild": "^1.0.2",
|
|
34
|
+
"@web/test-runner": "^0.18.0",
|
|
35
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
36
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
37
|
+
"@web/test-runner-visual-regression": "^0.9.0",
|
|
38
|
+
"astro": "^4.5.3",
|
|
39
|
+
"atomico": "^1.76.1",
|
|
40
|
+
"prettier": "^3.2.5",
|
|
41
|
+
"typescript": "^5.3.3",
|
|
42
|
+
"vite": "^5.1.4"
|
|
43
|
+
}
|
|
44
|
+
}
|