@odx/foundation 1.0.0-alpha.16 → 1.0.0-alpha.18

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.
@@ -14,6 +14,7 @@ export declare class OdxInputComponent extends OdxInputComponent_base {
14
14
  placeholder: string;
15
15
  type: HTMLInputElement['type'];
16
16
  variant?: InputVariant | null;
17
+ clear(): void;
17
18
  protected render(): TemplateResult;
18
19
  }
19
20
  export {};
@@ -17,6 +17,7 @@ export declare class OdxSearchBarComponent extends CustomElement {
17
17
  behavior: SearchBarBehavior;
18
18
  debounceTime?: number;
19
19
  placeholder: string;
20
+ get value(): string;
20
21
  search(value: string, options?: Partial<SearchOptions>): void;
21
22
  connectedCallback(): void;
22
23
  protected updated(props: PropertyValues<this>): void;
@@ -1,4 +1,4 @@
1
- import { WithAriaControls, CustomElement, toAriaBooleanAttribute, fromAriaBooleanAttribute, customElement, getKeyboardEventInfo, CanBeDisabled, requestUpdateOnAriaChange, optionalAttr, createIntersectionObserver, createMutationObserver, getElementFromEvent, WithLoadingState, getAssignedElements, optionalSlot, CheckboxGroupFormControl, CheckboxFormControl, toggleAttribute, SharedResizeObserver, getUniqueId, parseDate, searchTextContent, FormControl, waitForAnimations, FocusTrapController, OptionControl, toPx, RadioGroupFormControl, SelectFormControl, emptySlotFallbackFix, NumberControl } from '@odx/foundation';
1
+ import { WithAriaControls, CustomElement, toAriaBooleanAttribute, fromAriaBooleanAttribute, customElement, getKeyboardEventInfo, CanBeDisabled, requestUpdateOnAriaChange, optionalAttr, createIntersectionObserver, createMutationObserver, getElementFromEvent, WithLoadingState, getAssignedElements, optionalSlot, CheckboxGroupFormControl, CheckboxFormControl, toggleAttribute, SharedResizeObserver, getUniqueId, parseDate, searchTextContent, FormControl, forwardEvent, waitForAnimations, FocusTrapController, OptionControl, toPx, RadioGroupFormControl, SelectFormControl, emptySlotFallbackFix, NumberControl } from '@odx/foundation';
2
2
  import { html, isServer, unsafeCSS, nothing, css } from 'lit';
3
3
  import { property, queryAssignedElements, query, queryAll } from 'lit/decorators.js';
4
4
  import { signal, computed, SignalWatcher } from '@lit-labs/signals';
@@ -1876,29 +1876,29 @@ var __decorateClass$L = (decorators, target, key, kind) => {
1876
1876
  var __accessCheck$h = (obj, member, msg) => member.has(obj) || __typeError$h("Cannot " + msg);
1877
1877
  var __privateGet$e = (obj, member, getter) => (__accessCheck$h(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1878
1878
  var __privateAdd$h = (obj, member, value) => member.has(obj) ? __typeError$h("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1879
- var _handleInput, _clearInput;
1879
+ var _handleInput$1, _handleClear$1;
1880
1880
  let OdxInputComponent = class extends FormControl(CustomElement) {
1881
1881
  constructor() {
1882
1882
  super(...arguments);
1883
1883
  this.clearable = true;
1884
1884
  this.placeholder = "";
1885
1885
  this.type = "text";
1886
- __privateAdd$h(this, _handleInput, (event) => {
1886
+ __privateAdd$h(this, _handleInput$1, (event) => {
1887
1887
  this.value = event.target.value;
1888
- this.emit(event.type);
1889
1888
  });
1890
- __privateAdd$h(this, _clearInput, () => {
1891
- this.value = "";
1892
- this.emit("input");
1893
- if (this.type === "search") {
1894
- this.emit("search");
1895
- }
1889
+ __privateAdd$h(this, _handleClear$1, (event) => {
1890
+ event.stopPropagation();
1891
+ this.clear();
1896
1892
  });
1897
1893
  }
1894
+ clear() {
1895
+ this.value = "";
1896
+ this.emit("clear", { composed: false });
1897
+ }
1898
1898
  render() {
1899
1899
  const clearButton = when(
1900
1900
  this.clearable && this.value,
1901
- () => html`<odx-icon-button icon="core::error" @click=${__privateGet$e(this, _clearInput)} variant="ghost" tabindex="-1"></odx-icon-button>`
1901
+ () => html`<odx-icon-button icon="core::error" @click=${__privateGet$e(this, _handleClear$1)} variant="ghost" tabindex="-1"></odx-icon-button>`
1902
1902
  );
1903
1903
  return html`
1904
1904
  <div class="base">
@@ -1910,9 +1910,9 @@ let OdxInputComponent = class extends FormControl(CustomElement) {
1910
1910
  ?disabled=${this.disabled}
1911
1911
  ?readonly=${this.readonly}
1912
1912
  .value=${this.value}
1913
- @input=${__privateGet$e(this, _handleInput)}
1914
- @search=${__privateGet$e(this, _handleInput)}
1915
- @change=${__privateGet$e(this, _handleInput)}
1913
+ @change=${forwardEvent}
1914
+ @input=${__privateGet$e(this, _handleInput$1)}
1915
+ @search=${forwardEvent}
1916
1916
  />
1917
1917
  ${clearButton}
1918
1918
  <slot name="suffix"></slot>
@@ -1920,8 +1920,8 @@ let OdxInputComponent = class extends FormControl(CustomElement) {
1920
1920
  `;
1921
1921
  }
1922
1922
  };
1923
- _handleInput = new WeakMap();
1924
- _clearInput = new WeakMap();
1923
+ _handleInput$1 = new WeakMap();
1924
+ _handleClear$1 = new WeakMap();
1925
1925
  OdxInputComponent.formAssociated = true;
1926
1926
  __decorateClass$L([
1927
1927
  property({ type: Boolean })
@@ -2801,7 +2801,7 @@ const ProgressState = {
2801
2801
  ERROR: "error"
2802
2802
  };
2803
2803
 
2804
- const styles$q = ":host{--_indicator-space: var(--odx-size-12);--_indicator-size: calc(var(--odx-size-150) - var(--_indicator-space) * 2);--_indicator-color-background: var(--odx-color-selection-control-fill);--_indicator-color-stroke: var(--odx-color-selection-control-stroke);--_indicator-stroke-width: var(--odx-border-width-thin);--_label-color-foreground: var(--odx-color-foreground);cursor:pointer;display:inline-flex;margin:var(--odx-size-37) var(--odx-size-75);user-select:none;border-radius:var(--odx-border-radius-controls);padding:var(--_indicator-space)}:host,.indicator,.content{transition:var(--odx-transition-reduced)}.indicator{display:flex;place-content:center;place-items:center;block-size:var(--_indicator-size);inline-size:var(--_indicator-size);flex-shrink:0;border-radius:var(--odx-border-radius-circle);background-color:var(--_indicator-color-background);border:var(--odx-border-width-thin) solid var(--_indicator-color-stroke);border-color:var(--_indicator-color-stroke);border-width:var(--_indicator-stroke-width);transition-property:background-color,border-color,outline-color;outline:var(--odx-focus-ring-outline);outline-offset:var(--odx-focus-ring-offset)}.label{display:inline-block}.content{color:var(--_label-color-foreground);margin-block:calc(-1 * var(--_indicator-space));transition-property:color}:host(:empty) .content{display:none}:host(:not(:empty)) .indicator{margin-inline-end:var(--odx-size-75)}:host(:hover){--_indicator-color-background: var(--odx-color-selection-control-fill-hover);--_indicator-color-stroke: var(--odx-color-selection-control-stroke-hover)}:host(:focus-visible) .indicator{outline-color:var(--odx-focus-ring-color)}:host([aria-readonly=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-fill-readonly);--_indicator-color-foreground: var(--odx-color-selection-control-foreground-readonly);--_indicator-color-stroke: var(--odx-color-selection-control-stroke-readonly);cursor:default}:host([aria-disabled=\"true\"]){--_indicator-color-background: var(--odx-color-disabled-fill);--_indicator-color-foreground: var(--odx-color-disabled-foreground);--_indicator-color-stroke: var(--odx-color-disabled-stroke);--_label-color-foreground: var(--odx-color-disabled-foreground);cursor:not-allowed}:host([aria-checked=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-stroke-selected);--_indicator-color-foreground: var(--odx-color-foreground-light);--_indicator-color-stroke: var(--odx-color-selection-control-fill-selected);--_indicator-stroke-width: var(--odx-size-25)}:host([aria-checked=\"true\"]:not(:is([aria-readonly],[aria-disabled])):hover){--_indicator-color-stroke: var(--odx-color-selection-control-fill-selected-hover)}:host([aria-checked=\"true\"][aria-readonly=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-fill-selected);--_indicator-color-stroke: var(--odx-color-background-main);--_indicator-stroke-width: var(--odx-size-50);.indicator{outline-color:var(--odx-color-selection-control-fill-selected)}}:host([aria-checked=\"true\"][aria-disabled=\"true\"]){--_indicator-color-stroke: var(--odx-color-disabled-fill-selected);--_indicator-color-foreground: var(--odx-color-disabled-foreground-selected)}";
2804
+ const styles$q = "@layer base{:host{--_indicator-space: var(--odx-size-12);--_indicator-size: calc(var(--odx-size-150) - var(--_indicator-space) * 2);--_indicator-color-background: var(--odx-color-selection-control-fill);--_indicator-color-stroke: var(--odx-color-selection-control-stroke);--_indicator-stroke-width: var(--odx-border-width-thin);--_label-color-foreground: var(--odx-color-foreground);cursor:pointer;display:inline-flex;margin:var(--odx-size-37) var(--odx-size-75);user-select:none;border-radius:var(--odx-border-radius-controls);padding:var(--_indicator-space)}:host,.indicator,.content{transition:var(--odx-transition-reduced)}.indicator{display:flex;place-content:center;place-items:center;block-size:var(--_indicator-size);inline-size:var(--_indicator-size);flex-shrink:0;border-radius:var(--odx-border-radius-circle);background-color:var(--_indicator-color-background);border:var(--odx-border-width-thin) solid var(--_indicator-color-stroke);border-color:var(--_indicator-color-stroke);border-width:var(--_indicator-stroke-width);transition-property:background-color,border-color,outline-color,border-width,box-shadow;outline:var(--odx-focus-ring-outline);outline-offset:var(--odx-focus-ring-offset)}.label{display:inline-block}.content{color:var(--_label-color-foreground);margin-block:calc(-1 * var(--_indicator-space));transition-property:color}}@layer state{:host(:empty) .content{display:none}:host(:not(:empty)) .indicator{margin-inline-end:var(--odx-size-75)}:host(:hover){--_indicator-color-background: var(--odx-color-selection-control-fill-hover);--_indicator-color-stroke: var(--odx-color-selection-control-stroke-hover)}:host(:focus-visible) .indicator{outline-color:var(--odx-focus-ring-color)}:host([aria-readonly=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-fill-readonly);--_indicator-color-foreground: var(--odx-color-selection-control-foreground-readonly);--_indicator-color-stroke: var(--odx-color-selection-control-stroke-readonly);cursor:default}:host([aria-disabled=\"true\"]){--_indicator-color-background: var(--odx-color-disabled-fill);--_indicator-color-foreground: var(--odx-color-disabled-foreground);--_indicator-color-stroke: var(--odx-color-disabled-stroke);--_label-color-foreground: var(--odx-color-disabled-foreground);cursor:not-allowed}:host([aria-checked=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-stroke-selected);--_indicator-color-foreground: var(--odx-color-foreground-light);--_indicator-color-stroke: var(--odx-color-selection-control-fill-selected);--_indicator-stroke-width: var(--odx-size-25)}:host([aria-checked=\"true\"]:not(:is([aria-readonly],[aria-disabled])):hover){--_indicator-color-stroke: var(--odx-color-selection-control-fill-selected-hover)}:host([aria-checked=\"true\"][aria-readonly=\"true\"]){--_indicator-color-background: var(--odx-color-selection-control-fill-selected);--_indicator-stroke-width: var(--odx-size-px);.indicator{box-shadow:0 0 0 var(--odx-size-37) var(--odx-color-foreground-light) inset}}:host([aria-checked=\"true\"][aria-disabled=\"true\"]){--_indicator-color-stroke: var(--odx-color-disabled-fill-selected);--_indicator-color-background: var(--odx-color-disabled-fill-selected);--_indicator-stroke-width: var(--odx-size-px);.indicator{box-shadow:0 0 0 var(--odx-size-37) var(--odx-color-disabled-foreground-selected) inset}}}";
2805
2805
 
2806
2806
  var __defProp$r = Object.defineProperty;
2807
2807
  var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
@@ -2960,7 +2960,7 @@ var __privateGet$8 = (obj, member, getter) => (__accessCheck$a(obj, member, "rea
2960
2960
  var __privateAdd$a = (obj, member, value) => member.has(obj) ? __typeError$a("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2961
2961
  var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$a(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2962
2962
  var __privateMethod$7 = (obj, member, method) => (__accessCheck$a(obj, member, "access private method"), method);
2963
- var _value, _search, _OdxSearchBarComponent_instances, inputValue_get, _handleInputSearch, _handleInputChange, updateValue_fn;
2963
+ var _value, _search, _OdxSearchBarComponent_instances, inputValue_get, _handleSearch, _handleInput, _handleClear, updateValue_fn;
2964
2964
  let OdxSearchBarComponent = class extends CustomElement {
2965
2965
  constructor() {
2966
2966
  super(...arguments);
@@ -2969,17 +2969,24 @@ let OdxSearchBarComponent = class extends CustomElement {
2969
2969
  __privateAdd$a(this, _search, this.search.bind(this));
2970
2970
  this.behavior = SearchBarBehavior.SUBMIT;
2971
2971
  this.placeholder = "";
2972
- __privateAdd$a(this, _handleInputSearch, (event) => {
2972
+ __privateAdd$a(this, _handleSearch, (event) => {
2973
2973
  event.preventDefault();
2974
2974
  event.stopPropagation();
2975
2975
  this.search(__privateGet$8(this, _OdxSearchBarComponent_instances, inputValue_get));
2976
2976
  });
2977
- __privateAdd$a(this, _handleInputChange, (event) => {
2977
+ __privateAdd$a(this, _handleInput, (event) => {
2978
2978
  if (this.behavior !== SearchBarBehavior.INSTANT) return;
2979
2979
  event.preventDefault();
2980
2980
  event.stopPropagation();
2981
2981
  __privateGet$8(this, _search).call(this, __privateGet$8(this, _OdxSearchBarComponent_instances, inputValue_get));
2982
2982
  });
2983
+ __privateAdd$a(this, _handleClear, (event) => {
2984
+ event.stopPropagation();
2985
+ this.search("");
2986
+ });
2987
+ }
2988
+ get value() {
2989
+ return __privateGet$8(this, _value) ?? "";
2983
2990
  }
2984
2991
  search(value, options) {
2985
2992
  if (__privateGet$8(this, _value) === value && options?.forceUpdate !== true) return;
@@ -2998,7 +3005,16 @@ let OdxSearchBarComponent = class extends CustomElement {
2998
3005
  }
2999
3006
  render() {
3000
3007
  return html`
3001
- <odx-input class="input" spellcheck="false" autocomplete="off" placeholder=${this.placeholder} @search=${__privateGet$8(this, _handleInputSearch)} @input=${__privateGet$8(this, _handleInputChange)} type="search">
3008
+ <odx-input
3009
+ class="input"
3010
+ spellcheck="false"
3011
+ autocomplete="off"
3012
+ placeholder=${this.placeholder}
3013
+ type="search"
3014
+ @clear=${__privateGet$8(this, _handleClear)}
3015
+ @input=${__privateGet$8(this, _handleInput)}
3016
+ @search=${__privateGet$8(this, _handleSearch)}
3017
+ >
3002
3018
  <odx-icon name="core::search" slot="prefix"></odx-icon>
3003
3019
  </odx-input>
3004
3020
  `;
@@ -3010,8 +3026,9 @@ _OdxSearchBarComponent_instances = new WeakSet();
3010
3026
  inputValue_get = function() {
3011
3027
  return (this.inputElement.value ?? "").replace(/\s\s+/g, " ").trim();
3012
3028
  };
3013
- _handleInputSearch = new WeakMap();
3014
- _handleInputChange = new WeakMap();
3029
+ _handleSearch = new WeakMap();
3030
+ _handleInput = new WeakMap();
3031
+ _handleClear = new WeakMap();
3015
3032
  updateValue_fn = function(value, updateInput = false) {
3016
3033
  __privateSet$1(this, _value, value);
3017
3034
  if (!updateInput) return;
@@ -11,4 +11,5 @@ export declare function findClosestDocument(node: Node): ShadowRoot | Document |
11
11
  export declare function toPx(value?: string | number | null): string | null;
12
12
  export declare function getAssignedElements<T extends HTMLElement = HTMLElement>(host: HTMLElement, ...slots: string[]): T[];
13
13
  export declare function waitForAnimations(element?: Element | null, subtree?: boolean): Promise<Animation[]>;
14
+ export declare function forwardEvent(this: HTMLElement, event: Event): void;
14
15
  //# sourceMappingURL=dom.d.ts.map
package/dist/main.js CHANGED
@@ -48,6 +48,10 @@ async function waitForAnimations(element, subtree = false) {
48
48
  }
49
49
  return Promise.all(element.getAnimations({ subtree }).map((animation) => animation.finished)).catch(() => []);
50
50
  }
51
+ function forwardEvent(event) {
52
+ event.stopPropagation();
53
+ this.dispatchEvent(new CustomEvent(event.type, { bubbles: true, composed: true, cancelable: true }));
54
+ }
51
55
 
52
56
  function createOptions(defaultOptions) {
53
57
  return (options) => toMerged(defaultOptions, options ?? {});
@@ -1109,4 +1113,4 @@ class SharedResizeObserverInstance {
1109
1113
  }
1110
1114
  const SharedResizeObserver = new SharedResizeObserverInstance();
1111
1115
 
1112
- export { CanBeDisabled, CanBeReadonly, CanBeRequired, CanBeValidated, CheckboxFormControl, CheckboxGroupFormControl, CustomElement, FocusTrapController, FormControl, KeyboardKey, NumberControl, OptionControl, RadioGroupFormControl, SelectFormControl, SharedIntersectionObserver, SharedResizeObserver, WithAriaControls, WithLoadingState, clearUniqueIdCache, createIntersectionObserver, createMutationObserver, createOptions, createResizeObserver, customElement, dedupeMixin, effect, emptySlotFallbackFix, findClosestDocument, fromAriaBooleanAttribute, getAssignedElements, getElementFromEvent, getKeyboardEventInfo, getUniqueId, optionalAttr, optionalSlot, parseDate, requestUpdateOnAriaChange, searchTextContent, toAriaBooleanAttribute, toPx, toggleAttribute, waitForAnimations };
1116
+ export { CanBeDisabled, CanBeReadonly, CanBeRequired, CanBeValidated, CheckboxFormControl, CheckboxGroupFormControl, CustomElement, FocusTrapController, FormControl, KeyboardKey, NumberControl, OptionControl, RadioGroupFormControl, SelectFormControl, SharedIntersectionObserver, SharedResizeObserver, WithAriaControls, WithLoadingState, clearUniqueIdCache, createIntersectionObserver, createMutationObserver, createOptions, createResizeObserver, customElement, dedupeMixin, effect, emptySlotFallbackFix, findClosestDocument, forwardEvent, fromAriaBooleanAttribute, getAssignedElements, getElementFromEvent, getKeyboardEventInfo, getUniqueId, optionalAttr, optionalSlot, parseDate, requestUpdateOnAriaChange, searchTextContent, toAriaBooleanAttribute, toPx, toggleAttribute, waitForAnimations };
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-alpha.16",
4
+ "version": "1.0.0-alpha.18",
5
5
  "author": "Drägerwerk AG & Co.KGaA",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "homepage": "https://odx.draeger.com",