Skip to content

Commit b385d20

Browse files
Feature/publish (#80)
* Element ref setting can get element undefined. * Publish fixes. * onChange calls updated. * Protected methods naming unified.
1 parent caa14f1 commit b385d20

File tree

22 files changed

+58
-46
lines changed

22 files changed

+58
-46
lines changed

common/config/rush/npm-shrinkwrap.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"generate": "rush generate",
66
"tools-build": "ts-node ./tools/rush-tools.ts run gulp-build -e simplr-mvdir",
77
"source-build": "ts-node ./tools/rush-tools.ts run build -e simplr-mvdir",
8-
"test": "ts-node ./tools/rush-tools.ts run test-tsc -e simplr-mvdir"
8+
"test": "ts-node ./tools/rush-tools.ts run test-tsc -e simplr-mvdir",
9+
"rush-tools": "ts-node ./tools/rush-tools.ts"
910
},
1011
"devDependencies": {
1112
"@microsoft/rush": "^3.0.9",

packages/simplr-forms-dom/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simplr-forms-dom",
3-
"version": "4.0.1-beta",
3+
"version": "4.0.1-beta.2",
44
"description": "DOM components for simplr-forms.",
55
"repository": "SimplrJS/simplr-forms",
66
"homepage": "https://github.com/SimplrJS/simplr-forms",
@@ -60,7 +60,7 @@
6060
"prop-types": "^15.5.10",
6161
"react": "^15.6.1",
6262
"react-dom": "^15.6.1",
63-
"simplr-forms": "^4.0.1-beta",
63+
"simplr-forms": "^4.0.1-beta.2",
6464
"tslib": "^1.7.1",
6565
"typed-immutable-record": "^0.0.6"
6666
},

packages/simplr-forms-dom/src/abstractions/base-dom-field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export abstract class BaseDomField<TProps extends DomFieldProps, TState extends
6767
return restProps;
6868
}
6969

70-
protected SetElementRef = (element: TUnderlyingElement): void => {
70+
protected SetElementRef = (element: TUnderlyingElement | undefined): void => {
7171
this.Element = element;
7272
}
7373

packages/simplr-forms-dom/src/components/checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ export class CheckBox extends BaseDomField<CheckBoxProps, BaseDomFieldState, HTM
4040

4141
if (this.props.onChange != null) {
4242
event.persist();
43-
this.props.onChange(event, newValue, this.FieldId, this.FormId);
43+
this.props.onChange(event, newValue, this.FieldId, this.FormStore);
4444
}
4545

4646
const formStoreState = this.FormStore.GetState();
4747
const formProps = formStoreState.Form.Props as FormProps;
4848
if (formProps.onChange != null) {
4949
event.persist();
50-
formProps.onChange(event, newValue, this.FieldId, this.FormId);
50+
formProps.onChange(event, newValue, this.FieldId, this.FormStore);
5151
}
5252
}
5353

packages/simplr-forms-dom/src/components/email.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export class Email extends BaseDomField<EmailProps, BaseDomFieldState, HTMLInput
3939

4040
if (this.props.onChange != null) {
4141
event.persist();
42-
this.props.onChange(event, newValue, this.FieldId, this.FormId);
42+
this.props.onChange(event, newValue, this.FieldId, this.FormStore);
4343
}
4444

4545
const formStoreState = this.FormStore.GetState();
4646
const formProps = formStoreState.Form.Props as FormProps;
4747
if (formProps.onChange != null) {
4848
event.persist();
49-
formProps.onChange(event, newValue, this.FieldId, this.FormId);
49+
formProps.onChange(event, newValue, this.FieldId, this.FormStore);
5050
}
5151
}
5252

packages/simplr-forms-dom/src/components/fields-array.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ interface Dictionary {
1616
}
1717

1818
export class FieldsArray extends BaseFieldsArray<FieldsArrayProps, FieldsArrayState> {
19-
public Element: HTMLDivElement;
19+
public Element: HTMLDivElement | undefined;
2020

21-
private setElementRef = (element: HTMLDivElement): void => {
21+
protected SetElementRef = (element: HTMLDivElement | undefined): void => {
2222
this.Element = element;
2323
}
2424

@@ -34,7 +34,7 @@ export class FieldsArray extends BaseFieldsArray<FieldsArrayProps, FieldsArraySt
3434

3535
render(): JSX.Element | null {
3636
return <div
37-
ref={this.setElementRef}
37+
ref={this.SetElementRef}
3838
{...this.GetHTMLProps(this.props) }
3939
>
4040
{this.props.children}

packages/simplr-forms-dom/src/components/fields-group.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ interface Dictionary {
1616
}
1717

1818
export class FieldsGroup extends BaseFieldsGroup<FieldsGroupProps, FieldsGroupState> {
19-
public Element: HTMLDivElement;
19+
public Element: HTMLDivElement | undefined;
2020

21-
private setElementRef = (element: HTMLDivElement): void => {
21+
protected SetElementRef = (element: HTMLDivElement | undefined): void => {
2222
this.Element = element;
2323
}
2424

@@ -33,7 +33,7 @@ export class FieldsGroup extends BaseFieldsGroup<FieldsGroupProps, FieldsGroupSt
3333

3434
render(): JSX.Element | null {
3535
return <div
36-
ref={this.setElementRef}
36+
ref={this.SetElementRef}
3737
{...this.GetHTMLProps(this.props) }
3838
>
3939
{this.props.children}

packages/simplr-forms-dom/src/components/form.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { BaseForm } from "simplr-forms";
44
import { FormProps } from "../contracts/form";
55

66
export class Form extends BaseForm<FormProps, {}> {
7-
public Element: HTMLFormElement;
7+
public Element: HTMLFormElement | undefined;
88

9-
protected SetElementRef = (element: HTMLFormElement) => {
9+
protected SetElementRef = (element: HTMLFormElement | undefined) => {
1010
this.Element = element;
11-
this.FormStore.SetFormSubmitCallback(() => {
12-
element.dispatchEvent(new Event("submit"));
13-
});
11+
if (this.FormStore != null && element != null) {
12+
this.FormStore.SetFormSubmitCallback(() => {
13+
element.dispatchEvent(new Event("submit"));
14+
});
15+
}
1416
}
1517

1618
static defaultProps: FormProps = {

packages/simplr-forms-dom/src/components/number.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export class Number extends BaseDomField<NumberProps, BaseDomFieldState> {
4444

4545
if (this.props.onChange != null) {
4646
event.persist();
47-
this.props.onChange(event, newValue, this.FieldId, this.FormId);
47+
this.props.onChange(event, newValue, this.FieldId, this.FormStore);
4848
}
4949

5050
const formStoreState = this.FormStore.GetState();
5151
const formProps = formStoreState.Form.Props as FormProps;
5252
if (formProps.onChange != null) {
5353
event.persist();
54-
formProps.onChange(event, newValue, this.FieldId, this.FormId);
54+
formProps.onChange(event, newValue, this.FieldId, this.FormStore);
5555
}
5656
}
5757

0 commit comments

Comments
 (0)