Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
add: InputGroup.Input添加静态getValue和setValue方法
Browse files Browse the repository at this point in the history
  • Loading branch information
shenlq committed Nov 9, 2016
1 parent 296faf2 commit 7be3def
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-impression",
"version": "1.0.5",
"version": "1.0.6",
"author": "peter.shenlq",
"description": "An enterprise-class UI design language and React-based implementation.",
"main": "./lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,26 @@ export default class InputGroupInput extends PureComponent {
{...others}
type={type}
className={classnames('form-control', className)}
placeholder={placeholder} ref="main" />
placeholder={placeholder} ref={ref => (this.refMain = ref)} />
);
}
}


// getValue
InputGroupInput.getValue = ref => {
if(!ref) {
return undefined;
}

return ref.refMain.value;
};

// setValue
InputGroupInput.setValue = (ref, value) => {
if(!ref) {
return;
}

ref.refMain.value = value;
};
2 changes: 1 addition & 1 deletion site/src/styles/impression/modules/_input-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
z-index: 6;
}

&:last-child {
&:not(:first-child) {
margin-left: -1px;
}

Expand Down
21 changes: 20 additions & 1 deletion src/scripts/components/InputGroupInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,26 @@ export default class InputGroupInput extends PureComponent {
{...others}
type={type}
className={classnames('form-control', className)}
placeholder={placeholder} ref="main" />
placeholder={placeholder} ref={ref => (this.refMain = ref)} />
);
}
}


// getValue
InputGroupInput.getValue = ref => {
if(!ref) {
return undefined;
}

return ref.refMain.value;
};

// setValue
InputGroupInput.setValue = (ref, value) => {
if(!ref) {
return;
}

ref.refMain.value = value;
};

0 comments on commit 7be3def

Please sign in to comment.