@progress/kendo-react-inputs 8.2.0-develop.8 → 8.2.0

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.
@@ -6,154 +6,213 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as o from "react";
10
- import i from "prop-types";
11
- import { focusFirstFocusableChild as E, validatePackage as F, getTabIndex as u, classNames as H, Draggable as L, createPropsContext as D, withIdHOC as N, withPropsContext as A } from "@progress/kendo-react-common";
12
- import { packageMetadata as B } from "../package-metadata.mjs";
13
- import { Slider as m } from "../slider/Slider.mjs";
14
- import { fitIntoBounds as C, isPresent as v } from "./utils/misc.mjs";
15
- import { getHSV as g, getColorFromHue as d, getRGBA as c, getColorFromRGBA as P, parseColor as l, getColorFromHSV as w } from "./utils/color-parser.mjs";
16
- import { cacheHex as I, cacheRgba as M, removeCachedColor as T, cacheHsva as V, getCachedHsva as G, getCachedRgba as O, getCachedHex as U } from "./utils/color-cache.mjs";
17
- import j from "./ColorInput.mjs";
18
- import { ColorContrastLabels as W } from "./ColorContrastLabels.mjs";
19
- import { ColorContrastSvg as $ } from "./ColorContrastSvg.mjs";
20
- import { provideLocalizationService as X } from "@progress/kendo-react-intl";
21
- import { colorGradientHueSliderLabel as f, messages as k, colorGradientAlphaSliderLabel as S } from "../messages/index.mjs";
22
- const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component {
23
- constructor(e) {
24
- super(e), this.wrapper = null, this.onHexChange = (t, s, r) => {
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 = g(s);
27
- this.setState({ hsva: n, backgroundColor: d(n.h), rgba: c(s), hex: t });
28
+ const n = b(s);
29
+ this.setState({ hsva: n, backgroundColor: c(n.h), rgba: p(s), hex: e });
28
30
  } else
29
- I(this.state.guid, s, t);
30
- this.dispatchChangeEvent(s, r, r.nativeEvent);
31
- }, this.onRgbaChange = (t, s) => {
32
- const r = P(t);
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 = g(r), p = l(r, "hex");
35
- this.setState({ hsva: n, backgroundColor: d(n.h), rgba: t, hex: p });
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
- M(this.state.guid, r, t);
38
- this.dispatchChangeEvent(r, s.syntheticEvent, s.nativeEvent);
39
- }, this.onAlphaSliderChange = (t) => {
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: t.value / 100 }),
42
- t.syntheticEvent,
43
- t.nativeEvent
43
+ Object.assign({}, this.state.hsva, { a: e.value / 100 }),
44
+ e.syntheticEvent,
45
+ e.nativeEvent
44
46
  );
45
- }, this.onHueSliderChange = (t) => {
47
+ }, this.onHueSliderChange = (e) => {
46
48
  this.handleHsvaChange(
47
- Object.assign({}, this.state.hsva, { h: t.value }),
48
- t.syntheticEvent,
49
- t.nativeEvent
49
+ Object.assign({}, this.state.hsva, { h: e.value }),
50
+ e.syntheticEvent,
51
+ e.nativeEvent
50
52
  );
51
- }, this.onDrag = (t) => {
52
- this.gradientWrapper.classList.add("k-dragging"), this.changePosition(t.event);
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 = (t) => {
56
- this.changePosition(t);
57
- }, this.changePosition = (t) => {
58
- const s = this.getGradientRectMetrics(), r = t.clientX - s.left, n = t.clientY - s.top, p = C(r, 0, s.width), x = C(n, 0, s.height), y = Object.assign(
59
- {},
60
- this.state.hsva,
61
- { s: p / s.width, v: 1 - x / s.height }
62
- );
63
- this.handleHsvaChange(y, t, t.nativeEvent);
64
- }, this.onFocus = (t) => {
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: t, target: this }
71
+ { nativeEvent: e, target: this }
68
72
  );
69
- }, this.focus = () => {
70
- this.wrapper && E(this.wrapper);
71
- }, F(B);
72
- const a = e.value || e.defaultValue || l(R, Y);
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(e, a) {
79
- return e.value && !a.isFirstRender ? h.getStateFromValue(e.value, a.guid) : null;
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
- T(this.state.guid);
137
+ W(this.state.guid);
92
138
  }
93
139
  /**
94
140
  * @hidden
95
141
  */
