@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.
- package/checkbox/Checkbox.js +1 -1
- package/checkbox/Checkbox.mjs +133 -118
- package/colors/ColorPalette.d.ts +20 -81
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +207 -181
- package/colors/interfaces/ColorPaletteChangeEvent.d.ts +2 -2
- package/colors/interfaces/ColorPaletteHandle.d.ts +46 -0
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +2 -1
- package/index.d.ts +2 -1
- package/input/Input.js +1 -1
- package/input/Input.mjs +120 -101
- package/maskedtextbox/MaskedTextBox.d.ts +6 -0
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +82 -61
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +251 -227
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +10 -10
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +109 -90
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +131 -115
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +77 -62
package/checkbox/Checkbox.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
package/checkbox/Checkbox.mjs
CHANGED
|
@@ -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
|
|
9
|
-
import
|
|
10
|
-
import { createPropsContext as
|
|
11
|
-
import { useLocalization as
|
|
12
|
-
import { messages as
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
ariaDescribedBy:
|
|
16
|
-
ariaLabelledBy:
|
|
17
|
-
checked:
|
|
18
|
-
className:
|
|
19
|
-
labelClassName:
|
|
20
|
-
children:
|
|
21
|
-
defaultChecked:
|
|
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:
|
|
24
|
-
id:
|
|
25
|
-
size:
|
|
26
|
-
rounded:
|
|
27
|
-
label:
|
|
28
|
-
labelPlacement:
|
|
29
|
-
name:
|
|
30
|
-
labelOptional:
|
|
31
|
-
onChange:
|
|
32
|
-
onFocus:
|
|
33
|
-
onBlur:
|
|
34
|
-
tabIndex:
|
|
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:
|
|
37
|
-
valid:
|
|
36
|
+
required: d,
|
|
37
|
+
valid: K,
|
|
38
38
|
validationMessage: M,
|
|
39
39
|
validityStyles: S,
|
|
40
|
-
autoFocus:
|
|
40
|
+
autoFocus: ne,
|
|
41
41
|
// Removed to support direct use in Form Field component
|
|
42
|
-
visited:
|
|
43
|
-
touched:
|
|
44
|
-
modified:
|
|
45
|
-
...
|
|
46
|
-
} =
|
|
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 =
|
|
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
|
-
|
|
59
|
-
const [
|
|
60
|
-
|
|
61
|
-
n.current && n.current.setCustomValidity && n.current.setCustomValidity(
|
|
62
|
-
}, [
|
|
63
|
-
const
|
|
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
|
-
!
|
|
66
|
-
|
|
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
|
-
[
|
|
76
|
-
),
|
|
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
|
-
|
|
94
|
+
r(t, l);
|
|
80
95
|
},
|
|
81
|
-
[
|
|
82
|
-
),
|
|
96
|
+
[r, s]
|
|
97
|
+
), ke = e.useCallback(
|
|
83
98
|
(t) => {
|
|
84
99
|
if (o)
|
|
85
100
|
return;
|
|
86
|
-
const { keyCode: l } = t,
|
|
87
|
-
l ===
|
|
101
|
+
const { keyCode: l } = t, xe = t.currentTarget.checked;
|
|
102
|
+
l === _.space && (t.preventDefault(), t.stopPropagation(), r(t, !xe));
|
|
88
103
|
},
|
|
89
|
-
[o,
|
|
90
|
-
),
|
|
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 ===
|
|
110
|
+
l === _.space && t.preventDefault();
|
|
96
111
|
},
|
|
97
112
|
[o]
|
|
98
|
-
),
|
|
113
|
+
), he = e.useCallback(
|
|
99
114
|
(t) => {
|
|
100
|
-
|
|
115
|
+
f && !o && P(f, t, c(), void 0);
|
|
101
116
|
},
|
|
102
|
-
[
|
|
103
|
-
),
|
|
117
|
+
[f, o, c]
|
|
118
|
+
), ve = e.useCallback(
|
|
104
119
|
(t) => {
|
|
105
|
-
|
|
120
|
+
h && !o && P(h, t, c(), void 0);
|
|
106
121
|
},
|
|
107
|
-
[
|
|
108
|
-
),
|
|
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-${
|
|
112
|
-
[`k-rounded-${
|
|
113
|
-
"k-indeterminate":
|
|
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": !(
|
|
130
|
+
"k-invalid k-invalid": !(y || S !== void 0 || S === !0)
|
|
116
131
|
}),
|
|
117
132
|
ref: n,
|
|
118
|
-
name:
|
|
119
|
-
id:
|
|
133
|
+
name: z,
|
|
134
|
+
id: b || q,
|
|
120
135
|
disabled: o,
|
|
121
|
-
required:
|
|
122
|
-
tabIndex:
|
|
136
|
+
required: d !== void 0 ? d : !1,
|
|
137
|
+
tabIndex: Ie(oe, o),
|
|
123
138
|
role: "checkbox",
|
|
124
|
-
checked: !!
|
|
125
|
-
"aria-describedby":
|
|
126
|
-
"aria-labelledby":
|
|
139
|
+
checked: !!O,
|
|
140
|
+
"aria-describedby": J,
|
|
141
|
+
"aria-labelledby": Q,
|
|
127
142
|
"aria-disabled": o || void 0,
|
|
128
|
-
"aria-required":
|
|
129
|
-
autoFocus:
|
|
130
|
-
...
|
|
131
|
-
onChange:
|
|
132
|
-
onKeyDown:
|
|
133
|
-
onKeyUp:
|
|
134
|
-
onFocus:
|
|
135
|
-
onBlur:
|
|
136
|
-
},
|
|
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
|
-
|
|
140
|
-
),
|
|
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",
|
|
144
|
-
htmlFor:
|
|
158
|
+
className: E("k-checkbox-label", Y),
|
|
159
|
+
htmlFor: b || q,
|
|
145
160
|
style: { userSelect: "none" }
|
|
146
161
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
) : null,
|
|
150
|
-
return /* @__PURE__ */
|
|
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
|
-
|
|
153
|
-
checked:
|
|
154
|
-
className:
|
|
155
|
-
defaultChecked:
|
|
156
|
-
defaultValue:
|
|
157
|
-
dir:
|
|
158
|
-
disabled:
|
|
159
|
-
id:
|
|
160
|
-
size:
|
|
161
|
-
rounded:
|
|
162
|
-
ariaLabelledBy:
|
|
163
|
-
ariaDescribedBy:
|
|
164
|
-
label:
|
|
165
|
-
labelPlacement:
|
|
166
|
-
labelOptional:
|
|
167
|
-
name:
|
|
168
|
-
tabIndex:
|
|
169
|
-
value:
|
|
170
|
-
validationMessage:
|
|
171
|
-
required:
|
|
172
|
-
validate:
|
|
173
|
-
valid:
|
|
174
|
-
autoFocus:
|
|
175
|
-
onChange:
|
|
176
|
-
onFocus:
|
|
177
|
-
onBlur:
|
|
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
|
-
|
|
198
|
+
W.displayName = "KendoCheckbox";
|
|
184
199
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
200
|
+
W as Checkbox,
|
|
201
|
+
Se as CheckboxPropsContext
|
|
187
202
|
};
|
package/colors/ColorPalette.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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>>;
|
package/colors/ColorPalette.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|