@deepfuture/dui-components 0.0.10 → 0.0.12
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/_deprecated/center/register.d.ts +1 -0
- package/_deprecated/center/register.js +4 -0
- package/_deprecated/hstack/register.d.ts +1 -0
- package/_deprecated/hstack/register.js +4 -0
- package/_deprecated/page-inset/register.d.ts +1 -0
- package/_deprecated/page-inset/register.js +4 -0
- package/_deprecated/vstack/register.d.ts +1 -0
- package/_deprecated/vstack/register.js +4 -0
- package/alert-dialog/alert-dialog.d.ts +2 -0
- package/alert-dialog/alert-dialog.js +12 -6
- package/all.d.ts +16 -64
- package/all.js +132 -144
- package/checkbox/checkbox-group.d.ts +2 -0
- package/checkbox/checkbox-group.js +12 -6
- package/checkbox/checkbox.d.ts +2 -0
- package/checkbox/checkbox.js +17 -11
- package/dialog/dialog.d.ts +2 -0
- package/dialog/dialog.js +12 -6
- package/global.d.ts +0 -8
- package/input/input.d.ts +2 -0
- package/input/input.js +24 -18
- package/menubar/menubar.d.ts +2 -0
- package/menubar/menubar.js +11 -5
- package/number-field/number-field.d.ts +2 -0
- package/number-field/number-field.js +18 -12
- package/package.json +2 -18
- package/popover/popover.d.ts +2 -1
- package/popover/popover.js +14 -8
- package/preview-card/preview-card.d.ts +2 -1
- package/preview-card/preview-card.js +14 -8
- package/radio/radio-group.d.ts +2 -0
- package/radio/radio-group.js +12 -6
- package/radio/radio.d.ts +2 -0
- package/radio/radio.js +15 -9
- package/select/select.d.ts +2 -0
- package/select/select.js +19 -13
- package/sidebar/sidebar-provider.d.ts +2 -0
- package/sidebar/sidebar-provider.js +12 -6
- package/switch/switch.d.ts +2 -0
- package/switch/switch.js +15 -9
- package/toggle/toggle-group.d.ts +2 -0
- package/toggle/toggle-group.js +12 -6
- package/toggle/toggle.d.ts +2 -0
- package/toggle/toggle.js +15 -9
- package/tooltip/tooltip.d.ts +2 -1
- package/tooltip/tooltip.js +14 -8
- /package/{center → _deprecated/center}/center.d.ts +0 -0
- /package/{center → _deprecated/center}/center.js +0 -0
- /package/{center → _deprecated/center}/index.d.ts +0 -0
- /package/{center → _deprecated/center}/index.js +0 -0
- /package/{hstack → _deprecated/hstack}/hstack.d.ts +0 -0
- /package/{hstack → _deprecated/hstack}/hstack.js +0 -0
- /package/{hstack → _deprecated/hstack}/index.d.ts +0 -0
- /package/{hstack → _deprecated/hstack}/index.js +0 -0
- /package/{page-inset → _deprecated/page-inset}/index.d.ts +0 -0
- /package/{page-inset → _deprecated/page-inset}/index.js +0 -0
- /package/{page-inset → _deprecated/page-inset}/page-inset.d.ts +0 -0
- /package/{page-inset → _deprecated/page-inset}/page-inset.js +0 -0
- /package/{vstack → _deprecated/vstack}/index.d.ts +0 -0
- /package/{vstack → _deprecated/vstack}/index.js +0 -0
- /package/{vstack → _deprecated/vstack}/vstack.d.ts +0 -0
- /package/{vstack → _deprecated/vstack}/vstack.js +0 -0
package/checkbox/checkbox.js
CHANGED
|
@@ -6,10 +6,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
import { css, html, LitElement, nothing } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
10
|
import { ContextConsumer } from "@lit/context";
|
|
11
|
+
import { consume } from "@lit/context";
|
|
11
12
|
import { base } from "@deepfuture/dui-core/base";
|
|
12
13
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
14
|
+
import { fieldContext } from "../field/field-context.js";
|
|
13
15
|
import { checkboxGroupContext } from "./checkbox-group-context.js";
|
|
14
16
|
export const checkedChangeEvent = customEvent("checked-change", { bubbles: true, composed: true });
|
|
15
17
|
/** Structural styles only — layout and behavioral CSS. */
|
|
@@ -149,9 +151,9 @@ export class DuiCheckbox extends LitElement {
|
|
|
149
151
|
context: checkboxGroupContext,
|
|
150
152
|
subscribe: true,
|
|
151
153
|
});
|
|
152
|
-
#
|
|
153
|
-
get
|
|
154
|
-
set
|
|
154
|
+
#_fieldCtx_accessor_storage;
|
|
155
|
+
get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
|
|
156
|
+
set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
|
|
155
157
|
get #isChecked() {
|
|
156
158
|
const ctx = this.#groupCtx.value;
|
|
157
159
|
if (ctx && this.value !== undefined) {
|
|
@@ -174,10 +176,10 @@ export class DuiCheckbox extends LitElement {
|
|
|
174
176
|
get #isDisabled() {
|
|
175
177
|
return (this.disabled ||
|
|
176
178
|
(this.#groupCtx.value?.disabled ?? false) ||
|
|
177
|
-
(this
|
|
179
|
+
(this._fieldCtx?.disabled ?? false));
|
|
178
180
|
}
|
|
179
181
|
get #isInvalid() {
|
|
180
|
-
return this
|
|
182
|
+
return this._fieldCtx?.invalid ?? false;
|
|
181
183
|
}
|
|
182
184
|
connectedCallback() {
|
|
183
185
|
super.connectedCallback();
|
|
@@ -205,8 +207,8 @@ export class DuiCheckbox extends LitElement {
|
|
|
205
207
|
else {
|
|
206
208
|
ctx.toggle(this.value);
|
|
207
209
|
}
|
|
208
|
-
this
|
|
209
|
-
this
|
|
210
|
+
this._fieldCtx?.markDirty();
|
|
211
|
+
this._fieldCtx?.markTouched();
|
|
210
212
|
return;
|
|
211
213
|
}
|
|
212
214
|
// Standalone behavior
|
|
@@ -215,8 +217,8 @@ export class DuiCheckbox extends LitElement {
|
|
|
215
217
|
this.#internalChecked = newChecked;
|
|
216
218
|
this.indeterminate = false;
|
|
217
219
|
}
|
|
218
|
-
this
|
|
219
|
-
this
|
|
220
|
+
this._fieldCtx?.markDirty();
|
|
221
|
+
this._fieldCtx?.markTouched();
|
|
220
222
|
this.dispatchEvent(checkedChangeEvent({
|
|
221
223
|
checked: newChecked,
|
|
222
224
|
indeterminate: false,
|
|
@@ -234,7 +236,7 @@ export class DuiCheckbox extends LitElement {
|
|
|
234
236
|
const isDisabled = this.#isDisabled;
|
|
235
237
|
const isInvalid = this.#isInvalid;
|
|
236
238
|
const showIndicator = isChecked || isIndeterminate;
|
|
237
|
-
const controlId = this
|
|
239
|
+
const controlId = this._fieldCtx?.controlId ?? "";
|
|
238
240
|
return html `
|
|
239
241
|
<span
|
|
240
242
|
part="root"
|
|
@@ -311,3 +313,7 @@ __decorate([
|
|
|
311
313
|
__decorate([
|
|
312
314
|
property({ type: Boolean })
|
|
313
315
|
], DuiCheckbox.prototype, "parent", null);
|
|
316
|
+
__decorate([
|
|
317
|
+
consume({ context: fieldContext, subscribe: true }),
|
|
318
|
+
state()
|
|
319
|
+
], DuiCheckbox.prototype, "_fieldCtx", null);
|
package/dialog/dialog.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/dialog */
|
|
2
2
|
import { LitElement, type TemplateResult } from "lit";
|
|
3
|
+
import { type DialogContext } from "./dialog-context.js";
|
|
3
4
|
export type DialogOpenChangeDetail = {
|
|
4
5
|
open: boolean;
|
|
5
6
|
};
|
|
@@ -24,6 +25,7 @@ export declare class DuiDialog extends LitElement {
|
|
|
24
25
|
accessor open: boolean | undefined;
|
|
25
26
|
/** Initial open state for uncontrolled mode. */
|
|
26
27
|
accessor defaultOpen: boolean;
|
|
28
|
+
accessor _ctx: DialogContext;
|
|
27
29
|
connectedCallback(): void;
|
|
28
30
|
willUpdate(): void;
|
|
29
31
|
render(): TemplateResult;
|
package/dialog/dialog.js
CHANGED
|
@@ -6,9 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
import { css, html, LitElement } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { provide } from "@lit/context";
|
|
10
11
|
import { base } from "@deepfuture/dui-core/base";
|
|
11
12
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
13
|
+
import { dialogContext } from "./dialog-context.js";
|
|
12
14
|
export const openChangeEvent = customEvent("open-change", { bubbles: true, composed: true });
|
|
13
15
|
const hostStyles = css `
|
|
14
16
|
:host {
|
|
@@ -61,9 +63,9 @@ export class DuiDialog extends LitElement {
|
|
|
61
63
|
}
|
|
62
64
|
this.dispatchEvent(openChangeEvent({ open: false }));
|
|
63
65
|
};
|
|
64
|
-
#
|
|
65
|
-
get
|
|
66
|
-
set
|
|
66
|
+
#_ctx_accessor_storage = this.#buildContext();
|
|
67
|
+
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
68
|
+
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
67
69
|
#buildContext() {
|
|
68
70
|
return {
|
|
69
71
|
open: this.#isOpen,
|
|
@@ -80,10 +82,10 @@ export class DuiDialog extends LitElement {
|
|
|
80
82
|
if (this.open === undefined && this.defaultOpen) {
|
|
81
83
|
this.#internalOpen = true;
|
|
82
84
|
}
|
|
83
|
-
this
|
|
85
|
+
this._ctx = this.#buildContext();
|
|
84
86
|
}
|
|
85
87
|
willUpdate() {
|
|
86
|
-
this
|
|
88
|
+
this._ctx = this.#buildContext();
|
|
87
89
|
}
|
|
88
90
|
render() {
|
|
89
91
|
return html `<slot></slot>`;
|
|
@@ -95,3 +97,7 @@ __decorate([
|
|
|
95
97
|
__decorate([
|
|
96
98
|
property({ type: Boolean, attribute: "default-open" })
|
|
97
99
|
], DuiDialog.prototype, "defaultOpen", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
provide({ context: dialogContext }),
|
|
102
|
+
state()
|
|
103
|
+
], DuiDialog.prototype, "_ctx", null);
|
package/global.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ import type { DuiBreadcrumbSeparator } from "./breadcrumb/breadcrumb-separator.j
|
|
|
22
22
|
import type { DuiBreadcrumbEllipsis } from "./breadcrumb/breadcrumb-ellipsis.js";
|
|
23
23
|
import type { DuiButton } from "./button/button.js";
|
|
24
24
|
import type { DuiCalendar } from "./calendar/calendar.js";
|
|
25
|
-
import type { DuiCenter } from "./center/center.js";
|
|
26
25
|
import type { DuiCheckbox } from "./checkbox/checkbox.js";
|
|
27
26
|
import type { DuiCheckboxGroup } from "./checkbox/checkbox-group.js";
|
|
28
27
|
import type { DuiCollapsible } from "./collapsible/collapsible.js";
|
|
@@ -41,7 +40,6 @@ import type { DuiDialogTrigger } from "./dialog/dialog-trigger.js";
|
|
|
41
40
|
import type { DuiDialogPopup } from "./dialog/dialog-popup.js";
|
|
42
41
|
import type { DuiDialogClose } from "./dialog/dialog-close.js";
|
|
43
42
|
import type { DuiDropzone } from "./dropzone/dropzone.js";
|
|
44
|
-
import type { DuiHstack } from "./hstack/hstack.js";
|
|
45
43
|
import type { DuiIcon } from "./icon/icon.js";
|
|
46
44
|
import type { DuiInput } from "./input/input.js";
|
|
47
45
|
import type { DuiLink } from "./link/link.js";
|
|
@@ -49,7 +47,6 @@ import type { DuiMenu } from "./menu/menu.js";
|
|
|
49
47
|
import type { DuiMenuItem } from "./menu/menu-item.js";
|
|
50
48
|
import type { DuiMenubar } from "./menubar/menubar.js";
|
|
51
49
|
import type { DuiNumberField } from "./number-field/number-field.js";
|
|
52
|
-
import type { DuiPageInset } from "./page-inset/page-inset.js";
|
|
53
50
|
import type { DuiPopover } from "./popover/popover.js";
|
|
54
51
|
import type { DuiPopoverTrigger } from "./popover/popover-trigger.js";
|
|
55
52
|
import type { DuiPopoverPopup } from "./popover/popover-popup.js";
|
|
@@ -93,7 +90,6 @@ import type { DuiTooltip } from "./tooltip/tooltip.js";
|
|
|
93
90
|
import type { DuiTooltipTrigger } from "./tooltip/tooltip-trigger.js";
|
|
94
91
|
import type { DuiTooltipPopup } from "./tooltip/tooltip-popup.js";
|
|
95
92
|
import type { DuiTrunc } from "./trunc/trunc.js";
|
|
96
|
-
import type { DuiVstack } from "./vstack/vstack.js";
|
|
97
93
|
|
|
98
94
|
declare global {
|
|
99
95
|
interface HTMLElementTagNameMap {
|
|
@@ -113,7 +109,6 @@ declare global {
|
|
|
113
109
|
"dui-breadcrumb-ellipsis": DuiBreadcrumbEllipsis;
|
|
114
110
|
"dui-button": DuiButton;
|
|
115
111
|
"dui-calendar": DuiCalendar;
|
|
116
|
-
"dui-center": DuiCenter;
|
|
117
112
|
"dui-checkbox": DuiCheckbox;
|
|
118
113
|
"dui-checkbox-group": DuiCheckboxGroup;
|
|
119
114
|
"dui-collapsible": DuiCollapsible;
|
|
@@ -132,7 +127,6 @@ declare global {
|
|
|
132
127
|
"dui-dialog-popup": DuiDialogPopup;
|
|
133
128
|
"dui-dialog-close": DuiDialogClose;
|
|
134
129
|
"dui-dropzone": DuiDropzone;
|
|
135
|
-
"dui-hstack": DuiHstack;
|
|
136
130
|
"dui-icon": DuiIcon;
|
|
137
131
|
"dui-input": DuiInput;
|
|
138
132
|
"dui-link": DuiLink;
|
|
@@ -140,7 +134,6 @@ declare global {
|
|
|
140
134
|
"dui-menu-item": DuiMenuItem;
|
|
141
135
|
"dui-menubar": DuiMenubar;
|
|
142
136
|
"dui-number-field": DuiNumberField;
|
|
143
|
-
"dui-page-inset": DuiPageInset;
|
|
144
137
|
"dui-popover": DuiPopover;
|
|
145
138
|
"dui-popover-trigger": DuiPopoverTrigger;
|
|
146
139
|
"dui-popover-popup": DuiPopoverPopup;
|
|
@@ -184,6 +177,5 @@ declare global {
|
|
|
184
177
|
"dui-tooltip-trigger": DuiTooltipTrigger;
|
|
185
178
|
"dui-tooltip-popup": DuiTooltipPopup;
|
|
186
179
|
"dui-trunc": DuiTrunc;
|
|
187
|
-
"dui-vstack": DuiVstack;
|
|
188
180
|
}
|
|
189
181
|
}
|
package/input/input.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/input */
|
|
2
2
|
import { LitElement, type TemplateResult } from "lit";
|
|
3
|
+
import { type FieldContext } from "@deepfuture/dui-components/field";
|
|
3
4
|
export declare const inputChangeEvent: (detail: {
|
|
4
5
|
value: string;
|
|
5
6
|
}) => CustomEvent<{
|
|
@@ -42,6 +43,7 @@ export declare class DuiInput extends LitElement {
|
|
|
42
43
|
accessor autocomplete: string | undefined;
|
|
43
44
|
/** Whether the input should receive focus on mount. */
|
|
44
45
|
accessor autofocus: boolean;
|
|
46
|
+
accessor _fieldCtx: FieldContext;
|
|
45
47
|
firstUpdated(): void;
|
|
46
48
|
render(): TemplateResult;
|
|
47
49
|
}
|
package/input/input.js
CHANGED
|
@@ -6,10 +6,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
import { css, html, LitElement } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { consume } from "@lit/context";
|
|
10
11
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
11
12
|
import { live } from "lit/directives/live.js";
|
|
12
13
|
import { base } from "@deepfuture/dui-core/base";
|
|
14
|
+
import { fieldContext } from "@deepfuture/dui-components/field";
|
|
13
15
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
14
16
|
export const inputChangeEvent = customEvent("input-change", {
|
|
15
17
|
bubbles: true,
|
|
@@ -94,23 +96,23 @@ export class DuiInput extends LitElement {
|
|
|
94
96
|
/** Whether the input should receive focus on mount. */
|
|
95
97
|
get autofocus() { return this.#autofocus_accessor_storage; }
|
|
96
98
|
set autofocus(value) { this.#autofocus_accessor_storage = value; }
|
|
97
|
-
#
|
|
98
|
-
get
|
|
99
|
-
set
|
|
99
|
+
#_fieldCtx_accessor_storage;
|
|
100
|
+
get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
|
|
101
|
+
set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
|
|
100
102
|
get #controlId() {
|
|
101
|
-
return this
|
|
103
|
+
return this._fieldCtx?.controlId ?? "";
|
|
102
104
|
}
|
|
103
105
|
get #descriptionId() {
|
|
104
|
-
return this
|
|
106
|
+
return this._fieldCtx?.descriptionId;
|
|
105
107
|
}
|
|
106
108
|
get #errorId() {
|
|
107
|
-
return this
|
|
109
|
+
return this._fieldCtx?.errorId;
|
|
108
110
|
}
|
|
109
111
|
get #isDisabled() {
|
|
110
|
-
return this.disabled || (this
|
|
112
|
+
return this.disabled || (this._fieldCtx?.disabled ?? false);
|
|
111
113
|
}
|
|
112
114
|
get #isInvalid() {
|
|
113
|
-
return this
|
|
115
|
+
return this._fieldCtx?.invalid ?? false;
|
|
114
116
|
}
|
|
115
117
|
firstUpdated() {
|
|
116
118
|
if (this.autofocus) {
|
|
@@ -120,16 +122,16 @@ export class DuiInput extends LitElement {
|
|
|
120
122
|
#onInput = (event) => {
|
|
121
123
|
const target = event.target;
|
|
122
124
|
this.value = target.value;
|
|
123
|
-
this
|
|
124
|
-
this
|
|
125
|
+
this._fieldCtx?.markDirty();
|
|
126
|
+
this._fieldCtx?.setFilled(this.value.length > 0);
|
|
125
127
|
this.dispatchEvent(inputChangeEvent({ value: this.value }));
|
|
126
128
|
};
|
|
127
129
|
#onFocus = () => {
|
|
128
|
-
this
|
|
130
|
+
this._fieldCtx?.setFocused(true);
|
|
129
131
|
};
|
|
130
132
|
#onBlur = () => {
|
|
131
|
-
this
|
|
132
|
-
this
|
|
133
|
+
this._fieldCtx?.setFocused(false);
|
|
134
|
+
this._fieldCtx?.markTouched();
|
|
133
135
|
};
|
|
134
136
|
render() {
|
|
135
137
|
const describedBy = [this.#descriptionId, this.#isInvalid ? this.#errorId : undefined]
|
|
@@ -155,10 +157,10 @@ export class DuiInput extends LitElement {
|
|
|
155
157
|
?data-disabled="${this.#isDisabled}"
|
|
156
158
|
?data-invalid="${this.#isInvalid}"
|
|
157
159
|
?data-valid="${!this.#isInvalid}"
|
|
158
|
-
?data-dirty="${this
|
|
159
|
-
?data-touched="${this
|
|
160
|
-
?data-filled="${this
|
|
161
|
-
?data-focused="${this
|
|
160
|
+
?data-dirty="${this._fieldCtx?.dirty}"
|
|
161
|
+
?data-touched="${this._fieldCtx?.touched}"
|
|
162
|
+
?data-filled="${this._fieldCtx?.filled}"
|
|
163
|
+
?data-focused="${this._fieldCtx?.focused}"
|
|
162
164
|
@input="${this.#onInput}"
|
|
163
165
|
@focus="${this.#onFocus}"
|
|
164
166
|
@blur="${this.#onBlur}"
|
|
@@ -202,3 +204,7 @@ __decorate([
|
|
|
202
204
|
__decorate([
|
|
203
205
|
property({ type: Boolean })
|
|
204
206
|
], DuiInput.prototype, "autofocus", null);
|
|
207
|
+
__decorate([
|
|
208
|
+
consume({ context: fieldContext, subscribe: true }),
|
|
209
|
+
state()
|
|
210
|
+
], DuiInput.prototype, "_fieldCtx", null);
|
package/menubar/menubar.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, type TemplateResult } from "lit";
|
|
2
|
+
import { type MenubarContext } from "./menubar-context.js";
|
|
2
3
|
/**
|
|
3
4
|
* `<dui-menubar>` — A horizontal bar of menus with coordinated open/close.
|
|
4
5
|
*
|
|
@@ -14,6 +15,7 @@ export declare class DuiMenubar extends LitElement {
|
|
|
14
15
|
static styles: import("lit").CSSResult[];
|
|
15
16
|
accessor loop: boolean;
|
|
16
17
|
accessor orientation: "horizontal" | "vertical";
|
|
18
|
+
accessor _ctx: MenubarContext;
|
|
17
19
|
willUpdate(): void;
|
|
18
20
|
render(): TemplateResult;
|
|
19
21
|
}
|
package/menubar/menubar.js
CHANGED
|
@@ -5,8 +5,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { css, html, LitElement } from "lit";
|
|
8
|
-
import { property } from "lit/decorators.js";
|
|
8
|
+
import { property, state } from "lit/decorators.js";
|
|
9
|
+
import { provide } from "@lit/context";
|
|
9
10
|
import { base } from "@deepfuture/dui-core/base";
|
|
11
|
+
import { menubarContext, } from "./menubar-context.js";
|
|
10
12
|
/** Structural styles only — layout CSS. */
|
|
11
13
|
const styles = css `
|
|
12
14
|
:host {
|
|
@@ -82,9 +84,9 @@ export class DuiMenubar extends LitElement {
|
|
|
82
84
|
const trigger = nextMenu.querySelector('[slot="trigger"]');
|
|
83
85
|
trigger?.focus();
|
|
84
86
|
};
|
|
85
|
-
#
|
|
86
|
-
get
|
|
87
|
-
set
|
|
87
|
+
#_ctx_accessor_storage = this.#buildContext();
|
|
88
|
+
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
89
|
+
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
88
90
|
#buildContext() {
|
|
89
91
|
return {
|
|
90
92
|
activeMenuId: this.#activeMenuId,
|
|
@@ -94,7 +96,7 @@ export class DuiMenubar extends LitElement {
|
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
98
|
willUpdate() {
|
|
97
|
-
this
|
|
99
|
+
this._ctx = this.#buildContext();
|
|
98
100
|
}
|
|
99
101
|
#onKeyDown = (e) => {
|
|
100
102
|
const isHorizontal = this.orientation === "horizontal";
|
|
@@ -128,3 +130,7 @@ __decorate([
|
|
|
128
130
|
__decorate([
|
|
129
131
|
property({ reflect: true })
|
|
130
132
|
], DuiMenubar.prototype, "orientation", null);
|
|
133
|
+
__decorate([
|
|
134
|
+
provide({ context: menubarContext }),
|
|
135
|
+
state()
|
|
136
|
+
], DuiMenubar.prototype, "_ctx", null);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, type TemplateResult } from "lit";
|
|
2
|
+
import { type FieldContext } from "@deepfuture/dui-components/field";
|
|
2
3
|
export declare const valueChangeEvent: (detail: {
|
|
3
4
|
value: number;
|
|
4
5
|
}) => CustomEvent<{
|
|
@@ -28,6 +29,7 @@ export declare class DuiNumberField extends LitElement {
|
|
|
28
29
|
accessor readOnly: boolean;
|
|
29
30
|
accessor required: boolean;
|
|
30
31
|
accessor name: string | undefined;
|
|
32
|
+
accessor _fieldCtx: FieldContext;
|
|
31
33
|
connectedCallback(): void;
|
|
32
34
|
willUpdate(): void;
|
|
33
35
|
render(): TemplateResult;
|
|
@@ -5,10 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { css, html, LitElement, nothing } from "lit";
|
|
8
|
-
import { property } from "lit/decorators.js";
|
|
8
|
+
import { property, state } from "lit/decorators.js";
|
|
9
|
+
import { consume } from "@lit/context";
|
|
9
10
|
import { live } from "lit/directives/live.js";
|
|
10
11
|
import { base } from "@deepfuture/dui-core/base";
|
|
11
12
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
13
|
+
import { fieldContext } from "@deepfuture/dui-components/field";
|
|
12
14
|
export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
|
|
13
15
|
/** Structural styles only — layout CSS. */
|
|
14
16
|
const styles = css `
|
|
@@ -117,17 +119,17 @@ export class DuiNumberField extends LitElement {
|
|
|
117
119
|
#inputText_accessor_storage = "";
|
|
118
120
|
get #inputText() { return this.#inputText_accessor_storage; }
|
|
119
121
|
set #inputText(value) { this.#inputText_accessor_storage = value; }
|
|
120
|
-
#
|
|
121
|
-
get
|
|
122
|
-
set
|
|
122
|
+
#_fieldCtx_accessor_storage;
|
|
123
|
+
get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
|
|
124
|
+
set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
|
|
123
125
|
get #currentValue() {
|
|
124
126
|
return this.value ?? this.#internalValue;
|
|
125
127
|
}
|
|
126
128
|
get #isDisabled() {
|
|
127
|
-
return this.disabled || (this
|
|
129
|
+
return this.disabled || (this._fieldCtx?.disabled ?? false);
|
|
128
130
|
}
|
|
129
131
|
get #isInvalid() {
|
|
130
|
-
return this
|
|
132
|
+
return this._fieldCtx?.invalid ?? false;
|
|
131
133
|
}
|
|
132
134
|
get #canDecrement() {
|
|
133
135
|
const v = this.#currentValue;
|
|
@@ -167,8 +169,8 @@ export class DuiNumberField extends LitElement {
|
|
|
167
169
|
if (this.value === undefined) {
|
|
168
170
|
this.#internalValue = clamped;
|
|
169
171
|
}
|
|
170
|
-
this
|
|
171
|
-
this
|
|
172
|
+
this._fieldCtx?.markDirty();
|
|
173
|
+
this._fieldCtx?.setFilled(true);
|
|
172
174
|
this.dispatchEvent(valueChangeEvent({ value: clamped }));
|
|
173
175
|
}
|
|
174
176
|
#increment = (amount) => {
|
|
@@ -197,11 +199,11 @@ export class DuiNumberField extends LitElement {
|
|
|
197
199
|
};
|
|
198
200
|
#onBlur = () => {
|
|
199
201
|
this.#commitInput();
|
|
200
|
-
this
|
|
201
|
-
this
|
|
202
|
+
this._fieldCtx?.setFocused(false);
|
|
203
|
+
this._fieldCtx?.markTouched();
|
|
202
204
|
};
|
|
203
205
|
#onFocus = () => {
|
|
204
|
-
this
|
|
206
|
+
this._fieldCtx?.setFocused(true);
|
|
205
207
|
};
|
|
206
208
|
#onKeyDown = (e) => {
|
|
207
209
|
switch (e.key) {
|
|
@@ -239,7 +241,7 @@ export class DuiNumberField extends LitElement {
|
|
|
239
241
|
render() {
|
|
240
242
|
const isDisabled = this.#isDisabled;
|
|
241
243
|
const isInvalid = this.#isInvalid;
|
|
242
|
-
const controlId = this
|
|
244
|
+
const controlId = this._fieldCtx?.controlId ?? "";
|
|
243
245
|
const currentValue = this.#currentValue;
|
|
244
246
|
return html `
|
|
245
247
|
<div
|
|
@@ -324,3 +326,7 @@ __decorate([
|
|
|
324
326
|
__decorate([
|
|
325
327
|
property()
|
|
326
328
|
], DuiNumberField.prototype, "name", null);
|
|
329
|
+
__decorate([
|
|
330
|
+
consume({ context: fieldContext, subscribe: true }),
|
|
331
|
+
state()
|
|
332
|
+
], DuiNumberField.prototype, "_fieldCtx", null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepfuture/dui-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "DUI unstyled web components — structural CSS only, themed via applyTheme()",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,22 +94,6 @@
|
|
|
94
94
|
"import": "./trunc/index.js",
|
|
95
95
|
"types": "./trunc/index.d.ts"
|
|
96
96
|
},
|
|
97
|
-
"./center": {
|
|
98
|
-
"import": "./center/index.js",
|
|
99
|
-
"types": "./center/index.d.ts"
|
|
100
|
-
},
|
|
101
|
-
"./hstack": {
|
|
102
|
-
"import": "./hstack/index.js",
|
|
103
|
-
"types": "./hstack/index.d.ts"
|
|
104
|
-
},
|
|
105
|
-
"./vstack": {
|
|
106
|
-
"import": "./vstack/index.js",
|
|
107
|
-
"types": "./vstack/index.d.ts"
|
|
108
|
-
},
|
|
109
|
-
"./page-inset": {
|
|
110
|
-
"import": "./page-inset/index.js",
|
|
111
|
-
"types": "./page-inset/index.d.ts"
|
|
112
|
-
},
|
|
113
97
|
"./link": {
|
|
114
98
|
"import": "./link/index.js",
|
|
115
99
|
"types": "./link/index.d.ts"
|
|
@@ -194,7 +178,7 @@
|
|
|
194
178
|
"README.md"
|
|
195
179
|
],
|
|
196
180
|
"dependencies": {
|
|
197
|
-
"@deepfuture/dui-core": "0.0.
|
|
181
|
+
"@deepfuture/dui-core": "0.0.12",
|
|
198
182
|
"lit": "^3.3.2",
|
|
199
183
|
"@lit/context": "^1.1.3"
|
|
200
184
|
},
|
package/popover/popover.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/popover */
|
|
2
2
|
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
3
|
-
import { type PopoverSide } from "./popover-context.js";
|
|
3
|
+
import { type PopoverContext, type PopoverSide } from "./popover-context.js";
|
|
4
4
|
export type PopoverOpenChangeDetail = {
|
|
5
5
|
open: boolean;
|
|
6
6
|
};
|
|
@@ -23,6 +23,7 @@ export declare class DuiPopover extends LitElement {
|
|
|
23
23
|
accessor side: PopoverSide;
|
|
24
24
|
/** Offset from the trigger in pixels. */
|
|
25
25
|
accessor sideOffset: number;
|
|
26
|
+
accessor _ctx: PopoverContext;
|
|
26
27
|
connectedCallback(): void;
|
|
27
28
|
disconnectedCallback(): void;
|
|
28
29
|
protected willUpdate(changed: PropertyValues): void;
|
package/popover/popover.js
CHANGED
|
@@ -6,9 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
import { css, html, LitElement } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { provide } from "@lit/context";
|
|
10
11
|
import { base } from "@deepfuture/dui-core/base";
|
|
11
12
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
13
|
+
import { popoverContext, } from "./popover-context.js";
|
|
12
14
|
export const openChangeEvent = customEvent("open-change", { bubbles: true, composed: true });
|
|
13
15
|
const hostStyles = css `
|
|
14
16
|
:host {
|
|
@@ -51,7 +53,7 @@ export class DuiPopover extends LitElement {
|
|
|
51
53
|
}
|
|
52
54
|
#triggerId = `popover-trigger-${crypto.randomUUID().slice(0, 8)}`;
|
|
53
55
|
#popupId = `popover-popup-${crypto.randomUUID().slice(0, 8)}`;
|
|
54
|
-
#
|
|
56
|
+
#_ctx_accessor_storage = {
|
|
55
57
|
open: false,
|
|
56
58
|
triggerId: this.#triggerId,
|
|
57
59
|
popupId: this.#popupId,
|
|
@@ -63,8 +65,8 @@ export class DuiPopover extends LitElement {
|
|
|
63
65
|
togglePopover: () => this.#doToggle(),
|
|
64
66
|
setTriggerEl: (el) => this.#setTriggerEl(el),
|
|
65
67
|
};
|
|
66
|
-
get
|
|
67
|
-
set
|
|
68
|
+
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
69
|
+
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
68
70
|
connectedCallback() {
|
|
69
71
|
super.connectedCallback();
|
|
70
72
|
if (this.defaultOpen) {
|
|
@@ -80,10 +82,10 @@ export class DuiPopover extends LitElement {
|
|
|
80
82
|
if (changed.has("open") ||
|
|
81
83
|
changed.has("side") ||
|
|
82
84
|
changed.has("sideOffset") ||
|
|
83
|
-
this
|
|
84
|
-
this
|
|
85
|
-
this
|
|
86
|
-
...this
|
|
85
|
+
this._ctx.open !== this.#isOpen ||
|
|
86
|
+
this._ctx.triggerEl !== this.#triggerEl) {
|
|
87
|
+
this._ctx = {
|
|
88
|
+
...this._ctx,
|
|
87
89
|
open: this.#isOpen,
|
|
88
90
|
side: this.side,
|
|
89
91
|
sideOffset: this.sideOffset,
|
|
@@ -138,3 +140,7 @@ __decorate([
|
|
|
138
140
|
__decorate([
|
|
139
141
|
property({ type: Number, attribute: "side-offset" })
|
|
140
142
|
], DuiPopover.prototype, "sideOffset", null);
|
|
143
|
+
__decorate([
|
|
144
|
+
provide({ context: popoverContext }),
|
|
145
|
+
state()
|
|
146
|
+
], DuiPopover.prototype, "_ctx", null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/preview-card */
|
|
2
2
|
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
3
|
-
import { type PreviewCardSide } from "./preview-card-context.js";
|
|
3
|
+
import { type PreviewCardContext, type PreviewCardSide } from "./preview-card-context.js";
|
|
4
4
|
export type PreviewCardOpenChangeDetail = {
|
|
5
5
|
open: boolean;
|
|
6
6
|
};
|
|
@@ -27,6 +27,7 @@ export declare class DuiPreviewCard extends LitElement {
|
|
|
27
27
|
accessor delay: number;
|
|
28
28
|
/** Delay before closing in milliseconds. */
|
|
29
29
|
accessor closeDelay: number;
|
|
30
|
+
accessor _ctx: PreviewCardContext;
|
|
30
31
|
connectedCallback(): void;
|
|
31
32
|
disconnectedCallback(): void;
|
|
32
33
|
protected willUpdate(changed: PropertyValues): void;
|
|
@@ -6,9 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
import { css, html, LitElement } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { provide } from "@lit/context";
|
|
10
11
|
import { base } from "@deepfuture/dui-core/base";
|
|
11
12
|
import { customEvent } from "@deepfuture/dui-core/event";
|
|
13
|
+
import { previewCardContext, } from "./preview-card-context.js";
|
|
12
14
|
export const openChangeEvent = customEvent("open-change", { bubbles: true, composed: true });
|
|
13
15
|
const hostStyles = css `
|
|
14
16
|
:host {
|
|
@@ -58,7 +60,7 @@ export class DuiPreviewCard extends LitElement {
|
|
|
58
60
|
#closeTimeout;
|
|
59
61
|
#triggerId = `preview-card-trigger-${crypto.randomUUID().slice(0, 8)}`;
|
|
60
62
|
#popupId = `preview-card-popup-${crypto.randomUUID().slice(0, 8)}`;
|
|
61
|
-
#
|
|
63
|
+
#_ctx_accessor_storage = {
|
|
62
64
|
open: false,
|
|
63
65
|
triggerId: this.#triggerId,
|
|
64
66
|
popupId: this.#popupId,
|
|
@@ -69,8 +71,8 @@ export class DuiPreviewCard extends LitElement {
|
|
|
69
71
|
closePreviewCard: () => this.#scheduleClose(),
|
|
70
72
|
setTriggerEl: (el) => this.#setTriggerEl(el),
|
|
71
73
|
};
|
|
72
|
-
get
|
|
73
|
-
set
|
|
74
|
+
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
75
|
+
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
74
76
|
connectedCallback() {
|
|
75
77
|
super.connectedCallback();
|
|
76
78
|
if (this.defaultOpen) {
|
|
@@ -86,10 +88,10 @@ export class DuiPreviewCard extends LitElement {
|
|
|
86
88
|
if (changed.has("open") ||
|
|
87
89
|
changed.has("side") ||
|
|
88
90
|
changed.has("sideOffset") ||
|
|
89
|
-
this
|
|
90
|
-
this
|
|
91
|
-
this
|
|
92
|
-
...this
|
|
91
|
+
this._ctx.open !== isOpen ||
|
|
92
|
+
this._ctx.triggerEl !== this.#triggerEl) {
|
|
93
|
+
this._ctx = {
|
|
94
|
+
...this._ctx,
|
|
93
95
|
open: isOpen,
|
|
94
96
|
side: this.side,
|
|
95
97
|
sideOffset: this.sideOffset,
|
|
@@ -162,3 +164,7 @@ __decorate([
|
|
|
162
164
|
__decorate([
|
|
163
165
|
property({ type: Number, attribute: "close-delay" })
|
|
164
166
|
], DuiPreviewCard.prototype, "closeDelay", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
provide({ context: previewCardContext }),
|
|
169
|
+
state()
|
|
170
|
+
], DuiPreviewCard.prototype, "_ctx", null);
|
package/radio/radio-group.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/radio */
|
|
2
2
|
import { LitElement, type TemplateResult } from "lit";
|
|
3
|
+
import { type RadioGroupContext } from "./radio-group-context.js";
|
|
3
4
|
export declare const valueChangeEvent: (detail: {
|
|
4
5
|
value: string;
|
|
5
6
|
}) => CustomEvent<{
|
|
@@ -31,6 +32,7 @@ export declare class DuiRadioGroup extends LitElement {
|
|
|
31
32
|
accessor readOnly: boolean;
|
|
32
33
|
/** Whether a selection is required. */
|
|
33
34
|
accessor required: boolean;
|
|
35
|
+
accessor _ctx: RadioGroupContext;
|
|
34
36
|
connectedCallback(): void;
|
|
35
37
|
willUpdate(): void;
|
|
36
38
|
render(): TemplateResult;
|