Skip to content

Commit 2566adf

Browse files
thelukewaltongithub-actions
andauthored
chore: Update Input types to have better support for inputs (#199)
deps: Update deps --------- Co-authored-by: github-actions <github-actions@github.com>
1 parent 26c4844 commit 2566adf

12 files changed

Lines changed: 228 additions & 149 deletions

File tree

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"analyze": "cem analyze",
4545
"build-storybook:with-output-dir": "yarn run build && storybook build -o ",
4646
"build": "yarn prebuild && node scripts/build.js",
47-
"check": "npm-run-all analyze --parallel lint lint:lit-analyzer test docs",
47+
"check": "yarn analyze && yarn lint && yarn lint:lit-analyzer && yarn test && yarn docs",
4848
"create": "cd scripts && node makeWebComponentTemplate.js",
4949
"docs": "npx typedoc --logLevel Warn",
5050
"lint:lit-analyzer": "lit-analyzer src/components/**/* src/stories/**/* src/mixins/**/* src/test/**/* src/utils/**/* --quiet",
@@ -92,8 +92,8 @@
9292
"@types/jest": "^29.5.14",
9393
"@types/node": "^22.19.17",
9494
"@types/react": "^19.2.14",
95-
"@typescript-eslint/eslint-plugin": "^8.58.0",
96-
"@typescript-eslint/parser": "^8.58.0",
95+
"@typescript-eslint/eslint-plugin": "^8.58.1",
96+
"@typescript-eslint/parser": "^8.58.1",
9797
"@wc-toolkit/type-parser": "^1.2.0",
9898
"@web/test-runner": "^0.20.2",
9999
"@web/test-runner-commands": "^0.9.0",
@@ -113,15 +113,15 @@
113113
"eslint-plugin-tsdoc": "^0.4.0",
114114
"eslint-plugin-wc": "^2.2.1",
115115
"lit-analyzer": "^2.0.3",
116-
"prettier": "3.8.1",
117-
"react": "^19.2.4",
118-
"sinon": "^21.0.3",
116+
"prettier": "3.8.2",
117+
"react": "^19.2.5",
118+
"sinon": "^21.1.0",
119119
"storybook": "^8.6.18",
120120
"ts-lit-plugin": "^2.0.2",
121121
"ts-morph": "^25.0.1",
122122
"typedoc": "^0.28.18",
123123
"typescript": "^5.9.3",
124-
"typescript-eslint": "^8.58.0",
124+
"typescript-eslint": "^8.58.1",
125125
"vite": "^6.4.2"
126126
},
127127
"dependencies": {
@@ -131,7 +131,7 @@
131131
"@web/test-runner-junit-reporter": "^0.8.0",
132132
"@zebra-fed/zeta-icons": "1.9.3",
133133
"lit": "^3.3.2",
134-
"sinon": "^21.0.3"
134+
"sinon": "^21.1.0"
135135
},
136136
"overrides": {
137137
"@storybook/blocks": {

src/components/checkbox/checkbox.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { customElement, property } from "lit/decorators.js";
2-
import { type InputType } from "../../mixins/form-field.js";
32
import { BaseToggleFormElement } from "../base-toggle-form-element.js";
43
import styles from "./checkbox.styles.js";
54
import "../icon/icon.js";
65
import { LitElement } from "lit";
7-
8-
export type CheckboxType = Extract<InputType, "checkbox">;
6+
import type { ZetaInputType } from "../../mixins/form-field.js";
97

108
// TODO: When should change event fire? Does not seem to fire at all? Unless it needs to be in a form?
119

@@ -37,7 +35,7 @@ export class ZetaCheckbox extends BaseToggleFormElement {
3735
this.internals.role = "checkbox";
3836
}
3937

40-
override type: CheckboxType = "checkbox";
38+
override type: Extract<ZetaInputType, "checkbox"> = "checkbox";
4139

4240
override value = "on";
4341

src/components/dropdown/dropdown-menu/dropdown-menu-button.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { customElement, eventOptions, property, query, state } from "lit/decorat
22
import styles from "./dropdown-menu-button.styles.js";
33
import { html, LitElement } from "lit";
44
import { Contourable, Flavored, Size } from "../../../mixins/mixins.js";
5-
import { FormField, type InputType } from "../../../mixins/form-field.js";
5+
import { FormField, type ZetaInputType } from "../../../mixins/form-field.js";
66
import type { ZetaDroppable } from "../droppable.js";
77
import "../../button/button.js";
88
import "../../radio-button/radio-button.js";
@@ -14,6 +14,7 @@ import { ZetaDropdownEvent } from "../../../events.js";
1414
import type { ButtonFlavor } from "../../button/button.js";
1515

1616
export type ZetaDropdownItem = { label: string; icon?: ZetaIconName; checked?: boolean; disabled?: boolean; onClick?: () => void };
17+
export type ZetaDropdownType = Extract<ZetaInputType, "text-dropdown" | "checkbox-dropdown" | "radio-dropdown">;
1718

1819
//TODO check to see if this works with keyboard input
1920
// include check to see if input event is fired too
@@ -28,7 +29,7 @@ export type ZetaDropdownItem = { label: string; icon?: ZetaIconName; checked?: b
2829
* @property {boolean} open - Controls the state of the dropdown menu. Default is false.
2930
* @property {Array<ZetaDropdownItem>} items - Array of items to populate the dropdown. Includes label, icon (optional), checked (optional), disabled (optional), and onClick (optional) properties.
3031
* @property {ButtonFlavor} flavor - The flavor of the dropdown button. Default is "primary".
31-
* @property {InputType} type - The type of dropdown. Options are "text-dropdown", "checkbox-dropdown", and "radio-dropdown". Default is "text-dropdown".
32+
* @property {ZetaDropdownType} type - The type of dropdown. Options are "text-dropdown", "checkbox-dropdown", and "radio-dropdown". Default is "text-dropdown".
3233
* @property {string} name - The name of the dropdown menu button for form control. Default is "default".
3334
* @property {"left" | "right" | "bottom" | "top"} direction - The direction of the droppable relative to the anchor. Defaults to bottom if left undefined.
3435
*
@@ -74,7 +75,7 @@ export class ZetaDropdownMenuButton extends FormField(Contourable(Flavored(Size(
7475
* - "checkbox-dropdown" - A dropdown with checkboxes.
7576
* - "radio-dropdown" - A dropdown with radio buttons.
7677
*/
77-
@property({ type: String }) type: InputType = "text-dropdown";
78+
@property({ type: String }) type: ZetaDropdownType = "text-dropdown";
7879

7980
/** The name of the dropdown menu button for form control*/
8081
@property({ type: String }) name: string = "default";

src/components/radio-button/radio-button.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { customElement } from "lit/decorators.js";
2-
import { type InputType } from "../../mixins/form-field.js";
32

43
import { BaseToggleFormElement } from "../base-toggle-form-element.js";
54
import styles from "./radio-button.styles.js";
65
import { RadioButtonController } from "./radio-button-controller.js";
6+
import type { ZetaInputType } from "../../mixins/form-field.js";
77

88
/** Radio buttons are used for mutually exclusive choices, not for multiple choices. Only one radio button can be selected at a time. When a user chooses a new item, the previous choice is automatically deselected.
99
*
@@ -20,7 +20,8 @@ export class ZetaRadioButton extends BaseToggleFormElement {
2020
this.internals.role = "radio";
2121
this.addController(this.radioButtonController);
2222
}
23-
override type: InputType = "radio";
23+
override type: Extract<ZetaInputType, "radio"> = "radio";
24+
2425
override handleChange(event: Event): void {
2526
if (this.checked) super.handleChange(event); //Fires change Event only if checked.
2627
this.radioButtonController.handleChange();

src/components/search/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { html, LitElement, nothing } from "lit";
33
import styles from "./search.styles.js";
44
import { Interactive, Size } from "../../mixins/mixins.js";
55
import "../icon/icon.js";
6-
import { FormField, type InputType } from "../../mixins/form-field.js";
6+
import { FormField, type ZetaInputType } from "../../mixins/form-field.js";
77
import { ContourableThree } from "../../mixins/contourable-three.js";
88

99
//TODO onsubmit
@@ -25,7 +25,7 @@ import { ContourableThree } from "../../mixins/contourable-three.js";
2525
*/
2626
@customElement("zeta-search")
2727
export class ZetaSearch extends FormField(Size(ContourableThree(Interactive(LitElement)))) {
28-
type: InputType = "search";
28+
override type: Extract<ZetaInputType, "search"> = "search";
2929

3030
static override shadowRootOptions: ShadowRootInit = {
3131
...LitElement.shadowRootOptions,

src/components/select-input/select-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { customElement, property, query, queryAssignedNodes, state } from "lit/decorators.js";
22
import { html, LitElement, nothing, type PropertyValues, type TemplateResult } from "lit";
33

4-
import { FormField, type InputType } from "../../mixins/form-field.js";
4+
import { FormField, type ZetaInputType } from "../../mixins/form-field.js";
55
import { Size } from "../../mixins/size.js";
66
import { Contourable } from "../../mixins/contour.js";
77
import { Interactive } from "../../mixins/interactive.js";
@@ -45,7 +45,7 @@ export class ZetaSelectInput extends FormField(Size(Contourable(Interactive(LitE
4545
static styles = [styles, super.styles ?? []];
4646

4747
/** The type used in FormField mixin */
48-
@property({ type: String, attribute: false }) type: InputType = "select";
48+
override type: Extract<ZetaInputType, "select"> = "select";
4949

5050
/** Whether field is in error state. */
5151
@property({ type: Boolean, reflect: true }) error = false;

src/components/slider/range-selector/range-selector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
77
import { type ZetaRangeSliderEventDetail, ZetaRangeSliderEvent } from "../../../events.js";
88
import "../../text-input/text-input.js";
99
import "../slider.js";
10-
import { FormField, type InputType } from "../../../mixins/form-field.js";
10+
import { FormField, type ZetaInputType } from "../../../mixins/form-field.js";
1111

1212
export type ZetaRangeValues = { min: number; max: number };
1313

@@ -50,7 +50,7 @@ export class ZetaRangeSelector extends FormField(Contourable(LitElement)) {
5050

5151
id = "hidden-range-selector-input";
5252

53-
type: InputType = "range-selector";
53+
override type: Extract<ZetaInputType, "range-selector"> = "range-selector";
5454

5555
@query("input#hidden-range-selector-input") hiddenInput!: HTMLInputElement;
5656
@query(".lower-input") lowerInput!: HTMLInputElement;

src/components/slider/slider-input-field/slider-input-field.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styles from "./slider-input-field.styles.js";
55
import { ifDefined } from "lit/directives/if-defined.js";
66
import "../../text-input/text-input.js";
77
import "../slider.js";
8-
import { FormField, type InputType } from "../../../mixins/form-field.js";
8+
import { FormField, type ZetaInputType } from "../../../mixins/form-field.js";
99
import { ZetaSlider } from "../slider.js";
1010

1111
//TODO: min / max dont seem to change values of slider correctly.
@@ -46,7 +46,7 @@ export class ZetaSliderInputField extends FormField(Contourable(LitElement)) {
4646
/** Disables the input field. */
4747
@property({ type: Boolean, reflect: true }) disabled: boolean;
4848

49-
type: InputType = "slider";
49+
override type: Extract<ZetaInputType, "slider"> = "slider";
5050

5151
@query("input.contourable-target") input!: HTMLInputElement;
5252

src/components/stepper-input/stepper-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { customElement, property, query } from "lit/decorators.js";
2-
import { FormField, type InputType } from "../../mixins/form-field.js";
2+
import { FormField, type ZetaInputType } from "../../mixins/form-field.js";
33
import { html, LitElement, nothing } from "lit";
44
import styles from "./stepper-input.styles.js";
55
import { Contourable } from "../../mixins/mixins.js";
@@ -87,7 +87,7 @@ export class ZetaStepperInput extends FormField(Contourable(LitElement)) {
8787
*/
8888
@property() errorText?: string;
8989

90-
type: InputType = "stepper";
90+
override type: Extract<ZetaInputType, "stepper"> = "stepper";
9191

9292
handleChange(_event: Event) {
9393
this.value = this.validateValue(this.value);

src/components/switch/switch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styles from "./switch.styles.js";
44
import { type ZetaIconName } from "@zebra-fed/zeta-icons";
55
import { BaseToggleFormElement } from "../base-toggle-form-element.js";
66
import "../icon/icon.js";
7-
import type { CheckboxType } from "../checkbox/checkbox.js";
7+
import type { ZetaInputType } from "../../mixins/form-field.js";
88

99
//TODO we dont have focus styles for switch
1010
//TODO Having icons smaller than the thumb is difficult to position
@@ -41,7 +41,8 @@ export class ZetaSwitch extends BaseToggleFormElement {
4141
super();
4242
this.internals.role = "switch";
4343
}
44-
override type: CheckboxType = "checkbox";
44+
45+
override type: Extract<ZetaInputType, "checkbox"> = "checkbox";
4546

4647
//TODO aria-checked -> on=true, off|mixed=false?
4748
//TODO aria-readonly

0 commit comments

Comments
 (0)