@progress/kendo-react-inputs 8.2.0-develop.9 → 8.2.1-develop.1
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/checkbox/Checkbox.js +1 -1
- package/checkbox/Checkbox.mjs +74 -70
- package/colors/ColorGradient.js +1 -1
- package/colors/ColorGradient.mjs +181 -121
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +29 -29
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +168 -152
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +120 -104
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +120 -45
- package/index.d.ts +120 -45
- package/input/Input.js +1 -1
- package/input/Input.mjs +47 -43
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +61 -57
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +89 -86
- package/package-metadata.mjs +1 -1
- package/package.json +8 -8
- package/range-slider/RangeSlider.js +11 -11
- package/range-slider/RangeSlider.mjs +176 -154
- package/range-slider/range-raducer.js +1 -1
- package/range-slider/range-raducer.mjs +35 -1
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +112 -111
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +29 -29
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +96 -92
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +54 -50
package/colors/ColorGradient.mjs
CHANGED
|
@@ -6,154 +6,213 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { packageMetadata as
|
|
13
|
-
import { Slider as
|
|
14
|
-
import {
|
|
15
|
-
import { getHSV as
|
|
16
|
-
import { cacheHex as
|
|
17
|
-
import
|
|
18
|
-
import { ColorContrastLabels as
|
|
19
|
-
import { ColorContrastSvg as
|
|
20
|
-
import { provideLocalizationService as
|
|
21
|
-
import { colorGradientHueSliderLabel as
|
|
22
|
-
const
|
|
23
|
-
constructor(
|
|
24
|
-
super(
|
|
9
|
+
import * as r from "react";
|
|
10
|
+
import o from "prop-types";
|
|
11
|
+
import { validatePackage as L, Navigation as m, getActiveElement as u, disableNavigatableContainer as C, keepFocusInContainer as F, TABBABLE_ELEMENTS as G, focusFirstFocusableChild as A, enableNavigatableContainer as N, getTabIndex as S, classNames as I, Draggable as T, createPropsContext as M, withIdHOC as _, withPropsContext as B } from "@progress/kendo-react-common";
|
|
12
|
+
import { packageMetadata as P } from "../package-metadata.mjs";
|
|
13
|
+
import { Slider as k } from "../slider/Slider.mjs";
|
|
14
|
+
import { isPresent as R, fitIntoBounds as y } from "./utils/misc.mjs";
|
|
15
|
+
import { getHSV as b, getColorFromHue as c, getRGBA as p, getColorFromRGBA as V, parseColor as d, getColorFromHSV as K } from "./utils/color-parser.mjs";
|
|
16
|
+
import { cacheHex as U, cacheRgba as O, removeCachedColor as W, cacheHsva as $, getCachedHsva as j, getCachedRgba as X, getCachedHex as Y } from "./utils/color-cache.mjs";
|
|
17
|
+
import z from "./ColorInput.mjs";
|
|
18
|
+
import { ColorContrastLabels as q } from "./ColorContrastLabels.mjs";
|
|
19
|
+
import { ColorContrastSvg as J } from "./ColorContrastSvg.mjs";
|
|
20
|
+
import { provideLocalizationService as Q } from "@progress/kendo-react-intl";
|
|
21
|
+
import { colorGradientHueSliderLabel as E, messages as x, colorGradientAlphaSliderLabel as H } from "../messages/index.mjs";
|
|
22
|
+
const Z = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h extends r.Component {
|
|
23
|
+
constructor(t) {
|
|
24
|
+
super(t), this.wrapperRef = r.createRef(), this.hsvGradientRef = r.createRef(), this.focus = () => {
|
|
25
|
+
this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
|
|
26
|
+
}, this.onHexChange = (e, s, i) => {
|
|
25
27
|
if (this.isUncontrolled) {
|
|
26
|
-
const n =
|
|
27
|
-
this.setState({ hsva: n, backgroundColor:
|
|
28
|
+
const n = b(s);
|
|
29
|
+
this.setState({ hsva: n, backgroundColor: c(n.h), rgba: p(s), hex: e });
|
|
28
30
|
} else
|
|
29
|
-
|
|
30
|
-
this.dispatchChangeEvent(s,
|
|
31
|
-
}, this.onRgbaChange = (
|
|
32
|
-
const
|
|
31
|
+
U(this.state.guid, s, e);
|
|
32
|
+
this.dispatchChangeEvent(s, i, i.nativeEvent);
|
|
33
|
+
}, this.onRgbaChange = (e, s) => {
|
|
34
|
+
const i = V(e);
|
|
33
35
|
if (this.isUncontrolled) {
|
|
34
|
-
const n =
|
|
35
|
-
this.setState({ hsva: n, backgroundColor:
|
|
36
|
+
const n = b(i), l = d(i, "hex");
|
|
37
|
+
this.setState({ hsva: n, backgroundColor: c(n.h), rgba: e, hex: l });
|
|
36
38
|
} else
|
|
37
|
-
|
|
38
|
-
this.dispatchChangeEvent(
|
|
39
|
-
}, this.onAlphaSliderChange = (
|
|
39
|
+
O(this.state.guid, i, e);
|
|
40
|
+
this.dispatchChangeEvent(i, s.syntheticEvent, s.nativeEvent);
|
|
41
|
+
}, this.onAlphaSliderChange = (e) => {
|
|
40
42
|
this.handleHsvaChange(
|
|
41
|
-
Object.assign({}, this.state.hsva, { a:
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
Object.assign({}, this.state.hsva, { a: e.value / 100 }),
|
|
44
|
+
e.syntheticEvent,
|
|
45
|
+
e.nativeEvent
|
|
44
46
|
);
|
|
45
|
-
}, this.onHueSliderChange = (
|
|
47
|
+
}, this.onHueSliderChange = (e) => {
|
|
46
48
|
this.handleHsvaChange(
|
|
47
|
-
Object.assign({}, this.state.hsva, { h:
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
Object.assign({}, this.state.hsva, { h: e.value }),
|
|
50
|
+
e.syntheticEvent,
|
|
51
|
+
e.nativeEvent
|
|
50
52
|
);
|
|
51
|
-
}, this.onDrag = (
|
|
52
|
-
this.gradientWrapper.classList.add("k-dragging"), this.changePosition(
|
|
53
|
+
}, this.onDrag = (e) => {
|
|
54
|
+
this.gradientWrapper.classList.add("k-dragging"), this.changePosition(e.event);
|
|
53
55
|
}, this.onRelease = () => {
|
|
54
56
|
this.gradientWrapper.classList.remove("k-dragging");
|
|
55
|
-
}, this.onGradientWrapperClick = (
|
|
56
|
-
this.changePosition(
|
|
57
|
-
}, this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
}, this.onGradientWrapperClick = (e) => {
|
|
58
|
+
this.changePosition(e);
|
|
59
|
+
}, this.onHsvGradientKeyDown = (e) => {
|
|
60
|
+
var s;
|
|
61
|
+
(s = this.hsvNavigation) == null || s.triggerKeyboardEvent(e);
|
|
62
|
+
}, this.onHsvGradientValueChange = (e, s, i) => {
|
|
63
|
+
const n = parseInt(e.style.top, 10) + i, l = parseInt(e.style.left, 10) + s;
|
|
64
|
+
e.style.top = `${n}px`, e.style.left = `${l}px`, this.moveDragHandle(l, n);
|
|
65
|
+
}, this.changePosition = (e) => {
|
|
66
|
+
const s = this.getGradientRectMetrics(), i = e.clientX - s.left, n = e.clientY - s.top;
|
|
67
|
+
this.moveDragHandle(i, n);
|
|
68
|
+
}, this.onFocus = (e) => {
|
|
65
69
|
this.props.onFocus && this.props.onFocus.call(
|
|
66
70
|
void 0,
|
|
67
|
-
{ nativeEvent:
|
|
71
|
+
{ nativeEvent: e, target: this }
|
|
68
72
|
);
|
|
69
|
-
}, this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
}, this.onKeyDown = (e) => {
|
|
74
|
+
var s;
|
|
75
|
+
(s = this.navigation) == null || s.triggerKeyboardEvent(e);
|
|
76
|
+
}, L(P);
|
|
77
|
+
const a = t.value || t.defaultValue || d(w, Z);
|
|
73
78
|
this.state = Object.assign({}, h.getStateFromValue(a), { isFirstRender: !0, guid: this.props.id });
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
76
81
|
* @hidden
|
|
77
82
|
*/
|
|
78
|
-
static getDerivedStateFromProps(
|
|
79
|
-
return
|
|
83
|
+
static getDerivedStateFromProps(t, a) {
|
|
84
|
+
return t.value && !a.isFirstRender ? h.getStateFromValue(t.value, a.guid) : null;
|
|
80
85
|
}
|
|
81
86
|
/**
|
|
82
87
|
* @hidden
|
|
83
88
|
*/
|
|
84
89
|
componentDidMount() {
|
|
85
|
-
this.setAlphaSliderBackground(this.state.backgroundColor), this.state.isFirstRender && this.setState({ isFirstRender: !1 })
|
|
90
|
+
if (this.setAlphaSliderBackground(this.state.backgroundColor), this.state.isFirstRender && this.setState({ isFirstRender: !1 }), this.wrapperRef && this.hsvGradientRef) {
|
|
91
|
+
let t = 0, a = 0;
|
|
92
|
+
this.hsvNavigation = new m({
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
root: this.hsvGradientRef,
|
|
95
|
+
selectors: [".k-hsv-rectangle .k-hsv-draghandle"],
|
|
96
|
+
keyboardEvents: {
|
|
97
|
+
keydown: {
|
|
98
|
+
ArrowDown: (e, s, i) => {
|
|
99
|
+
a = i.shiftKey ? this.props.gradientSliderSmallStep || g : this.props.gradientSliderStep || v, this.onHsvGradientValueChange(e, 0, a);
|
|
100
|
+
},
|
|
101
|
+
ArrowUp: (e, s, i) => {
|
|
102
|
+
a = i.shiftKey ? -(this.props.gradientSliderSmallStep || g) : -(this.props.gradientSliderStep || v), this.onHsvGradientValueChange(e, 0, a);
|
|
103
|
+
},
|
|
104
|
+
ArrowLeft: (e, s, i) => {
|
|
105
|
+
t = i.shiftKey ? -(this.props.gradientSliderSmallStep || g) : -(this.props.gradientSliderStep || v), this.onHsvGradientValueChange(e, t, 0);
|
|
106
|
+
},
|
|
107
|
+
ArrowRight: (e, s, i) => {
|
|
108
|
+
t = i.shiftKey ? this.props.gradientSliderSmallStep || g : this.props.gradientSliderStep || v, this.onHsvGradientValueChange(e, t, 0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
this.wrapperRef && this.wrapperRef.current && (this.props.isInsidePopup ? this.hsvGradientRef.current && this.hsvGradientRef.current.focus() : this.navigation = new m({
|
|
115
|
+
tabIndex: 0,
|
|
116
|
+
root: this.wrapperRef,
|
|
117
|
+
selectors: [".k-colorgradient"],
|
|
118
|
+
keyboardEvents: {
|
|
119
|
+
keydown: {
|
|
120
|
+
Tab: (t, a, e) => {
|
|
121
|
+
u(document) === t ? C(t) : F(e, t, G);
|
|
122
|
+
},
|
|
123
|
+
Enter: (t, a, e) => {
|
|
124
|
+
u(document) === t && (A(t), N(t));
|
|
125
|
+
},
|
|
126
|
+
Escape: (t, a, e) => {
|
|
127
|
+
u(document) !== t && (t.focus(), C(t));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
86
132
|
}
|
|
87
133
|
/**
|
|
88
134
|
* @hidden
|
|
89
135
|
*/
|
|
90
136
|
componentWillUnmount() {
|
|
91
|
-
|
|
137
|
+
W(this.state.guid);
|
|
92
138
|
}
|
|
93
139
|
/**
|
|
94
140
|
* @hidden
|
|
95
141
|
*/
|
|
96
|
-
componentDidUpdate(
|
|
142
|
+
componentDidUpdate(t, a) {
|
|
97
143
|
a.backgroundColor !== this.state.backgroundColor && this.setAlphaSliderBackground(this.state.backgroundColor);
|
|
98
144
|
}
|
|
99
145
|
/**
|
|
100
146
|
* @hidden
|
|
101
147
|
*/
|
|
102
148
|
renderRectangleDragHandle() {
|
|
103
|
-
let
|
|
149
|
+
let t = {};
|
|
104
150
|
if (!this.state.isFirstRender) {
|
|
105
|
-
const a = this.getGradientRectMetrics(),
|
|
106
|
-
|
|
151
|
+
const a = this.getGradientRectMetrics(), e = (1 - this.state.hsva.v) * a.height, s = this.state.hsva.s * a.width;
|
|
152
|
+
t.top = `${e}px`, t.left = `${s}px`;
|
|
107
153
|
}
|
|
108
|
-
return /* @__PURE__ */
|
|
154
|
+
return /* @__PURE__ */ r.createElement(
|
|
109
155
|
"div",
|
|
110
156
|
{
|
|
157
|
+
ref: this.hsvGradientRef,
|
|
111
158
|
role: "slider",
|
|
112
|
-
tabIndex:
|
|
159
|
+
tabIndex: S(this.props.tabIndex, this.props.disabled),
|
|
113
160
|
"aria-valuetext": this.props.ariaValueText,
|
|
114
161
|
"aria-valuenow": parseInt(this.state.hex.substring(1), 16),
|
|
115
162
|
"aria-label": this.props.ariaLabelHSV,
|
|
116
163
|
"aria-orientation": void 0,
|
|
117
164
|
"aria-disabled": this.props.disabled ? "true" : void 0,
|
|
118
165
|
className: "k-hsv-draghandle k-draghandle",
|
|
119
|
-
style:
|
|
166
|
+
style: t,
|
|
167
|
+
onKeyDown: this.onHsvGradientKeyDown
|
|
120
168
|
}
|
|
121
169
|
);
|
|
122
170
|
}
|
|
123
171
|
/**
|
|
124
172
|
* @hidden
|
|
125
173
|
*/
|
|
126
|
-
|
|
127
|
-
const s =
|
|
174
|
+
moveDragHandle(t, a) {
|
|
175
|
+
const e = this.getGradientRectMetrics(), s = e.width, i = e.height, n = y(a, 0, i), l = y(t, 0, s), D = Object.assign(
|
|
176
|
+
{},
|
|
177
|
+
this.state.hsva,
|
|
178
|
+
{ s: l / s, v: 1 - n / i }
|
|
179
|
+
);
|
|
180
|
+
this.handleHsvaChange(D, {}, {});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @hidden
|
|
184
|
+
*/
|
|
185
|
+
handleHsvaChange(t, a, e) {
|
|
186
|
+
const s = K(t);
|
|
128
187
|
if (this.isUncontrolled) {
|
|
129
|
-
const
|
|
130
|
-
this.setState({ hsva:
|
|
188
|
+
const i = d(s, "hex");
|
|
189
|
+
this.setState({ hsva: t, backgroundColor: c(t.h), rgba: p(s), hex: i });
|
|
131
190
|
} else
|
|
132
|
-
|
|
133
|
-
this.dispatchChangeEvent(s, a,
|
|
191
|
+
$(this.state.guid, s, t);
|
|
192
|
+
this.dispatchChangeEvent(s, a, e);
|
|
134
193
|
}
|
|
135
194
|
/**
|
|
136
195
|
* @hidden
|
|
137
196
|
*/
|
|
138
|
-
dispatchChangeEvent(
|
|
197
|
+
dispatchChangeEvent(t, a, e) {
|
|
139
198
|
this.props.onChange && this.props.onChange.call(
|
|
140
199
|
void 0,
|
|
141
|
-
{ syntheticEvent: a, nativeEvent:
|
|
200
|
+
{ syntheticEvent: a, nativeEvent: e, target: this, value: t }
|
|
142
201
|
);
|
|
143
202
|
}
|
|
144
203
|
/**
|
|
145
204
|
* @hidden
|
|
146
205
|
*/
|
|
147
|
-
static getStateFromValue(
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
return { hsva:
|
|
206
|
+
static getStateFromValue(t, a) {
|
|
207
|
+
R(d(t, "hex")) || (t = w);
|
|
208
|
+
const e = j(a, t) || b(t), s = X(a, t) || p(t), i = Y(a, t) || d(t, "hex"), n = c(e.h);
|
|
209
|
+
return { hsva: e, backgroundColor: n, rgba: s, hex: i };
|
|
151
210
|
}
|
|
152
211
|
/**
|
|
153
212
|
* @hidden
|
|
154
213
|
*/
|
|
155
|
-
setAlphaSliderBackground(
|
|
156
|
-
this.props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack && (this.alphaSlider.sliderTrack.style.background = `linear-gradient(to top, transparent, ${
|
|
214
|
+
setAlphaSliderBackground(t) {
|
|
215
|
+
this.props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack && (this.alphaSlider.sliderTrack.style.background = `linear-gradient(to top, transparent, ${t})`);
|
|
157
216
|
}
|
|
158
217
|
/**
|
|
159
218
|
* @hidden
|
|
@@ -171,8 +230,8 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
171
230
|
* @hidden
|
|
172
231
|
*/
|
|
173
232
|
render() {
|
|
174
|
-
const
|
|
175
|
-
return /* @__PURE__ */
|
|
233
|
+
const t = Q(this), a = I("k-colorgradient", { "k-disabled": this.props.disabled }, this.props.className);
|
|
234
|
+
return /* @__PURE__ */ r.createElement(
|
|
176
235
|
"div",
|
|
177
236
|
{
|
|
178
237
|
id: this.props.id,
|
|
@@ -180,21 +239,22 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
180
239
|
className: a,
|
|
181
240
|
"aria-disabled": this.props.disabled ? "true" : void 0,
|
|
182
241
|
style: this.props.style,
|
|
183
|
-
ref:
|
|
184
|
-
tabIndex:
|
|
242
|
+
ref: this.wrapperRef,
|
|
243
|
+
tabIndex: S(this.props.tabIndex, this.props.disabled),
|
|
185
244
|
"aria-label": this.props.ariaLabel,
|
|
186
245
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
187
246
|
"aria-describedby": this.props.ariaDescribedBy,
|
|
188
|
-
onFocus: this.onFocus
|
|
247
|
+
onFocus: this.onFocus,
|
|
248
|
+
onKeyDown: this.onKeyDown
|
|
189
249
|
},
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
|
|
250
|
+
/* @__PURE__ */ r.createElement("div", { className: "k-colorgradient-canvas k-hstack" }, /* @__PURE__ */ r.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } }, /* @__PURE__ */ r.createElement(
|
|
251
|
+
T,
|
|
192
252
|
{
|
|
193
253
|
onDrag: this.onDrag,
|
|
194
254
|
onRelease: this.onRelease,
|
|
195
|
-
ref: (
|
|
255
|
+
ref: (e) => this.gradientWrapper = e ? e.element : void 0
|
|
196
256
|
},
|
|
197
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ r.createElement(
|
|
198
258
|
"div",
|
|
199
259
|
{
|
|
200
260
|
className: "k-hsv-gradient",
|
|
@@ -203,15 +263,15 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
203
263
|
},
|
|
204
264
|
this.renderRectangleDragHandle()
|
|
205
265
|
)
|
|
206
|
-
), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */
|
|
207
|
-
|
|
266
|
+
), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */ r.createElement(
|
|
267
|
+
J,
|
|
208
268
|
{
|
|
209
269
|
metrics: this.gradientWrapper ? this.getGradientRectMetrics() : void 0,
|
|
210
270
|
hsva: this.state.hsva,
|
|
211
271
|
backgroundColor: this.props.backgroundColor
|
|
212
272
|
}
|
|
213
|
-
)), /* @__PURE__ */
|
|
214
|
-
|
|
273
|
+
)), /* @__PURE__ */ r.createElement("div", { className: "k-hsv-controls k-hstack" }, /* @__PURE__ */ r.createElement(
|
|
274
|
+
k,
|
|
215
275
|
{
|
|
216
276
|
value: this.state.hsva.h,
|
|
217
277
|
buttons: !1,
|
|
@@ -222,26 +282,26 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
222
282
|
onChange: this.onHueSliderChange,
|
|
223
283
|
className: "k-hue-slider k-colorgradient-slider",
|
|
224
284
|
disabled: this.props.disabled,
|
|
225
|
-
ariaLabel:
|
|
285
|
+
ariaLabel: t.toLanguageString(E, x[E])
|
|
226
286
|
}
|
|
227
|
-
), this.props.opacity && /* @__PURE__ */
|
|
228
|
-
|
|
287
|
+
), this.props.opacity && /* @__PURE__ */ r.createElement(
|
|
288
|
+
k,
|
|
229
289
|
{
|
|
230
|
-
value:
|
|
290
|
+
value: R(this.state.hsva.a) ? this.state.hsva.a * 100 : 100,
|
|
231
291
|
buttons: !1,
|
|
232
292
|
vertical: !0,
|
|
233
293
|
min: 0,
|
|
234
294
|
max: 100,
|
|
235
295
|
step: 1,
|
|
236
|
-
ariaLabel:
|
|
296
|
+
ariaLabel: t.toLanguageString(H, x[H]),
|
|
237
297
|
onChange: this.onAlphaSliderChange,
|
|
238
298
|
className: "k-alpha-slider k-colorgradient-slider",
|
|
239
299
|
disabled: this.props.disabled,
|
|
240
|
-
ref: (
|
|
300
|
+
ref: (e) => this.alphaSlider = e
|
|
241
301
|
}
|
|
242
302
|
))),
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
|
|
303
|
+
/* @__PURE__ */ r.createElement(
|
|
304
|
+
z,
|
|
245
305
|
{
|
|
246
306
|
rgba: this.state.rgba,
|
|
247
307
|
onRgbaChange: this.onRgbaChange,
|
|
@@ -252,10 +312,10 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
252
312
|
defaultInputMode: this.props.format
|
|
253
313
|
}
|
|
254
314
|
),
|
|
255
|
-
this.props.backgroundColor && /* @__PURE__ */
|
|
256
|
-
|
|
315
|
+
this.props.backgroundColor && /* @__PURE__ */ r.createElement(
|
|
316
|
+
q,
|
|
257
317
|
{
|
|
258
|
-
bgColor:
|
|
318
|
+
bgColor: p(this.props.backgroundColor),
|
|
259
319
|
rgba: this.state.rgba
|
|
260
320
|
}
|
|
261
321
|
)
|
|
@@ -263,31 +323,31 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
|
|
|
263
323
|
}
|
|
264
324
|
};
|
|
265
325
|
h.displayName = "ColorGradient", h.propTypes = {
|
|
266
|
-
defaultValue:
|
|
267
|
-
value:
|
|
268
|
-
onChange:
|
|
269
|
-
onFocus:
|
|
270
|
-
opacity:
|
|
271
|
-
backgroundColor:
|
|
272
|
-
format:
|
|
273
|
-
disabled:
|
|
274
|
-
style:
|
|
275
|
-
id:
|
|
276
|
-
role:
|
|
277
|
-
ariaLabel:
|
|
278
|
-
ariaLabelledBy:
|
|
279
|
-
ariaDescribedBy:
|
|
280
|
-
className:
|
|
326
|
+
defaultValue: o.string,
|
|
327
|
+
value: o.string,
|
|
328
|
+
onChange: o.func,
|
|
329
|
+
onFocus: o.func,
|
|
330
|
+
opacity: o.bool,
|
|
331
|
+
backgroundColor: o.string,
|
|
332
|
+
format: o.any,
|
|
333
|
+
disabled: o.bool,
|
|
334
|
+
style: o.any,
|
|
335
|
+
id: o.string,
|
|
336
|
+
role: o.string,
|
|
337
|
+
ariaLabel: o.string,
|
|
338
|
+
ariaLabelledBy: o.string,
|
|
339
|
+
ariaDescribedBy: o.string,
|
|
340
|
+
className: o.string
|
|
281
341
|
}, h.defaultProps = {
|
|
282
342
|
opacity: !0,
|
|
283
343
|
role: "textbox",
|
|
284
344
|
format: "rgb"
|
|
285
345
|
};
|
|
286
|
-
let
|
|
287
|
-
const
|
|
288
|
-
|
|
346
|
+
let f = h;
|
|
347
|
+
const ee = M(), te = _(B(ee, f));
|
|
348
|
+
te.displayName = "KendoReactColorGradient";
|
|
289
349
|
export {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
350
|
+
te as ColorGradient,
|
|
351
|
+
ee as ColorGradientPropsContext,
|
|
352
|
+
f as ColorGradientWithoutContext
|
|
293
353
|
};
|
package/colors/ColorPalette.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),s=require("prop-types"),T=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),N=require("../package-metadata.js"),D=require("./models/palette-presets.js"),I=require("./utils/misc.js"),L=require("./utils/color-parser.js");function O(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const l=O(F),v=24,u=10,S="office",c=class c extends l.Component{constructor(t){super(t),this.wrapperRef=l.createRef(),this.paletteService=null,this.focus=()=>{this.wrapperRef&&this.wrapperRef.current&&this.wrapperRef.current.focus()},this.onKeyDown=e=>{switch(e.key){case r.KEYS.down:this.handleCellNavigation(0,1);break;case r.KEYS.up:this.handleCellNavigation(0,-1);break;case r.KEYS.right:this.handleCellNavigation(1,0);break;case r.KEYS.left:this.handleCellNavigation(-1,0);break;case r.KEYS.enter:this.handleEnter(e);break;default:return}e.preventDefault()},this.onColorClick=(e,o)=>{this.isUncontrolled?this.setState({selectedColor:e,focusedColor:e}):this.setState({focusedColor:e}),this.dispatchChangeEvent(e,o)},this.onFocus=e=>{this.paletteService&&(this.setState({focusedColor:this.state.selectedColor||this.paletteService.colorRows[0][0]}),this.props.onFocus&&this.props.onFocus.call(void 0,e))},this.onBlur=()=>{this.setState({focusedColor:void 0})},r.validatePackage(N.packageMetadata),this.state={selectedColor:this.props.value!==void 0?this.props.value:this.props.defaultValue?this.props.defaultValue:void 0,isFirstRender:!0}}get guid(){return this.props.id}render(){const t=this.getPaletteInfo(),e=this.paletteService=new T.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor),a=r.classNames("k-colorpalette",{"k-disabled":this.props.disabled},this.props.className);return t.colors.length?l.createElement("div",{id:this.props.id,role:"grid",className:a,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,"aria-disabled":this.props.ariaDisabled||(this.props.disabled?"true":void 0),"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),ref:this.wrapperRef},l.createElement("table",{className:"k-colorpalette-table",role:"presentation"},l.createElement("tbody",{role:"rowgroup"},this.renderRows(e.colorRows,o,i)))):""}static getDerivedStateFromProps(t,e){if(!e.isFirstRender&&t.value!==void 0){if(t.value===""&&e.selectedColor!==void 0)return{selectedColor:void 0};if(t.value!==""&&t.value!==e.selectedColor)return{selectedColor:t.value}}else if(e.isFirstRender)return{isFirstRender:!1};return null}handleCellNavigation(t,e){if(this.paletteService)if(this.focusedColorCooridanates){const o=this.paletteService.getNextCell(this.focusedColorCooridanates,t,e);this.setState({focusedColor:this.paletteService.getColorAt(o)})}else this.setState({focusedColor:this.paletteService.colorRows[0][0]})}handleEnter(t){this.isUncontrolled&&this.setState({selectedColor:this.state.focusedColor}),this.dispatchChangeEvent(this.state.focusedColor,t)}dispatchChangeEvent(t,e){r.dispatchEvent(this.props.onChange,e,this,{value:t,rgbaValue:L.parseColor(t,"rgba")})}get focusedColorCooridanates(){return this.state.focusedColor&&this.paletteService?this.paletteService.getCellCoordsFor(this.state.focusedColor):void 0}get isUncontrolled(){return this.props.value===void 0}getPaletteInfo(){if(typeof this.props.palette=="string"){const t=D.PALETTEPRESETS[this.props.palette];return I.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||u}:{colors:[],columns:0}}else return{colors:this.props.palette||[],columns:this.props.columns||u}}renderRows(t,e,o){return t.map((i,a)=>l.createElement("tr",{role:"row",key:a},this.renderColumns(i,a,e,o)))}renderColumns(t,e,o,i){const a=o!==void 0&&o.row===e,E=o&&o.col,w=i!==void 0&&i.row===e,y=i&&i.col,f=typeof this.props.tileSize!="number"?this.props.tileSize:{width:this.props.tileSize,height:this.props.tileSize},C=f.width+"px",P=f.height+"px";return t.map((h,d)=>{const g=a&&E===d,k=r.classNames("k-colorpalette-tile",{"k-selected":g,"k-focus":w&&y===d});return l.createElement("td",{role:"gridcell",className:k,"aria-label":h,"aria-selected":g?!0:this.props.disabled?void 0:!1,style:{backgroundColor:h,width:C,height:P,minWidth:C},onClick:R=>this.onColorClick(h,R),id:this.createCellId({row:e,col:d}),key:d})})}createCellId(t){return`${this.guid}_${t.row}_${t.col}`}};c.displayName="ColorPalette",c.propTypes={palette:s.oneOfType([s.arrayOf(s.string.isRequired),s.string]),columns:s.number,tileSize:s.any,defaultValue:s.string,value:s.string,disabled:s.bool,tabIndex:s.number,onChange:s.func,onFocus:s.func,id:s.string,ariaLabelledBy:s.string,ariaDescribedBy:s.string,className:s.string},c.defaultProps={palette:S,tileSize:v};let p=c;const b=r.createPropsContext(),m=r.withIdHOC(r.withPropsContext(b,p));m.displayName="KendoReactColorPalette";exports.ColorPalette=m;exports.ColorPalettePropsContext=b;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=u;exports.DEFAULT_PRESET=S;exports.DEFAULT_TILE_SIZE=v;
|
package/colors/ColorPalette.mjs
CHANGED
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
9
|
+
import * as i from "react";
|
|
10
10
|
import s from "prop-types";
|
|
11
11
|
import { ColorPaletteService as E } from "./utils/color-palette.service.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { KEYS as a, validatePackage as k, classNames as C, getTabIndex as R, dispatchEvent as F, createPropsContext as N, withIdHOC as P, withPropsContext as T } from "@progress/kendo-react-common";
|
|
13
13
|
import { packageMetadata as I } from "../package-metadata.mjs";
|
|
14
14
|
import { PALETTEPRESETS as D } from "./models/palette-presets.mjs";
|
|
15
15
|
import { isPresent as L } from "./utils/misc.mjs";
|
|
16
16
|
import { parseColor as U } from "./utils/color-parser.mjs";
|
|
17
|
-
const x = 24,
|
|
17
|
+
const x = 24, m = 10, z = "office", n = class n extends i.Component {
|
|
18
18
|
constructor(t) {
|
|
19
|
-
super(t), this.
|
|
20
|
-
this.
|
|
19
|
+
super(t), this.wrapperRef = i.createRef(), this.paletteService = null, this.focus = () => {
|
|
20
|
+
this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
|
|
21
21
|
}, this.onKeyDown = (e) => {
|
|
22
|
-
switch (e.
|
|
22
|
+
switch (e.key) {
|
|
23
23
|
case a.down:
|
|
24
24
|
this.handleCellNavigation(0, 1);
|
|
25
25
|
break;
|
|
@@ -62,23 +62,23 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
|
|
|
62
62
|
render() {
|
|
63
63
|
const t = this.getPaletteInfo(), e = this.paletteService = new E();
|
|
64
64
|
e.setColorMatrix(t.colors, t.columns);
|
|
65
|
-
const o = e.getCellCoordsFor(this.state.selectedColor), r = e.getCellCoordsFor(this.state.focusedColor),
|
|
66
|
-
return t.colors.length ? /* @__PURE__ */
|
|
65
|
+
const o = e.getCellCoordsFor(this.state.selectedColor), r = e.getCellCoordsFor(this.state.focusedColor), l = C("k-colorpalette", { "k-disabled": this.props.disabled }, this.props.className);
|
|
66
|
+
return t.colors.length ? /* @__PURE__ */ i.createElement(
|
|
67
67
|
"div",
|
|
68
68
|
{
|
|
69
69
|
id: this.props.id,
|
|
70
70
|
role: "grid",
|
|
71
|
-
className:
|
|
71
|
+
className: l,
|
|
72
72
|
onFocus: this.onFocus,
|
|
73
73
|
onBlur: this.onBlur,
|
|
74
74
|
onKeyDown: this.onKeyDown,
|
|
75
75
|
"aria-disabled": this.props.ariaDisabled || (this.props.disabled ? "true" : void 0),
|
|
76
76
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
77
77
|
"aria-describedby": this.props.ariaDescribedBy,
|
|
78
|
-
tabIndex:
|
|
79
|
-
ref:
|
|
78
|
+
tabIndex: R(this.props.tabIndex, this.props.disabled),
|
|
79
|
+
ref: this.wrapperRef
|
|
80
80
|
},
|
|
81
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ i.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ i.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
|
|
82
82
|
) : "";
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -110,7 +110,7 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
|
|
|
110
110
|
this.isUncontrolled && this.setState({ selectedColor: this.state.focusedColor }), this.dispatchChangeEvent(this.state.focusedColor, t);
|
|
111
111
|
}
|
|
112
112
|
dispatchChangeEvent(t, e) {
|
|
113
|
-
|
|
113
|
+
F(this.props.onChange, e, this, { value: t, rgbaValue: U(t, "rgba") });
|
|
114
114
|
}
|
|
115
115
|
get focusedColorCooridanates() {
|
|
116
116
|
return this.state.focusedColor && this.paletteService ? this.paletteService.getCellCoordsFor(this.state.focusedColor) : void 0;
|
|
@@ -123,33 +123,33 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
|
|
|
123
123
|
const t = D[this.props.palette];
|
|
124
124
|
return L(t) ? {
|
|
125
125
|
colors: t.colors,
|
|
126
|
-
columns: this.props.columns || t.columns ||
|
|
126
|
+
columns: this.props.columns || t.columns || m
|
|
127
127
|
} : { colors: [], columns: 0 };
|
|
128
128
|
} else
|
|
129
|
-
return { colors: this.props.palette || [], columns: this.props.columns ||
|
|
129
|
+
return { colors: this.props.palette || [], columns: this.props.columns || m };
|
|
130
130
|
}
|
|
131
131
|
renderRows(t, e, o) {
|
|
132
|
-
return t.map((r,
|
|
132
|
+
return t.map((r, l) => /* @__PURE__ */ i.createElement("tr", { role: "row", key: l }, this.renderColumns(r, l, e, o)));
|
|
133
133
|
}
|
|
134
134
|
renderColumns(t, e, o, r) {
|
|
135
|
-
const
|
|
136
|
-
return t.map((
|
|
137
|
-
const
|
|
135
|
+
const l = o !== void 0 && o.row === e, g = o && o.col, v = r !== void 0 && r.row === e, b = r && r.col, h = typeof this.props.tileSize != "number" ? this.props.tileSize : { width: this.props.tileSize, height: this.props.tileSize }, u = h.width + "px", S = h.height + "px";
|
|
136
|
+
return t.map((d, c) => {
|
|
137
|
+
const f = l && g === c, w = C(
|
|
138
138
|
"k-colorpalette-tile",
|
|
139
139
|
{
|
|
140
|
-
"k-selected":
|
|
140
|
+
"k-selected": f,
|
|
141
141
|
"k-focus": v && b === c
|
|
142
142
|
}
|
|
143
143
|
);
|
|
144
|
-
return /* @__PURE__ */
|
|
144
|
+
return /* @__PURE__ */ i.createElement(
|
|
145
145
|
"td",
|
|
146
146
|
{
|
|
147
147
|
role: "gridcell",
|
|
148
148
|
className: w,
|
|
149
|
-
"aria-label":
|
|
150
|
-
"aria-selected":
|
|
151
|
-
style: { backgroundColor:
|
|
152
|
-
onClick: (y) => this.onColorClick(
|
|
149
|
+
"aria-label": d,
|
|
150
|
+
"aria-selected": f ? !0 : this.props.disabled ? void 0 : !1,
|
|
151
|
+
style: { backgroundColor: d, width: u, height: S, minWidth: u },
|
|
152
|
+
onClick: (y) => this.onColorClick(d, y),
|
|
153
153
|
id: this.createCellId({ row: e, col: c }),
|
|
154
154
|
key: c
|
|
155
155
|
}
|
|
@@ -178,14 +178,14 @@ n.displayName = "ColorPalette", n.propTypes = {
|
|
|
178
178
|
palette: z,
|
|
179
179
|
tileSize: x
|
|
180
180
|
};
|
|
181
|
-
let
|
|
182
|
-
const B =
|
|
181
|
+
let p = n;
|
|
182
|
+
const B = N(), A = P(T(B, p));
|
|
183
183
|
A.displayName = "KendoReactColorPalette";
|
|
184
184
|
export {
|
|
185
185
|
A as ColorPalette,
|
|
186
186
|
B as ColorPalettePropsContext,
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
p as ColorPaletteWithoutContext,
|
|
188
|
+
m as DEFAULT_COLUMNS_COUNT,
|
|
189
189
|
z as DEFAULT_PRESET,
|
|
190
190
|
x as DEFAULT_TILE_SIZE
|
|
191
191
|
};
|