Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 5a7aca7

Browse files
authored
Merge pull request #547 from ckeditor/i/6110
Other: Rename `LabeledView` component to `LabeledFieldView`. See ckeditor/ckeditor5#6110. BREAKING CHANGE: `LabeledView` component was renamed to `LabeledFieldView`. Also, its instance of a labeled component's view is available through `LabeledFieldView#fieldView`. It replaced `LabeledView#view`.
2 parents e070119 + c5f7e82 commit 5a7aca7

File tree

7 files changed

+318
-318
lines changed

7 files changed

+318
-318
lines changed
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
*/
55

66
/**
7-
* @module ui/labeledview/labeledview
7+
* @module ui/labeledfield/labeledfieldview
88
*/
99

1010
import View from '../view';
1111
import uid from '@ckeditor/ckeditor5-utils/src/uid';
1212
import LabelView from '../label/labelview';
13-
import '../../theme/components/labeledview/labeledview.css';
13+
import '../../theme/components/labeledfield/labeledfieldview.css';
1414

1515
/**
16-
* The labeled view class. It can be used to enhance any view with the following features:
16+
* The labeled field view class. It can be used to enhance any view with the following features:
1717
*
1818
* * a label,
1919
* * (optional) an error message,
@@ -25,16 +25,16 @@ import '../../theme/components/labeledview/labeledview.css';
2525
* The constructor of this class requires a callback that returns a view to be labeled. The callback
2626
* is called with unique ids that allow binding of DOM properties:
2727
*
28-
* const labeledInputView = new LabeledView( locale, ( labeledView, viewUid, statusUid ) => {
29-
* const inputView = new InputTextView( labeledView.locale );
28+
* const labeledInputView = new LabeledFieldView( locale, ( labeledFieldView, viewUid, statusUid ) => {
29+
* const inputView = new InputTextView( labeledFieldView.locale );
3030
*
3131
* inputView.set( {
3232
* id: viewUid,
3333
* ariaDescribedById: statusUid
3434
* } );
3535
*
36-
* inputView.bind( 'isReadOnly' ).to( labeledView, 'isEnabled', value => !value );
37-
* inputView.bind( 'hasError' ).to( labeledView, 'errorText', value => !!value );
36+
* inputView.bind( 'isReadOnly' ).to( labeledFieldView, 'isEnabled', value => !value );
37+
* inputView.bind( 'hasError' ).to( labeledFieldView, 'errorText', value => !!value );
3838
*
3939
* return inputView;
4040
* } );
@@ -45,23 +45,23 @@ import '../../theme/components/labeledview/labeledview.css';
4545
*
4646
* document.body.append( labeledInputView.element );
4747
*
48-
* See {@link module:ui/labeledview/utils} to discover ready–to–use labeled input helpers for common
48+
* See {@link module:ui/labeledfield/utils} to discover ready–to–use labeled input helpers for common
4949
* UI components.
5050
*
5151
* @extends module:ui/view~View
5252
*/
53-
export default class LabeledView extends View {
53+
export default class LabeledFieldView extends View {
5454
/**
55-
* Creates an instance of the labeled view class using a provided creator function
55+
* Creates an instance of the labeled field view class using a provided creator function
5656
* that provides the view to be labeled.
5757
*
5858
* @param {module:utils/locale~Locale} locale The locale instance.
5959
* @param {Function} viewCreator A function that returns a {@link module:ui/view~View}
6060
* that will be labeled. The following arguments are passed to the creator function:
6161
*
62-
* * an instance of the `LabeledView` to allow binding observable properties,
63-
* * an UID string that connects the {@link #labelView label} and the labeled view in DOM,
64-
* * an UID string that connects the {@link #statusView status} and the labeled view in DOM.
62+
* * an instance of the `LabeledFieldView` to allow binding observable properties,
63+
* * an UID string that connects the {@link #labelView label} and the labeled field view in DOM,
64+
* * an UID string that connects the {@link #statusView status} and the labeled field view in DOM.
6565
*/
6666
constructor( locale, viewCreator ) {
6767
super( locale );
@@ -70,11 +70,11 @@ export default class LabeledView extends View {
7070
const statusUid = `ck-labeled-view-status-${ uid() }`;
7171

7272
/**
73-
* The view that gets labeled.
73+
* The field view that gets labeled.
7474
*
75-
* @member {module:ui/view~View} #view
75+
* @member {module:ui/view~View} #fieldView
7676
*/
77-
this.view = viewCreator( this, viewUid, statusUid );
77+
this.fieldView = viewCreator( this, viewUid, statusUid );
7878

7979
/**
8080
* The text of the label.
@@ -94,19 +94,19 @@ export default class LabeledView extends View {
9494

9595
/**
9696
* The validation error text. When set, it will be displayed
97-
* next to the {@link #view} as a typical validation error message.
97+
* next to the {@link #fieldView} as a typical validation error message.
9898
* Set it to `null` to hide the message.
9999
*
100100
* **Note:** Setting this property to anything but `null` will automatically
101-
* make the `hasError` of the {@link #view} `true`.
101+
* make the `hasError` of the {@link #fieldView} `true`.
102102
*
103103
* @observable
104104
* @member {String|null} #errorText
105105
*/
106106
this.set( 'errorText', null );
107107

108108
/**
109-
* The additional information text displayed next to the {@link #view} which can
109+
* The additional information text displayed next to the {@link #fieldView} which can
110110
* be used to inform the user about its purpose, provide help or hints.
111111
*
112112
* Set it to `null` to hide the message.
@@ -136,7 +136,7 @@ export default class LabeledView extends View {
136136
this.labelView = this._createLabelView( viewUid );
137137

138138
/**
139-
* The status view for the {@link #view}. It displays {@link #errorText} and
139+
* The status view for the {@link #fieldView}. It displays {@link #errorText} and
140140
* {@link #infoText}.
141141
*
142142
* @member {module:ui/view~View} #statusView
@@ -175,7 +175,7 @@ export default class LabeledView extends View {
175175
},
176176
children: [
177177
this.labelView,
178-
this.view,
178+
this.fieldView,
179179
this.statusView
180180
]
181181
} );
@@ -199,10 +199,10 @@ export default class LabeledView extends View {
199199

200200
/**
201201
* Creates the status view instance. It displays {@link #errorText} and {@link #infoText}
202-
* next to the {@link #view}. See {@link #_statusText}.
202+
* next to the {@link #fieldView}. See {@link #_statusText}.
203203
*
204204
* @private
205-
* @param {String} statusUid Unique id of the status, shared with the {@link #view view's}
205+
* @param {String} statusUid Unique id of the status, shared with the {@link #fieldView view's}
206206
* `aria-describedby` attribute.
207207
* @returns {module:ui/view~View}
208208
*/
@@ -233,9 +233,9 @@ export default class LabeledView extends View {
233233
}
234234

235235
/**
236-
* Focuses the {@link #view}.
236+
* Focuses the {@link #fieldView}.
237237
*/
238238
focus() {
239-
this.view.focus();
239+
this.fieldView.focus();
240240
}
241241
}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/**
7-
* @module ui/labeledview/utils
7+
* @module ui/labeledfield/utils
88
*/
99

1010
import InputTextView from '../inputtext/inputtextview';
@@ -14,7 +14,7 @@ import { createDropdown } from '../dropdown/utils';
1414
* A helper for creating labeled inputs.
1515
*
1616
* It creates an instance of a {@link module:ui/inputtext/inputtextview~InputTextView input text} that is
17-
* logically related to a {@link module:ui/labeledview/labeledview~LabeledView labeled view} in DOM.
17+
* logically related to a {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView labeled view} in DOM.
1818
*
1919
* The helper does the following:
2020
*
@@ -25,31 +25,31 @@ import { createDropdown } from '../dropdown/utils';
2525
*
2626
* Usage:
2727
*
28-
* const labeledInputView = new LabeledView( locale, createLabeledDropdown );
28+
* const labeledInputView = new LabeledFieldView( locale, createLabeledDropdown );
2929
* console.log( labeledInputView.view ); // An input instance.
3030
*
31-
* @param {module:ui/labeledview/labeledview~LabeledView} labeledView The instance of the labeled view.
31+
* @param {module:ui/labeledfield/labeledfieldview~LabeledFieldView} labeledFieldView The instance of the labeled field view.
3232
* @param {String} viewUid An UID string that allows DOM logical connection between the
33-
* {@link module:ui/labeledview/labeledview~LabeledView#labelView labeled view's label} and the input.
33+
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#labelView labeled view's label} and the input.
3434
* @param {String} statusUid An UID string that allows DOM logical connection between the
35-
* {@link module:ui/labeledview/labeledview~LabeledView#statusView labeled view's status} and the input.
35+
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view's status} and the input.
3636
* @returns {module:ui/inputtext/inputtextview~InputTextView} The input text view instance.
3737
*/
38-
export function createLabeledInputText( labeledView, viewUid, statusUid ) {
39-
const inputView = new InputTextView( labeledView.locale );
38+
export function createLabeledInputText( labeledFieldView, viewUid, statusUid ) {
39+
const inputView = new InputTextView( labeledFieldView.locale );
4040

4141
inputView.set( {
4242
id: viewUid,
4343
ariaDescribedById: statusUid
4444
} );
4545

46-
inputView.bind( 'isReadOnly' ).to( labeledView, 'isEnabled', value => !value );
47-
inputView.bind( 'hasError' ).to( labeledView, 'errorText', value => !!value );
46+
inputView.bind( 'isReadOnly' ).to( labeledFieldView, 'isEnabled', value => !value );
47+
inputView.bind( 'hasError' ).to( labeledFieldView, 'errorText', value => !!value );
4848

4949
inputView.on( 'input', () => {
5050
// UX: Make the error text disappear and disable the error indicator as the user
5151
// starts fixing the errors.
52-
labeledView.errorText = null;
52+
labeledFieldView.errorText = null;
5353
} );
5454

5555
return inputView;
@@ -59,7 +59,7 @@ export function createLabeledInputText( labeledView, viewUid, statusUid ) {
5959
* A helper for creating labeled dropdowns.
6060
*
6161
* It creates an instance of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown} that is
62-
* logically related to a {@link module:ui/labeledview/labeledview~LabeledView labeled view}.
62+
* logically related to a {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView labeled field view}.
6363
*
6464
* The helper does the following:
6565
*
@@ -68,25 +68,25 @@ export function createLabeledInputText( labeledView, viewUid, statusUid ) {
6868
*
6969
* Usage:
7070
*
71-
* const labeledInputView = new LabeledView( locale, createLabeledDropdown );
71+
* const labeledInputView = new LabeledFieldView( locale, createLabeledDropdown );
7272
* console.log( labeledInputView.view ); // A dropdown instance.
7373
*
74-
* @param {module:ui/labeledview/labeledview~LabeledView} labeledView The instance of the labeled view.
74+
* @param {module:ui/labeledfield/labeledfieldview~LabeledFieldView} labeledFieldView The instance of the labeled field view.
7575
* @param {String} viewUid An UID string that allows DOM logical connection between the
76-
* {@link module:ui/labeledview/labeledview~LabeledView#labelView labeled view label} and the dropdown.
76+
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#labelView labeled view label} and the dropdown.
7777
* @param {String} statusUid An UID string that allows DOM logical connection between the
78-
* {@link module:ui/labeledview/labeledview~LabeledView#statusView labeled view status} and the dropdown.
78+
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view status} and the dropdown.
7979
* @returns {module:ui/dropdown/dropdownview~DropdownView} The dropdown view instance.
8080
*/
81-
export function createLabeledDropdown( labeledView, viewUid, statusUid ) {
82-
const dropdownView = createDropdown( labeledView.locale );
81+
export function createLabeledDropdown( labeledFieldView, viewUid, statusUid ) {
82+
const dropdownView = createDropdown( labeledFieldView.locale );
8383

8484
dropdownView.set( {
8585
id: viewUid,
8686
ariaDescribedById: statusUid
8787
} );
8888

89-
dropdownView.bind( 'isEnabled' ).to( labeledView );
89+
dropdownView.bind( 'isEnabled' ).to( labeledFieldView );
9090

9191
return dropdownView;
9292
}

0 commit comments

Comments
 (0)