Skip to content

Commit

Permalink
upd: add initial value prop to text input
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Nov 12, 2023
1 parent fb88799 commit 0135633
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/block-data/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export default {
event("onInput", t.string, "as-hided-socket"),
method("clear", [], "as-hided-socket"),
plugin("validator", "input-plugin"),
[
textProp("class"),
],
[textProp("class"), textProp("initial")],
),

appbar: component(
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/input.r.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import QuasiRuntime from "./plugin";
export interface InputProps {
class: string;
label: string;
initial: string;
disabled: boolean;
onInput: (newVal: string) => void;
validator: (value: string) => string | true;
}

export class InputModel {
value: string = "";
value: string;
clear() {
this.value = "";
}
Expand All @@ -19,6 +20,7 @@ export class InputModel {
@QuasiRuntime.outputComponent("input")
export class QInput extends OutputComponent {
main(_: ComponentContext<this>, model: InputModel, props: InputProps): void {
model.value ??= props.initial;
_.$cls(props.class);
if (_.mdInput(fromProp(model, "value"), props.label, props.disabled)) {
props.onInput?.(_.$ev);
Expand Down

0 comments on commit 0135633

Please sign in to comment.