@progress/kendo-react-inputs 13.4.0-develop.5 → 14.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colors/ColorPalette.d.ts +20 -81
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +207 -181
- package/colors/interfaces/ColorPaletteChangeEvent.d.ts +2 -2
- package/colors/interfaces/ColorPaletteHandle.d.ts +46 -0
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +2 -1
- package/index.d.ts +2 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +10 -10
package/colors/ColorPalette.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { default as PropTypes } from 'prop-types';
|
|
9
8
|
import { ColorPaletteProps } from './interfaces/ColorPaletteProps.js';
|
|
9
|
+
import { ColorPaletteHandle } from './interfaces/ColorPaletteHandle.js';
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
/**
|
|
12
12
|
* @hidden
|
|
@@ -21,85 +21,25 @@ export declare const DEFAULT_COLUMNS_COUNT = 10;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const DEFAULT_PRESET = "office";
|
|
23
23
|
/**
|
|
24
|
+
* The default props of the ColorPalette component.
|
|
25
|
+
*
|
|
24
26
|
* @hidden
|
|
25
27
|
*/
|
|
28
|
+
export declare const defaultColorPaletteProps: {
|
|
29
|
+
palette: string;
|
|
30
|
+
columns: number;
|
|
31
|
+
tileSize: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*
|
|
36
|
+
* @deprecated This interface is no longer used in the functional implementation but maintained for backward compatibility
|
|
37
|
+
*/
|
|
26
38
|
export interface ColorPaletteState {
|
|
27
39
|
selectedColor?: string;
|
|
28
40
|
focusedColor?: string;
|
|
29
41
|
isFirstRender: boolean;
|
|
30
42
|
}
|
|
31
|
-
/** @hidden */
|
|
32
|
-
export declare class ColorPaletteWithoutContext extends React.Component<ColorPaletteProps, ColorPaletteState> {
|
|
33
|
-
static displayName: string;
|
|
34
|
-
/**
|
|
35
|
-
* @hidden
|
|
36
|
-
*/
|
|
37
|
-
static propTypes: {
|
|
38
|
-
palette: PropTypes.Requireable<NonNullable<string | string[] | null | undefined>>;
|
|
39
|
-
columns: PropTypes.Requireable<number>;
|
|
40
|
-
tileSize: PropTypes.Requireable<any>;
|
|
41
|
-
defaultValue: PropTypes.Requireable<string>;
|
|
42
|
-
value: PropTypes.Requireable<string>;
|
|
43
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
44
|
-
tabIndex: PropTypes.Requireable<number>;
|
|
45
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
46
|
-
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
47
|
-
id: PropTypes.Requireable<string>;
|
|
48
|
-
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
49
|
-
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
50
|
-
className: PropTypes.Requireable<string>;
|
|
51
|
-
size: PropTypes.Requireable<string | null>;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* @hidden
|
|
55
|
-
*/
|
|
56
|
-
static defaultProps: {
|
|
57
|
-
palette: string;
|
|
58
|
-
tileSize: number;
|
|
59
|
-
size: undefined;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* @hidden
|
|
63
|
-
*/
|
|
64
|
-
wrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
65
|
-
private paletteService;
|
|
66
|
-
private get guid();
|
|
67
|
-
constructor(props: ColorPaletteProps);
|
|
68
|
-
/**
|
|
69
|
-
* @hidden
|
|
70
|
-
*/
|
|
71
|
-
focus: () => void;
|
|
72
|
-
/**
|
|
73
|
-
* @hidden
|
|
74
|
-
*/
|
|
75
|
-
render(): "" | React.JSX.Element;
|
|
76
|
-
/**
|
|
77
|
-
* @hidden
|
|
78
|
-
*/
|
|
79
|
-
static getDerivedStateFromProps(props: ColorPaletteProps, state: ColorPaletteState): {
|
|
80
|
-
selectedColor: undefined;
|
|
81
|
-
isFirstRender?: undefined;
|
|
82
|
-
} | {
|
|
83
|
-
selectedColor: string;
|
|
84
|
-
isFirstRender?: undefined;
|
|
85
|
-
} | {
|
|
86
|
-
isFirstRender: boolean;
|
|
87
|
-
selectedColor?: undefined;
|
|
88
|
-
} | null;
|
|
89
|
-
private onKeyDown;
|
|
90
|
-
private onColorClick;
|
|
91
|
-
private onFocus;
|
|
92
|
-
private onBlur;
|
|
93
|
-
private handleCellNavigation;
|
|
94
|
-
private handleEnter;
|
|
95
|
-
private dispatchChangeEvent;
|
|
96
|
-
private get focusedColorCooridanates();
|
|
97
|
-
private get isUncontrolled();
|
|
98
|
-
private getPaletteInfo;
|
|
99
|
-
private renderRows;
|
|
100
|
-
private renderColumns;
|
|
101
|
-
private createCellId;
|
|
102
|
-
}
|
|
103
43
|
/**
|
|
104
44
|
* Represents the PropsContext of the `ColorPalette` component.
|
|
105
45
|
* Used for global configuration of all `ColorPalette` instances.
|
|
@@ -108,14 +48,7 @@ export declare class ColorPaletteWithoutContext extends React.Component<ColorPal
|
|
|
108
48
|
*/
|
|
109
49
|
export declare const ColorPalettePropsContext: React.Context<(p: ColorPaletteProps) => ColorPaletteProps>;
|
|
110
50
|
/**
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
export interface ColorPaletteHandle extends Pick<ColorPaletteWithoutContext, keyof ColorPaletteWithoutContext> {
|
|
114
|
-
}
|
|
115
|
-
/** @hidden */
|
|
116
|
-
export type ColorPalette = ColorPaletteHandle;
|
|
117
|
-
/**
|
|
118
|
-
* Represents the [KendoReact ColorPalette component](https://www.telerik.com/kendo-react-ui/components/inputs/colorpalette).
|
|
51
|
+
* Represents the [KendoReact ColorPalette component](https://www.telerik.com/kendo-react-ui/components/inputs/colorpalette) (Functional Implementation).
|
|
119
52
|
*
|
|
120
53
|
* Accepts properties of type [ColorPaletteProps](https://www.telerik.com/kendo-react-ui/components/inputs/api/colorpaletteprops).
|
|
121
54
|
* Obtaining the `ref` returns an object of type [ColorPaletteHandle](https://www.telerik.com/kendo-react-ui/components/inputs/api/colorpalettehandle).
|
|
@@ -127,3 +60,9 @@ export type ColorPalette = ColorPaletteHandle;
|
|
|
127
60
|
* ```
|
|
128
61
|
*/
|
|
129
62
|
export declare const ColorPalette: React.ForwardRefExoticComponent<ColorPaletteProps & React.RefAttributes<any>>;
|
|
63
|
+
/**
|
|
64
|
+
* ColorPalette component without context (for backward compatibility).
|
|
65
|
+
*
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
export declare const ColorPaletteWithoutContext: React.ForwardRefExoticComponent<ColorPaletteProps & React.RefAttributes<ColorPaletteHandle>>;
|
package/colors/ColorPalette.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),l=require("prop-types"),re=require("./utils/color-palette.service.js"),w=require("@progress/kendo-react-common"),se=require("./models/palette-presets.js"),q=require("./utils/color-parser.js");function le(c){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const h in c)if(h!=="default"){const E=Object.getOwnPropertyDescriptor(c,h);Object.defineProperty(p,h,E.get?E:{enumerable:!0,get:()=>c[h]})}}return p.default=c,Object.freeze(p)}const k=le(n),z=24,B=10,j="office",D={palette:j,columns:B,tileSize:z},V=w.createPropsContext(),ne=c=>{if(Array.isArray(c))return c;if(typeof c=="string"){const p=se.PALETTEPRESETS[c];if(p)return p.colors}return[]},F=k.forwardRef((c,p)=>{const h=w.usePropsContext(V,c),{palette:E=D.palette,columns:L=D.columns,tileSize:u=D.tileSize,value:x,defaultValue:$,disabled:d=!1,tabIndex:K,onChange:P,onFocus:I,className:W,size:N,id:Z,ariaLabelledBy:G,ariaDescribedBy:J}=h,S=n.useRef(null),Q=n.useRef({focus:()=>{var o;(o=S.current)==null||o.focus()},wrapperRef:S}),_=L!=null?L:D.columns,b=n.useMemo(()=>ne(E),[E]),t=n.useMemo(()=>{const o=new re.ColorPaletteService;return o.setColorMatrix(b,_),o},[b,_]),[g,O]=n.useState(()=>x!==void 0?x:$||""),[T,R]=n.useState(""),y=x!==void 0;n.useEffect(()=>{y&&O(x)},[x,y]);const X=n.useCallback(o=>{if(d||b.length===0)return;const f=g||b[0];R(f),I&&I(o)},[d,b,g,I]),Y=n.useCallback(()=>{R("")},[]),ee=n.useCallback(o=>{if(d)return;const{key:f}=o,r=()=>T||g||b[0],m=(s,e)=>s<0?e:s>e?0:s;switch(f){case"ArrowRight":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e&&t.colorRows[e.row]){const C=t.colorRows[e.row].length-1,a=m(e.col+1,C),i=t.colorRows[e.row][a];i&&R(i)}}break;case"ArrowLeft":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e&&t.colorRows[e.row]){const C=t.colorRows[e.row].length-1,a=m(e.col-1,C),i=t.colorRows[e.row][a];i&&R(i)}}break;case"ArrowDown":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e){const C=t.colorRows.length-1,a=m(e.row+1,C),i=Math.min(e.col,t.colorRows[a].length-1),v=t.colorRows[a][i];v&&R(v)}}break;case"ArrowUp":o.preventDefault();{const s=r(),e=t.getCellCoordsFor(s);if(e){const C=t.colorRows.length-1,a=m(e.row-1,C),i=Math.min(e.col,t.colorRows[a].length-1),v=t.colorRows[a][i];v&&R(v)}}break;case"Enter":o.preventDefault();{const s=r();if(s&&(y||O(s),P)){const e=q.parseColor(s,"rgba");w.dispatchEvent(P,o,null,{value:s,rgbaValue:e||""})}}break}},[d,T,g,b,t,y,P]),A=n.useCallback((o,f)=>{if(d)return;const r=o;if(y||O(r),P){const m=q.parseColor(r,"rgba");w.dispatchEvent(P,f,null,{value:r,rgbaValue:m||""})}},[d,P,y]),U=n.useCallback((o,f)=>o.map((r,m)=>{const s=g&&r.toLowerCase()===g.toLowerCase(),e=T&&r.toLowerCase()===T.toLowerCase(),C=w.classNames("k-colorpalette-tile",{"k-selected":s,"k-focus":e}),a={backgroundColor:r};return typeof u=="number"?(a.width=`${u}px`,a.height=`${u}px`):u&&typeof u=="object"&&("width"in u&&(a.width=`${u.width}px`),"height"in u&&(a.height=`${u.height}px`)),k.createElement("td",{key:r,role:"gridcell",className:C,style:a,"aria-label":r,"aria-selected":s?"true":"false",onClick:i=>A(r,i)})}),[g,T,u,A]),oe=n.useCallback(()=>t.colorRows.map((f,r)=>k.createElement("tr",{key:f[0]||r,role:"row"},U(f,r))),[t,U]),M=n.useCallback(()=>({focus:()=>{var o;(o=S.current)==null||o.focus()},wrapperRef:S}),[]);n.useImperativeHandle(Q,M),n.useImperativeHandle(p,M);const te=w.classNames("k-colorpalette",W,{"k-disabled":d,"k-colorpalette-sm":N==="small","k-colorpalette-md":N==="medium","k-colorpalette-lg":N==="large"});return k.createElement("div",{ref:S,role:"grid",className:te,tabIndex:w.getTabIndex(K,d),id:Z,"aria-labelledby":G,"aria-describedby":J,"aria-disabled":d?"true":void 0,onFocus:X,onBlur:Y,onKeyDown:ee},k.createElement("table",{className:"k-colorpalette-table",role:"presentation"},k.createElement("tbody",null,oe())))});F.displayName="ColorPalette";F.propTypes={palette:l.oneOfType([l.arrayOf(l.string.isRequired),l.string]),columns:l.number,tileSize:l.any,defaultValue:l.string,value:l.string,disabled:l.bool,tabIndex:l.number,onChange:l.func,onFocus:l.func,id:l.string,ariaLabelledBy:l.string,ariaDescribedBy:l.string,className:l.string,size:l.oneOf(["small","medium","large"])};const H=w.withIdHOC(F);H.displayName="KendoReactColorPalette";const ae=F;exports.ColorPalette=H;exports.ColorPalettePropsContext=V;exports.ColorPaletteWithoutContext=ae;exports.DEFAULT_COLUMNS_COUNT=B;exports.DEFAULT_PRESET=j;exports.DEFAULT_TILE_SIZE=z;exports.defaultColorPaletteProps=D;
|
package/colors/ColorPalette.mjs
CHANGED
|
@@ -5,200 +5,226 @@
|
|
|
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
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { parseColor as
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
import * as R from "react";
|
|
9
|
+
import { useRef as z, useMemo as O, useState as U, useEffect as re, useCallback as p, useImperativeHandle as V } from "react";
|
|
10
|
+
import l from "prop-types";
|
|
11
|
+
import { ColorPaletteService as se } from "./utils/color-palette.service.mjs";
|
|
12
|
+
import { withIdHOC as le, createPropsContext as ne, usePropsContext as ae, dispatchEvent as M, classNames as H, getTabIndex as ce } from "@progress/kendo-react-common";
|
|
13
|
+
import { PALETTEPRESETS as ie } from "./models/palette-presets.mjs";
|
|
14
|
+
import { parseColor as $ } from "./utils/color-parser.mjs";
|
|
15
|
+
const ue = 24, de = 10, fe = "office", F = {
|
|
16
|
+
palette: fe,
|
|
17
|
+
columns: de,
|
|
18
|
+
tileSize: ue
|
|
19
|
+
}, Ce = ne(), we = (m) => {
|
|
20
|
+
if (Array.isArray(m))
|
|
21
|
+
return m;
|
|
22
|
+
if (typeof m == "string") {
|
|
23
|
+
const P = ie[m];
|
|
24
|
+
if (P)
|
|
25
|
+
return P.colors;
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}, v = R.forwardRef((m, P) => {
|
|
29
|
+
const K = ae(Ce, m), {
|
|
30
|
+
palette: I = F.palette,
|
|
31
|
+
columns: S = F.columns,
|
|
32
|
+
tileSize: c = F.tileSize,
|
|
33
|
+
value: y,
|
|
34
|
+
defaultValue: j,
|
|
35
|
+
disabled: i = !1,
|
|
36
|
+
tabIndex: q,
|
|
37
|
+
onChange: g,
|
|
38
|
+
onFocus: D,
|
|
39
|
+
className: W,
|
|
40
|
+
size: L,
|
|
41
|
+
id: Z,
|
|
42
|
+
ariaLabelledBy: G,
|
|
43
|
+
ariaDescribedBy: J
|
|
44
|
+
} = K, k = z(null), Q = z({
|
|
45
|
+
focus: () => {
|
|
46
|
+
var o;
|
|
47
|
+
(o = k.current) == null || o.focus();
|
|
48
|
+
},
|
|
49
|
+
wrapperRef: k
|
|
50
|
+
}), A = S != null ? S : F.columns, f = O(() => we(I), [I]), t = O(() => {
|
|
51
|
+
const o = new se();
|
|
52
|
+
return o.setColorMatrix(f, A), o;
|
|
53
|
+
}, [f, A]), [C, T] = U(() => y !== void 0 ? y : j || ""), [x, b] = U(""), h = y !== void 0;
|
|
54
|
+
re(() => {
|
|
55
|
+
h && T(y);
|
|
56
|
+
}, [y, h]);
|
|
57
|
+
const X = p(
|
|
58
|
+
(o) => {
|
|
59
|
+
if (i || f.length === 0)
|
|
60
|
+
return;
|
|
61
|
+
const u = C || f[0];
|
|
62
|
+
b(u), D && D(o);
|
|
63
|
+
},
|
|
64
|
+
[i, f, C, D]
|
|
65
|
+
), Y = p(() => {
|
|
66
|
+
b("");
|
|
67
|
+
}, []), ee = p(
|
|
68
|
+
(o) => {
|
|
69
|
+
if (i)
|
|
70
|
+
return;
|
|
71
|
+
const { key: u } = o, r = () => x || C || f[0], w = (s, e) => s < 0 ? e : s > e ? 0 : s;
|
|
72
|
+
switch (u) {
|
|
73
|
+
case "ArrowRight":
|
|
74
|
+
o.preventDefault();
|
|
75
|
+
{
|
|
76
|
+
const s = r(), e = t.getCellCoordsFor(s);
|
|
77
|
+
if (e && t.colorRows[e.row]) {
|
|
78
|
+
const d = t.colorRows[e.row].length - 1, n = w(e.col + 1, d), a = t.colorRows[e.row][n];
|
|
79
|
+
a && b(a);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
23
82
|
break;
|
|
24
|
-
case
|
|
25
|
-
|
|
83
|
+
case "ArrowLeft":
|
|
84
|
+
o.preventDefault();
|
|
85
|
+
{
|
|
86
|
+
const s = r(), e = t.getCellCoordsFor(s);
|
|
87
|
+
if (e && t.colorRows[e.row]) {
|
|
88
|
+
const d = t.colorRows[e.row].length - 1, n = w(e.col - 1, d), a = t.colorRows[e.row][n];
|
|
89
|
+
a && b(a);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
26
92
|
break;
|
|
27
|
-
case
|
|
28
|
-
|
|
93
|
+
case "ArrowDown":
|
|
94
|
+
o.preventDefault();
|
|
95
|
+
{
|
|
96
|
+
const s = r(), e = t.getCellCoordsFor(s);
|
|
97
|
+
if (e) {
|
|
98
|
+
const d = t.colorRows.length - 1, n = w(e.row + 1, d), a = Math.min(e.col, t.colorRows[n].length - 1), E = t.colorRows[n][a];
|
|
99
|
+
E && b(E);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
29
102
|
break;
|
|
30
|
-
case
|
|
31
|
-
|
|
103
|
+
case "ArrowUp":
|
|
104
|
+
o.preventDefault();
|
|
105
|
+
{
|
|
106
|
+
const s = r(), e = t.getCellCoordsFor(s);
|
|
107
|
+
if (e) {
|
|
108
|
+
const d = t.colorRows.length - 1, n = w(e.row - 1, d), a = Math.min(e.col, t.colorRows[n].length - 1), E = t.colorRows[n][a];
|
|
109
|
+
E && b(E);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
32
112
|
break;
|
|
33
|
-
case
|
|
34
|
-
|
|
113
|
+
case "Enter":
|
|
114
|
+
o.preventDefault();
|
|
115
|
+
{
|
|
116
|
+
const s = r();
|
|
117
|
+
if (s && (h || T(s), g)) {
|
|
118
|
+
const e = $(s, "rgba");
|
|
119
|
+
M(g, o, null, {
|
|
120
|
+
value: s,
|
|
121
|
+
rgbaValue: e || ""
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
35
125
|
break;
|
|
36
|
-
default:
|
|
37
|
-
return;
|
|
38
126
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"div",
|
|
63
|
-
{
|
|
64
|
-
id: this.props.id,
|
|
65
|
-
role: "grid",
|
|
66
|
-
className: f(
|
|
67
|
-
"k-colorpalette",
|
|
68
|
-
{
|
|
69
|
-
[`k-colorpalette-${F.sizeMap[this.props.size] || this.props.size}`]: this.props.size,
|
|
70
|
-
"k-disabled": this.props.disabled
|
|
71
|
-
},
|
|
72
|
-
this.props.className
|
|
73
|
-
),
|
|
74
|
-
onFocus: this.onFocus,
|
|
75
|
-
onBlur: this.onBlur,
|
|
76
|
-
onKeyDown: this.onKeyDown,
|
|
77
|
-
"aria-disabled": this.props.ariaDisabled || (this.props.disabled ? "true" : void 0),
|
|
78
|
-
"aria-labelledby": this.props.ariaLabelledBy,
|
|
79
|
-
"aria-describedby": this.props.ariaDescribedBy,
|
|
80
|
-
tabIndex: R(this.props.tabIndex, this.props.disabled),
|
|
81
|
-
ref: this.wrapperRef
|
|
82
|
-
},
|
|
83
|
-
/* @__PURE__ */ i.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ i.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
|
|
84
|
-
) : "";
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* @hidden
|
|
88
|
-
*/
|
|
89
|
-
static getDerivedStateFromProps(t, e) {
|
|
90
|
-
if (!e.isFirstRender && t.value !== void 0) {
|
|
91
|
-
if (t.value === "" && e.selectedColor !== void 0)
|
|
92
|
-
return { selectedColor: void 0 };
|
|
93
|
-
if (t.value !== "" && t.value !== e.selectedColor)
|
|
94
|
-
return { selectedColor: t.value };
|
|
95
|
-
} else if (e.isFirstRender)
|
|
96
|
-
return { isFirstRender: !1 };
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
handleCellNavigation(t, e) {
|
|
100
|
-
if (this.paletteService)
|
|
101
|
-
if (this.focusedColorCooridanates) {
|
|
102
|
-
const o = this.paletteService.getNextCell(
|
|
103
|
-
this.focusedColorCooridanates,
|
|
104
|
-
t,
|
|
105
|
-
e
|
|
106
|
-
);
|
|
107
|
-
this.setState({ focusedColor: this.paletteService.getColorAt(o) });
|
|
108
|
-
} else
|
|
109
|
-
this.setState({ focusedColor: this.paletteService.colorRows[0][0] });
|
|
110
|
-
}
|
|
111
|
-
handleEnter(t) {
|
|
112
|
-
this.isUncontrolled && this.setState({ selectedColor: this.state.focusedColor }), this.dispatchChangeEvent(this.state.focusedColor, t);
|
|
113
|
-
}
|
|
114
|
-
dispatchChangeEvent(t, e) {
|
|
115
|
-
N(this.props.onChange, e, this, { value: t, rgbaValue: P(t, "rgba") });
|
|
116
|
-
}
|
|
117
|
-
get focusedColorCooridanates() {
|
|
118
|
-
return this.state.focusedColor && this.paletteService ? this.paletteService.getCellCoordsFor(this.state.focusedColor) : void 0;
|
|
119
|
-
}
|
|
120
|
-
get isUncontrolled() {
|
|
121
|
-
return this.props.value === void 0;
|
|
122
|
-
}
|
|
123
|
-
getPaletteInfo() {
|
|
124
|
-
if (typeof this.props.palette == "string") {
|
|
125
|
-
const t = z[this.props.palette];
|
|
126
|
-
return T(t) ? {
|
|
127
|
-
colors: t.colors,
|
|
128
|
-
columns: this.props.columns || t.columns || C
|
|
129
|
-
} : { colors: [], columns: 0 };
|
|
130
|
-
}
|
|
131
|
-
return { colors: this.props.palette || [], columns: this.props.columns || C };
|
|
132
|
-
}
|
|
133
|
-
renderRows(t, e, o) {
|
|
134
|
-
return t.map((r, n) => /* @__PURE__ */ i.createElement("tr", { role: "row", key: n }, this.renderColumns(r, n, e, o)));
|
|
135
|
-
}
|
|
136
|
-
renderColumns(t, e, o, r) {
|
|
137
|
-
const n = o !== void 0 && o.row === e, m = o && o.col, g = r !== void 0 && r.row === e, v = r && r.col;
|
|
138
|
-
return t.map((p, c) => {
|
|
139
|
-
const h = n && m === c, b = f("k-colorpalette-tile", {
|
|
140
|
-
"k-selected": h,
|
|
141
|
-
"k-focus": g && v === c
|
|
142
|
-
});
|
|
143
|
-
let u = {
|
|
144
|
-
width: this.props.tileSize,
|
|
145
|
-
height: this.props.tileSize
|
|
127
|
+
},
|
|
128
|
+
[i, x, C, f, t, h, g]
|
|
129
|
+
), N = p(
|
|
130
|
+
(o, u) => {
|
|
131
|
+
if (i)
|
|
132
|
+
return;
|
|
133
|
+
const r = o;
|
|
134
|
+
if (h || T(r), g) {
|
|
135
|
+
const w = $(r, "rgba");
|
|
136
|
+
M(g, u, null, {
|
|
137
|
+
value: r,
|
|
138
|
+
rgbaValue: w || ""
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
[i, g, h]
|
|
143
|
+
), B = p(
|
|
144
|
+
(o, u) => o.map((r, w) => {
|
|
145
|
+
const s = C && r.toLowerCase() === C.toLowerCase(), e = x && r.toLowerCase() === x.toLowerCase(), d = H("k-colorpalette-tile", {
|
|
146
|
+
"k-selected": s,
|
|
147
|
+
"k-focus": e
|
|
148
|
+
}), n = {
|
|
149
|
+
backgroundColor: r
|
|
146
150
|
};
|
|
147
|
-
return typeof
|
|
148
|
-
width: this.props.tileSize.width,
|
|
149
|
-
height: this.props.tileSize.height
|
|
150
|
-
}), /* @__PURE__ */ i.createElement(
|
|
151
|
+
return typeof c == "number" ? (n.width = `${c}px`, n.height = `${c}px`) : c && typeof c == "object" && ("width" in c && (n.width = `${c.width}px`), "height" in c && (n.height = `${c.height}px`)), /* @__PURE__ */ R.createElement(
|
|
151
152
|
"td",
|
|
152
153
|
{
|
|
154
|
+
key: r,
|
|
153
155
|
role: "gridcell",
|
|
154
|
-
className:
|
|
155
|
-
|
|
156
|
-
"aria-
|
|
157
|
-
|
|
158
|
-
onClick: (
|
|
159
|
-
id: this.createCellId({ row: e, col: c }),
|
|
160
|
-
key: c
|
|
156
|
+
className: d,
|
|
157
|
+
style: n,
|
|
158
|
+
"aria-label": r,
|
|
159
|
+
"aria-selected": s ? "true" : "false",
|
|
160
|
+
onClick: (a) => N(r, a)
|
|
161
161
|
}
|
|
162
162
|
);
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
163
|
+
}),
|
|
164
|
+
[C, x, c, N]
|
|
165
|
+
), oe = p(() => t.colorRows.map((u, r) => /* @__PURE__ */ R.createElement("tr", { key: u[0] || r, role: "row" }, B(u, r))), [t, B]), _ = p(
|
|
166
|
+
() => ({
|
|
167
|
+
focus: () => {
|
|
168
|
+
var o;
|
|
169
|
+
(o = k.current) == null || o.focus();
|
|
170
|
+
},
|
|
171
|
+
wrapperRef: k
|
|
172
|
+
}),
|
|
173
|
+
[]
|
|
174
|
+
);
|
|
175
|
+
V(Q, _), V(P, _);
|
|
176
|
+
const te = H("k-colorpalette", W, {
|
|
177
|
+
"k-disabled": i,
|
|
178
|
+
"k-colorpalette-sm": L === "small",
|
|
179
|
+
"k-colorpalette-md": L === "medium",
|
|
180
|
+
"k-colorpalette-lg": L === "large"
|
|
181
|
+
});
|
|
182
|
+
return /* @__PURE__ */ R.createElement(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
ref: k,
|
|
186
|
+
role: "grid",
|
|
187
|
+
className: te,
|
|
188
|
+
tabIndex: ce(q, i),
|
|
189
|
+
id: Z,
|
|
190
|
+
"aria-labelledby": G,
|
|
191
|
+
"aria-describedby": J,
|
|
192
|
+
"aria-disabled": i ? "true" : void 0,
|
|
193
|
+
onFocus: X,
|
|
194
|
+
onBlur: Y,
|
|
195
|
+
onKeyDown: ee
|
|
196
|
+
},
|
|
197
|
+
/* @__PURE__ */ R.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ R.createElement("tbody", null, oe()))
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
v.displayName = "ColorPalette";
|
|
201
|
+
v.propTypes = {
|
|
202
|
+
palette: l.oneOfType([l.arrayOf(l.string.isRequired), l.string]),
|
|
203
|
+
columns: l.number,
|
|
204
|
+
tileSize: l.any,
|
|
205
|
+
defaultValue: l.string,
|
|
206
|
+
value: l.string,
|
|
207
|
+
disabled: l.bool,
|
|
208
|
+
tabIndex: l.number,
|
|
209
|
+
onChange: l.func,
|
|
210
|
+
onFocus: l.func,
|
|
211
|
+
id: l.string,
|
|
212
|
+
ariaLabelledBy: l.string,
|
|
213
|
+
ariaDescribedBy: l.string,
|
|
214
|
+
className: l.string,
|
|
215
|
+
size: l.oneOf(["small", "medium", "large"])
|
|
188
216
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
k(
|
|
192
|
-
L,
|
|
193
|
-
d
|
|
194
|
-
)
|
|
217
|
+
const pe = le(
|
|
218
|
+
v
|
|
195
219
|
);
|
|
196
|
-
|
|
220
|
+
pe.displayName = "KendoReactColorPalette";
|
|
221
|
+
const ke = v;
|
|
197
222
|
export {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
pe as ColorPalette,
|
|
224
|
+
Ce as ColorPalettePropsContext,
|
|
225
|
+
ke as ColorPaletteWithoutContext,
|
|
226
|
+
de as DEFAULT_COLUMNS_COUNT,
|
|
227
|
+
fe as DEFAULT_PRESET,
|
|
228
|
+
ue as DEFAULT_TILE_SIZE,
|
|
229
|
+
F as defaultColorPaletteProps
|
|
204
230
|
};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { BaseEvent } from '@progress/kendo-react-common';
|
|
9
|
-
import {
|
|
9
|
+
import { ColorPaletteHandle } from './ColorPaletteHandle.js';
|
|
10
10
|
/**
|
|
11
11
|
* The arguments for the `onChange` ColorPalette event.
|
|
12
12
|
*/
|
|
13
|
-
export interface ColorPaletteChangeEvent extends BaseEvent<
|
|
13
|
+
export interface ColorPaletteChangeEvent extends BaseEvent<ColorPaletteHandle> {
|
|
14
14
|
/**
|
|
15
15
|
* The current value of the ColorPalette.
|
|
16
16
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* Represents the imperative handle exposed by the ColorPalette component through ref.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const paletteRef = useRef<ColorPaletteHandle>(null);
|
|
15
|
+
*
|
|
16
|
+
* // Focus the palette programmatically
|
|
17
|
+
* paletteRef.current?.focus();
|
|
18
|
+
*
|
|
19
|
+
* // Access the wrapper element
|
|
20
|
+
* const width = paletteRef.current?.wrapperRef.current?.offsetWidth;
|
|
21
|
+
*
|
|
22
|
+
* <ColorPalette ref={paletteRef} palette="basic" />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface ColorPaletteHandle {
|
|
26
|
+
/**
|
|
27
|
+
* Programmatically focuses the ColorPalette component.
|
|
28
|
+
*
|
|
29
|
+
* When called:
|
|
30
|
+
* - The root div element receives DOM focus
|
|
31
|
+
* - The first color tile (or previously selected tile) is focused for keyboard navigation
|
|
32
|
+
* - The component's `onFocus` callback is triggered
|
|
33
|
+
*/
|
|
34
|
+
focus: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* A React ref to the root wrapper element of the ColorPalette.
|
|
37
|
+
*
|
|
38
|
+
* This ref can be used to access the underlying DOM element for scenarios such as:
|
|
39
|
+
* - Measuring the component dimensions
|
|
40
|
+
* - Integrating with non-React libraries
|
|
41
|
+
* - Programmatic scrolling or focus management
|
|
42
|
+
*
|
|
43
|
+
* The ref is populated after the component mounts and will be `null` before that.
|
|
44
|
+
*/
|
|
45
|
+
wrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
46
|
+
}
|