96
- componentDidUpdate(e, a) {
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 e = {};
149
+ let t = {};
104
150
  if (!this.state.isFirstRender) {
105
- const a = this.getGradientRectMetrics(), t = (1 - this.state.hsva.v) * a.height, s = this.state.hsva.s * a.width;
106
- e.top = `${t}px`, e.left = `${s}px`;
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__ */ o.createElement(
154
+ return /* @__PURE__ */ r.createElement(
109
155
  "div",
110
156
  {
157
+ ref: this.hsvGradientRef,
111
158
  role: "slider",
112
- tabIndex: u(this.props.tabIndex, this.props.disabled),
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: e
166
+ style: t,
167
+ onKeyDown: this.onHsvGradientKeyDown
120
168
  }
121
169
  );
122
170
  }
123
171
  /**
124
172
  * @hidden
125
173
  */
126
- handleHsvaChange(e, a, t) {
127
- const s = w(e);
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 r = l(s, "hex");
130
- this.setState({ hsva: e, backgroundColor: d(e.h), rgba: c(s), hex: r });
188
+ const i = d(s, "hex");
189
+ this.setState({ hsva: t, backgroundColor: c(t.h), rgba: p(s), hex: i });
131
190
  } else
132
- V(this.state.guid, s, e);
133
- this.dispatchChangeEvent(s, a, t);
191
+ $(this.state.guid, s, t);
192
+ this.dispatchChangeEvent(s, a, e);
134
193
  }
135
194
  /**
136
195
  * @hidden
137
196
  */
138
- dispatchChangeEvent(e, a, t) {
197
+ dispatchChangeEvent(t, a, e) {
139
198
  this.props.onChange && this.props.onChange.call(
140
199
  void 0,
141
- { syntheticEvent: a, nativeEvent: t, target: this, value: e }
200
+ { syntheticEvent: a, nativeEvent: e, target: this, value: t }
142
201
  );
143
202
  }
144
203
  /**
145
204
  * @hidden
146
205
  */
147
- static getStateFromValue(e, a) {
148
- v(l(e, "hex")) || (e = R);
149
- const t = G(a, e) || g(e), s = O(a, e) || c(e), r = U(a, e) || l(e, "hex"), n = d(t.h);
150
- return { hsva: t, backgroundColor: n, rgba: s, hex: r };
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(e) {
156
- this.props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack && (this.alphaSlider.sliderTrack.style.background = `linear-gradient(to top, transparent, ${e})`);
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 e = X(this), a = H("k-colorgradient", { "k-disabled": this.props.disabled }, this.props.className);
175
- return /* @__PURE__ */ o.createElement(
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: (t) => this.wrapper = t,
184
- tabIndex: u(this.props.tabIndex, this.props.disabled),
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__ */ o.createElement("div", { className: "k-colorgradient-canvas k-hstack" }, /* @__PURE__ */ o.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } }, /* @__PURE__ */ o.createElement(
191
- L,
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: (t) => this.gradientWrapper = t ? t.element : void 0
255
+ ref: (e) => this.gradientWrapper = e ? e.element : void 0
196
256
  },
197
- /* @__PURE__ */ o.createElement(
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__ */ o.createElement(
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__ */ o.createElement("div", { className: "k-hsv-controls k-hstack" }, /* @__PURE__ */ o.createElement(
214
- m,
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: e.toLanguageString(f, k[f])
285
+ ariaLabel: t.toLanguageString(E, x[E])
226
286
  }
227
- ), this.props.opacity && /* @__PURE__ */ o.createElement(
228
- m,
287
+ ), this.props.opacity && /* @__PURE__ */ r.createElement(
288
+ k,
229
289
  {
230
- value: v(this.state.hsva.a) ? this.state.hsva.a * 100 : 100,
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: e.toLanguageString(S, k[S]),
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: (t) => this.alphaSlider = t
300
+ ref: (e) => this.alphaSlider = e
241
301
  }
242
302
  ))),
243
- /* @__PURE__ */ o.createElement(
244
- j,
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__ */ o.createElement(
256
- W,
315
+ this.props.backgroundColor && /* @__PURE__ */ r.createElement(
316
+ q,
257
317
  {
258
- bgColor: c(this.props.backgroundColor),
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: i.string,
267
- value: i.string,
268
- onChange: i.func,
269
- onFocus: i.func,
270
- opacity: i.bool,
271
- backgroundColor: i.string,
272
- format: i.any,
273
- disabled: i.bool,
274
- style: i.any,
275
- id: i.string,
276
- role: i.string,
277
- ariaLabel: i.string,
278
- ariaLabelledBy: i.string,
279
- ariaDescribedBy: i.string,
280
- className: i.string
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 b = h;
287
- const z = D(), K = N(A(z, b));
288
- K.displayName = "KendoReactColorGradient";
346
+ let f = h;
347
+ const ee = M(), te = _(B(ee, f));
348
+ te.displayName = "KendoReactColorGradient";
289
349
  export {
290
- K as ColorGradient,
291
- z as ColorGradientPropsContext,
292
- b as ColorGradientWithoutContext
350
+ te as ColorGradient,
351
+ ee as ColorGradientPropsContext,
352
+ f as ColorGradientWithoutContext
293
353
  };
@@ -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 T=require("react"),s=require("prop-types"),N=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),R=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 a=O(T),b=24,C=10,m="office",c=class c extends a.Component{constructor(t){super(t),this.wrapper=null,this.paletteService=null,this.focus=()=>{this.wrapper&&this.wrapper.focus()},this.onKeyDown=e=>{switch(e.keyCode){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(R.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 N.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor),l=r.classNames("k-colorpalette",{"k-disabled":this.props.disabled},this.props.className);return t.colors.length?a.createElement("div",{id:this.props.id,role:"grid",className:l,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:h=>this.wrapper=h},a.createElement("table",{className:"k-colorpalette-table",role:"presentation"},a.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||C}:{colors:[],columns:0}}else return{colors:this.props.palette||[],columns:this.props.columns||C}}renderRows(t,e,o){return t.map((i,l)=>a.createElement("tr",{role:"row",key:l},this.renderColumns(i,l,e,o)))}renderColumns(t,e,o,i){const l=o!==void 0&&o.row===e,h=o&&o.col,E=i!==void 0&&i.row===e,w=i&&i.col,f=typeof this.props.tileSize!="number"?this.props.tileSize:{width:this.props.tileSize,height:this.props.tileSize},g=f.width+"px",P=f.height+"px";return t.map((u,d)=>{const v=l&&h===d,k=r.classNames("k-colorpalette-tile",{"k-selected":v,"k-focus":E&&w===d});return a.createElement("td",{role:"gridcell",className:k,"aria-label":u,"aria-selected":v?!0:this.props.disabled?void 0:!1,style:{backgroundColor:u,width:g,height:P,minWidth:g},onClick:F=>this.onColorClick(u,F),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:m,tileSize:b};let p=c;const S=r.createPropsContext(),y=r.withIdHOC(r.withPropsContext(S,p));y.displayName="KendoReactColorPalette";exports.ColorPalette=y;exports.ColorPalettePropsContext=S;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=C;exports.DEFAULT_PRESET=m;exports.DEFAULT_TILE_SIZE=b;
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;
@@ -6,20 +6,20 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as l from "react";
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 { Keys as a, validatePackage as k, classNames as m, getTabIndex as F, dispatchEvent as N, createPropsContext as P, withIdHOC as R, withPropsContext as T } from "@progress/kendo-react-common";
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, g = 10, z = "office", n = class n extends l.Component {
17
+ const x = 24, m = 10, z = "office", n = class n extends i.Component {
18
18
  constructor(t) {
19
- super(t), this.wrapper = null, this.paletteService = null, this.focus = () => {
20
- this.wrapper && this.wrapper.focus();
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.keyCode) {
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), i = m("k-colorpalette", { "k-disabled": this.props.disabled }, this.props.className);
66
- return t.colors.length ? /* @__PURE__ */ l.createElement(
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: i,
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: F(this.props.tabIndex, this.props.disabled),
79
- ref: (d) => this.wrapper = d
78
+ tabIndex: R(this.props.tabIndex, this.props.disabled),
79
+ ref: this.wrapperRef
80
80
  },
81
- /* @__PURE__ */ l.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ l.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
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
- N(this.props.onChange, e, this, { value: t, rgbaValue: U(t, "rgba") });
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 || g
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 || g };
129
+ return { colors: this.props.palette || [], columns: this.props.columns || m };
130
130
  }
131
131
  renderRows(t, e, o) {
132
- return t.map((r, i) => /* @__PURE__ */ l.createElement("tr", { role: "row", key: i }, this.renderColumns(r, i, e, o)));
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 i = o !== void 0 && o.row === e, d = o && o.col, v = r !== void 0 && r.row === e, b = r && r.col, u = typeof this.props.tileSize != "number" ? this.props.tileSize : { width: this.props.tileSize, height: this.props.tileSize }, f = u.width + "px", S = u.height + "px";
136
- return t.map((p, c) => {
137
- const C = i && d === c, w = m(
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": C,
140
+ "k-selected": f,
141
141
  "k-focus": v && b === c
142
142
  }
143
143
  );
144
- return /* @__PURE__ */ l.createElement(
144
+ return /* @__PURE__ */ i.createElement(
145
145
  "td",
146
146
  {
147
147
  role: "gridcell",
148
148
  className: w,
149
- "aria-label": p,
150
- "aria-selected": C ? !0 : this.props.disabled ? void 0 : !1,
151
- style: { backgroundColor: p, width: f, height: S, minWidth: f },
152
- onClick: (y) => this.onColorClick(p, y),
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 h = n;
182
- const B = P(), A = R(T(B, h));
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
- h as ColorPaletteWithoutContext,
188
- g as DEFAULT_COLUMNS_COUNT,
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
  };