@progress/kendo-react-inputs 13.4.0-develop.4 → 14.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.
@@ -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 ge=require("react"),e=require("prop-types"),o=require("@progress/kendo-react-common"),ye=require("@progress/kendo-react-intl"),I=require("../messages/index.js");function xe(s){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const p=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(u,r,p.get?p:{enumerable:!0,get:()=>s[r]})}}return u.default=s,Object.freeze(u)}const t=xe(ge),A=o.createPropsContext(),M=t.forwardRef((s,u)=>{const r=o.usePropsContext(A,s),{ariaDescribedBy:p,ariaLabelledBy:W,checked:O,className:G,labelClassName:J,children:Q,defaultChecked:X,disabled:n,defaultValue:Y,id:B,size:h=$.size,rounded:v=$.rounded,label:q,labelPlacement:z,name:Z,labelOptional:ee,onChange:C,onFocus:g,onBlur:y,tabIndex:te,value:i,required:k,valid:D,validationMessage:T,validityStyles:F,autoFocus:ae,visited:Pe,touched:Ve,modified:Ee,...ne}=r,l=t.useRef(null),K=t.useCallback(()=>{l.current&&l.current.focus()},[]),d=t.useCallback(()=>({element:l.current,focus:K,get name(){return l.current&&l.current.name}}),[K]);t.useImperativeHandle(u,d);const[oe,le]=t.useState(X),[ce,se]=t.useState(Y),R=typeof i=="boolean"||i===null,x=O!==void 0,b=R,P=b?i:ce,V=x?O:b?void 0:oe,w=V===void 0&&P,j=w?P:V,m=w||b?i===null?i:void 0:i||P,re=j===null||m===null,L=o.useId(),ie=ye.useLocalization(),_=a=>ie.toLanguageString(a,I.messages[a]),H=_(I.checkboxValidation),de=_(I.checkboxOptionalText),E=D!==void 0?D:k?!!V:!0;t.useEffect(()=>{l.current&&l.current.setCustomValidity&&l.current.setCustomValidity(E?"":T||H)},[E,T,H]);const f=t.useCallback((a,c)=>{!b&&!n&&(se(c),!x&&!n&&le(c)),C&&!n&&o.dispatchEvent(C,a,{...d(),value:c},{value:c})},[x,n,C,b,d]),ue=t.useCallback(a=>{const c=a.target.checked;f(a,c)},[f,i]),be=t.useCallback(a=>{if(n)return;const{keyCode:c}=a,Ce=a.currentTarget.checked;c===o.Keys.space&&(a.preventDefault(),a.stopPropagation(),f(a,!Ce))},[n,f]),pe=t.useCallback(a=>{if(n)return;const{keyCode:c}=a;c===o.Keys.space&&a.preventDefault()},[n]),ke=t.useCallback(a=>{g&&!n&&o.dispatchEvent(g,a,d(),void 0)},[g,n,d]),me=t.useCallback(a=>{y&&!n&&o.dispatchEvent(y,a,d(),void 0)},[y,n,d]),fe=o.useDir(l,r.dir),he=o.classNames("k-checkbox-wrap",G),U={type:"checkbox",className:o.classNames("k-checkbox",{[`k-checkbox-${o.kendoThemeMaps.sizeMap[h]||h}`]:h,[`k-rounded-${o.kendoThemeMaps.roundedMap[v]||v}`]:v,"k-indeterminate":re,"k-disabled":n,"k-invalid k-invalid":!(E||F!==void 0||F===!0)}),ref:l,name:Z,id:B||L,disabled:n,required:k!==void 0?k:!1,tabIndex:o.getTabIndex(te,n),role:"checkbox",checked:!!j,"aria-describedby":p,"aria-labelledby":W,"aria-disabled":n||void 0,"aria-required":k,autoFocus:ae,...ne,onChange:ue,onKeyDown:be,onKeyUp:pe,onFocus:ke,onBlur:me},ve=m===void 0?t.createElement("input",{...U}):t.createElement("input",{...U,value:R?void 0:m===null?"":m}),N=q!==void 0?t.createElement("label",{className:o.classNames("k-checkbox-label",J),htmlFor:B||L,style:{userSelect:"none"}},q,ee&&t.createElement("span",{className:"k-label-optional"},de)):null,S=t.createElement("span",{className:he},ve,Q);return t.createElement(t.Fragment,null,z==="before"?t.createElement("div",{dir:"rtl"},S,N):z==="after"?t.createElement("div",{dir:"ltr"},S,N):t.createElement("div",{dir:fe},S,N))});M.propTypes={checked:e.bool,className:e.string,defaultChecked:e.bool,defaultValue:e.any,dir:e.string,disabled:e.bool,id:e.string,size:e.oneOf(["small","medium","large"]),rounded:e.oneOf(["small","medium","large","none"]),ariaLabelledBy:e.string,ariaDescribedBy:e.string,label:e.any,labelPlacement:e.string,labelOptional:e.bool,name:e.string,tabIndex:e.number,value:e.any,validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,autoFocus:e.bool,onChange:e.func,onFocus:e.func,onBlur:e.func};const $={size:void 0,rounded:void 0};M.displayName="KendoCheckbox";exports.Checkbox=M;exports.CheckboxPropsContext=A;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xe=require("react"),e=require("prop-types"),o=require("@progress/kendo-react-common"),Pe=require("@progress/kendo-react-intl"),I=require("../messages/index.js");function Ve(c){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const k=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(b,r,k.get?k:{enumerable:!0,get:()=>c[r]})}}return b.default=c,Object.freeze(b)}const t=Ve(xe),G=o.createPropsContext(),M=t.forwardRef((c,b)=>{const r=o.usePropsContext(G,c),{ariaDescribedBy:k,ariaLabelledBy:J,checked:O,className:Q,labelClassName:X,children:Y,defaultChecked:Z,disabled:n,defaultValue:ee,id:h,size:v=W.size,rounded:g=W.rounded,label:T,labelPlacement:q,name:z,labelOptional:te,onChange:C,onFocus:y,onBlur:x,tabIndex:ae,value:i,required:p,valid:D,validationMessage:F,validityStyles:K,autoFocus:ne,visited:Ee,touched:Ne,modified:Se,...oe}=r,l=t.useRef(null),R=t.useCallback(()=>{l.current&&l.current.focus()},[]),d=t.useCallback(()=>({element:l.current,focus:R,get name(){return l.current&&l.current.name}}),[R]);t.useImperativeHandle(b,d);const[le,se]=t.useState(Z),[ce,re]=t.useState(ee),w=typeof i=="boolean"||i===null,P=O!==void 0,m=w,V=m?i:ce,E=P?O:m?void 0:le,j=z||h,L=E===void 0&&V,_=L?V:E,f=L||m?i===null?i:void 0:i||V,ie=_===null||f===null,H=o.useId(),de=Pe.useLocalization(),U=a=>de.toLanguageString(a,I.messages[a]),$=U(I.checkboxValidation),ue=U(I.checkboxOptionalText),N=D!==void 0?D:p?!!E:!0;t.useEffect(()=>{l.current&&l.current.setCustomValidity&&l.current.setCustomValidity(N?"":F||$)},[N,F,$]);const u=t.useCallback((a,s)=>{!m&&!n&&(re(s),!P&&!n&&se(s)),C&&!n&&o.dispatchEvent(C,a,{...d(),value:s},{value:s})},[P,n,C,m,d]),be=t.useCallback(a=>{const s={target:l.current,currentTarget:l.current};u(s,a)},[u]);o.useKendoPaste(l,{fieldName:j,onValueChange:be,enabled:!!j});const me=t.useCallback(a=>{const s=a.target.checked;u(a,s)},[u,i]),ke=t.useCallback(a=>{if(n)return;const{keyCode:s}=a,ye=a.currentTarget.checked;s===o.Keys.space&&(a.preventDefault(),a.stopPropagation(),u(a,!ye))},[n,u]),pe=t.useCallback(a=>{if(n)return;const{keyCode:s}=a;s===o.Keys.space&&a.preventDefault()},[n]),fe=t.useCallback(a=>{y&&!n&&o.dispatchEvent(y,a,d(),void 0)},[y,n,d]),he=t.useCallback(a=>{x&&!n&&o.dispatchEvent(x,a,d(),void 0)},[x,n,d]),ve=o.useDir(l,r.dir),ge=o.classNames("k-checkbox-wrap",Q),A={type:"checkbox",className:o.classNames("k-checkbox",{[`k-checkbox-${o.kendoThemeMaps.sizeMap[v]||v}`]:v,[`k-rounded-${o.kendoThemeMaps.roundedMap[g]||g}`]:g,"k-indeterminate":ie,"k-disabled":n,"k-invalid k-invalid":!(N||K!==void 0||K===!0)}),ref:l,name:z,id:h||H,disabled:n,required:p!==void 0?p:!1,tabIndex:o.getTabIndex(ae,n),role:"checkbox",checked:!!_,"aria-describedby":k,"aria-labelledby":J,"aria-disabled":n||void 0,"aria-required":p,autoFocus:ne,...oe,onChange:me,onKeyDown:ke,onKeyUp:pe,onFocus:fe,onBlur:he},Ce=f===void 0?t.createElement("input",{...A}):t.createElement("input",{...A,value:w?void 0:f===null?"":f}),S=T!==void 0?t.createElement("label",{className:o.classNames("k-checkbox-label",X),htmlFor:h||H,style:{userSelect:"none"}},T,te&&t.createElement("span",{className:"k-label-optional"},ue)):null,B=t.createElement("span",{className:ge},Ce,Y);return t.createElement(t.Fragment,null,q==="before"?t.createElement("div",{dir:"rtl"},B,S):q==="after"?t.createElement("div",{dir:"ltr"},B,S):t.createElement("div",{dir:ve},B,S))});M.propTypes={checked:e.bool,className:e.string,defaultChecked:e.bool,defaultValue:e.any,dir:e.string,disabled:e.bool,id:e.string,size:e.oneOf(["small","medium","large"]),rounded:e.oneOf(["small","medium","large","none"]),ariaLabelledBy:e.string,ariaDescribedBy:e.string,label:e.any,labelPlacement:e.string,labelOptional:e.bool,name:e.string,tabIndex:e.number,value:e.any,validationMessage:e.string,required:e.bool,validate:e.bool,valid:e.bool,autoFocus:e.bool,onChange:e.func,onFocus:e.func,onBlur:e.func};const W={size:void 0,rounded:void 0};M.displayName="KendoCheckbox";exports.Checkbox=M;exports.CheckboxPropsContext=G;
@@ -5,47 +5,47 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
9
- import e from "prop-types";
10
- import { createPropsContext as ye, usePropsContext as xe, useId as Ve, dispatchEvent as V, Keys as H, useDir as Ee, classNames as E, getTabIndex as Pe, kendoThemeMaps as U } from "@progress/kendo-react-common";
11
- import { useLocalization as Be } from "@progress/kendo-react-intl";
12
- import { messages as Ie, checkboxValidation as Ne, checkboxOptionalText as ze } from "../messages/index.mjs";
13
- const Fe = ye(), $ = a.forwardRef((A, W) => {
14
- const P = xe(Fe, A), {
15
- ariaDescribedBy: j,
16
- ariaLabelledBy: G,
17
- checked: B,
18
- className: J,
19
- labelClassName: Q,
20
- children: X,
21
- defaultChecked: Y,
8
+ import * as e from "react";
9
+ import a from "prop-types";
10
+ import { createPropsContext as Ve, usePropsContext as Pe, useId as Ee, dispatchEvent as P, useKendoPaste as Be, Keys as _, useDir as Ne, classNames as E, getTabIndex as Ie, kendoThemeMaps as $ } from "@progress/kendo-react-common";
11
+ import { useLocalization as Fe } from "@progress/kendo-react-intl";
12
+ import { messages as ze, checkboxValidation as Ke, checkboxOptionalText as Me } from "../messages/index.mjs";
13
+ const Se = Ve(), W = e.forwardRef((j, G) => {
14
+ const B = Pe(Se, j), {
15
+ ariaDescribedBy: J,
16
+ ariaLabelledBy: Q,
17
+ checked: N,
18
+ className: X,
19
+ labelClassName: Y,
20
+ children: Z,
21
+ defaultChecked: ee,
22
22
  disabled: o,
23
- defaultValue: Z,
24
- id: I,
25
- size: b = _.size,
26
- rounded: m = _.rounded,
27
- label: N,
28
- labelPlacement: z,
29
- name: ee,
30
- labelOptional: ae,
31
- onChange: p,
32
- onFocus: k,
33
- onBlur: f,
34
- tabIndex: te,
23
+ defaultValue: ae,
24
+ id: b,
25
+ size: m = A.size,
26
+ rounded: p = A.rounded,
27
+ label: I,
28
+ labelPlacement: F,
29
+ name: z,
30
+ labelOptional: te,
31
+ onChange: k,
32
+ onFocus: f,
33
+ onBlur: h,
34
+ tabIndex: oe,
35
35
  value: s,
36
- required: i,
37
- valid: F,
36
+ required: d,
37
+ valid: K,
38
38
  validationMessage: M,
39
39
  validityStyles: S,
40
- autoFocus: oe,
40
+ autoFocus: ne,
41
41
  // Removed to support direct use in Form Field component
42
- visited: Me,
43
- touched: Se,
44
- modified: De,
45
- ...ne
46
- } = P, n = a.useRef(null), D = a.useCallback(() => {
42
+ visited: De,
43
+ touched: Te,
44
+ modified: we,
45
+ ...le
46
+ } = B, n = e.useRef(null), D = e.useCallback(() => {
47
47
  n.current && n.current.focus();
48
- }, []), c = a.useCallback(
48
+ }, []), c = e.useCallback(
49
49
  () => ({
50
50
  element: n.current,
51
51
  focus: D,
@@ -55,15 +55,15 @@ const Fe = ye(), $ = a.forwardRef((A, W) => {
55
55
  }),
56
56
  [D]
57
57
  );
58
- a.useImperativeHandle(W, c);
59
- const [le, se] = a.useState(Y), [ce, re] = a.useState(Z), K = typeof s == "boolean" || s === null, h = B !== void 0, r = K, v = r ? s : ce, C = h ? B : r ? void 0 : le, T = C === void 0 && v, w = T ? v : C, d = T || r ? s === null ? s : void 0 : s || v, ie = w === null || d === null, L = Ve(), de = Be(), O = (t) => de.toLanguageString(t, Ie[t]), q = O(Ne), ue = O(ze), g = F !== void 0 ? F : i ? !!C : !0;
60
- a.useEffect(() => {
61
- n.current && n.current.setCustomValidity && n.current.setCustomValidity(g ? "" : M || q);
62
- }, [g, M, q]);
63
- const u = a.useCallback(
58
+ e.useImperativeHandle(G, c);
59
+ const [se, ce] = e.useState(ee), [re, ie] = e.useState(ae), T = typeof s == "boolean" || s === null, v = N !== void 0, i = T, C = i ? s : re, g = v ? N : i ? void 0 : se, w = z || b, L = g === void 0 && C, O = L ? C : g, u = L || i ? s === null ? s : void 0 : s || C, de = O === null || u === null, q = Ee(), ue = Fe(), R = (t) => ue.toLanguageString(t, ze[t]), H = R(Ke), be = R(Me), y = K !== void 0 ? K : d ? !!g : !0;
60
+ e.useEffect(() => {
61
+ n.current && n.current.setCustomValidity && n.current.setCustomValidity(y ? "" : M || H);
62
+ }, [y, M, H]);
63
+ const r = e.useCallback(
64
64
  (t, l) => {
65
- !r && !o && (re(l), !h && !o && se(l)), p && !o && V(
66
- p,
65
+ !i && !o && (ie(l), !v && !o && ce(l)), k && !o && P(
66
+ k,
67
67
  t,
68
68
  {
69
69
  ...c(),
@@ -72,116 +72,131 @@ const Fe = ye(), $ = a.forwardRef((A, W) => {
72
72
  { value: l }
73
73
  );
74
74
  },
75
- [h, o, p, r, c]
76
- ), be = a.useCallback(
75
+ [v, o, k, i, c]
76
+ ), me = e.useCallback(
77
+ (t) => {
78
+ const l = {
79
+ target: n.current,
80
+ currentTarget: n.current
81
+ };
82
+ r(l, t);
83
+ },
84
+ [r]
85
+ );
86
+ Be(n, {
87
+ fieldName: w,
88
+ onValueChange: me,
89
+ enabled: !!w
90
+ });
91
+ const pe = e.useCallback(
77
92
  (t) => {
78
93
  const l = t.target.checked;
79
- u(t, l);
94
+ r(t, l);
80
95
  },
81
- [u, s]
82
- ), me = a.useCallback(
96
+ [r, s]
97
+ ), ke = e.useCallback(
83
98
  (t) => {
84
99
  if (o)
85
100
  return;
86
- const { keyCode: l } = t, ge = t.currentTarget.checked;
87
- l === H.space && (t.preventDefault(), t.stopPropagation(), u(t, !ge));
101
+ const { keyCode: l } = t, xe = t.currentTarget.checked;
102
+ l === _.space && (t.preventDefault(), t.stopPropagation(), r(t, !xe));
88
103
  },
89
- [o, u]
90
- ), pe = a.useCallback(
104
+ [o, r]
105
+ ), fe = e.useCallback(
91
106
  (t) => {
92
107
  if (o)
93
108
  return;
94
109
  const { keyCode: l } = t;
95
- l === H.space && t.preventDefault();
110
+ l === _.space && t.preventDefault();
96
111
  },
97
112
  [o]
98
- ), ke = a.useCallback(
113
+ ), he = e.useCallback(
99
114
  (t) => {
100
- k && !o && V(k, t, c(), void 0);
115
+ f && !o && P(f, t, c(), void 0);
101
116
  },
102
- [k, o, c]
103
- ), fe = a.useCallback(
117
+ [f, o, c]
118
+ ), ve = e.useCallback(
104
119
  (t) => {
105
- f && !o && V(f, t, c(), void 0);
120
+ h && !o && P(h, t, c(), void 0);
106
121
  },
107
- [f, o, c]
108
- ), he = Ee(n, P.dir), ve = E("k-checkbox-wrap", J), R = {
122
+ [h, o, c]
123
+ ), Ce = Ne(n, B.dir), ge = E("k-checkbox-wrap", X), U = {
109
124
  type: "checkbox",
110
125
  className: E("k-checkbox", {
111
- [`k-checkbox-${U.sizeMap[b] || b}`]: b,
112
- [`k-rounded-${U.roundedMap[m] || m}`]: m,
113
- "k-indeterminate": ie,
126
+ [`k-checkbox-${$.sizeMap[m] || m}`]: m,
127
+ [`k-rounded-${$.roundedMap[p] || p}`]: p,
128
+ "k-indeterminate": de,
114
129
  "k-disabled": o,
115
- "k-invalid k-invalid": !(g || S !== void 0 || S === !0)
130
+ "k-invalid k-invalid": !(y || S !== void 0 || S === !0)
116
131
  }),
117
132
  ref: n,
118
- name: ee,
119
- id: I || L,
133
+ name: z,
134
+ id: b || q,
120
135
  disabled: o,
121
- required: i !== void 0 ? i : !1,
122
- tabIndex: Pe(te, o),
136
+ required: d !== void 0 ? d : !1,
137
+ tabIndex: Ie(oe, o),
123
138
  role: "checkbox",
124
- checked: !!w,
125
- "aria-describedby": j,
126
- "aria-labelledby": G,
139
+ checked: !!O,
140
+ "aria-describedby": J,
141
+ "aria-labelledby": Q,
127
142
  "aria-disabled": o || void 0,
128
- "aria-required": i,
129
- autoFocus: oe,
130
- ...ne,
131
- onChange: be,
132
- onKeyDown: me,
133
- onKeyUp: pe,
134
- onFocus: ke,
135
- onBlur: fe
136
- }, Ce = (
143
+ "aria-required": d,
144
+ autoFocus: ne,
145
+ ...le,
146
+ onChange: pe,
147
+ onKeyDown: ke,
148
+ onKeyUp: fe,
149
+ onFocus: he,
150
+ onBlur: ve
151
+ }, ye = (
137
152
  // removing value prop is required due to bug in react where
138
153
  // value set to undefined override default submit value
139
- d === void 0 ? /* @__PURE__ */ a.createElement("input", { ...R }) : /* @__PURE__ */ a.createElement("input", { ...R, value: K ? void 0 : d === null ? "" : d })
140
- ), y = N !== void 0 ? /* @__PURE__ */ a.createElement(
154
+ u === void 0 ? /* @__PURE__ */ e.createElement("input", { ...U }) : /* @__PURE__ */ e.createElement("input", { ...U, value: T ? void 0 : u === null ? "" : u })
155
+ ), x = I !== void 0 ? /* @__PURE__ */ e.createElement(
141
156
  "label",
142
157
  {
143
- className: E("k-checkbox-label", Q),
144
- htmlFor: I || L,
158
+ className: E("k-checkbox-label", Y),
159
+ htmlFor: b || q,
145
160
  style: { userSelect: "none" }
146
161
  },
147
- N,
148
- ae && /* @__PURE__ */ a.createElement("span", { className: "k-label-optional" }, ue)
149
- ) : null, x = /* @__PURE__ */ a.createElement("span", { className: ve }, Ce, X);
150
- return /* @__PURE__ */ a.createElement(a.Fragment, null, z === "before" ? /* @__PURE__ */ a.createElement("div", { dir: "rtl" }, x, y) : z === "after" ? /* @__PURE__ */ a.createElement("div", { dir: "ltr" }, x, y) : /* @__PURE__ */ a.createElement("div", { dir: he }, x, y));
162
+ I,
163
+ te && /* @__PURE__ */ e.createElement("span", { className: "k-label-optional" }, be)
164
+ ) : null, V = /* @__PURE__ */ e.createElement("span", { className: ge }, ye, Z);
165
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, F === "before" ? /* @__PURE__ */ e.createElement("div", { dir: "rtl" }, V, x) : F === "after" ? /* @__PURE__ */ e.createElement("div", { dir: "ltr" }, V, x) : /* @__PURE__ */ e.createElement("div", { dir: Ce }, V, x));
151
166
  });
152
- $.propTypes = {
153
- checked: e.bool,
154
- className: e.string,
155
- defaultChecked: e.bool,
156
- defaultValue: e.any,
157
- dir: e.string,
158
- disabled: e.bool,
159
- id: e.string,
160
- size: e.oneOf(["small", "medium", "large"]),
161
- rounded: e.oneOf(["small", "medium", "large", "none"]),
162
- ariaLabelledBy: e.string,
163
- ariaDescribedBy: e.string,
164
- label: e.any,
165
- labelPlacement: e.string,
166
- labelOptional: e.bool,
167
- name: e.string,
168
- tabIndex: e.number,
169
- value: e.any,
170
- validationMessage: e.string,
171
- required: e.bool,
172
- validate: e.bool,
173
- valid: e.bool,
174
- autoFocus: e.bool,
175
- onChange: e.func,
176
- onFocus: e.func,
177
- onBlur: e.func
167
+ W.propTypes = {
168
+ checked: a.bool,
169
+ className: a.string,
170
+ defaultChecked: a.bool,
171
+ defaultValue: a.any,
172
+ dir: a.string,
173
+ disabled: a.bool,
174
+ id: a.string,
175
+ size: a.oneOf(["small", "medium", "large"]),
176
+ rounded: a.oneOf(["small", "medium", "large", "none"]),
177
+ ariaLabelledBy: a.string,
178
+ ariaDescribedBy: a.string,
179
+ label: a.any,
180
+ labelPlacement: a.string,
181
+ labelOptional: a.bool,
182
+ name: a.string,
183
+ tabIndex: a.number,
184
+ value: a.any,
185
+ validationMessage: a.string,
186
+ required: a.bool,
187
+ validate: a.bool,
188
+ valid: a.bool,
189
+ autoFocus: a.bool,
190
+ onChange: a.func,
191
+ onFocus: a.func,
192
+ onBlur: a.func
178
193
  };
179
- const _ = {
194
+ const A = {
180
195
  size: void 0,
181
196
  rounded: void 0
182
197
  };
183
- $.displayName = "KendoCheckbox";
198
+ W.displayName = "KendoCheckbox";
184
199
  export {
185
- $ as Checkbox,
186
- Fe as CheckboxPropsContext
200
+ W as Checkbox,
201
+ Se as CheckboxPropsContext
187
202
  };
@@ -5,8 +5,8 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { default as PropTypes } from 'prop-types';
9
8
  import { ColorPaletteProps } from './interfaces/ColorPaletteProps.js';
9
+ import { ColorPaletteHandle } from './interfaces/ColorPaletteHandle.js';
10
10
  import * as React from 'react';
11
11
  /**
12
12
  * @hidden
@@ -21,85 +21,25 @@ export declare const DEFAULT_COLUMNS_COUNT = 10;
21
21
  */
22
22
  export declare const DEFAULT_PRESET = "office";
23
23
  /**
24
+ * The default props of the ColorPalette component.
25
+ *
24
26
  * @hidden
25
27
  */
28
+ export declare const defaultColorPaletteProps: {
29
+ palette: string;
30
+ columns: number;
31
+ tileSize: number;
32
+ };
33
+ /**
34
+ * @hidden
35
+ *
36
+ * @deprecated This interface is no longer used in the functional implementation but maintained for backward compatibility
37
+ */
26
38
  export interface ColorPaletteState {
27
39
  selectedColor?: string;
28
40
  focusedColor?: string;
29
41
  isFirstRender: boolean;
30
42
  }
31
- /** @hidden */
32
- export declare class ColorPaletteWithoutContext extends React.Component<ColorPaletteProps, ColorPaletteState> {
33
- static displayName: string;
34
- /**
35
- * @hidden
36
- */
37
- static propTypes: {
38
- palette: PropTypes.Requireable<NonNullable<string | string[] | null | undefined>>;
39
- columns: PropTypes.Requireable<number>;
40
- tileSize: PropTypes.Requireable<any>;
41
- defaultValue: PropTypes.Requireable<string>;
42
- value: PropTypes.Requireable<string>;
43
- disabled: PropTypes.Requireable<boolean>;
44
- tabIndex: PropTypes.Requireable<number>;
45
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
46
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
47
- id: PropTypes.Requireable<string>;
48
- ariaLabelledBy: PropTypes.Requireable<string>;
49
- ariaDescribedBy: PropTypes.Requireable<string>;
50
- className: PropTypes.Requireable<string>;
51
- size: PropTypes.Requireable<string | null>;
52
- };
53
- /**
54
- * @hidden
55
- */
56
- static defaultProps: {
57
- palette: string;
58
- tileSize: number;
59
- size: undefined;
60
- };
61
- /**
62
- * @hidden
63
- */
64
- wrapperRef: React.RefObject<HTMLDivElement | null>;
65
- private paletteService;
66
- private get guid();
67
- constructor(props: ColorPaletteProps);
68
- /**
69
- * @hidden
70
- */
71
- focus: () => void;
72
- /**
73
- * @hidden
74
- */
75
- render(): "" | React.JSX.Element;
76
- /**
77
- * @hidden
78
- */
79
- static getDerivedStateFromProps(props: ColorPaletteProps, state: ColorPaletteState): {
80
- selectedColor: undefined;
81
- isFirstRender?: undefined;
82
- } | {
83
- selectedColor: string;
84
- isFirstRender?: undefined;
85
- } | {
86
- isFirstRender: boolean;
87
- selectedColor?: undefined;
88
- } | null;
89
- private onKeyDown;
90
- private onColorClick;
91
- private onFocus;
92
- private onBlur;
93
- private handleCellNavigation;
94
- private handleEnter;
95
- private dispatchChangeEvent;
96
- private get focusedColorCooridanates();
97
- private get isUncontrolled();
98
- private getPaletteInfo;
99
- private renderRows;
100
- private renderColumns;
101
- private createCellId;
102
- }
103
43
  /**
104
44
  * Represents the PropsContext of the `ColorPalette` component.
105
45
  * Used for global configuration of all `ColorPalette` instances.
@@ -108,14 +48,7 @@ export declare class ColorPaletteWithoutContext extends React.Component<ColorPal
108
48
  */
109
49
  export declare const ColorPalettePropsContext: React.Context<(p: ColorPaletteProps) => ColorPaletteProps>;
110
50
  /**
111
- * Represent the `ref` of the ColorPalette component.
112
- */
113
- export interface ColorPaletteHandle extends Pick<ColorPaletteWithoutContext, keyof ColorPaletteWithoutContext> {
114
- }
115
- /** @hidden */
116
- export type ColorPalette = ColorPaletteHandle;
117
- /**
118
- * Represents the [KendoReact ColorPalette component](https://www.telerik.com/kendo-react-ui/components/inputs/colorpalette).
51
+ * Represents the [KendoReact ColorPalette component](https://www.telerik.com/kendo-react-ui/components/inputs/colorpalette) (Functional Implementation).
119
52
  *
120
53
  * Accepts properties of type [ColorPaletteProps](https://www.telerik.com/kendo-react-ui/components/inputs/api/colorpaletteprops).
121
54
  * Obtaining the `ref` returns an object of type [ColorPaletteHandle](https://www.telerik.com/kendo-react-ui/components/inputs/api/colorpalettehandle).
@@ -127,3 +60,9 @@ export type ColorPalette = ColorPaletteHandle;
127
60
  * ```
128
61
  */
129
62
  export declare const ColorPalette: React.ForwardRefExoticComponent<ColorPaletteProps & React.RefAttributes<any>>;
63
+ /**
64
+ * ColorPalette component without context (for backward compatibility).
65
+ *
66
+ * @hidden
67
+ */
68
+ export declare const ColorPaletteWithoutContext: React.ForwardRefExoticComponent<ColorPaletteProps & React.RefAttributes<ColorPaletteHandle>>;
@@ -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 R=require("react"),s=require("prop-types"),k=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),T=require("./models/palette-presets.js"),F=require("./utils/misc.js"),N=require("./utils/color-parser.js");function D(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const l=D(R),g=24,u=10,v="office",n=class n 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})},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 k.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor);return t.colors.length?l.createElement("div",{id:this.props.id,role:"grid",className:r.classNames("k-colorpalette",{[`k-colorpalette-${r.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size,"k-disabled":this.props.disabled},this.props.className),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:N.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=T.PALETTEPRESETS[this.props.palette];return F.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||u}:{colors:[],columns:0}}return{colors:this.props.palette||[],columns:this.props.columns||u}}renderRows(t,e,o){return t.map((i,c)=>l.createElement("tr",{role:"row",key:c},this.renderColumns(i,c,e,o)))}renderColumns(t,e,o,i){const c=o!==void 0&&o.row===e,m=o&&o.col,E=i!==void 0&&i.row===e,w=i&&i.col;return t.map((h,d)=>{const f=c&&m===d,y=r.classNames("k-colorpalette-tile",{"k-selected":f,"k-focus":E&&w===d});let C={width:this.props.tileSize,height:this.props.tileSize};return typeof this.props.tileSize=="object"&&(C={width:this.props.tileSize.width,height:this.props.tileSize.height}),l.createElement("td",{role:"gridcell",className:y,"aria-label":h,"aria-selected":f?!0:this.props.disabled?void 0:!1,style:{backgroundColor:h,...C},onClick:P=>this.onColorClick(h,P),id:this.createCellId({row:e,col:d}),key:d})})}createCellId(t){return`${this.guid}_${t.row}_${t.col}`}};n.displayName="ColorPalette",n.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,size:s.oneOf(["small","medium","large",null])},n.defaultProps={palette:v,tileSize:g,size:void 0};let p=n;const S=r.createPropsContext(),b=r.withIdHOC(r.withPropsContext(S,p));b.displayName="KendoReactColorPalette";exports.ColorPalette=b;exports.ColorPalettePropsContext=S;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=u;exports.DEFAULT_PRESET=v;exports.DEFAULT_TILE_SIZE=g;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),l=require("prop-types"),re=require("./utils/color-palette.service.js"),w=require("@progress/kendo-react-common"),se=require("./models/palette-presets.js"),q=require("./utils/color-parser.js");function le(c){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const h in c)if(h!=="default"){const E=Object.getOwnPropertyDescriptor(c,h);Object.defineProperty(p,h,E.get?E:{enumerable:!0,get:()=>c[h]})}}return p.default=c,Object.freeze(p)}const k=le(n),z=24,B=10,j="office",D={palette:j,columns:B,tileSize:z},V=w.createPropsContext(),ne=c=>{if(Array.isArray(c))return c;if(typeof c=="string"){const p=se.PALETTEPRESETS[c];if(p)return p.colors}return[]},F=k.forwardRef((c,p)=>{const h=w.usePropsContext(V,c),{palette:E=D.palette,columns:L=D.columns,tileSize:u=D.tileSize,value:x,defaultValue:$,disabled:d=!1,tabIndex:K,onChange:P,onFocus:I,className:W,size:N,id:Z,ariaLabelledBy:G,ariaDescribedBy:J}=h,S=n.useRef(null),Q=n.useRef({focus:()=>{var o;(o=S.current)==null||o.focus()},wrapperRef:S}),_=L!=null?L:D.columns,b=n.useMemo(()=>ne(E),[E]),t=n.useMemo(()=>{const o=new re.ColorPaletteService;return o.setColorMatrix(b,_),o},[b,_]),[g,O]=n.useState(()=>x!==void 0?x:$||""),[T,R]=n.useState(""),y=x!==void 0;n.useEffect(()=>{y&&O(x)},[x,y]);const X=n.useCallback(o=>{if(d||b.length===0)return;const f=g||b[0];R(f),I&&I(o)},[d,b,g,I]),Y=n.useCallback(()=>{R("")},[]),ee=n.useCallback(o=>{if(d)return;const{key:f}=o,r=()=>T||g||b[0],m=(s,e)=>s<0?e:s>e?0:s;switch(f){case"ArrowRight":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e&&t.colorRows[e.row]){const C=t.colorRows[e.row].length-1,a=m(e.col+1,C),i=t.colorRows[e.row][a];i&&R(i)}}break;case"ArrowLeft":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e&&t.colorRows[e.row]){const C=t.colorRows[e.row].length-1,a=m(e.col-1,C),i=t.colorRows[e.row][a];i&&R(i)}}break;case"ArrowDown":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e){const C=t.colorRows.length-1,a=m(e.row+1,C),i=Math.min(e.col,t.colorRows[a].length-1),v=t.colorRows[a][i];v&&R(v)}}break;case"ArrowUp":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e){const C=t.colorRows.length-1,a=m(e.row-1,C),i=Math.min(e.col,t.colorRows[a].length-1),v=t.colorRows[a][i];v&&R(v)}}break;case"Enter":o.preventDefault();{const s=r();if(s&&(y||O(s),P)){const e=q.parseColor(s,"rgba");w.dispatchEvent(P,o,null,{value:s,rgbaValue:e||""})}}break}},[d,T,g,b,t,y,P]),A=n.useCallback((o,f)=>{if(d)return;const r=o;if(y||O(r),P){const m=q.parseColor(r,"rgba");w.dispatchEvent(P,f,null,{value:r,rgbaValue:m||""})}},[d,P,y]),U=n.useCallback((o,f)=>o.map((r,m)=>{const s=g&&r.toLowerCase()===g.toLowerCase(),e=T&&r.toLowerCase()===T.toLowerCase(),C=w.classNames("k-colorpalette-tile",{"k-selected":s,"k-focus":e}),a={backgroundColor:r};return typeof u=="number"?(a.width=`${u}px`,a.height=`${u}px`):u&&typeof u=="object"&&("width"in u&&(a.width=`${u.width}px`),"height"in u&&(a.height=`${u.height}px`)),k.createElement("td",{key:r,role:"gridcell",className:C,style:a,"aria-label":r,"aria-selected":s?"true":"false",onClick:i=>A(r,i)})}),[g,T,u,A]),oe=n.useCallback(()=>t.colorRows.map((f,r)=>k.createElement("tr",{key:f[0]||r,role:"row"},U(f,r))),[t,U]),M=n.useCallback(()=>({focus:()=>{var o;(o=S.current)==null||o.focus()},wrapperRef:S}),[]);n.useImperativeHandle(Q,M),n.useImperativeHandle(p,M);const te=w.classNames("k-colorpalette",W,{"k-disabled":d,"k-colorpalette-sm":N==="small","k-colorpalette-md":N==="medium","k-colorpalette-lg":N==="large"});return k.createElement("div",{ref:S,role:"grid",className:te,tabIndex:w.getTabIndex(K,d),id:Z,"aria-labelledby":G,"aria-describedby":J,"aria-disabled":d?"true":void 0,onFocus:X,onBlur:Y,onKeyDown:ee},k.createElement("table",{className:"k-colorpalette-table",role:"presentation"},k.createElement("tbody",null,oe())))});F.displayName="ColorPalette";F.propTypes={palette:l.oneOfType([l.arrayOf(l.string.isRequired),l.string]),columns:l.number,tileSize:l.any,defaultValue:l.string,value:l.string,disabled:l.bool,tabIndex:l.number,onChange:l.func,onFocus:l.func,id:l.string,ariaLabelledBy:l.string,ariaDescribedBy:l.string,className:l.string,size:l.oneOf(["small","medium","large"])};const H=w.withIdHOC(F);H.displayName="KendoReactColorPalette";const ae=F;exports.ColorPalette=H;exports.ColorPalettePropsContext=V;exports.ColorPaletteWithoutContext=ae;exports.DEFAULT_COLUMNS_COUNT=B;exports.DEFAULT_PRESET=j;exports.DEFAULT_TILE_SIZE=z;exports.defaultColorPaletteProps=D;