@odx/foundation 1.0.0-beta.76 → 1.0.0-beta.78

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.
@@ -10,10 +10,10 @@ export declare abstract class CheckboxGroupFormControl extends FormControl<strin
10
10
  value: string[];
11
11
  constructor();
12
12
  toFormValue(): FormData;
13
- protected isIndeterminate(): boolean;
14
13
  protected isControl(element: unknown): element is CheckboxFormControl;
14
+ protected isControlChecked(control: CheckboxFormControl): boolean;
15
15
  protected updated(props: PropertyValues<this>): void;
16
- protected updateCheckboxControls(updateFn: (control: CheckboxFormControl, index: number) => void): void;
16
+ protected updateControls(updateFn: (control: CheckboxFormControl, index: number) => void): void;
17
17
  protected updateValue(value: string[], dispatchEvent?: boolean): void;
18
18
  }
19
19
  //# sourceMappingURL=checkbox-group-form-control.d.ts.map
@@ -6,7 +6,7 @@ export declare class NumberFormControl extends FormControl<number> {
6
6
  step: number;
7
7
  value: number;
8
8
  getValueText(): string;
9
- protected update(props: PropertyValues<this>): void;
9
+ protected willUpdate(props: PropertyValues<this>): void;
10
10
  toFormValue(): string;
11
11
  }
12
12
  //# sourceMappingURL=number-form-control.d.ts.map
@@ -15,7 +15,8 @@ export declare abstract class RadioGroupFormControl extends FormControl<string>
15
15
  getControls(): CheckboxFormControl[];
16
16
  connectedCallback(): void;
17
17
  protected isControl(element: unknown): element is CheckboxFormControl;
18
- protected update(changes: PropertyValues<this>): void;
19
- protected updateCheckboxControls(updateFn: (control: CheckboxFormControl, index: number) => void): Promise<void>;
18
+ protected isControlChecked(control: CheckboxFormControl): boolean;
19
+ protected willUpdate(changes: PropertyValues<this>): void;
20
+ protected updateControls(updateFn: (control: CheckboxFormControl, index: number) => void): void;
20
21
  }
21
22
  //# sourceMappingURL=radio-group-form-control.d.ts.map
package/dist/main.js CHANGED
@@ -3,7 +3,7 @@ import { unsafeCSS, LitElement, html, isServer, nothing } from 'lit';
3
3
  import { property, queryAssignedElements, query } from 'lit/decorators.js';
4
4
  import { u as uniqBy, r as round, R as RovingTabindexController, m as minBy, c as computePosition, a as autoUpdate, t as throttle, o as offset, s as shift, f as flip, b as size, d as arrow, h as hide } from './vendor.js';
5
5
 
6
- const customElementStyles = "@layer reset,base,variant,state;@layer reset{:is(*){box-sizing:border-box;scrollbar-width:thin}:not(:defined){display:none}:before,:after{box-sizing:border-box}[popover]{outline:none;border:none}img,picture,video,canvas,svg{display:block;margin:0;max-width:100%}input,button,textarea,select{margin:0;font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word;margin:0}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}}@layer base{odx-icon{transition:var(--odx-transition-default);transition-property:transform}[odxPreventTextOverflow]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}odx-list-item:has(:is([odx-button],odx-list-item::part(control)):not([disabled]):active){--_color-background-pressed: var(--_color-background-hover)}[odx-button]:has(odx-icon:only-child),[odx-button]:has(odx-avatar:only-child){--_min-inline-size: 0}odx-accordion[indicator-position=start]{odx-accordion-item::part(indicator){--rotate: -90deg;order:-1}odx-accordion-item[expanded]::part(indicator){--rotate: 0}}odx-input:has([slot=suffix])::part(base){padding-inline-end:var(--odx-size-px)}}@layer reset{:host{outline:none;border:none;border-color:transparent}}";
6
+ const customElementStyles = "@layer reset,base,variant,state;@layer reset{:is(*){box-sizing:border-box;scrollbar-width:thin}:not(:defined){display:none}:before,:after{box-sizing:border-box}[popover]{outline:none;border:none}img,picture,video,canvas,svg{display:block;margin:0;max-width:100%}input,button,textarea,select{margin:0;font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word;margin:0}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}}@layer base{odx-icon{transition:var(--odx-transition-default);transition-property:transform}[odxPreventTextOverflow]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}odx-list-item:has(:is(odx-button,odx-list-item::part(control)):not([disabled]):active){--_color-background-pressed: var(--_color-background-hover)}odx-button:has(odx-icon:only-child),odx-button:has(odx-avatar:only-child){--_min-inline-size: 0}odx-accordion[indicator-position=start]{odx-accordion-item::part(indicator){--rotate: -90deg;order:-1}odx-accordion-item[expanded]::part(indicator){--rotate: 0}}odx-input:has([slot=suffix])::part(base){padding-inline-end:var(--odx-size-px)}}@layer reset{:host{outline:none;border:none;border-color:transparent}}";
7
7
 
