diff --git a/packages/devextreme/js/__internal/core/widget/widget.ts b/packages/devextreme/js/__internal/core/widget/widget.ts index 63256a2b1cab..b353adf61e52 100644 --- a/packages/devextreme/js/__internal/core/widget/widget.ts +++ b/packages/devextreme/js/__internal/core/widget/widget.ts @@ -676,7 +676,7 @@ class Widget< focus.trigger(this._focusTarget()); } - registerKeyHandler(key: string, handler: () => void): void { + registerKeyHandler(key: string, handler: (event?) => void): void { const currentKeys = this._supportedKeys(); // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @stylistic/max-len diff --git a/packages/devextreme/js/__internal/ui/chat/messagebox.ts b/packages/devextreme/js/__internal/ui/chat/messagebox.ts index b2c236b368a3..4260a1d5595b 100644 --- a/packages/devextreme/js/__internal/ui/chat/messagebox.ts +++ b/packages/devextreme/js/__internal/ui/chat/messagebox.ts @@ -6,10 +6,9 @@ import Button from '@js/ui/button'; import type { Properties as DOMComponentProperties } from '@ts/core/widget/dom_component'; import DOMComponent from '@ts/core/widget/dom_component'; import type { OptionChanged } from '@ts/core/widget/types'; +import TextArea from '@ts/ui/m_text_area'; import type { EnterKeyEvent, InputEvent } from '../../../ui/text_area'; -import type dxTextArea from '../../../ui/text_area'; -import TextArea from '../m_text_area'; const CHAT_MESSAGEBOX_CLASS = 'dx-chat-messagebox'; const CHAT_MESSAGEBOX_TEXTAREA_CLASS = 'dx-chat-messagebox-textarea'; @@ -38,7 +37,7 @@ export interface Properties extends DOMComponentProperties { } class MessageBox extends DOMComponent { - _textArea!: dxTextArea; + _textArea!: TextArea; _button!: Button; diff --git a/packages/devextreme/js/__internal/ui/color_box/m_color_box.ts b/packages/devextreme/js/__internal/ui/color_box/m_color_box.ts index 58e71de51e23..d3c682be812b 100644 --- a/packages/devextreme/js/__internal/ui/color_box/m_color_box.ts +++ b/packages/devextreme/js/__internal/ui/color_box/m_color_box.ts @@ -1,9 +1,14 @@ import Color from '@js/color'; import registerComponent from '@js/core/component_registrator'; +import type { dxElementWrapper } from '@js/core/renderer'; import $ from '@js/core/renderer'; -import { extend } from '@js/core/utils/extend'; +import type { Properties } from '@js/ui/color_box'; +import type { OptionChanged } from '@ts/core/widget/types'; import DropDownEditor from '@ts/ui/drop_down_editor/m_drop_down_editor'; +import type { PopupProperties } from '../popup/m_popup'; +import type Popup from '../popup/m_popup'; +import type { ColorViewProperties } from './m_color_view'; import ColorView from './m_color_view'; const COLOR_BOX_CLASS = 'dx-colorbox'; @@ -25,10 +30,27 @@ const colorUtils = { makeRgba: colorEditorPrototype._makeRgba.bind(colorEditorPrototype), }; -const ColorBox = (DropDownEditor as any).inherit({ +export interface ColorBoxProperties extends Omit { +} - _supportedKeys() { - // @ts-expect-error +class ColorBox extends DropDownEditor { + _popup!: Popup; + + _colorView!: ColorView; + + _colorViewEnterKeyPressed?: boolean; + + _shouldSaveEmptyValue?: boolean; + + _$colorResultPreview!: dxElementWrapper; + + _$colorBoxInputContainer!: dxElementWrapper; + + _supportedKeys(): Record boolean | undefined> { + // @ts-expect-error ts-error const arrowHandler = function (e) { e.stopPropagation(); if (this.option('opened')) { @@ -61,48 +83,50 @@ const ColorBox = (DropDownEditor as any).inherit({ return true; }; - return extend(this.callBase(), { + return { + ...super._supportedKeys(), enter: this._enterKeyHandler, leftArrow: arrowHandler, rightArrow: arrowHandler, upArrow: upArrowHandler, downArrow: downArrowHandler, - }); - }, + }; + } - _getDefaultOptions() { - return extend(this.callBase(), { + _getDefaultOptions(): ColorBoxProperties { + return { + ...super._getDefaultOptions(), editAlphaChannel: false, - applyValueMode: 'useButtons', - keyStep: 1, - + // @ts-expect-error ts-error fieldTemplate: null, - buttonsLocation: 'bottom after', - }); - }, + }; + } - _popupHidingHandler() { - this.callBase(); - if (this.option('applyValueMode') === 'useButtons') { + _popupHidingHandler(): void { + super._popupHidingHandler(); + const { applyValueMode } = this.option(); + + if (applyValueMode === 'useButtons') { this._updateColorViewValue(this.option('value')); } - }, + } - _popupConfig() { - return extend(this.callBase(), { + _popupConfig(): PopupProperties { + return { + ...super._popupConfig(), width: '', - }); - }, + }; + } - _contentReadyHandler() { + _contentReadyHandler(): void { this._createColorView(); this._addPopupBottomClasses(); - }, + } - _addPopupBottomClasses() { + _addPopupBottomClasses(): void { const $popupBottom = this._popup.bottomToolbar(); if ($popupBottom) { $popupBottom @@ -119,17 +143,17 @@ const ColorBox = (DropDownEditor as any).inherit({ .find('.dx-popup-cancel') .addClass(COLOR_BOX_CANCEL_BUTTON_CLASS); } - }, + } - _createColorView() { + _createColorView(): void { this._popup.$overlayContent().addClass(COLOR_BOX_OVERLAY_CLASS); const $colorView = $('
').appendTo(this._popup.$content()); this._colorView = this._createComponent($colorView, ColorView, this._colorViewConfig()); - }, + } - _applyNewColor(value) { + _applyNewColor(value): void { this.option('value', value); if (value) { @@ -140,18 +164,26 @@ const ColorBox = (DropDownEditor as any).inherit({ this.close(); this._colorViewEnterKeyPressed = false; } - }, + } + + _colorViewConfig(): ColorViewProperties { + const { + editAlphaChannel, + value, + applyValueMode, + focusStateEnabled, + stylingMode, + } = this.option(); - _colorViewConfig() { const that = this; return { - value: that.option('value'), - matchValue: that.option('value'), - editAlphaChannel: that.option('editAlphaChannel'), - applyValueMode: that.option('applyValueMode'), - focusStateEnabled: that.option('focusStateEnabled'), - stylingMode: this.option('stylingMode'), + value, + matchValue: value, + editAlphaChannel, + applyValueMode, + focusStateEnabled, + stylingMode, target: this._input(), onEnterKeyPressed({ event }) { that._colorViewEnterKeyPressed = true; @@ -163,6 +195,7 @@ const ColorBox = (DropDownEditor as any).inherit({ }, onValueChanged({ event, value, previousValue }) { + // @ts-expect-error ts-error const instantlyMode = that.option('applyValueMode') === 'instantly'; const isOldValue = colorUtils.makeRgba(value) === previousValue; const changesApplied = instantlyMode || that._colorViewEnterKeyPressed; @@ -173,12 +206,13 @@ const ColorBox = (DropDownEditor as any).inherit({ } if (event) { + // @ts-expect-error ts-error that._saveValueChangeEvent(event); } that._applyNewColor(value); }, }; - }, + } _enterKeyHandler(e) { const newValue = this._input().val(); @@ -193,7 +227,7 @@ const ColorBox = (DropDownEditor as any).inherit({ this._input().val(oldValue); return; } - + // @ts-expect-error ts-error if (newValue !== oldValue) { this._applyColorFromInput(newValue); this._saveValueChangeEvent(e); @@ -202,6 +236,7 @@ const ColorBox = (DropDownEditor as any).inherit({ if (this._colorView) { const colorViewValue = this._colorView.option('value'); + if (value !== colorViewValue) { this._saveValueChangeEvent(e); this.option('value', colorViewValue); @@ -210,42 +245,42 @@ const ColorBox = (DropDownEditor as any).inherit({ this.close(); return false; - }, + } - _applyButtonHandler(e) { + _applyButtonHandler(e): void { this._saveValueChangeEvent(e.event); this._applyNewColor(this._colorView.option('value')); - this.callBase(); - }, + super._applyButtonHandler(); + } - _cancelButtonHandler() { + _cancelButtonHandler(): void { this._resetInputValue(); - this.callBase(); - }, + super._cancelButtonHandler(); + } _getKeyboardListeners() { - return this.callBase().concat([this._colorView]); - }, + return super._getKeyboardListeners().concat([this._colorView]); + } - _init() { - this.callBase(); - }, + _init(): void { + super._init(); + } - _initMarkup() { + _initMarkup(): void { this.$element().addClass(COLOR_BOX_CLASS); - this.callBase(); - }, + super._initMarkup(); + } - _renderInput() { - this.callBase(); + _renderInput(): void { + super._renderInput(); this._input().addClass(COLOR_BOX_INPUT_CLASS); this._renderColorPreview(); - }, + } - _renderColorPreview() { + _renderColorPreview(): void { this.$element().wrapInner($('
').addClass(COLOR_BOX_INPUT_CONTAINER_CLASS)); this._$colorBoxInputContainer = this.$element().children().eq(0); @@ -258,7 +293,7 @@ const ColorBox = (DropDownEditor as any).inherit({ } else { colorUtils.makeTransparentBackground(this._$colorResultPreview, this.option('value')); } - }, + } _renderValue() { const { value, editAlphaChannel } = this.option(); @@ -267,27 +302,27 @@ const ColorBox = (DropDownEditor as any).inherit({ this.option('text', text); - return this.callBase(); - }, + return super._renderValue(); + } - _resetInputValue() { + _resetInputValue(): void { const $input = this._input(); const value = this.option('value'); - + // @ts-expect-error ts-error $input.val(value); this._updateColorViewValue(value); - }, + } - _updateColorViewValue(value) { + _updateColorViewValue(value): void { if (this._colorView) { this._colorView.option({ value, matchValue: value, }); } - }, + } - _valueChangeEventHandler(e) { + _valueChangeEventHandler(e): void { let value = this._input().val(); if (value) { @@ -295,8 +330,8 @@ const ColorBox = (DropDownEditor as any).inherit({ this._updateColorViewValue(value); } - this.callBase(e, value); - }, + super._valueChangeEventHandler(e, value); + } _applyColorFromInput(value) { const { editAlphaChannel } = this.option(); @@ -312,14 +347,14 @@ const ColorBox = (DropDownEditor as any).inherit({ } return value; - }, + } - _clean() { - this.callBase(); + _clean(): void { + super._clean(); delete this._shouldSaveEmptyValue; - }, + } - _optionChanged(args) { + _optionChanged(args: OptionChanged): void { const { name, value } = args; switch (name) { @@ -338,11 +373,11 @@ const ColorBox = (DropDownEditor as any).inherit({ this._updateColorViewValue(value); this._shouldSaveEmptyValue = false; - this.callBase(args); + super._optionChanged(args); break; case 'applyButtonText': case 'cancelButtonText': - this.callBase(args); + super._optionChanged(args); this._popup && this._addPopupBottomClasses(); break; case 'editAlphaChannel': @@ -352,10 +387,10 @@ const ColorBox = (DropDownEditor as any).inherit({ } break; default: - this.callBase(args); + super._optionChanged(args); } - }, -}); + } +} registerComponent('dxColorBox', ColorBox); diff --git a/packages/devextreme/js/__internal/ui/color_box/m_color_view.ts b/packages/devextreme/js/__internal/ui/color_box/m_color_view.ts index a7888615b3ef..8d20dce51863 100644 --- a/packages/devextreme/js/__internal/ui/color_box/m_color_view.ts +++ b/packages/devextreme/js/__internal/ui/color_box/m_color_view.ts @@ -1,4 +1,5 @@ import Color from '@js/color'; +import type { ApplyValueMode } from '@js/common'; import { locate, move } from '@js/common/core/animation/translator'; import { name as clickEventName } from '@js/common/core/events/click'; import eventsEngine from '@js/common/core/events/core/events_engine'; @@ -7,13 +8,17 @@ import messageLocalization from '@js/common/core/localization/message'; import registerComponent from '@js/core/component_registrator'; import devices from '@js/core/devices'; import Guid from '@js/core/guid'; +import type { DefaultOptionsRule } from '@js/core/options/utils'; +import type { dxElementWrapper } from '@js/core/renderer'; import $ from '@js/core/renderer'; import { extend } from '@js/core/utils/extend'; import { getHeight, getOuterHeight, getWidth } from '@js/core/utils/size'; import Draggable from '@js/ui/draggable'; -import Editor from '@js/ui/editor/editor'; -import NumberBox from '@js/ui/number_box'; -import TextBox from '@js/ui/text_box'; +import type { OptionChanged } from '@ts/core/widget/types'; +import type { EditorProperties } from '@ts/ui/editor/editor'; +import Editor from '@ts/ui/editor/editor'; +import NumberBox from '@ts/ui/number_box/m_number_box'; +import TextBox from '@ts/ui/text_box/m_text_box'; const COLOR_VIEW_CLASS = 'dx-colorview'; const COLOR_VIEW_CONTAINER_CLASS = 'dx-colorview-container'; @@ -58,16 +63,89 @@ const TEXT_EDITOR_INPUT = 'dx-texteditor-input'; const BLACK_COLOR = '#000000'; -const ColorView = (Editor as any).inherit({ +export interface ColorViewProperties extends EditorProperties { + keyStep?: number; - _supportedKeys() { + matchValue?: string; + + editAlphaChannel?: boolean; + + onEnterKeyPressed?: (event?) => void; + + applyValueMode?: ApplyValueMode; + + target?: string | Element | dxElementWrapper | null; +} + +class ColorView extends Editor { + _$palette!: dxElementWrapper; + + _$paletteHandle?: dxElementWrapper; + + _paletteWidth!: number; + + _paletteHeight!: number; + + _paletteHandleWidth!: number; + + _paletteHandleHeight!: number; + + _updateByDrag?: boolean; + + _currentColor!: any; + + _isTopColorHue?: boolean; + + _$colorPickerContainer!: dxElementWrapper; + + _$hueScale?: dxElementWrapper; + + _$hueScaleHandle?: dxElementWrapper; + + _$hueScaleWrapper?: dxElementWrapper; + + _hueScaleHeight?: number; + + _hueScaleWrapperHeight!: number; + + _hueScaleHandleHeight!: number; + + _suppressEditorsValueUpdating?: boolean; + + _$alphaChannelHandle?: dxElementWrapper; + + _$controlsContainer!: dxElementWrapper; + + _$alphaChannelScale?: dxElementWrapper; + + _alphaChannelInput!: NumberBox; + + _rgbInputs!: NumberBox[]; + + _hexInput!: TextBox; + + _$currentColor?: dxElementWrapper; + + _$baseColor?: dxElementWrapper; + + _alphaChannelScaleWorkWidth!: number; + + _alphaChannelHandleWidth!: number; + + _rgbInputsWithLabels?: dxElementWrapper[]; + + _onEnterKeyPressedAction?: (event: Record) => void; + + _supportedKeys(): Record) => void> { const isRTL = this.option('rtlEnabled'); const that = this; const getHorizontalPaletteStep = function (e) { let step = 100 / that._paletteWidth; if (e.shiftKey) { - step *= that.option('keyStep'); + const { keyStep } = that.option(); + // @ts-expect-error ts-error + step *= keyStep; } step = step > 1 ? step : 1; @@ -88,7 +166,9 @@ const ColorView = (Editor as any).inherit({ const getVerticalPaletteStep = function (e) { let step = 100 / that._paletteHeight; if (e.shiftKey) { - step *= that.option('keyStep'); + const { keyStep } = that.option(); + // @ts-expect-error ts-error + step *= keyStep; } step = step > 1 ? step : 1; @@ -117,7 +197,9 @@ const ColorView = (Editor as any).inherit({ const getHueScaleStep = function (e) { let step = 360 / (that._hueScaleWrapperHeight - that._hueScaleHandleHeight); if (e.shiftKey) { - step *= that.option('keyStep'); + const { keyStep } = that.option(); + // @ts-expect-error ts-error + step *= keyStep; } step = step > 1 ? step : 1; @@ -132,7 +214,9 @@ const ColorView = (Editor as any).inherit({ const getAlphaScaleStep = function (e) { let step = 1 / that._alphaChannelScaleWorkWidth; if (e.shiftKey) { - step *= that.option('keyStep'); + const { keyStep } = that.option(); + // @ts-expect-error ts-error + step *= keyStep; } step = step > 0.01 ? step : 0.01; @@ -146,8 +230,9 @@ const ColorView = (Editor as any).inherit({ that._calculateColorTransparencyByScaleWidth(handleLocation.left + that._alphaChannelHandleWidth / 2); }; - return extend(this.callBase(), { - upArrow(e) { + return { + ...super._supportedKeys(), + upArrow(e): void { e.preventDefault(); e.stopPropagation(); if (isCommandKeyPressed(e)) { @@ -160,7 +245,7 @@ const ColorView = (Editor as any).inherit({ updateVerticalPaletteValue(getVerticalPaletteStep(e)); } }, - downArrow(e) { + downArrow(e): void { e.preventDefault(); e.stopPropagation(); if (isCommandKeyPressed(e)) { @@ -177,7 +262,7 @@ const ColorView = (Editor as any).inherit({ updateVerticalPaletteValue(-getVerticalPaletteStep(e)); } }, - rightArrow(e) { + rightArrow(e): void { e.preventDefault(); e.stopPropagation(); if (isCommandKeyPressed(e)) { @@ -190,7 +275,7 @@ const ColorView = (Editor as any).inherit({ updateHorizontalPaletteValue(getHorizontalPaletteStep(e)); } }, - leftArrow(e) { + leftArrow(e): void { e.preventDefault(); e.stopPropagation(); if (isCommandKeyPressed(e)) { @@ -203,27 +288,29 @@ const ColorView = (Editor as any).inherit({ updateHorizontalPaletteValue(-getHorizontalPaletteStep(e)); } }, - enter(e) { + enter(e): void { this._fireEnterKeyPressed(e); }, - }); - }, + }; + } - _getDefaultOptions() { - return extend(this.callBase(), { + _getDefaultOptions(): ColorViewProperties { + return { + ...super._getDefaultOptions(), value: null, + // @ts-expect-error ts-error matchValue: null, onEnterKeyPressed: undefined, editAlphaChannel: false, keyStep: 1, stylingMode: undefined, - }); - }, + }; + } - _defaultOptionsRules() { - return this.callBase().concat([ + _defaultOptionsRules(): DefaultOptionsRule[] { + return super._defaultOptionsRules().concat([ { - device() { + device(): boolean { return devices.real().deviceType === 'desktop' && !devices.isSimulator(); }, options: { @@ -231,30 +318,30 @@ const ColorView = (Editor as any).inherit({ }, }, ]); - }, + } - _init() { - this.callBase(); + _init(): void { + super._init(); this._initColorAndOpacity(); this._initEnterKeyPressedAction(); - }, + } - _initEnterKeyPressedAction() { + _initEnterKeyPressedAction(): void { this._onEnterKeyPressedAction = this._createActionByOption('onEnterKeyPressed'); - }, + } _fireEnterKeyPressed(e) { if (!this._onEnterKeyPressedAction) return; this._onEnterKeyPressedAction({ event: e, }); - }, + } - _initColorAndOpacity() { + _initColorAndOpacity(): void { this._setCurrentColor(this.option('value')); - }, + } - _setCurrentColor(value) { + _setCurrentColor(value): void { value = value || BLACK_COLOR; const newColor = new Color(value); if (!newColor.colorIsInvalid) { @@ -270,57 +357,55 @@ const ColorView = (Editor as any).inherit({ } this.option('value', this._currentColor.baseColor); } - }, + } - _setBaseColor(value) { + _setBaseColor(value): void { const color = value || BLACK_COLOR; const newColor = new Color(color); if (!newColor.colorIsInvalid) { - const isBaseColorChanged = this._makeRgba(this.option('matchValue') !== this._makeRgba(newColor)); + const { matchValue } = this.option(); + + const isBaseColorChanged = this._makeRgba(matchValue !== this._makeRgba(newColor)); if (isBaseColorChanged) { if (this._$baseColor) { this._makeTransparentBackground(this._$baseColor, newColor); } } } - }, + } - _initMarkup() { - this.callBase(); + _initMarkup(): void { + super._initMarkup(); this.$element().addClass(COLOR_VIEW_CLASS); this._renderColorPickerContainer(); - }, + } - _render() { - this.callBase(); + _render(): void { + super._render(); this._renderPalette(); this._renderHueScale(); this._renderControlsContainer(); this._renderControls(); this._renderAlphaChannelElements(); - }, + } - _makeTransparentBackground($el, color) { + _makeTransparentBackground($el, color): void { if (!(color instanceof Color)) { color = new Color(color); } $el.css('backgroundColor', this._makeRgba(color)); - }, + } - _makeRgba(color) { + _makeRgba(color): string { if (!(color instanceof Color)) { color = new Color(color); } return `rgba(${[color.r, color.g, color.b, color.a].join(', ')})`; - }, - - _renderValue() { - this.callBase(this.option('editAlphaChannel') ? this._makeRgba(this._currentColor) : this.option('value')); - }, + } _renderColorPickerContainer() { const $parent = this.$element(); @@ -328,10 +413,10 @@ const ColorView = (Editor as any).inherit({ .appendTo($parent); this._renderHtmlRows(); - }, + } // eslint-disable-next-line @typescript-eslint/no-unused-vars - _renderHtmlRows(updatedOption) { + _renderHtmlRows(updatedOption?): void { const $renderedRows = this._$colorPickerContainer.find(`.${COLOR_VIEW_ROW_CLASS}`); const renderedRowsCount = $renderedRows.length; const rowCount = this.option('editAlphaChannel') ? 2 : 1; @@ -354,19 +439,20 @@ const ColorView = (Editor as any).inherit({ $renderedRows.eq(0).after(rows[i]); } } else { + // @ts-expect-error ts-error this._$colorPickerContainer.append(rows); } } - }, + } - _renderHtmlCellInsideRow(index, $rowParent, additionalClass) { + _renderHtmlCellInsideRow(index, $rowParent, additionalClass?): dxElementWrapper { return $('
') .addClass(COLOR_VIEW_CELL_CLASS) .addClass(additionalClass) .appendTo($rowParent.find(`.${COLOR_VIEW_ROW_CLASS}`).eq(index)); - }, + } - _renderPalette() { + _renderPalette(): void { const $paletteCell = this._renderHtmlCellInsideRow(0, this._$colorPickerContainer, COLOR_VIEW_PALETTE_CELL_CLASS); const $paletteGradientWhite = $('
').addClass([COLOR_VIEW_PALETTE_GRADIENT_CLASS, COLOR_VIEW_PALETTE_GRADIENT_WHITE_CLASS].join(' ')); const $paletteGradientBlack = $('
').addClass([COLOR_VIEW_PALETTE_GRADIENT_CLASS, COLOR_VIEW_PALETTE_GRADIENT_BLACK_CLASS].join(' ')); @@ -380,10 +466,11 @@ const ColorView = (Editor as any).inherit({ this._paletteWidth = getWidth(this._$palette); this._renderPaletteHandle(); + // @ts-expect-error ts-error this._$palette.append([$paletteGradientWhite, $paletteGradientBlack]); - }, + } - _renderPaletteHandle() { + _renderPaletteHandle(): void { this._$paletteHandle = $('
') .addClass(COLOR_VIEW_PALETTE_HANDLE_CLASS) .appendTo(this._$palette); @@ -420,34 +507,34 @@ const ColorView = (Editor as any).inherit({ this._paletteHandleHeight = getHeight(this._$paletteHandle); this._placePaletteHandle(); - }, + } - _placePaletteHandle() { + _placePaletteHandle(): void { move(this._$paletteHandle, { left: Math.round(this._paletteWidth * this._currentColor.hsv.s / 100 - this._paletteHandleWidth / 2), top: Math.round(this._paletteHeight - (this._paletteHeight * this._currentColor.hsv.v / 100) - this._paletteHandleHeight / 2), }); - }, + } - _calculateColorValue(paletteHandlePosition) { + _calculateColorValue(paletteHandlePosition): number { const value = Math.floor(paletteHandlePosition.top + this._paletteHandleHeight / 2); return 100 - Math.round(value * 100 / this._paletteHeight); - }, + } - _calculateColorSaturation(paletteHandlePosition) { + _calculateColorSaturation(paletteHandlePosition): number { const saturation = Math.floor(paletteHandlePosition.left + this._paletteHandleWidth / 2); return Math.round(saturation * 100 / this._paletteWidth); - }, + } - _updateColorFromHsv(hue, saturation, value) { + _updateColorFromHsv(hue, saturation, value): void { const { a } = this._currentColor; this._currentColor = new Color(`hsv(${[hue, saturation, value].join(',')})`); this._currentColor.a = a; this._updateColorParamsAndColorPreview(); this.applyColor(); - }, + } - _renderHueScale() { + _renderHueScale(): void { const $hueScaleCell = this._renderHtmlCellInsideRow(0, this._$colorPickerContainer, COLOR_VIEW_HUE_SCALE_CELL_CLASS); this._$hueScaleWrapper = $('
') @@ -462,11 +549,12 @@ const ColorView = (Editor as any).inherit({ this._hueScaleWrapperHeight = getOuterHeight(this._$hueScaleWrapper); this._renderHueScaleHandle(); - }, + } - _renderHueScaleHandle() { + _renderHueScaleHandle(): void { this._$hueScaleHandle = $('
') .addClass(COLOR_VIEW_HUE_SCALE_HANDLE_CLASS) + // @ts-expect-error ts-error .appendTo(this._$hueScaleWrapper); this._createComponent(this._$hueScaleHandle, Draggable, { contentTemplate: null, @@ -483,9 +571,9 @@ const ColorView = (Editor as any).inherit({ this._hueScaleHandleHeight = getHeight(this._$hueScaleHandle); this._placeHueScaleHandle(); - }, + } - _placeHueScaleHandle() { + _placeHueScaleHandle(): void { const hueScaleHeight = this._hueScaleWrapperHeight; const handleHeight = this._hueScaleHandleHeight; let top = (hueScaleHeight - handleHeight) * (360 - this._currentColor.hsv.h) / 360; @@ -498,9 +586,9 @@ const ColorView = (Editor as any).inherit({ } move(this._$hueScaleHandle, { top: Math.round(top) }); - }, + } - _updateColorHue(handlePosition) { + _updateColorHue(handlePosition): void { let hue = 360 - Math.round((handlePosition - this._hueScaleHandleHeight / 2) * 360 / (this._hueScaleWrapperHeight - this._hueScaleHandleHeight)); const saturation = this._currentColor.hsv.s; const value = this._currentColor.hsv.v; @@ -516,22 +604,22 @@ const ColorView = (Editor as any).inherit({ this._updateColorFromHsv(hue, saturation, value); this._$palette.css('backgroundColor', this._currentColor.getPureColor().toHex()); - }, + } - _renderControlsContainer() { + _renderControlsContainer(): void { const $controlsContainerCell = this._renderHtmlCellInsideRow(0, this._$colorPickerContainer); this._$controlsContainer = $('
') .addClass(COLOR_VIEW_CONTROLS_CONTAINER_CLASS) .appendTo($controlsContainerCell); - }, + } - _renderControls() { + _renderControls(): void { this._renderColorsPreview(); this._renderRgbInputs(); this._renderHexInput(); - }, + } - _renderColorsPreview() { + _renderColorsPreview(): void { const $colorsPreviewContainer = $('
') .addClass(COLOR_VIEW_COLOR_PREVIEW_CONTAINER_CLASS) .appendTo(this._$controlsContainer); @@ -548,7 +636,7 @@ const ColorView = (Editor as any).inherit({ // @ts-expect-error $colorsPreviewContainerInner.append([this._$baseColor, this._$currentColor]); - }, + } _renderAlphaChannelElements() { if (this.option('editAlphaChannel')) { @@ -560,9 +648,9 @@ const ColorView = (Editor as any).inherit({ this._renderAlphaChannelScale(); this._renderAlphaChannelInput(); } - }, + } - _renderRgbInputs() { + _renderRgbInputs(): void { this._rgbInputsWithLabels = [ this._renderEditorWithLabel({ editorType: NumberBox, @@ -590,16 +678,20 @@ const ColorView = (Editor as any).inherit({ }), ]; + // @ts-expect-error ts-error this._$controlsContainer.append(this._rgbInputsWithLabels); this._rgbInputs = [ + // @ts-expect-error ts-error this._rgbInputsWithLabels[0].find('.dx-numberbox').dxNumberBox('instance'), + // @ts-expect-error ts-error this._rgbInputsWithLabels[1].find('.dx-numberbox').dxNumberBox('instance'), + // @ts-expect-error ts-error this._rgbInputsWithLabels[2].find('.dx-numberbox').dxNumberBox('instance'), ]; - }, + } - _renderEditorWithLabel(options) { + _renderEditorWithLabel(options): dxElementWrapper { const $editor = $('
'); const $label = $('