@progress/kendo-react-inputs 9.5.0 → 10.0.0-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.
@@ -7,92 +7,91 @@
7
7
  */
8
8
  import * as a from "react";
9
9
  import R from "prop-types";
10
- import { createPropsContext as Y, validatePackage as _, usePropsContext as j, useDir as F, Keys as m, useDraggable as J, classNames as Q, getTabIndex as M } from "@progress/kendo-react-common";
11
- import { sliderDragTitle as S, messages as V } from "../messages/index.mjs";
12
- import { useLocalization as Z } from "@progress/kendo-react-intl";
13
- import { RANGE_ACTION as r, rangeReducer as ee } from "./range-raducer.mjs";
14
- import { packageMetadata as te } from "../package-metadata.mjs";
15
- const ae = (n, s, p) => {
16
- const [e, c] = a.useState(n), u = a.useCallback(
10
+ import { createPropsContext as Y, validatePackage as _, usePropsContext as j, useDir as J, Keys as m, useDraggable as Q, classNames as Z, getTabIndex as V, WatermarkOverlay as ee } from "@progress/kendo-react-common";
11
+ import { sliderDragTitle as $, messages as z } from "../messages/index.mjs";
12
+ import { useLocalization as te } from "@progress/kendo-react-intl";
13
+ import { RANGE_ACTION as r, rangeReducer as ae } from "./range-raducer.mjs";
14
+ import { packageMetadata as re } from "../package-metadata.mjs";
15
+ const ne = (n, s, p) => {
16
+ const [c, e] = a.useState(n), d = a.useCallback(
17
17
  (g) => {
18
- const b = ee(s.state || e, { ...g, ...s });
19
- p && p(b, g.event), c(b);
18
+ const S = ae(s.state || c, { ...g, ...s });
19
+ p && p(S, g.event), e(S);
20
20
  },
21
21
  [s, p]
22
22
  );
23
- return [e, u];
24
- }, re = Y(), z = a.forwardRef((n, s) => {
25
- _(te);
26
- const p = j(re, n), e = {
23
+ return [c, d];
24
+ }, le = Y(), P = a.forwardRef((n, s) => {
25
+ const p = !_(re, { component: "RangeSlider" }), c = j(le, n), e = {
27
26
  step: y.step,
28
27
  largeStep: y.largeStep,
29
28
  defaultValue: y.defaultValue,
30
29
  vertical: y.vertical,
31
30
  disabled: y.disabled,
32
- ...p
33
- }, c = a.useRef(null), u = a.useRef(null), g = a.useRef(null), b = a.useRef(null), I = a.useRef(null), P = a.useCallback(() => {
34
- b.current && b.current.focus();
35
- }, [b]);
36
- a.useImperativeHandle(c, () => ({
37
- element: u.current,
38
- focus: P,
31
+ ...c
32
+ }, d = a.useRef(null), g = a.useRef(null), S = a.useRef(null), D = a.useRef(null), T = a.useRef(null), K = a.useCallback(() => {
33
+ D.current && D.current.focus();
34
+ }, [D]);
35
+ a.useImperativeHandle(d, () => ({
36
+ element: g.current,
37
+ focus: K,
39
38
  props: e
40
- })), a.useImperativeHandle(s, () => c.current);
41
- const f = a.useMemo(() => e.min, [e.min]), k = a.useMemo(() => e.max, [e.max]), K = a.useMemo(
39
+ })), a.useImperativeHandle(s, () => d.current);
40
+ const f = a.useMemo(() => e.min, [e.min]), k = a.useMemo(() => e.max, [e.max]), A = a.useMemo(
42
41
  () => e.step !== void 0 ? e.step : y.step,
43
42
  [e.step, y.step]
44
- ), A = a.useMemo(
43
+ ), H = a.useMemo(
45
44
  () => e.largeStep !== void 0 ? e.largeStep : y.largeStep,
46
45
  [e.largeStep, y.largeStep]
47
- ), d = F(u, e.dir), H = (t, o) => {
48
- e.onChange && c.current && e.onChange.call(void 0, {
46
+ ), o = J(g, e.dir), N = (t, u) => {
47
+ e.onChange && d.current && e.onChange.call(void 0, {
49
48
  value: t,
50
- target: c.current,
51
- syntheticEvent: o
49
+ target: d.current,
50
+ syntheticEvent: u
52
51
  });
53
- }, [T, E] = a.useState(""), [x, l] = ae(
52
+ }, [E, L] = a.useState(""), [b, l] = ne(
54
53
  e.defaultValue || y.defaultValue,
55
54
  {
56
55
  min: f,
57
56
  max: k,
58
- step: K,
59
- largeStep: A,
57
+ step: A,
58
+ largeStep: H,
60
59
  state: e.value
61
60
  },
62
- H
63
- ), i = a.useMemo(() => e.value || x, [e.value, x]), N = a.useRef(null), w = a.useRef(null), h = a.useMemo(() => (i.start - f) / (k - f) * 100, [i.start, f, k]), D = a.useMemo(() => (i.end - f) / (k - f) * 100, [i.end, f, k]), q = a.useMemo(
61
+ N
62
+ ), i = a.useMemo(() => e.value || b, [e.value, b]), O = a.useRef(null), w = a.useRef(null), h = a.useMemo(() => (i.start - f) / (k - f) * 100, [i.start, f, k]), x = a.useMemo(() => (i.end - f) / (k - f) * 100, [i.end, f, k]), W = a.useMemo(
64
63
  () => e.vertical ? { paddingTop: 0, height: "100%" } : {},
65
64
  [e.vertical]
66
- ), B = a.useMemo(
65
+ ), q = a.useMemo(
67
66
  () => e.vertical ? { marginTop: "0.5rem", marginBottom: "0.5rem" } : { marginLeft: "0.5rem", marginRight: "0.5rem" },
68
67
  [e.vertical]
69
- ), L = Z(), $ = a.useCallback(
68
+ ), M = te(), C = a.useCallback(
70
69
  (t) => {
71
70
  if (!w.current)
72
71
  return;
73
- const o = w.current.getBoundingClientRect(), v = e.vertical ? o.bottom - t.clientY : d === "rtl" ? o.right - t.clientX : t.clientX - o.left, C = e.vertical ? o.height : o.width, W = v / C;
74
- return f + W * (k - f);
72
+ const u = w.current.getBoundingClientRect(), v = e.vertical ? u.bottom - t.clientY : o === "rtl" ? u.right - t.clientX : t.clientX - u.left, I = e.vertical ? u.height : u.width, F = v / I;
73
+ return f + F * (k - f);
75
74
  },
76
75
  [
77
76
  w,
78
77
  e.vertical,
79
- d,
78
+ o,
80
79
  f,
81
80
  k,
82
- x.start,
83
- x.end,
81
+ b.start,
82
+ b.end,
84
83
  e.value && e.value.start,
85
84
  e.value && e.value.end
86
85
  ]
87
- ), G = a.useCallback(
86
+ ), B = a.useCallback(
88
87
  (t) => t <= i.start ? "start" : t >= i.end ? "end" : 2 * t < i.end + i.start ? "start" : "end",
89
- [x.start, x.end, e.value && e.value.start, e.value && e.value.end]
90
- ), O = a.useCallback(
88
+ [b.start, b.end, e.value && e.value.start, e.value && e.value.end]
89
+ ), G = a.useCallback(
91
90
  (t) => {
92
91
  switch (t.keyCode) {
93
92
  case m.right:
94
93
  t.preventDefault(), l({
95
- type: d === "rtl" ? r.decrease : r.increase,
94
+ type: o === "rtl" ? r.decrease : r.increase,
96
95
  key: "start",
97
96
  event: t
98
97
  });
@@ -102,7 +101,7 @@ const ae = (n, s, p) => {
102
101
  break;
103
102
  case m.left:
104
103
  t.preventDefault(), l({
105
- type: d === "rtl" ? r.increase : r.decrease,
104
+ type: o === "rtl" ? r.increase : r.decrease,
106
105
  key: "start",
107
106
  event: t
108
107
  });
@@ -118,14 +117,14 @@ const ae = (n, s, p) => {
118
117
  break;
119
118
  case m.pageDown:
120
119
  t.preventDefault(), l({
121
- type: d === "rtl" ? r.increaseLarge : r.decreaseLarge,
120
+ type: o === "rtl" ? r.increaseLarge : r.decreaseLarge,
122
121
  key: "start",
123
122
  event: t
124
123
  });
125
124
  break;
126
125
  case m.pageUp:
127
126
  t.preventDefault(), l({
128
- type: d === "rtl" ? r.decreaseLarge : r.increaseLarge,
127
+ type: o === "rtl" ? r.decreaseLarge : r.increaseLarge,
129
128
  key: "start",
130
129
  event: t
131
130
  });
@@ -138,7 +137,7 @@ const ae = (n, s, p) => {
138
137
  switch (t.keyCode) {
139
138
  case m.right:
140
139
  t.preventDefault(), l({
141
- type: d === "rtl" ? r.decrease : r.increase,
140
+ type: o === "rtl" ? r.decrease : r.increase,
142
141
  key: "end",
143
142
  event: t
144
143
  });
@@ -148,7 +147,7 @@ const ae = (n, s, p) => {
148
147
  break;
149
148
  case m.left:
150
149
  t.preventDefault(), l({
151
- type: d === "rtl" ? r.increase : r.decrease,
150
+ type: o === "rtl" ? r.increase : r.decrease,
152
151
  key: "end",
153
152
  event: t
154
153
  });
@@ -164,55 +163,55 @@ const ae = (n, s, p) => {
164
163
  break;
165
164
  case m.pageDown:
166
165
  t.preventDefault(), l({
167
- type: d === "rtl" ? r.increaseLarge : r.decreaseLarge,
166
+ type: o === "rtl" ? r.increaseLarge : r.decreaseLarge,
168
167
  key: "end",
169
168
  event: t
170
169
  });
171
170
  break;
172
171
  case m.pageUp:
173
172
  t.preventDefault(), l({
174
- type: d === "rtl" ? r.decreaseLarge : r.increaseLarge,
173
+ type: o === "rtl" ? r.decreaseLarge : r.increaseLarge,
175
174
  key: "end",
176
175
  event: t
177
176
  });
178
177
  break;
179
178
  }
180
179
  },
181
- [l, d]
180
+ [l, o]
182
181
  ), X = a.useCallback(
183
182
  (t) => {
184
- const o = $(t), v = G(o);
185
- E(v), v === "end" ? I.current.focus() : b.current.focus();
186
- const C = v === "end" ? r.end : r.start;
187
- l({ type: C, payload: o, event: t });
183
+ const u = C(t), v = B(u);
184
+ L(v), v === "end" ? T.current.focus() : D.current.focus();
185
+ const I = v === "end" ? r.end : r.start;
186
+ l({ type: I, payload: u, event: t });
188
187
  },
189
188
  [e.vertical, f, k, l]
190
189
  );
191
- return J(
190
+ return Q(
192
191
  w,
193
192
  {
194
193
  onPress: X,
195
194
  onDrag: (t) => {
196
- const o = $(t), v = T === "end" ? r.end : r.start;
197
- l({ type: v, payload: o, event: t });
195
+ const u = C(t), v = E === "end" ? r.end : r.start;
196
+ l({ type: v, payload: u, event: t });
198
197
  },
199
198
  onRelease: (t) => {
200
- const o = $(t), v = T === "end" ? r.end : r.start;
201
- l({ type: v, payload: o, event: t }), E("");
199
+ const u = C(t), v = E === "end" ? r.end : r.start;
200
+ l({ type: v, payload: u, event: t }), L("");
202
201
  }
203
202
  },
204
203
  { autoScroll: !1 }
205
- ), /* @__PURE__ */ a.createElement(
204
+ ), /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement(
206
205
  "div",
207
206
  {
208
207
  id: e.id,
209
208
  style: e.style,
210
- ref: u,
211
- dir: d,
212
- className: Q(
209
+ ref: g,
210
+ dir: o,
211
+ className: Z(
213
212
  "k-slider",
214
213
  {
215
- "k-rtl": d === "rtl",
214
+ "k-rtl": o === "rtl",
216
215
  "k-disabled": e.disabled,
217
216
  "k-slider-vertical": e.vertical,
218
217
  "k-slider-horizontal": !e.vertical
@@ -229,81 +228,81 @@ const ae = (n, s, p) => {
229
228
  flexGrow: 1,
230
229
  position: "relative",
231
230
  touchAction: "none",
232
- ...B
231
+ ...q
233
232
  }
234
233
  },
235
- e.children && /* @__PURE__ */ a.createElement("ul", { className: "k-reset k-slider-items", style: { ...q } }, a.Children.map(e.children, (t, o) => t && a.cloneElement(
234
+ e.children && /* @__PURE__ */ a.createElement("ul", { className: "k-reset k-slider-items", style: { ...W } }, a.Children.map(e.children, (t, u) => t && a.cloneElement(
236
235
  t,
237
236
  {
238
237
  position: 100 * (t.props.position - e.min) / (e.max - e.min),
239
238
  vertical: e.vertical,
240
- firstTick: o === 0,
241
- lastTick: o === a.Children.count(e.children) - 1
239
+ firstTick: u === 0,
240
+ lastTick: u === a.Children.count(e.children) - 1
242
241
  },
243
242
  t.props.children
244
243
  ))),
245
244
  /* @__PURE__ */ a.createElement(
246
245
  "div",
247
246
  {
248
- ref: N,
247
+ ref: O,
249
248
  className: "k-slider-track",
250
- style: e.vertical ? { bottom: 0, height: "100%" } : { [d === "rtl" ? "right" : "left"]: 0, width: "100%" }
249
+ style: e.vertical ? { bottom: 0, height: "100%" } : { [o === "rtl" ? "right" : "left"]: 0, width: "100%" }
251
250
  },
252
- h !== null && D !== null && /* @__PURE__ */ a.createElement(
251
+ h !== null && x !== null && /* @__PURE__ */ a.createElement(
253
252
  "div",
254
253
  {
255
254
  "data-selection": !0,
256
- ref: g,
255
+ ref: S,
257
256
  title: `${i.start} - ${i.end}`,
258
257
  className: "k-slider-selection",
259
- style: e.vertical ? { height: D - h + "%", bottom: h + "%" } : {
260
- [d === "rtl" ? "right" : "left"]: h + "%",
261
- width: D - h + "%"
258
+ style: e.vertical ? { height: x - h + "%", bottom: h + "%" } : {
259
+ [o === "rtl" ? "right" : "left"]: h + "%",
260
+ width: x - h + "%"
262
261
  }
263
262
  }
264
263
  ),
265
264
  /* @__PURE__ */ a.createElement(
266
265
  "span",
267
266
  {
268
- ref: b,
267
+ ref: D,
269
268
  role: "slider",
270
- tabIndex: M(e.startTabIndex, e.disabled, void 0),
269
+ tabIndex: V(e.startTabIndex, e.disabled, void 0),
271
270
  "aria-valuemin": f,
272
271
  "aria-valuemax": Math.max(k, i.end),
273
272
  "aria-valuenow": i.start,
274
273
  "aria-disabled": e.disabled ? "true" : void 0,
275
274
  "aria-valuetext": `${i.start} - ${i.end}`,
276
275
  className: "k-draghandle k-draghandle-start",
277
- title: L.toLanguageString(S, V[S]),
278
- style: e.vertical ? { bottom: "calc(" + h + "%)", zIndex: 1 } : d === "rtl" ? { right: "calc(" + h + "% - 13px)", zIndex: 1 } : { left: "calc(" + h + "%)", zIndex: 1 },
279
- onKeyDown: O
276
+ title: M.toLanguageString($, z[$]),
277
+ style: e.vertical ? { bottom: "calc(" + h + "%)", zIndex: 1 } : o === "rtl" ? { right: "calc(" + h + "% - 13px)", zIndex: 1 } : { left: "calc(" + h + "%)", zIndex: 1 },
278
+ onKeyDown: G
280
279
  }
281
280
  ),
282
281
  /* @__PURE__ */ a.createElement(
283
282
  "span",
284
283
  {
285
- ref: I,
284
+ ref: T,
286
285
  role: "slider",
287
- tabIndex: M(e.endTabIndex, e.disabled, void 0),
286
+ tabIndex: V(e.endTabIndex, e.disabled, void 0),
288
287
  "aria-valuemin": Math.min(f, i.start),
289
288
  "aria-valuemax": k,
290
289
  "aria-valuenow": i.end,
291
290
  "aria-disabled": e.disabled ? "true" : void 0,
292
291
  "aria-valuetext": `${i.start} - ${i.end}`,
293
292
  className: "k-draghandle k-draghandle-end",
294
- title: L.toLanguageString(S, V[S]),
295
- style: e.vertical ? { bottom: "calc(" + D + "%)", zIndex: 1 } : d === "rtl" ? { right: "calc(" + D + "% - 13px)", zIndex: 1 } : { left: "calc(" + D + "%)", zIndex: 1 },
293
+ title: M.toLanguageString($, z[$]),
294
+ style: e.vertical ? { bottom: "calc(" + x + "%)", zIndex: 1 } : o === "rtl" ? { right: "calc(" + x + "% - 13px)", zIndex: 1 } : { left: "calc(" + x + "%)", zIndex: 1 },
296
295
  onKeyDown: U
297
296
  }
298
297
  )
299
298
  )
300
299
  )
301
- );
302
- }), ne = {
300
+ ), p && /* @__PURE__ */ a.createElement(ee, null));
301
+ }), se = {
303
302
  value: (n, s, p) => {
304
303
  if (n.value) {
305
- const e = n.value.start, c = n.value.end, u = n.min, g = n.max;
306
- if (e > c || e > g || e < u || c > g || c < u || c < e)
304
+ const c = n.value.start, e = n.value.end, d = n.min, g = n.max;
305
+ if (c > e || c > g || c < d || e > g || e < d || e < c)
307
306
  return new Error(
308
307
  `Invalid prop + ${s} supplied to ${p}.
309
308
  The { start, end } value must be between the min & max value and { start, end } must be start < end.
@@ -314,8 +313,8 @@ const ae = (n, s, p) => {
314
313
  },
315
314
  defaultValue: (n, s, p) => {
316
315
  if (n.defaultValue) {
317
- const e = n.defaultValue.start, c = n.defaultValue.end, u = n.min, g = n.max;
318
- if (e > c || e > g || e < u || c > g || c < u || c < e)
316
+ const c = n.defaultValue.start, e = n.defaultValue.end, d = n.min, g = n.max;
317
+ if (c > e || c > g || c < d || e > g || e < d || e < c)
319
318
  return new Error(
320
319
  `Invalid prop + ${s} supplied to ${p}.
321
320
  The { start, end } value must be between the min & max value and { start, end } must be start < end.
@@ -327,24 +326,24 @@ const ae = (n, s, p) => {
327
326
  onChange: R.func,
328
327
  step: R.number,
329
328
  min: (n, s, p) => {
330
- const e = n[s], c = n.min, u = n.max;
331
- return c === void 0 ? new Error(
329
+ const c = n[s], e = n.min, d = n.max;
330
+ return e === void 0 ? new Error(
332
331
  `Invalid prop + ${s} supplied to ${p}.
333
332
  ${s} value can not be undefined.
334
333
  `
335
- ) : e && c >= u ? new Error(
334
+ ) : c && e >= d ? new Error(
336
335
  `Invalid prop + ${s} supplied to ${p}.
337
336
  ${s} value can not be equal to or bigger than the max value.
338
337
  `
339
338
  ) : null;
340
339
  },
341
340
  max: (n, s, p) => {
342
- const e = n[s], c = n.min, u = n.max;
343
- return u === void 0 ? new Error(
341
+ const c = n[s], e = n.min, d = n.max;
342
+ return d === void 0 ? new Error(
344
343
  `Invalid prop + ${s} supplied to ${p}.
345
344
  ${s} value can not be undefined.
346
345
  `
347
- ) : e && u <= c ? new Error(
346
+ ) : c && d <= e ? new Error(
348
347
  `Invalid prop + ${s} supplied to ${p}.
349
348
  ${s} value can not be equal to or smaller than the min value.
350
349
  `
@@ -363,9 +362,9 @@ const ae = (n, s, p) => {
363
362
  vertical: !1,
364
363
  disabled: !1
365
364
  };
366
- z.displayName = "KendoReactRangeSlider";
367
- z.propTypes = ne;
365
+ P.displayName = "KendoReactRangeSlider";
366
+ P.propTypes = se;
368
367
  export {
369
- z as RangeSlider,
370
- re as RangeSliderPropsContext
368
+ P as RangeSlider,
369
+ le as RangeSliderPropsContext
371
370
  };
@@ -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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("@progress/kendo-inputs-common"),B=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-common"),he=require("@progress/kendo-react-dialogs"),Se=require("@progress/kendo-react-intl"),a=require("prop-types"),ze=require("react"),p=require("../messages/index.js"),Oe=require("../package-metadata.js"),Ee=require("./utils/index.js"),_=require("@progress/kendo-svg-icons");function xe(c){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const f in c)if(f!=="default"){const e=Object.getOwnPropertyDescriptor(c,f);Object.defineProperty(b,f,e.get?e:{enumerable:!0,get:()=>c[f]})}}return b.default=c,Object.freeze(b)}const n=xe(ze),Me=250,Ie=84,te=3,ne=2,we="#000000",Pe="#ffffff",ee=c=>c!==void 0,oe=s.createPropsContext(),O=n.forwardRef((c,b)=>{s.validatePackage(Oe.packageMetadata);const f=s.usePropsContext(oe,c),e=n.useMemo(()=>({strokeWidth:l.strokeWidth,smooth:l.smooth,popupScale:l.popupScale,exportScale:l.exportScale,maximizable:l.maximizable,disabled:l.disabled,required:l.required,validityStyles:l.validityStyles,onChange:l.onChange,onFocus:l.onFocus,onBlur:l.onBlur,onOpen:l.onOpen,onClose:l.onClose,size:l.size,rounded:l.rounded,fillMode:l.fillMode,...f}),[f]),E=Se.useLocalization(),d=n.useRef(null),y=n.useRef(null),N=n.useRef(null),F=n.useRef(null),x=n.useRef(null),[r,ae]=n.useState(),[v,j]=n.useState(!1),[M,G]=n.useState(!1),[C,W]=n.useState(),[re,se]=n.useState(),A=ee(e.value)?e.value:C,[ie,le]=n.useState(!1),k=ee(e.open),g=k?e.open:ie,ce=e.maximized||M||!e.maximizable||e.disabled,ue=!(e.maximized&&!M),de=!(!(e.value||C)||M||e.readOnly||e.disabled),V=E.toLanguageString(p.signatureMaximize,p.messages[p.signatureMaximize]),U=E.toLanguageString(p.signatureMinimize,p.messages[p.signatureMinimize]),H=E.toLanguageString(p.signatureClear,p.messages[p.signatureClear]),I=e.popupScale||te,w=e.exportScale||ne,P=t=>{W(t),e.onChange&&e.onChange({value:t})},me=t=>{r==null||r.loadImage(t.value),P(t.value)};n.useEffect(()=>{e.value!==C&&(W(e.value),r==null||r.loadImage(e.value))},[e.value]);const pe=()=>{r==null||r.clear(),P()},h=n.useCallback(t=>{k||le(t)},[k]),fe=t=>{var o,i;Q(t),(i=((o=x.current)==null?void 0:o.element)||y.current)==null||i.focus()},L=n.useCallback(()=>{let t=we;return!e.color&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).color),e.color||t},[e.color]),q=n.useCallback(()=>{let t=Pe;return!e.backgroundColor&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).backgroundColor),e.backgroundColor||t},[e.backgroundColor]),$=()=>({scale:e.maximized?e.popupScale:1,color:L(),backgroundColor:q(),strokeWidth:e.strokeWidth,smooth:e.smooth,readonly:e.readOnly}),K=async t=>{const{width:o,height:i}=t;return await(r==null?void 0:r.exportImage({width:o*w,height:i*w}))};n.useEffect(()=>{const t=y.current,o=new Ce.SignaturePad(t,$());return A&&o.loadImage(A),ae(o),()=>o.destroy()},[]),n.useEffect(()=>{r==null||r.setOptions({onChange:async()=>P(await K(Y())),onDraw:()=>G(!0),onDrawEnd:()=>G(!1)})},[r]),s.useIsomorphicLayoutEffect(()=>r==null?void 0:r.setOptions($()),[e.readOnly,e.color,e.backgroundColor,e.strokeWidth,e.smooth]),n.useEffect(()=>{var i,u;const t=(u=(i=N.current)==null?void 0:i.element)==null?void 0:u.querySelector(".k-overlay");if(!t)return;const o=()=>h(!1);return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[g]),n.useEffect(()=>{if(!g||typeof document=="undefined")return;const t=o=>{var i,u;o.key==="Escape"&&(h(!1),(u=(i=x.current)==null?void 0:i.element)==null||u.focus())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]),n.useEffect(()=>{var t,o;e.maximized&&((o=(t=F.current)==null?void 0:t.element)==null||o.focus())},[]);const D=n.useCallback(()=>{var t;return(t=y.current)==null?void 0:t.focus()},[]),S=n.useCallback(()=>e.value,[e.value]),X=n.useCallback(()=>e.name,[e.name]),z=n.useCallback(()=>e.required,[e.required]),R=n.useCallback(()=>{const t=e.validationMessage!==void 0,i=!S(),u=e.valid!==void 0?e.valid:!z()||!i;return{customError:t,valid:u,valueMissing:i}},[e.validationMessage,e.valid,S,z]),T=n.useCallback(()=>e.validityStyles,[e.validityStyles]),J=n.useCallback(()=>e,[e]),m=n.useCallback(()=>{const t={element:d.current,focus:D};return Object.defineProperty(t,"name",{get:X}),Object.defineProperty(t,"value",{get:S}),Object.defineProperty(t,"validity",{get:R}),Object.defineProperty(t,"validityStyles",{get:T}),Object.defineProperty(t,"required",{get:z}),Object.defineProperty(t,"props",{get:J}),Object.defineProperty(t,"color",{get:L}),Object.defineProperty(t,"backgroundColor",{get:q}),t},[X,S,R,T,z,D,J,L,q]);n.useImperativeHandle(b,m);const ge=n.useCallback(t=>{v||e.maximized||(j(!0),s.dispatchEvent(e.onFocus,t,m(),{}))},[v,e.onFocus,m]),be=n.useCallback(t=>{Ee.hasParent(t.relatedTarget,d.current)||(j(!1),s.dispatchEvent(e.onBlur,t,m(),{}))},[v,e.onBlur,m]),ke=n.useCallback(async t=>{se(await K(Z())),h(!0),s.dispatchEvent(e.onOpen,t,m(),{})},[g,k,e.onOpen,e.value,C,m]),Q=n.useCallback(t=>{h(!1),s.dispatchEvent(e.onClose,t,m(),{})},[g,k,e.onClose,m]),ye=()=>{pe(),D()},Y=()=>{var i,u;const t=e.width||((i=d.current)==null?void 0:i.offsetWidth)||Me,o=e.height||((u=d.current)==null?void 0:u.offsetHeight)||Ie;return{width:t,height:o}},Z=()=>{const{width:t,height:o}=Y();return{width:t*I,height:o*I}},ve=!T()||R().valid;return n.createElement("div",{ref:d,dir:e.dir,style:{width:e.width,height:e.height,...e.style},className:s.classNames("k-input","k-signature",{"k-signature-maximized":e.maximized,[`k-signature-${s.kendoThemeMaps.sizeMap[e.size]||e.size}`]:e.size,[`k-signature-${e.fillMode}`]:e.fillMode,[`k-input-${e.fillMode}`]:e.fillMode,[`k-rounded-${s.kendoThemeMaps.roundedMap[e.rounded]||e.rounded}`]:e.rounded,"k-invalid":!ve,"k-required":e.required,"k-disabled":e.disabled,"k-focus":v},e.className),onFocus:ge,onBlur:be},n.createElement("div",{className:"k-signature-canvas",ref:y,tabIndex:s.getTabIndex(e.tabIndex,e.disabled),role:"img",id:e.id,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-disabled":e.disabled?"true":void 0}),n.createElement("div",{className:"k-signature-actions k-signature-actions-top"},n.createElement(B.Button,{type:"button",className:s.classNames("k-signature-action","k-signature-maximize",{"k-hidden":e.disabled||ce}),ref:x,icon:"hyperlink-open",svgIcon:_.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:ke,"aria-label":V,title:V}),n.createElement(B.Button,{type:"button",className:s.classNames("k-signature-action","k-signature-minimize","k-rotate-180",{"k-hidden":e.disabled||ue}),ref:F,icon:"hyperlink-open",svgIcon:_.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:Q,"aria-label":U,title:U})),!e.hideLine&&n.createElement("div",{className:"k-signature-line",style:{zIndex:2,pointerEvents:"none"}}),n.createElement("div",{className:"k-signature-actions k-signature-actions-bottom"},de&&n.createElement(B.Button,{type:"button",className:"k-signature-action k-signature-clear",icon:"x",svgIcon:_.xIcon,fillMode:"flat",size:e.size,onClick:ye,"aria-label":H,title:H})),g&&n.createElement(he.Dialog,{ref:N},n.createElement(O,{...e,...Z(),value:re,maximized:!0,exportScale:1/I*w,open:!1,onChange:me,onClose:fe})))});O.propTypes={value:a.string,width:a.number,height:a.number,tabIndex:a.number,dir:a.string,ariaDescribedBy:a.string,ariaLabelledBy:a.string,ariaLabel:a.string,readOnly:a.bool,disabled:a.bool,validationMessage:a.string,required:a.bool,onChange:a.func,onFocus:a.func,onBlur:a.func,onOpen:a.func,onClose:a.func,size:a.oneOf([null,"small","medium","large"]),rounded:a.oneOf([null,"small","medium","large"]),fillMode:a.oneOf([null,"solid","flat","outline"])};const l={strokeWidth:1,smooth:!1,popupScale:te,exportScale:ne,maximizable:!0,disabled:!1,required:!1,validityStyles:!0,onChange:c=>s.noop,onFocus:c=>s.noop,onBlur:c=>s.noop,onOpen:c=>s.noop,onClose:c=>s.noop,size:"medium",rounded:"medium",fillMode:"solid"};O.displayName="KendoSignature";exports.Signature=O;exports.SignaturePropsContext=oe;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("@progress/kendo-inputs-common"),_=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-react-common"),Se=require("@progress/kendo-react-dialogs"),ze=require("@progress/kendo-react-intl"),a=require("prop-types"),Oe=require("react"),p=require("../messages/index.js"),Ee=require("../package-metadata.js"),xe=require("./utils/index.js"),N=require("@progress/kendo-svg-icons");function Me(c){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const f in c)if(f!=="default"){const b=Object.getOwnPropertyDescriptor(c,f);Object.defineProperty(k,f,b.get?b:{enumerable:!0,get:()=>c[f]})}}return k.default=c,Object.freeze(k)}const n=Me(Oe),we=250,Ie=84,ne=3,oe=2,Le="#000000",Pe="#ffffff",te=c=>c!==void 0,ae=r.createPropsContext(),E=n.forwardRef((c,k)=>{const f=!r.validatePackage(Ee.packageMetadata,{component:"Signature"}),b=r.usePropsContext(ae,c),e=n.useMemo(()=>({strokeWidth:l.strokeWidth,smooth:l.smooth,popupScale:l.popupScale,exportScale:l.exportScale,maximizable:l.maximizable,disabled:l.disabled,required:l.required,validityStyles:l.validityStyles,onChange:l.onChange,onFocus:l.onFocus,onBlur:l.onBlur,onOpen:l.onOpen,onClose:l.onClose,size:l.size,rounded:l.rounded,fillMode:l.fillMode,...b}),[b]),x=ze.useLocalization(),d=n.useRef(null),v=n.useRef(null),F=n.useRef(null),j=n.useRef(null),M=n.useRef(null),[s,re]=n.useState(),[h,W]=n.useState(!1),[w,G]=n.useState(!1),[C,A]=n.useState(),[se,ie]=n.useState(),V=te(e.value)?e.value:C,[le,ce]=n.useState(!1),y=te(e.open),g=y?e.open:le,ue=e.maximized||w||!e.maximizable||e.disabled,de=!(e.maximized&&!w),me=!(!(e.value||C)||w||e.readOnly||e.disabled),U=x.toLanguageString(p.signatureMaximize,p.messages[p.signatureMaximize]),H=x.toLanguageString(p.signatureMinimize,p.messages[p.signatureMinimize]),$=x.toLanguageString(p.signatureClear,p.messages[p.signatureClear]),I=e.popupScale||ne,L=e.exportScale||oe,P=t=>{A(t),e.onChange&&e.onChange({value:t})},pe=t=>{s==null||s.loadImage(t.value),P(t.value)};n.useEffect(()=>{e.value!==C&&(A(e.value),s==null||s.loadImage(e.value))},[e.value]);const fe=()=>{s==null||s.clear(),P()},S=n.useCallback(t=>{y||ce(t)},[y]),ge=t=>{var o,i;Y(t),(i=((o=M.current)==null?void 0:o.element)||v.current)==null||i.focus()},q=n.useCallback(()=>{let t=Le;return!e.color&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).color),e.color||t},[e.color]),D=n.useCallback(()=>{let t=Pe;return!e.backgroundColor&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).backgroundColor),e.backgroundColor||t},[e.backgroundColor]),K=()=>({scale:e.maximized?e.popupScale:1,color:q(),backgroundColor:D(),strokeWidth:e.strokeWidth,smooth:e.smooth,readonly:e.readOnly}),X=async t=>{const{width:o,height:i}=t;return await(s==null?void 0:s.exportImage({width:o*L,height:i*L}))};n.useEffect(()=>{const t=v.current,o=new Ce.SignaturePad(t,K());return V&&o.loadImage(V),re(o),()=>o.destroy()},[]),n.useEffect(()=>{s==null||s.setOptions({onChange:async()=>P(await X(Z())),onDraw:()=>G(!0),onDrawEnd:()=>G(!1)})},[s]),r.useIsomorphicLayoutEffect(()=>s==null?void 0:s.setOptions(K()),[e.readOnly,e.color,e.backgroundColor,e.strokeWidth,e.smooth]),n.useEffect(()=>{var i,u;const t=(u=(i=F.current)==null?void 0:i.element)==null?void 0:u.querySelector(".k-overlay");if(!t)return;const o=()=>S(!1);return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[g]),n.useEffect(()=>{if(!g||typeof document=="undefined")return;const t=o=>{var i,u;o.key==="Escape"&&(S(!1),(u=(i=M.current)==null?void 0:i.element)==null||u.focus())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]),n.useEffect(()=>{var t,o;e.maximized&&((o=(t=j.current)==null?void 0:t.element)==null||o.focus())},[]);const R=n.useCallback(()=>{var t;return(t=v.current)==null?void 0:t.focus()},[]),z=n.useCallback(()=>e.value,[e.value]),J=n.useCallback(()=>e.name,[e.name]),O=n.useCallback(()=>e.required,[e.required]),T=n.useCallback(()=>{const t=e.validationMessage!==void 0,i=!z(),u=e.valid!==void 0?e.valid:!O()||!i;return{customError:t,valid:u,valueMissing:i}},[e.validationMessage,e.valid,z,O]),B=n.useCallback(()=>e.validityStyles,[e.validityStyles]),Q=n.useCallback(()=>e,[e]),m=n.useCallback(()=>{const t={element:d.current,focus:R};return Object.defineProperty(t,"name",{get:J}),Object.defineProperty(t,"value",{get:z}),Object.defineProperty(t,"validity",{get:T}),Object.defineProperty(t,"validityStyles",{get:B}),Object.defineProperty(t,"required",{get:O}),Object.defineProperty(t,"props",{get:Q}),Object.defineProperty(t,"color",{get:q}),Object.defineProperty(t,"backgroundColor",{get:D}),t},[J,z,T,B,O,R,Q,q,D]);n.useImperativeHandle(k,m);const ke=n.useCallback(t=>{h||e.maximized||(W(!0),r.dispatchEvent(e.onFocus,t,m(),{}))},[h,e.onFocus,m]),be=n.useCallback(t=>{xe.hasParent(t.relatedTarget,d.current)||(W(!1),r.dispatchEvent(e.onBlur,t,m(),{}))},[h,e.onBlur,m]),ye=n.useCallback(async t=>{ie(await X(ee())),S(!0),r.dispatchEvent(e.onOpen,t,m(),{})},[g,y,e.onOpen,e.value,C,m]),Y=n.useCallback(t=>{S(!1),r.dispatchEvent(e.onClose,t,m(),{})},[g,y,e.onClose,m]),ve=()=>{fe(),R()},Z=()=>{var i,u;const t=e.width||((i=d.current)==null?void 0:i.offsetWidth)||we,o=e.height||((u=d.current)==null?void 0:u.offsetHeight)||Ie;return{width:t,height:o}},ee=()=>{const{width:t,height:o}=Z();return{width:t*I,height:o*I}},he=!B()||T().valid;return n.createElement("div",{ref:d,dir:e.dir,style:{width:e.width,height:e.height,...e.style},className:r.classNames("k-input","k-signature",{"k-signature-maximized":e.maximized,[`k-signature-${r.kendoThemeMaps.sizeMap[e.size]||e.size}`]:e.size,[`k-signature-${e.fillMode}`]:e.fillMode,[`k-input-${e.fillMode}`]:e.fillMode,[`k-rounded-${r.kendoThemeMaps.roundedMap[e.rounded]||e.rounded}`]:e.rounded,"k-invalid":!he,"k-required":e.required,"k-disabled":e.disabled,"k-focus":h},e.className),onFocus:ke,onBlur:be},n.createElement("div",{className:"k-signature-canvas",ref:v,tabIndex:r.getTabIndex(e.tabIndex,e.disabled),role:"img",id:e.id,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-disabled":e.disabled?"true":void 0}),n.createElement("div",{className:"k-signature-actions k-signature-actions-top"},n.createElement(_.Button,{type:"button",className:r.classNames("k-signature-action","k-signature-maximize",{"k-hidden":e.disabled||ue}),ref:M,icon:"hyperlink-open",svgIcon:N.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:ye,"aria-label":U,title:U}),n.createElement(_.Button,{type:"button",className:r.classNames("k-signature-action","k-signature-minimize","k-rotate-180",{"k-hidden":e.disabled||de}),ref:j,icon:"hyperlink-open",svgIcon:N.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:Y,"aria-label":H,title:H})),!e.hideLine&&n.createElement("div",{className:"k-signature-line",style:{zIndex:2,pointerEvents:"none"}}),n.createElement("div",{className:"k-signature-actions k-signature-actions-bottom"},me&&n.createElement(_.Button,{type:"button",className:"k-signature-action k-signature-clear",icon:"x",svgIcon:N.xIcon,fillMode:"flat",size:e.size,onClick:ve,"aria-label":$,title:$})),g&&n.createElement(Se.Dialog,{ref:F},n.createElement(E,{...e,...ee(),value:se,maximized:!0,exportScale:1/I*L,open:!1,onChange:pe,onClose:ge})),f&&n.createElement(r.WatermarkOverlay,null))});E.propTypes={value:a.string,width:a.number,height:a.number,tabIndex:a.number,dir:a.string,ariaDescribedBy:a.string,ariaLabelledBy:a.string,ariaLabel:a.string,readOnly:a.bool,disabled:a.bool,validationMessage:a.string,required:a.bool,onChange:a.func,onFocus:a.func,onBlur:a.func,onOpen:a.func,onClose:a.func,size:a.oneOf([null,"small","medium","large"]),rounded:a.oneOf([null,"small","medium","large"]),fillMode:a.oneOf([null,"solid","flat","outline"])};const l={strokeWidth:1,smooth:!1,popupScale:ne,exportScale:oe,maximizable:!0,disabled:!1,required:!1,validityStyles:!0,onChange:c=>r.noop,onFocus:c=>r.noop,onBlur:c=>r.noop,onOpen:c=>r.noop,onClose:c=>r.noop,size:"medium",rounded:"medium",fillMode:"solid"};E.displayName="KendoSignature";exports.Signature=E;exports.SignaturePropsContext=ae;