8
8
  function customElement(tagName, ...styles) {
9
9
  return (target) => {
@@ -291,10 +291,10 @@ const _CheckboxGroupFormControl = class _CheckboxGroupFormControl extends FormCo
291
291
  return this.elements.filter((element) => element instanceof _CheckboxGroupFormControl);
292
292
  }
293
293
  get controls() {
294
- return this.#findCheckboxControls((element) => !element.hasAttribute(GROUP_CONTROL_SELECTOR)).concat(this.childGroups.flatMap((group) => group.controls));
294
+ return this.#findControls((element) => !element.hasAttribute(GROUP_CONTROL_SELECTOR)).concat(this.childGroups.flatMap((group) => group.controls));
295
295
  }
296
296
  get groupControls() {
297
- return this.#findCheckboxControls((element) => element.hasAttribute(GROUP_CONTROL_SELECTOR));
297
+ return this.#findControls((element) => element.hasAttribute(GROUP_CONTROL_SELECTOR));
298
298
  }
299
299
  toFormValue() {
300
300
  const formData = new FormData();
@@ -303,42 +303,42 @@ const _CheckboxGroupFormControl = class _CheckboxGroupFormControl extends FormCo
303
303
  });
304
304
  return formData;
305
305
  }
306
- isIndeterminate() {
307
- return this.value.length > 0 && this.value.length < this.controls.length;
308
- }
309
306
  isControl(element) {
310
307
  return element instanceof CheckboxFormControl;
311
308
  }
