@deepfuture/dui-components 0.0.1
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/accordion/accordion-context.d.ts +15 -0
- package/accordion/accordion-context.js +3 -0
- package/accordion/accordion-item.d.ts +22 -0
- package/accordion/accordion-item.js +254 -0
- package/accordion/accordion.d.ts +20 -0
- package/accordion/accordion.js +185 -0
- package/accordion/index.d.ts +3 -0
- package/accordion/index.js +2 -0
- package/accordion/register.d.ts +1 -0
- package/accordion/register.js +8 -0
- package/alert-dialog/alert-dialog-close.d.ts +15 -0
- package/alert-dialog/alert-dialog-close.js +35 -0
- package/alert-dialog/alert-dialog-context.d.ts +13 -0
- package/alert-dialog/alert-dialog-context.js +3 -0
- package/alert-dialog/alert-dialog-popup.d.ts +34 -0
- package/alert-dialog/alert-dialog-popup.js +260 -0
- package/alert-dialog/alert-dialog-trigger.d.ts +15 -0
- package/alert-dialog/alert-dialog-trigger.js +52 -0
- package/alert-dialog/alert-dialog.d.ts +30 -0
- package/alert-dialog/alert-dialog.js +97 -0
- package/alert-dialog/index.d.ts +6 -0
- package/alert-dialog/index.js +4 -0
- package/alert-dialog/register.d.ts +1 -0
- package/alert-dialog/register.js +16 -0
- package/all.d.ts +86 -0
- package/all.js +191 -0
- package/avatar/avatar.d.ts +41 -0
- package/avatar/avatar.js +188 -0
- package/avatar/index.d.ts +2 -0
- package/avatar/index.js +1 -0
- package/avatar/register.d.ts +1 -0
- package/avatar/register.js +4 -0
- package/badge/badge.d.ts +14 -0
- package/badge/badge.js +43 -0
- package/badge/index.d.ts +2 -0
- package/badge/index.js +1 -0
- package/badge/register.d.ts +1 -0
- package/badge/register.js +4 -0
- package/breadcrumb/breadcrumb-ellipsis.d.ts +14 -0
- package/breadcrumb/breadcrumb-ellipsis.js +39 -0
- package/breadcrumb/breadcrumb-item.d.ts +13 -0
- package/breadcrumb/breadcrumb-item.js +31 -0
- package/breadcrumb/breadcrumb-link.d.ts +14 -0
- package/breadcrumb/breadcrumb-link.js +32 -0
- package/breadcrumb/breadcrumb-page.d.ts +13 -0
- package/breadcrumb/breadcrumb-page.js +36 -0
- package/breadcrumb/breadcrumb-separator.d.ts +14 -0
- package/breadcrumb/breadcrumb-separator.js +36 -0
- package/breadcrumb/breadcrumb.d.ts +14 -0
- package/breadcrumb/breadcrumb.js +38 -0
- package/breadcrumb/index.d.ts +6 -0
- package/breadcrumb/index.js +6 -0
- package/breadcrumb/register.d.ts +1 -0
- package/breadcrumb/register.js +14 -0
- package/button/button.d.ts +38 -0
- package/button/button.js +143 -0
- package/button/index.d.ts +2 -0
- package/button/index.js +1 -0
- package/button/register.d.ts +1 -0
- package/button/register.js +4 -0
- package/calendar/calendar.d.ts +33 -0
- package/calendar/calendar.js +428 -0
- package/calendar/index.d.ts +1 -0
- package/calendar/index.js +1 -0
- package/calendar/register.d.ts +1 -0
- package/calendar/register.js +4 -0
- package/center/center.d.ts +14 -0
- package/center/center.js +37 -0
- package/center/index.d.ts +1 -0
- package/center/index.js +1 -0
- package/center/register.d.ts +1 -0
- package/center/register.js +4 -0
- package/checkbox/checkbox-group-context.d.ts +11 -0
- package/checkbox/checkbox-group-context.js +3 -0
- package/checkbox/checkbox-group.d.ts +34 -0
- package/checkbox/checkbox-group.js +128 -0
- package/checkbox/checkbox.d.ts +46 -0
- package/checkbox/checkbox.js +314 -0
- package/checkbox/index.d.ts +3 -0
- package/checkbox/index.js +2 -0
- package/checkbox/register.d.ts +1 -0
- package/checkbox/register.js +8 -0
- package/collapsible/collapsible.d.ts +22 -0
- package/collapsible/collapsible.js +227 -0
- package/collapsible/index.d.ts +1 -0
- package/collapsible/index.js +1 -0
- package/collapsible/register.d.ts +1 -0
- package/collapsible/register.js +4 -0
- package/combobox/combobox.d.ts +46 -0
- package/combobox/combobox.js +524 -0
- package/combobox/index.d.ts +2 -0
- package/combobox/index.js +1 -0
- package/combobox/register.d.ts +1 -0
- package/combobox/register.js +4 -0
- package/command/command-context.d.ts +30 -0
- package/command/command-context.js +3 -0
- package/command/command-empty.d.ts +10 -0
- package/command/command-empty.js +50 -0
- package/command/command-group.d.ts +15 -0
- package/command/command-group.js +79 -0
- package/command/command-input.d.ts +13 -0
- package/command/command-input.js +106 -0
- package/command/command-item.d.ts +20 -0
- package/command/command-item.js +175 -0
- package/command/command-list.d.ts +9 -0
- package/command/command-list.js +43 -0
- package/command/command-score.d.ts +6 -0
- package/command/command-score.js +31 -0
- package/command/command-separator.d.ts +7 -0
- package/command/command-separator.js +15 -0
- package/command/command-shortcut.d.ts +7 -0
- package/command/command-shortcut.js +16 -0
- package/command/command.d.ts +25 -0
- package/command/command.js +278 -0
- package/command/index.d.ts +10 -0
- package/command/index.js +9 -0
- package/command/register.d.ts +1 -0
- package/command/register.js +22 -0
- package/data-table/data-table.d.ts +59 -0
- package/data-table/data-table.js +416 -0
- package/data-table/index.d.ts +2 -0
- package/data-table/index.js +1 -0
- package/data-table/register.d.ts +1 -0
- package/data-table/register.js +4 -0
- package/dialog/dialog-close.d.ts +15 -0
- package/dialog/dialog-close.js +35 -0
- package/dialog/dialog-context.d.ts +13 -0
- package/dialog/dialog-context.js +3 -0
- package/dialog/dialog-popup.d.ts +36 -0
- package/dialog/dialog-popup.js +277 -0
- package/dialog/dialog-trigger.d.ts +15 -0
- package/dialog/dialog-trigger.js +52 -0
- package/dialog/dialog.d.ts +30 -0
- package/dialog/dialog.js +97 -0
- package/dialog/index.d.ts +6 -0
- package/dialog/index.js +4 -0
- package/dialog/register.d.ts +1 -0
- package/dialog/register.js +16 -0
- package/dropzone/dropzone.d.ts +74 -0
- package/dropzone/dropzone.js +357 -0
- package/dropzone/index.d.ts +2 -0
- package/dropzone/index.js +1 -0
- package/dropzone/register.d.ts +1 -0
- package/dropzone/register.js +4 -0
- package/field/field-context.d.ts +20 -0
- package/field/field-context.js +2 -0
- package/field/index.d.ts +2 -0
- package/field/index.js +1 -0
- package/global.d.ts +189 -0
- package/hstack/hstack.d.ts +25 -0
- package/hstack/hstack.js +141 -0
- package/hstack/index.d.ts +2 -0
- package/hstack/index.js +1 -0
- package/hstack/register.d.ts +1 -0
- package/hstack/register.js +4 -0
- package/icon/icon.d.ts +16 -0
- package/icon/icon.js +34 -0
- package/icon/index.d.ts +1 -0
- package/icon/index.js +1 -0
- package/icon/register.d.ts +1 -0
- package/icon/register.js +4 -0
- package/input/index.d.ts +1 -0
- package/input/index.js +1 -0
- package/input/input.d.ts +47 -0
- package/input/input.js +205 -0
- package/input/register.d.ts +1 -0
- package/input/register.js +4 -0
- package/link/index.d.ts +1 -0
- package/link/index.js +1 -0
- package/link/link.d.ts +27 -0
- package/link/link.js +57 -0
- package/link/register.d.ts +1 -0
- package/link/register.js +4 -0
- package/menu/index.d.ts +2 -0
- package/menu/index.js +2 -0
- package/menu/menu-item.d.ts +17 -0
- package/menu/menu-item.js +62 -0
- package/menu/menu.d.ts +15 -0
- package/menu/menu.js +228 -0
- package/menu/register.d.ts +1 -0
- package/menu/register.js +8 -0
- package/menubar/index.d.ts +2 -0
- package/menubar/index.js +1 -0
- package/menubar/menubar-context.d.ts +9 -0
- package/menubar/menubar-context.js +2 -0
- package/menubar/menubar.d.ts +19 -0
- package/menubar/menubar.js +130 -0
- package/menubar/register.d.ts +1 -0
- package/menubar/register.js +4 -0
- package/number-field/index.d.ts +1 -0
- package/number-field/index.js +1 -0
- package/number-field/number-field.d.ts +34 -0
- package/number-field/number-field.js +326 -0
- package/number-field/register.d.ts +1 -0
- package/number-field/register.js +4 -0
- package/package.json +217 -0
- package/page-inset/index.d.ts +1 -0
- package/page-inset/index.js +1 -0
- package/page-inset/page-inset.d.ts +28 -0
- package/page-inset/page-inset.js +103 -0
- package/page-inset/register.d.ts +1 -0
- package/page-inset/register.js +4 -0
- package/popover/index.d.ts +6 -0
- package/popover/index.js +4 -0
- package/popover/popover-close.d.ts +13 -0
- package/popover/popover-close.js +33 -0
- package/popover/popover-context.d.ts +17 -0
- package/popover/popover-context.js +3 -0
- package/popover/popover-popup.d.ts +20 -0
- package/popover/popover-popup.js +176 -0
- package/popover/popover-trigger.d.ts +13 -0
- package/popover/popover-trigger.js +57 -0
- package/popover/popover.d.ts +30 -0
- package/popover/popover.js +140 -0
- package/popover/register.d.ts +1 -0
- package/popover/register.js +16 -0
- package/portal/index.d.ts +2 -0
- package/portal/index.js +1 -0
- package/portal/portal.d.ts +29 -0
- package/portal/portal.js +115 -0
- package/portal/register.d.ts +1 -0
- package/portal/register.js +4 -0
- package/preview-card/index.d.ts +5 -0
- package/preview-card/index.js +3 -0
- package/preview-card/preview-card-context.d.ts +16 -0
- package/preview-card/preview-card-context.js +3 -0
- package/preview-card/preview-card-popup.d.ts +16 -0
- package/preview-card/preview-card-popup.js +167 -0
- package/preview-card/preview-card-trigger.d.ts +13 -0
- package/preview-card/preview-card-trigger.js +75 -0
- package/preview-card/preview-card.d.ts +34 -0
- package/preview-card/preview-card.js +164 -0
- package/preview-card/register.d.ts +1 -0
- package/preview-card/register.js +12 -0
- package/progress/index.d.ts +1 -0
- package/progress/index.js +1 -0
- package/progress/progress.d.ts +19 -0
- package/progress/progress.js +94 -0
- package/progress/register.d.ts +1 -0
- package/progress/register.js +4 -0
- package/radio/index.d.ts +3 -0
- package/radio/index.js +2 -0
- package/radio/radio-group-context.d.ts +11 -0
- package/radio/radio-group-context.js +2 -0
- package/radio/radio-group.d.ts +37 -0
- package/radio/radio-group.js +135 -0
- package/radio/radio.d.ts +27 -0
- package/radio/radio.js +204 -0
- package/radio/register.d.ts +1 -0
- package/radio/register.js +8 -0
- package/scroll-area/index.d.ts +1 -0
- package/scroll-area/index.js +1 -0
- package/scroll-area/register.d.ts +1 -0
- package/scroll-area/register.js +4 -0
- package/scroll-area/scroll-area.d.ts +38 -0
- package/scroll-area/scroll-area.js +453 -0
- package/select/index.d.ts +2 -0
- package/select/index.js +1 -0
- package/select/register.d.ts +1 -0
- package/select/register.js +4 -0
- package/select/select.d.ts +36 -0
- package/select/select.js +404 -0
- package/separator/index.d.ts +1 -0
- package/separator/index.js +1 -0
- package/separator/register.d.ts +1 -0
- package/separator/register.js +4 -0
- package/separator/separator.d.ts +12 -0
- package/separator/separator.js +50 -0
- package/sidebar/index.d.ts +16 -0
- package/sidebar/index.js +13 -0
- package/sidebar/register.d.ts +1 -0
- package/sidebar/register.js +52 -0
- package/sidebar/sidebar-content.d.ts +14 -0
- package/sidebar/sidebar-content.js +30 -0
- package/sidebar/sidebar-context.d.ts +15 -0
- package/sidebar/sidebar-context.js +3 -0
- package/sidebar/sidebar-footer.d.ts +12 -0
- package/sidebar/sidebar-footer.js +21 -0
- package/sidebar/sidebar-group-label.d.ts +17 -0
- package/sidebar/sidebar-group-label.js +49 -0
- package/sidebar/sidebar-group.d.ts +15 -0
- package/sidebar/sidebar-group.js +29 -0
- package/sidebar/sidebar-header.d.ts +12 -0
- package/sidebar/sidebar-header.js +21 -0
- package/sidebar/sidebar-inset.d.ts +15 -0
- package/sidebar/sidebar-inset.js +29 -0
- package/sidebar/sidebar-menu-button.d.ts +31 -0
- package/sidebar/sidebar-menu-button.js +201 -0
- package/sidebar/sidebar-menu-item.d.ts +12 -0
- package/sidebar/sidebar-menu-item.js +20 -0
- package/sidebar/sidebar-menu.d.ts +14 -0
- package/sidebar/sidebar-menu.js +30 -0
- package/sidebar/sidebar-provider.d.ts +34 -0
- package/sidebar/sidebar-provider.js +157 -0
- package/sidebar/sidebar-separator.d.ts +12 -0
- package/sidebar/sidebar-separator.js +24 -0
- package/sidebar/sidebar-trigger.d.ts +16 -0
- package/sidebar/sidebar-trigger.js +50 -0
- package/sidebar/sidebar.d.ts +21 -0
- package/sidebar/sidebar.js +228 -0
- package/slider/index.d.ts +1 -0
- package/slider/index.js +1 -0
- package/slider/register.d.ts +1 -0
- package/slider/register.js +4 -0
- package/slider/slider.d.ts +37 -0
- package/slider/slider.js +268 -0
- package/spinner/index.d.ts +1 -0
- package/spinner/index.js +1 -0
- package/spinner/register.d.ts +1 -0
- package/spinner/register.js +4 -0
- package/spinner/spinner.d.ts +18 -0
- package/spinner/spinner.js +138 -0
- package/switch/index.d.ts +1 -0
- package/switch/index.js +1 -0
- package/switch/register.d.ts +1 -0
- package/switch/register.js +4 -0
- package/switch/switch.d.ts +29 -0
- package/switch/switch.js +201 -0
- package/tabs/index.d.ts +6 -0
- package/tabs/index.js +5 -0
- package/tabs/register.d.ts +1 -0
- package/tabs/register.js +10 -0
- package/tabs/tab.d.ts +16 -0
- package/tabs/tab.js +98 -0
- package/tabs/tabs-context.d.ts +8 -0
- package/tabs/tabs-context.js +2 -0
- package/tabs/tabs-indicator.d.ts +11 -0
- package/tabs/tabs-indicator.js +27 -0
- package/tabs/tabs-list.d.ts +17 -0
- package/tabs/tabs-list.js +85 -0
- package/tabs/tabs-panel.d.ts +18 -0
- package/tabs/tabs-panel.js +85 -0
- package/tabs/tabs.d.ts +24 -0
- package/tabs/tabs.js +111 -0
- package/textarea/index.d.ts +2 -0
- package/textarea/index.js +1 -0
- package/textarea/register.d.ts +1 -0
- package/textarea/register.js +4 -0
- package/textarea/textarea.d.ts +37 -0
- package/textarea/textarea.js +170 -0
- package/toggle/index.d.ts +3 -0
- package/toggle/index.js +2 -0
- package/toggle/register.d.ts +1 -0
- package/toggle/register.js +8 -0
- package/toggle/toggle-group-context.d.ts +9 -0
- package/toggle/toggle-group-context.js +2 -0
- package/toggle/toggle-group.d.ts +27 -0
- package/toggle/toggle-group.js +163 -0
- package/toggle/toggle.d.ts +25 -0
- package/toggle/toggle.js +124 -0
- package/toolbar/index.d.ts +1 -0
- package/toolbar/index.js +1 -0
- package/toolbar/register.d.ts +1 -0
- package/toolbar/register.js +4 -0
- package/toolbar/toolbar.d.ts +15 -0
- package/toolbar/toolbar.js +89 -0
- package/tooltip/index.d.ts +5 -0
- package/tooltip/index.js +3 -0
- package/tooltip/register.d.ts +1 -0
- package/tooltip/register.js +12 -0
- package/tooltip/tooltip-context.d.ts +17 -0
- package/tooltip/tooltip-context.js +3 -0
- package/tooltip/tooltip-popup.d.ts +16 -0
- package/tooltip/tooltip-popup.js +162 -0
- package/tooltip/tooltip-trigger.d.ts +15 -0
- package/tooltip/tooltip-trigger.js +110 -0
- package/tooltip/tooltip.d.ts +36 -0
- package/tooltip/tooltip.js +176 -0
- package/trunc/index.d.ts +1 -0
- package/trunc/index.js +1 -0
- package/trunc/register.d.ts +1 -0
- package/trunc/register.js +4 -0
- package/trunc/trunc.d.ts +19 -0
- package/trunc/trunc.js +68 -0
- package/vstack/index.d.ts +1 -0
- package/vstack/index.js +1 -0
- package/vstack/register.d.ts +1 -0
- package/vstack/register.js +4 -0
- package/vstack/vstack.d.ts +17 -0
- package/vstack/vstack.js +83 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html, LitElement } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { base } from "@deepfuture/dui-core/base";
|
|
10
|
+
import { customEvent } from "@deepfuture/dui-core/event";
|
|
11
|
+
export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
|
|
12
|
+
/** Structural styles only — layout CSS. */
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[part="root"] {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part="header"] {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[part="heading"] {
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
text-align: center;
|
|
32
|
+
flex: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[part="prev"],
|
|
36
|
+
[part="next"] {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
border: none;
|
|
42
|
+
background: none;
|
|
43
|
+
padding: 0;
|
|
44
|
+
font: inherit;
|
|
45
|
+
color: inherit;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[part="grid"] {
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: repeat(7, 1fr);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part="weekday"] {
|
|
54
|
+
text-align: center;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[part="day"] {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
border: none;
|
|
64
|
+
background: none;
|
|
65
|
+
padding: 0;
|
|
66
|
+
font: inherit;
|
|
67
|
+
color: inherit;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[part="day"]:disabled {
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
/**
|
|
75
|
+
* `<dui-calendar>` — A date picker calendar grid.
|
|
76
|
+
*
|
|
77
|
+
* @csspart root - The outer container.
|
|
78
|
+
* @csspart header - Month navigation header.
|
|
79
|
+
* @csspart heading - The month/year heading text.
|
|
80
|
+
* @csspart prev - Previous month button.
|
|
81
|
+
* @csspart next - Next month button.
|
|
82
|
+
* @csspart grid - The day grid container.
|
|
83
|
+
* @csspart weekday - Weekday column header.
|
|
84
|
+
* @csspart day - Individual day button.
|
|
85
|
+
* @fires value-change - Fired when a date is selected. Detail: { value: string }
|
|
86
|
+
*/
|
|
87
|
+
export class DuiCalendar extends LitElement {
|
|
88
|
+
static { this.tagName = "dui-calendar"; }
|
|
89
|
+
static { this.styles = [base, styles]; }
|
|
90
|
+
#value_accessor_storage = undefined;
|
|
91
|
+
get value() { return this.#value_accessor_storage; }
|
|
92
|
+
set value(value) { this.#value_accessor_storage = value; }
|
|
93
|
+
#defaultValue_accessor_storage = undefined;
|
|
94
|
+
get defaultValue() { return this.#defaultValue_accessor_storage; }
|
|
95
|
+
set defaultValue(value) { this.#defaultValue_accessor_storage = value; }
|
|
96
|
+
#min_accessor_storage = undefined;
|
|
97
|
+
get min() { return this.#min_accessor_storage; }
|
|
98
|
+
set min(value) { this.#min_accessor_storage = value; }
|
|
99
|
+
#max_accessor_storage = undefined;
|
|
100
|
+
get max() { return this.#max_accessor_storage; }
|
|
101
|
+
set max(value) { this.#max_accessor_storage = value; }
|
|
102
|
+
#locale_accessor_storage = "en-US";
|
|
103
|
+
get locale() { return this.#locale_accessor_storage; }
|
|
104
|
+
set locale(value) { this.#locale_accessor_storage = value; }
|
|
105
|
+
#disabled_accessor_storage = false;
|
|
106
|
+
get disabled() { return this.#disabled_accessor_storage; }
|
|
107
|
+
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
108
|
+
#readOnly_accessor_storage = false;
|
|
109
|
+
get readOnly() { return this.#readOnly_accessor_storage; }
|
|
110
|
+
set readOnly(value) { this.#readOnly_accessor_storage = value; }
|
|
111
|
+
#internalValue_accessor_storage = undefined;
|
|
112
|
+
get #internalValue() { return this.#internalValue_accessor_storage; }
|
|
113
|
+
set #internalValue(value) { this.#internalValue_accessor_storage = value; }
|
|
114
|
+
#focusedDate_accessor_storage = new Date();
|
|
115
|
+
get #focusedDate() { return this.#focusedDate_accessor_storage; }
|
|
116
|
+
set #focusedDate(value) { this.#focusedDate_accessor_storage = value; }
|
|
117
|
+
#viewMonth_accessor_storage = new Date().getMonth();
|
|
118
|
+
get #viewMonth() { return this.#viewMonth_accessor_storage; }
|
|
119
|
+
set #viewMonth(value) { this.#viewMonth_accessor_storage = value; }
|
|
120
|
+
#viewYear_accessor_storage = new Date().getFullYear();
|
|
121
|
+
get #viewYear() { return this.#viewYear_accessor_storage; }
|
|
122
|
+
set #viewYear(value) { this.#viewYear_accessor_storage = value; }
|
|
123
|
+
get #selectedValue() {
|
|
124
|
+
return this.value ?? this.#internalValue;
|
|
125
|
+
}
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
super.connectedCallback();
|
|
128
|
+
if (this.value === undefined && this.defaultValue !== undefined) {
|
|
129
|
+
this.#internalValue = this.defaultValue;
|
|
130
|
+
}
|
|
131
|
+
const selected = this.#selectedValue;
|
|
132
|
+
if (selected) {
|
|
133
|
+
const d = new Date(selected + "T00:00:00");
|
|
134
|
+
this.#viewMonth = d.getMonth();
|
|
135
|
+
this.#viewYear = d.getFullYear();
|
|
136
|
+
this.#focusedDate = d;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
#formatISO(date) {
|
|
140
|
+
const y = date.getFullYear();
|
|
141
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
142
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
143
|
+
return `${y}-${m}-${d}`;
|
|
144
|
+
}
|
|
145
|
+
#isSameDay(a, b) {
|
|
146
|
+
return (a.getFullYear() === b.getFullYear() &&
|
|
147
|
+
a.getMonth() === b.getMonth() &&
|
|
148
|
+
a.getDate() === b.getDate());
|
|
149
|
+
}
|
|
150
|
+
#isDateDisabled(date) {
|
|
151
|
+
if (this.disabled)
|
|
152
|
+
return true;
|
|
153
|
+
const iso = this.#formatISO(date);
|
|
154
|
+
if (this.min && iso < this.min)
|
|
155
|
+
return true;
|
|
156
|
+
if (this.max && iso > this.max)
|
|
157
|
+
return true;
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
#getDaysInMonth(year, month) {
|
|
161
|
+
return new Date(year, month + 1, 0).getDate();
|
|
162
|
+
}
|
|
163
|
+
#getFirstDayOfWeek() {
|
|
164
|
+
// Use Intl to determine first day of week for locale
|
|
165
|
+
// Fallback to Sunday (0) for most locales
|
|
166
|
+
try {
|
|
167
|
+
const locale = new Intl.Locale(this.locale);
|
|
168
|
+
// @ts-ignore — weekInfo is a newer API
|
|
169
|
+
const weekInfo = locale.weekInfo ?? locale.getWeekInfo?.();
|
|
170
|
+
return weekInfo?.firstDay === 7 ? 0 : (weekInfo?.firstDay ?? 0);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
#buildGrid() {
|
|
177
|
+
const year = this.#viewYear;
|
|
178
|
+
const month = this.#viewMonth;
|
|
179
|
+
const daysInMonth = this.#getDaysInMonth(year, month);
|
|
180
|
+
const firstDay = new Date(year, month, 1).getDay();
|
|
181
|
+
const firstDayOfWeek = this.#getFirstDayOfWeek();
|
|
182
|
+
const today = new Date();
|
|
183
|
+
const selectedIso = this.#selectedValue;
|
|
184
|
+
let startOffset = firstDay - firstDayOfWeek;
|
|
185
|
+
if (startOffset < 0)
|
|
186
|
+
startOffset += 7;
|
|
187
|
+
const cells = [];
|
|
188
|
+
// Days from previous month
|
|
189
|
+
const prevMonth = month === 0 ? 11 : month - 1;
|
|
190
|
+
const prevYear = month === 0 ? year - 1 : year;
|
|
191
|
+
const daysInPrevMonth = this.#getDaysInMonth(prevYear, prevMonth);
|
|
192
|
+
for (let i = startOffset - 1; i >= 0; i--) {
|
|
193
|
+
const day = daysInPrevMonth - i;
|
|
194
|
+
const date = new Date(prevYear, prevMonth, day);
|
|
195
|
+
cells.push({
|
|
196
|
+
date,
|
|
197
|
+
day,
|
|
198
|
+
iso: this.#formatISO(date),
|
|
199
|
+
isToday: this.#isSameDay(date, today),
|
|
200
|
+
isSelected: this.#formatISO(date) === selectedIso,
|
|
201
|
+
isOutsideMonth: true,
|
|
202
|
+
isDisabled: this.#isDateDisabled(date),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Days in current month
|
|
206
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
207
|
+
const date = new Date(year, month, day);
|
|
208
|
+
cells.push({
|
|
209
|
+
date,
|
|
210
|
+
day,
|
|
211
|
+
iso: this.#formatISO(date),
|
|
212
|
+
isToday: this.#isSameDay(date, today),
|
|
213
|
+
isSelected: this.#formatISO(date) === selectedIso,
|
|
214
|
+
isOutsideMonth: false,
|
|
215
|
+
isDisabled: this.#isDateDisabled(date),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Fill remaining cells to make 6 rows
|
|
219
|
+
const remaining = 42 - cells.length;
|
|
220
|
+
const nextMonth = month === 11 ? 0 : month + 1;
|
|
221
|
+
const nextYear = month === 11 ? year + 1 : year;
|
|
222
|
+
for (let day = 1; day <= remaining; day++) {
|
|
223
|
+
const date = new Date(nextYear, nextMonth, day);
|
|
224
|
+
cells.push({
|
|
225
|
+
date,
|
|
226
|
+
day,
|
|
227
|
+
iso: this.#formatISO(date),
|
|
228
|
+
isToday: this.#isSameDay(date, today),
|
|
229
|
+
isSelected: this.#formatISO(date) === selectedIso,
|
|
230
|
+
isOutsideMonth: true,
|
|
231
|
+
isDisabled: this.#isDateDisabled(date),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
// Split into rows of 7
|
|
235
|
+
const rows = [];
|
|
236
|
+
for (let i = 0; i < cells.length; i += 7) {
|
|
237
|
+
rows.push(cells.slice(i, i + 7));
|
|
238
|
+
}
|
|
239
|
+
return rows;
|
|
240
|
+
}
|
|
241
|
+
#getWeekdayNames() {
|
|
242
|
+
const formatter = new Intl.DateTimeFormat(this.locale, { weekday: "short" });
|
|
243
|
+
const firstDayOfWeek = this.#getFirstDayOfWeek();
|
|
244
|
+
const names = [];
|
|
245
|
+
for (let i = 0; i < 7; i++) {
|
|
246
|
+
// Jan 4 2015 is a Sunday
|
|
247
|
+
const date = new Date(2015, 0, 4 + firstDayOfWeek + i);
|
|
248
|
+
names.push(formatter.format(date));
|
|
249
|
+
}
|
|
250
|
+
return names;
|
|
251
|
+
}
|
|
252
|
+
#getMonthYearHeading() {
|
|
253
|
+
const date = new Date(this.#viewYear, this.#viewMonth, 1);
|
|
254
|
+
return new Intl.DateTimeFormat(this.locale, {
|
|
255
|
+
month: "long",
|
|
256
|
+
year: "numeric",
|
|
257
|
+
}).format(date);
|
|
258
|
+
}
|
|
259
|
+
#selectDate(iso) {
|
|
260
|
+
if (this.disabled || this.readOnly)
|
|
261
|
+
return;
|
|
262
|
+
if (this.value === undefined) {
|
|
263
|
+
this.#internalValue = iso;
|
|
264
|
+
}
|
|
265
|
+
this.dispatchEvent(valueChangeEvent({ value: iso }));
|
|
266
|
+
}
|
|
267
|
+
#navigateMonth(delta) {
|
|
268
|
+
let newMonth = this.#viewMonth + delta;
|
|
269
|
+
let newYear = this.#viewYear;
|
|
270
|
+
if (newMonth < 0) {
|
|
271
|
+
newMonth = 11;
|
|
272
|
+
newYear--;
|
|
273
|
+
}
|
|
274
|
+
else if (newMonth > 11) {
|
|
275
|
+
newMonth = 0;
|
|
276
|
+
newYear++;
|
|
277
|
+
}
|
|
278
|
+
this.#viewMonth = newMonth;
|
|
279
|
+
this.#viewYear = newYear;
|
|
280
|
+
this.#focusedDate = new Date(newYear, newMonth, 1);
|
|
281
|
+
}
|
|
282
|
+
#onDayClick = (e) => {
|
|
283
|
+
const button = e.currentTarget;
|
|
284
|
+
const iso = button.dataset.date;
|
|
285
|
+
if (iso && !button.disabled) {
|
|
286
|
+
this.#selectDate(iso);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
#onKeyDown = (e) => {
|
|
290
|
+
const focused = new Date(this.#focusedDate);
|
|
291
|
+
let handled = true;
|
|
292
|
+
switch (e.key) {
|
|
293
|
+
case "ArrowLeft":
|
|
294
|
+
focused.setDate(focused.getDate() - 1);
|
|
295
|
+
break;
|
|
296
|
+
case "ArrowRight":
|
|
297
|
+
focused.setDate(focused.getDate() + 1);
|
|
298
|
+
break;
|
|
299
|
+
case "ArrowUp":
|
|
300
|
+
focused.setDate(focused.getDate() - 7);
|
|
301
|
+
break;
|
|
302
|
+
case "ArrowDown":
|
|
303
|
+
focused.setDate(focused.getDate() + 7);
|
|
304
|
+
break;
|
|
305
|
+
case "PageUp":
|
|
306
|
+
if (e.shiftKey) {
|
|
307
|
+
focused.setFullYear(focused.getFullYear() - 1);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
focused.setMonth(focused.getMonth() - 1);
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
case "PageDown":
|
|
314
|
+
if (e.shiftKey) {
|
|
315
|
+
focused.setFullYear(focused.getFullYear() + 1);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
focused.setMonth(focused.getMonth() + 1);
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
case "Home": {
|
|
322
|
+
focused.setDate(1);
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
case "End": {
|
|
326
|
+
const daysInMonth = this.#getDaysInMonth(focused.getFullYear(), focused.getMonth());
|
|
327
|
+
focused.setDate(daysInMonth);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
case "Enter":
|
|
331
|
+
case " ":
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
if (!this.#isDateDisabled(focused)) {
|
|
334
|
+
this.#selectDate(this.#formatISO(focused));
|
|
335
|
+
}
|
|
336
|
+
return;
|
|
337
|
+
default:
|
|
338
|
+
handled = false;
|
|
339
|
+
}
|
|
340
|
+
if (handled) {
|
|
341
|
+
e.preventDefault();
|
|
342
|
+
this.#focusedDate = focused;
|
|
343
|
+
this.#viewMonth = focused.getMonth();
|
|
344
|
+
this.#viewYear = focused.getFullYear();
|
|
345
|
+
// Focus the correct day button after render
|
|
346
|
+
this.updateComplete.then(() => {
|
|
347
|
+
const iso = this.#formatISO(focused);
|
|
348
|
+
const btn = this.shadowRoot?.querySelector(`[data-date="${iso}"]`);
|
|
349
|
+
btn?.focus();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
#onPrevClick = () => {
|
|
354
|
+
this.#navigateMonth(-1);
|
|
355
|
+
};
|
|
356
|
+
#onNextClick = () => {
|
|
357
|
+
this.#navigateMonth(1);
|
|
358
|
+
};
|
|
359
|
+
render() {
|
|
360
|
+
const grid = this.#buildGrid();
|
|
361
|
+
const weekdays = this.#getWeekdayNames();
|
|
362
|
+
const heading = this.#getMonthYearHeading();
|
|
363
|
+
const focusedIso = this.#formatISO(this.#focusedDate);
|
|
364
|
+
return html `
|
|
365
|
+
<div part="root" role="grid" @keydown="${this.#onKeyDown}">
|
|
366
|
+
<div part="header">
|
|
367
|
+
<button
|
|
368
|
+
part="prev"
|
|
369
|
+
type="button"
|
|
370
|
+
aria-label="Previous month"
|
|
371
|
+
@click="${this.#onPrevClick}"
|
|
372
|
+
>
|
|
373
|
+
<slot name="prev">‹</slot>
|
|
374
|
+
</button>
|
|
375
|
+
<div part="heading" aria-live="polite">${heading}</div>
|
|
376
|
+
<button
|
|
377
|
+
part="next"
|
|
378
|
+
type="button"
|
|
379
|
+
aria-label="Next month"
|
|
380
|
+
@click="${this.#onNextClick}"
|
|
381
|
+
>
|
|
382
|
+
<slot name="next">›</slot>
|
|
383
|
+
</button>
|
|
384
|
+
</div>
|
|
385
|
+
|
|
386
|
+
<div part="grid" role="grid">
|
|
387
|
+
${weekdays.map((name) => html `<div part="weekday" role="columnheader">${name}</div>`)}
|
|
388
|
+
${grid.flat().map((cell) => html `
|
|
389
|
+
<button
|
|
390
|
+
part="day"
|
|
391
|
+
type="button"
|
|
392
|
+
role="gridcell"
|
|
393
|
+
data-date="${cell.iso}"
|
|
394
|
+
tabindex="${cell.iso === focusedIso ? 0 : -1}"
|
|
395
|
+
?data-selected="${cell.isSelected}"
|
|
396
|
+
?data-today="${cell.isToday}"
|
|
397
|
+
?data-outside-month="${cell.isOutsideMonth}"
|
|
398
|
+
?disabled="${cell.isDisabled}"
|
|
399
|
+
aria-selected="${cell.isSelected ? "true" : "false"}"
|
|
400
|
+
@click="${this.#onDayClick}"
|
|
401
|
+
>${cell.day}</button>
|
|
402
|
+
`)}
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
`;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
__decorate([
|
|
409
|
+
property()
|
|
410
|
+
], DuiCalendar.prototype, "value", null);
|
|
411
|
+
__decorate([
|
|
412
|
+
property({ attribute: "default-value" })
|
|
413
|
+
], DuiCalendar.prototype, "defaultValue", null);
|
|
414
|
+
__decorate([
|
|
415
|
+
property()
|
|
416
|
+
], DuiCalendar.prototype, "min", null);
|
|
417
|
+
__decorate([
|
|
418
|
+
property()
|
|
419
|
+
], DuiCalendar.prototype, "max", null);
|
|
420
|
+
__decorate([
|
|
421
|
+
property()
|
|
422
|
+
], DuiCalendar.prototype, "locale", null);
|
|
423
|
+
__decorate([
|
|
424
|
+
property({ type: Boolean, reflect: true })
|
|
425
|
+
], DuiCalendar.prototype, "disabled", null);
|
|
426
|
+
__decorate([
|
|
427
|
+
property({ type: Boolean, reflect: true, attribute: "read-only" })
|
|
428
|
+
], DuiCalendar.prototype, "readOnly", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DuiCalendar, valueChangeEvent } from "./calendar.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DuiCalendar, valueChangeEvent } from "./calendar.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Ported from original DUI: deep-future-app/app/client/components/dui/center */
|
|
2
|
+
import { LitElement, type TemplateResult } from "lit";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-center>` — Centers content horizontally and vertically
|
|
5
|
+
* within its container query dimensions.
|
|
6
|
+
*
|
|
7
|
+
* @slot - Content to center.
|
|
8
|
+
* @csspart root - The centering container element.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DuiCenter extends LitElement {
|
|
11
|
+
static tagName: "dui-center";
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
render(): TemplateResult;
|
|
14
|
+
}
|
package/center/center.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Ported from original DUI: deep-future-app/app/client/components/dui/center */
|
|
2
|
+
import { css, html, LitElement } from "lit";
|
|
3
|
+
import { base } from "@deepfuture/dui-core/base";
|
|
4
|
+
/** Structural styles only — layout CSS. */
|
|
5
|
+
const styles = css `
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
min-height: 100cqh;
|
|
9
|
+
width: 100cqw;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[part="root"] {
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
min-height: 100cqh;
|
|
17
|
+
width: 100cqw;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
/**
|
|
21
|
+
* `<dui-center>` — Centers content horizontally and vertically
|
|
22
|
+
* within its container query dimensions.
|
|
23
|
+
*
|
|
24
|
+
* @slot - Content to center.
|
|
25
|
+
* @csspart root - The centering container element.
|
|
26
|
+
*/
|
|
27
|
+
export class DuiCenter extends LitElement {
|
|
28
|
+
static { this.tagName = "dui-center"; }
|
|
29
|
+
static { this.styles = [base, styles]; }
|
|
30
|
+
render() {
|
|
31
|
+
return html `
|
|
32
|
+
<div part="root">
|
|
33
|
+
<slot></slot>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DuiCenter } from "./center.js";
|
package/center/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DuiCenter } from "./center.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Ported from original DUI: deep-future-app/app/client/components/dui/checkbox */
|
|
2
|
+
export type CheckboxGroupContext = {
|
|
3
|
+
readonly checkedValues: readonly string[];
|
|
4
|
+
readonly allValues: readonly string[];
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
readonly toggle: (value: string) => void;
|
|
7
|
+
readonly toggleAll: (checked: boolean) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const checkboxGroupContext: {
|
|
10
|
+
__context__: CheckboxGroupContext;
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Ported from original DUI: deep-future-app/app/client/components/dui/checkbox */
|
|
2
|
+
import { LitElement, type TemplateResult } from "lit";
|
|
3
|
+
export declare const valueChangeEvent: (detail: string[]) => CustomEvent<string[]>;
|
|
4
|
+
/**
|
|
5
|
+
* `<dui-checkbox-group>` — Groups multiple checkboxes with shared state.
|
|
6
|
+
*
|
|
7
|
+
* Manages a shared array of checked values. Supports controlled and
|
|
8
|
+
* uncontrolled usage, and an `allValues` prop for parent checkbox
|
|
9
|
+
* (select-all) patterns.
|
|
10
|
+
*
|
|
11
|
+
* @slot - Default slot for `<dui-checkbox>` children.
|
|
12
|
+
* @csspart root - The group container element.
|
|
13
|
+
*
|
|
14
|
+
* @fires value-change - Fired when the set of checked values changes. Detail: string[]
|
|
15
|
+
*/
|
|
16
|
+
export declare class DuiCheckboxGroup extends LitElement {
|
|
17
|
+
#private;
|
|
18
|
+
static tagName: "dui-checkbox-group";
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
/** Checked values (controlled). */
|
|
21
|
+
accessor value: string[] | undefined;
|
|
22
|
+
/** Initial checked values for uncontrolled usage. */
|
|
23
|
+
accessor defaultValue: string[];
|
|
24
|
+
/**
|
|
25
|
+
* All possible checkbox values in the group.
|
|
26
|
+
* Required when using a parent (select-all) checkbox.
|
|
27
|
+
*/
|
|
28
|
+
accessor allValues: string[];
|
|
29
|
+
/** Whether all checkboxes in the group are disabled. */
|
|
30
|
+
accessor disabled: boolean;
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
willUpdate(): void;
|
|
33
|
+
render(): TemplateResult;
|
|
34
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** Ported from original DUI: deep-future-app/app/client/components/dui/checkbox */
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
import { css, html, LitElement } from "lit";
|
|
9
|
+
import { property } from "lit/decorators.js";
|
|
10
|
+
import { base } from "@deepfuture/dui-core/base";
|
|
11
|
+
import { customEvent } from "@deepfuture/dui-core/event";
|
|
12
|
+
export const valueChangeEvent = customEvent("value-change", {
|
|
13
|
+
bubbles: true,
|
|
14
|
+
composed: true,
|
|
15
|
+
});
|
|
16
|
+
/** Structural styles only — layout and behavioral CSS. */
|
|
17
|
+
const styles = css `
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[part="root"] {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
align-items: start;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
/**
|
|
29
|
+
* `<dui-checkbox-group>` — Groups multiple checkboxes with shared state.
|
|
30
|
+
*
|
|
31
|
+
* Manages a shared array of checked values. Supports controlled and
|
|
32
|
+
* uncontrolled usage, and an `allValues` prop for parent checkbox
|
|
33
|
+
* (select-all) patterns.
|
|
34
|
+
*
|
|
35
|
+
* @slot - Default slot for `<dui-checkbox>` children.
|
|
36
|
+
* @csspart root - The group container element.
|
|
37
|
+
*
|
|
38
|
+
* @fires value-change - Fired when the set of checked values changes. Detail: string[]
|
|
39
|
+
*/
|
|
40
|
+
export class DuiCheckboxGroup extends LitElement {
|
|
41
|
+
static { this.tagName = "dui-checkbox-group"; }
|
|
42
|
+
static { this.styles = [base, styles]; }
|
|
43
|
+
#value_accessor_storage = undefined;
|
|
44
|
+
/** Checked values (controlled). */
|
|
45
|
+
get value() { return this.#value_accessor_storage; }
|
|
46
|
+
set value(value) { this.#value_accessor_storage = value; }
|
|
47
|
+
#defaultValue_accessor_storage = [];
|
|
48
|
+
/** Initial checked values for uncontrolled usage. */
|
|
49
|
+
get defaultValue() { return this.#defaultValue_accessor_storage; }
|
|
50
|
+
set defaultValue(value) { this.#defaultValue_accessor_storage = value; }
|
|
51
|
+
#allValues_accessor_storage = [];
|
|
52
|
+
/**
|
|
53
|
+
* All possible checkbox values in the group.
|
|
54
|
+
* Required when using a parent (select-all) checkbox.
|
|
55
|
+
*/
|
|
56
|
+
get allValues() { return this.#allValues_accessor_storage; }
|
|
57
|
+
set allValues(value) { this.#allValues_accessor_storage = value; }
|
|
58
|
+
#disabled_accessor_storage = false;
|
|
59
|
+
/** Whether all checkboxes in the group are disabled. */
|
|
60
|
+
get disabled() { return this.#disabled_accessor_storage; }
|
|
61
|
+
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
62
|
+
#internalValues_accessor_storage = [];
|
|
63
|
+
get #internalValues() { return this.#internalValues_accessor_storage; }
|
|
64
|
+
set #internalValues(value) { this.#internalValues_accessor_storage = value; }
|
|
65
|
+
#getCheckedValues = () => this.value ?? this.#internalValues;
|
|
66
|
+
#toggle = (val) => {
|
|
67
|
+
const current = this.#getCheckedValues();
|
|
68
|
+
const next = current.includes(val)
|
|
69
|
+
? current.filter((v) => v !== val)
|
|
70
|
+
: [...current, val];
|
|
71
|
+
if (this.value === undefined) {
|
|
72
|
+
this.#internalValues = next;
|
|
73
|
+
}
|
|
74
|
+
this.dispatchEvent(valueChangeEvent(next));
|
|
75
|
+
};
|
|
76
|
+
#toggleAll = (checked) => {
|
|
77
|
+
const next = checked ? [...this.allValues] : [];
|
|
78
|
+
if (this.value === undefined) {
|
|
79
|
+
this.#internalValues = next;
|
|
80
|
+
}
|
|
81
|
+
this.dispatchEvent(valueChangeEvent(next));
|
|
82
|
+
};
|
|
83
|
+
#ctx_accessor_storage = this.#buildContext();
|
|
84
|
+
get #ctx() { return this.#ctx_accessor_storage; }
|
|
85
|
+
set #ctx(value) { this.#ctx_accessor_storage = value; }
|
|
86
|
+
#buildContext() {
|
|
87
|
+
return {
|
|
88
|
+
checkedValues: this.#getCheckedValues(),
|
|
89
|
+
allValues: this.allValues,
|
|
90
|
+
disabled: this.disabled,
|
|
91
|
+
toggle: this.#toggle,
|
|
92
|
+
toggleAll: this.#toggleAll,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
connectedCallback() {
|
|
96
|
+
super.connectedCallback();
|
|
97
|
+
if (this.value === undefined && this.defaultValue.length > 0) {
|
|
98
|
+
this.#internalValues = [...this.defaultValue];
|
|
99
|
+
}
|
|
100
|
+
this.#ctx = this.#buildContext();
|
|
101
|
+
}
|
|
102
|
+
willUpdate() {
|
|
103
|
+
this.#ctx = this.#buildContext();
|
|
104
|
+
}
|
|
105
|
+
render() {
|
|
106
|
+
return html `
|
|
107
|
+
<div
|
|
108
|
+
part="root"
|
|
109
|
+
role="group"
|
|
110
|
+
?data-disabled="${this.disabled}"
|
|
111
|
+
>
|
|
112
|
+
<slot></slot>
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
__decorate([
|
|
118
|
+
property({ attribute: false })
|
|
119
|
+
], DuiCheckboxGroup.prototype, "value", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
property({ attribute: false })
|
|
122
|
+
], DuiCheckboxGroup.prototype, "defaultValue", null);
|
|
123
|
+
__decorate([
|
|
124
|
+
property({ attribute: false })
|
|
125
|
+
], DuiCheckboxGroup.prototype, "allValues", null);
|
|
126
|
+
__decorate([
|
|
127
|
+
property({ type: Boolean, reflect: true })
|
|
128
|
+
], DuiCheckboxGroup.prototype, "disabled", null);
|