@syncfusion/ej2-inplace-editor 31.2.2 → 31.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.eslintrc.json +2 -0
  2. package/README.md +36 -23
  3. package/dist/ej2-inplace-editor.min.js +2 -2
  4. package/dist/ej2-inplace-editor.umd.min.js +1 -1
  5. package/dist/global/ej2-inplace-editor.min.js +1 -1
  6. package/dist/global/index.d.ts +1 -1
  7. package/package.json +23 -59
  8. package/styles/bootstrap-dark-lite.css +0 -4
  9. package/styles/bootstrap-dark.css +0 -4
  10. package/styles/bootstrap-lite.css +3 -63
  11. package/styles/bootstrap.css +3 -63
  12. package/styles/bootstrap4-lite.css +11 -87
  13. package/styles/bootstrap4.css +11 -87
  14. package/styles/fluent2-lite.css +2 -1
  15. package/styles/fluent2.css +2 -1
  16. package/styles/inplace-editor/bootstrap-dark.css +0 -4
  17. package/styles/inplace-editor/bootstrap.css +3 -63
  18. package/styles/inplace-editor/bootstrap4.css +11 -87
  19. package/styles/inplace-editor/fluent2.css +2 -1
  20. package/styles/inplace-editor/material.css +9 -0
  21. package/styles/inplace-editor/tailwind3.css +1 -0
  22. package/styles/material-lite.css +9 -0
  23. package/styles/material.css +9 -0
  24. package/styles/tailwind3-lite.css +1 -0
  25. package/styles/tailwind3.css +1 -0
  26. package/dist/ts/index.d.ts +0 -4
  27. package/dist/ts/index.ts +0 -4
  28. package/dist/ts/inplace-editor/base/classes.d.ts +0 -63
  29. package/dist/ts/inplace-editor/base/classes.ts +0 -63
  30. package/dist/ts/inplace-editor/base/events.d.ts +0 -17
  31. package/dist/ts/inplace-editor/base/events.ts +0 -18
  32. package/dist/ts/inplace-editor/base/index.d.ts +0 -10
  33. package/dist/ts/inplace-editor/base/index.ts +0 -10
  34. package/dist/ts/inplace-editor/base/inplace-editor-model.d.ts +0 -344
  35. package/dist/ts/inplace-editor/base/inplace-editor.d.ts +0 -623
  36. package/dist/ts/inplace-editor/base/inplace-editor.ts +0 -1762
  37. package/dist/ts/inplace-editor/base/interface.d.ts +0 -117
  38. package/dist/ts/inplace-editor/base/interface.ts +0 -127
  39. package/dist/ts/inplace-editor/base/models-model.d.ts +0 -22
  40. package/dist/ts/inplace-editor/base/models.d.ts +0 -31
  41. package/dist/ts/inplace-editor/base/models.ts +0 -45
  42. package/dist/ts/inplace-editor/base/util.d.ts +0 -28
  43. package/dist/ts/inplace-editor/base/util.ts +0 -104
  44. package/dist/ts/inplace-editor/index.d.ts +0 -5
  45. package/dist/ts/inplace-editor/index.ts +0 -5
  46. package/dist/ts/inplace-editor/modules/auto-complete.d.ts +0 -34
  47. package/dist/ts/inplace-editor/modules/auto-complete.ts +0 -65
  48. package/dist/ts/inplace-editor/modules/base-module.d.ts +0 -19
  49. package/dist/ts/inplace-editor/modules/base-module.ts +0 -74
  50. package/dist/ts/inplace-editor/modules/color-picker.d.ts +0 -29
  51. package/dist/ts/inplace-editor/modules/color-picker.ts +0 -55
  52. package/dist/ts/inplace-editor/modules/combo-box.d.ts +0 -34
  53. package/dist/ts/inplace-editor/modules/combo-box.ts +0 -63
  54. package/dist/ts/inplace-editor/modules/date-range-picker.d.ts +0 -29
  55. package/dist/ts/inplace-editor/modules/date-range-picker.ts +0 -55
  56. package/dist/ts/inplace-editor/modules/index.d.ts +0 -12
  57. package/dist/ts/inplace-editor/modules/index.ts +0 -12
  58. package/dist/ts/inplace-editor/modules/multi-select.d.ts +0 -35
  59. package/dist/ts/inplace-editor/modules/multi-select.ts +0 -88
  60. package/dist/ts/inplace-editor/modules/rte.d.ts +0 -31
  61. package/dist/ts/inplace-editor/modules/rte.ts +0 -73
  62. package/dist/ts/inplace-editor/modules/slider.d.ts +0 -30
  63. package/dist/ts/inplace-editor/modules/slider.ts +0 -59
  64. package/dist/ts/inplace-editor/modules/time-picker.d.ts +0 -29
  65. package/dist/ts/inplace-editor/modules/time-picker.ts +0 -54