309
+ isControlChecked(control) {
310
+ return this.value.includes(control.value);
311
+ }
312
312
  updated(props) {
313
313
  super.updated(props);
314
314
  if (props.has("value")) {
315
- this.updateCheckboxControls((control) => {
316
- control.checked = this.value.includes(control.value);
315
+ this.updateControls((control) => {
316
+ control.checked = this.isControlChecked(control);
317
317
  });
318
318
  for (const groupControl of this.groupControls) {
319
319
  if (groupControl instanceof CheckboxFormControl && "indeterminate" in groupControl) {
320
- groupControl.indeterminate = this.isIndeterminate();
320
+ groupControl.indeterminate = this.value.length > 0 && this.value.length < this.controls.length;
321
321
  groupControl.checked = this.controls.length > 0 && this.value.length === this.controls.length;
322
322
  }
323
323
  }
324
324
  }
325
325
  if (props.has("name")) {
326
- this.updateCheckboxControls((control) => {
326
+ this.updateControls((control) => {
327
327
  control.name = this.name;
328
328
  });
329
329
  }
330
330
  if (props.has("disabled")) {
331
- this.updateCheckboxControls((control) => {
331
+ this.updateControls((control) => {
332
332
  control.disabled = this.disabled;
333
333
  });
334
334
  }
335
335
  if (props.has("readonly")) {
336
- this.updateCheckboxControls((control) => {
336
+ this.updateControls((control) => {
337
337
  control.readonly = this.readonly;
338
338
  });
339
339
  }
340
340
  }
341
- updateCheckboxControls(updateFn) {
341
+ updateControls(updateFn) {
342
342
  this.controls.forEach(updateFn);
343
343
  }
344
344
  updateValue(value, dispatchEvent) {
@@ -347,7 +347,7 @@ const _CheckboxGroupFormControl = class _CheckboxGroupFormControl extends FormCo
347
347
  this.emit("change");
348
348
  }
349
349
  #handleChangeEvent;
350
- #findCheckboxControls(predicate) {
350
+ #findControls(predicate) {
351
351
  return this.elements.filter((element) => this.isControl(element) && predicate(element));
352
352
  }
353
353
  };
@@ -565,7 +565,7 @@ class ListboxFormControl extends FormControl {
565
565
  toggleOption(option, state) {
566
566
  if (!this.canSelect(option)) return;
567
567
  const newState = state ?? (this.required && !this.multiple || !option.selected);
568
- if (this.disabled) return;
568
+ if (this.disabled || this.readonly) return;
569
569
  option.selected = newState;
570
570
  this.updateValue(option);
571
571
  if (newState) {
@@ -667,7 +667,7 @@ class NumberFormControl extends FormControl {
667
667
  getValueText() {
668
668
  return this.ariaValueText?.trim() ?? "";
669
669
  }
670
- update(props) {
670
+ willUpdate(props) {
671
671
  if (props.has("value")) {
672
672
  this.internals.ariaValueNow = String(this.value);
673
673
  this.internals.ariaValueText = this.getValueText();
@@ -682,7 +682,7 @@ class NumberFormControl extends FormControl {
682
682
  this.step = Math.max(MIN_STEP_VALUE, this.step);
683
683
  }
684
684
  this.value = Math.max(this.min, Math.min(this.value, this.max));
685
- super.update(props);
685
+ super.willUpdate(props);
686
686
  }
687
687
  toFormValue() {
688
688
  return String(this.value);
@@ -713,9 +713,13 @@ class RadioGroupFormControl extends FormControl {
713
713
  this.addEventListener("change", this.#handleChange, { capture: true });
714
714
  new RovingTabindexController(this, {
715
715
  direction: "both",
716
+ hostDelegatesFocus: true,
716
717
  elements: () => this.getControls(),
717
718
  elementEnterAction: (element) => element.click(),
718
- focusInIndex: (elements) => elements.findIndex((element) => element.checked)
719
+ focusInIndex: (elements) => {
720
+ const selectedIndex = elements.findIndex((control) => this.isControlChecked(control));
721
+ return selectedIndex !== -1 ? selectedIndex : 0;
722
+ }
719
723
  });
720
724
  }
721
725
  }
@@ -735,25 +739,28 @@ class RadioGroupFormControl extends FormControl {
735
739
  isControl(element) {
736
740
  return element instanceof CheckboxFormControl;
737
741
  }
738
- update(changes) {
742
+ isControlChecked(control) {
743
+ return this.value === control.value;
744
+ }
745
+ willUpdate(changes) {
739
746
  super.update(changes);
740
747
  if (changes.has("value")) {
741
- this.updateCheckboxControls((control) => {
742
- control.checked = this.value.includes(control.value);
748
+ this.updateControls((control) => {
749
+ control.checked = this.isControlChecked(control);
743
750
  });
744
751
  }
745
752
  if (changes.has("name")) {
746
- this.updateCheckboxControls((control) => {
753
+ this.updateControls((control) => {
747
754
  control.name = this.name;
748
755
  });
749
756
  }
750
757
  if (changes.has("disabled")) {
751
- this.updateCheckboxControls((control) => {
758
+ this.updateControls((control) => {
752
759
  control.disabled = this.disabled;
753
760
  });
754
761
  }
755
762
  if (changes.has("readonly")) {
756
- this.updateCheckboxControls((control) => {
763
+ this.updateControls((control) => {
757
764
  control.readonly = this.readonly;
758
765
  });
759
766
  }
@@ -763,8 +770,7 @@ class RadioGroupFormControl extends FormControl {
763
770
  this.setValidity({ valueMissing: this.required && this.value.length === 0 }, firstControl);
764
771
  }
765
772
  }
766
- async updateCheckboxControls(updateFn) {
767
- await 0;
773
+ updateControls(updateFn) {
768
774
  this.getControls().forEach(updateFn);
769
775
  }
770
776
  #handleChange;
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- @layer reset,base,variant,state,theme;@layer reset{:is(*){box-sizing:border-box;scrollbar-width:thin}:not(:defined){display:none}:before,:after{box-sizing:border-box}[popover]{outline:none;border:none}img,picture,video,canvas,svg{display:block;margin:0;max-width:100%}input,button,textarea,select{margin:0;font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word;margin:0}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}}@layer base{odx-icon{transition:var(--odx-transition-default);transition-property:transform}[odxPreventTextOverflow]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}odx-list-item:has(:is([odx-button],odx-list-item::part(control)):not([disabled]):active){--_color-background-pressed: var(--_color-background-hover)}[odx-button]:has(odx-icon:only-child),[odx-button]:has(odx-avatar:only-child){--_min-inline-size: 0}odx-accordion[indicator-position=start]{odx-accordion-item::part(indicator){--rotate: -90deg;order:-1}odx-accordion-item[expanded]::part(indicator){--rotate: 0}}odx-input:has([slot=suffix])::part(base){padding-inline-end:var(--odx-size-px)}}@layer base{h1,h2,h3,h4,h5,h6{display:block;line-height:var(--_line-height);font-family:var(--odx-typography-font-family-brand);font-size:var(--_font-size);font-weight:var(--odx-typography-font-weight-semibold)}h6{--_font-size: var(--odx-breakpoint-font-size-heading-6);--_line-height: var(--odx-breakpoint-line-height-heading-6)}h5{--_font-size: var(--odx-breakpoint-font-size-heading-5);--_line-height: var(--odx-breakpoint-line-height-heading-5)}h4{--_font-size: var(--odx-breakpoint-font-size-heading-4);--_line-height: var(--odx-breakpoint-line-height-heading-4)}h3{--_font-size: var(--odx-breakpoint-font-size-heading-3);--_line-height: var(--odx-breakpoint-line-height-heading-3)}h2{--_font-size: var(--odx-breakpoint-font-size-heading-2);--_line-height: var(--odx-breakpoint-line-height-heading-2)}h1{--_font-size: var(--odx-breakpoint-font-size-heading-1);--_line-height: var(--odx-breakpoint-line-height-heading-1)}}:root{--odx-color-background-neutral-rest: var(--odx-palette-white);--odx-color-background-neutral-subtle: var(--odx-palette-coolgray-00);--odx-color-background-neutral-hover: var(--odx-palette-coolgray-30);--odx-color-background-neutral-pressed: var(--odx-palette-coolgray-40);--odx-color-stroke-control-rest: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-hover: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-pressed: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-readonly: var(--odx-color-stroke-primary-rest);--odx-color-background-control-selected: var(--odx-color-background-primary-rest);--odx-color-background-control-selected-hover: var(--odx-color-background-primary-hover);--odx-color-background-control-selected-pressed: var(--odx-color-background-primary-pressed);--odx-color-background-control-readonly: var(--odx-color-background-disabled-rest);--odx-experience-color-secondary-rest: var(--odx-palette-coolgray-30);--odx-experience-color-secondary-hover: var(--odx-palette-coolgray-40);--odx-experience-color-secondary-pressed: var(--odx-palette-coolgray-50)}@layer base{:root{--odx-transition-default: all var(--odx-motion-duration-default) var(--odx-motion-easing-default);--odx-transition-slow: all var(--odx-motion-duration-slow) var(--odx-motion-easing-default);--odx-transition-reduced: all var(--odx-motion-duration-fast) var(--odx-motion-easing-reduced);--odx-page-max-inline-size: 1600px;--odx-page-max-inline-size-narrow: 1200px;--odx-page-max-inline-size-wide: 2400px;scrollbar-color:var(--odx-color-background-brand) var(--odx-palette-transparent)}html,body{margin:0;padding:0}html{scroll-behavior:smooth}body{background-color:var(--odx-color-background-base);line-height:var(--odx-typography-line-height-base);color:var(--odx-color-foreground-rest);font-family:var(--odx-typography-font-family-base),"Noto Sans",Kanit,sans-serif;font-size:var(--odx-typography-font-size-base)}}
1
+ @layer reset,base,variant,state,theme;@layer reset{:is(*){box-sizing:border-box;scrollbar-width:thin}:not(:defined){display:none}:before,:after{box-sizing:border-box}[popover]{outline:none;border:none}img,picture,video,canvas,svg{display:block;margin:0;max-width:100%}input,button,textarea,select{margin:0;font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word;margin:0}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}}@layer base{odx-icon{transition:var(--odx-transition-default);transition-property:transform}[odxPreventTextOverflow]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}odx-list-item:has(:is(odx-button,odx-list-item::part(control)):not([disabled]):active){--_color-background-pressed: var(--_color-background-hover)}odx-button:has(odx-icon:only-child),odx-button:has(odx-avatar:only-child){--_min-inline-size: 0}odx-accordion[indicator-position=start]{odx-accordion-item::part(indicator){--rotate: -90deg;order:-1}odx-accordion-item[expanded]::part(indicator){--rotate: 0}}odx-input:has([slot=suffix])::part(base){padding-inline-end:var(--odx-size-px)}}@layer base{h1,h2,h3,h4,h5,h6{display:block;line-height:var(--_line-height);font-family:var(--odx-typography-font-family-brand);font-size:var(--_font-size);font-weight:var(--odx-typography-font-weight-semibold)}h6{--_font-size: var(--odx-breakpoint-font-size-heading-6);--_line-height: var(--odx-breakpoint-line-height-heading-6)}h5{--_font-size: var(--odx-breakpoint-font-size-heading-5);--_line-height: var(--odx-breakpoint-line-height-heading-5)}h4{--_font-size: var(--odx-breakpoint-font-size-heading-4);--_line-height: var(--odx-breakpoint-line-height-heading-4)}h3{--_font-size: var(--odx-breakpoint-font-size-heading-3);--_line-height: var(--odx-breakpoint-line-height-heading-3)}h2{--_font-size: var(--odx-breakpoint-font-size-heading-2);--_line-height: var(--odx-breakpoint-line-height-heading-2)}h1{--_font-size: var(--odx-breakpoint-font-size-heading-1);--_line-height: var(--odx-breakpoint-line-height-heading-1)}}:root{--odx-color-background-neutral-rest: var(--odx-palette-white);--odx-color-background-neutral-subtle: var(--odx-palette-coolgray-00);--odx-color-background-neutral-hover: var(--odx-palette-coolgray-30);--odx-color-background-neutral-pressed: var(--odx-palette-coolgray-40);--odx-color-stroke-control-rest: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-hover: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-pressed: var(--odx-color-stroke-primary-rest);--odx-color-stroke-control-readonly: var(--odx-color-stroke-primary-rest);--odx-color-background-control-selected: var(--odx-color-background-primary-rest);--odx-color-background-control-selected-hover: var(--odx-color-background-primary-hover);--odx-color-background-control-selected-pressed: var(--odx-color-background-primary-pressed);--odx-experience-color-secondary-rest: var(--odx-palette-coolgray-30);--odx-experience-color-secondary-hover: var(--odx-palette-coolgray-40);--odx-experience-color-secondary-pressed: var(--odx-palette-coolgray-50)}@layer base{:root{--odx-transition-default: all var(--odx-motion-duration-default) var(--odx-motion-easing-default);--odx-transition-slow: all var(--odx-motion-duration-slow) var(--odx-motion-easing-default);--odx-transition-reduced: all var(--odx-motion-duration-fast) var(--odx-motion-easing-reduced);--odx-page-max-inline-size: 1600px;--odx-page-max-inline-size-narrow: 1200px;--odx-page-max-inline-size-wide: 2400px;scrollbar-color:var(--odx-color-background-brand) var(--odx-palette-transparent)}html,body{margin:0;padding:0}html{scroll-behavior:smooth}body{background-color:var(--odx-color-background-base);line-height:var(--odx-typography-line-height-base);color:var(--odx-color-foreground-rest);font-family:var(--odx-typography-font-family-base),"Noto Sans",Kanit,sans-serif;font-size:var(--odx-typography-font-size-base)}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odx/foundation",
3
3
  "description": "A library of Web Component building blocks for ODX",
4
- "version": "1.0.0-beta.76",
4
+ "version": "1.0.0-beta.78",
5
5
  "author": "Drägerwerk AG & Co.KGaA",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "homepage": "https://odx.draeger.com",
@@ -19,7 +19,7 @@
19
19
  "lit": "3.3.0"
20
20
  },
21
21
  "peerDependencies": {
22
- "@odx/design-tokens": "^1.0.0",
22
+ "@odx/design-tokens": "^1.0.2",
23
23
  "@odx/icons": "^4.0.0-rc.29"
24
24
  },
25
25
  "devDependencies": {