@progress/kendo-react-inputs 4.11.0-dev.202111060921 → 4.11.0-dev.202111151049
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.
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/dist/es/colors/ColorGradient.d.ts +5 -0
- package/dist/es/colors/ColorGradient.js +10 -1
- package/dist/es/colors/ColorInput.js +1 -1
- package/dist/es/colors/ColorPalette.d.ts +1 -0
- package/dist/es/colors/ColorPalette.js +5 -1
- package/dist/es/colors/FlatColorPicker.d.ts +71 -0
- package/dist/es/colors/FlatColorPicker.js +105 -0
- package/dist/es/colors/interfaces/ColorGradientProps.d.ts +4 -0
- package/dist/es/colors/interfaces/ColorPaletteProps.d.ts +4 -0
- package/dist/es/main.d.ts +1 -0
- package/dist/es/main.js +1 -0
- package/dist/es/messages/index.d.ts +10 -0
- package/dist/es/messages/index.js +10 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/npm/colors/ColorGradient.d.ts +5 -0
- package/dist/npm/colors/ColorGradient.js +10 -1
- package/dist/npm/colors/ColorInput.js +1 -1
- package/dist/npm/colors/ColorPalette.d.ts +1 -0
- package/dist/npm/colors/ColorPalette.js +5 -1
- package/dist/npm/colors/FlatColorPicker.d.ts +71 -0
- package/dist/npm/colors/FlatColorPicker.js +107 -0
- package/dist/npm/colors/interfaces/ColorGradientProps.d.ts +4 -0
- package/dist/npm/colors/interfaces/ColorPaletteProps.d.ts +4 -0
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +1 -0
- package/dist/npm/messages/index.d.ts +10 -0
- package/dist/npm/messages/index.js +10 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-react-inputs.js +1 -1
- package/package.json +11 -11
|
@@ -37,6 +37,7 @@ export declare class ColorGradient extends React.Component<ColorGradientProps, C
|
|
|
37
37
|
defaultValue: PropTypes.Requireable<string>;
|
|
38
38
|
value: PropTypes.Requireable<string>;
|
|
39
39
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
41
|
opacity: PropTypes.Requireable<boolean>;
|
|
41
42
|
backgroundColor: PropTypes.Requireable<string>;
|
|
42
43
|
disabled: PropTypes.Requireable<boolean>;
|
|
@@ -123,6 +124,10 @@ export declare class ColorGradient extends React.Component<ColorGradientProps, C
|
|
|
123
124
|
* @hidden
|
|
124
125
|
*/
|
|
125
126
|
dispatchChangeEvent(value: string, syntheticEvent: React.SyntheticEvent<any>, nativeEvent: any): void;
|
|
127
|
+
/**
|
|
128
|
+
* @hidden
|
|
129
|
+
*/
|
|
130
|
+
onFocus: (nativeEvent: any) => void;
|
|
126
131
|
/**
|
|
127
132
|
* @hidden
|
|
128
133
|
*/
|
|
@@ -113,6 +113,14 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
113
113
|
var hsva = Object.assign({}, _this.state.hsva, { s: left / gradientRectMetrics.width, v: 1 - top / gradientRectMetrics.height });
|
|
114
114
|
_this.handleHsvaChange(hsva, event, event.nativeEvent);
|
|
115
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* @hidden
|
|
118
|
+
*/
|
|
119
|
+
_this.onFocus = function (nativeEvent) {
|
|
120
|
+
if (_this.props.onFocus) {
|
|
121
|
+
_this.props.onFocus.call(undefined, { nativeEvent: nativeEvent, target: _this });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
116
124
|
/**
|
|
117
125
|
* @hidden
|
|
118
126
|
*/
|
|
@@ -237,7 +245,7 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
237
245
|
ColorGradient.prototype.render = function () {
|
|
238
246
|
var _this = this;
|
|
239
247
|
var className = classNames('k-colorgradient', { 'k-state-disabled': this.props.disabled });
|
|
240
|
-
return (React.createElement("div", { id: this.props.id, className: className, "aria-disabled": this.props.disabled ? 'true' : undefined, style: this.props.style, ref: function (el) { return _this.wrapper = el; }, tabIndex: getTabIndex(this.props.tabIndex, this.props.disabled), "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy },
|
|
248
|
+
return (React.createElement("div", { id: this.props.id, className: className, "aria-disabled": this.props.disabled ? 'true' : undefined, style: this.props.style, ref: function (el) { return _this.wrapper = el; }, tabIndex: getTabIndex(this.props.tabIndex, this.props.disabled), "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy, onFocus: this.onFocus },
|
|
241
249
|
React.createElement("div", { className: "k-colorgradient-canvas k-hstack" },
|
|
242
250
|
React.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } },
|
|
243
251
|
React.createElement(Draggable, { onDrag: this.onDrag, onRelease: this.onRelease, ref: function (el) { return _this.gradientWrapper = el ? el.element : undefined; } },
|
|
@@ -258,6 +266,7 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
258
266
|
defaultValue: PropTypes.string,
|
|
259
267
|
value: PropTypes.string,
|
|
260
268
|
onChange: PropTypes.func,
|
|
269
|
+
onFocus: PropTypes.func,
|
|
261
270
|
opacity: PropTypes.bool,
|
|
262
271
|
backgroundColor: PropTypes.string,
|
|
263
272
|
disabled: PropTypes.bool,
|
|
@@ -47,6 +47,7 @@ export declare class ColorPalette extends React.Component<ColorPaletteProps, Col
|
|
|
47
47
|
disabled: PropTypes.Requireable<boolean>;
|
|
48
48
|
tabIndex: PropTypes.Requireable<number>;
|
|
49
49
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
51
|
id: PropTypes.Requireable<string>;
|
|
51
52
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
52
53
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
@@ -92,8 +92,11 @@ var ColorPalette = /** @class */ (function (_super) {
|
|
|
92
92
|
}
|
|
93
93
|
_this.dispatchChangeEvent(color, event);
|
|
94
94
|
};
|
|
95
|
-
_this.onFocus = function () {
|
|
95
|
+
_this.onFocus = function (nativeEvent) {
|
|
96
96
|
_this.setState({ focusedColor: _this.state.selectedColor || _this.paletteService.colorRows[0][0] });
|
|
97
|
+
if (_this.props.onFocus) {
|
|
98
|
+
_this.props.onFocus.call(undefined, { nativeEvent: nativeEvent, target: _this });
|
|
99
|
+
}
|
|
97
100
|
};
|
|
98
101
|
_this.onBlur = function () {
|
|
99
102
|
_this.setState({ focusedColor: undefined });
|
|
@@ -237,6 +240,7 @@ var ColorPalette = /** @class */ (function (_super) {
|
|
|
237
240
|
disabled: PropTypes.bool,
|
|
238
241
|
tabIndex: PropTypes.number,
|
|
239
242
|
onChange: PropTypes.func,
|
|
243
|
+
onFocus: PropTypes.func,
|
|
240
244
|
id: PropTypes.string,
|
|
241
245
|
ariaLabelledBy: PropTypes.string,
|
|
242
246
|
ariaDescribedBy: PropTypes.string
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the properties of [FlatColorPicker](% slug api_inputs_flatcolorpicker %) component.
|
|
4
|
+
*/
|
|
5
|
+
export interface FlatColorPickerProps {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the `id` property of the top `div` element of the FlatColorPicker.
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets additional CSS styles to the FlatColorPicker.
|
|
12
|
+
*/
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
/**
|
|
15
|
+
* Sets additional classes to the FlatColorPicker.
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the color value.
|
|
20
|
+
*/
|
|
21
|
+
value?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the `tabIndex` property of the FlatColorPicker.
|
|
24
|
+
*/
|
|
25
|
+
tabIndex?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether the FlatColorPicker is disabled.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the FlatColorPicker view. The default is `ColorGradient`.
|
|
32
|
+
*/
|
|
33
|
+
view?: 'ColorGradient' | 'ColorPalette' | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Sets custom header component.
|
|
36
|
+
*/
|
|
37
|
+
header?: React.ComponentType;
|
|
38
|
+
/**
|
|
39
|
+
* Specifies whether clear button will be rendered in the header.
|
|
40
|
+
*/
|
|
41
|
+
showClearButton?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specifies whether preview and revert color boxes will be rendered in the header.
|
|
44
|
+
*/
|
|
45
|
+
showPreview?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Specifies whether action buttons will be rendered in the footer.
|
|
48
|
+
*/
|
|
49
|
+
showButtons?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents the target (element and props) of the FlatColorPicker.
|
|
53
|
+
*/
|
|
54
|
+
export interface FlatColorPickerHandle {
|
|
55
|
+
/**
|
|
56
|
+
* The current element or `null` if there is none.
|
|
57
|
+
*/
|
|
58
|
+
element: HTMLDivElement | null;
|
|
59
|
+
/**
|
|
60
|
+
* The props values of the FlatColorPicker.
|
|
61
|
+
*/
|
|
62
|
+
props: FlatColorPickerProps;
|
|
63
|
+
/**
|
|
64
|
+
* The focus event callback.
|
|
65
|
+
*/
|
|
66
|
+
focus: () => void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Represents the FlatColorPicker component.
|
|
70
|
+
*/
|
|
71
|
+
export declare const FlatColorPicker: React.ForwardRefExoticComponent<FlatColorPickerProps & React.RefAttributes<FlatColorPickerHandle>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import { classNames, validatePackage, getTabIndex } from '@progress/kendo-react-common';
|
|
4
|
+
import { ButtonGroup, Button } from '@progress/kendo-react-buttons';
|
|
5
|
+
import { ColorPalette, ColorGradient } from '../main';
|
|
6
|
+
import { packageMetadata } from '../package-metadata';
|
|
7
|
+
import { messages, flatColorPickerApplyBtn, flatColorPickerCancelBtn } from '../messages';
|
|
8
|
+
;
|
|
9
|
+
;
|
|
10
|
+
/**
|
|
11
|
+
* Represents the FlatColorPicker component.
|
|
12
|
+
*/
|
|
13
|
+
export var FlatColorPicker = React.forwardRef(function (props, ref) {
|
|
14
|
+
validatePackage(packageMetadata);
|
|
15
|
+
var target = React.useRef(null);
|
|
16
|
+
var flatColorPickerRef = React.useRef(null);
|
|
17
|
+
var colorGradientRef = React.useRef(null);
|
|
18
|
+
var _a = React.useState((props.view || 'ColorGradient') === 'ColorGradient'), colorGradientView = _a[0], setColorGradientView = _a[1];
|
|
19
|
+
var _b = React.useState('rgba(255, 255, 255, 1)'), colorValue = _b[0], setColorValue = _b[1];
|
|
20
|
+
var _c = React.useState('rgba(255, 255, 255, 1)'), prevColor = _c[0], setPrevColor = _c[1];
|
|
21
|
+
var focus = React.useCallback(function () {
|
|
22
|
+
if (target.current) {
|
|
23
|
+
target.current.focus();
|
|
24
|
+
}
|
|
25
|
+
}, [target]);
|
|
26
|
+
React.useImperativeHandle(target, function () { return ({
|
|
27
|
+
element: flatColorPickerRef.current,
|
|
28
|
+
focus: focus,
|
|
29
|
+
props: props
|
|
30
|
+
}); });
|
|
31
|
+
React.useImperativeHandle(ref, function () { return target.current; });
|
|
32
|
+
var handleViewChange = React.useCallback(function (viewType) {
|
|
33
|
+
if ((viewType === 'ColorGradient' && !colorGradientView) || (viewType === 'ColorPalette' && colorGradientView)) {
|
|
34
|
+
setColorGradientView(!colorGradientView);
|
|
35
|
+
}
|
|
36
|
+
}, [colorGradientView]);
|
|
37
|
+
var handleResetColor = React.useCallback(function () {
|
|
38
|
+
setColorValue('rgba(255, 255, 255, 1)');
|
|
39
|
+
}, []);
|
|
40
|
+
var handleColorChange = React.useCallback(function (event) {
|
|
41
|
+
setColorValue(event.value);
|
|
42
|
+
}, []);
|
|
43
|
+
var handleApplyBtnClick = React.useCallback(function () {
|
|
44
|
+
setPrevColor(colorValue);
|
|
45
|
+
}, [colorValue]);
|
|
46
|
+
var handleCancelBtnClick = React.useCallback(function () {
|
|
47
|
+
setPrevColor('rgba(255, 255, 255, 1)');
|
|
48
|
+
}, []);
|
|
49
|
+
var handlePrevColorClick = React.useCallback(function () {
|
|
50
|
+
setColorValue(prevColor);
|
|
51
|
+
}, [prevColor]);
|
|
52
|
+
var handleFocus = React.useCallback(function () {
|
|
53
|
+
if (flatColorPickerRef.current) {
|
|
54
|
+
flatColorPickerRef.current.focus();
|
|
55
|
+
}
|
|
56
|
+
}, [flatColorPickerRef]);
|
|
57
|
+
var handleFlatColorPickerBlur = React.useCallback(function () {
|
|
58
|
+
setPrevColor(colorValue);
|
|
59
|
+
}, [colorValue]);
|
|
60
|
+
return (React.createElement("div", { id: props.id, style: props.style, ref: flatColorPickerRef, tabIndex: getTabIndex(props.tabIndex, props.disabled), className: classNames('k-flatcolorpicker k-coloreditor', {
|
|
61
|
+
'k-state-disabled': props.disabled
|
|
62
|
+
}, props.className), onBlur: handleFlatColorPickerBlur },
|
|
63
|
+
props.header ||
|
|
64
|
+
React.createElement("div", { className: "k-coloreditor-header k-hstack" },
|
|
65
|
+
React.createElement("div", { className: "k-coloreditor-header-actions k-hstack" },
|
|
66
|
+
React.createElement(ButtonGroup, null,
|
|
67
|
+
React.createElement(Button, { type: "button", togglable: true, look: 'flat', selected: colorGradientView, onClick: function () { return handleViewChange('ColorGradient'); } },
|
|
68
|
+
React.createElement("span", { className: "k-icon k-i-color-canvas" })),
|
|
69
|
+
React.createElement(Button, { type: "button", togglable: true, look: 'flat', selected: !colorGradientView, onClick: function () { return handleViewChange('ColorPalette'); } },
|
|
70
|
+
React.createElement("span", { className: "k-icon k-i-palette" })))),
|
|
71
|
+
React.createElement("div", { className: "k-spacer" }),
|
|
72
|
+
React.createElement("div", { className: "k-coloreditor-header-actions k-hstack" },
|
|
73
|
+
(props.showClearButton && defaultProps.showClearButton) &&
|
|
74
|
+
React.createElement(Button, { type: "button", look: 'flat', onClick: handleResetColor },
|
|
75
|
+
React.createElement("span", { className: "k-icon k-i-reset-color" })),
|
|
76
|
+
(props.showPreview && defaultProps.showPreview) &&
|
|
77
|
+
React.createElement("div", { className: "k-coloreditor-preview k-vstack" },
|
|
78
|
+
React.createElement("span", { className: "k-coloreditor-preview-color k-color-preview", style: { background: colorValue } }),
|
|
79
|
+
React.createElement("span", { className: "k-coloreditor-current-color k-color-preview", style: { background: prevColor }, onClick: handlePrevColorClick })))),
|
|
80
|
+
React.createElement("div", { className: "k-coloreditor-views k-vstack" }, colorGradientView
|
|
81
|
+
? React.createElement(ColorGradient, { ref: colorGradientRef, value: colorValue, onChange: handleColorChange, onFocus: handleFocus })
|
|
82
|
+
: React.createElement(ColorPalette, { value: colorValue, onChange: handleColorChange, onFocus: handleFocus })),
|
|
83
|
+
(props.showButtons && defaultProps.showButtons) &&
|
|
84
|
+
React.createElement("div", { className: "k-coloreditor-footer k-actions k-actions-end" },
|
|
85
|
+
React.createElement(Button, { type: "button", className: "k-coloreditor-cancel", onClick: handleCancelBtnClick }, messages[flatColorPickerCancelBtn]),
|
|
86
|
+
React.createElement(Button, { type: "button", className: "k-coloreditor-apply k-primary", onClick: handleApplyBtnClick }, messages[flatColorPickerApplyBtn]))));
|
|
87
|
+
});
|
|
88
|
+
var propTypes = {
|
|
89
|
+
id: PropTypes.string,
|
|
90
|
+
value: PropTypes.string,
|
|
91
|
+
view: PropTypes.string,
|
|
92
|
+
header: PropTypes.elementType,
|
|
93
|
+
showClearButton: PropTypes.bool,
|
|
94
|
+
showPreview: PropTypes.bool,
|
|
95
|
+
showButtons: PropTypes.bool
|
|
96
|
+
};
|
|
97
|
+
var defaultProps = {
|
|
98
|
+
showClearButton: true,
|
|
99
|
+
showPreview: true,
|
|
100
|
+
showButtons: true
|
|
101
|
+
};
|
|
102
|
+
FlatColorPicker.displayName = 'KendoFlatColorPicker';
|
|
103
|
+
// TODO: delete casting when @types/react is updated!
|
|
104
|
+
FlatColorPicker.propTypes = propTypes;
|
|
105
|
+
FlatColorPicker.defaultProps = defaultProps;
|
|
@@ -16,6 +16,10 @@ export interface ColorGradientProps {
|
|
|
16
16
|
* Determines the event handler that will be fired when the user edits the value.
|
|
17
17
|
*/
|
|
18
18
|
onChange?: (event: ColorGradientChangeEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the focus event.
|
|
21
|
+
*/
|
|
22
|
+
onFocus?: (event: any) => void;
|
|
19
23
|
/**
|
|
20
24
|
* Determines whether the alpha slider and the alpha input will be displayed. Defaults to `true`.
|
|
21
25
|
*/
|
|
@@ -68,4 +68,8 @@ export interface ColorPaletteProps {
|
|
|
68
68
|
* Determines the event handler that will be fired when the user edits the value.
|
|
69
69
|
*/
|
|
70
70
|
onChange?: (event: ColorPaletteChangeEvent) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Represent the focus event of the ColorPalette.
|
|
73
|
+
*/
|
|
74
|
+
onFocus?: (event: FocusEvent) => void;
|
|
71
75
|
}
|
package/dist/es/main.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './colors/interfaces/ColorPickerGradientSettings';
|
|
|
16
16
|
export * from './colors/interfaces/ColorPickerPaletteSettings';
|
|
17
17
|
export * from './colors/interfaces/ColorPickerPopupSettings';
|
|
18
18
|
export * from './colors/interfaces/ColorPickerProps';
|
|
19
|
+
export * from './colors/FlatColorPicker';
|
|
19
20
|
export * from './input/Input';
|
|
20
21
|
export * from './maskedtextbox/MaskedTextBox';
|
|
21
22
|
export * from './maskedtextbox/MaskedTextBoxProps';
|
package/dist/es/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './colors/ColorGradient';
|
|
2
2
|
export * from './colors/ColorPalette';
|
|
3
3
|
export * from './colors/ColorPicker';
|
|
4
|
+
export * from './colors/FlatColorPicker';
|
|
4
5
|
export * from './input/Input';
|
|
5
6
|
export * from './maskedtextbox/MaskedTextBox';
|
|
6
7
|
export * from './numerictextbox/NumericTextBox';
|
|
@@ -58,6 +58,14 @@ export declare const colorGradientPass = "colorGradient.colorGradientPass";
|
|
|
58
58
|
* @hidden
|
|
59
59
|
*/
|
|
60
60
|
export declare const colorGradientFail = "colorGradient.colorGradientFail";
|
|
61
|
+
/**
|
|
62
|
+
* @hidden
|
|
63
|
+
*/
|
|
64
|
+
export declare const flatColorPickerCancelBtn = "flatColorPicker.cancelBtn";
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
export declare const flatColorPickerApplyBtn = "flatColorPicker.applyBtn";
|
|
61
69
|
/**
|
|
62
70
|
* @hidden
|
|
63
71
|
*/
|
|
@@ -93,6 +101,8 @@ export declare const messages: {
|
|
|
93
101
|
[colorGradientAAALevel]: string;
|
|
94
102
|
[colorGradientPass]: string;
|
|
95
103
|
[colorGradientFail]: string;
|
|
104
|
+
[flatColorPickerCancelBtn]: string;
|
|
105
|
+
[flatColorPickerApplyBtn]: string;
|
|
96
106
|
[checkboxValidation]: string;
|
|
97
107
|
[checkboxOptionalText]: string;
|
|
98
108
|
[radioButtonValidation]: string;
|
|
@@ -59,6 +59,14 @@ export var colorGradientPass = 'colorGradient.colorGradientPass';
|
|
|
59
59
|
* @hidden
|
|
60
60
|
*/
|
|
61
61
|
export var colorGradientFail = 'colorGradient.colorGradientFail';
|
|
62
|
+
/**
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
|
+
export var flatColorPickerCancelBtn = 'flatColorPicker.cancelBtn';
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
69
|
+
export var flatColorPickerApplyBtn = 'flatColorPicker.applyBtn';
|
|
62
70
|
/**
|
|
63
71
|
* @hidden
|
|
64
72
|
*/
|
|
@@ -94,6 +102,8 @@ export var messages = (_a = {},
|
|
|
94
102
|
_a[colorGradientAAALevel] = 'AAA',
|
|
95
103
|
_a[colorGradientPass] = 'Pass',
|
|
96
104
|
_a[colorGradientFail] = 'Fail',
|
|
105
|
+
_a[flatColorPickerCancelBtn] = 'Cancel',
|
|
106
|
+
_a[flatColorPickerApplyBtn] = 'Apply',
|
|
97
107
|
_a[checkboxValidation] = 'Please check this box if you want to proceed!',
|
|
98
108
|
_a[checkboxOptionalText] = '(Optional)',
|
|
99
109
|
_a[radioButtonValidation] = 'Please select option if you want to proceed!',
|
|
@@ -5,7 +5,7 @@ export var packageMetadata = {
|
|
|
5
5
|
name: '@progress/kendo-react-inputs',
|
|
6
6
|
productName: 'KendoReact',
|
|
7
7
|
productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
|
|
8
|
-
publishDate:
|
|
8
|
+
publishDate: 1636972216,
|
|
9
9
|
version: '',
|
|
10
10
|
licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
11
11
|
};
|
|
@@ -37,6 +37,7 @@ export declare class ColorGradient extends React.Component<ColorGradientProps, C
|
|
|
37
37
|
defaultValue: PropTypes.Requireable<string>;
|
|
38
38
|
value: PropTypes.Requireable<string>;
|
|
39
39
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
41
|
opacity: PropTypes.Requireable<boolean>;
|
|
41
42
|
backgroundColor: PropTypes.Requireable<string>;
|
|
42
43
|
disabled: PropTypes.Requireable<boolean>;
|
|
@@ -123,6 +124,10 @@ export declare class ColorGradient extends React.Component<ColorGradientProps, C
|
|
|
123
124
|
* @hidden
|
|
124
125
|
*/
|
|
125
126
|
dispatchChangeEvent(value: string, syntheticEvent: React.SyntheticEvent<any>, nativeEvent: any): void;
|
|
127
|
+
/**
|
|
128
|
+
* @hidden
|
|
129
|
+
*/
|
|
130
|
+
onFocus: (nativeEvent: any) => void;
|
|
126
131
|
/**
|
|
127
132
|
* @hidden
|
|
128
133
|
*/
|
|
@@ -115,6 +115,14 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
115
115
|
var hsva = Object.assign({}, _this.state.hsva, { s: left / gradientRectMetrics.width, v: 1 - top / gradientRectMetrics.height });
|
|
116
116
|
_this.handleHsvaChange(hsva, event, event.nativeEvent);
|
|
117
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* @hidden
|
|
120
|
+
*/
|
|
121
|
+
_this.onFocus = function (nativeEvent) {
|
|
122
|
+
if (_this.props.onFocus) {
|
|
123
|
+
_this.props.onFocus.call(undefined, { nativeEvent: nativeEvent, target: _this });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
118
126
|
/**
|
|
119
127
|
* @hidden
|
|
120
128
|
*/
|
|
@@ -239,7 +247,7 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
239
247
|
ColorGradient.prototype.render = function () {
|
|
240
248
|
var _this = this;
|
|
241
249
|
var className = kendo_react_common_1.classNames('k-colorgradient', { 'k-state-disabled': this.props.disabled });
|
|
242
|
-
return (React.createElement("div", { id: this.props.id, className: className, "aria-disabled": this.props.disabled ? 'true' : undefined, style: this.props.style, ref: function (el) { return _this.wrapper = el; }, tabIndex: kendo_react_common_1.getTabIndex(this.props.tabIndex, this.props.disabled), "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy },
|
|
250
|
+
return (React.createElement("div", { id: this.props.id, className: className, "aria-disabled": this.props.disabled ? 'true' : undefined, style: this.props.style, ref: function (el) { return _this.wrapper = el; }, tabIndex: kendo_react_common_1.getTabIndex(this.props.tabIndex, this.props.disabled), "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy, onFocus: this.onFocus },
|
|
243
251
|
React.createElement("div", { className: "k-colorgradient-canvas k-hstack" },
|
|
244
252
|
React.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } },
|
|
245
253
|
React.createElement(kendo_react_common_1.Draggable, { onDrag: this.onDrag, onRelease: this.onRelease, ref: function (el) { return _this.gradientWrapper = el ? el.element : undefined; } },
|
|
@@ -260,6 +268,7 @@ var ColorGradient = /** @class */ (function (_super) {
|
|
|
260
268
|
defaultValue: PropTypes.string,
|
|
261
269
|
value: PropTypes.string,
|
|
262
270
|
onChange: PropTypes.func,
|
|
271
|
+
onFocus: PropTypes.func,
|
|
263
272
|
opacity: PropTypes.bool,
|
|
264
273
|
backgroundColor: PropTypes.string,
|
|
265
274
|
disabled: PropTypes.bool,
|
|
@@ -47,6 +47,7 @@ export declare class ColorPalette extends React.Component<ColorPaletteProps, Col
|
|
|
47
47
|
disabled: PropTypes.Requireable<boolean>;
|
|
48
48
|
tabIndex: PropTypes.Requireable<number>;
|
|
49
49
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
50
51
|
id: PropTypes.Requireable<string>;
|
|
51
52
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
52
53
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
@@ -94,8 +94,11 @@ var ColorPalette = /** @class */ (function (_super) {
|
|
|
94
94
|
}
|
|
95
95
|
_this.dispatchChangeEvent(color, event);
|
|
96
96
|
};
|
|
97
|
-
_this.onFocus = function () {
|
|
97
|
+
_this.onFocus = function (nativeEvent) {
|
|
98
98
|
_this.setState({ focusedColor: _this.state.selectedColor || _this.paletteService.colorRows[0][0] });
|
|
99
|
+
if (_this.props.onFocus) {
|
|
100
|
+
_this.props.onFocus.call(undefined, { nativeEvent: nativeEvent, target: _this });
|
|
101
|
+
}
|
|
99
102
|
};
|
|
100
103
|
_this.onBlur = function () {
|
|
101
104
|
_this.setState({ focusedColor: undefined });
|
|
@@ -239,6 +242,7 @@ var ColorPalette = /** @class */ (function (_super) {
|
|
|
239
242
|
disabled: PropTypes.bool,
|
|
240
243
|
tabIndex: PropTypes.number,
|
|
241
244
|
onChange: PropTypes.func,
|
|
245
|
+
onFocus: PropTypes.func,
|
|
242
246
|
id: PropTypes.string,
|
|
243
247
|
ariaLabelledBy: PropTypes.string,
|
|
244
248
|
ariaDescribedBy: PropTypes.string
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the properties of [FlatColorPicker](% slug api_inputs_flatcolorpicker %) component.
|
|
4
|
+
*/
|
|
5
|
+
export interface FlatColorPickerProps {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the `id` property of the top `div` element of the FlatColorPicker.
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets additional CSS styles to the FlatColorPicker.
|
|
12
|
+
*/
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
/**
|
|
15
|
+
* Sets additional classes to the FlatColorPicker.
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the color value.
|
|
20
|
+
*/
|
|
21
|
+
value?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the `tabIndex` property of the FlatColorPicker.
|
|
24
|
+
*/
|
|
25
|
+
tabIndex?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether the FlatColorPicker is disabled.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the FlatColorPicker view. The default is `ColorGradient`.
|
|
32
|
+
*/
|
|
33
|
+
view?: 'ColorGradient' | 'ColorPalette' | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Sets custom header component.
|
|
36
|
+
*/
|
|
37
|
+
header?: React.ComponentType;
|
|
38
|
+
/**
|
|
39
|
+
* Specifies whether clear button will be rendered in the header.
|
|
40
|
+
*/
|
|
41
|
+
showClearButton?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specifies whether preview and revert color boxes will be rendered in the header.
|
|
44
|
+
*/
|
|
45
|
+
showPreview?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Specifies whether action buttons will be rendered in the footer.
|
|
48
|
+
*/
|
|
49
|
+
showButtons?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents the target (element and props) of the FlatColorPicker.
|
|
53
|
+
*/
|
|
54
|
+
export interface FlatColorPickerHandle {
|
|
55
|
+
/**
|
|
56
|
+
* The current element or `null` if there is none.
|
|
57
|
+
*/
|
|
58
|
+
element: HTMLDivElement | null;
|
|
59
|
+
/**
|
|
60
|
+
* The props values of the FlatColorPicker.
|
|
61
|
+
*/
|
|
62
|
+
props: FlatColorPickerProps;
|
|
63
|
+
/**
|
|
64
|
+
* The focus event callback.
|
|
65
|
+
*/
|
|
66
|
+
focus: () => void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Represents the FlatColorPicker component.
|
|
70
|
+
*/
|
|
71
|
+
export declare const FlatColorPicker: React.ForwardRefExoticComponent<FlatColorPickerProps & React.RefAttributes<FlatColorPickerHandle>>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var React = require("react");
|
|
4
|
+
var PropTypes = require("prop-types");
|
|
5
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
6
|
+
var kendo_react_buttons_1 = require("@progress/kendo-react-buttons");
|
|
7
|
+
var main_1 = require("../main");
|
|
8
|
+
var package_metadata_1 = require("../package-metadata");
|
|
9
|
+
var messages_1 = require("../messages");
|
|
10
|
+
;
|
|
11
|
+
;
|
|
12
|
+
/**
|
|
13
|
+
* Represents the FlatColorPicker component.
|
|
14
|
+
*/
|
|
15
|
+
exports.FlatColorPicker = React.forwardRef(function (props, ref) {
|
|
16
|
+
kendo_react_common_1.validatePackage(package_metadata_1.packageMetadata);
|
|
17
|
+
var target = React.useRef(null);
|
|
18
|
+
var flatColorPickerRef = React.useRef(null);
|
|
19
|
+
var colorGradientRef = React.useRef(null);
|
|
20
|
+
var _a = React.useState((props.view || 'ColorGradient') === 'ColorGradient'), colorGradientView = _a[0], setColorGradientView = _a[1];
|
|
21
|
+
var _b = React.useState('rgba(255, 255, 255, 1)'), colorValue = _b[0], setColorValue = _b[1];
|
|
22
|
+
var _c = React.useState('rgba(255, 255, 255, 1)'), prevColor = _c[0], setPrevColor = _c[1];
|
|
23
|
+
var focus = React.useCallback(function () {
|
|
24
|
+
if (target.current) {
|
|
25
|
+
target.current.focus();
|
|
26
|
+
}
|
|
27
|
+
}, [target]);
|
|
28
|
+
React.useImperativeHandle(target, function () { return ({
|
|
29
|
+
element: flatColorPickerRef.current,
|
|
30
|
+
focus: focus,
|
|
31
|
+
props: props
|
|
32
|
+
}); });
|
|
33
|
+
React.useImperativeHandle(ref, function () { return target.current; });
|
|
34
|
+
var handleViewChange = React.useCallback(function (viewType) {
|
|
35
|
+
if ((viewType === 'ColorGradient' && !colorGradientView) || (viewType === 'ColorPalette' && colorGradientView)) {
|
|
36
|
+
setColorGradientView(!colorGradientView);
|
|
37
|
+
}
|
|
38
|
+
}, [colorGradientView]);
|
|
39
|
+
var handleResetColor = React.useCallback(function () {
|
|
40
|
+
setColorValue('rgba(255, 255, 255, 1)');
|
|
41
|
+
}, []);
|
|
42
|
+
var handleColorChange = React.useCallback(function (event) {
|
|
43
|
+
setColorValue(event.value);
|
|
44
|
+
}, []);
|
|
45
|
+
var handleApplyBtnClick = React.useCallback(function () {
|
|
46
|
+
setPrevColor(colorValue);
|
|
47
|
+
}, [colorValue]);
|
|
48
|
+
var handleCancelBtnClick = React.useCallback(function () {
|
|
49
|
+
setPrevColor('rgba(255, 255, 255, 1)');
|
|
50
|
+
}, []);
|
|
51
|
+
var handlePrevColorClick = React.useCallback(function () {
|
|
52
|
+
setColorValue(prevColor);
|
|
53
|
+
}, [prevColor]);
|
|
54
|
+
var handleFocus = React.useCallback(function () {
|
|
55
|
+
if (flatColorPickerRef.current) {
|
|
56
|
+
flatColorPickerRef.current.focus();
|
|
57
|
+
}
|
|
58
|
+
}, [flatColorPickerRef]);
|
|
59
|
+
var handleFlatColorPickerBlur = React.useCallback(function () {
|
|
60
|
+
setPrevColor(colorValue);
|
|
61
|
+
}, [colorValue]);
|
|
62
|
+
return (React.createElement("div", { id: props.id, style: props.style, ref: flatColorPickerRef, tabIndex: kendo_react_common_1.getTabIndex(props.tabIndex, props.disabled), className: kendo_react_common_1.classNames('k-flatcolorpicker k-coloreditor', {
|
|
63
|
+
'k-state-disabled': props.disabled
|
|
64
|
+
}, props.className), onBlur: handleFlatColorPickerBlur },
|
|
65
|
+
props.header ||
|
|
66
|
+
React.createElement("div", { className: "k-coloreditor-header k-hstack" },
|
|
67
|
+
React.createElement("div", { className: "k-coloreditor-header-actions k-hstack" },
|
|
68
|
+
React.createElement(kendo_react_buttons_1.ButtonGroup, null,
|
|
69
|
+
React.createElement(kendo_react_buttons_1.Button, { type: "button", togglable: true, look: 'flat', selected: colorGradientView, onClick: function () { return handleViewChange('ColorGradient'); } },
|
|
70
|
+
React.createElement("span", { className: "k-icon k-i-color-canvas" })),
|
|
71
|
+
React.createElement(kendo_react_buttons_1.Button, { type: "button", togglable: true, look: 'flat', selected: !colorGradientView, onClick: function () { return handleViewChange('ColorPalette'); } },
|
|
72
|
+
React.createElement("span", { className: "k-icon k-i-palette" })))),
|
|
73
|
+
React.createElement("div", { className: "k-spacer" }),
|
|
74
|
+
React.createElement("div", { className: "k-coloreditor-header-actions k-hstack" },
|
|
75
|
+
(props.showClearButton && defaultProps.showClearButton) &&
|
|
76
|
+
React.createElement(kendo_react_buttons_1.Button, { type: "button", look: 'flat', onClick: handleResetColor },
|
|
77
|
+
React.createElement("span", { className: "k-icon k-i-reset-color" })),
|
|
78
|
+
(props.showPreview && defaultProps.showPreview) &&
|
|
79
|
+
React.createElement("div", { className: "k-coloreditor-preview k-vstack" },
|
|
80
|
+
React.createElement("span", { className: "k-coloreditor-preview-color k-color-preview", style: { background: colorValue } }),
|
|
81
|
+
React.createElement("span", { className: "k-coloreditor-current-color k-color-preview", style: { background: prevColor }, onClick: handlePrevColorClick })))),
|
|
82
|
+
React.createElement("div", { className: "k-coloreditor-views k-vstack" }, colorGradientView
|
|
83
|
+
? React.createElement(main_1.ColorGradient, { ref: colorGradientRef, value: colorValue, onChange: handleColorChange, onFocus: handleFocus })
|
|
84
|
+
: React.createElement(main_1.ColorPalette, { value: colorValue, onChange: handleColorChange, onFocus: handleFocus })),
|
|
85
|
+
(props.showButtons && defaultProps.showButtons) &&
|
|
86
|
+
React.createElement("div", { className: "k-coloreditor-footer k-actions k-actions-end" },
|
|
87
|
+
React.createElement(kendo_react_buttons_1.Button, { type: "button", className: "k-coloreditor-cancel", onClick: handleCancelBtnClick }, messages_1.messages[messages_1.flatColorPickerCancelBtn]),
|
|
88
|
+
React.createElement(kendo_react_buttons_1.Button, { type: "button", className: "k-coloreditor-apply k-primary", onClick: handleApplyBtnClick }, messages_1.messages[messages_1.flatColorPickerApplyBtn]))));
|
|
89
|
+
});
|
|
90
|
+
var propTypes = {
|
|
91
|
+
id: PropTypes.string,
|
|
92
|
+
value: PropTypes.string,
|
|
93
|
+
view: PropTypes.string,
|
|
94
|
+
header: PropTypes.elementType,
|
|
95
|
+
showClearButton: PropTypes.bool,
|
|
96
|
+
showPreview: PropTypes.bool,
|
|
97
|
+
showButtons: PropTypes.bool
|
|
98
|
+
};
|
|
99
|
+
var defaultProps = {
|
|
100
|
+
showClearButton: true,
|
|
101
|
+
showPreview: true,
|
|
102
|
+
showButtons: true
|
|
103
|
+
};
|
|
104
|
+
exports.FlatColorPicker.displayName = 'KendoFlatColorPicker';
|
|
105
|
+
// TODO: delete casting when @types/react is updated!
|
|
106
|
+
exports.FlatColorPicker.propTypes = propTypes;
|
|
107
|
+
exports.FlatColorPicker.defaultProps = defaultProps;
|
|
@@ -16,6 +16,10 @@ export interface ColorGradientProps {
|
|
|
16
16
|
* Determines the event handler that will be fired when the user edits the value.
|
|
17
17
|
*/
|
|
18
18
|
onChange?: (event: ColorGradientChangeEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the focus event.
|
|
21
|
+
*/
|
|
22
|
+
onFocus?: (event: any) => void;
|
|
19
23
|
/**
|
|
20
24
|
* Determines whether the alpha slider and the alpha input will be displayed. Defaults to `true`.
|
|
21
25
|
*/
|