@progress/kendo-react-inputs 9.5.0-develop.6 → 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.
- package/checkbox/Checkbox.js +1 -1
- package/checkbox/Checkbox.mjs +21 -23
- package/colors/ColorGradient.js +1 -1
- package/colors/ColorGradient.mjs +61 -60
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +25 -26
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +78 -79
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +61 -62
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +1 -1
- package/index.d.ts +1 -1
- package/input/Input.js +1 -1
- package/input/Input.mjs +36 -39
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +79 -80
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +18 -20
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +9 -9
- package/radiobutton/RadioButton.js +1 -1
- package/radiobutton/RadioButton.mjs +37 -39
- package/radiobutton/RadioGroup.js +1 -1
- package/radiobutton/RadioGroup.mjs +19 -21
- package/range-slider/RangeSlider.js +7 -7
- package/range-slider/RangeSlider.mjs +100 -101
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +58 -58
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +15 -16
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +15 -16
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +43 -45
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 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(c){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const m=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(d,r,m.get?m:{enumerable:!0,get:()=>c[r]})}}return d.default=c,Object.freeze(d)}const t=xe(ge),A=o.createPropsContext(),M=t.forwardRef((c,d)=>{const r=o.usePropsContext(A,c),{ariaDescribedBy:m,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:p,valid:D,validationMessage:F,validityStyles:T,autoFocus:ae,visited:Pe,touched:Ve,modified:Ee,...ne}=r,l=t.useRef(null),K=t.useCallback(()=>{l.current&&l.current.focus()},[]),u=t.useCallback(()=>({element:l.current,focus:K,get name(){return l.current&&l.current.name}}),[K]);t.useImperativeHandle(d,u);const[oe,le]=t.useState(X),[se,ce]=t.useState(Y),R=typeof i=="boolean"||i===null,x=O!==void 0,b=R,P=b?i:se,V=x?O:b?void 0:oe,w=V===void 0&&P,j=w?P:V,k=w||b?i===null?i:void 0:i||P,re=j===null||k===null,L=o.useId(),ie=ye.useLocalization(),_=a=>ie.toLanguageString(a,I.messages[a]),H=_(I.checkboxValidation),ue=_(I.checkboxOptionalText),E=D!==void 0?D:p?!!V:!0;t.useEffect(()=>{l.current&&l.current.setCustomValidity&&l.current.setCustomValidity(E?"":F||H)},[E,F,H]);const f=t.useCallback((a,s)=>{!b&&!n&&(ce(s),!x&&!n&&le(s)),C&&!n&&o.dispatchEvent(C,a,{...u(),value:s},{value:s})},[x,n,C,b,u]),de=t.useCallback(a=>{const s=a.target.checked;f(a,s)},[f,i]),be=t.useCallback(a=>{if(n)return;const{keyCode:s}=a,Ce=a.currentTarget.checked;s===o.Keys.space&&(a.preventDefault(),a.stopPropagation(),f(a,!Ce))},[n,f]),me=t.useCallback(a=>{if(n)return;const{keyCode:s}=a;s===o.Keys.space&&a.preventDefault()},[n]),pe=t.useCallback(a=>{g&&!n&&o.dispatchEvent(g,a,u(),void 0)},[g,n,u]),ke=t.useCallback(a=>{y&&!n&&o.dispatchEvent(y,a,u(),void 0)},[y,n,u]),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||T!==void 0||T===!0)}),ref:l,name:Z,id:B||L,disabled:n,required:p!==void 0?p:!1,tabIndex:o.getTabIndex(te,n),role:"checkbox",checked:!!j,"aria-describedby":m,"aria-labelledby":W,"aria-disabled":n||void 0,"aria-required":p,autoFocus:ae,...ne,onChange:de,onKeyDown:be,onKeyUp:me,onFocus:pe,onBlur:ke},ve=k===void 0?t.createElement("input",{...U}):t.createElement("input",{...U,value:R?void 0:k===null?"":k}),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"},ue)):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([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large"]),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:"medium",rounded:"medium",autoFocus:!1};M.displayName="KendoCheckbox";exports.Checkbox=M;exports.CheckboxPropsContext=A;
|
package/checkbox/Checkbox.mjs
CHANGED
|
@@ -7,13 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as a from "react";
|
|
9
9
|
import e from "prop-types";
|
|
10
|
-
import { createPropsContext as ye,
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
xe(Ie);
|
|
16
|
-
const E = Ve(Se, W), {
|
|
10
|
+
import { createPropsContext as ye, usePropsContext as xe, useId as Ve, dispatchEvent as V, Keys as H, useDir as Ee, classNames as E, kendoThemeMaps as U, getTabIndex as Pe } from "@progress/kendo-react-common";
|
|
11
|
+
import { useLocalization as Be } from "@progress/kendo-react-intl";
|
|
12
|
+
import { messages as Ie, checkboxValidation as Fe, checkboxOptionalText as Ne } from "../messages/index.mjs";
|
|
13
|
+
const ze = ye(), A = a.forwardRef((W, j) => {
|
|
14
|
+
const P = xe(ze, W), {
|
|
17
15
|
ariaDescribedBy: G,
|
|
18
16
|
ariaLabelledBy: J,
|
|
19
17
|
checked: B,
|
|
@@ -27,7 +25,7 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
27
25
|
size: b = $.size,
|
|
28
26
|
rounded: m = $.rounded,
|
|
29
27
|
label: F,
|
|
30
|
-
labelPlacement:
|
|
28
|
+
labelPlacement: N,
|
|
31
29
|
name: ee,
|
|
32
30
|
labelOptional: ae,
|
|
33
31
|
onChange: p,
|
|
@@ -36,16 +34,16 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
36
34
|
tabIndex: te,
|
|
37
35
|
value: s,
|
|
38
36
|
required: i,
|
|
39
|
-
valid:
|
|
40
|
-
validationMessage:
|
|
37
|
+
valid: z,
|
|
38
|
+
validationMessage: M,
|
|
41
39
|
validityStyles: S,
|
|
42
40
|
autoFocus: oe,
|
|
43
41
|
// Removed to support direct use in Form Field component
|
|
44
|
-
visited:
|
|
45
|
-
touched:
|
|
46
|
-
modified:
|
|
42
|
+
visited: Me,
|
|
43
|
+
touched: Se,
|
|
44
|
+
modified: De,
|
|
47
45
|
...le
|
|
48
|
-
} =
|
|
46
|
+
} = P, l = a.useRef(null), D = a.useCallback(() => {
|
|
49
47
|
l.current && l.current.focus();
|
|
50
48
|
}, []), c = a.useCallback(
|
|
51
49
|
() => ({
|
|
@@ -58,10 +56,10 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
58
56
|
[D]
|
|
59
57
|
);
|
|
60
58
|
a.useImperativeHandle(j, c);
|
|
61
|
-
const [ne, se] = a.useState(Z), [ce, re] = a.useState(_), K = typeof s == "boolean" || s === null, h = B !== void 0, r = K, v = r ? s : ce, C = h ? B : r ? void 0 : ne, 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 =
|
|
59
|
+
const [ne, se] = a.useState(Z), [ce, re] = a.useState(_), K = typeof s == "boolean" || s === null, h = B !== void 0, r = K, v = r ? s : ce, C = h ? B : r ? void 0 : ne, 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(Fe), ue = O(Ne), g = z !== void 0 ? z : i ? !!C : !0;
|
|
62
60
|
a.useEffect(() => {
|
|
63
|
-
l.current && l.current.setCustomValidity && l.current.setCustomValidity(g ? "" :
|
|
64
|
-
}, [g,
|
|
61
|
+
l.current && l.current.setCustomValidity && l.current.setCustomValidity(g ? "" : M || q);
|
|
62
|
+
}, [g, M, q]);
|
|
65
63
|
const u = a.useCallback(
|
|
66
64
|
(t, n) => {
|
|
67
65
|
!r && !o && (re(n), !h && !o && se(n)), p && !o && V(
|
|
@@ -107,9 +105,9 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
107
105
|
f && !o && V(f, t, c(), void 0);
|
|
108
106
|
},
|
|
109
107
|
[f, o, c]
|
|
110
|
-
), he = Ee(l,
|
|
108
|
+
), he = Ee(l, P.dir), ve = E("k-checkbox-wrap", Q), R = {
|
|
111
109
|
type: "checkbox",
|
|
112
|
-
className:
|
|
110
|
+
className: E("k-checkbox", {
|
|
113
111
|
[`k-checkbox-${U.sizeMap[b] || b}`]: b,
|
|
114
112
|
[`k-rounded-${U.roundedMap[m] || m}`]: m,
|
|
115
113
|
"k-indeterminate": ie,
|
|
@@ -121,7 +119,7 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
121
119
|
id: I || L,
|
|
122
120
|
disabled: o,
|
|
123
121
|
required: i !== void 0 ? i : !1,
|
|
124
|
-
tabIndex:
|
|
122
|
+
tabIndex: Pe(te, o),
|
|
125
123
|
role: "checkbox",
|
|
126
124
|
checked: !!w,
|
|
127
125
|
"aria-describedby": G,
|
|
@@ -142,14 +140,14 @@ const Se = ye(), A = a.forwardRef((W, j) => {
|
|
|
142
140
|
), y = F !== void 0 ? /* @__PURE__ */ a.createElement(
|
|
143
141
|
"label",
|
|
144
142
|
{
|
|
145
|
-
className:
|
|
143
|
+
className: E("k-checkbox-label", X),
|
|
146
144
|
htmlFor: I || L,
|
|
147
145
|
style: { userSelect: "none" }
|
|
148
146
|
},
|
|
149
147
|
F,
|
|
150
148
|
ae && /* @__PURE__ */ a.createElement("span", { className: "k-label-optional" }, ue)
|
|
151
149
|
) : null, x = /* @__PURE__ */ a.createElement("span", { className: ve }, Ce, Y);
|
|
152
|
-
return /* @__PURE__ */ a.createElement(a.Fragment, null,
|
|
150
|
+
return /* @__PURE__ */ a.createElement(a.Fragment, null, N === "before" ? /* @__PURE__ */ a.createElement("div", { dir: "rtl" }, x, y) : N === "after" ? /* @__PURE__ */ a.createElement("div", { dir: "ltr" }, x, y) : /* @__PURE__ */ a.createElement("div", { dir: he }, x, y));
|
|
153
151
|
});
|
|
154
152
|
A.propTypes = {
|
|
155
153
|
checked: e.bool,
|
|
@@ -186,5 +184,5 @@ const $ = {
|
|
|
186
184
|
A.displayName = "KendoCheckbox";
|
|
187
185
|
export {
|
|
188
186
|
A as Checkbox,
|
|
189
|
-
|
|
187
|
+
ze as CheckboxPropsContext
|
|
190
188
|
};
|
package/colors/ColorGradient.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 E=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),H=require("../package-metadata.js"),m=require("../slider/Slider.js"),v=require("./utils/misc.js"),o=require("./utils/color-parser.js"),d=require("./utils/color-cache.js"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),H=require("../package-metadata.js"),m=require("../slider/Slider.js"),v=require("./utils/misc.js"),o=require("./utils/color-parser.js"),d=require("./utils/color-cache.js"),w=require("./ColorInput.js"),x=require("./ColorContrastLabels.js"),G=require("./ColorContrastSvg.js"),L=require("@progress/kendo-react-intl"),g=require("../messages/index.js");function D(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const e=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(t,s,e.get?e:{enumerable:!0,get:()=>u[s]})}}return t.default=u,Object.freeze(t)}const l=D(E),A="rgba",k="rgba(255, 255, 255, 1)",b=2,C=5,c=class c extends l.Component{constructor(t){super(t),this.wrapperRef=l.createRef(),this.hsvGradientRef=l.createRef(),this.showLicenseWatermark=!1,this.focus=()=>{this.wrapperRef&&this.wrapperRef.current&&this.wrapperRef.current.focus()},this.onHexChange=(e,a,i)=>{if(this.isUncontrolled){const h=o.getHSV(a);this.setState({hsva:h,backgroundColor:o.getColorFromHue(h.h),rgba:o.getRGBA(a),hex:e})}else d.cacheHex(this.state.guid,a,e);this.dispatchChangeEvent(a,i,i.nativeEvent)},this.onRgbaChange=(e,a)=>{const i=o.getColorFromRGBA(e);if(this.isUncontrolled){const h=o.getHSV(i),p=o.parseColor(i,"hex");this.setState({hsva:h,backgroundColor:o.getColorFromHue(h.h),rgba:e,hex:p})}else d.cacheRgba(this.state.guid,i,e);this.dispatchChangeEvent(i,a.syntheticEvent,a.nativeEvent)},this.onAlphaSliderChange=e=>{this.handleHsvaChange(Object.assign({},this.state.hsva,{a:e.value/100}),e.syntheticEvent,e.nativeEvent)},this.onHueSliderChange=e=>{this.handleHsvaChange(Object.assign({},this.state.hsva,{h:e.value}),e.syntheticEvent,e.nativeEvent)},this.onDrag=e=>{this.gradientWrapper.classList.add("k-dragging"),this.changePosition(e.event)},this.onRelease=()=>{this.gradientWrapper.classList.remove("k-dragging")},this.onGradientWrapperClick=e=>{this.changePosition(e)},this.onHsvGradientKeyDown=e=>{var a;(a=this.hsvNavigation)==null||a.triggerKeyboardEvent(e)},this.onHsvGradientValueChange=(e,a,i)=>{const h=parseInt(e.style.top,10)+i,p=parseInt(e.style.left,10)+a;e.style.top=`${h}px`,e.style.left=`${p}px`,this.moveDragHandle(p,h)},this.changePosition=e=>{const a=this.getGradientRectMetrics(),i=e.clientX-a.left,h=e.clientY-a.top;this.moveDragHandle(i,h)},this.onFocus=e=>{this.props.onFocus&&this.props.onFocus.call(void 0,{nativeEvent:e,target:this})},this.onKeyDown=e=>{var a;(a=this.navigation)==null||a.triggerKeyboardEvent(e)},this.showLicenseWatermark=!r.validatePackage(H.packageMetadata,{component:"ColorGradient"});const s=t.value||t.defaultValue||o.parseColor(k,A);this.state=Object.assign({},c.getStateFromValue(s),{isFirstRender:!0,guid:this.props.id})}static getDerivedStateFromProps(t,s){return t.value&&!s.isFirstRender?c.getStateFromValue(t.value,s.guid):null}componentDidMount(){if(this.setAlphaSliderBackground(this.state.backgroundColor),this.state.isFirstRender&&this.setState({isFirstRender:!1}),this.wrapperRef&&this.hsvGradientRef){let t=0,s=0;this.hsvNavigation=new r.Navigation({tabIndex:0,root:this.hsvGradientRef,selectors:[".k-hsv-rectangle .k-hsv-draghandle"],keyboardEvents:{keydown:{ArrowDown:(e,a,i)=>{s=i.shiftKey?this.props.gradientSliderSmallStep||b:this.props.gradientSliderStep||C,this.onHsvGradientValueChange(e,0,s)},ArrowUp:(e,a,i)=>{s=i.shiftKey?-(this.props.gradientSliderSmallStep||b):-(this.props.gradientSliderStep||C),this.onHsvGradientValueChange(e,0,s)},ArrowLeft:(e,a,i)=>{t=i.shiftKey?-(this.props.gradientSliderSmallStep||b):-(this.props.gradientSliderStep||C),this.onHsvGradientValueChange(e,t,0)},ArrowRight:(e,a,i)=>{t=i.shiftKey?this.props.gradientSliderSmallStep||b:this.props.gradientSliderStep||C,this.onHsvGradientValueChange(e,t,0)}}}})}this.wrapperRef&&this.wrapperRef.current&&(this.props.isInsidePopup?this.hsvGradientRef.current&&this.hsvGradientRef.current.focus():this.navigation=new r.Navigation({tabIndex:0,root:this.wrapperRef,selectors:[".k-colorgradient"],keyboardEvents:{keydown:{Tab:(t,s,e)=>{r.getActiveElement(document)===t?r.disableNavigatableContainer(t):r.keepFocusInContainer(e,t,r.TABBABLE_ELEMENTS)},Enter:(t,s,e)=>{r.getActiveElement(document)===t&&(r.focusFirstFocusableChild(t),r.enableNavigatableContainer(t))},Escape:(t,s,e)=>{r.getActiveElement(document)!==t&&(t.focus(),r.disableNavigatableContainer(t))}}}}))}componentWillUnmount(){d.removeCachedColor(this.state.guid)}componentDidUpdate(t,s){s.backgroundColor!==this.state.backgroundColor&&this.setAlphaSliderBackground(this.state.backgroundColor)}renderRectangleDragHandle(){const t={};if(!this.state.isFirstRender){const s=this.getGradientRectMetrics(),e=(1-this.state.hsva.v)*s.height,a=this.state.hsva.s*s.width;t.top=`${e}px`,t.left=`${a}px`}return l.createElement("div",{ref:this.hsvGradientRef,role:"slider",tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),"aria-valuetext":this.props.ariaValueText,"aria-valuenow":parseInt(this.state.hex.substring(1),16),"aria-label":this.props.ariaLabelHSV,"aria-orientation":void 0,"aria-disabled":this.props.disabled?"true":void 0,className:"k-hsv-draghandle k-draghandle",style:t,onKeyDown:this.onHsvGradientKeyDown})}moveDragHandle(t,s){const e=this.getGradientRectMetrics(),a=e.width,i=e.height,h=v.fitIntoBounds(s,0,i),p=v.fitIntoBounds(t,0,a),y=Object.assign({},this.state.hsva,{s:p/a,v:1-h/i});this.handleHsvaChange(y,{},{})}handleHsvaChange(t,s,e){const a=o.getColorFromHSV(t),i=o.parseColor(a,"hex");this.isUncontrolled||d.cacheHsva(this.state.guid,a,t),this.setState({hsva:t,backgroundColor:o.getColorFromHue(t.h),rgba:o.getRGBA(a),hex:i}),this.dispatchChangeEvent(a,s,e)}dispatchChangeEvent(t,s,e){this.props.onChange&&this.props.onChange.call(void 0,{syntheticEvent:s,nativeEvent:e,target:this,value:t})}static getStateFromValue(t,s){v.isPresent(o.parseColor(t,"hex"))||(t=k);const e=d.getCachedHsva(s,t)||o.getHSV(t),a=d.getCachedRgba(s,t)||o.getRGBA(t),i=d.getCachedHex(s,t)||o.parseColor(t,"hex"),h=o.getColorFromHue(e.h);return{hsva:e,backgroundColor:h,rgba:a,hex:i}}setAlphaSliderBackground(t){this.props.opacity&&this.alphaSlider&&this.alphaSlider.sliderTrack&&(this.alphaSlider.sliderTrack.style.background=`linear-gradient(to ${this.props._adaptive?"right":"top"}, transparent, ${t})`)}get isUncontrolled(){return this.props.value===void 0}getGradientRectMetrics(){return this.gradientWrapper.getBoundingClientRect()}render(){const t=L.provideLocalizationService(this);return l.createElement("div",{id:this.props.id,role:this.props.role,className:r.classNames("k-colorgradient",{[`k-colorgradient-${r.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size,"k-disabled":this.props.disabled},this.props.className),"aria-disabled":this.props.disabled?"true":void 0,style:{position:"relative",...this.props.style},ref:this.wrapperRef,tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),"aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,onFocus:this.onFocus,onKeyDown:this.onKeyDown},l.createElement("div",{className:`k-colorgradient-canvas ${this.props._adaptive?"k-vstack":"k-hstack"}`},l.createElement("div",{className:"k-hsv-rectangle",style:{background:this.state.backgroundColor}},l.createElement(r.Draggable,{onDrag:this.onDrag,onRelease:this.onRelease,ref:s=>this.gradientWrapper=s?s.element:void 0},l.createElement("div",{className:"k-hsv-gradient",style:{touchAction:"none"},onClick:this.onGradientWrapperClick},this.renderRectangleDragHandle())),this.props.backgroundColor&&!this.state.isFirstRender&&l.createElement(G.ColorContrastSvg,{metrics:this.gradientWrapper?this.getGradientRectMetrics():void 0,hsva:this.state.hsva,backgroundColor:this.props.backgroundColor})),l.createElement("div",{className:`k-hsv-controls ${this.props._adaptive?"k-vstack":"k-hstack"}`},l.createElement(m.Slider,{value:this.state.hsva.h,buttons:!1,vertical:!this.props._adaptive,min:0,max:360,step:5,onChange:this.onHueSliderChange,className:"k-hue-slider k-colorgradient-slider",disabled:this.props.disabled,ariaLabel:t.toLanguageString(g.colorGradientHueSliderLabel,g.messages[g.colorGradientHueSliderLabel])}),this.props.opacity&&l.createElement(m.Slider,{value:v.isPresent(this.state.hsva.a)?this.state.hsva.a*100:100,buttons:!1,vertical:!this.props._adaptive,min:0,max:100,step:1,ariaLabel:t.toLanguageString(g.colorGradientAlphaSliderLabel,g.messages[g.colorGradientAlphaSliderLabel]),onChange:this.onAlphaSliderChange,className:"k-alpha-slider k-colorgradient-slider",disabled:this.props.disabled,ref:s=>this.alphaSlider=s}))),l.createElement(w,{rgba:this.state.rgba,onRgbaChange:this.onRgbaChange,hex:this.state.hex,onHexChange:this.onHexChange,opacity:this.props.opacity,disabled:this.props.disabled,defaultInputMode:this.props.format,size:this.props.size,fillMode:this.props.fillMode}),this.props.backgroundColor&&l.createElement(x.ColorContrastLabels,{bgColor:o.getRGBA(this.props.backgroundColor),rgba:this.state.rgba}),this.showLicenseWatermark&&l.createElement(r.WatermarkOverlay,null))}};c.displayName="ColorGradient",c.propTypes={defaultValue:n.string,value:n.string,onChange:n.func,onFocus:n.func,opacity:n.bool,backgroundColor:n.string,format:n.any,disabled:n.bool,style:n.any,id:n.string,role:n.string,ariaLabel:n.string,ariaLabelledBy:n.string,ariaDescribedBy:n.string,className:n.string,size:n.oneOf(["small","medium","large",null])},c.defaultProps={opacity:!0,role:"textbox",format:"rgb",size:"medium"};let f=c;const S=r.createPropsContext(),R=r.withIdHOC(r.withPropsContext(S,f));R.displayName="KendoReactColorGradient";exports.ColorGradient=R;exports.ColorGradientPropsContext=S;exports.ColorGradientWithoutContext=f;
|
package/colors/ColorGradient.mjs
CHANGED
|
@@ -5,22 +5,22 @@
|
|
|
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 { validatePackage as
|
|
11
|
-
import { packageMetadata as
|
|
8
|
+
import * as r from "react";
|
|
9
|
+
import o from "prop-types";
|
|
10
|
+
import { validatePackage as D, Navigation as f, getActiveElement as u, disableNavigatableContainer as C, keepFocusInContainer as F, TABBABLE_ELEMENTS as G, focusFirstFocusableChild as A, enableNavigatableContainer as N, getTabIndex as k, classNames as I, kendoThemeMaps as M, Draggable as _, WatermarkOverlay as T, createPropsContext as B, withIdHOC as P, withPropsContext as V } from "@progress/kendo-react-common";
|
|
11
|
+
import { packageMetadata as K } from "../package-metadata.mjs";
|
|
12
12
|
import { Slider as S } from "../slider/Slider.mjs";
|
|
13
13
|
import { isPresent as R, fitIntoBounds as y } from "./utils/misc.mjs";
|
|
14
|
-
import { getHSV as b, getColorFromHue as p, getRGBA as c, getColorFromRGBA as
|
|
15
|
-
import { cacheHex as z, cacheRgba as
|
|
16
|
-
import
|
|
17
|
-
import { ColorContrastLabels as
|
|
18
|
-
import { ColorContrastSvg as
|
|
19
|
-
import { provideLocalizationService as
|
|
20
|
-
import { colorGradientHueSliderLabel as E, messages as
|
|
21
|
-
const
|
|
14
|
+
import { getHSV as b, getColorFromHue as p, getRGBA as c, getColorFromRGBA as O, parseColor as d, getColorFromHSV as U } from "./utils/color-parser.mjs";
|
|
15
|
+
import { cacheHex as z, cacheRgba as W, removeCachedColor as $, cacheHsva as j, getCachedHsva as X, getCachedRgba as Y, getCachedHex as q } from "./utils/color-cache.mjs";
|
|
16
|
+
import J from "./ColorInput.mjs";
|
|
17
|
+
import { ColorContrastLabels as Q } from "./ColorContrastLabels.mjs";
|
|
18
|
+
import { ColorContrastSvg as Z } from "./ColorContrastSvg.mjs";
|
|
19
|
+
import { provideLocalizationService as ee } from "@progress/kendo-react-intl";
|
|
20
|
+
import { colorGradientHueSliderLabel as E, messages as w, colorGradientAlphaSliderLabel as x } from "../messages/index.mjs";
|
|
21
|
+
const te = "rgba", H = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h extends r.Component {
|
|
22
22
|
constructor(t) {
|
|
23
|
-
super(t), this.wrapperRef =
|
|
23
|
+
super(t), this.wrapperRef = r.createRef(), this.hsvGradientRef = r.createRef(), this.showLicenseWatermark = !1, this.focus = () => {
|
|
24
24
|
this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
|
|
25
25
|
}, this.onHexChange = (e, s, i) => {
|
|
26
26
|
if (this.isUncontrolled) {
|
|
@@ -30,12 +30,12 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
30
30
|
z(this.state.guid, s, e);
|
|
31
31
|
this.dispatchChangeEvent(s, i, i.nativeEvent);
|
|
32
32
|
}, this.onRgbaChange = (e, s) => {
|
|
33
|
-
const i =
|
|
33
|
+
const i = O(e);
|
|
34
34
|
if (this.isUncontrolled) {
|
|
35
35
|
const n = b(i), l = d(i, "hex");
|
|
36
36
|
this.setState({ hsva: n, backgroundColor: p(n.h), rgba: e, hex: l });
|
|
37
37
|
} else
|
|
38
|
-
|
|
38
|
+
W(this.state.guid, i, e);
|
|
39
39
|
this.dispatchChangeEvent(i, s.syntheticEvent, s.nativeEvent);
|
|
40
40
|
}, this.onAlphaSliderChange = (e) => {
|
|
41
41
|
this.handleHsvaChange(
|
|
@@ -69,8 +69,8 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
69
69
|
}, this.onKeyDown = (e) => {
|
|
70
70
|
var s;
|
|
71
71
|
(s = this.navigation) == null || s.triggerKeyboardEvent(e);
|
|
72
|
-
},
|
|
73
|
-
const a = t.value || t.defaultValue || d(
|
|
72
|
+
}, this.showLicenseWatermark = !D(K, { component: "ColorGradient" });
|
|
73
|
+
const a = t.value || t.defaultValue || d(H, te);
|
|
74
74
|
this.state = Object.assign({}, h.getStateFromValue(a), {
|
|
75
75
|
isFirstRender: !0,
|
|
76
76
|
guid: this.props.id
|
|
@@ -150,7 +150,7 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
150
150
|
const a = this.getGradientRectMetrics(), e = (1 - this.state.hsva.v) * a.height, s = this.state.hsva.s * a.width;
|
|
151
151
|
t.top = `${e}px`, t.left = `${s}px`;
|
|
152
152
|
}
|
|
153
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ r.createElement(
|
|
154
154
|
"div",
|
|
155
155
|
{
|
|
156
156
|
ref: this.hsvGradientRef,
|
|
@@ -171,18 +171,18 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
171
171
|
* @hidden
|
|
172
172
|
*/
|
|
173
173
|
moveDragHandle(t, a) {
|
|
174
|
-
const e = this.getGradientRectMetrics(), s = e.width, i = e.height, n = y(a, 0, i), l = y(t, 0, s),
|
|
174
|
+
const e = this.getGradientRectMetrics(), s = e.width, i = e.height, n = y(a, 0, i), l = y(t, 0, s), L = Object.assign({}, this.state.hsva, {
|
|
175
175
|
s: l / s,
|
|
176
176
|
v: 1 - n / i
|
|
177
177
|
});
|
|
178
|
-
this.handleHsvaChange(
|
|
178
|
+
this.handleHsvaChange(L, {}, {});
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* @hidden
|
|
182
182
|
*/
|
|
183
183
|
handleHsvaChange(t, a, e) {
|
|
184
184
|
const s = U(t), i = d(s, "hex");
|
|
185
|
-
this.isUncontrolled ||
|
|
185
|
+
this.isUncontrolled || j(this.state.guid, s, t), this.setState({ hsva: t, backgroundColor: p(t.h), rgba: c(s), hex: i }), this.dispatchChangeEvent(s, a, e);
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
188
|
* @hidden
|
|
@@ -199,8 +199,8 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
199
199
|
* @hidden
|
|
200
200
|
*/
|
|
201
201
|
static getStateFromValue(t, a) {
|
|
202
|
-
R(d(t, "hex")) || (t =
|
|
203
|
-
const e =
|
|
202
|
+
R(d(t, "hex")) || (t = H);
|
|
203
|
+
const e = X(a, t) || b(t), s = Y(a, t) || c(t), i = q(a, t) || d(t, "hex"), n = p(e.h);
|
|
204
204
|
return { hsva: e, backgroundColor: n, rgba: s, hex: i };
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
@@ -225,8 +225,8 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
225
225
|
* @hidden
|
|
226
226
|
*/
|
|
227
227
|
render() {
|
|
228
|
-
const t =
|
|
229
|
-
return /* @__PURE__ */
|
|
228
|
+
const t = ee(this);
|
|
229
|
+
return /* @__PURE__ */ r.createElement(
|
|
230
230
|
"div",
|
|
231
231
|
{
|
|
232
232
|
id: this.props.id,
|
|
@@ -240,7 +240,7 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
240
240
|
this.props.className
|
|
241
241
|
),
|
|
242
242
|
"aria-disabled": this.props.disabled ? "true" : void 0,
|
|
243
|
-
style: this.props.style,
|
|
243
|
+
style: { position: "relative", ...this.props.style },
|
|
244
244
|
ref: this.wrapperRef,
|
|
245
245
|
tabIndex: k(this.props.tabIndex, this.props.disabled),
|
|
246
246
|
"aria-label": this.props.ariaLabel,
|
|
@@ -249,14 +249,14 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
249
249
|
onFocus: this.onFocus,
|
|
250
250
|
onKeyDown: this.onKeyDown
|
|
251
251
|
},
|
|
252
|
-
/* @__PURE__ */
|
|
252
|
+
/* @__PURE__ */ r.createElement("div", { className: `k-colorgradient-canvas ${this.props._adaptive ? "k-vstack" : "k-hstack"}` }, /* @__PURE__ */ r.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } }, /* @__PURE__ */ r.createElement(
|
|
253
253
|
_,
|
|
254
254
|
{
|
|
255
255
|
onDrag: this.onDrag,
|
|
256
256
|
onRelease: this.onRelease,
|
|
257
257
|
ref: (a) => this.gradientWrapper = a ? a.element : void 0
|
|
258
258
|
},
|
|
259
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ r.createElement(
|
|
260
260
|
"div",
|
|
261
261
|
{
|
|
262
262
|
className: "k-hsv-gradient",
|
|
@@ -265,14 +265,14 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
265
265
|
},
|
|
266
266
|
this.renderRectangleDragHandle()
|
|
267
267
|
)
|
|
268
|
-
), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */
|
|
269
|
-
|
|
268
|
+
), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */ r.createElement(
|
|
269
|
+
Z,
|
|
270
270
|
{
|
|
271
271
|
metrics: this.gradientWrapper ? this.getGradientRectMetrics() : void 0,
|
|
272
272
|
hsva: this.state.hsva,
|
|
273
273
|
backgroundColor: this.props.backgroundColor
|
|
274
274
|
}
|
|
275
|
-
)), /* @__PURE__ */
|
|
275
|
+
)), /* @__PURE__ */ r.createElement("div", { className: `k-hsv-controls ${this.props._adaptive ? "k-vstack" : "k-hstack"}` }, /* @__PURE__ */ r.createElement(
|
|
276
276
|
S,
|
|
277
277
|
{
|
|
278
278
|
value: this.state.hsva.h,
|
|
@@ -286,10 +286,10 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
286
286
|
disabled: this.props.disabled,
|
|
287
287
|
ariaLabel: t.toLanguageString(
|
|
288
288
|
E,
|
|
289
|
-
|
|
289
|
+
w[E]
|
|
290
290
|
)
|
|
291
291
|
}
|
|
292
|
-
), this.props.opacity && /* @__PURE__ */
|
|
292
|
+
), this.props.opacity && /* @__PURE__ */ r.createElement(
|
|
293
293
|
S,
|
|
294
294
|
{
|
|
295
295
|
value: R(this.state.hsva.a) ? this.state.hsva.a * 100 : 100,
|
|
@@ -299,8 +299,8 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
299
299
|
max: 100,
|
|
300
300
|
step: 1,
|
|
301
301
|
ariaLabel: t.toLanguageString(
|
|
302
|
-
|
|
303
|
-
x
|
|
302
|
+
x,
|
|
303
|
+
w[x]
|
|
304
304
|
),
|
|
305
305
|
onChange: this.onAlphaSliderChange,
|
|
306
306
|
className: "k-alpha-slider k-colorgradient-slider",
|
|
@@ -308,8 +308,8 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
308
308
|
ref: (a) => this.alphaSlider = a
|
|
309
309
|
}
|
|
310
310
|
))),
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
311
|
+
/* @__PURE__ */ r.createElement(
|
|
312
|
+
J,
|
|
313
313
|
{
|
|
314
314
|
rgba: this.state.rgba,
|
|
315
315
|
onRgbaChange: this.onRgbaChange,
|
|
@@ -322,27 +322,28 @@ const ee = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h exten
|
|
|
322
322
|
fillMode: this.props.fillMode
|
|
323
323
|
}
|
|
324
324
|
),
|
|
325
|
-
this.props.backgroundColor && /* @__PURE__ */
|
|
325
|
+
this.props.backgroundColor && /* @__PURE__ */ r.createElement(Q, { bgColor: c(this.props.backgroundColor), rgba: this.state.rgba }),
|
|
326
|
+
this.showLicenseWatermark && /* @__PURE__ */ r.createElement(T, null)
|
|
326
327
|
);
|
|
327
328
|
}
|
|
328
329
|
};
|
|
329
330
|
h.displayName = "ColorGradient", h.propTypes = {
|
|
330
|
-
defaultValue:
|
|
331
|
-
value:
|
|
332
|
-
onChange:
|
|
333
|
-
onFocus:
|
|
334
|
-
opacity:
|
|
335
|
-
backgroundColor:
|
|
336
|
-
format:
|
|
337
|
-
disabled:
|
|
338
|
-
style:
|
|
339
|
-
id:
|
|
340
|
-
role:
|
|
341
|
-
ariaLabel:
|
|
342
|
-
ariaLabelledBy:
|
|
343
|
-
ariaDescribedBy:
|
|
344
|
-
className:
|
|
345
|
-
size:
|
|
331
|
+
defaultValue: o.string,
|
|
332
|
+
value: o.string,
|
|
333
|
+
onChange: o.func,
|
|
334
|
+
onFocus: o.func,
|
|
335
|
+
opacity: o.bool,
|
|
336
|
+
backgroundColor: o.string,
|
|
337
|
+
format: o.any,
|
|
338
|
+
disabled: o.bool,
|
|
339
|
+
style: o.any,
|
|
340
|
+
id: o.string,
|
|
341
|
+
role: o.string,
|
|
342
|
+
ariaLabel: o.string,
|
|
343
|
+
ariaLabelledBy: o.string,
|
|
344
|
+
ariaDescribedBy: o.string,
|
|
345
|
+
className: o.string,
|
|
346
|
+
size: o.oneOf(["small", "medium", "large", null])
|
|
346
347
|
}, h.defaultProps = {
|
|
347
348
|
opacity: !0,
|
|
348
349
|
role: "textbox",
|
|
@@ -350,15 +351,15 @@ h.displayName = "ColorGradient", h.propTypes = {
|
|
|
350
351
|
size: "medium"
|
|
351
352
|
};
|
|
352
353
|
let m = h;
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
const se = B(), ae = P(
|
|
355
|
+
V(
|
|
356
|
+
se,
|
|
356
357
|
m
|
|
357
358
|
)
|
|
358
359
|
);
|
|
359
|
-
|
|
360
|
+
ae.displayName = "KendoReactColorGradient";
|
|
360
361
|
export {
|
|
361
|
-
|
|
362
|
-
|
|
362
|
+
ae as ColorGradient,
|
|
363
|
+
se as ColorGradientPropsContext,
|
|
363
364
|
m as ColorGradientWithoutContext
|
|
364
365
|
};
|
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 P=require("react"),s=require("prop-types"),R=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),k=require("./models/palette-presets.js"),T=require("./utils/misc.js"),F=require("./utils/color-parser.js");function N(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=N(P),C=24,h=10,g="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 R.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:F.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=k.PALETTEPRESETS[this.props.palette];return T.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||h}:{colors:[],columns:0}}return{colors:this.props.palette||[],columns:this.props.columns||h}}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,b=o&&o.col,S=i!==void 0&&i.row===e,E=i&&i.col;return t.map((u,d)=>{const f=c&&b===d,y=r.classNames("k-colorpalette-tile",{"k-selected":f,"k-focus":S&&E===d});return l.createElement("td",{role:"gridcell",className:y,"aria-label":u,"aria-selected":f?!0:this.props.disabled?void 0:!1,style:{backgroundColor:u},onClick:w=>this.onColorClick(u,w),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:g,tileSize:C,size:"medium"};let p=n;const m=r.createPropsContext(),v=r.withIdHOC(r.withPropsContext(m,p));v.displayName="KendoReactColorPalette";exports.ColorPalette=v;exports.ColorPalettePropsContext=m;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=h;exports.DEFAULT_PRESET=g;exports.DEFAULT_TILE_SIZE=C;
|
package/colors/ColorPalette.mjs
CHANGED
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
import * as i from "react";
|
|
9
9
|
import s from "prop-types";
|
|
10
10
|
import { ColorPaletteService as S } from "./utils/color-palette.service.mjs";
|
|
11
|
-
import { KEYS as l,
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
11
|
+
import { KEYS as l, classNames as u, kendoThemeMaps as w, getTabIndex as E, dispatchEvent as y, createPropsContext as k, withIdHOC as R, withPropsContext as F } from "@progress/kendo-react-common";
|
|
12
|
+
import { PALETTEPRESETS as N } from "./models/palette-presets.mjs";
|
|
13
|
+
import { isPresent as T } from "./utils/misc.mjs";
|
|
14
|
+
import { parseColor as P } from "./utils/color-parser.mjs";
|
|
15
|
+
const I = 24, f = 10, D = "office", a = class a extends i.Component {
|
|
17
16
|
constructor(t) {
|
|
18
17
|
super(t), this.wrapperRef = i.createRef(), this.paletteService = null, this.focus = () => {
|
|
19
18
|
this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
|
|
@@ -44,7 +43,7 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
44
43
|
this.paletteService && (this.setState({ focusedColor: this.state.selectedColor || this.paletteService.colorRows[0][0] }), this.props.onFocus && this.props.onFocus.call(void 0, e));
|
|
45
44
|
}, this.onBlur = () => {
|
|
46
45
|
this.setState({ focusedColor: void 0 });
|
|
47
|
-
},
|
|
46
|
+
}, this.state = {
|
|
48
47
|
selectedColor: this.props.value !== void 0 ? this.props.value : this.props.defaultValue ? this.props.defaultValue : void 0,
|
|
49
48
|
isFirstRender: !0
|
|
50
49
|
};
|
|
@@ -67,7 +66,7 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
67
66
|
className: u(
|
|
68
67
|
"k-colorpalette",
|
|
69
68
|
{
|
|
70
|
-
[`k-colorpalette-${
|
|
69
|
+
[`k-colorpalette-${w.sizeMap[this.props.size] || this.props.size}`]: this.props.size,
|
|
71
70
|
"k-disabled": this.props.disabled
|
|
72
71
|
},
|
|
73
72
|
this.props.className
|
|
@@ -78,7 +77,7 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
78
77
|
"aria-disabled": this.props.ariaDisabled || (this.props.disabled ? "true" : void 0),
|
|
79
78
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
80
79
|
"aria-describedby": this.props.ariaDescribedBy,
|
|
81
|
-
tabIndex:
|
|
80
|
+
tabIndex: E(this.props.tabIndex, this.props.disabled),
|
|
82
81
|
ref: this.wrapperRef
|
|
83
82
|
},
|
|
84
83
|
/* @__PURE__ */ i.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ i.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
|
|
@@ -113,7 +112,7 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
113
112
|
this.isUncontrolled && this.setState({ selectedColor: this.state.focusedColor }), this.dispatchChangeEvent(this.state.focusedColor, t);
|
|
114
113
|
}
|
|
115
114
|
dispatchChangeEvent(t, e) {
|
|
116
|
-
y(this.props.onChange, e, this, { value: t, rgbaValue:
|
|
115
|
+
y(this.props.onChange, e, this, { value: t, rgbaValue: P(t, "rgba") });
|
|
117
116
|
}
|
|
118
117
|
get focusedColorCooridanates() {
|
|
119
118
|
return this.state.focusedColor && this.paletteService ? this.paletteService.getCellCoordsFor(this.state.focusedColor) : void 0;
|
|
@@ -123,8 +122,8 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
123
122
|
}
|
|
124
123
|
getPaletteInfo() {
|
|
125
124
|
if (typeof this.props.palette == "string") {
|
|
126
|
-
const t =
|
|
127
|
-
return
|
|
125
|
+
const t = N[this.props.palette];
|
|
126
|
+
return T(t) ? {
|
|
128
127
|
colors: t.colors,
|
|
129
128
|
columns: this.props.columns || t.columns || f
|
|
130
129
|
} : { colors: [], columns: 0 };
|
|
@@ -135,17 +134,17 @@ const z = 24, f = 10, L = "office", a = class a extends i.Component {
|
|
|
135
134
|
return t.map((r, n) => /* @__PURE__ */ i.createElement("tr", { role: "row", key: n }, this.renderColumns(r, n, e, o)));
|
|
136
135
|
}
|
|
137
136
|
renderColumns(t, e, o, r) {
|
|
138
|
-
const n = o !== void 0 && o.row === e, C = o && o.col, m = r !== void 0 && r.row === e,
|
|
137
|
+
const n = o !== void 0 && o.row === e, C = o && o.col, m = r !== void 0 && r.row === e, v = r && r.col;
|
|
139
138
|
return t.map((d, c) => {
|
|
140
|
-
const h = n && C === c,
|
|
139
|
+
const h = n && C === c, g = u("k-colorpalette-tile", {
|
|
141
140
|
"k-selected": h,
|
|
142
|
-
"k-focus": m &&
|
|
141
|
+
"k-focus": m && v === c
|
|
143
142
|
});
|
|
144
143
|
return /* @__PURE__ */ i.createElement(
|
|
145
144
|
"td",
|
|
146
145
|
{
|
|
147
146
|
role: "gridcell",
|
|
148
|
-
className:
|
|
147
|
+
className: g,
|
|
149
148
|
"aria-label": d,
|
|
150
149
|
"aria-selected": h ? !0 : this.props.disabled ? void 0 : !1,
|
|
151
150
|
style: { backgroundColor: d },
|
|
@@ -176,23 +175,23 @@ a.displayName = "ColorPalette", a.propTypes = {
|
|
|
176
175
|
className: s.string,
|
|
177
176
|
size: s.oneOf(["small", "medium", "large", null])
|
|
178
177
|
}, a.defaultProps = {
|
|
179
|
-
palette:
|
|
180
|
-
tileSize:
|
|
178
|
+
palette: D,
|
|
179
|
+
tileSize: I,
|
|
181
180
|
size: "medium"
|
|
182
181
|
};
|
|
183
182
|
let p = a;
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
const z = k(), L = R(
|
|
184
|
+
F(
|
|
185
|
+
z,
|
|
187
186
|
p
|
|
188
187
|
)
|
|
189
188
|
);
|
|
190
|
-
|
|
189
|
+
L.displayName = "KendoReactColorPalette";
|
|
191
190
|
export {
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
L as ColorPalette,
|
|
192
|
+
z as ColorPalettePropsContext,
|
|
194
193
|
p as ColorPaletteWithoutContext,
|
|
195
194
|
f as DEFAULT_COLUMNS_COUNT,
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
D as DEFAULT_PRESET,
|
|
196
|
+
I as DEFAULT_TILE_SIZE
|
|
198
197
|
};
|