@progress/kendo-react-inputs 8.2.0-develop.29 → 8.2.0-develop.30

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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),i=require("prop-types"),h=require("@progress/kendo-react-common"),x=require("../package-metadata.js"),v=require("../slider/Slider.js"),u=require("./utils/misc.js"),r=require("./utils/color-parser.js"),c=require("./utils/color-cache.js"),E=require("./ColorInput.js"),H=require("./ColorContrastLabels.js"),F=require("./ColorContrastSvg.js"),L=require("@progress/kendo-react-intl"),g=require("../messages/index.js");function P(p){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const e=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(t,s,e.get?e:{enumerable:!0,get:()=>p[s]})}}return t.default=p,Object.freeze(t)}const n=P(y),G="rgba",m="rgba(255, 255, 255, 1)",d=class d extends n.Component{constructor(t){super(t),this.wrapper=null,this.onHexChange=(e,a,o)=>{if(this.isUncontrolled){const l=r.getHSV(a);this.setState({hsva:l,backgroundColor:r.getColorFromHue(l.h),rgba:r.getRGBA(a),hex:e})}else c.cacheHex(this.state.guid,a,e);this.dispatchChangeEvent(a,o,o.nativeEvent)},this.onRgbaChange=(e,a)=>{const o=r.getColorFromRGBA(e);if(this.isUncontrolled){const l=r.getHSV(o),C=r.parseColor(o,"hex");this.setState({hsva:l,backgroundColor:r.getColorFromHue(l.h),rgba:e,hex:C})}else c.cacheRgba(this.state.guid,o,e);this.dispatchChangeEvent(o,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.changePosition=e=>{const a=this.getGradientRectMetrics(),o=e.clientX-a.left,l=e.clientY-a.top,C=u.fitIntoBounds(o,0,a.width),S=u.fitIntoBounds(l,0,a.height),R=Object.assign({},this.state.hsva,{s:C/a.width,v:1-S/a.height});this.handleHsvaChange(R,e,e.nativeEvent)},this.onFocus=e=>{this.props.onFocus&&this.props.onFocus.call(void 0,{nativeEvent:e,target:this})},this.focus=()=>{this.wrapper&&h.focusFirstFocusableChild(this.wrapper)},h.validatePackage(x.packageMetadata);const s=t.value||t.defaultValue||r.parseColor(m,G);this.state=Object.assign({},d.getStateFromValue(s),{isFirstRender:!0,guid:this.props.id})}static getDerivedStateFromProps(t,s){return t.value&&!s.isFirstRender?d.getStateFromValue(t.value,s.guid):null}componentDidMount(){this.setAlphaSliderBackground(this.state.backgroundColor),this.state.isFirstRender&&this.setState({isFirstRender:!1})}componentWillUnmount(){c.removeCachedColor(this.state.guid)}componentDidUpdate(t,s){s.backgroundColor!==this.state.backgroundColor&&this.setAlphaSliderBackground(this.state.backgroundColor)}renderRectangleDragHandle(){let 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 n.createElement("div",{role:"slider",tabIndex:h.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})}handleHsvaChange(t,s,e){const a=r.getColorFromHSV(t);if(this.isUncontrolled){const o=r.parseColor(a,"hex");this.setState({hsva:t,backgroundColor:r.getColorFromHue(t.h),rgba:r.getRGBA(a),hex:o})}else c.cacheHsva(this.state.guid,a,t);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){u.isPresent(r.parseColor(t,"hex"))||(t=m);const e=c.getCachedHsva(s,t)||r.getHSV(t),a=c.getCachedRgba(s,t)||r.getRGBA(t),o=c.getCachedHex(s,t)||r.parseColor(t,"hex"),l=r.getColorFromHue(e.h);return{hsva:e,backgroundColor:l,rgba:a,hex:o}}setAlphaSliderBackground(t){this.props.opacity&&this.alphaSlider&&this.alphaSlider.sliderTrack&&(this.alphaSlider.sliderTrack.style.background=`linear-gradient(to top, transparent, ${t})`)}get isUncontrolled(){return this.props.value===void 0}getGradientRectMetrics(){return this.gradientWrapper.getBoundingClientRect()}render(){const t=L.provideLocalizationService(this),s=h.classNames("k-colorgradient",{"k-disabled":this.props.disabled},this.props.className);return n.createElement("div",{id:this.props.id,role:this.props.role,className:s,"aria-disabled":this.props.disabled?"true":void 0,style:this.props.style,ref:e=>this.wrapper=e,tabIndex:h.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},n.createElement("div",{className:"k-colorgradient-canvas k-hstack"},n.createElement("div",{className:"k-hsv-rectangle",style:{background:this.state.backgroundColor}},n.createElement(h.Draggable,{onDrag:this.onDrag,onRelease:this.onRelease,ref:e=>this.gradientWrapper=e?e.element:void 0},n.createElement("div",{className:"k-hsv-gradient",style:{touchAction:"none"},onClick:this.onGradientWrapperClick},this.renderRectangleDragHandle())),this.props.backgroundColor&&!this.state.isFirstRender&&n.createElement(F.ColorContrastSvg,{metrics:this.gradientWrapper?this.getGradientRectMetrics():void 0,hsva:this.state.hsva,backgroundColor:this.props.backgroundColor})),n.createElement("div",{className:"k-hsv-controls k-hstack"},n.createElement(v.Slider,{value:this.state.hsva.h,buttons:!1,vertical:!0,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&&n.createElement(v.Slider,{value:u.isPresent(this.state.hsva.a)?this.state.hsva.a*100:100,buttons:!1,vertical:!0,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:e=>this.alphaSlider=e}))),n.createElement(E,{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}),this.props.backgroundColor&&n.createElement(H.ColorContrastLabels,{bgColor:r.getRGBA(this.props.backgroundColor),rgba:this.state.rgba}))}};d.displayName="ColorGradient",d.propTypes={defaultValue:i.string,value:i.string,onChange:i.func,onFocus:i.func,opacity:i.bool,backgroundColor:i.string,format:i.any,disabled:i.bool,style:i.any,id:i.string,role:i.string,ariaLabel:i.string,ariaLabelledBy:i.string,ariaDescribedBy:i.string,className:i.string},d.defaultProps={opacity:!0,role:"textbox",format:"rgb"};let b=d;const k=h.createPropsContext(),f=h.withIdHOC(h.withPropsContext(k,b));f.displayName="KendoReactColorGradient";exports.ColorGradient=f;exports.ColorGradientPropsContext=k;exports.ColorGradientWithoutContext=b;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react"),n=require("prop-types"),i=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"),x=require("./ColorInput.js"),w=require("./ColorContrastLabels.js"),G=require("./ColorContrastSvg.js"),D=require("@progress/kendo-react-intl"),p=require("../messages/index.js");function L(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const a in u)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(u,a);Object.defineProperty(t,a,e.get?e:{enumerable:!0,get:()=>u[a]})}}return t.default=u,Object.freeze(t)}const l=L(E),A="rgba",S="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.focus=()=>{this.wrapperRef&&this.wrapperRef.current&&this.wrapperRef.current.focus()},this.onHexChange=(e,s,r)=>{if(this.isUncontrolled){const h=o.getHSV(s);this.setState({hsva:h,backgroundColor:o.getColorFromHue(h.h),rgba:o.getRGBA(s),hex:e})}else d.cacheHex(this.state.guid,s,e);this.dispatchChangeEvent(s,r,r.nativeEvent)},this.onRgbaChange=(e,s)=>{const r=o.getColorFromRGBA(e);if(this.isUncontrolled){const h=o.getHSV(r),g=o.parseColor(r,"hex");this.setState({hsva:h,backgroundColor:o.getColorFromHue(h.h),rgba:e,hex:g})}else d.cacheRgba(this.state.guid,r,e);this.dispatchChangeEvent(r,s.syntheticEvent,s.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 s;(s=this.hsvNavigation)==null||s.triggerKeyboardEvent(e)},this.onHsvGradientValueChange=(e,s,r)=>{const h=parseInt(e.style.top,10)+r,g=parseInt(e.style.left,10)+s;e.style.top=`${h}px`,e.style.left=`${g}px`,this.moveDragHandle(g,h)},this.changePosition=e=>{const s=this.getGradientRectMetrics(),r=e.clientX-s.left,h=e.clientY-s.top;this.moveDragHandle(r,h)},this.onFocus=e=>{this.props.onFocus&&this.props.onFocus.call(void 0,{nativeEvent:e,target:this})},this.onKeyDown=e=>{var s;(s=this.navigation)==null||s.triggerKeyboardEvent(e)},i.validatePackage(H.packageMetadata);const a=t.value||t.defaultValue||o.parseColor(S,A);this.state=Object.assign({},c.getStateFromValue(a),{isFirstRender:!0,guid:this.props.id})}static getDerivedStateFromProps(t,a){return t.value&&!a.isFirstRender?c.getStateFromValue(t.value,a.guid):null}componentDidMount(){if(this.setAlphaSliderBackground(this.state.backgroundColor),this.state.isFirstRender&&this.setState({isFirstRender:!1}),this.wrapperRef&&this.hsvGradientRef){let t=0,a=0;this.hsvNavigation=new i.Navigation({tabIndex:0,root:this.hsvGradientRef,selectors:[".k-hsv-rectangle .k-hsv-draghandle"],keyboardEvents:{keydown:{ArrowDown:(e,s,r)=>{a=r.shiftKey?this.props.gradientSliderSmallStep||b:this.props.gradientSliderStep||C,this.onHsvGradientValueChange(e,0,a)},ArrowUp:(e,s,r)=>{a=r.shiftKey?-(this.props.gradientSliderSmallStep||b):-(this.props.gradientSliderStep||C),this.onHsvGradientValueChange(e,0,a)},ArrowLeft:(e,s,r)=>{t=r.shiftKey?-(this.props.gradientSliderSmallStep||b):-(this.props.gradientSliderStep||C),this.onHsvGradientValueChange(e,t,0)},ArrowRight:(e,s,r)=>{t=r.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 i.Navigation({tabIndex:0,root:this.wrapperRef,selectors:[".k-colorgradient"],keyboardEvents:{keydown:{Tab:(t,a,e)=>{i.getActiveElement(document)===t?i.disableNavigatableContainer(t):i.keepFocusInContainer(e,t,i.TABBABLE_ELEMENTS)},Enter:(t,a,e)=>{i.getActiveElement(document)===t&&(i.focusFirstFocusableChild(t),i.enableNavigatableContainer(t))},Escape:(t,a,e)=>{i.getActiveElement(document)!==t&&(t.focus(),i.disableNavigatableContainer(t))}}}}))}componentWillUnmount(){d.removeCachedColor(this.state.guid)}componentDidUpdate(t,a){a.backgroundColor!==this.state.backgroundColor&&this.setAlphaSliderBackground(this.state.backgroundColor)}renderRectangleDragHandle(){let t={};if(!this.state.isFirstRender){const a=this.getGradientRectMetrics(),e=(1-this.state.hsva.v)*a.height,s=this.state.hsva.s*a.width;t.top=`${e}px`,t.left=`${s}px`}return l.createElement("div",{ref:this.hsvGradientRef,role:"slider",tabIndex:i.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,a){const e=this.getGradientRectMetrics(),s=e.width,r=e.height,h=v.fitIntoBounds(a,0,r),g=v.fitIntoBounds(t,0,s),y=Object.assign({},this.state.hsva,{s:g/s,v:1-h/r});this.handleHsvaChange(y,{},{})}handleHsvaChange(t,a,e){const s=o.getColorFromHSV(t);if(this.isUncontrolled){const r=o.parseColor(s,"hex");this.setState({hsva:t,backgroundColor:o.getColorFromHue(t.h),rgba:o.getRGBA(s),hex:r})}else d.cacheHsva(this.state.guid,s,t);this.dispatchChangeEvent(s,a,e)}dispatchChangeEvent(t,a,e){this.props.onChange&&this.props.onChange.call(void 0,{syntheticEvent:a,nativeEvent:e,target:this,value:t})}static getStateFromValue(t,a){v.isPresent(o.parseColor(t,"hex"))||(t=S);const e=d.getCachedHsva(a,t)||o.getHSV(t),s=d.getCachedRgba(a,t)||o.getRGBA(t),r=d.getCachedHex(a,t)||o.parseColor(t,"hex"),h=o.getColorFromHue(e.h);return{hsva:e,backgroundColor:h,rgba:s,hex:r}}setAlphaSliderBackground(t){this.props.opacity&&this.alphaSlider&&this.alphaSlider.sliderTrack&&(this.alphaSlider.sliderTrack.style.background=`linear-gradient(to top, transparent, ${t})`)}get isUncontrolled(){return this.props.value===void 0}getGradientRectMetrics(){return this.gradientWrapper.getBoundingClientRect()}render(){const t=D.provideLocalizationService(this),a=i.classNames("k-colorgradient",{"k-disabled":this.props.disabled},this.props.className);return l.createElement("div",{id:this.props.id,role:this.props.role,className:a,"aria-disabled":this.props.disabled?"true":void 0,style:this.props.style,ref:this.wrapperRef,tabIndex:i.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 k-hstack"},l.createElement("div",{className:"k-hsv-rectangle",style:{background:this.state.backgroundColor}},l.createElement(i.Draggable,{onDrag:this.onDrag,onRelease:this.onRelease,ref:e=>this.gradientWrapper=e?e.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 k-hstack"},l.createElement(m.Slider,{value:this.state.hsva.h,buttons:!1,vertical:!0,min:0,max:360,step:5,onChange:this.onHueSliderChange,className:"k-hue-slider k-colorgradient-slider",disabled:this.props.disabled,ariaLabel:t.toLanguageString(p.colorGradientHueSliderLabel,p.messages[p.colorGradientHueSliderLabel])}),this.props.opacity&&l.createElement(m.Slider,{value:v.isPresent(this.state.hsva.a)?this.state.hsva.a*100:100,buttons:!1,vertical:!0,min:0,max:100,step:1,ariaLabel:t.toLanguageString(p.colorGradientAlphaSliderLabel,p.messages[p.colorGradientAlphaSliderLabel]),onChange:this.onAlphaSliderChange,className:"k-alpha-slider k-colorgradient-slider",disabled:this.props.disabled,ref:e=>this.alphaSlider=e}))),l.createElement(x,{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}),this.props.backgroundColor&&l.createElement(w.ColorContrastLabels,{bgColor:o.getRGBA(this.props.backgroundColor),rgba:this.state.rgba}))}};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},c.defaultProps={opacity:!0,role:"textbox",format:"rgb"};let f=c;const R=i.createPropsContext(),k=i.withIdHOC(i.withPropsContext(R,f));k.displayName="KendoReactColorGradient";exports.ColorGradient=k;exports.ColorGradientPropsContext=R;exports.ColorGradientWithoutContext=f;
@@ -6,154 +6,213 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as o from "react";
10
- import i from "prop-types";
11
- import { focusFirstFocusableChild as E, validatePackage as F, getTabIndex as u, classNames as H, Draggable as L, createPropsContext as D, withIdHOC as N, withPropsContext as A } from "@progress/kendo-react-common";
12
- import { packageMetadata as B } from "../package-metadata.mjs";
13
- import { Slider as m } from "../slider/Slider.mjs";
14
- import { fitIntoBounds as C, isPresent as v } from "./utils/misc.mjs";
15
- import { getHSV as g, getColorFromHue as d, getRGBA as c, getColorFromRGBA as P, parseColor as l, getColorFromHSV as w } from "./utils/color-parser.mjs";
16
- import { cacheHex as I, cacheRgba as M, removeCachedColor as T, cacheHsva as V, getCachedHsva as G, getCachedRgba as O, getCachedHex as U } from "./utils/color-cache.mjs";
17
- import j from "./ColorInput.mjs";
18
- import { ColorContrastLabels as W } from "./ColorContrastLabels.mjs";
19
- import { ColorContrastSvg as $ } from "./ColorContrastSvg.mjs";
20
- import { provideLocalizationService as X } from "@progress/kendo-react-intl";
21
- import { colorGradientHueSliderLabel as f, messages as k, colorGradientAlphaSliderLabel as S } from "../messages/index.mjs";
22
- const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component {
23
- constructor(e) {
24
- super(e), this.wrapper = null, this.onHexChange = (t, s, r) => {
9
+ import * as r from "react";
10
+ import o from "prop-types";
11
+ import { validatePackage as L, Navigation as m, getActiveElement as u, disableNavigatableContainer as C, keepFocusInContainer as F, TABBABLE_ELEMENTS as G, focusFirstFocusableChild as A, enableNavigatableContainer as N, getTabIndex as S, classNames as I, Draggable as T, createPropsContext as M, withIdHOC as _, withPropsContext as B } from "@progress/kendo-react-common";
12
+ import { packageMetadata as P } from "../package-metadata.mjs";
13
+ import { Slider as k } from "../slider/Slider.mjs";
14
+ import { isPresent as R, fitIntoBounds as y } from "./utils/misc.mjs";
15
+ import { getHSV as b, getColorFromHue as c, getRGBA as p, getColorFromRGBA as V, parseColor as d, getColorFromHSV as K } from "./utils/color-parser.mjs";
16
+ import { cacheHex as U, cacheRgba as O, removeCachedColor as W, cacheHsva as $, getCachedHsva as j, getCachedRgba as X, getCachedHex as Y } from "./utils/color-cache.mjs";
17
+ import z from "./ColorInput.mjs";
18
+ import { ColorContrastLabels as q } from "./ColorContrastLabels.mjs";
19
+ import { ColorContrastSvg as J } from "./ColorContrastSvg.mjs";
20
+ import { provideLocalizationService as Q } from "@progress/kendo-react-intl";
21
+ import { colorGradientHueSliderLabel as E, messages as x, colorGradientAlphaSliderLabel as H } from "../messages/index.mjs";
22
+ const Z = "rgba", w = "rgba(255, 255, 255, 1)", g = 2, v = 5, h = class h extends r.Component {
23
+ constructor(t) {
24
+ super(t), this.wrapperRef = r.createRef(), this.hsvGradientRef = r.createRef(), this.focus = () => {
25
+ this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
26
+ }, this.onHexChange = (e, s, i) => {
25
27
  if (this.isUncontrolled) {
26
- const n = g(s);
27
- this.setState({ hsva: n, backgroundColor: d(n.h), rgba: c(s), hex: t });
28
+ const n = b(s);
29
+ this.setState({ hsva: n, backgroundColor: c(n.h), rgba: p(s), hex: e });
28
30
  } else
29
- I(this.state.guid, s, t);
30
- this.dispatchChangeEvent(s, r, r.nativeEvent);
31
- }, this.onRgbaChange = (t, s) => {
32
- const r = P(t);
31
+ U(this.state.guid, s, e);
32
+ this.dispatchChangeEvent(s, i, i.nativeEvent);
33
+ }, this.onRgbaChange = (e, s) => {
34
+ const i = V(e);
33
35
  if (this.isUncontrolled) {
34
- const n = g(r), p = l(r, "hex");
35
- this.setState({ hsva: n, backgroundColor: d(n.h), rgba: t, hex: p });
36
+ const n = b(i), l = d(i, "hex");
37
+ this.setState({ hsva: n, backgroundColor: c(n.h), rgba: e, hex: l });
36
38
  } else
37
- M(this.state.guid, r, t);
38
- this.dispatchChangeEvent(r, s.syntheticEvent, s.nativeEvent);
39
- }, this.onAlphaSliderChange = (t) => {
39
+ O(this.state.guid, i, e);
40
+ this.dispatchChangeEvent(i, s.syntheticEvent, s.nativeEvent);
41
+ }, this.onAlphaSliderChange = (e) => {
40
42
  this.handleHsvaChange(
41
- Object.assign({}, this.state.hsva, { a: t.value / 100 }),
42
- t.syntheticEvent,
43
- t.nativeEvent
43
+ Object.assign({}, this.state.hsva, { a: e.value / 100 }),
44
+ e.syntheticEvent,
45
+ e.nativeEvent
44
46
  );
45
- }, this.onHueSliderChange = (t) => {
47
+ }, this.onHueSliderChange = (e) => {
46
48
  this.handleHsvaChange(
47
- Object.assign({}, this.state.hsva, { h: t.value }),
48
- t.syntheticEvent,
49
- t.nativeEvent
49
+ Object.assign({}, this.state.hsva, { h: e.value }),
50
+ e.syntheticEvent,
51
+ e.nativeEvent
50
52
  );
51
- }, this.onDrag = (t) => {
52
- this.gradientWrapper.classList.add("k-dragging"), this.changePosition(t.event);
53
+ }, this.onDrag = (e) => {
54
+ this.gradientWrapper.classList.add("k-dragging"), this.changePosition(e.event);
53
55
  }, this.onRelease = () => {
54
56
  this.gradientWrapper.classList.remove("k-dragging");
55
- }, this.onGradientWrapperClick = (t) => {
56
- this.changePosition(t);
57
- }, this.changePosition = (t) => {
58
- const s = this.getGradientRectMetrics(), r = t.clientX - s.left, n = t.clientY - s.top, p = C(r, 0, s.width), x = C(n, 0, s.height), y = Object.assign(
59
- {},
60
- this.state.hsva,
61
- { s: p / s.width, v: 1 - x / s.height }
62
- );
63
- this.handleHsvaChange(y, t, t.nativeEvent);
64
- }, this.onFocus = (t) => {
57
+ }, this.onGradientWrapperClick = (e) => {
58
+ this.changePosition(e);
59
+ }, this.onHsvGradientKeyDown = (e) => {
60
+ var s;
61
+ (s = this.hsvNavigation) == null || s.triggerKeyboardEvent(e);
62
+ }, this.onHsvGradientValueChange = (e, s, i) => {
63
+ const n = parseInt(e.style.top, 10) + i, l = parseInt(e.style.left, 10) + s;
64
+ e.style.top = `${n}px`, e.style.left = `${l}px`, this.moveDragHandle(l, n);
65
+ }, this.changePosition = (e) => {
66
+ const s = this.getGradientRectMetrics(), i = e.clientX - s.left, n = e.clientY - s.top;
67
+ this.moveDragHandle(i, n);
68
+ }, this.onFocus = (e) => {
65
69
  this.props.onFocus && this.props.onFocus.call(
66
70
  void 0,
67
- { nativeEvent: t, target: this }
71
+ { nativeEvent: e, target: this }
68
72
  );
69
- }, this.focus = () => {
70
- this.wrapper && E(this.wrapper);
71
- }, F(B);
72
- const a = e.value || e.defaultValue || l(R, Y);
73
+ }, this.onKeyDown = (e) => {
74
+ var s;
75
+ (s = this.navigation) == null || s.triggerKeyboardEvent(e);
76
+ }, L(P);
77
+ const a = t.value || t.defaultValue || d(w, Z);
73
78
  this.state = Object.assign({}, h.getStateFromValue(a), { isFirstRender: !0, guid: this.props.id });
74
79
  }
75
80
  /**
76
81
  * @hidden
77
82
  */
78
- static getDerivedStateFromProps(e, a) {
79
- return e.value && !a.isFirstRender ? h.getStateFromValue(e.value, a.guid) : null;
83
+ static getDerivedStateFromProps(t, a) {
84
+ return t.value && !a.isFirstRender ? h.getStateFromValue(t.value, a.guid) : null;
80
85
  }
81
86
  /**
82
87
  * @hidden
83
88
  */
84
89
  componentDidMount() {
85
- this.setAlphaSliderBackground(this.state.backgroundColor), this.state.isFirstRender && this.setState({ isFirstRender: !1 });
90
+ if (this.setAlphaSliderBackground(this.state.backgroundColor), this.state.isFirstRender && this.setState({ isFirstRender: !1 }), this.wrapperRef && this.hsvGradientRef) {
91
+ let t = 0, a = 0;
92
+ this.hsvNavigation = new m({
93
+ tabIndex: 0,
94
+ root: this.hsvGradientRef,
95
+ selectors: [".k-hsv-rectangle .k-hsv-draghandle"],
96
+ keyboardEvents: {
97
+ keydown: {
98
+ ArrowDown: (e, s, i) => {
99
+ a = i.shiftKey ? this.props.gradientSliderSmallStep || g : this.props.gradientSliderStep || v, this.onHsvGradientValueChange(e, 0, a);
100
+ },
101
+ ArrowUp: (e, s, i) => {
102
+ a = i.shiftKey ? -(this.props.gradientSliderSmallStep || g) : -(this.props.gradientSliderStep || v), this.onHsvGradientValueChange(e, 0, a);
103
+ },
104
+ ArrowLeft: (e, s, i) => {
105
+ t = i.shiftKey ? -(this.props.gradientSliderSmallStep || g) : -(this.props.gradientSliderStep || v), this.onHsvGradientValueChange(e, t, 0);
106
+ },
107
+ ArrowRight: (e, s, i) => {
108
+ t = i.shiftKey ? this.props.gradientSliderSmallStep || g : this.props.gradientSliderStep || v, this.onHsvGradientValueChange(e, t, 0);
109
+ }
110
+ }
111
+ }
112
+ });
113
+ }
114
+ this.wrapperRef && this.wrapperRef.current && (this.props.isInsidePopup ? this.hsvGradientRef.current && this.hsvGradientRef.current.focus() : this.navigation = new m({
115
+ tabIndex: 0,
116
+ root: this.wrapperRef,
117
+ selectors: [".k-colorgradient"],
118
+ keyboardEvents: {
119
+ keydown: {
120
+ Tab: (t, a, e) => {
121
+ u(document) === t ? C(t) : F(e, t, G);
122
+ },
123
+ Enter: (t, a, e) => {
124
+ u(document) === t && (A(t), N(t));
125
+ },
126
+ Escape: (t, a, e) => {
127
+ u(document) !== t && (t.focus(), C(t));
128
+ }
129
+ }
130
+ }
131
+ }));
86
132
  }
87
133
  /**
88
134
  * @hidden
89
135
  */
90
136
  componentWillUnmount() {
91
- T(this.state.guid);
137
+ W(this.state.guid);
92
138
  }
93
139
  /**
94
140
  * @hidden
95
141
  */
96
- componentDidUpdate(e, a) {
142
+ componentDidUpdate(t, a) {
97
143
  a.backgroundColor !== this.state.backgroundColor && this.setAlphaSliderBackground(this.state.backgroundColor);
98
144
  }
99
145
  /**
100
146
  * @hidden
101
147
  */
102
148
  renderRectangleDragHandle() {
103
- let e = {};
149
+ let t = {};
104
150
  if (!this.state.isFirstRender) {
105
- const a = this.getGradientRectMetrics(), t = (1 - this.state.hsva.v) * a.height, s = this.state.hsva.s * a.width;
106
- e.top = `${t}px`, e.left = `${s}px`;
151
+ const a = this.getGradientRectMetrics(), e = (1 - this.state.hsva.v) * a.height, s = this.state.hsva.s * a.width;
152
+ t.top = `${e}px`, t.left = `${s}px`;
107
153
  }
108
- return /* @__PURE__ */ o.createElement(
154
+ return /* @__PURE__ */ r.createElement(
109
155
  "div",
110
156
  {
157
+ ref: this.hsvGradientRef,
111
158
  role: "slider",
112
- tabIndex: u(this.props.tabIndex, this.props.disabled),
159
+ tabIndex: S(this.props.tabIndex, this.props.disabled),
113
160
  "aria-valuetext": this.props.ariaValueText,
114
161
  "aria-valuenow": parseInt(this.state.hex.substring(1), 16),
115
162
  "aria-label": this.props.ariaLabelHSV,
116
163
  "aria-orientation": void 0,
117
164
  "aria-disabled": this.props.disabled ? "true" : void 0,
118
165
  className: "k-hsv-draghandle k-draghandle",
119
- style: e
166
+ style: t,
167
+ onKeyDown: this.onHsvGradientKeyDown
120
168
  }
121
169
  );
122
170
  }
123
171
  /**
124
172
  * @hidden
125
173
  */
126
- handleHsvaChange(e, a, t) {
127
- const s = w(e);
174
+ moveDragHandle(t, a) {
175
+ const e = this.getGradientRectMetrics(), s = e.width, i = e.height, n = y(a, 0, i), l = y(t, 0, s), D = Object.assign(
176
+ {},
177
+ this.state.hsva,
178
+ { s: l / s, v: 1 - n / i }
179
+ );
180
+ this.handleHsvaChange(D, {}, {});
181
+ }
182
+ /**
183
+ * @hidden
184
+ */
185
+ handleHsvaChange(t, a, e) {
186
+ const s = K(t);
128
187
  if (this.isUncontrolled) {
129
- const r = l(s, "hex");
130
- this.setState({ hsva: e, backgroundColor: d(e.h), rgba: c(s), hex: r });
188
+ const i = d(s, "hex");
189
+ this.setState({ hsva: t, backgroundColor: c(t.h), rgba: p(s), hex: i });
131
190
  } else
132
- V(this.state.guid, s, e);
133
- this.dispatchChangeEvent(s, a, t);
191
+ $(this.state.guid, s, t);
192
+ this.dispatchChangeEvent(s, a, e);
134
193
  }
135
194
  /**
136
195
  * @hidden
137
196
  */
138
- dispatchChangeEvent(e, a, t) {
197
+ dispatchChangeEvent(t, a, e) {
139
198
  this.props.onChange && this.props.onChange.call(
140
199
  void 0,
141
- { syntheticEvent: a, nativeEvent: t, target: this, value: e }
200
+ { syntheticEvent: a, nativeEvent: e, target: this, value: t }
142
201
  );
143
202
  }
144
203
  /**
145
204
  * @hidden
146
205
  */
147
- static getStateFromValue(e, a) {
148
- v(l(e, "hex")) || (e = R);
149
- const t = G(a, e) || g(e), s = O(a, e) || c(e), r = U(a, e) || l(e, "hex"), n = d(t.h);
150
- return { hsva: t, backgroundColor: n, rgba: s, hex: r };
206
+ static getStateFromValue(t, a) {
207
+ R(d(t, "hex")) || (t = w);
208
+ const e = j(a, t) || b(t), s = X(a, t) || p(t), i = Y(a, t) || d(t, "hex"), n = c(e.h);
209
+ return { hsva: e, backgroundColor: n, rgba: s, hex: i };
151
210
  }
152
211
  /**
153
212
  * @hidden
154
213
  */
155
- setAlphaSliderBackground(e) {
156
- this.props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack && (this.alphaSlider.sliderTrack.style.background = `linear-gradient(to top, transparent, ${e})`);
214
+ setAlphaSliderBackground(t) {
215
+ this.props.opacity && this.alphaSlider && this.alphaSlider.sliderTrack && (this.alphaSlider.sliderTrack.style.background = `linear-gradient(to top, transparent, ${t})`);
157
216
  }
158
217
  /**
159
218
  * @hidden
@@ -171,8 +230,8 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
171
230
  * @hidden
172
231
  */
173
232
  render() {
174
- const e = X(this), a = H("k-colorgradient", { "k-disabled": this.props.disabled }, this.props.className);
175
- return /* @__PURE__ */ o.createElement(
233
+ const t = Q(this), a = I("k-colorgradient", { "k-disabled": this.props.disabled }, this.props.className);
234
+ return /* @__PURE__ */ r.createElement(
176
235
  "div",
177
236
  {
178
237
  id: this.props.id,
@@ -180,21 +239,22 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
180
239
  className: a,
181
240
  "aria-disabled": this.props.disabled ? "true" : void 0,
182
241
  style: this.props.style,
183
- ref: (t) => this.wrapper = t,
184
- tabIndex: u(this.props.tabIndex, this.props.disabled),
242
+ ref: this.wrapperRef,
243
+ tabIndex: S(this.props.tabIndex, this.props.disabled),
185
244
  "aria-label": this.props.ariaLabel,
186
245
  "aria-labelledby": this.props.ariaLabelledBy,
187
246
  "aria-describedby": this.props.ariaDescribedBy,
188
- onFocus: this.onFocus
247
+ onFocus: this.onFocus,
248
+ onKeyDown: this.onKeyDown
189
249
  },
190
- /* @__PURE__ */ o.createElement("div", { className: "k-colorgradient-canvas k-hstack" }, /* @__PURE__ */ o.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } }, /* @__PURE__ */ o.createElement(
191
- L,
250
+ /* @__PURE__ */ r.createElement("div", { className: "k-colorgradient-canvas k-hstack" }, /* @__PURE__ */ r.createElement("div", { className: "k-hsv-rectangle", style: { background: this.state.backgroundColor } }, /* @__PURE__ */ r.createElement(
251
+ T,
192
252
  {
193
253
  onDrag: this.onDrag,
194
254
  onRelease: this.onRelease,
195
- ref: (t) => this.gradientWrapper = t ? t.element : void 0
255
+ ref: (e) => this.gradientWrapper = e ? e.element : void 0
196
256
  },
197
- /* @__PURE__ */ o.createElement(
257
+ /* @__PURE__ */ r.createElement(
198
258
  "div",
199
259
  {
200
260
  className: "k-hsv-gradient",
@@ -203,15 +263,15 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
203
263
  },
204
264
  this.renderRectangleDragHandle()
205
265
  )
206
- ), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */ o.createElement(
207
- $,
266
+ ), this.props.backgroundColor && !this.state.isFirstRender && /* @__PURE__ */ r.createElement(
267
+ J,
208
268
  {
209
269
  metrics: this.gradientWrapper ? this.getGradientRectMetrics() : void 0,
210
270
  hsva: this.state.hsva,
211
271
  backgroundColor: this.props.backgroundColor
212
272
  }
213
- )), /* @__PURE__ */ o.createElement("div", { className: "k-hsv-controls k-hstack" }, /* @__PURE__ */ o.createElement(
214
- m,
273
+ )), /* @__PURE__ */ r.createElement("div", { className: "k-hsv-controls k-hstack" }, /* @__PURE__ */ r.createElement(
274
+ k,
215
275
  {
216
276
  value: this.state.hsva.h,
217
277
  buttons: !1,
@@ -222,26 +282,26 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
222
282
  onChange: this.onHueSliderChange,
223
283
  className: "k-hue-slider k-colorgradient-slider",
224
284
  disabled: this.props.disabled,
225
- ariaLabel: e.toLanguageString(f, k[f])
285
+ ariaLabel: t.toLanguageString(E, x[E])
226
286
  }
227
- ), this.props.opacity && /* @__PURE__ */ o.createElement(
228
- m,
287
+ ), this.props.opacity && /* @__PURE__ */ r.createElement(
288
+ k,
229
289
  {
230
- value: v(this.state.hsva.a) ? this.state.hsva.a * 100 : 100,
290
+ value: R(this.state.hsva.a) ? this.state.hsva.a * 100 : 100,
231
291
  buttons: !1,
232
292
  vertical: !0,
233
293
  min: 0,
234
294
  max: 100,
235
295
  step: 1,
236
- ariaLabel: e.toLanguageString(S, k[S]),
296
+ ariaLabel: t.toLanguageString(H, x[H]),
237
297
  onChange: this.onAlphaSliderChange,
238
298
  className: "k-alpha-slider k-colorgradient-slider",
239
299
  disabled: this.props.disabled,
240
- ref: (t) => this.alphaSlider = t
300
+ ref: (e) => this.alphaSlider = e
241
301
  }
242
302
  ))),
243
- /* @__PURE__ */ o.createElement(
244
- j,
303
+ /* @__PURE__ */ r.createElement(
304
+ z,
245
305
  {
246
306
  rgba: this.state.rgba,
247
307
  onRgbaChange: this.onRgbaChange,
@@ -252,10 +312,10 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
252
312
  defaultInputMode: this.props.format
253
313
  }
254
314
  ),
255
- this.props.backgroundColor && /* @__PURE__ */ o.createElement(
256
- W,
315
+ this.props.backgroundColor && /* @__PURE__ */ r.createElement(
316
+ q,
257
317
  {
258
- bgColor: c(this.props.backgroundColor),
318
+ bgColor: p(this.props.backgroundColor),
259
319
  rgba: this.state.rgba
260
320
  }
261
321
  )
@@ -263,31 +323,31 @@ const Y = "rgba", R = "rgba(255, 255, 255, 1)", h = class h extends o.Component
263
323
  }
264
324
  };
265
325
  h.displayName = "ColorGradient", h.propTypes = {
266
- defaultValue: i.string,
267
- value: i.string,
268
- onChange: i.func,
269
- onFocus: i.func,
270
- opacity: i.bool,
271
- backgroundColor: i.string,
272
- format: i.any,
273
- disabled: i.bool,
274
- style: i.any,
275
- id: i.string,
276
- role: i.string,
277
- ariaLabel: i.string,
278
- ariaLabelledBy: i.string,
279
- ariaDescribedBy: i.string,
280
- className: i.string
326
+ defaultValue: o.string,
327
+ value: o.string,
328
+ onChange: o.func,
329
+ onFocus: o.func,
330
+ opacity: o.bool,
331
+ backgroundColor: o.string,
332
+ format: o.any,
333
+ disabled: o.bool,
334
+ style: o.any,
335
+ id: o.string,
336
+ role: o.string,
337
+ ariaLabel: o.string,
338
+ ariaLabelledBy: o.string,
339
+ ariaDescribedBy: o.string,
340
+ className: o.string
281
341
  }, h.defaultProps = {
282
342
  opacity: !0,
283
343
  role: "textbox",
284
344
  format: "rgb"
285
345
  };
286
- let b = h;
287
- const z = D(), K = N(A(z, b));
288
- K.displayName = "KendoReactColorGradient";
346
+ let f = h;
347
+ const ee = M(), te = _(B(ee, f));
348
+ te.displayName = "KendoReactColorGradient";
289
349
  export {
290
- K as ColorGradient,
291
- z as ColorGradientPropsContext,
292
- b as ColorGradientWithoutContext
350
+ te as ColorGradient,
351
+ ee as ColorGradientPropsContext,
352
+ f as ColorGradientWithoutContext
293
353
  };
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),s=require("prop-types"),N=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),R=require("../package-metadata.js"),D=require("./models/palette-presets.js"),I=require("./utils/misc.js"),L=require("./utils/color-parser.js");function O(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const a=O(T),b=24,C=10,m="office",c=class c extends a.Component{constructor(t){super(t),this.wrapper=null,this.paletteService=null,this.focus=()=>{this.wrapper&&this.wrapper.focus()},this.onKeyDown=e=>{switch(e.keyCode){case r.Keys.down:this.handleCellNavigation(0,1);break;case r.Keys.up:this.handleCellNavigation(0,-1);break;case r.Keys.right:this.handleCellNavigation(1,0);break;case r.Keys.left:this.handleCellNavigation(-1,0);break;case r.Keys.enter:this.handleEnter(e);break;default:return}e.preventDefault()},this.onColorClick=(e,o)=>{this.isUncontrolled?this.setState({selectedColor:e,focusedColor:e}):this.setState({focusedColor:e}),this.dispatchChangeEvent(e,o)},this.onFocus=e=>{this.paletteService&&(this.setState({focusedColor:this.state.selectedColor||this.paletteService.colorRows[0][0]}),this.props.onFocus&&this.props.onFocus.call(void 0,e))},this.onBlur=()=>{this.setState({focusedColor:void 0})},r.validatePackage(R.packageMetadata),this.state={selectedColor:this.props.value!==void 0?this.props.value:this.props.defaultValue?this.props.defaultValue:void 0,isFirstRender:!0}}get guid(){return this.props.id}render(){const t=this.getPaletteInfo(),e=this.paletteService=new N.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor),l=r.classNames("k-colorpalette",{"k-disabled":this.props.disabled},this.props.className);return t.colors.length?a.createElement("div",{id:this.props.id,role:"grid",className:l,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,"aria-disabled":this.props.ariaDisabled||(this.props.disabled?"true":void 0),"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),ref:h=>this.wrapper=h},a.createElement("table",{className:"k-colorpalette-table",role:"presentation"},a.createElement("tbody",{role:"rowgroup"},this.renderRows(e.colorRows,o,i)))):""}static getDerivedStateFromProps(t,e){if(!e.isFirstRender&&t.value!==void 0){if(t.value===""&&e.selectedColor!==void 0)return{selectedColor:void 0};if(t.value!==""&&t.value!==e.selectedColor)return{selectedColor:t.value}}else if(e.isFirstRender)return{isFirstRender:!1};return null}handleCellNavigation(t,e){if(this.paletteService)if(this.focusedColorCooridanates){const o=this.paletteService.getNextCell(this.focusedColorCooridanates,t,e);this.setState({focusedColor:this.paletteService.getColorAt(o)})}else this.setState({focusedColor:this.paletteService.colorRows[0][0]})}handleEnter(t){this.isUncontrolled&&this.setState({selectedColor:this.state.focusedColor}),this.dispatchChangeEvent(this.state.focusedColor,t)}dispatchChangeEvent(t,e){r.dispatchEvent(this.props.onChange,e,this,{value:t,rgbaValue:L.parseColor(t,"rgba")})}get focusedColorCooridanates(){return this.state.focusedColor&&this.paletteService?this.paletteService.getCellCoordsFor(this.state.focusedColor):void 0}get isUncontrolled(){return this.props.value===void 0}getPaletteInfo(){if(typeof this.props.palette=="string"){const t=D.PALETTEPRESETS[this.props.palette];return I.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||C}:{colors:[],columns:0}}else return{colors:this.props.palette||[],columns:this.props.columns||C}}renderRows(t,e,o){return t.map((i,l)=>a.createElement("tr",{role:"row",key:l},this.renderColumns(i,l,e,o)))}renderColumns(t,e,o,i){const l=o!==void 0&&o.row===e,h=o&&o.col,E=i!==void 0&&i.row===e,w=i&&i.col,f=typeof this.props.tileSize!="number"?this.props.tileSize:{width:this.props.tileSize,height:this.props.tileSize},g=f.width+"px",P=f.height+"px";return t.map((u,d)=>{const v=l&&h===d,k=r.classNames("k-colorpalette-tile",{"k-selected":v,"k-focus":E&&w===d});return a.createElement("td",{role:"gridcell",className:k,"aria-label":u,"aria-selected":v?!0:this.props.disabled?void 0:!1,style:{backgroundColor:u,width:g,height:P,minWidth:g},onClick:F=>this.onColorClick(u,F),id:this.createCellId({row:e,col:d}),key:d})})}createCellId(t){return`${this.guid}_${t.row}_${t.col}`}};c.displayName="ColorPalette",c.propTypes={palette:s.oneOfType([s.arrayOf(s.string.isRequired),s.string]),columns:s.number,tileSize:s.any,defaultValue:s.string,value:s.string,disabled:s.bool,tabIndex:s.number,onChange:s.func,onFocus:s.func,id:s.string,ariaLabelledBy:s.string,ariaDescribedBy:s.string,className:s.string},c.defaultProps={palette:m,tileSize:b};let p=c;const S=r.createPropsContext(),y=r.withIdHOC(r.withPropsContext(S,p));y.displayName="KendoReactColorPalette";exports.ColorPalette=y;exports.ColorPalettePropsContext=S;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=C;exports.DEFAULT_PRESET=m;exports.DEFAULT_TILE_SIZE=b;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),s=require("prop-types"),T=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),N=require("../package-metadata.js"),D=require("./models/palette-presets.js"),I=require("./utils/misc.js"),L=require("./utils/color-parser.js");function O(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const l=O(F),v=24,u=10,S="office",c=class c extends l.Component{constructor(t){super(t),this.wrapperRef=l.createRef(),this.paletteService=null,this.focus=()=>{this.wrapperRef&&this.wrapperRef.current&&this.wrapperRef.current.focus()},this.onKeyDown=e=>{switch(e.key){case r.KEYS.down:this.handleCellNavigation(0,1);break;case r.KEYS.up:this.handleCellNavigation(0,-1);break;case r.KEYS.right:this.handleCellNavigation(1,0);break;case r.KEYS.left:this.handleCellNavigation(-1,0);break;case r.KEYS.enter:this.handleEnter(e);break;default:return}e.preventDefault()},this.onColorClick=(e,o)=>{this.isUncontrolled?this.setState({selectedColor:e,focusedColor:e}):this.setState({focusedColor:e}),this.dispatchChangeEvent(e,o)},this.onFocus=e=>{this.paletteService&&(this.setState({focusedColor:this.state.selectedColor||this.paletteService.colorRows[0][0]}),this.props.onFocus&&this.props.onFocus.call(void 0,e))},this.onBlur=()=>{this.setState({focusedColor:void 0})},r.validatePackage(N.packageMetadata),this.state={selectedColor:this.props.value!==void 0?this.props.value:this.props.defaultValue?this.props.defaultValue:void 0,isFirstRender:!0}}get guid(){return this.props.id}render(){const t=this.getPaletteInfo(),e=this.paletteService=new T.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor),a=r.classNames("k-colorpalette",{"k-disabled":this.props.disabled},this.props.className);return t.colors.length?l.createElement("div",{id:this.props.id,role:"grid",className:a,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,"aria-disabled":this.props.ariaDisabled||(this.props.disabled?"true":void 0),"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),ref:this.wrapperRef},l.createElement("table",{className:"k-colorpalette-table",role:"presentation"},l.createElement("tbody",{role:"rowgroup"},this.renderRows(e.colorRows,o,i)))):""}static getDerivedStateFromProps(t,e){if(!e.isFirstRender&&t.value!==void 0){if(t.value===""&&e.selectedColor!==void 0)return{selectedColor:void 0};if(t.value!==""&&t.value!==e.selectedColor)return{selectedColor:t.value}}else if(e.isFirstRender)return{isFirstRender:!1};return null}handleCellNavigation(t,e){if(this.paletteService)if(this.focusedColorCooridanates){const o=this.paletteService.getNextCell(this.focusedColorCooridanates,t,e);this.setState({focusedColor:this.paletteService.getColorAt(o)})}else this.setState({focusedColor:this.paletteService.colorRows[0][0]})}handleEnter(t){this.isUncontrolled&&this.setState({selectedColor:this.state.focusedColor}),this.dispatchChangeEvent(this.state.focusedColor,t)}dispatchChangeEvent(t,e){r.dispatchEvent(this.props.onChange,e,this,{value:t,rgbaValue:L.parseColor(t,"rgba")})}get focusedColorCooridanates(){return this.state.focusedColor&&this.paletteService?this.paletteService.getCellCoordsFor(this.state.focusedColor):void 0}get isUncontrolled(){return this.props.value===void 0}getPaletteInfo(){if(typeof this.props.palette=="string"){const t=D.PALETTEPRESETS[this.props.palette];return I.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||u}:{colors:[],columns:0}}else return{colors:this.props.palette||[],columns:this.props.columns||u}}renderRows(t,e,o){return t.map((i,a)=>l.createElement("tr",{role:"row",key:a},this.renderColumns(i,a,e,o)))}renderColumns(t,e,o,i){const a=o!==void 0&&o.row===e,E=o&&o.col,w=i!==void 0&&i.row===e,y=i&&i.col,f=typeof this.props.tileSize!="number"?this.props.tileSize:{width:this.props.tileSize,height:this.props.tileSize},C=f.width+"px",P=f.height+"px";return t.map((h,d)=>{const g=a&&E===d,k=r.classNames("k-colorpalette-tile",{"k-selected":g,"k-focus":w&&y===d});return l.createElement("td",{role:"gridcell",className:k,"aria-label":h,"aria-selected":g?!0:this.props.disabled?void 0:!1,style:{backgroundColor:h,width:C,height:P,minWidth:C},onClick:R=>this.onColorClick(h,R),id:this.createCellId({row:e,col:d}),key:d})})}createCellId(t){return`${this.guid}_${t.row}_${t.col}`}};c.displayName="ColorPalette",c.propTypes={palette:s.oneOfType([s.arrayOf(s.string.isRequired),s.string]),columns:s.number,tileSize:s.any,defaultValue:s.string,value:s.string,disabled:s.bool,tabIndex:s.number,onChange:s.func,onFocus:s.func,id:s.string,ariaLabelledBy:s.string,ariaDescribedBy:s.string,className:s.string},c.defaultProps={palette:S,tileSize:v};let p=c;const b=r.createPropsContext(),m=r.withIdHOC(r.withPropsContext(b,p));m.displayName="KendoReactColorPalette";exports.ColorPalette=m;exports.ColorPalettePropsContext=b;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=u;exports.DEFAULT_PRESET=S;exports.DEFAULT_TILE_SIZE=v;