Skip to content

Commit ae41711

Browse files
committed
fix: rename maxLength to counterMaxLength
this allows to use both counterMaxLength and N maxLength
1 parent 78b2e33 commit ae41711

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

src/core/textbase/cssproperties.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export const errorProperty = new CssProperty<Style, string>({
2424
cssName: 'error'
2525
});
2626
errorProperty.register(Style);
27-
export const maxLengthProperty = new CssProperty<Style, number>({
28-
name: 'maxLength',
29-
cssName: 'max-length',
27+
export const counterMaxLengthProperty = new CssProperty<Style, number>({
28+
name: 'counterMaxLength',
29+
cssName: 'counter-max-length',
3030
valueConverter: v => parseFloat(v)
3131
});
32-
maxLengthProperty.register(Style);
32+
counterMaxLengthProperty.register(Style);
3333
export const floatingProperty = new CssProperty<Style, boolean>({
3434
name: 'floating',
3535
cssName: 'floating',

src/textfield/textfield.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getLayout, stateSets } from '@nativescript-community/ui-material-core/android/utils';
22
import {
3+
counterMaxLengthProperty,
34
digitsProperty,
45
errorColorProperty,
56
errorProperty,
@@ -8,7 +9,6 @@ import {
89
floatingProperty,
910
helperColorProperty,
1011
helperProperty,
11-
maxLengthProperty,
1212
strokeColorProperty,
1313
strokeDisabledColorProperty,
1414
strokeInactiveColorProperty
@@ -180,7 +180,7 @@ export class TextField extends TextFieldBase {
180180
this.layoutView.setErrorEnabled(!!value);
181181
}
182182

183-
[maxLengthProperty.setNative](value: number) {
183+
[counterMaxLengthProperty.setNative](value: number) {
184184
this.layoutView.setCounterEnabled(value > 0);
185185
this.layoutView.setCounterMaxLength(value);
186186
}

src/textfield/textfield.common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export abstract class TextFieldBase extends NTextField {
1212

1313
@cssProperty helper: string;
1414
@cssProperty helperColor: Color;
15-
@cssProperty maxLength: number;
15+
@cssProperty counterMaxLength: number;
1616
@cssProperty errorColor: Color;
1717
@cssProperty floating: boolean;
1818
@cssProperty placeholderColor: Color;

src/textfield/textfield.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class TextField extends NTextField {
1313

1414
helper: string;
1515
helperColor: Color;
16-
maxLength: number;
16+
counterMaxLength: number;
1717
errorColor: Color;
1818
floating: boolean;
1919
placeholderColor: Color;

src/textfield/textfield.ios.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { themer } from '@nativescript-community/ui-material-core';
22
import {
33
buttonColorProperty,
4+
counterMaxLengthProperty,
45
digitsProperty,
56
errorColorProperty,
67
errorProperty,
@@ -9,7 +10,6 @@ import {
910
floatingProperty,
1011
helperColorProperty,
1112
helperProperty,
12-
maxLengthProperty,
1313
strokeColorProperty,
1414
strokeDisabledColorProperty,
1515
strokeInactiveColorProperty,
@@ -151,7 +151,7 @@ export class TextField extends TextFieldBase {
151151
if (range.length > 0) {
152152
const delta = replacementString.length - range.length;
153153
if (delta > 0) {
154-
if (textField.text.length + delta > this.maxLength) {
154+
if (textField.text.length + delta > this.counterMaxLength) {
155155
return false;
156156
}
157157
}
@@ -321,7 +321,7 @@ export class TextField extends TextFieldBase {
321321
const color: UIColor = temp.ios;
322322
this._controller.leadingUnderlineLabelTextColor = color;
323323
}
324-
[maxLengthProperty.setNative](value: number) {
324+
[counterMaxLengthProperty.setNative](value: number) {
325325
this._controller.characterCountMax = value;
326326
}
327327
[floatingProperty.setNative](value: boolean) {

src/textview/textview.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
2+
counterMaxLengthProperty,
23
errorColorProperty,
34
errorProperty,
45
floatingColorProperty,
56
floatingInactiveColorProperty,
67
floatingProperty,
78
helperColorProperty,
89
helperProperty,
9-
maxLengthProperty,
1010
strokeColorProperty,
1111
strokeInactiveColorProperty,
1212
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
@@ -187,7 +187,7 @@ export class TextView extends TextViewBase {
187187
this.layoutView.setErrorEnabled(!!value);
188188
}
189189

190-
[maxLengthProperty.setNative](value: number) {
190+
[counterMaxLengthProperty.setNative](value: number) {
191191
this.layoutView.setCounterEnabled(value > 0);
192192
this.layoutView.setCounterMaxLength(value);
193193
}

src/textview/textview.common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export abstract class TextViewBase extends NSTextView {
88

99
@cssProperty helper: string;
1010
@cssProperty helperColor: Color;
11-
@cssProperty maxLength: number;
11+
@cssProperty counterMaxLength: number;
1212
@cssProperty errorColor: Color;
1313
@cssProperty floating: boolean;
1414
@cssProperty placeholderColor: Color;

src/textview/textview.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class TextView extends EditableTextBase {
1313

1414
helper: string;
1515
helperColor: Color;
16-
maxLength: number;
16+
counterMaxLength: number;
1717
errorColor: Color;
1818
floating: boolean;
1919
placeholderColor: Color;

src/textview/textview.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { themer } from '@nativescript-community/ui-material-core';
22
import {
33
buttonColorProperty,
4+
counterMaxLengthProperty,
45
errorColorProperty,
56
errorProperty,
67
floatingColorProperty,
78
floatingInactiveColorProperty,
89
floatingProperty,
910
helperColorProperty,
1011
helperProperty,
11-
maxLengthProperty,
1212
strokeColorProperty,
1313
strokeInactiveColorProperty,
1414
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
@@ -318,7 +318,7 @@ export class TextView extends TextViewBase {
318318
const color: UIColor = temp.ios;
319319
this._controller.leadingUnderlineLabelTextColor = color;
320320
}
321-
[maxLengthProperty.setNative](value: number) {
321+
[counterMaxLengthProperty.setNative](value: number) {
322322
this._controller.characterCountMax = value;
323323
}
324324
[floatingProperty.setNative](value: boolean) {

0 commit comments

Comments
 (0)