Skip to content

Commit fea522d

Browse files
committed
adds maxLength and minLength to input
1 parent c2a042b commit fea522d

4 files changed

Lines changed: 21 additions & 23 deletions

File tree

package-lock.json

Lines changed: 11 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"devDependencies": {
2323
"@lit/react": "^1.0.0",
2424
"@types/node": "^20.0.0",
25-
"@types/react": "^18.0.0",
26-
"@types/react-dom": "^18.0.0",
25+
"@types/react": "^19.0.0",
26+
"@types/react-dom": "^19.0.0",
2727
"typescript": "^5.0.0",
2828
"vite": "^5.0.0",
2929
"vite-plugin-dts": "^3.0.0"
3030
},
3131
"peerDependencies": {
3232
"@lit/react": "^1.0.0",
33-
"react": "^18.0.0 || ^19.0.0",
34-
"react-dom": "^18.0.0 || ^19.0.0",
33+
"react": "^19.0.0",
34+
"react-dom": "^19.0.0",
3535
"lit": "^3.0.0"
3636
}
3737
}

src/components/input/input.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export class Input extends LitElement {
3030
@property({ type: String }) hint = "";
3131
@property({ type: Boolean, reflect: true }) invalid = false;
3232
@property({ type: Boolean, reflect: true }) required = false;
33+
@property({ type: Number }) minLength?: number;
34+
@property({ type: Number }) maxLength?: number;
3335

3436
// Event handler for input changes
3537
private handleInput(e: InputEvent) {
@@ -90,6 +92,8 @@ export class Input extends LitElement {
9092
?disabled=${this.disabled || this.loading}
9193
?readonly=${this.readonly}
9294
?required=${this.required}
95+
minlength=${this.minLength ?? ""}
96+
maxlength=${this.maxLength ?? ""}
9397
name=${this.name}
9498
class="input-field ${this.invalid ? "error" : ""}"
9599
@input=${this.handleInput}

src/react/input/input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export interface InputProps {
3333
label?: string;
3434
hint?: string;
3535
required?: boolean;
36+
minLength?: number;
37+
maxLength?: number;
3638
onInput?: (e: CustomEvent<InputChangeDetail>) => void;
3739
onChange?: (e: CustomEvent<InputChangeDetail>) => void;
3840
className?: string;

0 commit comments

Comments
 (0)