@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.
@@ -6,20 +6,20 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as l from "react";
9
+ import * as i from "react";
10
10
  import s from "prop-types";
11
11
  import { ColorPaletteService as E } from "./utils/color-palette.service.mjs";
12
- import { Keys as a, validatePackage as k, classNames as m, getTabIndex as F, dispatchEvent as N, createPropsContext as P, withIdHOC as R, withPropsContext as T } from "@progress/kendo-react-common";
12
+ import { KEYS as a, validatePackage as k, classNames as C, getTabIndex as R, dispatchEvent as F, createPropsContext as N, withIdHOC as P, withPropsContext as T } from "@progress/kendo-react-common";
13
13
  import { packageMetadata as I } from "../package-metadata.mjs";
14
14
  import { PALETTEPRESETS as D } from "./models/palette-presets.mjs";
15
15
  import { isPresent as L } from "./utils/misc.mjs";
16
16
  import { parseColor as U } from "./utils/color-parser.mjs";
17
- const x = 24, g = 10, z = "office", n = class n extends l.Component {
17
+ const x = 24, m = 10, z = "office", n = class n extends i.Component {
18
18
  constructor(t) {
19
- super(t), this.wrapper = null, this.paletteService = null, this.focus = () => {
20
- this.wrapper && this.wrapper.focus();
19
+ super(t), this.wrapperRef = i.createRef(), this.paletteService = null, this.focus = () => {
20
+ this.wrapperRef && this.wrapperRef.current && this.wrapperRef.current.focus();
21
21
  }, this.onKeyDown = (e) => {
22
- switch (e.keyCode) {
22
+ switch (e.key) {
23
23
  case a.down:
24
24
  this.handleCellNavigation(0, 1);
25
25
  break;
@@ -62,23 +62,23 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
62
62
  render() {
63
63
  const t = this.getPaletteInfo(), e = this.paletteService = new E();
64
64
  e.setColorMatrix(t.colors, t.columns);
65
- const o = e.getCellCoordsFor(this.state.selectedColor), r = e.getCellCoordsFor(this.state.focusedColor), i = m("k-colorpalette", { "k-disabled": this.props.disabled }, this.props.className);
66
- return t.colors.length ? /* @__PURE__ */ l.createElement(
65
+ const o = e.getCellCoordsFor(this.state.selectedColor), r = e.getCellCoordsFor(this.state.focusedColor), l = C("k-colorpalette", { "k-disabled": this.props.disabled }, this.props.className);
66
+ return t.colors.length ? /* @__PURE__ */ i.createElement(
67
67
  "div",
68
68
  {
69
69
  id: this.props.id,
70
70
  role: "grid",
71
- className: i,
71
+ className: l,
72
72
  onFocus: this.onFocus,
73
73
  onBlur: this.onBlur,
74
74
  onKeyDown: this.onKeyDown,
75
75
  "aria-disabled": this.props.ariaDisabled || (this.props.disabled ? "true" : void 0),
76
76
  "aria-labelledby": this.props.ariaLabelledBy,
77
77
  "aria-describedby": this.props.ariaDescribedBy,
78
- tabIndex: F(this.props.tabIndex, this.props.disabled),
79
- ref: (d) => this.wrapper = d
78
+ tabIndex: R(this.props.tabIndex, this.props.disabled),
79
+ ref: this.wrapperRef
80
80
  },
81
- /* @__PURE__ */ l.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ l.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
81
+ /* @__PURE__ */ i.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ i.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
82
82
  ) : "";
83
83
  }
84
84
  /**
@@ -110,7 +110,7 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
110
110
  this.isUncontrolled && this.setState({ selectedColor: this.state.focusedColor }), this.dispatchChangeEvent(this.state.focusedColor, t);
111
111
  }
112
112
  dispatchChangeEvent(t, e) {
113
- N(this.props.onChange, e, this, { value: t, rgbaValue: U(t, "rgba") });
113
+ F(this.props.onChange, e, this, { value: t, rgbaValue: U(t, "rgba") });
114
114
  }
115
115
  get focusedColorCooridanates() {
116
116
  return this.state.focusedColor && this.paletteService ? this.paletteService.getCellCoordsFor(this.state.focusedColor) : void 0;
@@ -123,33 +123,33 @@ const x = 24, g = 10, z = "office", n = class n extends l.Component {
123
123
  const t = D[this.props.palette];
124
124
  return L(t) ? {
125
125
  colors: t.colors,
126
- columns: this.props.columns || t.columns || g
126
+ columns: this.props.columns || t.columns || m
127
127
  } : { colors: [], columns: 0 };
128
128
  } else
129
- return { colors: this.props.palette || [], columns: this.props.columns || g };
129
+ return { colors: this.props.palette || [], columns: this.props.columns || m };
130
130
  }
131
131
  renderRows(t, e, o) {
132
- return t.map((r, i) => /* @__PURE__ */ l.createElement("tr", { role: "row", key: i }, this.renderColumns(r, i, e, o)));
132
+ return t.map((r, l) => /* @__PURE__ */ i.createElement("tr", { role: "row", key: l }, this.renderColumns(r, l, e, o)));
133
133
  }
134
134
  renderColumns(t, e, o, r) {
135
- const i = o !== void 0 && o.row === e, d = o && o.col, v = r !== void 0 && r.row === e, b = r && r.col, u = typeof this.props.tileSize != "number" ? this.props.tileSize : { width: this.props.tileSize, height: this.props.tileSize }, f = u.width + "px", S = u.height + "px";
136
- return t.map((p, c) => {
137
- const C = i && d === c, w = m(
135
+ const l = o !== void 0 && o.row === e, g = o && o.col, v = r !== void 0 && r.row === e, b = r && r.col, h = typeof this.props.tileSize != "number" ? this.props.tileSize : { width: this.props.tileSize, height: this.props.tileSize }, u = h.width + "px", S = h.height + "px";
136
+ return t.map((d, c) => {
137
+ const f = l && g === c, w = C(
138
138
  "k-colorpalette-tile",
139
139
  {
140
- "k-selected": C,
140
+ "k-selected": f,
141
141
  "k-focus": v && b === c
142
142
  }
143
143
  );
144
- return /* @__PURE__ */ l.createElement(
144
+ return /* @__PURE__ */ i.createElement(
145
145
  "td",
146
146
  {
147
147
  role: "gridcell",
148
148
  className: w,
149
- "aria-label": p,
150
- "aria-selected": C ? !0 : this.props.disabled ? void 0 : !1,
151
- style: { backgroundColor: p, width: f, height: S, minWidth: f },
152
- onClick: (y) => this.onColorClick(p, y),
149
+ "aria-label": d,
150
+ "aria-selected": f ? !0 : this.props.disabled ? void 0 : !1,
151
+ style: { backgroundColor: d, width: u, height: S, minWidth: u },
152
+ onClick: (y) => this.onColorClick(d, y),
153
153
  id: this.createCellId({ row: e, col: c }),
154
154
  key: c
155
155
  }
@@ -178,14 +178,14 @@ n.displayName = "ColorPalette", n.propTypes = {
178
178
  palette: z,
179
179
  tileSize: x
180
180
  };
181
- let h = n;
182
- const B = P(), A = R(T(B, h));
181
+ let p = n;
182
+ const B = N(), A = P(T(B, p));
183
183
  A.displayName = "KendoReactColorPalette";
184
184
  export {
185
185
  A as ColorPalette,
186
186
  B as ColorPalettePropsContext,
187
- h as ColorPaletteWithoutContext,
188
- g as DEFAULT_COLUMNS_COUNT,
187
+ p as ColorPaletteWithoutContext,
188
+ m as DEFAULT_COLUMNS_COUNT,
189
189
  z as DEFAULT_PRESET,
190
190
  x as DEFAULT_TILE_SIZE
191
191
  };
@@ -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 ce=require("react"),a=require("prop-types"),n=require("@progress/kendo-react-common"),ie=require("../package-metadata.js"),ue=require("./Picker.js"),de=require("./ColorGradient.js"),B=require("./ColorPalette.js"),pe=require("@progress/kendo-react-buttons"),fe=require("@progress/kendo-svg-icons"),L=require("../messages/index.js"),me=require("@progress/kendo-react-intl");function ke(l){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const o in l)if(o!=="default"){const b=Object.getOwnPropertyDescriptor(l,o);Object.defineProperty(k,o,b.get?b:{enumerable:!0,get:()=>l[o]})}}return k.default=l,Object.freeze(k)}const e=ke(ce),be={opacity:!0},ge={palette:B.DEFAULT_PRESET,tileSize:B.DEFAULT_TILE_SIZE},A=l=>l!==void 0,z=n.createPropsContext(),M=e.forwardRef((l,k)=>{n.validatePackage(ie.packageMetadata);const o=n.usePropsContext(z,l),b=me.useLocalization(),{size:C=m.size,rounded:E=m.rounded,fillMode:q=m.fillMode,gradientSettings:F=m.gradientSettings,paletteSettings:H=m.paletteSettings,view:g=m.view,popupSettings:V,valid:j,disabled:y,tabIndex:G,icon:P,svgIcon:S,iconClassName:v,onChange:T,onFocus:w,onBlur:I,onActiveColorClick:R,className:U}=o,r=e.useRef(null),D=e.useRef(null),N=e.useRef(null),d=e.useRef(),$=e.useRef(null),[W,x]=e.useState(!1),[Z,J]=e.useState(o.defaultValue),[Q,X]=e.useState(!1),O=A(o.value),i=A(o.open),c=O?o.value:Z,p=i?o.open:Q,K=e.useCallback(()=>{r.current&&r.current.focus()},[]);e.useImperativeHandle(k,()=>({element:r.current,actionElement:$.current,value:c,focus:K}),[c,K]);const u=e.useCallback((t,f)=>{i||(!t&&!f&&r&&r.current&&r.current.focus(),X(t))},[i]),Y=e.useCallback(t=>{const{altKey:f,keyCode:s}=t;if(s===n.Keys.esc){u(!1);return}if(s===n.Keys.enter&&!i){t.preventDefault(),t.stopPropagation(),u(!p);return}f&&(s===n.Keys.up||s===n.Keys.down)&&(t.preventDefault(),t.stopPropagation(),s===n.Keys.up&&r&&r.current&&(r.current.focus(),u(!1)),s===n.Keys.down&&u(!0))},[p,i]),ee=e.useCallback(()=>{i||(D.current?D.current.focus():N.current&&N.current.focus())},[i]),te=e.useCallback(()=>{u(!p,!0)},[p]),ne=e.useCallback(t=>{R&&R.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:c})},[R,c]),oe=e.useCallback(t=>{d.current?(clearTimeout(d.current),d.current=void 0):x(!0),w&&w.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[w]),ae=e.useCallback(()=>{u(!1,!0),x(!1),d.current=void 0},[]),re=e.useCallback(t=>{clearTimeout(d.current),d.current=window.setTimeout(ae),I&&I.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[I]),h=e.useCallback((t,f)=>{const s=f?t.rgbaValue:t.value;O||J(s),f&&u(!1),T&&T.call(void 0,{value:s,nativeEvent:t.nativeEvent,syntheticEvent:t.syntheticEvent})},[O,T]),le=e.useCallback(t=>h(t,!0),[A,h]),_=n.useDir(r,o.dir),se=j!==!1;return e.createElement("span",{id:o.id,role:"combobox","aria-label":o.ariaLabel,"aria-labelledby":o.ariaLabelledBy,"aria-describedby":o.ariaDescribedBy,"aria-haspopup":"dialog","aria-expanded":p,"aria-disabled":y?"true":void 0,className:n.classNames("k-colorpicker","k-picker","k-icon-picker",{[`k-picker-${n.kendoThemeMaps.sizeMap[C]||C}`]:C,[`k-picker-${q}`]:q,[`k-rounded-${n.kendoThemeMaps.roundedMap[E]||E}`]:E,"k-invalid":!se,"k-disabled":y,"k-focus":W,className:U}),ref:r,tabIndex:n.getTabIndex(G,y),title:o.title,onKeyDown:Y,onFocus:oe,onBlur:re,dir:_},e.createElement(ue.Picker,{dir:_,open:p,onOpen:ee,popupAnchor:r.current||void 0,popupSettings:{...V},input:e.createElement("span",{onClick:ne,className:"k-input-inner"},e.createElement("span",{className:n.classNames("k-value-icon","k-color-preview",{"k-no-color":!c,"k-icon-color-preview":P||S||v})},v&&e.createElement("span",{className:n.classNames("k-color-preview-icon",v)}),!v&&(P||S)&&e.createElement(n.IconWrap,{name:P,icon:S}),e.createElement("span",{className:"k-color-preview-mask",style:{backgroundColor:c}}))),button:e.createElement(pe.Button,{tabIndex:-1,type:"button",onClick:te,className:"k-input-button",rounded:null,icon:"caret-alt-down",svgIcon:fe.caretAltDownIcon,"aria-label":b.toLanguageString(L.colorPickerDropdownButtonAriaLabel,L.messages[L.colorPickerDropdownButtonAriaLabel])}),content:e.createElement(e.Fragment,null,(g==="combo"||g==="gradient")&&e.createElement(de.ColorGradient,{...F,tabIndex:0,ref:D,value:c,onChange:h}),(g==="combo"||g==="palette")&&e.createElement(B.ColorPalette,{...H,ref:N,value:c,onChange:le}))}))});M.propTypes={value:a.string,defaultValue:a.string,disabled:a.bool,view:a.oneOf(["gradient","palette","combo"]),dir:a.string,id:a.string,icon:a.string,svgIcon:n.svgIconPropType,ariaLabelledBy:a.string,ariaDescribedBy:a.string,size:a.oneOf([null,"small","medium","large"]),rounded:a.oneOf([null,"small","medium","large","full"]),fillMode:a.oneOf([null,"solid","flat","outline"]),className:a.string};const m={size:"medium",rounded:"medium",fillMode:"solid",view:"palette",gradientSettings:be,paletteSettings:ge};M.displayName="KendoColorPicker";exports.ColorPicker=M;exports.ColorPickerPropsContext=z;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("react"),r=require("prop-types"),o=require("@progress/kendo-react-common"),ke=require("../package-metadata.js"),me=require("./Picker.js"),ge=require("./ColorGradient.js"),M=require("./ColorPalette.js"),be=require("@progress/kendo-react-buttons"),ve=require("@progress/kendo-svg-icons"),F=require("../messages/index.js"),Ee=require("@progress/kendo-react-intl");function Ce(c){const m=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const a in c)if(a!=="default"){const b=Object.getOwnPropertyDescriptor(c,a);Object.defineProperty(m,a,b.get?b:{enumerable:!0,get:()=>c[a]})}}return m.default=c,Object.freeze(m)}const e=Ce(fe),ye={opacity:!0},Pe={palette:M.DEFAULT_PRESET,tileSize:M.DEFAULT_TILE_SIZE},L=c=>c!==void 0,K=o.createPropsContext(),B=e.forwardRef((c,m)=>{o.validatePackage(ke.packageMetadata);const a=o.usePropsContext(K,c),b=Ee.useLocalization(),{size:P=k.size,rounded:T=k.rounded,fillMode:q=k.fillMode,gradientSettings:U=k.gradientSettings,paletteSettings:$=k.paletteSettings,view:u=k.view,popupSettings:W,valid:Z,disabled:w,tabIndex:J,icon:S,svgIcon:I,iconClassName:v,onChange:R,onFocus:D,onBlur:N,onActiveColorClick:h,className:Q}=a,l=e.useRef(null),g=e.useRef(null),E=e.useRef(null),f=e.useRef(),X=e.useRef(null),[Y,x]=e.useState(!1),[ee,te]=e.useState(a.defaultValue),[ne,oe]=e.useState(!1),A=L(a.value),d=L(a.open),i=A?a.value:ee,C=d?a.open:ne,_=e.useCallback(()=>{l.current&&l.current.focus()},[]);e.useImperativeHandle(m,()=>({element:l.current,actionElement:X.current,value:i,focus:_}),[i,_]);const p=e.useCallback((t,s)=>{d||(!t&&!s&&l&&l.current&&l.current.focus(),oe(t))},[d]),z=e.useMemo(()=>new o.Navigation({root:l,selectors:[".k-colorpicker",".k-color-picker-popup"],tabIndex:0,keyboardEvents:{keydown:{Escape:(t,s,n)=>{p(!1)},Enter:(t,s,n)=>{!d&&t===l.current&&(n.preventDefault(),n.stopPropagation(),p(!0))},ArrowDown:(t,s,n)=>{n.altKey&&(n.preventDefault(),n.stopPropagation(),p(!0))},ArrowUp:(t,s,n)=>{n.altKey&&(n.preventDefault(),n.stopPropagation(),p(!1))},Tab:(t,s,n)=>{var V,j;if(o.getActiveElement(document)!==l.current){const G=(V=E.current)==null?void 0:V.wrapperRef.current,y=(j=g.current)==null?void 0:j.wrapperRef.current;u==="palette"&&G?o.keepFocusInContainer(n,G):u==="gradient"&&y?o.keepFocusInContainer(n,y):u==="combo"&&y&&o.keepFocusInContainer(n,y.parentElement)}}}}}),[p,d]),ae=e.useCallback(z.triggerKeyboardEvent.bind(z),[]),re=e.useCallback(()=>{d||(g.current&&g.current.wrapperRef.current?o.focusFirstFocusableChild(g.current.wrapperRef.current):E.current&&E.current.focus())},[d]),le=e.useCallback(()=>{p(!C,!0)},[C]),ce=e.useCallback(t=>{h&&h.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:i})},[h,i]),ie=e.useCallback(t=>{f.current?(clearTimeout(f.current),f.current=void 0):x(!0),D&&D.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[D]),se=e.useCallback(()=>{p(!1,!0),x(!1),f.current=void 0},[]),ue=e.useCallback(t=>{clearTimeout(f.current),f.current=window.setTimeout(se),N&&N.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[N]),O=e.useCallback((t,s)=>{const n=s?t.rgbaValue:t.value;A||te(n),R&&R.call(void 0,{value:n,nativeEvent:t.nativeEvent,syntheticEvent:t.syntheticEvent})},[A,R]),de=e.useCallback(t=>O(t,!0),[L,O]),H=o.useDir(l,a.dir),pe=Z!==!1;return e.createElement("span",{id:a.id,role:"combobox","aria-label":a.ariaLabel,"aria-labelledby":a.ariaLabelledBy,"aria-describedby":a.ariaDescribedBy,"aria-haspopup":"dialog","aria-expanded":C,"aria-disabled":w?"true":void 0,className:o.classNames("k-colorpicker","k-picker","k-icon-picker",{[`k-picker-${o.kendoThemeMaps.sizeMap[P]||P}`]:P,[`k-picker-${q}`]:q,[`k-rounded-${o.kendoThemeMaps.roundedMap[T]||T}`]:T,"k-invalid":!pe,"k-disabled":w,"k-focus":Y,className:Q}),ref:l,tabIndex:o.getTabIndex(J,w),title:a.title,onKeyDown:ae,onFocus:ie,onBlur:ue,dir:H},e.createElement(me.Picker,{dir:H,open:C,onOpen:re,popupAnchor:l.current||void 0,popupSettings:{...W},input:e.createElement("span",{onClick:ce,className:"k-input-inner"},e.createElement("span",{className:o.classNames("k-value-icon","k-color-preview",{"k-no-color":!i,"k-icon-color-preview":S||I||v})},v&&e.createElement("span",{className:o.classNames("k-color-preview-icon",v)}),!v&&(S||I)&&e.createElement(o.IconWrap,{name:S,icon:I}),e.createElement("span",{className:"k-color-preview-mask",style:{backgroundColor:i}}))),button:e.createElement(be.Button,{tabIndex:-1,type:"button",onClick:le,className:"k-input-button",rounded:null,icon:"caret-alt-down",svgIcon:ve.caretAltDownIcon,"aria-label":b.toLanguageString(F.colorPickerDropdownButtonAriaLabel,F.messages[F.colorPickerDropdownButtonAriaLabel])}),content:e.createElement(e.Fragment,null,(u==="combo"||u==="gradient")&&e.createElement(ge.ColorGradient,{...U,ref:g,isInsidePopup:!0,value:i,onChange:O}),(u==="combo"||u==="palette")&&e.createElement(M.ColorPalette,{...$,ref:E,value:i,onChange:de}))}))});B.propTypes={value:r.string,defaultValue:r.string,disabled:r.bool,view:r.oneOf(["gradient","palette","combo"]),dir:r.string,id:r.string,icon:r.string,svgIcon:o.svgIconPropType,ariaLabelledBy:r.string,ariaDescribedBy:r.string,size:r.oneOf([null,"small","medium","large"]),rounded:r.oneOf([null,"small","medium","large","full"]),fillMode:r.oneOf([null,"solid","flat","outline"]),className:r.string};const k={size:"medium",rounded:"medium",fillMode:"solid",view:"palette",gradientSettings:ye,paletteSettings:Pe};B.displayName="KendoColorPicker";exports.ColorPicker=B;exports.ColorPickerPropsContext=K;
@@ -7,246 +7,262 @@
7
7
  */
8
8
  "use client";
9
9
  import * as e from "react";
10
- import n from "prop-types";
11
- import { createPropsContext as se, validatePackage as ce, usePropsContext as ue, Keys as p, useDir as de, classNames as h, kendoThemeMaps as H, getTabIndex as pe, IconWrap as fe, svgIconPropType as me } from "@progress/kendo-react-common";
12
- import { packageMetadata as ke } from "../package-metadata.mjs";
13
- import { Picker as ve } from "./Picker.mjs";
14
- import { ColorGradient as be } from "./ColorGradient.mjs";
15
- import { ColorPalette as ge, DEFAULT_PRESET as Ee, DEFAULT_TILE_SIZE as Ce } from "./ColorPalette.mjs";
16
- import { Button as ye } from "@progress/kendo-react-buttons";
17
- import { caretAltDownIcon as Te } from "@progress/kendo-svg-icons";
18
- import { colorPickerDropdownButtonAriaLabel as O, messages as Se } from "../messages/index.mjs";
19
- import { useLocalization as we } from "@progress/kendo-react-intl";
20
- const Ie = {
10
+ import o from "prop-types";
11
+ import { createPropsContext as fe, validatePackage as me, usePropsContext as ve, Navigation as ke, getActiveElement as ge, keepFocusInContainer as h, focusFirstFocusableChild as be, useDir as Ee, classNames as A, kendoThemeMaps as _, getTabIndex as Ce, IconWrap as we, svgIconPropType as ye } from "@progress/kendo-react-common";
12
+ import { packageMetadata as Te } from "../package-metadata.mjs";
13
+ import { Picker as Se } from "./Picker.mjs";
14
+ import { ColorGradient as Pe } from "./ColorGradient.mjs";
15
+ import { ColorPalette as Ie, DEFAULT_PRESET as Re, DEFAULT_TILE_SIZE as De } from "./ColorPalette.mjs";
16
+ import { Button as Ne } from "@progress/kendo-react-buttons";
17
+ import { caretAltDownIcon as he } from "@progress/kendo-svg-icons";
18
+ import { colorPickerDropdownButtonAriaLabel as K, messages as Ae } from "../messages/index.mjs";
19
+ import { useLocalization as Fe } from "@progress/kendo-react-intl";
20
+ const Le = {
21
21
  opacity: !0
22
- }, Pe = {
23
- palette: Ee,
24
- tileSize: Ce
25
- }, L = (v) => v !== void 0, De = se(), z = e.forwardRef((v, M) => {
26
- ce(ke);
27
- const o = ue(De, v), V = we(), {
28
- size: b = f.size,
29
- rounded: g = f.rounded,
30
- fillMode: A = f.fillMode,
31
- gradientSettings: _ = f.gradientSettings,
32
- paletteSettings: K = f.paletteSettings,
33
- view: m = f.view,
34
- popupSettings: G,
35
- valid: U,
36
- disabled: E,
37
- tabIndex: $,
38
- icon: C,
39
- svgIcon: y,
40
- iconClassName: k,
41
- onChange: T,
42
- onFocus: S,
43
- onBlur: w,
44
- onActiveColorClick: I,
45
- className: W
46
- } = o, a = e.useRef(null), P = e.useRef(null), D = e.useRef(null), c = e.useRef(), Z = e.useRef(null), [j, x] = e.useState(!1), [q, J] = e.useState(o.defaultValue), [Q, X] = e.useState(!1), N = L(o.value), i = L(o.open), l = N ? o.value : q, u = i ? o.open : Q, B = e.useCallback(
22
+ }, xe = {
23
+ palette: Re,
24
+ tileSize: De
25
+ }, F = (b) => b !== void 0, Be = fe(), U = e.forwardRef((b, G) => {
26
+ me(Te);
27
+ const a = ve(Be, b), $ = Fe(), {
28
+ size: E = d.size,
29
+ rounded: C = d.rounded,
30
+ fillMode: L = d.fillMode,
31
+ gradientSettings: W = d.gradientSettings,
32
+ paletteSettings: Z = d.paletteSettings,
33
+ view: s = d.view,
34
+ popupSettings: j,
35
+ valid: q,
36
+ disabled: w,
37
+ tabIndex: J,
38
+ icon: y,
39
+ svgIcon: T,
40
+ iconClassName: m,
41
+ onChange: S,
42
+ onFocus: P,
43
+ onBlur: I,
44
+ onActiveColorClick: R,
45
+ className: Q
46
+ } = a, r = e.useRef(null), f = e.useRef(null), v = e.useRef(null), p = e.useRef(), X = e.useRef(null), [Y, x] = e.useState(!1), [ee, te] = e.useState(a.defaultValue), [ne, oe] = e.useState(!1), D = F(a.value), c = F(a.open), l = D ? a.value : ee, k = c ? a.open : ne, B = e.useCallback(
47
47
  () => {
48
- a.current && a.current.focus();
48
+ r.current && r.current.focus();
49
49
  },
50
50
  []
51
51
  );
52
- e.useImperativeHandle(M, () => ({
52
+ e.useImperativeHandle(G, () => ({
53
53
  // we agreed that each element will have focus method exposed
54
- element: a.current,
55
- actionElement: Z.current,
54
+ element: r.current,
55
+ actionElement: X.current,
56
56
  value: l,
57
57
  focus: B
58
58
  }), [l, B]);
59
- const s = e.useCallback(
60
- (t, d) => {
61
- i || (!t && !d && a && a.current && a.current.focus(), X(t));
59
+ const u = e.useCallback(
60
+ (t, i) => {
61
+ c || (!t && !i && r && r.current && r.current.focus(), oe(t));
62
62
  },
63
- [i]
64
- ), Y = e.useCallback(
65
- (t) => {
66
- const { altKey: d, keyCode: r } = t;
67
- if (r === p.esc) {
68
- s(!1);
69
- return;
70
- }
71
- if (r === p.enter && !i) {
72
- t.preventDefault(), t.stopPropagation(), s(!u);
73
- return;
63
+ [c]
64
+ ), M = e.useMemo(
65
+ () => new ke({
66
+ root: r,
67
+ selectors: [".k-colorpicker", ".k-color-picker-popup"],
68
+ tabIndex: 0,
69
+ keyboardEvents: {
70
+ keydown: {
71
+ Escape: (t, i, n) => {
72
+ u(!1);
73
+ },
74
+ Enter: (t, i, n) => {
75
+ !c && t === r.current && (n.preventDefault(), n.stopPropagation(), u(!0));
76
+ },
77
+ ArrowDown: (t, i, n) => {
78
+ n.altKey && (n.preventDefault(), n.stopPropagation(), u(!0));
79
+ },
80
+ ArrowUp: (t, i, n) => {
81
+ n.altKey && (n.preventDefault(), n.stopPropagation(), u(!1));
82
+ },
83
+ Tab: (t, i, n) => {
84
+ var z, H;
85
+ if (ge(document) !== r.current) {
86
+ const V = (z = v.current) == null ? void 0 : z.wrapperRef.current, g = (H = f.current) == null ? void 0 : H.wrapperRef.current;
87
+ s === "palette" && V ? h(n, V) : s === "gradient" && g ? h(n, g) : s === "combo" && g && h(n, g.parentElement);
88
+ }
89
+ }
90
+ }
74
91
  }
75
- d && (r === p.up || r === p.down) && (t.preventDefault(), t.stopPropagation(), r === p.up && a && a.current && (a.current.focus(), s(!1)), r === p.down && s(!0));
76
- },
77
- [u, i]
78
- ), ee = e.useCallback(
92
+ }),
93
+ [u, c]
94
+ ), ae = e.useCallback(M.triggerKeyboardEvent.bind(M), []), re = e.useCallback(
79
95
  () => {
80
- i || (P.current ? P.current.focus() : D.current && D.current.focus());
96
+ c || (f.current && f.current.wrapperRef.current ? be(f.current.wrapperRef.current) : v.current && v.current.focus());
81
97
  },
82
- [i]
83
- ), te = e.useCallback(
98
+ [c]
99
+ ), le = e.useCallback(
84
100
  () => {
85
- s(!u, !0);
101
+ u(!k, !0);
86
102
  },
87
- [u]
88
- ), ne = e.useCallback(
103
+ [k]
104
+ ), ie = e.useCallback(
89
105
  (t) => {
90
- I && I.call(void 0, {
106
+ R && R.call(void 0, {
91
107
  syntheticEvent: t,
92
108
  nativeEvent: t.nativeEvent,
93
109
  value: l
94
110
  });
95
111
  },
96
- [I, l]
97
- ), oe = e.useCallback(
112
+ [R, l]
113
+ ), se = e.useCallback(
98
114
  (t) => {
99
- c.current ? (clearTimeout(c.current), c.current = void 0) : x(!0), S && S.call(void 0, {
115
+ p.current ? (clearTimeout(p.current), p.current = void 0) : x(!0), P && P.call(void 0, {
100
116
  nativeEvent: t.nativeEvent,
101
117
  syntheticEvent: t
102
118
  });
103
119
  },
104
- [S]
105
- ), ae = e.useCallback(
120
+ [P]
121
+ ), ce = e.useCallback(
106
122
  () => {
107
- s(!1, !0), x(!1), c.current = void 0;
123
+ u(!1, !0), x(!1), p.current = void 0;
108
124
  },
109
125
  []
110
- ), re = e.useCallback(
126
+ ), ue = e.useCallback(
111
127
  (t) => {
112
- clearTimeout(c.current), c.current = window.setTimeout(ae), w && w.call(void 0, {
128
+ clearTimeout(p.current), p.current = window.setTimeout(ce), I && I.call(void 0, {
113
129
  nativeEvent: t.nativeEvent,
114
130
  syntheticEvent: t
115
131
  });
116
132
  },
117
- [w]
118
- ), R = e.useCallback(
119
- (t, d) => {
120
- const r = d ? t.rgbaValue : t.value;
121
- N || J(r), d && s(!1), T && T.call(void 0, {
122
- value: r,
133
+ [I]
134
+ ), N = e.useCallback(
135
+ (t, i) => {
136
+ const n = i ? t.rgbaValue : t.value;
137
+ D || te(n), S && S.call(void 0, {
138
+ value: n,
123
139
  nativeEvent: t.nativeEvent,
124
140
  syntheticEvent: t.syntheticEvent
125
141
  });
126
142
  },
127
- [N, T]
128
- ), le = e.useCallback(
129
- (t) => R(t, !0),
130
- [L, R]
131
- ), F = de(a, o.dir), ie = U !== !1;
143
+ [D, S]
144
+ ), pe = e.useCallback(
145
+ (t) => N(t, !0),
146
+ [F, N]
147
+ ), O = Ee(r, a.dir), de = q !== !1;
132
148
  return /* @__PURE__ */ e.createElement(
133
149
  "span",
134
150
  {
135
- id: o.id,
151
+ id: a.id,
136
152
  role: "combobox",
137
- "aria-label": o.ariaLabel,
138
- "aria-labelledby": o.ariaLabelledBy,
139
- "aria-describedby": o.ariaDescribedBy,
153
+ "aria-label": a.ariaLabel,
154
+ "aria-labelledby": a.ariaLabelledBy,
155
+ "aria-describedby": a.ariaDescribedBy,
140
156
  "aria-haspopup": "dialog",
141
- "aria-expanded": u,
142
- "aria-disabled": E ? "true" : void 0,
143
- className: h(
157
+ "aria-expanded": k,
158
+ "aria-disabled": w ? "true" : void 0,
159
+ className: A(
144
160
  "k-colorpicker",
145
161
  "k-picker",
146
162
  "k-icon-picker",
147
163
  {
148
- [`k-picker-${H.sizeMap[b] || b}`]: b,
149
- [`k-picker-${A}`]: A,
150
- [`k-rounded-${H.roundedMap[g] || g}`]: g,
151
- "k-invalid": !ie,
152
- "k-disabled": E,
153
- "k-focus": j,
154
- className: W
164
+ [`k-picker-${_.sizeMap[E] || E}`]: E,
165
+ [`k-picker-${L}`]: L,
166
+ [`k-rounded-${_.roundedMap[C] || C}`]: C,
167
+ "k-invalid": !de,
168
+ "k-disabled": w,
169
+ "k-focus": Y,
170
+ className: Q
155
171
  }
156
172
  ),
157
- ref: a,
158
- tabIndex: pe($, E),
159
- title: o.title,
160
- onKeyDown: Y,
161
- onFocus: oe,
162
- onBlur: re,
163
- dir: F
173
+ ref: r,
174
+ tabIndex: Ce(J, w),
175
+ title: a.title,
176
+ onKeyDown: ae,
177
+ onFocus: se,
178
+ onBlur: ue,
179
+ dir: O
164
180
  },
165
181
  /* @__PURE__ */ e.createElement(
166
- ve,
182
+ Se,
167
183
  {
168
- dir: F,
169
- open: u,
170
- onOpen: ee,
171
- popupAnchor: a.current || void 0,
172
- popupSettings: { ...G },
173
- input: /* @__PURE__ */ e.createElement("span", { onClick: ne, className: "k-input-inner" }, /* @__PURE__ */ e.createElement(
184
+ dir: O,
185
+ open: k,
186
+ onOpen: re,
187
+ popupAnchor: r.current || void 0,
188
+ popupSettings: { ...j },
189
+ input: /* @__PURE__ */ e.createElement("span", { onClick: ie, className: "k-input-inner" }, /* @__PURE__ */ e.createElement(
174
190
  "span",
175
191
  {
176
- className: h(
192
+ className: A(
177
193
  "k-value-icon",
178
194
  "k-color-preview",
179
195
  {
180
196
  "k-no-color": !l,
181
- "k-icon-color-preview": C || y || k
197
+ "k-icon-color-preview": y || T || m
182
198
  }
183
199
  )
184
200
  },
185
- k && /* @__PURE__ */ e.createElement("span", { className: h("k-color-preview-icon", k) }),
186
- !k && (C || y) && /* @__PURE__ */ e.createElement(fe, { name: C, icon: y }),
201
+ m && /* @__PURE__ */ e.createElement("span", { className: A("k-color-preview-icon", m) }),
202
+ !m && (y || T) && /* @__PURE__ */ e.createElement(we, { name: y, icon: T }),
187
203
  /* @__PURE__ */ e.createElement("span", { className: "k-color-preview-mask", style: { backgroundColor: l } })
188
204
  )),
189
205
  button: /* @__PURE__ */ e.createElement(
190
- ye,
206
+ Ne,
191
207
  {
192
208
  tabIndex: -1,
193
209
  type: "button",
194
- onClick: te,
210
+ onClick: le,
195
211
  className: "k-input-button",
196
212
  rounded: null,
197
213
  icon: "caret-alt-down",
198
- svgIcon: Te,
199
- "aria-label": V.toLanguageString(O, Se[O])
214
+ svgIcon: he,
215
+ "aria-label": $.toLanguageString(K, Ae[K])
200
216
  }
201
217
  ),
202
- content: /* @__PURE__ */ e.createElement(e.Fragment, null, (m === "combo" || m === "gradient") && /* @__PURE__ */ e.createElement(
203
- be,
218
+ content: /* @__PURE__ */ e.createElement(e.Fragment, null, (s === "combo" || s === "gradient") && /* @__PURE__ */ e.createElement(
219
+ Pe,
204
220
  {
205
- ..._,
206
- tabIndex: 0,
207
- ref: P,
221
+ ...W,
222
+ ref: f,
223
+ isInsidePopup: !0,
208
224
  value: l,
209
- onChange: R
225
+ onChange: N
210
226
  }
211
- ), (m === "combo" || m === "palette") && /* @__PURE__ */ e.createElement(
212
- ge,
227
+ ), (s === "combo" || s === "palette") && /* @__PURE__ */ e.createElement(
228
+ Ie,
213
229
  {
214
- ...K,
215
- ref: D,
230
+ ...Z,
231
+ ref: v,
216
232
  value: l,
217
- onChange: le
233
+ onChange: pe
218
234
  }
219
235
  ))
220
236
  }
221
237
  )
222
238
  );
223
239
  });
224
- z.propTypes = {
225
- value: n.string,
226
- defaultValue: n.string,
227
- disabled: n.bool,
228
- view: n.oneOf(["gradient", "palette", "combo"]),
229
- dir: n.string,
230
- id: n.string,
231
- icon: n.string,
232
- svgIcon: me,
233
- ariaLabelledBy: n.string,
234
- ariaDescribedBy: n.string,
235
- size: n.oneOf([null, "small", "medium", "large"]),
236
- rounded: n.oneOf([null, "small", "medium", "large", "full"]),
237
- fillMode: n.oneOf([null, "solid", "flat", "outline"]),
238
- className: n.string
240
+ U.propTypes = {
241
+ value: o.string,
242
+ defaultValue: o.string,
243
+ disabled: o.bool,
244
+ view: o.oneOf(["gradient", "palette", "combo"]),
245
+ dir: o.string,
246
+ id: o.string,
247
+ icon: o.string,
248
+ svgIcon: ye,
249
+ ariaLabelledBy: o.string,
250
+ ariaDescribedBy: o.string,
251
+ size: o.oneOf([null, "small", "medium", "large"]),
252
+ rounded: o.oneOf([null, "small", "medium", "large", "full"]),
253
+ fillMode: o.oneOf([null, "solid", "flat", "outline"]),
254
+ className: o.string
239
255
  };
240
- const f = {
256
+ const d = {
241
257
  size: "medium",
242
258
  rounded: "medium",
243
259
  fillMode: "solid",
244
260
  view: "palette",
245
- gradientSettings: Ie,
246
- paletteSettings: Pe
261
+ gradientSettings: Le,
262
+ paletteSettings: xe
247
263
  };
248
- z.displayName = "KendoColorPicker";
264
+ U.displayName = "KendoColorPicker";
249
265
  export {
250
- z as ColorPicker,
251
- De as ColorPickerPropsContext
266
+ U as ColorPicker,
267
+ Be as ColorPickerPropsContext
252
268
  };