@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.
Files changed (62) hide show
  1. package/_deprecated/center/register.d.ts +1 -0
  2. package/_deprecated/center/register.js +4 -0
  3. package/_deprecated/hstack/register.d.ts +1 -0
  4. package/_deprecated/hstack/register.js +4 -0
  5. package/_deprecated/page-inset/register.d.ts +1 -0
  6. package/_deprecated/page-inset/register.js +4 -0
  7. package/_deprecated/vstack/register.d.ts +1 -0
  8. package/_deprecated/vstack/register.js +4 -0
  9. package/alert-dialog/alert-dialog.d.ts +2 -0
  10. package/alert-dialog/alert-dialog.js +12 -6
  11. package/all.d.ts +16 -64
  12. package/all.js +132 -144
  13. package/checkbox/checkbox-group.d.ts +2 -0
  14. package/checkbox/checkbox-group.js +12 -6
  15. package/checkbox/checkbox.d.ts +2 -0
  16. package/checkbox/checkbox.js +17 -11
  17. package/dialog/dialog.d.ts +2 -0
  18. package/dialog/dialog.js +12 -6
  19. package/global.d.ts +0 -8
  20. package/input/input.d.ts +2 -0
  21. package/input/input.js +24 -18
  22. package/menubar/menubar.d.ts +2 -0
  23. package/menubar/menubar.js +11 -5
  24. package/number-field/number-field.d.ts +2 -0
  25. package/number-field/number-field.js +18 -12
  26. package/package.json +2 -18
  27. package/popover/popover.d.ts +2 -1
  28. package/popover/popover.js +14 -8
  29. package/preview-card/preview-card.d.ts +2 -1
  30. package/preview-card/preview-card.js +14 -8
  31. package/radio/radio-group.d.ts +2 -0
  32. package/radio/radio-group.js +12 -6
  33. package/radio/radio.d.ts +2 -0
  34. package/radio/radio.js +15 -9
  35. package/select/select.d.ts +2 -0
  36. package/select/select.js +19 -13
  37. package/sidebar/sidebar-provider.d.ts +2 -0
  38. package/sidebar/sidebar-provider.js +12 -6
  39. package/switch/switch.d.ts +2 -0
  40. package/switch/switch.js +15 -9
  41. package/toggle/toggle-group.d.ts +2 -0
  42. package/toggle/toggle-group.js +12 -6
  43. package/toggle/toggle.d.ts +2 -0
  44. package/toggle/toggle.js +15 -9
  45. package/tooltip/tooltip.d.ts +2 -1
  46. package/tooltip/tooltip.js +14 -8
  47. /package/{center → _deprecated/center}/center.d.ts +0 -0
  48. /package/{center → _deprecated/center}/center.js +0 -0
  49. /package/{center → _deprecated/center}/index.d.ts +0 -0
  50. /package/{center → _deprecated/center}/index.js +0 -0
  51. /package/{hstack → _deprecated/hstack}/hstack.d.ts +0 -0
  52. /package/{hstack → _deprecated/hstack}/hstack.js +0 -0
  53. /package/{hstack → _deprecated/hstack}/index.d.ts +0 -0
  54. /package/{hstack → _deprecated/hstack}/index.js +0 -0
  55. /package/{page-inset → _deprecated/page-inset}/index.d.ts +0 -0
  56. /package/{page-inset → _deprecated/page-inset}/index.js +0 -0
  57. /package/{page-inset → _deprecated/page-inset}/page-inset.d.ts +0 -0
  58. /package/{page-inset → _deprecated/page-inset}/page-inset.js +0 -0
  59. /package/{vstack → _deprecated/vstack}/index.d.ts +0 -0
  60. /package/{vstack → _deprecated/vstack}/index.js +0 -0
  61. /package/{vstack → _deprecated/vstack}/vstack.d.ts +0 -0
  62. /package/{vstack → _deprecated/vstack}/vstack.js +0 -0