@@ -1,1762 +0,0 @@
1
- import { Component, INotifyPropertyChanged, NotifyPropertyChanges, Property, Event, EmitType, select } from '@syncfusion/ej2-base';
2
- import { detach, addClass, removeClass, EventHandler, setStyleAttribute, Complex, ModuleDeclaration } from '@syncfusion/ej2-base';
3
- import { isNullOrUndefined as isNOU, closest, extend, L10n, compile, Browser, Touch, TapEventArgs } from '@syncfusion/ej2-base';
4
- import { updateBlazorTemplate, resetBlazorTemplate, SanitizeHtmlHelper, getValue, isBlazor } from '@syncfusion/ej2-base';
5
- import { DataManager, UrlAdaptor, Query, WebApiAdaptor, ODataV4Adaptor, ReturnOption, Predicate } from '@syncfusion/ej2-data';
6
- import { Button, ButtonModel } from '@syncfusion/ej2-buttons';
7
- import { RichTextEditorModel } from '@syncfusion/ej2-richtexteditor';
8
- import { DatePicker, DatePickerModel, DateTimePicker, DateRange, RangeEventArgs } from '@syncfusion/ej2-calendars';
9
- import { DateTimePickerModel, DateRangePickerModel, TimePickerModel } from '@syncfusion/ej2-calendars';
10
- import { createSpinner, hideSpinner, SpinnerArgs, showSpinner} from '@syncfusion/ej2-popups';
11
- import { Tooltip, TooltipEventArgs, TipPointerPosition } from '@syncfusion/ej2-popups';
12
- import { NumericTextBox, NumericTextBoxModel, TextBox, TextBoxModel, SliderChangeEventArgs, ValidArgs } from '@syncfusion/ej2-inputs';
13
- import { ColorPickerModel, FormValidator, MaskedTextBox, MaskedTextBoxModel, SliderModel } from '@syncfusion/ej2-inputs';
14
- import { ChangeEventArgs as InputChangeEventArgs, ColorPickerEventArgs } from '@syncfusion/ej2-inputs';
15
- import { AutoCompleteModel, ComboBoxModel, DropDownList, DropDownListModel, MultiSelectModel } from '@syncfusion/ej2-dropdowns';
16
- import { MultiSelectChangeEventArgs, ChangeEventArgs as DropDownsChangeEventArgs } from '@syncfusion/ej2-dropdowns';
17
- /* Inject modules */
18
- import { Rte } from '../modules/rte';
19
- import { Slider } from '../modules/slider';
20
- import { ComboBox } from '../modules/combo-box';
21
- import { TimePicker } from '../modules/time-picker';
22
- import { MultiSelect } from '../modules/multi-select';
23
- import { ColorPicker } from '../modules/color-picker';
24
- import { AutoComplete } from '../modules/auto-complete';
25
- import { DateRangePicker } from '../modules/date-range-picker';
26
- /* Helper modules */
27
- import * as events from './events';
28
- import * as classes from './classes';
29
- /* Models */
30
- import { PopupSettings, modulesList, localeConstant } from './models';
31
- import { InPlaceEditorModel } from './inplace-editor-model';
32
- import { PopupSettingsModel } from './models-model';
33
- /* Interface */
34
- import { ActionBeginEventArgs, ActionEventArgs, FormEventArgs, ValidateEventArgs, IButton, BeginEditEventArgs } from './interface';
35
- import { ChangeEventArgs, EndEditEventArgs } from './interface';
36
- /* Interface */
37
- import { parseValue, getCompValue, encode } from './util';
38
-
39
- /**
40
- * Provides information about a SanitizeSelectors.
41
- */
42
- export interface SanitizeSelectors {
43
- /** Returns the tags. */
44
- tags?: string[]
45
- /** Returns the attributes. */
46
- attributes?: SanitizeRemoveAttrs[]
47
- }
48
-
49
- /**
50
- * Provides information about a BeforeSanitizeHtml event.
51
- */
52
- export interface BeforeSanitizeHtmlArgs {
53
- /** Illustrates whether the current action needs to be prevented or not. */
54
- cancel?: boolean
55
- /** It is a callback function and executed it before our inbuilt action. It should return HTML as a string.
56
- *
57
- * @function
58
- * @param {string} value - Returns the value.
59
- * @returns {string} - returns the string value
60
- */
61
- helper?: Function
62
- /** Returns the selectors object which carrying both tags and attributes selectors to block list of cross-site scripting attack.
63
- * Also possible to modify the block list in this event.
64
- */
65
- selectors?: SanitizeSelectors
66
- }
67
-
68
- /**
69
- * Provides information about a SanitizeRemoveAttributes.
70
- */
71
- export interface SanitizeRemoveAttrs {
72
- /** Defines the attribute name to sanitize */
73
- attribute?: string
74
- /** Defines the selector that sanitize the specified attributes within the selector */
75
- selector?: string
76
- }
77
-
78
- /**
79
- * Specifies the mode to be render while editing.
80
- */
81
- export type RenderMode = 'Inline' | 'Popup';
82
- /**
83
- * Specifies the action to be perform when user clicks outside the container, that is focus out of editable content.
84
- */
85
- export type ActionBlur = 'Cancel' | 'Submit' | 'Ignore';
86
- /**
87
- * Specifies the event action of input to enter edit mode instead of using edit icon.
88
- */
89
- export type EditableType = 'Click' | 'DblClick' | 'EditIconClick';
90
- /**
91
- * Specifies the value to be set when initial rendering.
92
- */
93
- export type textOptionType = 'Never' | 'Always';
94
- /**
95
- * Specifies the adaptor type that are used DataManager to communicate with DataSource.
96
- */
97
- export type AdaptorType = 'UrlAdaptor' | 'ODataV4Adaptor' | 'WebApiAdaptor';
98
- /**
99
- * Specifies the type of components that integrated with In-place editor to make it as editable.
100
- */
101
- export type InputType = 'AutoComplete' | 'Color' | 'ComboBox' | 'Date' | 'DateRange' | 'DateTime' | 'DropDownList' |
102
- 'Mask' | 'MultiSelect' | 'Numeric' | 'RTE' | 'Slider' | 'Text' | 'Time';
103
- type ComponentTypes = DatePicker | DateTimePicker | DropDownList | MaskedTextBox | NumericTextBox | TextBox;
104
- type DropDownTypes = AutoCompleteModel | ComboBoxModel | DropDownListModel | MultiSelectModel;
105
-
106
- /**
107
- * ```html
108
- * * The In-place editor control is used to edit an element in a place and to update the value in server.
109
- * <div id='element' />
110
- * <script>
111
- * var editorObj = new InPlaceEditor();
112
- * editorObj.appendTo('#element');
113
- * </script>
114
- * ```
115
- */
116
- @NotifyPropertyChanges
117
- export class InPlaceEditor extends Component<HTMLElement> implements INotifyPropertyChanged {
118
- private tipObj: Tooltip;
119
- private touchModule: Touch;
120
- private loader: HTMLElement;
121
- private editEle: HTMLElement;
122
- private spinObj: SpinnerArgs;
123
- private formEle: HTMLElement;
124
- private valueEle: HTMLElement;
125
- private titleEle: HTMLElement;
126
- private editIcon: HTMLElement;
127
- private valueWrap: HTMLElement;
128
- private templateEle: HTMLElement;
129
- private containerEle: HTMLElement;
130
- private initRender: boolean;
131
- private inlineWrapper: HTMLElement;
132
- private isTemplate: boolean;
133
- private formValidate: FormValidator;
134
- private componentObj: ComponentTypes;
135
- private isExtModule: boolean;
136
- private submitBtn: Button;
137
- private cancelBtn: Button;
138
- private isClearTarget: boolean;
139
- private beginEditArgs: BeginEditEventArgs;
140
- private btnElements: HTMLElement;
141
- private dataManager: DataManager;
142
- private oldValue: string | number | Date | string[] | Date[] | number[];
143
- private componentRoot: HTMLElement | HTMLInputElement;
144
- private dataAdaptor: UrlAdaptor | ODataV4Adaptor | WebApiAdaptor;
145
- private prevValue: string | number | Date | string[] | Date[] | number[];
146
- private divComponents: string[];
147
- private clearComponents: string[];
148
- private dateType: string[];
149
- private inputDataEle: string[];
150
- private dropDownEle: string[];
151
- private compPrevValue: string | string[] | number | number[] | boolean[] | Date | Date[] | DateRange;
152
- private moduleList: string[];
153
- private afterOpenEvent: EmitType<TooltipEventArgs>;
154
- private onScrollResizeHandler: EventListenerOrEventListenerObject;
155
-
156
- /**
157
- * @hidden
158
- */
159
- public printValue: string;
160
- /**
161
- * @hidden
162
- */
163
- public needsID: boolean;
164
- /**
165
- * @hidden
166
- */
167
- public atcModule: AutoComplete;
168
- /**
169
- * @hidden
170
- */
171
- public colorModule: ColorPicker;
172
- /**
173
- * @hidden
174
- */
175
- public comboBoxModule: ComboBox;
176
- /**
177
- * @hidden
178
- */
179
- public dateRangeModule: DateRangePicker;
180
- /**
181
- * @hidden
182
- */
183
- public multiSelectModule: MultiSelect;
184
- /**
185
- * @hidden
186
- */
187
- public rteModule: Rte;
188
- /**
189
- * @hidden
190
- */
191
- public sliderModule: Slider;
192
- /**
193
- * @hidden
194
- */
195
- public timeModule: TimePicker;
196
- /**
197
- * Specifies the name of the field which is used to map data to the server.
198
- * If name is not given, then component ID is taken as mapping field name.
199
- *
200
- * {% codeBlock src='inplace-editor/name/index.md' %}{% endcodeBlock %}
201
- *
202
- * @default ''
203
- */
204
- @Property('')
205
- public name: string;
206
- /**
207
- * Specifies the display value for input when original input value is empty.
208
- *
209
- * {% codeBlock src='inplace-editor/value/index.md' %}{% endcodeBlock %}
210
- *
211
- * @default null
212
- * @isGenericType true
213
- */
214
- @Property(null)
215
- public value: string | number | Date | string[] | Date[] | number[];
216
- /**
217
- * Specifies the HTML element ID as a string that can be added as a editable field.
218
- *
219
- * {% codeBlock src='inplace-editor/template/index.md' %}{% endcodeBlock %}
220
- *
221
- * @default ''
222
- * @blazorType string
223
- * @aspType string
224
- */
225
- @Property('')
226
- public template: string | HTMLElement | Function;
227
- /**
228
- * Defines whether to allow the cross-scripting site or not.
229
- *
230
- * @default true
231
- */
232
- @Property(true)
233
- public enableHtmlSanitizer: boolean;
234
- /**
235
- * It enables or disables the parsing of HTML string content into HTML DOM elements for In-place Editor.
236
- * If the value of the property is set to false, the In-place Editor value will be displayed as HTML string instead of HTML DOM elements.
237
- *
238
- * @default true
239
- */
240
- @Property(true)
241
- public enableHtmlParse: boolean;
242
- /**
243
- * Defines single/multiple classes (separated by space) to be used for customization of In-place editor.
244
- *
245
- * @default ''
246
- */
247
- @Property('')
248
- public cssClass: string;
249
- /**
250
- * Defines the unique primary key of editable field which can be used for saving data in data-base.
251
- *
252
- * {% codeBlock src='inplace-editor/primary-key/index.md' %}{% endcodeBlock %}
253
- *
254
- * @default ''
255
- */
256
- @Property('')
257
- public primaryKey: string | number;
258
- /**
259
- * Sets the text to be shown when an element has 'Empty' value.
260
- *
261
- * {% codeBlock src='inplace-editor/empty-text/index.md' %}{% endcodeBlock %}
262
- *
263
- * @default 'Empty'
264
- */
265
- @Property('Empty')
266
- public emptyText: string;
267
- /**
268
- * Gets the url for server submit action.
269
- *
270
- * {% codeBlock src='inplace-editor/url/index.md' %}{% endcodeBlock %}
271
- *
272
- * @default ''
273
- */
274
- @Property('')
275
- public url: string;
276
- /**
277
- * Specifies the mode to be render while editing. The possible modes are :
278
- *
279
- * - `Inline`: Editable content is displayed as inline text and ok/cancel buttons are displayed at right bottom corner of input.
280
- * - `Popup`: Editable content and ok/cancel buttons are displayed inside popup while editing.
281
- *
282
- * {% codeBlock src='inplace-editor/mode/index.md' %}{% endcodeBlock %}
283
- *
284
- * @default 'Popup'
285
- */
286
- @Property('Popup')
287
- public mode: RenderMode;
288
- /**
289
- * Specifies the adaptor type that are used DataManager to communicate with DataSource. The possible values are,
290
- *
291
- * - `UrlAdaptor`: Base adaptor for interacting with remote data services.
292
- * - `ODataV4Adaptor`: Used to interact with ODataV4 service.
293
- * - `WebApiAdaptor`: Used to interact with Web api created with OData endpoint.
294
- *
295
- * {% codeBlock src='inplace-editor/adaptor/index.md' %}{% endcodeBlock %}
296
- *
297
- * @default 'UrlAdaptor'
298
- */
299
- @Property('UrlAdaptor')
300
- public adaptor: AdaptorType;
301
- /**
302
- * Specifies the type of components that integrated with In-place editor to make it as editable.
303
- *
304
- * {% codeBlock src='inplace-editor/type/index.md' %}{% endcodeBlock %}
305
- *
306
- * @default 'Text'
307
- */
308
- @Property('Text')
309
- public type: InputType;
310
- /**
311
- * Specifies the event action of input to enter edit mode instead of using edit icon. The possible values are:
312
- *
313
- * - `Click`: Do the single click action on input to enter into the edit mode.
314
- * - `DblClick`: Do the single double click action on input to enter into the edit mode.
315
- * - `EditIconClick`: Disables the editing of event action of input and allows user to edit only through edit icon.
316
- *
317
- * {% codeBlock src='inplace-editor/editable-on/index.md' %}{% endcodeBlock %}
318
- *
319
- * @default 'Click'
320
- */
321
- @Property('Click')
322
- public editableOn: EditableType;
323
- /**
324
- * Specifies the option to be set on initial rendering. It is applicable for DropDownList,
325
- * AutoComplete, ComboBox, and MultiSelect component types.
326
- * The possible options are:
327
- *
328
- * - `Never`: The corresponding field value will never be set initially in the component.
329
- * - `Always`: The corresponding field value will be set initially in the component.
330
- *
331
- * @default 'Never'
332
- */
333
- @Property('Never')
334
- public textOption: textOptionType;
335
- /**
336
- * Specifies the action to be perform when user clicks outside the container, that is focus out of editable content.
337
- * The possible options are,
338
- *
339
- * - `Cancel`: Cancel's the editing and resets the old content.
340
- * - `Submit`: Submit the edited content to the server.
341
- * - `Ignore`: No action is perform with this type and allows to have many containers open.
342
- *
343
- * @default 'Submit'
344
- */
345
- @Property('Submit')
346
- public actionOnBlur: ActionBlur;
347
- /**
348
- * Enable or disable persisting component's state between page reloads. If enabled, following list of states will be persisted.
349
- * 1. value
350
- *
351
- * {% codeBlock src='inplace-editor/enable-persistence/index.md' %}{% endcodeBlock %}
352
- *
353
- * @default false
354
- */
355
- @Property(false)
356
- public enablePersistence: boolean;
357
- /**
358
- * Specifies whether to enable editing mode or not.
359
- *
360
- * @default false
361
- */
362
- @Property(false)
363
- public disabled: boolean;
364
- /**
365
- * Used to show/hide the ok/cancel buttons of In-place editor.
366
- *
367
- * {% codeBlock src='inplace-editor/show-buttons/index.md' %}{% endcodeBlock %}
368
- *
369
- * @default true
370
- */
371
- @Property(true)
372
- public showButtons: boolean;
373
- /**
374
- * Specifies to show/hide the editing mode.
375
- *
376
- * {% codeBlock src='inplace-editor/enable-edit-mode/index.md' %}{% endcodeBlock %}
377
- *
378
- * @default false
379
- */
380
- @Property(false)
381
- public enableEditMode: boolean;
382
- /**
383
- * Sets to trigger the submit action with enter key pressing of input.
384
- *
385
- * {% codeBlock src='inplace-editor/submit-on-enter/index.md' %}{% endcodeBlock %}
386
- *
387
- * @default true
388
- */
389
- @Property(true)
390
- public submitOnEnter: boolean;
391
- /**
392
- * Specifies the object to customize popup display settings like positions, animation etc.
393
- *
394
- * {% codeBlock src='inplace-editor/popup-settings/index.md' %}{% endcodeBlock %}
395
- *
396
- * @default {}
397
- */
398
- @Complex<PopupSettingsModel>({}, PopupSettings)
399
- public popupSettings: PopupSettingsModel;
400
- /* eslint-disable */
401
- /**
402
- * Specifies the model object configuration for the integrated components like AutoComplete, DatePicker,NumericTextBox, etc.
403
- *
404
- * {% codeBlock src='inplace-editor/model/index.md' %}{% endcodeBlock %}
405
- *
406
- * @default null
407
- */
408
- @Property(null)
409
- public model: AutoCompleteModel | ColorPickerModel | ComboBoxModel | DatePickerModel | DateRangePickerModel | DateTimePickerModel | DropDownListModel | MaskedTextBoxModel | MultiSelectModel | NumericTextBoxModel | RichTextEditorModel | SliderModel | TextBoxModel | TimePickerModel;
410
- /* eslint-enable */
411
- /**
412
- * Used to customize the "Save" button UI appearance by defining Button model configuration.
413
- *
414
- * {% codeBlock src='inplace-editor/save-button/index.md' %}{% endcodeBlock %}
415
- *
416
- * @default { iconCss: 'e-icons e-save-icon' }
417
- */
418
- @Property({ iconCss: 'e-icons e-save-icon' })
419
- public saveButton: ButtonModel;
420
- /**
421
- * Used to customize the "Cancel" button UI appearance by defining Button model configuration.
422
- *
423
- * {% codeBlock src='inplace-editor/cancel-button/index.md' %}{% endcodeBlock %}
424
- *
425
- * @default { iconCss: 'e-icons e-cancel-icon' }
426
- */
427
- @Property({ iconCss: 'e-icons e-cancel-icon' })
428
- public cancelButton: ButtonModel;
429
- /**
430
- * Maps the validation rules for the input.
431
- *
432
- * {% codeBlock src='inplace-editor/validation-rules/index.md' %}{% endcodeBlock %}
433
- *
434
- * @default null
435
- */
436
- @Property(null)
437
- public validationRules: { [name: string]: { [rule: string]: Object } };
438
- /* eslint-disable */
439
- /**
440
- * The event will be fired once the component rendering is completed.
441
- *
442
- * @event 'event'
443
- * @blazorProperty 'Created'
444
- */
445
- @Event()
446
- public created: EmitType<Event>;
447
- /**
448
- * Event triggers before sanitize the value.
449
- * @event
450
- * @blazorProperty 'OnSanitizeHtml'
451
- */
452
- @Event()
453
- public beforeSanitizeHtml: EmitType<BeforeSanitizeHtmlArgs>;
454
- /**
455
- * The event will be fired before the data submitted to the server.
456
- *
457
- * @event 'event'
458
- * @blazorProperty 'OnActionBegin'
459
- */
460
- @Event()
461
- public actionBegin: EmitType<ActionBeginEventArgs>;
462
- /**
463
- * The event will be fired when data submitted successfully to the server.
464
- *
465
- * @event 'event'
466
- * @blazorProperty 'OnActionSuccess'
467
- */
468
- @Event()
469
- public actionSuccess: EmitType<ActionEventArgs>;
470
- /**
471
- * The event will be fired when data submission failed.
472
- *
473
- * @event 'event'
474
- * @blazorProperty 'OnActionFailure'
475
- */
476
- @Event()
477
- public actionFailure: EmitType<ActionEventArgs>;
478
- /**
479
- * The event will be fired while validating current value.
480
- *
481
- * @event 'event'
482
- * @blazorProperty 'Validating'
483
- */
484
- @Event()
485
- public validating: EmitType<ValidateEventArgs>;
486
- /**
487
- * The event will be fired before changing the mode from default to edit mode.
488
- *
489
- * @event 'event'
490
- */
491
- @Event()
492
- public beginEdit: EmitType<BeginEditEventArgs>;
493
- /**
494
- * The event will be fired when the edit action is finished and begin to submit/cancel the current value.
495
- *
496
- * @event 'event'
497
- */
498
- @Event()
499
- public endEdit: EmitType<EndEditEventArgs>;
500
- /**
501
- * The event will be fired when the integrated component value has changed that render based on the `type` property
502
- * in the In-place editor.
503
- *
504
- * @event 'event'
505
- * @blazorProperty 'ValueChange'
506
- */
507
- @Event()
508
- public change: EmitType<ChangeEventArgs>;
509
- /**
510
- * Event triggers when click the submit button.
511
- *
512
- * @event 'event'
513
- * @blazorProperty 'SubmitClick'
514
- */
515
- @Event()
516
- public submitClick: EmitType<MouseEvent>;
517
- /**
518
- * Event triggers when click the cancel button.
519
- *
520
- * @event 'event'
521
- * @blazorProperty 'CancelClick'
522
- */
523
- @Event()
524
- public cancelClick: EmitType<MouseEvent>;
525
- /**
526
- * The event will be fired when the component gets destroyed.
527
- *
528
- * @event 'event'
529
- * @blazorProperty 'Destroyed'
530
- */
531
- @Event()
532
- public destroyed: EmitType<Event>;
533
-
534
-
535
-
536
- private initializeValue(): void{
537
-
538
- this.initRender=true;
539
- this.isTemplate=false;
540
- this.isVue=false;
541
- this.isExtModule=false;
542
- this.submitBtn=undefined;
543
- this.cancelBtn=undefined;
544
- this.isClearTarget=false;
545
- this.btnElements=undefined;
546
- this.dataManager=undefined;
547
- this.oldValue=undefined;
548
- this.divComponents = ['RTE', 'Slider'];
549
- this.clearComponents= ['AutoComplete', 'Mask', 'Text'];
550
- this.dateType = ['Date', 'DateTime', 'Time'];
551
- this.inputDataEle=['Date', 'DateTime', 'DateRange', 'Time', 'Numeric'];
552
- this.dropDownEle = ['AutoComplete', 'ComboBox', 'DropDownList', 'MultiSelect'];
553
- this.moduleList = ['AutoComplete', 'Color', 'ComboBox', 'DateRange', 'MultiSelect', 'RTE', 'Slider', 'Time'];
554
- }
555
- /**
556
- * Initialize the event handler
557
- *
558
- * @returns {void}
559
- * @private
560
- */
561
- protected preRender(): void {
562
- this.initializeValue();
563
- this.onScrollResizeHandler = this.scrollResizeHandler.bind(this);
564
- if (isNOU(this.model)) {
565
- this.setProperties({ model: {} }, true);
566
- }
567
- this.titleEle = this.createElement('div', { className: classes.TITLE });
568
- if (!isNOU(this.popupSettings.model) && this.popupSettings.model.afterOpen) {
569
- this.afterOpenEvent = this.popupSettings.model.afterOpen;
570
- }
571
- }
572
- /**
573
- * To Initialize the In-place editor rendering
574
- *
575
- * @returns {void}
576
- * @private
577
- */
578
- protected render(): void {
579
- if (isNOU(this.element.getAttribute('tabindex'))) {
580
- this.disabled ? this.element.setAttribute('tabindex', '-1') : this.element.setAttribute('tabindex', '0');
581
- }
582
- this.checkIsTemplate();
583
- this.disable(this.disabled);
584
- this.updateAdaptor();
585
- this.appendValueElement();
586
- this.updateValue();
587
- this.textOption === 'Never' ?
588
- this.renderValue(this.checkValue(parseValue(this.type, this.value, this.model)))
589
- : this.renderInitialValue();
590
- this.wireEvents();
591
- this.setRtl(this.enableRtl);
592
- this.enableEditor(this.enableEditMode, true);
593
- this.setClass('add', this.cssClass);
594
- this.renderComplete();
595
- }
596
-
597
- /**
598
- * Initializes a new instance of the In-place editor class.
599
- *
600
- * @param {InPlaceEditorModel} options - Specifies In-place editor model properties as options.
601
- * @param {string} element - Specifies the element for which In-place editor applies.
602
- */
603
- public constructor(options?: InPlaceEditorModel, element?: string | HTMLElement) {
604
- super(options, <HTMLElement | string>element);
605
- this.needsID = true;
606
- }
607
- private setClass(action: string, val: string): void {
608
- if (!this.isEmpty(val)) {
609
- const allClassName: string[] = val.split(' ');
610
- for (let i: number = 0; i < allClassName.length; i++) {
611
- if (allClassName[i].trim() !== '') {
612
- action === 'add' ? addClass([this.element], [allClassName[i]]) : removeClass([this.element], [allClassName[i]]);
613
- }
614
- }
615
- }
616
- }
617
- private appendValueElement(): void {
618
- this.valueWrap = this.createElement('div', { id: this.element.id + '_wrap', className: classes.VALUE_WRAPPER });
619
- if (!isBlazor()) {
620
- this.element.innerHTML = '';
621
- }
622
- this.valueEle = this.createElement('span', { className: classes.VALUE });
623
- this.editIcon = this.createElement('span', {
624
- className: classes.OVERLAY_ICON + ' ' + classes.ICONS,
625
- attrs: { 'title': this.getLocale({ editIcon: 'Click to edit' }, 'editIcon') }
626
- });
627
- this.valueWrap.appendChild(this.valueEle);
628
- this.valueWrap.appendChild(this.editIcon);
629
- this.element.appendChild(this.valueWrap);
630
- }
631
- private renderInitialValue(): void {
632
- if (['AutoComplete', 'ComboBox', 'DropDownList', 'MultiSelect'].indexOf(this.type) > -1
633
- && !isNOU(this.value) && !this.isEmpty(this.value.toString()) && !isNOU((this.model as DropDownTypes).fields)
634
- && !isNOU((this.model as DropDownTypes).dataSource)) {
635
- this.renderValue(this.getLocale({ loadingText: 'Loading...' }, 'loadingText'));
636
- this.valueWrap.classList.add(classes.LOAD);
637
- createSpinner({ target: this.valueWrap, width: 10 });
638
- showSpinner(this.valueWrap);
639
- this.getInitFieldMapValue();
640
- } else {
641
- this.renderValue(this.checkValue(parseValue(this.type, this.value, this.model)));
642
- }
643
- }
644
- private getInitFieldMapValue(): void {
645
- const model: DropDownTypes = this.model as DropDownTypes;
646
- const mText: string = model.fields.text;
647
- const mVal: string = model.fields.value;
648
- const query: Query = isNOU(model.query) ? new Query() : model.query;
649
- if (model.dataSource instanceof DataManager) {
650
- (model.dataSource as DataManager).executeQuery(this.getInitQuery(model, query)).then((e: ReturnOption) => {
651
- this.updateInitValue(mText, mVal, e.result as { [key: string]: object }[]);
652
- });
653
- } else {
654
- this.updateInitValue(mText, mVal, new DataManager(model.dataSource).executeLocal(
655
- this.getInitQuery(model, query)) as { [key: string]: object }[]);
656
- }
657
- }
658
- private getInitQuery(model: DropDownTypes, query: Query): Query {
659
- let predicate: Predicate;
660
- const mVal: string = model.fields.value;
661
- const value: string[] | number[] = this.value as string[] | number[];
662
- if (this.type !== 'MultiSelect' || typeof(this.value) !== 'object') {
663
- predicate = new Predicate(mVal, 'equal', this.value as string);
664
- } else {
665
- let i: number = 0;
666
- for (const val of value) {
667
- predicate = ((i === 0) ? predicate = new Predicate(mVal, 'equal', val) : predicate.or(mVal, 'equal', val));
668
- i++;
669
- }
670
- }
671
- return query.where(predicate);
672
- }
673
- private updateInitValue(mText: string, mVal: string, result: { [key: string]: object }[]): void {
674
- if (result.length <= 0) {
675
- return;
676
- }
677
- if (result.length === 1) {
678
- this.valueEle.innerHTML = this.checkValue(getValue((isNOU(mText) ? mVal : mText), result[0]));
679
- } else {
680
- const val: string[] = [];
681
- for (const obj of result) {
682
- val.push(getValue((isNOU(mText) ? mVal : mText), obj) as string);
683
- }
684
- this.valueEle.innerHTML = this.checkValue(val.toString());
685
- }
686
- hideSpinner(this.valueWrap);
687
- this.valueWrap.classList.remove(classes.LOAD);
688
- }
689
- private renderValue(val: string): void {
690
- this.enableHtmlSanitizer && this.type !== 'RTE' && this.type !== 'MultiSelect' ? this.valueEle.innerText = val :
691
- (this.valueEle.innerHTML = this.enableHtmlParse ? val : encode(val));
692
- if (this.type === 'Color') {
693
- setStyleAttribute(this.valueEle, { 'color': val });
694
- }
695
- if (this.mode === 'Inline') {
696
- if (this.isEditorOpen()) {
697
- removeClass([this.valueWrap], [classes.HIDE]);
698
- }
699
- }
700
- }
701
- private isEditorOpen(): boolean {
702
- if (this.isVue && (this.enableEditMode || (!isNOU(this.valueWrap) &&
703
- !(this.valueWrap.classList.contains(classes.HIDE) || this.valueWrap.classList.contains('e-tooltip'))))) {
704
- return false;
705
- } else {
706
- return true;
707
- }
708
- }
709
- private renderEditor(): void {
710
- this.prevValue = this.value;
711
- this.beginEditArgs = { mode: this.mode, cancelFocus: false, cancel: false };
712
- this.trigger('beginEdit', this.beginEditArgs);
713
- if (this.beginEditArgs.cancel) {
714
- return;
715
- }
716
- let tipOptions: object = undefined;
717
- const target: HTMLElement = <HTMLElement>select('.' + classes.VALUE_WRAPPER, this.element);
718
- if (this.editableOn !== 'EditIconClick') {
719
- target.parentElement.removeAttribute('title');
720
- }
721
- if (this.valueWrap.classList.contains(classes.OPEN)) {
722
- return;
723
- }
724
- if (this.mode === 'Inline') {
725
- addClass([this.valueWrap], [classes.HIDE]);
726
- this.inlineWrapper = this.createElement('div', { className: classes.INLINE });
727
- this.element.appendChild(this.inlineWrapper);
728
- if (['AutoComplete', 'ComboBox', 'DropDownList', 'MultiSelect'].indexOf(this.type) > -1) {
729
- this.checkRemoteData(this.model as AutoCompleteModel | ComboBoxModel | DropDownListModel | MultiSelectModel);
730
- } else {
731
- this.renderAndOpen();
732
- }
733
- } else {
734
- if (!isNOU(this.popupSettings.model) && this.popupSettings.model.afterOpen) {
735
- this.popupSettings.model.afterOpen = this.afterOpenHandler.bind(this);
736
- }
737
- const content: HTMLElement = this.createElement('div', { className: classes.POPUP });
738
- if (!this.isEmpty(this.popupSettings.title)) {
739
- this.titleEle.innerHTML = this.popupSettings.title;
740
- content.appendChild(this.titleEle);
741
- }
742
- tipOptions = {
743
- content: content, opensOn: 'Custom',
744
- enableRtl: this.enableRtl, cssClass: classes.ROOT_TIP,
745
- afterOpen: this.afterOpenHandler.bind(this)
746
- };
747
- content.appendChild(this.renderControl(document.body));
748
- extend(tipOptions, this.popupSettings.model, tipOptions, true);
749
- this.tipObj = new Tooltip(tipOptions);
750
- this.tipObj.appendTo(target);
751
- this.tipObj.open(target);
752
- }
753
- if (this.actionOnBlur !== 'Ignore') {
754
- this.wireDocEvent();
755
- }
756
- addClass([this.valueWrap], [classes.OPEN]);
757
- this.setProperties({ enableEditMode: true }, true);
758
- if ((this as any).isReact) {
759
- this.renderReactTemplates();
760
- }
761
- }
762
-
763
- private renderAndOpen(): void {
764
- this.renderControl(this.inlineWrapper);
765
- this.afterOpenHandler(null);
766
- }
767
-
768
- private checkRemoteData(model: AutoCompleteModel | ComboBoxModel | DropDownListModel | MultiSelectModel): void {
769
- if (model.dataSource instanceof DataManager) {
770
- model.dataBound = () => {
771
- this.afterOpenHandler(null);
772
- };
773
- this.renderControl(this.inlineWrapper);
774
- if ((isNOU(model.value) && isNOU(this.value)) || (model.value === this.value
775
- && (!isNOU(model.value) && (model.value as string[] | number[]).length === 0))) {
776
- this.showDropDownPopup();
777
- }
778
- } else {
779
- this.renderAndOpen();
780
- }
781
- }
782
-
783
- private showDropDownPopup(): void {
784
- if (this.type === 'DropDownList') {
785
- if (!(this.model as AutoCompleteModel | ComboBoxModel | DropDownListModel
786
- | MultiSelectModel).allowFiltering) {
787
- (this.componentObj as DropDownList).focusIn();
788
- }
789
- (this.componentObj as DropDownList).showPopup();
790
- } else {
791
- if (this.isExtModule) {
792
- this.notify(((this.type === 'MultiSelect') ? events.setFocus : events.showPopup), {});
793
- }
794
- }
795
- }
796
-
797
- private setAttribute(ele: HTMLElement, attr: string[]): void {
798
- const value: string = this.name && this.name.length !== 0 ? this.name : this.element.id;
799
- attr.forEach((val: string) => {
800
- ele.setAttribute(val, ((val === 'id') ? (value + '_editor') : value));
801
- });
802
- }
803
- private renderControl(target: HTMLElement): HTMLElement {
804
- let ele: HTMLElement | HTMLInputElement;
805
- this.containerEle = this.createElement('div', { className: classes.WRAPPER });
806
- this.loader = this.createElement('div', { className: classes.LOADING });
807
- this.formEle = this.createElement('form', { className: classes.FORM }) as HTMLFormElement;
808
- const ctrlGroupEle: HTMLElement = this.createElement('div', { className: classes.CTRL_GROUP });
809
- const inputWrap: HTMLElement = this.createElement('div', { className: classes.INPUT });
810
- target.appendChild(this.containerEle);
811
- this.loadSpinner();
812
- this.containerEle.appendChild(this.formEle);
813
- this.formEle.appendChild(ctrlGroupEle);
814
- if (this.isTemplate) {
815
- this.appendTemplate(inputWrap, this.template);
816
- } else {
817
- if (Array.prototype.indexOf.call(this.divComponents, this.type) > -1) {
818
- ele = this.createElement('div') as HTMLElement;
819
- this.setAttribute(ele, ['id']);
820
- } else {
821
- ele = this.createElement('input') as HTMLInputElement;
822
- this.setAttribute(ele, ['id', 'name']);
823
- }
824
- this.componentRoot = ele;
825
- inputWrap.appendChild(ele);
826
- inputWrap.appendChild(this.loader);
827
- }
828
- ctrlGroupEle.appendChild(inputWrap);
829
- ctrlGroupEle.appendChild(this.createElement('div', { className: classes.EDITABLE_ERROR }));
830
- this.appendButtons(this.formEle);
831
- if (!this.isTemplate) {
832
- this.renderComponent(ele);
833
- }
834
- this.removeSpinner();
835
- if (this.submitOnEnter) {
836
- this.wireEditorKeyDownEvent(this.containerEle);
837
- }
838
- return this.containerEle;
839
- }
840
- private appendButtons(trg: HTMLElement): void {
841
- if (this.showButtons && trg) {
842
- this.btnElements = this.renderButtons();
843
- trg.appendChild(this.btnElements);
844
- this.wireBtnEvents();
845
- }
846
- }
847
- private renderButtons(): HTMLElement {
848
- const btnWrap: HTMLElement = this.createElement('div', { className: classes.BUTTONS });
849
- const primary: string = (!isNOU(this.saveButton.content) && this.saveButton.content.length !== 0) ? (' ' + classes.PRIMARY) : '';
850
- this.submitBtn = this.createButtons({
851
- constant: 'save', type: 'submit', container: btnWrap,
852
- title: { save: 'Save' }, model: this.saveButton,
853
- className: classes.BTN_SAVE + primary
854
- });
855
- this.cancelBtn = this.createButtons({
856
- type: 'button', constant: 'cancel', title: { cancel: 'Cancel' },
857
- container: btnWrap, model: this.cancelButton,
858
- className: classes.BTN_CANCEL
859
- });
860
- return btnWrap;
861
- }
862
- private createButtons(args: IButton): Button {
863
- let btnObj: Button = undefined;
864
- if (Object.keys(args.model).length > 0) {
865
- const btnEle: HTMLButtonElement = <HTMLButtonElement>this.createElement('button', {
866
- className: args.className,
867
- attrs: { 'type': args.type, 'title': (args.constant=="save")? (isNOU(this.saveButton.content)?this.getLocale(args.title, args.constant):this.saveButton.content): (isNOU(this.cancelButton.content)?this.getLocale(args.title, args.constant):this.cancelButton.content)}
868
- });
869
- args.container.appendChild(btnEle);
870
- btnObj = new Button(args.model, btnEle);
871
- }
872
- return btnObj;
873
- }
874
- private renderComponent(ele: HTMLElement | HTMLInputElement): void {
875
- this.isExtModule = (Array.prototype.indexOf.call(this.moduleList, this.type) > -1) ? true : false;
876
- let classProp: string;
877
- if (!isNOU(this.model.cssClass)) {
878
- classProp = this.model.cssClass.indexOf(classes.ELEMENTS) < 0 ?
879
- this.model.cssClass === '' ? classes.ELEMENTS : this.model.cssClass + ' ' + classes.ELEMENTS :
880
- this.model.cssClass;
881
- } else {
882
- classProp = classes.ELEMENTS;
883
- }
884
- extend(this.model, this.model, {
885
- cssClass: classProp, enableRtl: this.enableRtl, locale: this.locale, change: this.changeHandler.bind(this)
886
- });
887
- if (!isNOU(this.value)) {
888
- this.updateModelValue(false);
889
- }
890
- if (this.isExtModule) {
891
- this.notify(events.render, { module: modulesList[this.type], target: ele, type: this.type });
892
- } else {
893
- if (isNOU((this.model as DropDownListModel).showClearButton) && !isBlazor()) {
894
- (this.model as DropDownListModel).showClearButton = true;
895
- }
896
- switch (this.type) {
897
- case 'Date':
898
- this.componentObj = new DatePicker(this.model as DatePickerModel);
899
- break;
900
- case 'DateTime':
901
- this.componentObj = new DateTimePicker(this.model as DateTimePickerModel);
902
- break;
903
- case 'DropDownList':
904
- this.componentObj = new DropDownList(this.model as DropDownListModel);
905
- break;
906
- case 'Mask':
907
- this.componentObj = new MaskedTextBox(this.model as MaskedTextBoxModel);
908
- break;
909
- case 'Numeric':
910
- if (this.model.value) {
911
- const expRegex = new RegExp('[eE][\-+]?([0-9]+)');
912
- if (expRegex.test(this.model.value as string)) {
913
- this.model.value = this.model.value;
914
- } else {
915
- this.model.value = (this.model.value as string).toString().replace(/[`~!@#$%^&*()_|\=?;:'",<>\{\}\[\]\\\/]/gi, '');
916
- }
917
- }
918
- this.componentObj = new NumericTextBox(this.model as NumericTextBoxModel);
919
- break;
920
- case 'Text':
921
- this.componentObj = new TextBox(this.model as TextBoxModel);
922
- break;
923
- }
924
- this.componentObj.appendTo(ele as HTMLInputElement);
925
- }
926
- }
927
- private updateAdaptor(): void {
928
- switch (this.adaptor) {
929
- case 'UrlAdaptor':
930
- this.dataAdaptor = new UrlAdaptor;
931
- break;
932
- case 'WebApiAdaptor':
933
- this.dataAdaptor = new WebApiAdaptor;
934
- break;
935
- case 'ODataV4Adaptor':
936
- this.dataAdaptor = new ODataV4Adaptor;
937
- break;
938
- }
939
- }
940
- private loadSpinner(callType?: string): void {
941
- addClass([this.loader], [classes.SHOW]);
942
- if (callType === 'validate' && (this.type === 'RTE' || this.type === 'Color' || this.type === 'Slider')) {
943
- addClass([this.loader], [classes.RTE_SPIN_WRAP]);
944
- addClass([this.getEditElement()], [classes.CTRL_OVERLAY]);
945
- this.spinObj = { target: this.loader };
946
- } else {
947
- this.spinObj = { target: this.loader, width: Browser.isDevice ? '16px' : '14px' };
948
- }
949
- if (this.formEle) {
950
- addClass([this.formEle], [classes.LOAD]);
951
- }
952
- if (this.btnElements) {
953
- addClass([this.btnElements], [classes.HIDE]);
954
- }
955
- setStyleAttribute(this.loader, { 'width': '100%' });
956
- createSpinner(this.spinObj);
957
- showSpinner(this.spinObj.target);
958
- }
959
- private removeSpinner(callType?: string): void {
960
- this.loader.removeAttribute('style');
961
- hideSpinner(this.spinObj.target);
962
- detach(this.spinObj.target.firstChild);
963
- if (callType === 'submit' && (this.type === 'RTE' || this.type === 'Color' || this.type === 'Slider')) {
964
- removeClass([this.loader], [classes.RTE_SPIN_WRAP]);
965
- removeClass([this.getEditElement()], [classes.CTRL_OVERLAY]);
966
- }
967
- if (this.formEle) {
968
- removeClass([this.formEle], [classes.LOAD]);
969
- }
970
- if (this.btnElements) {
971
- removeClass([this.btnElements], [classes.HIDE]);
972
- }
973
- removeClass([this.loader], [classes.SHOW]);
974
- }
975
- private getEditElement(): Element {
976
- return select('.' + classes.ELEMENTS, this.formEle);
977
- }
978
- private getLocale(prop: object, val: string): string {
979
- return new L10n('inplace-editor', prop, this.locale).getConstant(val);
980
- }
981
- private checkValue(val: string): string {
982
- return (!this.isEmpty(val)) ? val : this.emptyText;
983
- }
984
- public extendModelValue(val: string | number | boolean | Date | object | DateRange | string[] | Date[] | number[] | boolean[] | object[]): void {
985
- const model: object = this.model;
986
- extend(model, { value: val });
987
- this.setProperties({ model: model }, true);
988
- }
989
- private updateValue(): void {
990
- this.oldValue = this.value;
991
- if (this.enableHtmlSanitizer && typeof(this.value) === 'string') {
992
- this.oldValue = this.sanitizeHelper(this.value);
993
- }
994
- if (!isNOU(this.value)) {
995
- this.setProperties({ value: getCompValue(this.type, this.oldValue) }, true);
996
- this.extendModelValue(getCompValue(this.type, this.oldValue));
997
- }
998
- }
999
- private updateModelValue(updateOldValue: boolean): void {
1000
- if (this.type === 'MultiSelect' && !this.isEmpty(this.value as string[])) {
1001
- this.model.value = !updateOldValue ? (<string[]>this.value).slice() : (<string[]>this.oldValue).slice();
1002
- } else {
1003
- this.model.value = !updateOldValue ? this.value : this.oldValue;
1004
- }
1005
- }
1006
- public setValue(): void {
1007
- if (this.isExtModule) {
1008
- this.notify(events.update, { type: this.type });
1009
- } else if (this.componentObj) {
1010
- if (this.type === 'Numeric' && this.componentObj.value === null) {
1011
- this.componentObj.setProperties({ value: null }, true);
1012
- }
1013
- this.setProperties({ value: this.componentObj.value }, true);
1014
- this.extendModelValue(this.componentObj.value);
1015
- }
1016
- }
1017
- private getDropDownsValue(display: boolean): string {
1018
- let value: string;
1019
- if (Array.prototype.indexOf.call(this.dropDownEle, this.type) > -1 && this.type !== 'MultiSelect') {
1020
- value = display ? (select('.e-' + this.type.toLocaleLowerCase(), this.containerEle) as HTMLInputElement).value :
1021
- this.value.toString();
1022
- } else if (this.type === 'MultiSelect') {
1023
- this.notify(events.accessValue, { type: this.type });
1024
- value = display ? this.printValue : (this.value as string[] | number[]).join();
1025
- }
1026
- return value;
1027
- }
1028
-
1029
- private getSendValue(): string {
1030
- if (this.isEmpty(this.value as string)) {
1031
- return '';
1032
- }
1033
- if (Array.prototype.indexOf.call(this.dropDownEle, this.type) > -1) {
1034
- return this.getDropDownsValue(false);
1035
- } else if (Array.prototype.indexOf.call(this.dateType, this.type) > -1) {
1036
- return (<Date>this.value).toISOString();
1037
- } else if (this.type === 'DateRange') {
1038
- return (<Date[]>this.value)[0].toISOString() + ' - ' + (<Date[]>this.value)[1].toISOString();
1039
- } else {
1040
- return this.value.toString();
1041
- }
1042
- }
1043
- private getRenderValue(): string {
1044
- if (this.type === 'Mask' && (<string>this.componentObj.value).length !== 0) {
1045
- return (this.componentObj as MaskedTextBox).getMaskedValue();
1046
- } else if (Array.prototype.indexOf.call(this.inputDataEle, this.type) > -1) {
1047
- return (this.componentRoot as HTMLInputElement).value;
1048
- } else if (Array.prototype.indexOf.call(this.dropDownEle, this.type) > -1) {
1049
- return this.getDropDownsValue(true);
1050
- } else {
1051
- return parseValue(this.type, this.value, this.model);
1052
- }
1053
- }
1054
- private setRtl(value: boolean): void {
1055
- value ? addClass([this.element], [classes.RTL]) : removeClass([this.element], [classes.RTL]);
1056
- }
1057
- private setFocus(): void {
1058
- if (this.isTemplate) {
1059
- return;
1060
- }
1061
- this.isExtModule ? this.notify(events.setFocus, {}) : (this as any).componentObj.getModuleName() === 'dropdownlist' ? this.componentObj.focusIn() : this.componentObj.element.focus();
1062
- }
1063
- private removeEditor(isBlazorDestroy?: boolean): void {
1064
- const blazorContain: string[] = Object.keys(window) as string[];
1065
- if (isBlazor() && !this.isStringTemplate) {
1066
- resetBlazorTemplate(this.element.id + 'template', 'Template');
1067
- }
1068
- let tipEle: HTMLElement;
1069
- if (this.tipObj && this.formEle) {
1070
- tipEle = <HTMLElement>closest(this.formEle, '.' + classes.ROOT_TIP);
1071
- tipEle.classList.add(classes.HIDE);
1072
- }
1073
- this.unWireDocEvent();
1074
- this.destroyComponents();
1075
- this.formEle = undefined;
1076
- if (!isNOU(select('.' + classes.INLINE, this.element))) {
1077
- detach(this.inlineWrapper);
1078
- this.inlineWrapper = undefined;
1079
- } else if (this.tipObj) {
1080
- if (this.type === 'MultiSelect') {
1081
- EventHandler.remove(this.containerEle, 'mousedown', this.popMouseDown);
1082
- EventHandler.remove(this.containerEle, 'click', this.popClickHandler);
1083
- }
1084
- this.tipObj.close();
1085
- this.tipObj.destroy();
1086
- this.tipObj = undefined;
1087
- }
1088
- this.containerEle = undefined;
1089
- removeClass([this.valueWrap], [classes.OPEN, classes.HIDE]);
1090
- if (!isBlazorDestroy) {
1091
- this.setProperties({ enableEditMode: false }, true);
1092
- }
1093
- if (!isNOU(this.editableOn) && this.editableOn !== 'EditIconClick') {
1094
- const titleConstant: string = (this.editableOn === 'DblClick') ? 'editAreaDoubleClick' : 'editAreaClick';
1095
- if (!isNOU(this.valueWrap.parentElement)) {
1096
- this.valueWrap.parentElement.setAttribute('title', this.getLocale(localeConstant[this.editableOn], titleConstant));
1097
- }
1098
- }
1099
- if ((this as any).isReact) {
1100
- this.clearTemplate();
1101
- }
1102
- }
1103
- private destroyComponents(): void {
1104
- if (this.showButtons) {
1105
- this.destroyButtons();
1106
- }
1107
- if (this.isExtModule) {
1108
- this.notify(events.destroyModules, {});
1109
- } else {
1110
- if (this.templateEle) {
1111
- document.body.appendChild(this.templateEle);
1112
- this.templateEle.style.display = 'none';
1113
- this.templateEle = undefined;
1114
- }
1115
- if (!isNOU(this.componentObj)) {
1116
- this.componentObj.destroy();
1117
- this.componentObj = undefined;
1118
- }
1119
- }
1120
- if (this.formValidate) {
1121
- this.formValidate = undefined;
1122
- }
1123
- if (this.submitOnEnter && this.containerEle) {
1124
- this.unWireEditorKeyDownEvent(this.containerEle);
1125
- }
1126
- }
1127
- private destroyButtons(): void {
1128
- if (!isNOU(this.submitBtn)) {
1129
- EventHandler.remove(this.submitBtn.element, 'mousedown', this.submitHandler);
1130
- EventHandler.remove(this.submitBtn.element, 'click', this.submitPrevent);
1131
- EventHandler.remove(this.submitBtn.element, 'keydown', this.btnKeyDownHandler);
1132
- this.submitBtn.destroy();
1133
- this.submitBtn = undefined;
1134
- }
1135
- if (!isNOU(this.cancelBtn)) {
1136
- EventHandler.remove(this.cancelBtn.element, 'mousedown', this.cancelBtnClick);
1137
- EventHandler.remove(this.cancelBtn.element, 'keydown', this.btnKeyDownHandler);
1138
- this.cancelBtn.destroy();
1139
- this.cancelBtn = undefined;
1140
- }
1141
- this.btnElements = undefined;
1142
- }
1143
- private getQuery(params: { [key: string]: string | number }): Query {
1144
- const query: Query = new Query();
1145
- Object.keys(params).forEach((key: string) => {
1146
- query.addParams(key, params[key] as string);
1147
- });
1148
- return query;
1149
- }
1150
- private sendValue(): void {
1151
- const eventArgs: ActionBeginEventArgs = { data: { name: this.name, primaryKey: this.primaryKey, value: this.getSendValue() } };
1152
- this.trigger('actionBegin', eventArgs, (actionBeginArgs: ActionBeginEventArgs) => {
1153
- if (actionBeginArgs.cancel) {
1154
- this.removeSpinner('submit');
1155
- if (this.mode === 'Popup') {
1156
- this.updateArrow();
1157
- }
1158
- } else {
1159
- if (!this.isEmpty(this.url) && !this.isEmpty(this.primaryKey as string)
1160
- && (this.initRender || (!this.initRender && this.prevValue !== this.value))) {
1161
- this.dataManager = new DataManager({ url: this.url, adaptor: this.dataAdaptor });
1162
- if (this.adaptor === 'UrlAdaptor') {
1163
- this.dataManager.executeQuery(
1164
- this.getQuery(actionBeginArgs.data), this.successHandler.bind(this), this.failureHandler.bind(this)
1165
- );
1166
- } else {
1167
- const crud: Promise<Object> = this.dataManager.insert(actionBeginArgs.data) as Promise<Object>;
1168
- crud.then((e: ReturnOption) => this.successHandler(e)).catch((e: ReturnOption) => this.failureHandler(e));
1169
- }
1170
- } else {
1171
- const eventArg: ActionEventArgs = { data: {}, value: actionBeginArgs.data.value as string };
1172
- this.triggerSuccess(eventArg);
1173
- }
1174
- this.dataManager = undefined;
1175
- }
1176
- });
1177
- }
1178
- private isEmpty(value: string | string[]): boolean {
1179
- return (!isNOU(value) && value.length !== 0) ? false : true;
1180
- }
1181
- private checkIsTemplate(): void {
1182
- this.isTemplate = (!isNOU(this.template) && this.template !== '') ? true : false;
1183
- }
1184
- private templateCompile(trgEle: HTMLElement, tempStr: string | Function): void {
1185
- let tempEle: HTMLElement[];
1186
- const blazorContain: string[] = Object.keys(window) as string[];
1187
- if (typeof tempStr === 'string') {
1188
- tempStr = tempStr.trim();
1189
- }
1190
- const compiler: Function = compile(tempStr);
1191
- if (!isNOU(compiler)) {
1192
- const isString: boolean = (isBlazor() && typeof tempStr !== 'function' &&
1193
- !this.isStringTemplate && (tempStr).indexOf('<div>Blazor') === 0) ?
1194
- this.isStringTemplate : true;
1195
- tempEle = compiler({}, this, 'template', this.element.id + 'template', isString);
1196
- }
1197
- if (!isNOU(compiler) && tempEle.length > 0) {
1198
- [].slice.call(tempEle).forEach((el: HTMLElement): void => {
1199
- trgEle.appendChild(el);
1200
- });
1201
- if (isBlazor() && !this.isStringTemplate && typeof tempStr !== 'function' &&
1202
- (tempStr).indexOf('<div>Blazor') === 0) {
1203
- updateBlazorTemplate(this.element.id + 'template', 'Template', this);
1204
- }
1205
- }
1206
- }
1207
- /**
1208
- * @param {string} value - specifies the string value
1209
- * @returns {string} - returns the string
1210
- * @hidden
1211
- */
1212
- public sanitizeHelper(value: string): string {
1213
- if (this.enableHtmlSanitizer) {
1214
- const item: BeforeSanitizeHtmlArgs = SanitizeHtmlHelper.beforeSanitize();
1215
- const beforeEvent: BeforeSanitizeHtmlArgs = {
1216
- cancel: false,
1217
- helper: null
1218
- };
1219
- extend(item, item, beforeEvent);
1220
- this.trigger('beforeSanitizeHtml', item, (args: BeforeSanitizeHtmlArgs) => {
1221
- if (item.cancel && !isNOU(item.helper)) {
1222
- value = item.helper(value);
1223
- } else if (!item.cancel) {
1224
- value = SanitizeHtmlHelper.serializeValue(item, value);
1225
- }
1226
- });
1227
- }
1228
- return value;
1229
- }
1230
- private appendTemplate(trgEle: HTMLElement, tempStr: string | HTMLElement | Function): void {
1231
- tempStr = typeof(tempStr) === 'string' ? this.sanitizeHelper(tempStr) : tempStr;
1232
- this.setProperties({ template: tempStr }, true);
1233
- if (typeof tempStr === 'function') {
1234
- this.templateCompile(trgEle, tempStr);
1235
- } else if (typeof tempStr === 'string' || isNOU((<HTMLElement>tempStr).innerHTML)) {
1236
- if ((<string>tempStr)[0] === '.' || (<string>tempStr)[0] === '#') {
1237
- if (document.querySelectorAll(<string>tempStr).length) {
1238
- this.templateEle = document.querySelector(<string>tempStr);
1239
- trgEle.appendChild(this.templateEle);
1240
- this.templateEle.style.display = '';
1241
- } else {
1242
- this.templateCompile(trgEle, <string>tempStr);
1243
- }
1244
- } else {
1245
- this.templateCompile(trgEle, <string>tempStr);
1246
- }
1247
- } else {
1248
- this.templateEle = tempStr;
1249
- trgEle.appendChild(this.templateEle);
1250
- }
1251
- }
1252
-
1253
- private disable(value: boolean): void {
1254
- value ? addClass([this.element], [classes.DISABLE]) : removeClass([this.element], [classes.DISABLE]);
1255
- }
1256
- private enableEditor(val: boolean, isInit?: boolean): void {
1257
- if (isInit && !val) { return; }
1258
- (val) ? this.renderEditor() : this.cancelHandler('cancel');
1259
- }
1260
- private checkValidation(fromSubmit : boolean , isValidate?: boolean): void {
1261
- let args: ValidateEventArgs;
1262
- if (this.validationRules) {
1263
- const rules: string[] = Object.keys(this.validationRules);
1264
- let validationLength : number = Object.keys(this.validationRules[rules[0]]).length;
1265
- validationLength = 'validateHidden' in this.validationRules[rules[0]] ? validationLength - 1 : validationLength;
1266
- let count : number = 0;
1267
- this.formValidate = new FormValidator(this.formEle as HTMLFormElement, {
1268
- rules: this.validationRules,
1269
- validationBegin: (e: ValidArgs) => {
1270
- if (this.type ==='RTE') {
1271
- let ele : HTMLElement =document.createElement('div');
1272
- ele.innerHTML = e.value;
1273
- e.value = ele.innerText;
1274
- }
1275
- },
1276
- validationComplete: (e: FormEventArgs) => {
1277
- count = count + 1;
1278
- args = {
1279
- errorMessage: e.message,
1280
- data: { name: this.name, primaryKey: this.primaryKey, value: this.checkValue(this.getSendValue()) }
1281
- };
1282
- this.trigger('validating', args, (validateArgs: ValidateEventArgs) => {
1283
- if (e.status === 'failure') {
1284
- e.errorElement.innerText = validateArgs.errorMessage;
1285
- this.toggleErrorClass(true);
1286
- } else {
1287
- this.toggleErrorClass(false);
1288
- }
1289
- if (!isNOU(fromSubmit) && fromSubmit && (validationLength === count || e.status === 'failure')) {
1290
- fromSubmit = false;
1291
- this.afterValidation(isValidate);
1292
- count = 0;
1293
- }
1294
- });
1295
- },
1296
- customPlacement: (inputElement: HTMLElement, errorElement: HTMLElement) => {
1297
- if (this.formEle) {
1298
- select('.' + classes.EDITABLE_ERROR, this.formEle).appendChild(errorElement);
1299
- }
1300
- }
1301
- });
1302
- count = 0;
1303
- this.formValidate.validate();
1304
- } else if (this.template !== '') {
1305
- args = {
1306
- errorMessage: '',
1307
- data: { name: this.name, primaryKey: this.primaryKey, value: this.checkValue(this.getSendValue()) }
1308
- };
1309
- this.trigger('validating', args, (validateArgs: ValidateEventArgs) => {
1310
- if (validateArgs.errorMessage) {
1311
- select('.' + classes.EDITABLE_ERROR, this.formEle).innerHTML = validateArgs.errorMessage;
1312
- this.toggleErrorClass(true);
1313
- } else {
1314
- this.toggleErrorClass(false);
1315
- }
1316
- this.afterValidation(isValidate);
1317
- });
1318
- } else {
1319
- this.afterValidation(isValidate);
1320
- }
1321
- }
1322
- private afterValidation(isValidate: boolean): void {
1323
- if (!this.formEle.classList.contains(classes.ERROR) && isValidate) {
1324
- this.loadSpinner('validate');
1325
- if (this.mode === 'Popup') {
1326
- this.updateArrow();
1327
- }
1328
- this.sendValue();
1329
- }
1330
- }
1331
- private toggleErrorClass(value: boolean): void {
1332
- if (isNOU(this.formEle)) {
1333
- return;
1334
- }
1335
- const inputEle: HTMLElement = <HTMLElement>select('.e-input-group', this.formEle);
1336
- const errorClass: Function = (element: HTMLElement[], val: string, action: string) => {
1337
- [].slice.call(element).forEach((ele: HTMLElement) => {
1338
- if (ele) {
1339
- action === 'add' ? addClass([ele], [val]) : removeClass([ele], [val]);
1340
- }
1341
- });
1342
- };
1343
- errorClass([this.formEle, inputEle], classes.ERROR, value ? 'add' : 'remove');
1344
- }
1345
- private updateArrow(): void {
1346
- const pos: TipPointerPosition = this.tipObj.tipPointerPosition;
1347
- this.tipObj.tipPointerPosition = (pos === 'Middle') ? 'Auto' : 'Middle';
1348
- this.tipObj.tipPointerPosition = pos;
1349
- this.tipObj.dataBind();
1350
- }
1351
- private triggerSuccess(args: ActionEventArgs): void {
1352
- const val: string = args.value;
1353
- this.trigger('actionSuccess', args, (actionArgs: ActionEventArgs) => {
1354
- this.oldValue = val;
1355
- this.removeSpinner('submit');
1356
- if (!actionArgs.cancel) {
1357
- this.renderValue(this.checkValue((actionArgs.value !== val) ? actionArgs.value : this.getRenderValue()));
1358
- }
1359
- if (actionArgs.cancel && this.mode === 'Inline') {
1360
- removeClass([this.valueWrap], [classes.HIDE]);
1361
- }
1362
- this.removeEditor();
1363
- });
1364
- }
1365
- private triggerEndEdit(closeBeginBy: string): void {
1366
- const endEditArgs = { cancel: false, mode: this.mode, action: closeBeginBy };
1367
- this.trigger('endEdit', endEditArgs, (args: EndEditEventArgs) => {
1368
- if (!args.cancel) {
1369
- if (this.formEle && this.formEle.classList.contains(classes.ERROR)) {
1370
- this.updateModelValue(true);
1371
- this.setProperties({ value: this.oldValue }, true);
1372
- }
1373
- this.removeEditor();
1374
- }
1375
- });
1376
- }
1377
- private wireEvents(): void {
1378
- if (!isNOU(this.editableOn)) {
1379
- this.wireEditEvent(this.editableOn);
1380
- }
1381
- EventHandler.add(this.editIcon, 'click', this.clickHandler, this);
1382
- EventHandler.add(this.element, 'keydown', this.valueKeyDownHandler, this);
1383
- document.addEventListener('scroll', this.onScrollResizeHandler);
1384
- window.addEventListener('resize', this.onScrollResizeHandler);
1385
- if (Array.prototype.indexOf.call(this.clearComponents, this.type) > -1) {
1386
- EventHandler.add(this.element, 'mousedown', this.mouseDownHandler, this);
1387
- }
1388
- }
1389
- private wireDocEvent(): void {
1390
- EventHandler.add(document, 'mousedown', this.docClickHandler, this);
1391
- }
1392
- private wireEditEvent(event: string): void {
1393
- if (event === 'EditIconClick') {
1394
- return;
1395
- }
1396
- const titleConstant: string = (event === 'Click') ? 'editAreaClick' : 'editAreaDoubleClick';
1397
- this.element.setAttribute('title', this.getLocale(localeConstant[event], titleConstant));
1398
- if (Browser.isDevice && Browser.isIos && event === 'DblClick') {
1399
- this.touchModule = new Touch(this.valueWrap, { tap: this.doubleTapHandler.bind(this) });
1400
- } else {
1401
- EventHandler.add(this.valueWrap, event.toLowerCase(), this.clickHandler, this);
1402
- }
1403
- }
1404
- private wireEditorKeyDownEvent(ele: HTMLElement): void {
1405
- EventHandler.add(ele, 'keydown', this.enterKeyDownHandler, this);
1406
- }
1407
- private wireBtnEvents(): void {
1408
- if (!isNOU(this.submitBtn)) {
1409
- EventHandler.add(this.submitBtn.element, 'mousedown', this.submitHandler, this);
1410
- EventHandler.add(this.submitBtn.element, 'click', this.submitPrevent, this);
1411
- EventHandler.add(this.submitBtn.element, 'keydown', this.btnKeyDownHandler, this);
1412
- }
1413
- if (!isNOU(this.cancelBtn)) {
1414
- EventHandler.add(this.cancelBtn.element, 'mousedown', this.cancelBtnClick, this);
1415
- EventHandler.add(this.cancelBtn.element, 'keydown', this.btnKeyDownHandler, this);
1416
- }
1417
- }
1418
- private cancelBtnClick(e: MouseEvent) : void {
1419
- this.cancelHandler('cancel');
1420
- this.trigger('cancelClick' , e);
1421
- }
1422
- private unWireEvents(): void {
1423
- if (!isNOU(this.editableOn)) {
1424
- this.unWireEditEvent(this.editableOn);
1425
- }
1426
- EventHandler.remove(this.editIcon, 'click', this.clickHandler);
1427
- document.removeEventListener('scroll', this.onScrollResizeHandler);
1428
- window.removeEventListener('resize', this.onScrollResizeHandler);
1429
- EventHandler.remove(this.element, 'keydown', this.valueKeyDownHandler);
1430
- if (Array.prototype.indexOf.call(this.clearComponents, this.type) > -1) {
1431
- EventHandler.remove(this.element, 'mousedown', this.mouseDownHandler);
1432
- }
1433
- }
1434
- private unWireDocEvent(): void {
1435
- EventHandler.remove(document, 'mousedown', this.docClickHandler);
1436
- }
1437
- private unWireEditEvent(event: string): void {
1438
- if (event === 'EditIconClick') {
1439
- return;
1440
- }
1441
- this.element.removeAttribute('title');
1442
- if (Browser.isDevice && Browser.isIos && event === 'DblClick') {
1443
- this.touchModule.destroy();
1444
- this.touchModule = undefined;
1445
- } else {
1446
- EventHandler.remove(this.valueWrap, event.toLowerCase(), this.clickHandler);
1447
- }
1448
- }
1449
- private unWireEditorKeyDownEvent(ele: HTMLElement): void {
1450
- EventHandler.remove(ele, 'keydown', this.enterKeyDownHandler);
1451
- }
1452
- private submitPrevent(e: Event): void {
1453
- e.preventDefault();
1454
- }
1455
- private btnKeyDownHandler(e: KeyboardEvent): void {
1456
- const trg: HTMLElement = <HTMLElement>e.target;
1457
- if ((e.keyCode === 13 && e.which === 13) || (e.keyCode === 32 && e.which === 32)) {
1458
- if (trg.classList.contains(classes.BTN_SAVE)) {
1459
- this.save();
1460
- } else if (trg.classList.contains(classes.BTN_CANCEL)) {
1461
- this.cancelHandler('cancel');
1462
- }
1463
- }
1464
- if (e.keyCode === 9 && e.shiftKey === false &&
1465
- (isNOU((e.target as HTMLElement).nextElementSibling) ||
1466
- (e.target as HTMLElement).nextElementSibling.tagName !== 'BUTTON')) {
1467
- if (this.actionOnBlur === 'Submit') {
1468
- this.save();
1469
- } else if (this.actionOnBlur === 'Cancel') {
1470
- this.cancelHandler('cancel');
1471
- }
1472
- }
1473
- }
1474
- private afterOpenHandler(e: TooltipEventArgs): void {
1475
- if (this.mode === 'Popup' && this.type === 'MultiSelect') {
1476
- EventHandler.add(this.containerEle, 'mousedown', this.popMouseDown, this);
1477
- EventHandler.add(this.containerEle, 'click', this.popClickHandler, this);
1478
- }
1479
- if (this.mode === 'Popup' && !this.isEmpty(this.titleEle.innerHTML)) {
1480
- e.element.classList.add(classes.TIP_TITLE);
1481
- }
1482
- if (this.type === 'RTE') {
1483
- this.rteModule.refresh();
1484
- this.setAttribute(<HTMLElement>select('.e-richtexteditor textarea', this.containerEle), ['name']);
1485
- } else if (this.type === 'Slider') {
1486
- this.sliderModule.refresh();
1487
- this.setAttribute(<HTMLElement>select('.e-slider-input', this.containerEle), ['name']);
1488
- }
1489
- if (!this.beginEditArgs.cancelFocus) {
1490
- if (this.mode === 'Inline' && (['AutoComplete', 'ComboBox', 'DropDownList', 'MultiSelect'].indexOf(this.type) > -1)
1491
- && (this.model as AutoCompleteModel | ComboBoxModel | DropDownListModel
1492
- | MultiSelectModel).dataSource instanceof DataManager) {
1493
- this.showDropDownPopup();
1494
- } else {
1495
- this.setFocus();
1496
- }
1497
- }
1498
- if (this.afterOpenEvent) {
1499
- this.tipObj.setProperties({ afterOpen: this.afterOpenEvent }, true);
1500
- this.tipObj.trigger('afterOpen', e);
1501
- }
1502
- }
1503
- private popMouseDown(e: MouseEvent): void {
1504
- const trgClass: DOMTokenList = (<Element>e.target).classList;
1505
- if (trgClass.contains('e-chips-close') && !trgClass.contains('e-close-hooker')) {
1506
- this.updateArrow();
1507
- }
1508
- }
1509
- private doubleTapHandler(e: TapEventArgs): void {
1510
- if (e.tapCount > 1) {
1511
- this.clickHandler(e.originalEvent);
1512
- }
1513
- }
1514
- private clickHandler(e: MouseEvent): void {
1515
- if (this.editableOn !== 'EditIconClick') {
1516
- e.stopPropagation();
1517
- }
1518
- this.renderEditor();
1519
- }
1520
- private submitHandler(e: MouseEvent): void {
1521
- e.preventDefault();
1522
- this.save();
1523
- this.trigger('submitClick', e);
1524
- }
1525
- private cancelHandler(action: string): void {
1526
- this.triggerEndEdit(action);
1527
- }
1528
- private popClickHandler(e: MouseEvent): void {
1529
- const tipTarget: HTMLElement = <HTMLElement>select('.' + classes.VALUE_WRAPPER, this.element);
1530
- if ((<Element>e.target).classList.contains('e-chips-close')) {
1531
- this.tipObj.refresh(tipTarget);
1532
- }
1533
- }
1534
- private successHandler(e: Object): void {
1535
- this.initRender = false;
1536
- const eventArgs: ActionEventArgs = { data: e, value: this.getSendValue() };
1537
- this.triggerSuccess(eventArgs);
1538
- }
1539
- private failureHandler(e: Object): void {
1540
- const eventArgs: ActionEventArgs = { data: e, value: this.getSendValue() };
1541
- this.trigger('actionFailure', eventArgs, (args: ActionEventArgs) => {
1542
- this.removeSpinner('submit');
1543
- if (this.mode === 'Popup') {
1544
- this.updateArrow();
1545
- }
1546
- });
1547
- }
1548
- private enterKeyDownHandler(e: KeyboardEvent): void {
1549
- if (!closest(e.target as Element, '.' + classes.INPUT + ' .e-richtexteditor') && (!(e.currentTarget as Element).getElementsByTagName("textarea")[0])) {
1550
- if ((e.keyCode === 13 && e.which === 13) && closest(e.target as Element, '.' + classes.INPUT)) {
1551
- this.save();
1552
- this.trigger('submitClick', e);
1553
- } else if (e.keyCode === 27 && e.which === 27) {
1554
- this.cancelHandler('cancel');
1555
- }
1556
- }
1557
- }
1558
- private valueKeyDownHandler(e: KeyboardEvent): void {
1559
- if (e.keyCode === 9 && e.shiftKey === true && (e.target as HTMLElement).tagName !== 'BUTTON') {
1560
- if (this.actionOnBlur === 'Submit') {
1561
- this.save();
1562
- } else if (this.actionOnBlur === 'Cancel') {
1563
- this.cancelHandler('cancel');
1564
- }
1565
- }
1566
- if ((e.keyCode === 13 && e.which === 13) && (e.target as Element).classList.contains(classes.ROOT) &&
1567
- !this.valueWrap.classList.contains(classes.OPEN) && !this.element.classList.contains(classes.DISABLE)) {
1568
- e.preventDefault();
1569
- this.renderEditor();
1570
- }
1571
- }
1572
- private mouseDownHandler(e: Event): void {
1573
- if ((<Element>e.target).classList.contains('e-clear-icon')) {
1574
- this.isClearTarget = true;
1575
- }
1576
- }
1577
- private scrollResizeHandler(): void {
1578
- if (this.mode === 'Popup' && this.tipObj && !(Browser.isDevice)) {
1579
- this.triggerEndEdit('cancel');
1580
- }
1581
- }
1582
- private docClickHandler(e: Event): void {
1583
- const trg: Element = <Element>e.target;
1584
- if (this.isClearTarget) {
1585
- this.isClearTarget = false;
1586
- return;
1587
- }
1588
- const relateRoot: Element = closest(trg, '.' + classes.ROOT);
1589
- const relateTipRoot: Element = closest(trg, '.' + classes.ROOT_TIP);
1590
- const relateElements: Element = closest(trg, '.' + classes.ELEMENTS);
1591
- const relateRTEElements: Element = closest(trg, '.e-rte-elements');
1592
- if ((!isNOU(relateRoot) && relateRoot.isEqualNode(this.element)) ||
1593
- (!isNOU(relateTipRoot) && this.tipObj && (relateTipRoot.id.indexOf(this.valueWrap.id) > -1)) ||
1594
- !isNOU(relateElements) || !isNOU(relateRTEElements) || trg.classList.contains('e-chips-close')) {
1595
- return;
1596
- } else {
1597
- if (this.actionOnBlur === 'Submit') {
1598
- this.save();
1599
- } else if (this.actionOnBlur === 'Cancel') {
1600
- this.cancelHandler('cancel');
1601
- }
1602
- }
1603
- }
1604
- private changeHandler(e: InputChangeEventArgs | ColorPickerEventArgs | MultiSelectChangeEventArgs | SliderChangeEventArgs |
1605
- RangeEventArgs | DropDownsChangeEventArgs): void {
1606
- const eventArgs: ChangeEventArgs = {
1607
- previousValue: this.compPrevValue === undefined ? this.value : this.compPrevValue,
1608
- value: (e as InputChangeEventArgs).value
1609
- };
1610
- if (this.type === 'AutoComplete' || this.type === 'ComboBox' || this.type === 'DropDownList') {
1611
- eventArgs.itemData = (e as DropDownsChangeEventArgs).itemData;
1612
- eventArgs.previousItemData = (e as DropDownsChangeEventArgs).previousItemData;
1613
- }
1614
- this.compPrevValue = eventArgs.value;
1615
- this.trigger('change', eventArgs);
1616
- }
1617
- /**
1618
- * Validate current editor value.
1619
- *
1620
- * @returns {void}
1621
- */
1622
- public validate(): void {
1623
- this.checkValidation(true, false);
1624
- }
1625
- /**
1626
- * Submit the edited input value to the server.
1627
- *
1628
- * @returns {void}
1629
- */
1630
- public save(): void {
1631
- if (!this.formEle) {
1632
- return;
1633
- }
1634
- this.element.focus();
1635
- this.editEle = <HTMLElement>select('.' + classes.INPUT, this.formEle);
1636
- let errEle: HTMLElement = null;
1637
- errEle = <HTMLElement>select('.' + classes.ERROR, this.editEle);
1638
- if (!this.isTemplate) {
1639
- this.setValue();
1640
- }
1641
- const endEditArgs = { cancel: false, mode: this.mode, action: 'submit' };
1642
- this.trigger('endEdit', endEditArgs, (args: EndEditEventArgs) => {
1643
- if (!args.cancel) { this.checkValidation(true, true); }
1644
- });
1645
- }
1646
- /**
1647
- * Removes the control from the DOM and also removes all its related events.
1648
- *
1649
- * @returns {void}
1650
- */
1651
- public destroy(): void {
1652
- this.removeEditor(isBlazor());
1653
- if (this.isExtModule) {
1654
- this.notify(events.destroy, {});
1655
- }
1656
- this.unWireEvents();
1657
- const classList: string[] = [classes.DISABLE, classes.RTL];
1658
- classList.forEach((val: string): void => {
1659
- removeClass([this.element], [val]);
1660
- });
1661
- while (this.element.firstElementChild) {
1662
- this.element.removeChild(this.element.firstElementChild);
1663
- }
1664
- if (!(isBlazor() && this.isServerRendered)) {
1665
- super.destroy();
1666
- }
1667
- if ((this as any).isReact) {
1668
- this.clearTemplate();
1669
- }
1670
- }
1671
- /**
1672
- * Get the properties to be maintained in the persisted state.
1673
- *
1674
- * @returns {string} - returns the string
1675
- */
1676
-
1677
- protected getPersistData(): string {
1678
- return this.addOnPersist(['value']);
1679
- }
1680
- /**
1681
- * To provide the array of modules needed for component rendering
1682
- *
1683
- * @returns {ModuleDeclaration[]} - returns the module declaration
1684
- * @hidden
1685
- */
1686
- public requiredModules(): ModuleDeclaration[] {
1687
- const modules: ModuleDeclaration[] = [];
1688
- if (Array.prototype.indexOf.call(this.moduleList, this.type) > -1) {
1689
- modules.push({ member: modulesList[this.type], args: [this] });
1690
- }
1691
- return modules;
1692
- }
1693
- /**
1694
- * Returns the current module name.
1695
- *
1696
- * @returns {string} - returrns the string
1697
- * @private
1698
- */
1699
- protected getModuleName(): string {
1700
- return 'inplaceeditor';
1701
- }
1702
- /**
1703
- * Gets called when the model property changes.The data that describes the old and new values of property that changed.
1704
- *
1705
- * @param {InPlaceEditorModel} newProp - specifies the new property
1706
- * @param {InPlaceEditorModel} oldProp - specifies the old property
1707
- * @returns {void}
1708
- * @private
1709
- */
1710
- public onPropertyChanged(newProp: InPlaceEditorModel, oldProp: InPlaceEditorModel): void {
1711
- let checkValidation: boolean = this.validationRules ? !isNOU(this.element.querySelectorAll('.' + classes.ERROR)) &&
1712
- this.element.querySelectorAll('.' + classes.ERROR).length > 0 ? false : true : true;
1713
- if (checkValidation) {
1714
- if (this.isEditorOpen()) {
1715
- const editModeChanged: boolean = 'enableEditMode' in newProp;
1716
- if ((editModeChanged && oldProp.enableEditMode && !newProp.enableEditMode) || (!editModeChanged && this.enableEditMode)) {
1717
- this.triggerEndEdit('cancel');
1718
- } else { this.removeEditor(); }
1719
- }
1720
- for (const prop of Object.keys(newProp)) {
1721
- switch (prop) {
1722
- case 'showButtons':
1723
- (newProp.showButtons) ? this.appendButtons(this.formEle) : this.destroyButtons();
1724
- break;
1725
- case 'value':
1726
- this.updateValue();
1727
- this.textOption === 'Never' ? this.renderValue(this.checkValue(parseValue(this.type, this.value, this.model)))
1728
- : this.renderInitialValue();
1729
- break;
1730
- case 'emptyText':
1731
- this.textOption === 'Never' ? this.renderValue(this.checkValue(parseValue(this.type, this.value, this.model)))
1732
- : this.renderInitialValue();
1733
- break;
1734
- case 'template':
1735
- this.checkIsTemplate();
1736
- break;
1737
- case 'disabled':
1738
- this.disable(newProp.disabled);
1739
- newProp.disabled ? this.element.tabIndex = -1 : this.element.tabIndex = 0;
1740
- break;
1741
- case 'enableRtl':
1742
- this.setRtl(newProp.enableRtl);
1743
- break;
1744
- case 'cssClass':
1745
- this.setClass('remove', oldProp.cssClass);
1746
- this.setClass('add', newProp.cssClass);
1747
- break;
1748
- case 'mode':
1749
- this.enableEditor(this.enableEditMode);
1750
- break;
1751
- case 'enableEditMode':
1752
- this.enableEditor(newProp.enableEditMode);
1753
- break;
1754
- case 'editableOn':
1755
- this.unWireEditEvent(oldProp.editableOn);
1756
- if (newProp.editableOn !== 'EditIconClick') { this.wireEditEvent(newProp.editableOn); }
1757
- break;
1758
- }
1759
- }
1760
- }
1761
- }
1762
- }