reke-ui 0.1.0 → 0.1.2
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/README.md +2 -0
- package/custom-elements.json +216 -116
- package/dist/components/reke-alert/reke-alert.js +53 -0
- package/dist/components/reke-alert/reke-alert.styles.d.ts.map +1 -1
- package/dist/components/reke-alert/reke-alert.styles.js +106 -0
- package/dist/components/reke-badge/reke-badge.d.ts +4 -2
- package/dist/components/reke-badge/reke-badge.d.ts.map +1 -1
- package/dist/components/reke-badge/reke-badge.js +44 -0
- package/dist/components/reke-badge/reke-badge.styles.d.ts.map +1 -1
- package/dist/components/reke-badge/reke-badge.styles.js +95 -0
- package/dist/components/reke-button/reke-button.js +64 -0
- package/dist/components/reke-button/reke-button.styles.d.ts.map +1 -1
- package/dist/components/reke-button/reke-button.styles.js +229 -0
- package/dist/components/reke-card/reke-card.d.ts +7 -0
- package/dist/components/reke-card/reke-card.d.ts.map +1 -1
- package/dist/components/reke-card/reke-card.js +70 -0
- package/dist/components/reke-card/reke-card.styles.d.ts.map +1 -1
- package/dist/components/reke-card/reke-card.styles.js +150 -0
- package/dist/components/reke-checkbox/reke-checkbox.js +64 -0
- package/dist/components/reke-checkbox/reke-checkbox.styles.js +81 -0
- package/dist/components/reke-chip/reke-chip.js +70 -0
- package/dist/components/reke-chip/reke-chip.styles.d.ts.map +1 -1
- package/dist/components/reke-chip/reke-chip.styles.js +125 -0
- package/dist/components/reke-date-range/reke-date-range.js +346 -0
- package/dist/components/reke-date-range/reke-date-range.styles.js +322 -0
- package/dist/components/reke-dialog/reke-dialog.js +90 -0
- package/dist/components/reke-dialog/reke-dialog.styles.js +134 -0
- package/dist/components/reke-file-upload/reke-file-upload.js +108 -0
- package/dist/components/reke-file-upload/reke-file-upload.styles.js +107 -0
- package/dist/components/reke-input/reke-input.js +73 -0
- package/dist/components/reke-input/reke-input.styles.js +80 -0
- package/dist/components/reke-select/reke-select.js +112 -0
- package/dist/components/reke-select/reke-select.styles.js +122 -0
- package/dist/components/reke-table/reke-table.d.ts +21 -1
- package/dist/components/reke-table/reke-table.d.ts.map +1 -1
- package/dist/components/reke-table/reke-table.js +191 -0
- package/dist/components/reke-table/reke-table.styles.js +207 -0
- package/dist/components/reke-textarea/reke-textarea.js +73 -0
- package/dist/components/reke-textarea/reke-textarea.styles.js +76 -0
- package/dist/components/reke-toast/reke-toast.js +92 -0
- package/dist/components/reke-toast/reke-toast.styles.d.ts.map +1 -1
- package/dist/components/reke-toast/reke-toast.styles.js +182 -0
- package/dist/components/reke-toggle/reke-toggle.js +57 -0
- package/dist/components/reke-toggle/reke-toggle.styles.js +71 -0
- package/dist/components/reke-tooltip/reke-tooltip.js +67 -0
- package/dist/components/reke-tooltip/reke-tooltip.styles.js +67 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/react.js +79 -64
- package/dist/shared/base-element.js +16 -0
- package/dist/shared/tailwind-styles.js +6 -0
- package/dist/shared/tailwind.css.js +4 -0
- package/dist/tokens/reke-tokens.css +23 -0
- package/package.json +6 -4
- package/dist/reke-chip-Xb0Y_Cqo.js +0 -3358
- package/dist/reke-ui.js +0 -20
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { nothing as d, html as a } from "lit";
|
|
2
|
+
import { property as l, customElement as p } from "lit/decorators.js";
|
|
3
|
+
import { RekeElement as k } from "../../shared/base-element.js";
|
|
4
|
+
import { styles as m } from "./reke-checkbox.styles.js";
|
|
5
|
+
var b = Object.defineProperty, f = Object.getOwnPropertyDescriptor, i = (e, s, o, n) => {
|
|
6
|
+
for (var t = n > 1 ? void 0 : n ? f(s, o) : s, c = e.length - 1, h; c >= 0; c--)
|
|
7
|
+
(h = e[c]) && (t = (n ? h(s, o, t) : h(t)) || t);
|
|
8
|
+
return n && t && b(s, o, t), t;
|
|
9
|
+
};
|
|
10
|
+
let r = class extends k {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.checked = !1, this.indeterminate = !1, this.disabled = !1, this.label = "";
|
|
13
|
+
}
|
|
14
|
+
handleClick() {
|
|
15
|
+
this.disabled || (this.checked = !this.checked, this.indeterminate = !1, this.emit("reke-change", { checked: this.checked }));
|
|
16
|
+
}
|
|
17
|
+
handleKeyDown(e) {
|
|
18
|
+
(e.key === " " || e.key === "Enter") && (e.preventDefault(), this.handleClick());
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
const e = this.indeterminate ? "mixed" : String(this.checked);
|
|
22
|
+
return a`
|
|
23
|
+
<div
|
|
24
|
+
part="container"
|
|
25
|
+
class="container"
|
|
26
|
+
role="checkbox"
|
|
27
|
+
tabindex=${this.disabled ? "-1" : "0"}
|
|
28
|
+
aria-checked=${e}
|
|
29
|
+
aria-disabled=${this.disabled}
|
|
30
|
+
@click=${this.handleClick}
|
|
31
|
+
@keydown=${this.handleKeyDown}
|
|
32
|
+
>
|
|
33
|
+
<span part="box" class="box ${this.checked ? "box--checked" : ""} ${this.indeterminate ? "box--indeterminate" : ""}">
|
|
34
|
+
${this.checked ? a`<svg class="checkmark" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
35
|
+
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
36
|
+
</svg>` : d}
|
|
37
|
+
${this.indeterminate && !this.checked ? a`<svg class="indeterminate-mark" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
38
|
+
<path d="M3 6H9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
39
|
+
</svg>` : d}
|
|
40
|
+
</span>
|
|
41
|
+
${this.label ? a`<span part="label" class="label">${this.label}</span>` : d}
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
r.styles = m;
|
|
47
|
+
i([
|
|
48
|
+
l({ type: Boolean, reflect: !0 })
|
|
49
|
+
], r.prototype, "checked", 2);
|
|
50
|
+
i([
|
|
51
|
+
l({ type: Boolean, reflect: !0 })
|
|
52
|
+
], r.prototype, "indeterminate", 2);
|
|
53
|
+
i([
|
|
54
|
+
l({ type: Boolean, reflect: !0 })
|
|
55
|
+
], r.prototype, "disabled", 2);
|
|
56
|
+
i([
|
|
57
|
+
l()
|
|
58
|
+
], r.prototype, "label", 2);
|
|
59
|
+
r = i([
|
|
60
|
+
p("reke-checkbox")
|
|
61
|
+
], r);
|
|
62
|
+
export {
|
|
63
|
+
r as RekeCheckbox
|
|
64
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { tailwindStyles as e } from "../../shared/tailwind-styles.js";
|
|
2
|
+
import { css as o } from "lit";
|
|
3
|
+
const n = [
|
|
4
|
+
e,
|
|
5
|
+
o`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 8px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([disabled]) {
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
opacity: 0.5;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.container {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 8px;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.native-input {
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 1px;
|
|
29
|
+
height: 1px;
|
|
30
|
+
margin: -1px;
|
|
31
|
+
padding: 0;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
clip: rect(0, 0, 0, 0);
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
border: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.box {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
width: 16px;
|
|
43
|
+
height: 16px;
|
|
44
|
+
min-width: 16px;
|
|
45
|
+
min-height: 16px;
|
|
46
|
+
background-color: var(--reke-color-surface, #1A1A1A);
|
|
47
|
+
border: 1px solid var(--reke-color-border, #252525);
|
|
48
|
+
border-radius: 3px;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.box--checked,
|
|
54
|
+
.box--indeterminate {
|
|
55
|
+
background-color: var(--reke-color-primary, #22C55E);
|
|
56
|
+
border-color: var(--reke-color-primary, #22C55E);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.container:focus-visible .box {
|
|
60
|
+
outline: 2px solid var(--reke-color-primary, #22C55E);
|
|
61
|
+
outline-offset: 2px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.checkmark,
|
|
65
|
+
.indeterminate-mark {
|
|
66
|
+
width: 12px;
|
|
67
|
+
height: 12px;
|
|
68
|
+
color: var(--reke-color-on-primary, #0A0A0B);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.label {
|
|
72
|
+
font-family: var(--reke-font-mono, 'JetBrains Mono', ui-monospace, monospace);
|
|
73
|
+
font-size: var(--reke-font-size-sm, 13px);
|
|
74
|
+
color: var(--reke-color-text, #E5E5E5);
|
|
75
|
+
user-select: none;
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
];
|
|
79
|
+
export {
|
|
80
|
+
n as styles
|
|
81
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { nothing as h, html as n } from "lit";
|
|
2
|
+
import { property as o, customElement as m } from "lit/decorators.js";
|
|
3
|
+
import { classMap as d } from "lit/directives/class-map.js";
|
|
4
|
+
import { RekeElement as u } from "../../shared/base-element.js";
|
|
5
|
+
import { styles as f } from "./reke-chip.styles.js";
|
|
6
|
+
var b = Object.defineProperty, y = Object.getOwnPropertyDescriptor, i = (t, r, a, l) => {
|
|
7
|
+
for (var e = l > 1 ? void 0 : l ? y(r, a) : r, p = t.length - 1, c; p >= 0; p--)
|
|
8
|
+
(c = t[p]) && (e = (l ? c(r, a, e) : c(e)) || e);
|
|
9
|
+
return l && e && b(r, a, e), e;
|
|
10
|
+
};
|
|
11
|
+
let s = class extends u {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.color = "primary", this.active = !1, this.dismissible = !1, this.disabled = !1;
|
|
14
|
+
}
|
|
15
|
+
_handleClick() {
|
|
16
|
+
this.disabled || this.emit("reke-click");
|
|
17
|
+
}
|
|
18
|
+
_handleDismiss(t) {
|
|
19
|
+
t.stopPropagation(), !this.disabled && this.emit("reke-dismiss");
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const t = {
|
|
23
|
+
chip: !0,
|
|
24
|
+
[`chip--${this.color}`]: !0,
|
|
25
|
+
"chip--active": this.active
|
|
26
|
+
};
|
|
27
|
+
return n`
|
|
28
|
+
<button
|
|
29
|
+
part="chip"
|
|
30
|
+
class=${d(t)}
|
|
31
|
+
type="button"
|
|
32
|
+
?disabled=${this.disabled}
|
|
33
|
+
aria-pressed=${this.active}
|
|
34
|
+
@click=${this._handleClick}
|
|
35
|
+
>
|
|
36
|
+
<slot></slot>
|
|
37
|
+
${this.dismissible ? n`
|
|
38
|
+
<span
|
|
39
|
+
part="dismiss"
|
|
40
|
+
class="chip__dismiss"
|
|
41
|
+
role="button"
|
|
42
|
+
aria-label="Dismiss"
|
|
43
|
+
@click=${this._handleDismiss}
|
|
44
|
+
>
|
|
45
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
46
|
+
</span>
|
|
47
|
+
` : h}
|
|
48
|
+
</button>
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
s.styles = f;
|
|
53
|
+
i([
|
|
54
|
+
o({ reflect: !0 })
|
|
55
|
+
], s.prototype, "color", 2);
|
|
56
|
+
i([
|
|
57
|
+
o({ type: Boolean, reflect: !0 })
|
|
58
|
+
], s.prototype, "active", 2);
|
|
59
|
+
i([
|
|
60
|
+
o({ type: Boolean, reflect: !0 })
|
|
61
|
+
], s.prototype, "dismissible", 2);
|
|
62
|
+
i([
|
|
63
|
+
o({ type: Boolean, reflect: !0 })
|
|
64
|
+
], s.prototype, "disabled", 2);
|
|
65
|
+
s = i([
|
|
66
|
+
m("reke-chip")
|
|
67
|
+
], s);
|
|
68
|
+
export {
|
|
69
|
+
s as RekeChip
|
|
70
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reke-chip.styles.d.ts","sourceRoot":"","sources":["../../../src/components/reke-chip/reke-chip.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"reke-chip.styles.d.ts","sourceRoot":"","sources":["../../../src/components/reke-chip/reke-chip.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,2BAuHlB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { tailwindStyles as r } from "../../shared/tailwind-styles.js";
|
|
2
|
+
import { css as o } from "lit";
|
|
3
|
+
const i = [
|
|
4
|
+
r,
|
|
5
|
+
o`
|
|
6
|
+
:host {
|
|
7
|
+
display: inline-block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host([disabled]) {
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chip {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: 6px;
|
|
19
|
+
padding: 4px 10px;
|
|
20
|
+
font-family: var(--reke-font-mono, 'JetBrains Mono', ui-monospace, monospace);
|
|
21
|
+
font-size: var(--reke-font-size-xs, 12px);
|
|
22
|
+
font-weight: var(--reke-font-weight-medium, 500);
|
|
23
|
+
line-height: 1.4;
|
|
24
|
+
border: 1px solid var(--reke-color-border-subtle, #1F1F1F);
|
|
25
|
+
border-radius: var(--reke-radius, 4px);
|
|
26
|
+
background: transparent;
|
|
27
|
+
color: var(--reke-color-text-muted, #525252);
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
transition:
|
|
30
|
+
background-color var(--reke-transition-fast, 0.12s ease),
|
|
31
|
+
border-color var(--reke-transition-fast, 0.12s ease),
|
|
32
|
+
color var(--reke-transition-fast, 0.12s ease),
|
|
33
|
+
box-shadow var(--reke-transition-normal, 0.2s ease);
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.chip:focus-visible {
|
|
39
|
+
outline: 2px solid var(--reke-color-primary, #22C55E);
|
|
40
|
+
outline-offset: 2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.chip:hover:not(:disabled) {
|
|
44
|
+
color: var(--reke-color-text, #E5E5E5);
|
|
45
|
+
border-color: var(--reke-color-border-hover, #3A3A3A);
|
|
46
|
+
background: var(--reke-color-surface-hover, #202020);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* === Active states by color === */
|
|
50
|
+
|
|
51
|
+
.chip--primary.chip--active {
|
|
52
|
+
border-color: color-mix(in srgb, var(--reke-color-primary, #22C55E) 60%, transparent);
|
|
53
|
+
background: color-mix(in srgb, var(--reke-color-primary, #22C55E) 12%, transparent);
|
|
54
|
+
color: var(--reke-color-primary, #22C55E);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.chip--primary.chip--active:hover:not(:disabled) {
|
|
58
|
+
background: color-mix(in srgb, var(--reke-color-primary, #22C55E) 18%, transparent);
|
|
59
|
+
box-shadow: 0 0 12px color-mix(in srgb, var(--reke-color-primary, #22C55E) 20%, transparent);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.chip--secondary.chip--active {
|
|
63
|
+
border-color: color-mix(in srgb, var(--reke-color-secondary, #3B82F6) 60%, transparent);
|
|
64
|
+
background: color-mix(in srgb, var(--reke-color-secondary, #3B82F6) 12%, transparent);
|
|
65
|
+
color: var(--reke-color-secondary, #3B82F6);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.chip--secondary.chip--active:hover:not(:disabled) {
|
|
69
|
+
background: color-mix(in srgb, var(--reke-color-secondary, #3B82F6) 18%, transparent);
|
|
70
|
+
box-shadow: 0 0 12px color-mix(in srgb, var(--reke-color-secondary, #3B82F6) 20%, transparent);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.chip--danger.chip--active {
|
|
74
|
+
border-color: color-mix(in srgb, var(--reke-color-danger, #EF4444) 60%, transparent);
|
|
75
|
+
background: color-mix(in srgb, var(--reke-color-danger, #EF4444) 12%, transparent);
|
|
76
|
+
color: var(--reke-color-danger, #EF4444);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.chip--danger.chip--active:hover:not(:disabled) {
|
|
80
|
+
background: color-mix(in srgb, var(--reke-color-danger, #EF4444) 18%, transparent);
|
|
81
|
+
box-shadow: 0 0 12px color-mix(in srgb, var(--reke-color-danger, #EF4444) 20%, transparent);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.chip--warning.chip--active {
|
|
85
|
+
border-color: color-mix(in srgb, var(--reke-color-warning, #F59E0B) 60%, transparent);
|
|
86
|
+
background: color-mix(in srgb, var(--reke-color-warning, #F59E0B) 12%, transparent);
|
|
87
|
+
color: var(--reke-color-warning, #F59E0B);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.chip--warning.chip--active:hover:not(:disabled) {
|
|
91
|
+
background: color-mix(in srgb, var(--reke-color-warning, #F59E0B) 18%, transparent);
|
|
92
|
+
box-shadow: 0 0 12px color-mix(in srgb, var(--reke-color-warning, #F59E0B) 20%, transparent);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* === Dismiss button === */
|
|
96
|
+
|
|
97
|
+
.chip__dismiss {
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
width: 12px;
|
|
102
|
+
height: 12px;
|
|
103
|
+
border-radius: 2px;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
opacity: 0.6;
|
|
106
|
+
transition: opacity 0.15s ease;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.chip__dismiss:hover {
|
|
110
|
+
opacity: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.chip__dismiss svg {
|
|
114
|
+
width: 10px;
|
|
115
|
+
height: 10px;
|
|
116
|
+
stroke: currentColor;
|
|
117
|
+
stroke-width: 2.5;
|
|
118
|
+
stroke-linecap: round;
|
|
119
|
+
fill: none;
|
|
120
|
+
}
|
|
121
|
+
`
|
|
122
|
+
];
|
|
123
|
+
export {
|
|
124
|
+
i as styles
|
|
125
|
+
};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { html as _, nothing as y } from "lit";
|
|
2
|
+
import { property as c, state as u, customElement as w } from "lit/decorators.js";
|
|
3
|
+
import { classMap as f } from "lit/directives/class-map.js";
|
|
4
|
+
import { RekeElement as D } from "../../shared/base-element.js";
|
|
5
|
+
import { styles as S } from "./reke-date-range.styles.js";
|
|
6
|
+
var M = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, o = (e, t, i, s) => {
|
|
7
|
+
for (var a = s > 1 ? void 0 : s ? $(t, i) : t, n = e.length - 1, h; n >= 0; n--)
|
|
8
|
+
(h = e[n]) && (a = (s ? h(t, i, a) : h(a)) || a);
|
|
9
|
+
return s && a && M(t, i, a), a;
|
|
10
|
+
};
|
|
11
|
+
const k = [
|
|
12
|
+
"Enero",
|
|
13
|
+
"Febrero",
|
|
14
|
+
"Marzo",
|
|
15
|
+
"Abril",
|
|
16
|
+
"Mayo",
|
|
17
|
+
"Junio",
|
|
18
|
+
"Julio",
|
|
19
|
+
"Agosto",
|
|
20
|
+
"Septiembre",
|
|
21
|
+
"Octubre",
|
|
22
|
+
"Noviembre",
|
|
23
|
+
"Diciembre"
|
|
24
|
+
], x = ["Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"];
|
|
25
|
+
function l(e) {
|
|
26
|
+
if (!e) return null;
|
|
27
|
+
const [t, i, s] = e.split("-").map(Number);
|
|
28
|
+
return !t || !i || !s ? null : new Date(t, i - 1, s);
|
|
29
|
+
}
|
|
30
|
+
function d(e) {
|
|
31
|
+
const t = e.getFullYear(), i = String(e.getMonth() + 1).padStart(2, "0"), s = String(e.getDate()).padStart(2, "0");
|
|
32
|
+
return `${t}-${i}-${s}`;
|
|
33
|
+
}
|
|
34
|
+
function m(e) {
|
|
35
|
+
const t = String(e.getDate()).padStart(2, "0"), i = String(e.getMonth() + 1).padStart(2, "0");
|
|
36
|
+
return `${t}/${i}/${e.getFullYear()}`;
|
|
37
|
+
}
|
|
38
|
+
function p(e, t) {
|
|
39
|
+
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
40
|
+
}
|
|
41
|
+
function Y(e, t) {
|
|
42
|
+
let s = new Date(e, t, 1).getDay() - 1;
|
|
43
|
+
s < 0 && (s = 6);
|
|
44
|
+
const a = new Date(e, t, 1 - s), n = [];
|
|
45
|
+
for (let h = 0; h < 42; h++) {
|
|
46
|
+
const g = new Date(a.getFullYear(), a.getMonth(), a.getDate() + h);
|
|
47
|
+
n.push({ date: g, day: g.getDate(), otherMonth: g.getMonth() !== t });
|
|
48
|
+
}
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
let r = class extends D {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments), this.mode = "range", this.value = "", this.from = "", this.to = "", this.label = "", this.placeholder = "", this.min = "", this.max = "", this.disabled = !1, this.error = !1, this._open = !1, this._viewYear = (/* @__PURE__ */ new Date()).getFullYear(), this._viewMonth = (/* @__PURE__ */ new Date()).getMonth(), this._rangeSelecting = !1, this._boundOutsideClick = this._onOutsideClick.bind(this), this._onKeyDown = (e) => {
|
|
54
|
+
if (e.key === "Escape" && this._open) {
|
|
55
|
+
if (this._rangeSelecting && this.from) {
|
|
56
|
+
this.to = this.from, this._rangeSelecting = !1, this._open = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._open = !1, this._rangeSelecting = !1;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
connectedCallback() {
|
|
64
|
+
super.connectedCallback(), document.addEventListener("click", this._boundOutsideClick, !0), document.addEventListener("keydown", this._onKeyDown);
|
|
65
|
+
}
|
|
66
|
+
disconnectedCallback() {
|
|
67
|
+
super.disconnectedCallback(), document.removeEventListener("click", this._boundOutsideClick, !0), document.removeEventListener("keydown", this._onKeyDown);
|
|
68
|
+
}
|
|
69
|
+
_onOutsideClick(e) {
|
|
70
|
+
if (!this._open) return;
|
|
71
|
+
if (!e.composedPath().includes(this)) {
|
|
72
|
+
if (this._rangeSelecting && this.from) {
|
|
73
|
+
this.to = this.from, this._rangeSelecting = !1, this._open = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this._open = !1, this._rangeSelecting = !1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_toggleOpen() {
|
|
80
|
+
if (!this.disabled)
|
|
81
|
+
if (this._open = !this._open, this._open)
|
|
82
|
+
this._syncView();
|
|
83
|
+
else {
|
|
84
|
+
if (this._rangeSelecting && this.from) {
|
|
85
|
+
this.to = this.from, this._rangeSelecting = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this._rangeSelecting = !1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Sync calendar view to the current selection. */
|
|
92
|
+
_syncView() {
|
|
93
|
+
let e = null;
|
|
94
|
+
if (this.mode === "single" ? e = l(this.value) : e = l(this.from), e)
|
|
95
|
+
this._viewYear = e.getFullYear(), this._viewMonth = e.getMonth();
|
|
96
|
+
else {
|
|
97
|
+
const t = /* @__PURE__ */ new Date();
|
|
98
|
+
this._viewYear = t.getFullYear(), this._viewMonth = t.getMonth();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_prevYear() {
|
|
102
|
+
this._viewYear--;
|
|
103
|
+
}
|
|
104
|
+
_nextYear() {
|
|
105
|
+
this._viewYear++;
|
|
106
|
+
}
|
|
107
|
+
_prevMonth() {
|
|
108
|
+
this._viewMonth === 0 ? (this._viewMonth = 11, this._viewYear--) : this._viewMonth--;
|
|
109
|
+
}
|
|
110
|
+
_nextMonth() {
|
|
111
|
+
this._viewMonth === 11 ? (this._viewMonth = 0, this._viewYear++) : this._viewMonth++;
|
|
112
|
+
}
|
|
113
|
+
_isDisabledDate(e) {
|
|
114
|
+
const t = l(this.min), i = l(this.max);
|
|
115
|
+
return !!(t && e < t || i && e > i);
|
|
116
|
+
}
|
|
117
|
+
_selectDay(e) {
|
|
118
|
+
if (!this._isDisabledDate(e.date)) {
|
|
119
|
+
if (this.mode === "single") {
|
|
120
|
+
this.value = d(e.date), this._open = !1, this.emit("reke-change", { value: this.value });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!this._rangeSelecting)
|
|
124
|
+
this.from = d(e.date), this.to = "", this._rangeSelecting = !0;
|
|
125
|
+
else {
|
|
126
|
+
let t = l(this.from), i = e.date;
|
|
127
|
+
i < t && ([t, i] = [i, t]), this.from = d(t), this.to = d(i), this._rangeSelecting = !1, this._open = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
_goToday() {
|
|
132
|
+
const e = /* @__PURE__ */ new Date(), t = d(e);
|
|
133
|
+
if (this._viewYear = e.getFullYear(), this._viewMonth = e.getMonth(), this.mode === "single")
|
|
134
|
+
this.value = t, this._open = !1, this.emit("reke-change", { value: this.value });
|
|
135
|
+
else if (this._rangeSelecting && this.from) {
|
|
136
|
+
let i = l(this.from), s = e;
|
|
137
|
+
s < i && ([i, s] = [s, i]), this.from = d(i), this.to = d(s), this._rangeSelecting = !1, this._open = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
138
|
+
} else
|
|
139
|
+
this.from = t, this.to = t, this._rangeSelecting = !1, this._open = !1, this.emit("reke-change", { from: this.from, to: this.to });
|
|
140
|
+
}
|
|
141
|
+
_clear() {
|
|
142
|
+
this.mode === "single" ? (this.value = "", this.emit("reke-change", { value: "" })) : (this.from = "", this.to = "", this._rangeSelecting = !1, this.emit("reke-change", { from: "", to: "" })), this._open = !1;
|
|
143
|
+
}
|
|
144
|
+
_getDayClasses(e) {
|
|
145
|
+
const t = /* @__PURE__ */ new Date(), i = p(e.date, t), s = this._isDisabledDate(e.date);
|
|
146
|
+
if (this.mode === "single") {
|
|
147
|
+
const v = l(this.value);
|
|
148
|
+
return {
|
|
149
|
+
calendar__day: !0,
|
|
150
|
+
"calendar__day--other": e.otherMonth,
|
|
151
|
+
"calendar__day--today": i,
|
|
152
|
+
"calendar__day--selected": !!v && p(e.date, v),
|
|
153
|
+
"calendar__day--disabled": s
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const a = l(this.from), n = l(this.to), h = !!a && p(e.date, a), g = !!n && p(e.date, n), b = !!a && !!n && e.date > a && e.date < n;
|
|
157
|
+
return {
|
|
158
|
+
calendar__day: !0,
|
|
159
|
+
"calendar__day--other": e.otherMonth,
|
|
160
|
+
"calendar__day--today": i && !h && !g,
|
|
161
|
+
"calendar__day--selected": (this.mode === "range", !1),
|
|
162
|
+
"calendar__day--in-range": b,
|
|
163
|
+
"calendar__day--range-start": h,
|
|
164
|
+
"calendar__day--range-end": g,
|
|
165
|
+
"calendar__day--disabled": s
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
_getDisplayText() {
|
|
169
|
+
if (this.mode === "single") {
|
|
170
|
+
const a = l(this.value);
|
|
171
|
+
return a ? m(a) : this.placeholder || "Seleccionar fecha";
|
|
172
|
+
}
|
|
173
|
+
const e = l(this.from), t = l(this.to);
|
|
174
|
+
if (!e && !t)
|
|
175
|
+
return this.placeholder || "Seleccionar rango";
|
|
176
|
+
const i = e ? m(e) : "—", s = t ? m(t) : "—";
|
|
177
|
+
return _`${i} <span class="trigger__separator">→</span> ${s}`;
|
|
178
|
+
}
|
|
179
|
+
_hasValue() {
|
|
180
|
+
return this.mode === "single" ? !!this.value : !!(this.from || this.to);
|
|
181
|
+
}
|
|
182
|
+
_renderCalendarIcon() {
|
|
183
|
+
return _`
|
|
184
|
+
<span class="trigger__icon" aria-hidden="true">
|
|
185
|
+
<svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
|
|
186
|
+
</span>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
_renderChevron() {
|
|
190
|
+
return _`
|
|
191
|
+
<span class="trigger__chevron" aria-hidden="true">
|
|
192
|
+
<svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
|
193
|
+
</span>
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
render() {
|
|
197
|
+
const e = Y(this._viewYear, this._viewMonth), t = !this._hasValue(), i = `${k[this._viewMonth]} ${this._viewYear}`, s = {
|
|
198
|
+
trigger: !0,
|
|
199
|
+
"trigger--open": this._open,
|
|
200
|
+
"trigger--error": this.error,
|
|
201
|
+
"trigger--placeholder": t
|
|
202
|
+
}, a = {
|
|
203
|
+
label: !0,
|
|
204
|
+
"label--active": this._open
|
|
205
|
+
};
|
|
206
|
+
return _`
|
|
207
|
+
${this.label ? _`<span class=${f(a)}>${this.label}</span>` : y}
|
|
208
|
+
|
|
209
|
+
<button
|
|
210
|
+
part="trigger"
|
|
211
|
+
class=${f(s)}
|
|
212
|
+
type="button"
|
|
213
|
+
@click=${this._toggleOpen}
|
|
214
|
+
aria-haspopup="dialog"
|
|
215
|
+
aria-expanded=${this._open}
|
|
216
|
+
?disabled=${this.disabled}
|
|
217
|
+
>
|
|
218
|
+
${this._renderCalendarIcon()}
|
|
219
|
+
<span class="trigger__text">${this._getDisplayText()}</span>
|
|
220
|
+
${this._renderChevron()}
|
|
221
|
+
</button>
|
|
222
|
+
|
|
223
|
+
${this._open ? _`
|
|
224
|
+
<div part="calendar" class="calendar" role="dialog" aria-label="Calendar">
|
|
225
|
+
<div class="calendar__header">
|
|
226
|
+
<span class="calendar__title">${i}</span>
|
|
227
|
+
<div class="calendar__nav">
|
|
228
|
+
<button
|
|
229
|
+
class="calendar__nav-btn"
|
|
230
|
+
type="button"
|
|
231
|
+
@click=${this._prevYear}
|
|
232
|
+
aria-label="Previous year"
|
|
233
|
+
>
|
|
234
|
+
<svg viewBox="0 0 24 24"><polyline points="17 18 11 12 17 6"/><polyline points="11 18 5 12 11 6"/></svg>
|
|
235
|
+
</button>
|
|
236
|
+
<button
|
|
237
|
+
class="calendar__nav-btn"
|
|
238
|
+
type="button"
|
|
239
|
+
@click=${this._prevMonth}
|
|
240
|
+
aria-label="Previous month"
|
|
241
|
+
>
|
|
242
|
+
<svg viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"/></svg>
|
|
243
|
+
</button>
|
|
244
|
+
<button
|
|
245
|
+
class="calendar__nav-btn"
|
|
246
|
+
type="button"
|
|
247
|
+
@click=${this._nextMonth}
|
|
248
|
+
aria-label="Next month"
|
|
249
|
+
>
|
|
250
|
+
<svg viewBox="0 0 24 24"><polyline points="9 6 15 12 9 18"/></svg>
|
|
251
|
+
</button>
|
|
252
|
+
<button
|
|
253
|
+
class="calendar__nav-btn"
|
|
254
|
+
type="button"
|
|
255
|
+
@click=${this._nextYear}
|
|
256
|
+
aria-label="Next year"
|
|
257
|
+
>
|
|
258
|
+
<svg viewBox="0 0 24 24"><polyline points="7 6 13 12 7 18"/><polyline points="13 6 19 12 13 18"/></svg>
|
|
259
|
+
</button>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
<div class="calendar__weekdays">
|
|
264
|
+
${x.map(
|
|
265
|
+
(n) => _`<span class="calendar__weekday">${n}</span>`
|
|
266
|
+
)}
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div class="calendar__grid">
|
|
270
|
+
${e.map(
|
|
271
|
+
(n) => _`
|
|
272
|
+
<button
|
|
273
|
+
class=${f(this._getDayClasses(n))}
|
|
274
|
+
type="button"
|
|
275
|
+
@click=${() => this._selectDay(n)}
|
|
276
|
+
?disabled=${this._isDisabledDate(n.date)}
|
|
277
|
+
aria-label="${n.date.toLocaleDateString("es-ES", { day: "numeric", month: "long", year: "numeric" })}"
|
|
278
|
+
>
|
|
279
|
+
${n.day}
|
|
280
|
+
</button>
|
|
281
|
+
`
|
|
282
|
+
)}
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<div class="calendar__footer">
|
|
286
|
+
<button class="calendar__action calendar__action--today" type="button" @click=${this._goToday}>
|
|
287
|
+
Hoy
|
|
288
|
+
</button>
|
|
289
|
+
<button class="calendar__action calendar__action--clear" type="button" @click=${this._clear}>
|
|
290
|
+
Limpiar
|
|
291
|
+
</button>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
` : y}
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
r.styles = S;
|
|
299
|
+
o([
|
|
300
|
+
c({ reflect: !0 })
|
|
301
|
+
], r.prototype, "mode", 2);
|
|
302
|
+
o([
|
|
303
|
+
c()
|
|
304
|
+
], r.prototype, "value", 2);
|
|
305
|
+
o([
|
|
306
|
+
c()
|
|
307
|
+
], r.prototype, "from", 2);
|
|
308
|
+
o([
|
|
309
|
+
c()
|
|
310
|
+
], r.prototype, "to", 2);
|
|
311
|
+
o([
|
|
312
|
+
c()
|
|
313
|
+
], r.prototype, "label", 2);
|
|
314
|
+
o([
|
|
315
|
+
c()
|
|
316
|
+
], r.prototype, "placeholder", 2);
|
|
317
|
+
o([
|
|
318
|
+
c()
|
|
319
|
+
], r.prototype, "min", 2);
|
|
320
|
+
o([
|
|
321
|
+
c()
|
|
322
|
+
], r.prototype, "max", 2);
|
|
323
|
+
o([
|
|
324
|
+
c({ type: Boolean, reflect: !0 })
|
|
325
|
+
], r.prototype, "disabled", 2);
|
|
326
|
+
o([
|
|
327
|
+
c({ type: Boolean, reflect: !0 })
|
|
328
|
+
], r.prototype, "error", 2);
|
|
329
|
+
o([
|
|
330
|
+
u()
|
|
331
|
+
], r.prototype, "_open", 2);
|
|
332
|
+
o([
|
|
333
|
+
u()
|
|
334
|
+
], r.prototype, "_viewYear", 2);
|
|
335
|
+
o([
|
|
336
|
+
u()
|
|
337
|
+
], r.prototype, "_viewMonth", 2);
|
|
338
|
+
o([
|
|
339
|
+
u()
|
|
340
|
+
], r.prototype, "_rangeSelecting", 2);
|
|
341
|
+
r = o([
|
|
342
|
+
w("reke-date-range")
|
|
343
|
+
], r);
|
|
344
|
+
export {
|
|
345
|
+
r as RekeDateRange
|
|
346
|
+
};
|