@itenthusiasm/custom-elements 1.0.1 → 1.0.3

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.
@@ -40,6 +40,7 @@ class CheckboxGroup extends HTMLElement {
40
40
  */
41
41
  attributeChangedCallback(_name, _oldValue, _newValue) {
42
42
  // NOTE: If we're only watching constraint-related attributes, then we only need to re-run validation here.
43
+ if (!this.fieldset) return; // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- Check needed here.
43
44
  this.#validateConstraints();
44
45
  }
45
46
 
@@ -132,11 +132,19 @@ class ComboboxOption extends HTMLElement {
132
132
  if (!this.#combobox) return;
133
133
  const combobox = this.#combobox;
134
134
 
135
- if (this.selected && combobox.value !== this.value) combobox.value = this.value;
136
- else if (!this.selected && combobox.value === this.value) {
137
- if (combobox.text.data && combobox.acceptsValue(combobox.text.data)) return;
138
- if (combobox.acceptsValue("")) return combobox.forceEmptyValue();
139
- combobox.formResetCallback();
135
+ // Selection
136
+ if (this.selected) {
137
+ if (combobox.value !== this.value) combobox.value = this.value;
138
+ else if (this.value === "" && combobox.text.data !== this.label) combobox.text.data = this.label;
139
+ }
140
+ // Deslection
141
+ else {
142
+ if (combobox.value !== this.value) return;
143
+
144
+ if (combobox.text.data && combobox.acceptsValue(combobox.text.data)) {
145
+ if (combobox.value !== combobox.text.data) combobox.value = combobox.text.data;
146
+ } else if (combobox.acceptsValue("")) combobox.forceEmptyValue();
147
+ else combobox.formResetCallback();
140
148
  }
141
149
  }
142
150
  }
@@ -30,8 +30,10 @@ declare module "preact" {
30
30
  }
31
31
 
32
32
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- This is required to support ComboboxField props
33
- interface SelectHTMLAttributes<T extends EventTarget = HTMLSelectElement>
34
- extends Omit<ComboboxFieldHTMLAttributes<T>, "onfilterchange"> {}
33
+ interface SelectHTMLAttributes<T extends EventTarget = HTMLSelectElement> extends Omit<
34
+ ComboboxFieldHTMLAttributes<T>,
35
+ "onfilterchange"
36
+ > {}
35
37
 
36
38
  interface ComboboxOptionHTMLAttributes<T extends EventTarget = ComboboxOption> extends HTMLAttributes<T> {
37
39
  defaultSelected?: Signalish<ComboboxOption["defaultSelected"] | undefined>;
@@ -22,8 +22,10 @@ declare module "react" {
22
22
  onfilterchangeCapture?: ReactEventHandler<T>;
23
23
  }
24
24
 
25
- interface SelectHTMLAttributes<T>
26
- extends Omit<ComboboxFieldHTMLAttributes<T>, "filter" | "onfilterchange" | "onfilterchangeCapture"> {
25
+ interface SelectHTMLAttributes<T> extends Omit<
26
+ ComboboxFieldHTMLAttributes<T>,
27
+ "filter" | "onfilterchange" | "onfilterchangeCapture"
28
+ > {
27
29
  filter?: "";
28
30
  }
29
31
 
@@ -37,8 +37,10 @@ declare module "solid-js" {
37
37
  }
38
38
 
39
39
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- This is required to support ComboboxField props
40
- interface SelectHTMLAttributes<T>
41
- extends Omit<ComboboxFieldHTMLAttributes<T>, "onFilterchange" | "onfilterchange" | "on:filterchange"> {}
40
+ interface SelectHTMLAttributes<T> extends Omit<
41
+ ComboboxFieldHTMLAttributes<T>,
42
+ "onFilterchange" | "onfilterchange" | "on:filterchange"
43
+ > {}
42
44
 
43
45
  interface ComboboxOptionHTMLAttributes<T> extends HTMLAttributes<T> {
44
46
  disabled?: ComboboxOption["disabled"];
@@ -31,8 +31,10 @@ declare module "svelte/elements" {
31
31
  }
32
32
 
33
33
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- This is required to support ComboboxField attrs
34
- interface HTMLSelectAttributes
35
- extends Omit<HTMLComboboxFieldAttributes<HTMLSelectElement>, "onfilterchange" | "on:filterchange"> {}
34
+ interface HTMLSelectAttributes extends Omit<
35
+ HTMLComboboxFieldAttributes<HTMLSelectElement>,
36
+ "onfilterchange" | "on:filterchange"
37
+ > {}
36
38
 
37
39
  interface HTMLComboboxOptionAttributes extends HTMLAttributes<ComboboxOption> {
38
40
  defaultSelected?: ComboboxOption["defaultSelected"] | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@itenthusiasm/custom-elements",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
7
7
  "description": "Robust, accessible, and progressively-enhanceable Web Components for common developer needs",
@@ -1,12 +1,13 @@
1
1
  // NOTE: For some reason, TS complains in the JS files if we export a `type`, so we're exporting `interface`s instead.
2
2
  /* eslint @typescript-eslint/no-empty-object-type: ["error", { "allowInterfaces": "with-single-extends" }] */
3
- export interface ExposedInternals
4
- extends Pick<
5
- ElementInternals,
6
- "labels" | "form" | "validity" | "validationMessage" | "willValidate" | "checkValidity" | "reportValidity"
7
- > {}
3
+ export interface ExposedInternals extends Pick<
4
+ ElementInternals,
5
+ "labels" | "form" | "validity" | "validationMessage" | "willValidate" | "checkValidity" | "reportValidity"
6
+ > {}
8
7
 
9
- export interface FieldPropertiesAndMethods
10
- extends Pick<HTMLInputElement, "name" | "required" | "disabled" | "setCustomValidity"> {}
8
+ export interface FieldPropertiesAndMethods extends Pick<
9
+ HTMLInputElement,
10
+ "name" | "required" | "disabled" | "setCustomValidity"
11
+ > {}
11
12
 
12
13
  export interface FieldMinMax extends Pick<HTMLInputElement, "min" | "max"> {}