@@ -6,8 +6,10 @@ 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";
12
+ import { radioGroupContext, } from "./radio-group-context.js";
11
13
  import { customEvent } from "@deepfuture/dui-core/event";
12
14
  export const valueChangeEvent = customEvent("value-change", {
13
15
  bubbles: true,
@@ -78,9 +80,9 @@ export class DuiRadioGroup extends LitElement {
78
80
  }
79
81
  this.dispatchEvent(valueChangeEvent({ value: val }));
80
82
  };
81
- #ctx_accessor_storage = this.#buildContext();
82
- get #ctx() { return this.#ctx_accessor_storage; }
83
- set #ctx(value) { this.#ctx_accessor_storage = value; }
83
+ #_ctx_accessor_storage = this.#buildContext();
84
+ get _ctx() { return this.#_ctx_accessor_storage; }
85
+ set _ctx(value) { this.#_ctx_accessor_storage = value; }
84
86
  #buildContext() {
85
87
  return {
86
88
  name: this.name,
@@ -96,10 +98,10 @@ export class DuiRadioGroup extends LitElement {
96
98
  if (this.value === undefined && this.defaultValue !== undefined) {
97
99
  this.#internalValue = this.defaultValue;
98
100
  }
99
- this.#ctx = this.#buildContext();
101
+ this._ctx = this.#buildContext();
100
102
  }
101
103
  willUpdate() {
102
- this.#ctx = this.#buildContext();
104
+ this._ctx = this.#buildContext();
103
105
  }
104
106
  render() {
105
107
  return html `
@@ -133,3 +135,7 @@ __decorate([
133
135
  __decorate([
134
136
  property({ type: Boolean, reflect: true })
135
137
  ], DuiRadioGroup.prototype, "required", null);
138
+ __decorate([
139
+ provide({ context: radioGroupContext }),
140
+ state()
141
+ ], DuiRadioGroup.prototype, "_ctx", null);
package/radio/radio.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 FieldContext } from "@deepfuture/dui-components/field";
3
4
  /**
4
5
  * `<dui-radio>` — A radio button input.
5
6
  *
@@ -21,6 +22,7 @@ export declare class DuiRadio extends LitElement {
21
22
  accessor disabled: boolean;
22
23
  /** Whether the radio is read-only. */
23
24
  accessor readOnly: boolean;
25
+ accessor _fieldCtx: FieldContext;
24
26
  connectedCallback(): void;
25
27
  disconnectedCallback(): void;
26
28
  render(): TemplateResult;
package/radio/radio.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 { radioGroupContext } from "./radio-group-context.js";
14
+ import { fieldContext } from "@deepfuture/dui-components/field";
13
15
  /** Structural styles only — layout CSS. */
14
16
  const styles = css `
15
17
  :host {
@@ -93,16 +95,16 @@ export class DuiRadio extends LitElement {
93
95
  context: radioGroupContext,
94
96
  subscribe: true,
95
97
  });
96
- #fieldCtx_accessor_storage;
97
- get #fieldCtx() { return this.#fieldCtx_accessor_storage; }
98
- set #fieldCtx(value) { this.#fieldCtx_accessor_storage = value; }
98
+ #_fieldCtx_accessor_storage;
99
+ get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
100
+ set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
99
101
  get #isChecked() {
100
102
  return this.#groupCtx.value?.value === this.value;
101
103
  }
102
104
  get #isDisabled() {
103
105
  return (this.disabled ||
104
106
  (this.#groupCtx.value?.disabled ?? false) ||
105
- (this.#fieldCtx?.disabled ?? false));
107
+ (this._fieldCtx?.disabled ?? false));
106
108
  }
107
109
  get #isReadOnly() {
108
110
  return this.readOnly || (this.#groupCtx.value?.readOnly ?? false);
@@ -111,7 +113,7 @@ export class DuiRadio extends LitElement {
111
113
  return this.#groupCtx.value?.required ?? false;
112
114
  }
113
115
  get #isInvalid() {
114
- return this.#fieldCtx?.invalid ?? false;
116
+ return this._fieldCtx?.invalid ?? false;
115
117
  }
116
118
  connectedCallback() {
117
119
  super.connectedCallback();
@@ -132,8 +134,8 @@ export class DuiRadio extends LitElement {
132
134
  const ctx = this.#groupCtx.value;
133
135
  if (ctx) {
134
136
  ctx.select(this.value);
135
- this.#fieldCtx?.markDirty();
136
- this.#fieldCtx?.markTouched();
137
+ this._fieldCtx?.markDirty();
138
+ this._fieldCtx?.markTouched();
137
139
  }
138
140
  };
139
141
  #handleKeyDown = (e) => {
@@ -148,7 +150,7 @@ export class DuiRadio extends LitElement {
148
150
  const isReadOnly = this.#isReadOnly;
149
151
  const isRequired = this.#isRequired;
150
152
  const isInvalid = this.#isInvalid;
151
- const controlId = this.#fieldCtx?.controlId ?? "";
153
+ const controlId = this._fieldCtx?.controlId ?? "";
152
154
  return html `
153
155
  <span
154
156
  part="root"
@@ -201,3 +203,7 @@ __decorate([
201
203
  __decorate([
202
204
  property({ type: Boolean, reflect: true, attribute: "read-only" })
203
205
  ], DuiRadio.prototype, "readOnly", null);
206
+ __decorate([
207
+ consume({ context: fieldContext, subscribe: true }),
208
+ state()
209
+ ], DuiRadio.prototype, "_fieldCtx", null);
@@ -1,5 +1,6 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/select */
2
2
  import { LitElement, type TemplateResult } from "lit";
3
+ import { type FieldContext } from "../field/field-context.js";
3
4
  export type SelectOption = {
4
5
  label: string;
5
6
  value: string;
@@ -32,5 +33,6 @@ export declare class DuiSelect extends LitElement {
32
33
  accessor disabled: boolean;
33
34
  /** Name for form submission. */
34
35
  accessor name: string;
36
+ accessor _fieldCtx: FieldContext;
35
37
  render(): TemplateResult;
36
38
  }
package/select/select.js CHANGED
@@ -6,11 +6,13 @@ 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 { repeat } from "lit/directives/repeat.js";
11
+ import { consume } from "@lit/context";
11
12
  import { base } from "@deepfuture/dui-core/base";
12
13
  import { customEvent } from "@deepfuture/dui-core/event";
13
14
  import { FloatingPortalController } from "@deepfuture/dui-core/floating-portal-controller";
15
+ import { fieldContext } from "../field/field-context.js";
14
16
  export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
15
17
  /** Structural styles only — layout CSS. */
16
18
  const hostStyles = css `
@@ -115,9 +117,9 @@ export class DuiSelect extends LitElement {
115
117
  /** Name for form submission. */
116
118
  get name() { return this.#name_accessor_storage; }
117
119
  set name(value) { this.#name_accessor_storage = value; }
118
- #ctx_accessor_storage;
119
- get #ctx() { return this.#ctx_accessor_storage; }
120
- set #ctx(value) { this.#ctx_accessor_storage = value; }
120
+ #_fieldCtx_accessor_storage;
121
+ get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
122
+ set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
121
123
  #highlightedIndex_accessor_storage = -1;
122
124
  get #highlightedIndex() { return this.#highlightedIndex_accessor_storage; }
123
125
  set #highlightedIndex(value) { this.#highlightedIndex_accessor_storage = value; }
@@ -131,7 +133,7 @@ export class DuiSelect extends LitElement {
131
133
  },
132
134
  onClose: () => {
133
135
  this.#highlightedIndex = -1;
134
- this.#ctx?.markTouched();
136
+ this._fieldCtx?.markTouched();
135
137
  },
136
138
  renderPopup: (portal) => {
137
139
  return html `
@@ -144,7 +146,7 @@ export class DuiSelect extends LitElement {
144
146
  class="Listbox"
145
147
  id="${this.#listboxId}"
146
148
  role="listbox"
147
- aria-labelledby="${this.#ctx?.labelId ?? ""}"
149
+ aria-labelledby="${this._fieldCtx?.labelId ?? ""}"
148
150
  @mousedown="${this.#onListMouseDown}"
149
151
  >
150
152
  ${repeat(this.options, (option) => option.value, this.#renderItem)}
@@ -155,10 +157,10 @@ export class DuiSelect extends LitElement {
155
157
  });
156
158
  // ---- Computed ----
157
159
  get #isDisabled() {
158
- return this.disabled || (this.#ctx?.disabled ?? false);
160
+ return this.disabled || (this._fieldCtx?.disabled ?? false);
159
161
  }
160
162
  get #isInvalid() {
161
- return this.#ctx?.invalid ?? false;
163
+ return this._fieldCtx?.invalid ?? false;
162
164
  }
163
165
  get #selectedOption() {
164
166
  return this.options.find((o) => o.value === this.value);
@@ -265,8 +267,8 @@ export class DuiSelect extends LitElement {
265
267
  // ---- Selection ----
266
268
  #selectOption(option) {
267
269
  this.value = option.value;
268
- this.#ctx?.markDirty();
269
- this.#ctx?.setFilled(this.value.length > 0);
270
+ this._fieldCtx?.markDirty();
271
+ this._fieldCtx?.setFilled(this.value.length > 0);
270
272
  this.dispatchEvent(valueChangeEvent({ value: option.value, option }));
271
273
  this.#popup.close();
272
274
  this.#focusTrigger();
@@ -325,15 +327,15 @@ export class DuiSelect extends LitElement {
325
327
  aria-activedescendant="${this.#highlightedIndex >= 0
326
328
  ? `${this.#listboxId}-option-${this.#highlightedIndex}`
327
329
  : nothing}"
328
- aria-labelledby="${this.#ctx?.labelId ?? ""}"
330
+ aria-labelledby="${this._fieldCtx?.labelId ?? ""}"
329
331
  aria-invalid="${this.#isInvalid}"
330
332
  ?data-disabled="${this.#isDisabled}"
331
333
  ?data-invalid="${this.#isInvalid}"
332
334
  ?data-open="${this.#popup.isOpen}"
333
335
  @click="${this.#onTriggerClick}"
334
336
  @keydown="${this.#onTriggerKeyDown}"
335
- @focus="${() => this.#ctx?.setFocused(true)}"
336
- @blur="${() => this.#ctx?.setFocused(false)}"
337
+ @focus="${() => this._fieldCtx?.setFocused(true)}"
338
+ @blur="${() => this._fieldCtx?.setFocused(false)}"
337
339
  >
338
340
  <span
339
341
  class="Value"
@@ -368,3 +370,7 @@ __decorate([
368
370
  __decorate([
369
371
  property({ type: String })
370
372
  ], DuiSelect.prototype, "name", null);
373
+ __decorate([
374
+ consume({ context: fieldContext, subscribe: true }),
375
+ state()
376
+ ], DuiSelect.prototype, "_fieldCtx", null);
@@ -1,5 +1,6 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/sidebar */
2
2
  import { LitElement, type TemplateResult } from "lit";
3
+ import { type SidebarContext } from "./sidebar-context.js";
3
4
  export type SidebarOpenChangeDetail = {
4
5
  open: boolean;
5
6
  };
@@ -27,6 +28,7 @@ export declare class DuiSidebarProvider extends LitElement {
27
28
  accessor variant: string;
28
29
  /** How the sidebar collapses. */
29
30
  accessor collapsible: "offcanvas" | "icon" | "none";
31
+ accessor _ctx: SidebarContext;
30
32
  connectedCallback(): void;
31
33
  disconnectedCallback(): void;
32
34
  willUpdate(): 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 { sidebarContext } from "./sidebar-context.js";
12
14
  export const openChangeEvent = customEvent("open-change", { bubbles: true, composed: true });
13
15
  const styles = css `
14
16
  :host {
@@ -95,9 +97,9 @@ export class DuiSidebarProvider extends LitElement {
95
97
  this.#toggleSidebar();
96
98
  }
97
99
  };
98
- #ctx_accessor_storage = this.#buildContext();
99
- get #ctx() { return this.#ctx_accessor_storage; }
100
- set #ctx(value) { this.#ctx_accessor_storage = value; }
100
+ #_ctx_accessor_storage = this.#buildContext();
101
+ get _ctx() { return this.#_ctx_accessor_storage; }
102
+ set _ctx(value) { this.#_ctx_accessor_storage = value; }
101
103
  #buildContext() {
102
104
  return {
103
105
  state: this.#isOpen ? "expanded" : "collapsed",
@@ -122,7 +124,7 @@ export class DuiSidebarProvider extends LitElement {
122
124
  this.#mediaQuery.addEventListener("change", this.#boundOnMediaChange);
123
125
  this.#boundOnKeyDown = this.#onKeyDown.bind(this);
124
126
  document.addEventListener("keydown", this.#boundOnKeyDown);
125
- this.#ctx = this.#buildContext();
127
+ this._ctx = this.#buildContext();
126
128
  }
127
129
  disconnectedCallback() {
128
130
  super.disconnectedCallback();
@@ -134,7 +136,7 @@ export class DuiSidebarProvider extends LitElement {
134
136
  }
135
137
  }
136
138
  willUpdate() {
137
- this.#ctx = this.#buildContext();
139
+ this._ctx = this.#buildContext();
138
140
  }
139
141
  render() {
140
142
  return html `<slot></slot>`;
@@ -155,3 +157,7 @@ __decorate([
155
157
  __decorate([
156
158
  property({ reflect: true })
157
159
  ], DuiSidebarProvider.prototype, "collapsible", null);
160
+ __decorate([
161
+ provide({ context: sidebarContext }),
162
+ state()
163
+ ], DuiSidebarProvider.prototype, "_ctx", null);
@@ -1,4 +1,5 @@
1
1
  import { LitElement, type TemplateResult } from "lit";
2
+ import { type FieldContext } from "../field/field-context.js";
2
3
  export declare const checkedChangeEvent: (detail: {
3
4
  checked: boolean;
4
5
  }) => CustomEvent<{
@@ -23,6 +24,7 @@ export declare class DuiSwitch extends LitElement {
23
24
  accessor name: string | undefined;
24
25
  accessor value: string;
25
26
  accessor uncheckedValue: string;
27
+ accessor _fieldCtx: FieldContext;
26
28
  connectedCallback(): void;
27
29
  disconnectedCallback(): void;
28
30
  render(): TemplateResult;
package/switch/switch.js CHANGED
@@ -5,9 +5,11 @@ 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 { base } from "@deepfuture/dui-core/base";
10
11
  import { customEvent } from "@deepfuture/dui-core/event";
12
+ import { fieldContext } from "../field/field-context.js";
11
13
  export const checkedChangeEvent = customEvent("checked-change", { bubbles: true, composed: true });
12
14
  /** Structural styles only — layout and behavioral CSS. */
13
15
  const styles = css `
@@ -89,17 +91,17 @@ export class DuiSwitch extends LitElement {
89
91
  #internalChecked_accessor_storage = false;
90
92
  get #internalChecked() { return this.#internalChecked_accessor_storage; }
91
93
  set #internalChecked(value) { this.#internalChecked_accessor_storage = value; }
92
- #fieldCtx_accessor_storage;
93
- get #fieldCtx() { return this.#fieldCtx_accessor_storage; }
94
- set #fieldCtx(value) { this.#fieldCtx_accessor_storage = value; }
94
+ #_fieldCtx_accessor_storage;
95
+ get _fieldCtx() { return this.#_fieldCtx_accessor_storage; }
96
+ set _fieldCtx(value) { this.#_fieldCtx_accessor_storage = value; }
95
97
  get #isChecked() {
96
98
  return this.checked ?? this.#internalChecked;
97
99
  }
98
100
  get #isDisabled() {
99
- return this.disabled || (this.#fieldCtx?.disabled ?? false);
101
+ return this.disabled || (this._fieldCtx?.disabled ?? false);
100
102
  }
101
103
  get #isInvalid() {
102
- return this.#fieldCtx?.invalid ?? false;
104
+ return this._fieldCtx?.invalid ?? false;
103
105
  }
104
106
  connectedCallback() {
105
107
  super.connectedCallback();
@@ -122,8 +124,8 @@ export class DuiSwitch extends LitElement {
122
124
  if (this.checked === undefined) {
123
125
  this.#internalChecked = newChecked;
124
126
  }
125
- this.#fieldCtx?.markDirty();
126
- this.#fieldCtx?.markTouched();
127
+ this._fieldCtx?.markDirty();
128
+ this._fieldCtx?.markTouched();
127
129
  this.dispatchEvent(checkedChangeEvent({ checked: newChecked }));
128
130
  };
129
131
  #handleKeyDown = (e) => {
@@ -136,7 +138,7 @@ export class DuiSwitch extends LitElement {
136
138
  const isChecked = this.#isChecked;
137
139
  const isDisabled = this.#isDisabled;
138
140
  const isInvalid = this.#isInvalid;
139
- const controlId = this.#fieldCtx?.controlId ?? "";
141
+ const controlId = this._fieldCtx?.controlId ?? "";
140
142
  return html `
141
143
  <span
142
144
  part="root"
@@ -197,3 +199,7 @@ __decorate([
197
199
  __decorate([
198
200
  property({ attribute: "unchecked-value" })
199
201
  ], DuiSwitch.prototype, "uncheckedValue", null);
202
+ __decorate([
203
+ consume({ context: fieldContext, subscribe: true }),
204
+ state()
205
+ ], DuiSwitch.prototype, "_fieldCtx", null);
@@ -1,4 +1,5 @@
1
1
  import { LitElement, type TemplateResult } from "lit";
2
+ import { type ToggleGroupContext } from "./toggle-group-context.js";
2
3
  export declare const valueChangeEvent: (detail: {
3
4
  value: string[];
4
5
  }) => CustomEvent<{
@@ -21,6 +22,7 @@ export declare class DuiToggleGroup extends LitElement {
21
22
  accessor orientation: "horizontal" | "vertical";
22
23
  accessor disabled: boolean;
23
24
  accessor loop: boolean;
25
+ accessor _ctx: ToggleGroupContext;
24
26
  connectedCallback(): void;
25
27
  willUpdate(): void;
26
28
  render(): TemplateResult;
@@ -5,9 +5,11 @@ 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";
10
11
  import { customEvent } from "@deepfuture/dui-core/event";
12
+ import { toggleGroupContext, } from "./toggle-group-context.js";
11
13
  export const valueChangeEvent = customEvent("value-change", { bubbles: true, composed: true });
12
14
  /** Structural styles only — layout CSS. */
13
15
  const styles = css `
@@ -75,9 +77,9 @@ export class DuiToggleGroup extends LitElement {
75
77
  }
76
78
  this.dispatchEvent(valueChangeEvent({ value: next }));
77
79
  };
78
- #ctx_accessor_storage = this.#buildContext();
79
- get #ctx() { return this.#ctx_accessor_storage; }
80
- set #ctx(value) { this.#ctx_accessor_storage = value; }
80
+ #_ctx_accessor_storage = this.#buildContext();
81
+ get _ctx() { return this.#_ctx_accessor_storage; }
82
+ set _ctx(value) { this.#_ctx_accessor_storage = value; }
81
83
  #buildContext() {
82
84
  return {
83
85
  value: this.#currentValue,
@@ -91,10 +93,10 @@ export class DuiToggleGroup extends LitElement {
91
93
  if (this.value === undefined && this.defaultValue.length > 0) {
92
94
  this.#internalValue = [...this.defaultValue];
93
95
  }
94
- this.#ctx = this.#buildContext();
96
+ this._ctx = this.#buildContext();
95
97
  }
96
98
  willUpdate() {
97
- this.#ctx = this.#buildContext();
99
+ this._ctx = this.#buildContext();
98
100
  }
99
101
  #onKeyDown = (e) => {
100
102
  const isHorizontal = this.orientation === "horizontal";
@@ -161,3 +163,7 @@ __decorate([
161
163
  __decorate([
162
164
  property({ type: Boolean })
163
165
  ], DuiToggleGroup.prototype, "loop", null);
166
+ __decorate([
167
+ provide({ context: toggleGroupContext }),
168
+ state()
169
+ ], DuiToggleGroup.prototype, "_ctx", null);
@@ -1,4 +1,5 @@
1
1
  import { LitElement, type TemplateResult } from "lit";
2
+ import { type ToggleGroupContext } from "./toggle-group-context.js";
2
3
  export declare const pressedChangeEvent: (detail: {
3
4
  pressed: boolean;
4
5
  }) => CustomEvent<{
@@ -21,6 +22,7 @@ export declare class DuiToggle extends LitElement {
21
22
  accessor defaultPressed: boolean;
22
23
  accessor disabled: boolean;
23
24
  accessor value: string | undefined;
25
+ accessor _groupCtx: ToggleGroupContext;
24
26
  connectedCallback(): void;
25
27
  render(): TemplateResult;
26
28
  }
package/toggle/toggle.js CHANGED
@@ -5,9 +5,11 @@ 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 { consume } from "@lit/context";
9
10
  import { base } from "@deepfuture/dui-core/base";
10
11
  import { customEvent } from "@deepfuture/dui-core/event";
12
+ import { toggleGroupContext, } from "./toggle-group-context.js";
11
13
  export const pressedChangeEvent = customEvent("pressed-change", { bubbles: true, composed: true });
12
14
  /** Structural styles only — layout CSS. */
13
15
  const styles = css `
@@ -63,17 +65,17 @@ export class DuiToggle extends LitElement {
63
65
  #internalPressed_accessor_storage = false;
64
66
  get #internalPressed() { return this.#internalPressed_accessor_storage; }
65
67
  set #internalPressed(value) { this.#internalPressed_accessor_storage = value; }
66
- #groupCtx_accessor_storage;
67
- get #groupCtx() { return this.#groupCtx_accessor_storage; }
68
- set #groupCtx(value) { this.#groupCtx_accessor_storage = value; }
68
+ #_groupCtx_accessor_storage;
69
+ get _groupCtx() { return this.#_groupCtx_accessor_storage; }
70
+ set _groupCtx(value) { this.#_groupCtx_accessor_storage = value; }
69
71
  get #isPressed() {
70
- if (this.#groupCtx && this.value !== undefined) {
71
- return this.#groupCtx.value.includes(this.value);
72
+ if (this._groupCtx && this.value !== undefined) {
73
+ return this._groupCtx.value.includes(this.value);
72
74
  }
73
75
  return this.pressed ?? this.#internalPressed;
74
76
  }
75
77
  get #isDisabled() {
76
- return this.disabled || (this.#groupCtx?.disabled ?? false);
78
+ return this.disabled || (this._groupCtx?.disabled ?? false);
77
79
  }
78
80
  connectedCallback() {
79
81
  super.connectedCallback();
@@ -84,8 +86,8 @@ export class DuiToggle extends LitElement {
84
86
  #handleClick = () => {
85
87
  if (this.#isDisabled)
86
88
  return;
87
- if (this.#groupCtx && this.value !== undefined) {
88
- this.#groupCtx.toggle(this.value);
89
+ if (this._groupCtx && this.value !== undefined) {
90
+ this._groupCtx.toggle(this.value);
89
91
  return;
90
92
  }
91
93
  const newPressed = !this.#isPressed;
@@ -125,3 +127,7 @@ __decorate([
125
127
  __decorate([
126
128
  property()
127
129
  ], DuiToggle.prototype, "value", null);
130
+ __decorate([
131
+ consume({ context: toggleGroupContext, subscribe: true }),
132
+ state()
133
+ ], DuiToggle.prototype, "_groupCtx", null);
@@ -1,6 +1,6 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/tooltip */
2
2
  import { LitElement, type PropertyValues, type TemplateResult } from "lit";
3
- import { type TooltipSide } from "./tooltip-context.js";
3
+ import { type TooltipContext, type TooltipSide } from "./tooltip-context.js";
4
4
  export type TooltipOpenChangeDetail = {
5
5
  open: boolean;
6
6
  };
@@ -29,6 +29,7 @@ export declare class DuiTooltip extends LitElement {
29
29
  accessor closeDelay: number;
30
30
  /** Disable the tooltip. */
31
31
  accessor disabled: boolean;
32
+ accessor _ctx: TooltipContext;
32
33
  connectedCallback(): void;
33
34
  disconnectedCallback(): void;
34
35
  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 { tooltipContext, } from "./tooltip-context.js";
12
14
  export const openChangeEvent = customEvent("open-change", { bubbles: true, composed: true });
13
15
  const hostStyles = css `
14
16
  :host {
@@ -62,7 +64,7 @@ export class DuiTooltip extends LitElement {
62
64
  #closeTimeout;
63
65
  #triggerId = `tooltip-trigger-${crypto.randomUUID().slice(0, 8)}`;
64
66
  #popupId = `tooltip-popup-${crypto.randomUUID().slice(0, 8)}`;
65
- #ctx_accessor_storage = {
67
+ #_ctx_accessor_storage = {
66
68
  open: false,
67
69
  triggerId: this.#triggerId,
68
70
  popupId: this.#popupId,
@@ -74,8 +76,8 @@ export class DuiTooltip extends LitElement {
74
76
  closeTooltip: () => this.#scheduleClose(),
75
77
  setTriggerEl: (el) => this.#setTriggerEl(el),
76
78
  };
77
- get #ctx() { return this.#ctx_accessor_storage; }
78
- set #ctx(value) { this.#ctx_accessor_storage = value; }
79
+ get _ctx() { return this.#_ctx_accessor_storage; }
80
+ set _ctx(value) { this.#_ctx_accessor_storage = value; }
79
81
  connectedCallback() {
80
82
  super.connectedCallback();
81
83
  if (this.defaultOpen && !this.disabled) {
@@ -92,10 +94,10 @@ export class DuiTooltip extends LitElement {
92
94
  changed.has("side") ||
93
95
  changed.has("sideOffset") ||
94
96
  changed.has("disabled") ||
95
- this.#ctx.open !== isOpen ||
96
- this.#ctx.triggerEl !== this.#triggerEl) {
97
- this.#ctx = {
98
- ...this.#ctx,
97
+ this._ctx.open !== isOpen ||
98
+ this._ctx.triggerEl !== this.#triggerEl) {
99
+ this._ctx = {
100
+ ...this._ctx,
99
101
  open: isOpen,
100
102
  side: this.side,
101
103
  sideOffset: this.sideOffset,
@@ -174,3 +176,7 @@ __decorate([
174
176
  __decorate([
175
177
  property({ type: Boolean, reflect: true })
176
178
  ], DuiTooltip.prototype, "disabled", null);
179
+ __decorate([
180
+ provide({ context: tooltipContext }),
181
+ state()
182
+ ], DuiTooltip.prototype, "_ctx", null);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes