@deepfuture/dui-components 0.0.20 → 1.0.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/README.md +56 -65
- package/_install.js +11 -0
- package/accordion/accordion-item.d.ts +3 -20
- package/accordion/accordion-item.js +93 -292
- package/accordion/accordion.d.ts +3 -18
- package/accordion/accordion.js +9 -247
- package/accordion/index.d.ts +6 -6
- package/accordion/index.js +5 -5
- package/alert-dialog/alert-dialog-close.d.ts +3 -14
- package/alert-dialog/alert-dialog-close.js +4 -34
- package/alert-dialog/alert-dialog-popup.d.ts +3 -32
- package/alert-dialog/alert-dialog-popup.js +68 -317
- package/alert-dialog/alert-dialog-trigger.d.ts +3 -14
- package/alert-dialog/alert-dialog-trigger.js +4 -51
- package/alert-dialog/alert-dialog.d.ts +3 -30
- package/alert-dialog/alert-dialog.js +8 -158
- package/alert-dialog/index.d.ts +11 -11
- package/alert-dialog/index.js +9 -9
- package/all.d.ts +159 -123
- package/all.js +134 -231
- package/avatar/avatar.d.ts +3 -39
- package/avatar/avatar.js +18 -238
- package/avatar/index.d.ts +4 -4
- package/avatar/index.js +3 -3
- package/badge/badge.d.ts +3 -10
- package/badge/badge.js +88 -22
- package/badge/index.d.ts +2 -3
- package/badge/index.js +2 -3
- package/breadcrumb/breadcrumb-ellipsis.d.ts +3 -12
- package/breadcrumb/breadcrumb-ellipsis.js +8 -34
- package/breadcrumb/breadcrumb-item.d.ts +3 -11
- package/breadcrumb/breadcrumb-item.js +7 -26
- package/breadcrumb/breadcrumb-link.d.ts +3 -12
- package/breadcrumb/breadcrumb-link.js +16 -26
- package/breadcrumb/breadcrumb-page.d.ts +3 -11
- package/breadcrumb/breadcrumb-page.js +8 -31
- package/breadcrumb/breadcrumb-separator.d.ts +3 -12
- package/breadcrumb/breadcrumb-separator.js +8 -31
- package/breadcrumb/breadcrumb.d.ts +3 -12
- package/breadcrumb/breadcrumb.js +10 -33
- package/breadcrumb/index.d.ts +12 -13
- package/breadcrumb/index.js +12 -13
- package/button/button.d.ts +3 -32
- package/button/button.js +221 -165
- package/button/index.d.ts +3 -3
- package/button/index.js +3 -3
- package/calendar/calendar.d.ts +3 -31
- package/calendar/calendar.js +71 -481
- package/calendar/index.d.ts +3 -3
- package/calendar/index.js +3 -3
- package/card/card.d.ts +3 -27
- package/card/card.js +80 -163
- package/card/index.d.ts +2 -3
- package/card/index.js +2 -3
- package/card-grid/card-grid.d.ts +3 -15
- package/card-grid/card-grid.js +8 -106
- package/card-grid/index.d.ts +2 -3
- package/card-grid/index.js +2 -3
- package/checkbox/checkbox-group.d.ts +3 -34
- package/checkbox/checkbox-group.js +11 -188
- package/checkbox/checkbox.d.ts +3 -47
- package/checkbox/checkbox.js +43 -341
- package/checkbox/index.d.ts +6 -6
- package/checkbox/index.js +5 -5
- package/collapsible/collapsible.d.ts +3 -20
- package/collapsible/collapsible.js +83 -277
- package/collapsible/index.d.ts +3 -3
- package/collapsible/index.js +3 -3
- package/combobox/combobox.d.ts +3 -47
- package/combobox/combobox.js +136 -538
- package/combobox/index.d.ts +4 -4
- package/combobox/index.js +3 -3
- package/command/command-empty.d.ts +3 -8
- package/command/command-empty.js +10 -88
- package/command/command-group.d.ts +3 -13
- package/command/command-group.js +15 -114
- package/command/command-input.d.ts +3 -11
- package/command/command-input.js +20 -136
- package/command/command-item.d.ts +3 -18
- package/command/command-item.js +24 -212
- package/command/command-list.d.ts +3 -7
- package/command/command-list.js +11 -79
- package/command/command-separator.d.ts +3 -5
- package/command/command-separator.js +10 -11
- package/command/command-shortcut.d.ts +3 -5
- package/command/command-shortcut.js +9 -12
- package/command/command.d.ts +3 -23
- package/command/command.js +10 -339
- package/command/index.d.ts +17 -19
- package/command/index.js +16 -18
- package/data-table/data-table.d.ts +3 -57
- package/data-table/data-table.js +86 -449
- package/data-table/index.d.ts +3 -4
- package/data-table/index.js +2 -3
- package/dialog/dialog-close.d.ts +3 -14
- package/dialog/dialog-close.js +4 -34
- package/dialog/dialog-popup.d.ts +3 -34
- package/dialog/dialog-popup.js +70 -336
- package/dialog/dialog-trigger.d.ts +3 -14
- package/dialog/dialog-trigger.js +4 -51
- package/dialog/dialog.d.ts +3 -30
- package/dialog/dialog.js +8 -158
- package/dialog/index.d.ts +11 -11
- package/dialog/index.js +9 -9
- package/dropzone/dropzone.d.ts +3 -72
- package/dropzone/dropzone.js +29 -407
- package/dropzone/index.d.ts +4 -4
- package/dropzone/index.js +3 -3
- package/field/field.d.ts +3 -30
- package/field/field.js +34 -353
- package/field/index.d.ts +1 -0
- package/field/index.js +1 -0
- package/fieldset/fieldset.d.ts +3 -18
- package/fieldset/fieldset.js +21 -110
- package/fieldset/index.d.ts +1 -0
- package/fieldset/index.js +1 -0
- package/icon/icon.d.ts +3 -15
- package/icon/icon.js +4 -33
- package/icon/index.d.ts +2 -3
- package/icon/index.js +2 -3
- package/input/index.d.ts +3 -3
- package/input/index.js +3 -3
- package/input/input.d.ts +3 -49
- package/input/input.js +57 -238
- package/menu/index.d.ts +4 -5
- package/menu/index.js +4 -5
- package/menu/menu-item.d.ts +3 -13
- package/menu/menu-item.js +41 -91
- package/menu/menu.d.ts +3 -15
- package/menu/menu.js +27 -277
- package/menubar/index.d.ts +3 -4
- package/menubar/index.js +2 -3
- package/menubar/menubar.d.ts +3 -19
- package/menubar/menubar.js +12 -183
- package/number-field/index.d.ts +3 -3
- package/number-field/index.js +3 -3
- package/number-field/number-field.d.ts +3 -55
- package/number-field/number-field.js +205 -698
- package/package.json +126 -113
- package/popover/index.d.ts +11 -11
- package/popover/index.js +9 -9
- package/popover/popover-close.d.ts +3 -12
- package/popover/popover-close.js +4 -32
- package/popover/popover-popup.d.ts +3 -18
- package/popover/popover-popup.js +28 -205
- package/popover/popover-trigger.d.ts +3 -13
- package/popover/popover-trigger.js +4 -73
- package/popover/popover.d.ts +3 -29
- package/popover/popover.js +8 -207
- package/portal/index.d.ts +3 -4
- package/portal/index.js +2 -3
- package/portal/portal.d.ts +3 -27
- package/portal/portal.js +8 -157
- package/preview-card/index.d.ts +9 -9
- package/preview-card/index.js +7 -7
- package/preview-card/preview-card-popup.d.ts +3 -14
- package/preview-card/preview-card-popup.js +29 -193
- package/preview-card/preview-card-trigger.d.ts +3 -12
- package/preview-card/preview-card-trigger.js +4 -74
- package/preview-card/preview-card.d.ts +3 -33
- package/preview-card/preview-card.js +8 -239
- package/progress/index.d.ts +2 -3
- package/progress/index.js +2 -3
- package/progress/progress.d.ts +3 -17
- package/progress/progress.js +28 -130
- package/radio/index.d.ts +6 -6
- package/radio/index.js +5 -5
- package/radio/radio-group.d.ts +3 -37
- package/radio/radio-group.js +8 -200
- package/radio/radio.d.ts +3 -28
- package/radio/radio.js +38 -213
- package/scroll-area/index.d.ts +2 -3
- package/scroll-area/index.js +2 -3
- package/scroll-area/scroll-area.d.ts +3 -36
- package/scroll-area/scroll-area.js +25 -546
- package/select/index.d.ts +3 -4
- package/select/index.js +2 -3
- package/select/select.d.ts +3 -37
- package/select/select.js +115 -403
- package/separator/index.d.ts +2 -3
- package/separator/index.js +2 -3
- package/separator/separator.d.ts +3 -10
- package/separator/separator.js +23 -84
- package/sidebar/index.d.ts +29 -29
- package/sidebar/index.js +27 -32
- package/sidebar/sidebar-content.d.ts +3 -12
- package/sidebar/sidebar-content.js +7 -29
- package/sidebar/sidebar-footer.d.ts +3 -10
- package/sidebar/sidebar-footer.js +7 -20
- package/sidebar/sidebar-group-label.d.ts +3 -15
- package/sidebar/sidebar-group-label.js +17 -41
- package/sidebar/sidebar-group.d.ts +3 -13
- package/sidebar/sidebar-group.js +7 -24
- package/sidebar/sidebar-header.d.ts +3 -10
- package/sidebar/sidebar-header.js +7 -16
- package/sidebar/sidebar-inset.d.ts +3 -13
- package/sidebar/sidebar-inset.js +7 -28
- package/sidebar/sidebar-menu-button.d.ts +3 -26
- package/sidebar/sidebar-menu-button.js +60 -217
- package/sidebar/sidebar-menu-item.d.ts +3 -10
- package/sidebar/sidebar-menu-item.js +7 -19
- package/sidebar/sidebar-menu.d.ts +3 -12
- package/sidebar/sidebar-menu.js +7 -25
- package/sidebar/sidebar-provider.d.ts +3 -34
- package/sidebar/sidebar-provider.js +22 -232
- package/sidebar/sidebar-separator.d.ts +3 -10
- package/sidebar/sidebar-separator.js +9 -19
- package/sidebar/sidebar-trigger.d.ts +3 -14
- package/sidebar/sidebar-trigger.js +10 -46
- package/sidebar/sidebar.d.ts +3 -19
- package/sidebar/sidebar.js +65 -262
- package/slider/index.d.ts +3 -3
- package/slider/index.js +3 -3
- package/slider/slider.d.ts +3 -45
- package/slider/slider.js +97 -382
- package/spinner/index.d.ts +2 -3
- package/spinner/index.js +2 -3
- package/spinner/spinner.d.ts +3 -11
- package/spinner/spinner.js +20 -163
- package/split-button/index.d.ts +3 -1
- package/split-button/index.js +3 -1
- package/split-button/split-button.d.ts +3 -31
- package/split-button/split-button.js +307 -384
- package/stepper/index.d.ts +3 -3
- package/stepper/index.js +3 -3
- package/stepper/stepper.d.ts +3 -41
- package/stepper/stepper.js +57 -381
- package/switch/index.d.ts +3 -3
- package/switch/index.js +3 -3
- package/switch/switch.d.ts +3 -30
- package/switch/switch.js +63 -228
- package/tabs/index.d.ts +12 -12
- package/tabs/index.js +11 -11
- package/tabs/tab.d.ts +3 -14
- package/tabs/tab.js +33 -131
- package/tabs/tabs-indicator.d.ts +3 -9
- package/tabs/tabs-indicator.js +17 -22
- package/tabs/tabs-list.d.ts +3 -15
- package/tabs/tabs-list.js +14 -113
- package/tabs/tabs-panel.d.ts +3 -16
- package/tabs/tabs-panel.js +32 -114
- package/tabs/tabs.d.ts +3 -22
- package/tabs/tabs.js +8 -170
- package/textarea/index.d.ts +4 -4
- package/textarea/index.js +3 -3
- package/textarea/textarea.d.ts +3 -36
- package/textarea/textarea.js +63 -220
- package/toggle/index.d.ts +6 -6
- package/toggle/index.js +5 -5
- package/toggle/toggle-group.d.ts +3 -27
- package/toggle/toggle-group.js +9 -224
- package/toggle/toggle.d.ts +3 -26
- package/toggle/toggle.js +94 -178
- package/tokens/properties.css +361 -0
- package/tokens/prose.css +250 -0
- package/tokens/prose.d.ts +2 -0
- package/tokens/prose.js +4 -0
- package/tokens/tokens-raw.d.ts +2 -0
- package/tokens/tokens-raw.js +2 -0
- package/tokens/tokens.css +409 -0
- package/tokens/tokens.d.ts +2 -0
- package/tokens/tokens.js +5 -0
- package/toolbar/index.d.ts +2 -3
- package/toolbar/index.js +2 -3
- package/toolbar/toolbar.d.ts +3 -11
- package/toolbar/toolbar.js +25 -116
- package/tooltip/index.d.ts +9 -9
- package/tooltip/index.js +7 -7
- package/tooltip/tooltip-popup.d.ts +3 -14
- package/tooltip/tooltip-popup.js +32 -185
- package/tooltip/tooltip-trigger.d.ts +3 -14
- package/tooltip/tooltip-trigger.js +5 -148
- package/tooltip/tooltip.d.ts +3 -35
- package/tooltip/tooltip.js +8 -253
- package/trunc/index.d.ts +2 -3
- package/trunc/index.js +2 -3
- package/trunc/trunc.d.ts +3 -17
- package/trunc/trunc.js +10 -108
- package/_deprecated/center/center.d.ts +0 -14
- package/_deprecated/center/center.js +0 -37
- package/_deprecated/center/index.d.ts +0 -3
- package/_deprecated/center/index.js +0 -3
- package/_deprecated/center/register.js +0 -4
- package/_deprecated/hstack/hstack.d.ts +0 -25
- package/_deprecated/hstack/hstack.js +0 -187
- package/_deprecated/hstack/index.d.ts +0 -4
- package/_deprecated/hstack/index.js +0 -3
- package/_deprecated/hstack/register.d.ts +0 -1
- package/_deprecated/hstack/register.js +0 -4
- package/_deprecated/page-inset/index.d.ts +0 -3
- package/_deprecated/page-inset/index.js +0 -3
- package/_deprecated/page-inset/page-inset.d.ts +0 -28
- package/_deprecated/page-inset/page-inset.js +0 -151
- package/_deprecated/page-inset/register.d.ts +0 -1
- package/_deprecated/page-inset/register.js +0 -4
- package/_deprecated/vstack/index.d.ts +0 -3
- package/_deprecated/vstack/index.js +0 -3
- package/_deprecated/vstack/register.d.ts +0 -1
- package/_deprecated/vstack/register.js +0 -4
- package/_deprecated/vstack/vstack.d.ts +0 -17
- package/_deprecated/vstack/vstack.js +0 -125
- package/accordion/accordion-context.d.ts +0 -15
- package/accordion/accordion-context.js +0 -3
- package/alert-dialog/alert-dialog-context.d.ts +0 -13
- package/alert-dialog/alert-dialog-context.js +0 -3
- package/checkbox/checkbox-group-context.d.ts +0 -11
- package/checkbox/checkbox-group-context.js +0 -3
- package/command/command-context.d.ts +0 -30
- package/command/command-context.js +0 -3
- package/command/command-score.d.ts +0 -6
- package/command/command-score.js +0 -31
- package/dialog/dialog-context.d.ts +0 -13
- package/dialog/dialog-context.js +0 -3
- package/global.d.ts +0 -179
- package/menubar/menubar-context.d.ts +0 -9
- package/menubar/menubar-context.js +0 -2
- package/popover/popover-context.d.ts +0 -17
- package/popover/popover-context.js +0 -3
- package/preview-card/preview-card-context.d.ts +0 -16
- package/preview-card/preview-card-context.js +0 -3
- package/radio/radio-group-context.d.ts +0 -11
- package/radio/radio-group-context.js +0 -2
- package/sidebar/sidebar-context.d.ts +0 -15
- package/sidebar/sidebar-context.js +0 -3
- package/split-button/register.d.ts +0 -1
- package/split-button/register.js +0 -4
- package/tabs/tabs-context.d.ts +0 -8
- package/tabs/tabs-context.js +0 -2
- package/toggle/toggle-group-context.d.ts +0 -9
- package/toggle/toggle-group-context.js +0 -2
- package/tooltip/tooltip-context.d.ts +0 -17
- package/tooltip/tooltip-context.js +0 -3
- /package/{_deprecated/center/register.d.ts → _install.d.ts} +0 -0
package/button/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiButton
|
|
3
|
-
export
|
|
1
|
+
import "./button.js";
|
|
2
|
+
export { DuiButton } from "./button.js";
|
|
3
|
+
export { navigateEvent } from "@deepfuture/dui-primitives/button";
|
package/button/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiButton
|
|
3
|
-
export
|
|
1
|
+
import "./button.js";
|
|
2
|
+
export { DuiButton } from "./button.js";
|
|
3
|
+
export { navigateEvent } from "@deepfuture/dui-primitives/button";
|
package/calendar/calendar.d.ts
CHANGED
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}) => CustomEvent<{
|
|
5
|
-
value: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* `<dui-calendar>` — A date picker calendar grid.
|
|
9
|
-
*
|
|
10
|
-
* @csspart root - The outer container.
|
|
11
|
-
* @csspart header - Month navigation header.
|
|
12
|
-
* @csspart heading - The month/year heading text.
|
|
13
|
-
* @csspart prev - Previous month button.
|
|
14
|
-
* @csspart next - Next month button.
|
|
15
|
-
* @csspart grid - The day grid container.
|
|
16
|
-
* @csspart weekday - Weekday column header.
|
|
17
|
-
* @csspart day - Individual day button.
|
|
18
|
-
* @fires value-change - Fired when a date is selected. Detail: { value: string }
|
|
19
|
-
*/
|
|
20
|
-
export declare class DuiCalendar extends LitElement {
|
|
21
|
-
#private;
|
|
22
|
-
static tagName: "dui-calendar";
|
|
1
|
+
import { DuiCalendarPrimitive } from "@deepfuture/dui-primitives/calendar";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
export declare class DuiCalendar extends DuiCalendarPrimitive {
|
|
23
4
|
static styles: import("lit").CSSResult[];
|
|
24
|
-
accessor value: string | undefined;
|
|
25
|
-
accessor defaultValue: string | undefined;
|
|
26
|
-
accessor min: string | undefined;
|
|
27
|
-
accessor max: string | undefined;
|
|
28
|
-
accessor locale: string;
|
|
29
|
-
accessor disabled: boolean;
|
|
30
|
-
accessor readOnly: boolean;
|
|
31
|
-
connectedCallback(): void;
|
|
32
|
-
render(): TemplateResult;
|
|
33
5
|
}
|
package/calendar/calendar.js
CHANGED
|
@@ -1,506 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
-
var _, done = false;
|
|
7
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
-
var context = {};
|
|
9
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
-
if (kind === "accessor") {
|
|
14
|
-
if (result === void 0) continue;
|
|
15
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
-
}
|
|
20
|
-
else if (_ = accept(result)) {
|
|
21
|
-
if (kind === "field") initializers.unshift(_);
|
|
22
|
-
else descriptor[key] = _;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
-
done = true;
|
|
27
|
-
};
|
|
28
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
-
var useValue = arguments.length > 2;
|
|
30
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
-
}
|
|
33
|
-
return useValue ? value : void 0;
|
|
34
|
-
};
|
|
35
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
36
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
37
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
38
|
-
};
|
|
39
|
-
import { css, html, LitElement } from "lit";
|
|
40
|
-
import { property, state } from "lit/decorators.js";
|
|
41
|
-
import { base } from "@deepfuture/dui-core/base";
|
|
42
|
-
import { customEvent } from "@deepfuture/dui-core/event";
|
|
43
|
-
export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
|
|
44
|
-
/** Structural styles only — layout CSS. */
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiCalendarPrimitive } from "@deepfuture/dui-primitives/calendar";
|
|
3
|
+
import "../_install.js";
|
|
45
4
|
const styles = css `
|
|
46
|
-
:host {
|
|
47
|
-
display: inline-block;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
5
|
[part="root"] {
|
|
51
|
-
|
|
52
|
-
|
|
6
|
+
padding: var(--space-3);
|
|
7
|
+
font-family: var(--font-sans);
|
|
8
|
+
font-size: var(--text-sm); line-height: var(--text-sm--line-height);
|
|
53
9
|
}
|
|
54
10
|
|
|
55
11
|
[part="header"] {
|
|
56
|
-
|
|
57
|
-
align-items: center;
|
|
58
|
-
justify-content: space-between;
|
|
12
|
+
padding-bottom: var(--space-2);
|
|
59
13
|
}
|
|
60
14
|
|
|
61
15
|
[part="heading"] {
|
|
62
|
-
font-
|
|
63
|
-
|
|
64
|
-
|
|
16
|
+
font-size: var(--text-sm); line-height: var(--text-sm--line-height);
|
|
17
|
+
font-weight: var(--font-weight-medium);
|
|
18
|
+
color: var(--text-1);
|
|
65
19
|
}
|
|
66
20
|
|
|
67
21
|
[part="prev"],
|
|
68
22
|
[part="next"] {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
font: inherit;
|
|
77
|
-
color: inherit;
|
|
23
|
+
width: var(--space-7);
|
|
24
|
+
height: var(--space-7);
|
|
25
|
+
border-radius: var(--radius-md);
|
|
26
|
+
color: var(--text-2);
|
|
27
|
+
font-size: var(--text-lg);
|
|
28
|
+
transition-property: background, color;
|
|
29
|
+
transition-duration: var(--duration-fast);
|
|
78
30
|
}
|
|
79
31
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
32
|
+
@media (hover: hover) {
|
|
33
|
+
[part="prev"]:hover,
|
|
34
|
+
[part="next"]:hover {
|
|
35
|
+
background: var(--surface-1);
|
|
36
|
+
color: var(--text-1);
|
|
37
|
+
}
|
|
83
38
|
}
|
|
84
39
|
|
|
85
40
|
[part="weekday"] {
|
|
86
|
-
|
|
87
|
-
|
|
41
|
+
width: var(--space-8);
|
|
42
|
+
height: var(--space-8);
|
|
43
|
+
font-size: var(--text-xs); line-height: var(--text-xs--line-height);
|
|
44
|
+
font-weight: var(--font-weight-regular);
|
|
45
|
+
color: var(--text-2);
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
88
49
|
}
|
|
89
50
|
|
|
90
51
|
[part="day"] {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
52
|
+
width: var(--space-8);
|
|
53
|
+
height: var(--space-8);
|
|
54
|
+
border-radius: var(--radius-md);
|
|
55
|
+
font-size: var(--text-sm); line-height: var(--text-sm--line-height);
|
|
56
|
+
color: var(--text-1);
|
|
57
|
+
transition-property: background, color;
|
|
58
|
+
transition-duration: var(--duration-fast);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@media (hover: hover) {
|
|
62
|
+
[part="day"]:hover:not(:disabled):not([data-selected]) {
|
|
63
|
+
background: var(--surface-1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part="day"][data-today]:not([data-selected]) {
|
|
68
|
+
background: var(--accent-subtle);
|
|
69
|
+
color: var(--accent-text);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[part="day"][data-selected] {
|
|
73
|
+
background: var(--accent);
|
|
74
|
+
color: oklch(from var(--accent) 0.98 0.01 h);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[part="day"][data-outside-month] {
|
|
78
|
+
color: var(--text-2);
|
|
79
|
+
opacity: 0.4;
|
|
100
80
|
}
|
|
101
81
|
|
|
102
82
|
[part="day"]:disabled {
|
|
103
|
-
|
|
83
|
+
opacity: 0.4;
|
|
104
84
|
}
|
|
105
|
-
`;
|
|
106
|
-
/**
|
|
107
|
-
* `<dui-calendar>` — A date picker calendar grid.
|
|
108
|
-
*
|
|
109
|
-
* @csspart root - The outer container.
|
|
110
|
-
* @csspart header - Month navigation header.
|
|
111
|
-
* @csspart heading - The month/year heading text.
|
|
112
|
-
* @csspart prev - Previous month button.
|
|
113
|
-
* @csspart next - Next month button.
|
|
114
|
-
* @csspart grid - The day grid container.
|
|
115
|
-
* @csspart weekday - Weekday column header.
|
|
116
|
-
* @csspart day - Individual day button.
|
|
117
|
-
* @fires value-change - Fired when a date is selected. Detail: { value: string }
|
|
118
|
-
*/
|
|
119
|
-
let DuiCalendar = (() => {
|
|
120
|
-
let _classSuper = LitElement;
|
|
121
|
-
let _value_decorators;
|
|
122
|
-
let _value_initializers = [];
|
|
123
|
-
let _value_extraInitializers = [];
|
|
124
|
-
let _defaultValue_decorators;
|
|
125
|
-
let _defaultValue_initializers = [];
|
|
126
|
-
let _defaultValue_extraInitializers = [];
|
|
127
|
-
let _min_decorators;
|
|
128
|
-
let _min_initializers = [];
|
|
129
|
-
let _min_extraInitializers = [];
|
|
130
|
-
let _max_decorators;
|
|
131
|
-
let _max_initializers = [];
|
|
132
|
-
let _max_extraInitializers = [];
|
|
133
|
-
let _locale_decorators;
|
|
134
|
-
let _locale_initializers = [];
|
|
135
|
-
let _locale_extraInitializers = [];
|
|
136
|
-
let _disabled_decorators;
|
|
137
|
-
let _disabled_initializers = [];
|
|
138
|
-
let _disabled_extraInitializers = [];
|
|
139
|
-
let _readOnly_decorators;
|
|
140
|
-
let _readOnly_initializers = [];
|
|
141
|
-
let _readOnly_extraInitializers = [];
|
|
142
|
-
let _private_internalValue_decorators;
|
|
143
|
-
let _private_internalValue_initializers = [];
|
|
144
|
-
let _private_internalValue_extraInitializers = [];
|
|
145
|
-
let _private_internalValue_descriptor;
|
|
146
|
-
let _private_focusedDate_decorators;
|
|
147
|
-
let _private_focusedDate_initializers = [];
|
|
148
|
-
let _private_focusedDate_extraInitializers = [];
|
|
149
|
-
let _private_focusedDate_descriptor;
|
|
150
|
-
let _private_viewMonth_decorators;
|
|
151
|
-
let _private_viewMonth_initializers = [];
|
|
152
|
-
let _private_viewMonth_extraInitializers = [];
|
|
153
|
-
let _private_viewMonth_descriptor;
|
|
154
|
-
let _private_viewYear_decorators;
|
|
155
|
-
let _private_viewYear_initializers = [];
|
|
156
|
-
let _private_viewYear_extraInitializers = [];
|
|
157
|
-
let _private_viewYear_descriptor;
|
|
158
|
-
return class DuiCalendar extends _classSuper {
|
|
159
|
-
static {
|
|
160
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
161
|
-
_value_decorators = [property()];
|
|
162
|
-
_defaultValue_decorators = [property({ attribute: "default-value" })];
|
|
163
|
-
_min_decorators = [property()];
|
|
164
|
-
_max_decorators = [property()];
|
|
165
|
-
_locale_decorators = [property()];
|
|
166
|
-
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
167
|
-
_readOnly_decorators = [property({ type: Boolean, reflect: true, attribute: "read-only" })];
|
|
168
|
-
_private_internalValue_decorators = [state()];
|
|
169
|
-
_private_focusedDate_decorators = [state()];
|
|
170
|
-
_private_viewMonth_decorators = [state()];
|
|
171
|
-
_private_viewYear_decorators = [state()];
|
|
172
|
-
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
173
|
-
__esDecorate(this, null, _defaultValue_decorators, { kind: "accessor", name: "defaultValue", static: false, private: false, access: { has: obj => "defaultValue" in obj, get: obj => obj.defaultValue, set: (obj, value) => { obj.defaultValue = value; } }, metadata: _metadata }, _defaultValue_initializers, _defaultValue_extraInitializers);
|
|
174
|
-
__esDecorate(this, null, _min_decorators, { kind: "accessor", name: "min", static: false, private: false, access: { has: obj => "min" in obj, get: obj => obj.min, set: (obj, value) => { obj.min = value; } }, metadata: _metadata }, _min_initializers, _min_extraInitializers);
|
|
175
|
-
__esDecorate(this, null, _max_decorators, { kind: "accessor", name: "max", static: false, private: false, access: { has: obj => "max" in obj, get: obj => obj.max, set: (obj, value) => { obj.max = value; } }, metadata: _metadata }, _max_initializers, _max_extraInitializers);
|
|
176
|
-
__esDecorate(this, null, _locale_decorators, { kind: "accessor", name: "locale", static: false, private: false, access: { has: obj => "locale" in obj, get: obj => obj.locale, set: (obj, value) => { obj.locale = value; } }, metadata: _metadata }, _locale_initializers, _locale_extraInitializers);
|
|
177
|
-
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
178
|
-
__esDecorate(this, null, _readOnly_decorators, { kind: "accessor", name: "readOnly", static: false, private: false, access: { has: obj => "readOnly" in obj, get: obj => obj.readOnly, set: (obj, value) => { obj.readOnly = value; } }, metadata: _metadata }, _readOnly_initializers, _readOnly_extraInitializers);
|
|
179
|
-
__esDecorate(this, _private_internalValue_descriptor = { get: __setFunctionName(function () { return this.#internalValue_accessor_storage; }, "#internalValue", "get"), set: __setFunctionName(function (value) { this.#internalValue_accessor_storage = value; }, "#internalValue", "set") }, _private_internalValue_decorators, { kind: "accessor", name: "#internalValue", static: false, private: true, access: { has: obj => #internalValue in obj, get: obj => obj.#internalValue, set: (obj, value) => { obj.#internalValue = value; } }, metadata: _metadata }, _private_internalValue_initializers, _private_internalValue_extraInitializers);
|
|
180
|
-
__esDecorate(this, _private_focusedDate_descriptor = { get: __setFunctionName(function () { return this.#focusedDate_accessor_storage; }, "#focusedDate", "get"), set: __setFunctionName(function (value) { this.#focusedDate_accessor_storage = value; }, "#focusedDate", "set") }, _private_focusedDate_decorators, { kind: "accessor", name: "#focusedDate", static: false, private: true, access: { has: obj => #focusedDate in obj, get: obj => obj.#focusedDate, set: (obj, value) => { obj.#focusedDate = value; } }, metadata: _metadata }, _private_focusedDate_initializers, _private_focusedDate_extraInitializers);
|
|
181
|
-
__esDecorate(this, _private_viewMonth_descriptor = { get: __setFunctionName(function () { return this.#viewMonth_accessor_storage; }, "#viewMonth", "get"), set: __setFunctionName(function (value) { this.#viewMonth_accessor_storage = value; }, "#viewMonth", "set") }, _private_viewMonth_decorators, { kind: "accessor", name: "#viewMonth", static: false, private: true, access: { has: obj => #viewMonth in obj, get: obj => obj.#viewMonth, set: (obj, value) => { obj.#viewMonth = value; } }, metadata: _metadata }, _private_viewMonth_initializers, _private_viewMonth_extraInitializers);
|
|
182
|
-
__esDecorate(this, _private_viewYear_descriptor = { get: __setFunctionName(function () { return this.#viewYear_accessor_storage; }, "#viewYear", "get"), set: __setFunctionName(function (value) { this.#viewYear_accessor_storage = value; }, "#viewYear", "set") }, _private_viewYear_decorators, { kind: "accessor", name: "#viewYear", static: false, private: true, access: { has: obj => #viewYear in obj, get: obj => obj.#viewYear, set: (obj, value) => { obj.#viewYear = value; } }, metadata: _metadata }, _private_viewYear_initializers, _private_viewYear_extraInitializers);
|
|
183
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
184
|
-
}
|
|
185
|
-
static tagName = "dui-calendar";
|
|
186
|
-
static styles = [base, styles];
|
|
187
|
-
#value_accessor_storage = __runInitializers(this, _value_initializers, undefined);
|
|
188
|
-
get value() { return this.#value_accessor_storage; }
|
|
189
|
-
set value(value) { this.#value_accessor_storage = value; }
|
|
190
|
-
#defaultValue_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _defaultValue_initializers, undefined));
|
|
191
|
-
get defaultValue() { return this.#defaultValue_accessor_storage; }
|
|
192
|
-
set defaultValue(value) { this.#defaultValue_accessor_storage = value; }
|
|
193
|
-
#min_accessor_storage = (__runInitializers(this, _defaultValue_extraInitializers), __runInitializers(this, _min_initializers, undefined));
|
|
194
|
-
get min() { return this.#min_accessor_storage; }
|
|
195
|
-
set min(value) { this.#min_accessor_storage = value; }
|
|
196
|
-
#max_accessor_storage = (__runInitializers(this, _min_extraInitializers), __runInitializers(this, _max_initializers, undefined));
|
|
197
|
-
get max() { return this.#max_accessor_storage; }
|
|
198
|
-
set max(value) { this.#max_accessor_storage = value; }
|
|
199
|
-
#locale_accessor_storage = (__runInitializers(this, _max_extraInitializers), __runInitializers(this, _locale_initializers, "en-US"));
|
|
200
|
-
get locale() { return this.#locale_accessor_storage; }
|
|
201
|
-
set locale(value) { this.#locale_accessor_storage = value; }
|
|
202
|
-
#disabled_accessor_storage = (__runInitializers(this, _locale_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
203
|
-
get disabled() { return this.#disabled_accessor_storage; }
|
|
204
|
-
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
205
|
-
#readOnly_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _readOnly_initializers, false));
|
|
206
|
-
get readOnly() { return this.#readOnly_accessor_storage; }
|
|
207
|
-
set readOnly(value) { this.#readOnly_accessor_storage = value; }
|
|
208
|
-
#internalValue_accessor_storage = (__runInitializers(this, _readOnly_extraInitializers), __runInitializers(this, _private_internalValue_initializers, undefined));
|
|
209
|
-
get #internalValue() { return _private_internalValue_descriptor.get.call(this); }
|
|
210
|
-
set #internalValue(value) { return _private_internalValue_descriptor.set.call(this, value); }
|
|
211
|
-
#focusedDate_accessor_storage = (__runInitializers(this, _private_internalValue_extraInitializers), __runInitializers(this, _private_focusedDate_initializers, new Date()));
|
|
212
|
-
get #focusedDate() { return _private_focusedDate_descriptor.get.call(this); }
|
|
213
|
-
set #focusedDate(value) { return _private_focusedDate_descriptor.set.call(this, value); }
|
|
214
|
-
#viewMonth_accessor_storage = (__runInitializers(this, _private_focusedDate_extraInitializers), __runInitializers(this, _private_viewMonth_initializers, new Date().getMonth()));
|
|
215
|
-
get #viewMonth() { return _private_viewMonth_descriptor.get.call(this); }
|
|
216
|
-
set #viewMonth(value) { return _private_viewMonth_descriptor.set.call(this, value); }
|
|
217
|
-
#viewYear_accessor_storage = (__runInitializers(this, _private_viewMonth_extraInitializers), __runInitializers(this, _private_viewYear_initializers, new Date().getFullYear()));
|
|
218
|
-
get #viewYear() { return _private_viewYear_descriptor.get.call(this); }
|
|
219
|
-
set #viewYear(value) { return _private_viewYear_descriptor.set.call(this, value); }
|
|
220
|
-
get #selectedValue() {
|
|
221
|
-
return this.value ?? this.#internalValue;
|
|
222
|
-
}
|
|
223
|
-
connectedCallback() {
|
|
224
|
-
super.connectedCallback();
|
|
225
|
-
if (this.value === undefined && this.defaultValue !== undefined) {
|
|
226
|
-
this.#internalValue = this.defaultValue;
|
|
227
|
-
}
|
|
228
|
-
const selected = this.#selectedValue;
|
|
229
|
-
if (selected) {
|
|
230
|
-
const d = new Date(selected + "T00:00:00");
|
|
231
|
-
this.#viewMonth = d.getMonth();
|
|
232
|
-
this.#viewYear = d.getFullYear();
|
|
233
|
-
this.#focusedDate = d;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
#formatISO(date) {
|
|
237
|
-
const y = date.getFullYear();
|
|
238
|
-
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
239
|
-
const d = String(date.getDate()).padStart(2, "0");
|
|
240
|
-
return `${y}-${m}-${d}`;
|
|
241
|
-
}
|
|
242
|
-
#isSameDay(a, b) {
|
|
243
|
-
return (a.getFullYear() === b.getFullYear() &&
|
|
244
|
-
a.getMonth() === b.getMonth() &&
|
|
245
|
-
a.getDate() === b.getDate());
|
|
246
|
-
}
|
|
247
|
-
#isDateDisabled(date) {
|
|
248
|
-
if (this.disabled)
|
|
249
|
-
return true;
|
|
250
|
-
const iso = this.#formatISO(date);
|
|
251
|
-
if (this.min && iso < this.min)
|
|
252
|
-
return true;
|
|
253
|
-
if (this.max && iso > this.max)
|
|
254
|
-
return true;
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
#getDaysInMonth(year, month) {
|
|
258
|
-
return new Date(year, month + 1, 0).getDate();
|
|
259
|
-
}
|
|
260
|
-
#getFirstDayOfWeek() {
|
|
261
|
-
// Use Intl to determine first day of week for locale
|
|
262
|
-
// Fallback to Sunday (0) for most locales
|
|
263
|
-
try {
|
|
264
|
-
const locale = new Intl.Locale(this.locale);
|
|
265
|
-
// @ts-ignore — weekInfo is a newer API
|
|
266
|
-
const weekInfo = locale.weekInfo ?? locale.getWeekInfo?.();
|
|
267
|
-
return weekInfo?.firstDay === 7 ? 0 : (weekInfo?.firstDay ?? 0);
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
270
|
-
return 0;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
#buildGrid() {
|
|
274
|
-
const year = this.#viewYear;
|
|
275
|
-
const month = this.#viewMonth;
|
|
276
|
-
const daysInMonth = this.#getDaysInMonth(year, month);
|
|
277
|
-
const firstDay = new Date(year, month, 1).getDay();
|
|
278
|
-
const firstDayOfWeek = this.#getFirstDayOfWeek();
|
|
279
|
-
const today = new Date();
|
|
280
|
-
const selectedIso = this.#selectedValue;
|
|
281
|
-
let startOffset = firstDay - firstDayOfWeek;
|
|
282
|
-
if (startOffset < 0)
|
|
283
|
-
startOffset += 7;
|
|
284
|
-
const cells = [];
|
|
285
|
-
// Days from previous month
|
|
286
|
-
const prevMonth = month === 0 ? 11 : month - 1;
|
|
287
|
-
const prevYear = month === 0 ? year - 1 : year;
|
|
288
|
-
const daysInPrevMonth = this.#getDaysInMonth(prevYear, prevMonth);
|
|
289
|
-
for (let i = startOffset - 1; i >= 0; i--) {
|
|
290
|
-
const day = daysInPrevMonth - i;
|
|
291
|
-
const date = new Date(prevYear, prevMonth, day);
|
|
292
|
-
cells.push({
|
|
293
|
-
date,
|
|
294
|
-
day,
|
|
295
|
-
iso: this.#formatISO(date),
|
|
296
|
-
isToday: this.#isSameDay(date, today),
|
|
297
|
-
isSelected: this.#formatISO(date) === selectedIso,
|
|
298
|
-
isOutsideMonth: true,
|
|
299
|
-
isDisabled: this.#isDateDisabled(date),
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
// Days in current month
|
|
303
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
304
|
-
const date = new Date(year, month, day);
|
|
305
|
-
cells.push({
|
|
306
|
-
date,
|
|
307
|
-
day,
|
|
308
|
-
iso: this.#formatISO(date),
|
|
309
|
-
isToday: this.#isSameDay(date, today),
|
|
310
|
-
isSelected: this.#formatISO(date) === selectedIso,
|
|
311
|
-
isOutsideMonth: false,
|
|
312
|
-
isDisabled: this.#isDateDisabled(date),
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
// Fill remaining cells to make 6 rows
|
|
316
|
-
const remaining = 42 - cells.length;
|
|
317
|
-
const nextMonth = month === 11 ? 0 : month + 1;
|
|
318
|
-
const nextYear = month === 11 ? year + 1 : year;
|
|
319
|
-
for (let day = 1; day <= remaining; day++) {
|
|
320
|
-
const date = new Date(nextYear, nextMonth, day);
|
|
321
|
-
cells.push({
|
|
322
|
-
date,
|
|
323
|
-
day,
|
|
324
|
-
iso: this.#formatISO(date),
|
|
325
|
-
isToday: this.#isSameDay(date, today),
|
|
326
|
-
isSelected: this.#formatISO(date) === selectedIso,
|
|
327
|
-
isOutsideMonth: true,
|
|
328
|
-
isDisabled: this.#isDateDisabled(date),
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
// Split into rows of 7
|
|
332
|
-
const rows = [];
|
|
333
|
-
for (let i = 0; i < cells.length; i += 7) {
|
|
334
|
-
rows.push(cells.slice(i, i + 7));
|
|
335
|
-
}
|
|
336
|
-
return rows;
|
|
337
|
-
}
|
|
338
|
-
#getWeekdayNames() {
|
|
339
|
-
const formatter = new Intl.DateTimeFormat(this.locale, { weekday: "short" });
|
|
340
|
-
const firstDayOfWeek = this.#getFirstDayOfWeek();
|
|
341
|
-
const names = [];
|
|
342
|
-
for (let i = 0; i < 7; i++) {
|
|
343
|
-
// Jan 4 2015 is a Sunday
|
|
344
|
-
const date = new Date(2015, 0, 4 + firstDayOfWeek + i);
|
|
345
|
-
names.push(formatter.format(date));
|
|
346
|
-
}
|
|
347
|
-
return names;
|
|
348
|
-
}
|
|
349
|
-
#getMonthYearHeading() {
|
|
350
|
-
const date = new Date(this.#viewYear, this.#viewMonth, 1);
|
|
351
|
-
return new Intl.DateTimeFormat(this.locale, {
|
|
352
|
-
month: "long",
|
|
353
|
-
year: "numeric",
|
|
354
|
-
}).format(date);
|
|
355
|
-
}
|
|
356
|
-
#selectDate(iso) {
|
|
357
|
-
if (this.disabled || this.readOnly)
|
|
358
|
-
return;
|
|
359
|
-
if (this.value === undefined) {
|
|
360
|
-
this.#internalValue = iso;
|
|
361
|
-
}
|
|
362
|
-
this.dispatchEvent(valueChangeEvent({ value: iso }));
|
|
363
|
-
}
|
|
364
|
-
#navigateMonth(delta) {
|
|
365
|
-
let newMonth = this.#viewMonth + delta;
|
|
366
|
-
let newYear = this.#viewYear;
|
|
367
|
-
if (newMonth < 0) {
|
|
368
|
-
newMonth = 11;
|
|
369
|
-
newYear--;
|
|
370
|
-
}
|
|
371
|
-
else if (newMonth > 11) {
|
|
372
|
-
newMonth = 0;
|
|
373
|
-
newYear++;
|
|
374
|
-
}
|
|
375
|
-
this.#viewMonth = newMonth;
|
|
376
|
-
this.#viewYear = newYear;
|
|
377
|
-
this.#focusedDate = new Date(newYear, newMonth, 1);
|
|
378
|
-
}
|
|
379
|
-
#onDayClick = (__runInitializers(this, _private_viewYear_extraInitializers), (e) => {
|
|
380
|
-
const button = e.currentTarget;
|
|
381
|
-
const iso = button.dataset.date;
|
|
382
|
-
if (iso && !button.disabled) {
|
|
383
|
-
this.#selectDate(iso);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
#onKeyDown = (e) => {
|
|
387
|
-
const focused = new Date(this.#focusedDate);
|
|
388
|
-
let handled = true;
|
|
389
|
-
switch (e.key) {
|
|
390
|
-
case "ArrowLeft":
|
|
391
|
-
focused.setDate(focused.getDate() - 1);
|
|
392
|
-
break;
|
|
393
|
-
case "ArrowRight":
|
|
394
|
-
focused.setDate(focused.getDate() + 1);
|
|
395
|
-
break;
|
|
396
|
-
case "ArrowUp":
|
|
397
|
-
focused.setDate(focused.getDate() - 7);
|
|
398
|
-
break;
|
|
399
|
-
case "ArrowDown":
|
|
400
|
-
focused.setDate(focused.getDate() + 7);
|
|
401
|
-
break;
|
|
402
|
-
case "PageUp":
|
|
403
|
-
if (e.shiftKey) {
|
|
404
|
-
focused.setFullYear(focused.getFullYear() - 1);
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
focused.setMonth(focused.getMonth() - 1);
|
|
408
|
-
}
|
|
409
|
-
break;
|
|
410
|
-
case "PageDown":
|
|
411
|
-
if (e.shiftKey) {
|
|
412
|
-
focused.setFullYear(focused.getFullYear() + 1);
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
focused.setMonth(focused.getMonth() + 1);
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
case "Home": {
|
|
419
|
-
focused.setDate(1);
|
|
420
|
-
break;
|
|
421
|
-
}
|
|
422
|
-
case "End": {
|
|
423
|
-
const daysInMonth = this.#getDaysInMonth(focused.getFullYear(), focused.getMonth());
|
|
424
|
-
focused.setDate(daysInMonth);
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
case "Enter":
|
|
428
|
-
case " ":
|
|
429
|
-
e.preventDefault();
|
|
430
|
-
if (!this.#isDateDisabled(focused)) {
|
|
431
|
-
this.#selectDate(this.#formatISO(focused));
|
|
432
|
-
}
|
|
433
|
-
return;
|
|
434
|
-
default:
|
|
435
|
-
handled = false;
|
|
436
|
-
}
|
|
437
|
-
if (handled) {
|
|
438
|
-
e.preventDefault();
|
|
439
|
-
this.#focusedDate = focused;
|
|
440
|
-
this.#viewMonth = focused.getMonth();
|
|
441
|
-
this.#viewYear = focused.getFullYear();
|
|
442
|
-
// Focus the correct day button after render
|
|
443
|
-
this.updateComplete.then(() => {
|
|
444
|
-
const iso = this.#formatISO(focused);
|
|
445
|
-
const btn = this.shadowRoot?.querySelector(`[data-date="${iso}"]`);
|
|
446
|
-
btn?.focus();
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
#onPrevClick = () => {
|
|
451
|
-
this.#navigateMonth(-1);
|
|
452
|
-
};
|
|
453
|
-
#onNextClick = () => {
|
|
454
|
-
this.#navigateMonth(1);
|
|
455
|
-
};
|
|
456
|
-
render() {
|
|
457
|
-
const grid = this.#buildGrid();
|
|
458
|
-
const weekdays = this.#getWeekdayNames();
|
|
459
|
-
const heading = this.#getMonthYearHeading();
|
|
460
|
-
const focusedIso = this.#formatISO(this.#focusedDate);
|
|
461
|
-
return html `
|
|
462
|
-
<div part="root" role="grid" @keydown="${this.#onKeyDown}">
|
|
463
|
-
<div part="header">
|
|
464
|
-
<button
|
|
465
|
-
part="prev"
|
|
466
|
-
type="button"
|
|
467
|
-
aria-label="Previous month"
|
|
468
|
-
@click="${this.#onPrevClick}"
|
|
469
|
-
>
|
|
470
|
-
<slot name="prev">‹</slot>
|
|
471
|
-
</button>
|
|
472
|
-
<div part="heading" aria-live="polite">${heading}</div>
|
|
473
|
-
<button
|
|
474
|
-
part="next"
|
|
475
|
-
type="button"
|
|
476
|
-
aria-label="Next month"
|
|
477
|
-
@click="${this.#onNextClick}"
|
|
478
|
-
>
|
|
479
|
-
<slot name="next">›</slot>
|
|
480
|
-
</button>
|
|
481
|
-
</div>
|
|
482
85
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
?data-outside-month="${cell.isOutsideMonth}"
|
|
495
|
-
?disabled="${cell.isDisabled}"
|
|
496
|
-
aria-selected="${cell.isSelected ? "true" : "false"}"
|
|
497
|
-
@click="${this.#onDayClick}"
|
|
498
|
-
>${cell.day}</button>
|
|
499
|
-
`)}
|
|
500
|
-
</div>
|
|
501
|
-
</div>
|
|
502
|
-
`;
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
})();
|
|
506
|
-
export { DuiCalendar };
|
|
86
|
+
[part="day"]:focus-visible {
|
|
87
|
+
outline: none;
|
|
88
|
+
box-shadow:
|
|
89
|
+
0 0 0 var(--focus-ring-offset) var(--background),
|
|
90
|
+
0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
export class DuiCalendar extends DuiCalendarPrimitive {
|
|
94
|
+
static styles = [...DuiCalendarPrimitive.styles, styles];
|
|
95
|
+
}
|
|
96
|
+
customElements.define(DuiCalendar.tagName, DuiCalendar);
|
package/calendar/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiCalendar
|
|
3
|
-
export
|
|
1
|
+
import "./calendar.js";
|
|
2
|
+
export { DuiCalendar } from "./calendar.js";
|
|
3
|
+
export { valueChangeEvent } from "@deepfuture/dui-primitives/calendar";
|
package/calendar/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiCalendar
|
|
3
|
-
export
|
|
1
|
+
import "./calendar.js";
|
|
2
|
+
export { DuiCalendar } from "./calendar.js";
|
|
3
|
+
export { valueChangeEvent } from "@deepfuture/dui-primitives/calendar";
|