@progress/kendo-react-inputs 10.3.0-develop.1 → 11.0.0-develop.10
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/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +125 -124
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +70 -70
- package/colors/utils/misc.js +1 -1
- package/colors/utils/misc.mjs +3 -3
- package/common/AdaptiveMode.js +1 -1
- package/common/AdaptiveMode.mjs +10 -9
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +31 -1
- package/index.d.ts +31 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
package/colors/ColorPicker.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 ze=require("react"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ze=require("react"),l=require("prop-types"),n=require("@progress/kendo-react-common"),Le=require("../package-metadata.js"),Ne=require("./Picker.js"),xe=require("./ColorGradient.js"),J=require("./ColorPalette.js"),L=require("./FlatColorPicker.js"),qe=require("@progress/kendo-react-buttons"),Ve=require("@progress/kendo-svg-icons"),d=require("../messages/index.js"),He=require("@progress/kendo-react-intl"),Me=require("../common/AdaptiveMode.js"),We=require("@progress/kendo-react-layout");function Ue(f){const S=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const w in f)if(w!=="default"){const r=Object.getOwnPropertyDescriptor(f,w);Object.defineProperty(S,w,r.get?r:{enumerable:!0,get:()=>f[w]})}}return S.default=f,Object.freeze(S)}const t=Ue(ze),je={opacity:!0},Ge={palette:J.DEFAULT_PRESET,tileSize:J.DEFAULT_TILE_SIZE},Z=f=>f!==void 0,ge=n.createPropsContext(),Q=t.forwardRef((f,S)=>{var ce,se;const w=!n.validatePackage(Le.packageMetadata,{component:"ColorPicker"}),r=n.usePropsContext(ge,f),_=He.useLocalization(),X=n.useAdaptiveModeContext(),{size:p=E.size,rounded:N=E.rounded,fillMode:I=E.fillMode,gradientSettings:P=E.gradientSettings,paletteSettings:h=E.paletteSettings,flatColorPickerSettings:T,view:g=r.views?void 0:E.view,views:s=g?void 0:E.views,activeView:Y,popupSettings:C,valid:ve,disabled:x,tabIndex:ke,icon:q,svgIcon:V,iconClassName:F,onChange:H,onFocus:M,onBlur:W,onActiveColorClick:U,className:me,adaptive:Ce,adaptiveTitle:ee=_.toLanguageString(d.colorPickerAdaptiveTitle,d.messages[d.colorPickerAdaptiveTitle])}=r,u=t.useRef(null),R=t.useRef(null),B=t.useRef(null),m=t.useRef(null),y=t.useRef(void 0),be=t.useRef(null),[Ee,te]=t.useState(!1),[we,Pe]=t.useState(r.defaultValue||void 0),[ye,Se]=t.useState(!1),[O,_e]=t.useState(),j=Z(r.value),b=Z(r.open),i=j?r.value:we,v=b?r.open:ye,ne=t.useRef(i),ae=t.useCallback(()=>{u.current&&u.current.focus()},[]);t.useImperativeHandle(S,()=>({element:u.current,actionElement:be.current,value:i,focus:ae}),[i,ae]);const G=!!(O&&X&&O<=X.medium&&Ce);t.useEffect(()=>{const e=n.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(Oe.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{document!=null&&document.body&&e&&e.disconnect()}},[]);const o=t.useCallback((e,c)=>{b||(!e&&!c&&u&&u.current&&u.current.focus(),Se(e))},[b]),re=t.useMemo(()=>new n.Navigation({root:u,selectors:[".k-colorpicker",".k-color-picker-popup"],tabIndex:0,keyboardEvents:{keydown:{Escape:(e,c,a)=>{o(!1)},Enter:(e,c,a)=>{!b&&e===u.current&&(a.preventDefault(),a.stopPropagation(),o(!0))},ArrowDown:(e,c,a)=>{a.altKey&&(a.preventDefault(),a.stopPropagation(),o(!0))},ArrowUp:(e,c,a)=>{a.altKey&&(a.preventDefault(),a.stopPropagation(),o(!1))},Tab:(e,c,a)=>{var A,ue,de;if(n.getActiveElement(document)!==u.current){const pe=(A=B.current)==null?void 0:A.wrapperRef.current,z=(ue=R.current)==null?void 0:ue.wrapperRef.current,fe=(de=m.current)==null?void 0:de.element;g==="palette"&&pe?n.keepFocusInContainer(a,pe):g==="gradient"&&z?n.keepFocusInContainer(a,z):g==="combo"&&z?n.keepFocusInContainer(a,z.parentElement):s&&fe&&n.keepFocusInContainer(a,fe)}}}}}),[o,b]),he=t.useCallback(re.triggerKeyboardEvent.bind(re),[]),Te=t.useCallback(()=>{b||(R.current&&R.current.wrapperRef.current?n.focusFirstFocusableChild(R.current.wrapperRef.current):B.current?B.current.focus():m.current&&m.current.element&&n.focusFirstFocusableChild(m.current.element))},[b]),D=e=>ne.current=e,oe=t.useCallback(e=>{const c={value:ne.current,nativeEvent:e.nativeEvent,syntheticEvent:e};k(c),o(!v,!0)},[v]),K=t.useCallback(()=>{o(!1,!0)},[o]),Re=t.useCallback(e=>{U&&U.call(void 0,{syntheticEvent:e,nativeEvent:e.nativeEvent,value:i,target:{element:u.current,value:i}})},[U,i]),Ae=t.useCallback(e=>{y.current?(clearTimeout(y.current),y.current=void 0):(te(!0),G&&!v&&o(!0)),M&&M.call(void 0,{nativeEvent:e.nativeEvent,syntheticEvent:e})},[G,M,v,o]),Ie=t.useCallback(()=>{o(!1,!0),te(!1),y.current=void 0},[]),Fe=t.useCallback(e=>{clearTimeout(y.current),y.current=window.setTimeout(Ie),W&&W.call(void 0,{nativeEvent:e.nativeEvent,syntheticEvent:e})},[W]),k=t.useCallback((e,c)=>{var A;const a=c?e.rgbaValue||"":(A=e.value)!=null?A:"";j||Pe(a),H&&H.call(void 0,{value:a,nativeEvent:e.nativeEvent,syntheticEvent:e.syntheticEvent,target:{element:u.current,value:a}}),o(!1)},[j,H]),le=t.useCallback(e=>k(e,!0),[Z,k]),$=t.useCallback(e=>t.createElement(t.Fragment,null,(g==="combo"||g==="gradient")&&t.createElement(xe.ColorGradient,{...P,_adaptive:e,ref:R,isInsidePopup:!0,size:e?"large":p,fillMode:I,value:i,onChange:k}),(g==="combo"||g==="palette")&&t.createElement(J.ColorPalette,{...h,ref:B,size:e?"large":p,value:i,onChange:le}),s&&s[0]==="gradient"&&s[1]==="palette"&&t.createElement(L.FlatColorPicker,{...T,_paletteSettings:h,_gradientSettings:{_adaptive:e,...P},ref:m,size:e?"large":p,views:["gradient","palette"],activeView:Y,setOpen:o,showButtons:!e,value:i,onChange:k,setAdaptiveModeValue:D}),s&&s[0]==="palette"&&s[1]==="gradient"&&t.createElement(L.FlatColorPicker,{...T,_paletteSettings:h,_gradientSettings:{_adaptive:e,...P},ref:m,size:e?"large":p,views:["palette","gradient"],setOpen:o,showButtons:!e,value:i,onChange:k,setAdaptiveModeValue:D}),s&&s.includes("gradient")&&!s.includes("palette")&&t.createElement(L.FlatColorPicker,{...T,_gradientSettings:{_adaptive:e,...P},ref:m,size:e?"large":p,views:["gradient"],showButtons:!e,setOpen:o,value:i,onChange:k,setAdaptiveModeValue:D}),s&&s.includes("palette")&&!s.includes("gradient")&&t.createElement(L.FlatColorPicker,{...T,_paletteSettings:h,_gradientSettings:{_adaptive:e,...P},ref:m,size:e?"large":p,views:["palette"],showButtons:!e,setOpen:o,value:i,onChange:k,setAdaptiveModeValue:D}),w&&t.createElement(n.WatermarkOverlay,null)),[Y,I,T,P,k,le,h,o,p,i,g,s]),Be=t.useCallback(()=>{var c;const e={animation:!!((c=C==null?void 0:C.animate)==null||c),title:ee,expand:v,onClose:K,windowWidth:O,footer:{cancelText:_.toLanguageString(d.flatColorPickerCancelBtn,d.messages[d.flatColorPickerCancelBtn]),onCancel:K,applyText:_.toLanguageString(d.flatColorPickerApplyBtn,d.messages[d.flatColorPickerApplyBtn]),onApply:oe}};return t.createElement(Me.AdaptiveMode,{...e},t.createElement(We.ActionSheetContent,null,$(!0)))},[C==null?void 0:C.animate,ee,v,K,O,_,oe,$]),Oe=t.useCallback(e=>{for(const c of e)_e(c.target.clientWidth)},[]),ie=n.useDir(u,r.dir),De=ve!==!1;return t.createElement("span",{id:r.id,role:"combobox","aria-label":r.ariaLabel,"aria-labelledby":r.ariaLabelledBy,"aria-describedby":r.ariaDescribedBy,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":`k-colorpicker-popup-${(ce=r.id)!=null?ce:0}`,"aria-disabled":x?"true":void 0,className:n.classNames("k-colorpicker","k-picker","k-icon-picker",{[`k-picker-${n.kendoThemeMaps.sizeMap[p]||p}`]:p,[`k-picker-${I}`]:I,[`k-rounded-${n.kendoThemeMaps.roundedMap[N]||N}`]:N,"k-invalid":!De,"k-disabled":x,"k-focus":Ee,className:me}),ref:u,tabIndex:n.getTabIndex(ke,x),title:r.title,onKeyDown:he,onFocus:Ae,onBlur:Fe,dir:ie},t.createElement(Ne.Picker,{dir:ie,open:v,onOpen:Te,popupAnchor:u.current||void 0,popupSettings:{id:`k-colorpicker-popup-${(se=r.id)!=null?se:0}`,...C},input:t.createElement("span",{onClick:Re,className:"k-input-inner"},t.createElement("span",{className:n.classNames("k-value-icon","k-color-preview",{"k-no-color":!i,"k-icon-color-preview":q||V||F})},F&&t.createElement("span",{className:n.classNames("k-color-preview-icon",F)}),!F&&(q||V)&&t.createElement(n.IconWrap,{name:q,icon:V}),t.createElement("span",{className:"k-color-preview-mask",style:{backgroundColor:i}}))),button:t.createElement(qe.Button,{tabIndex:-1,type:"button",onClick:()=>o(!v),className:"k-input-button",rounded:null,icon:"caret-alt-down",svgIcon:Ve.caretAltDownIcon,"aria-label":_.toLanguageString(d.colorPickerDropdownButtonAriaLabel,d.messages[d.colorPickerDropdownButtonAriaLabel])}),content:$(!1),_mobileMode:G,_actionSheet:Be()}))});Q.propTypes={value:l.string,defaultValue:l.string,disabled:l.bool,view:l.oneOf(["gradient","palette","combo"]),views:l.arrayOf(l.oneOf(["gradient","palette"])),dir:l.string,id:l.string,icon:l.string,svgIcon:n.svgIconPropType,ariaLabelledBy:l.string,ariaDescribedBy:l.string,size:l.oneOf([null,"small","medium","large"]),rounded:l.oneOf([null,"small","medium","large","full"]),fillMode:l.oneOf([null,"solid","flat","outline"]),className:l.string,adaptive:l.bool,adaptiveTitle:l.string,adaptiveSubtitle:l.string};const E={size:"medium",rounded:"medium",fillMode:"solid",view:"palette",views:["gradient","palette"],gradientSettings:je,paletteSettings:Ge};Q.displayName="KendoColorPicker";exports.ColorPicker=Q;exports.ColorPickerPropsContext=ge;
|
package/colors/ColorPicker.mjs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
|
-
import
|
|
10
|
-
import { createPropsContext as He, validatePackage as We, usePropsContext as Ue, useAdaptiveModeContext as Ke, canUseDOM as $e, Navigation as Ge, getActiveElement as Me, keepFocusInContainer as z, focusFirstFocusableChild as
|
|
9
|
+
import r from "prop-types";
|
|
10
|
+
import { createPropsContext as He, validatePackage as We, usePropsContext as Ue, useAdaptiveModeContext as Ke, canUseDOM as $e, Navigation as Ge, getActiveElement as Me, keepFocusInContainer as z, focusFirstFocusableChild as de, WatermarkOverlay as Ze, useDir as je, classNames as Z, kendoThemeMaps as pe, getTabIndex as qe, IconWrap as Je, svgIconPropType as Qe } from "@progress/kendo-react-common";
|
|
11
11
|
import { packageMetadata as Xe } from "../package-metadata.mjs";
|
|
12
12
|
import { Picker as Ye } from "./Picker.mjs";
|
|
13
13
|
import { ColorGradient as et } from "./ColorGradient.mjs";
|
|
@@ -15,7 +15,7 @@ import { ColorPalette as tt, DEFAULT_PRESET as nt, DEFAULT_TILE_SIZE as at } fro
|
|
|
15
15
|
import { FlatColorPicker as B } from "./FlatColorPicker.mjs";
|
|
16
16
|
import { Button as rt } from "@progress/kendo-react-buttons";
|
|
17
17
|
import { caretAltDownIcon as ot } from "@progress/kendo-svg-icons";
|
|
18
|
-
import { colorPickerAdaptiveTitle as
|
|
18
|
+
import { colorPickerAdaptiveTitle as fe, messages as D, flatColorPickerCancelBtn as me, flatColorPickerApplyBtn as ve, colorPickerDropdownButtonAriaLabel as ge } from "../messages/index.mjs";
|
|
19
19
|
import { useLocalization as lt } from "@progress/kendo-react-intl";
|
|
20
20
|
import { AdaptiveMode as it } from "../common/AdaptiveMode.mjs";
|
|
21
21
|
import { ActionSheetContent as ct } from "@progress/kendo-react-layout";
|
|
@@ -24,9 +24,9 @@ const st = {
|
|
|
24
24
|
}, ut = {
|
|
25
25
|
palette: nt,
|
|
26
26
|
tileSize: at
|
|
27
|
-
},
|
|
28
|
-
var
|
|
29
|
-
const
|
|
27
|
+
}, j = (L) => L !== void 0, dt = He(), ke = t.forwardRef((L, Ce) => {
|
|
28
|
+
var oe, le;
|
|
29
|
+
const Ee = !We(Xe, { component: "ColorPicker" }), o = Ue(dt, L), b = lt(), q = Ke(), {
|
|
30
30
|
size: u = k.size,
|
|
31
31
|
rounded: x = k.rounded,
|
|
32
32
|
fillMode: _ = k.fillMode,
|
|
@@ -35,11 +35,11 @@ const st = {
|
|
|
35
35
|
flatColorPickerSettings: y,
|
|
36
36
|
view: d = o.views ? void 0 : k.view,
|
|
37
37
|
views: c = d ? void 0 : k.views,
|
|
38
|
-
activeView:
|
|
39
|
-
popupSettings:
|
|
40
|
-
valid:
|
|
38
|
+
activeView: J,
|
|
39
|
+
popupSettings: v,
|
|
40
|
+
valid: be,
|
|
41
41
|
disabled: N,
|
|
42
|
-
tabIndex:
|
|
42
|
+
tabIndex: we,
|
|
43
43
|
icon: O,
|
|
44
44
|
svgIcon: F,
|
|
45
45
|
iconClassName: P,
|
|
@@ -47,77 +47,77 @@ const st = {
|
|
|
47
47
|
onFocus: H,
|
|
48
48
|
onBlur: W,
|
|
49
49
|
onActiveColorClick: U,
|
|
50
|
-
className:
|
|
51
|
-
adaptive:
|
|
52
|
-
adaptiveTitle:
|
|
53
|
-
} = o, s = t.useRef(null), S = t.useRef(null), T = t.useRef(null),
|
|
50
|
+
className: ye,
|
|
51
|
+
adaptive: Se,
|
|
52
|
+
adaptiveTitle: Q = b.toLanguageString(fe, D[fe])
|
|
53
|
+
} = o, s = t.useRef(null), S = t.useRef(null), T = t.useRef(null), m = t.useRef(null), E = t.useRef(void 0), he = t.useRef(null), [_e, X] = t.useState(!1), [Pe, Te] = t.useState(o.defaultValue || void 0), [Re, Ae] = t.useState(!1), [R, Ie] = t.useState(), K = j(o.value), g = j(o.open), l = K ? o.value : Pe, p = g ? o.open : Re, Y = t.useRef(l), ee = t.useCallback(() => {
|
|
54
54
|
s.current && s.current.focus();
|
|
55
55
|
}, []);
|
|
56
56
|
t.useImperativeHandle(
|
|
57
|
-
|
|
57
|
+
Ce,
|
|
58
58
|
() => ({
|
|
59
59
|
// we agreed that each element will have focus method exposed
|
|
60
60
|
element: s.current,
|
|
61
|
-
actionElement:
|
|
61
|
+
actionElement: he.current,
|
|
62
62
|
value: l,
|
|
63
|
-
focus:
|
|
63
|
+
focus: ee
|
|
64
64
|
}),
|
|
65
|
-
[l,
|
|
65
|
+
[l, ee]
|
|
66
66
|
);
|
|
67
|
-
const
|
|
67
|
+
const $ = !!(R && q && R <= q.medium && Se);
|
|
68
68
|
t.useEffect(() => {
|
|
69
69
|
const e = $e && window.ResizeObserver && new window.ResizeObserver(Fe.bind(void 0));
|
|
70
70
|
return document != null && document.body && e && e.observe(document.body), () => {
|
|
71
71
|
document != null && document.body && e && e.disconnect();
|
|
72
72
|
};
|
|
73
73
|
}, []);
|
|
74
|
-
const
|
|
74
|
+
const a = t.useCallback(
|
|
75
75
|
(e, i) => {
|
|
76
|
-
|
|
76
|
+
g || (!e && !i && s && s.current && s.current.focus(), Ae(e));
|
|
77
77
|
},
|
|
78
|
-
[
|
|
79
|
-
),
|
|
78
|
+
[g]
|
|
79
|
+
), te = t.useMemo(() => new Ge({
|
|
80
80
|
root: s,
|
|
81
81
|
selectors: [".k-colorpicker", ".k-color-picker-popup"],
|
|
82
82
|
tabIndex: 0,
|
|
83
83
|
keyboardEvents: {
|
|
84
84
|
keydown: {
|
|
85
85
|
Escape: (e, i, n) => {
|
|
86
|
-
|
|
86
|
+
a(!1);
|
|
87
87
|
},
|
|
88
88
|
Enter: (e, i, n) => {
|
|
89
|
-
!
|
|
89
|
+
!g && e === s.current && (n.preventDefault(), n.stopPropagation(), a(!0));
|
|
90
90
|
},
|
|
91
91
|
ArrowDown: (e, i, n) => {
|
|
92
|
-
n.altKey && (n.preventDefault(), n.stopPropagation(),
|
|
92
|
+
n.altKey && (n.preventDefault(), n.stopPropagation(), a(!0));
|
|
93
93
|
},
|
|
94
94
|
ArrowUp: (e, i, n) => {
|
|
95
|
-
n.altKey && (n.preventDefault(), n.stopPropagation(),
|
|
95
|
+
n.altKey && (n.preventDefault(), n.stopPropagation(), a(!1));
|
|
96
96
|
},
|
|
97
97
|
Tab: (e, i, n) => {
|
|
98
|
-
var h,
|
|
98
|
+
var h, ie, ce;
|
|
99
99
|
if (Me(document) !== s.current) {
|
|
100
|
-
const
|
|
101
|
-
d === "palette" &&
|
|
100
|
+
const se = (h = T.current) == null ? void 0 : h.wrapperRef.current, I = (ie = S.current) == null ? void 0 : ie.wrapperRef.current, ue = (ce = m.current) == null ? void 0 : ce.element;
|
|
101
|
+
d === "palette" && se ? z(n, se) : d === "gradient" && I ? z(n, I) : d === "combo" && I ? z(n, I.parentElement) : c && ue && z(n, ue);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
}), [
|
|
107
|
-
|
|
108
|
-
}, [
|
|
106
|
+
}), [a, g]), ze = t.useCallback(te.triggerKeyboardEvent.bind(te), []), Be = t.useCallback(() => {
|
|
107
|
+
g || (S.current && S.current.wrapperRef.current ? de(S.current.wrapperRef.current) : T.current ? T.current.focus() : m.current && m.current.element && de(m.current.element));
|
|
108
|
+
}, [g]), A = (e) => Y.current = e, ne = t.useCallback(
|
|
109
109
|
(e) => {
|
|
110
110
|
const i = {
|
|
111
|
-
value:
|
|
111
|
+
value: Y.current,
|
|
112
112
|
nativeEvent: e.nativeEvent,
|
|
113
113
|
syntheticEvent: e
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
f(i), a(!p, !0);
|
|
116
116
|
},
|
|
117
|
-
[
|
|
118
|
-
),
|
|
119
|
-
|
|
120
|
-
}, [
|
|
117
|
+
[p]
|
|
118
|
+
), G = t.useCallback(() => {
|
|
119
|
+
a(!1, !0);
|
|
120
|
+
}, [a]), De = t.useCallback(
|
|
121
121
|
(e) => {
|
|
122
122
|
U && U.call(void 0, {
|
|
123
123
|
syntheticEvent: e,
|
|
@@ -132,14 +132,14 @@ const st = {
|
|
|
132
132
|
[U, l]
|
|
133
133
|
), Le = t.useCallback(
|
|
134
134
|
(e) => {
|
|
135
|
-
E.current ? (clearTimeout(E.current), E.current = void 0) :
|
|
135
|
+
E.current ? (clearTimeout(E.current), E.current = void 0) : (X(!0), $ && !p && a(!0)), H && H.call(void 0, {
|
|
136
136
|
nativeEvent: e.nativeEvent,
|
|
137
137
|
syntheticEvent: e
|
|
138
138
|
});
|
|
139
139
|
},
|
|
140
|
-
[H]
|
|
140
|
+
[$, H, p, a]
|
|
141
141
|
), xe = t.useCallback(() => {
|
|
142
|
-
|
|
142
|
+
a(!1, !0), X(!1), E.current = void 0;
|
|
143
143
|
}, []), Ne = t.useCallback(
|
|
144
144
|
(e) => {
|
|
145
145
|
clearTimeout(E.current), E.current = window.setTimeout(xe), W && W.call(void 0, {
|
|
@@ -148,11 +148,11 @@ const st = {
|
|
|
148
148
|
});
|
|
149
149
|
},
|
|
150
150
|
[W]
|
|
151
|
-
),
|
|
151
|
+
), f = t.useCallback(
|
|
152
152
|
(e, i) => {
|
|
153
153
|
var h;
|
|
154
154
|
const n = i ? e.rgbaValue || "" : (h = e.value) != null ? h : "";
|
|
155
|
-
K ||
|
|
155
|
+
K || Te(n), V && V.call(void 0, {
|
|
156
156
|
value: n,
|
|
157
157
|
nativeEvent: e.nativeEvent,
|
|
158
158
|
syntheticEvent: e.syntheticEvent,
|
|
@@ -160,13 +160,13 @@ const st = {
|
|
|
160
160
|
element: s.current,
|
|
161
161
|
value: n
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
163
|
+
}), a(!1);
|
|
164
164
|
},
|
|
165
165
|
[K, V]
|
|
166
|
-
),
|
|
167
|
-
(e) =>
|
|
168
|
-
[
|
|
169
|
-
),
|
|
166
|
+
), ae = t.useCallback(
|
|
167
|
+
(e) => f(e, !0),
|
|
168
|
+
[j, f]
|
|
169
|
+
), M = t.useCallback(
|
|
170
170
|
(e) => /* @__PURE__ */ t.createElement(t.Fragment, null, (d === "combo" || d === "gradient") && /* @__PURE__ */ t.createElement(
|
|
171
171
|
et,
|
|
172
172
|
{
|
|
@@ -177,7 +177,7 @@ const st = {
|
|
|
177
177
|
size: e ? "large" : u,
|
|
178
178
|
fillMode: _,
|
|
179
179
|
value: l,
|
|
180
|
-
onChange:
|
|
180
|
+
onChange: f
|
|
181
181
|
}
|
|
182
182
|
), (d === "combo" || d === "palette") && /* @__PURE__ */ t.createElement(
|
|
183
183
|
tt,
|
|
@@ -186,7 +186,7 @@ const st = {
|
|
|
186
186
|
ref: T,
|
|
187
187
|
size: e ? "large" : u,
|
|
188
188
|
value: l,
|
|
189
|
-
onChange:
|
|
189
|
+
onChange: ae
|
|
190
190
|
}
|
|
191
191
|
), c && c[0] === "gradient" && c[1] === "palette" && /* @__PURE__ */ t.createElement(
|
|
192
192
|
B,
|
|
@@ -194,14 +194,14 @@ const st = {
|
|
|
194
194
|
...y,
|
|
195
195
|
_paletteSettings: w,
|
|
196
196
|
_gradientSettings: { _adaptive: e, ...C },
|
|
197
|
-
ref:
|
|
197
|
+
ref: m,
|
|
198
198
|
size: e ? "large" : u,
|
|
199
199
|
views: ["gradient", "palette"],
|
|
200
|
-
activeView:
|
|
201
|
-
setOpen:
|
|
200
|
+
activeView: J,
|
|
201
|
+
setOpen: a,
|
|
202
202
|
showButtons: !e,
|
|
203
203
|
value: l,
|
|
204
|
-
onChange:
|
|
204
|
+
onChange: f,
|
|
205
205
|
setAdaptiveModeValue: A
|
|
206
206
|
}
|
|
207
207
|
), c && c[0] === "palette" && c[1] === "gradient" && /* @__PURE__ */ t.createElement(
|
|
@@ -210,13 +210,13 @@ const st = {
|
|
|
210
210
|
...y,
|
|
211
211
|
_paletteSettings: w,
|
|
212
212
|
_gradientSettings: { _adaptive: e, ...C },
|
|
213
|
-
ref:
|
|
213
|
+
ref: m,
|
|
214
214
|
size: e ? "large" : u,
|
|
215
215
|
views: ["palette", "gradient"],
|
|
216
|
-
setOpen:
|
|
216
|
+
setOpen: a,
|
|
217
217
|
showButtons: !e,
|
|
218
218
|
value: l,
|
|
219
|
-
onChange:
|
|
219
|
+
onChange: f,
|
|
220
220
|
setAdaptiveModeValue: A
|
|
221
221
|
}
|
|
222
222
|
), c && c.includes("gradient") && !c.includes("palette") && /* @__PURE__ */ t.createElement(
|
|
@@ -224,13 +224,13 @@ const st = {
|
|
|
224
224
|
{
|
|
225
225
|
...y,
|
|
226
226
|
_gradientSettings: { _adaptive: e, ...C },
|
|
227
|
-
ref:
|
|
227
|
+
ref: m,
|
|
228
228
|
size: e ? "large" : u,
|
|
229
229
|
views: ["gradient"],
|
|
230
230
|
showButtons: !e,
|
|
231
|
-
setOpen:
|
|
231
|
+
setOpen: a,
|
|
232
232
|
value: l,
|
|
233
|
-
onChange:
|
|
233
|
+
onChange: f,
|
|
234
234
|
setAdaptiveModeValue: A
|
|
235
235
|
}
|
|
236
236
|
), c && c.includes("palette") && !c.includes("gradient") && /* @__PURE__ */ t.createElement(
|
|
@@ -239,25 +239,25 @@ const st = {
|
|
|
239
239
|
...y,
|
|
240
240
|
_paletteSettings: w,
|
|
241
241
|
_gradientSettings: { _adaptive: e, ...C },
|
|
242
|
-
ref:
|
|
242
|
+
ref: m,
|
|
243
243
|
size: e ? "large" : u,
|
|
244
244
|
views: ["palette"],
|
|
245
245
|
showButtons: !e,
|
|
246
|
-
setOpen:
|
|
246
|
+
setOpen: a,
|
|
247
247
|
value: l,
|
|
248
|
-
onChange:
|
|
248
|
+
onChange: f,
|
|
249
249
|
setAdaptiveModeValue: A
|
|
250
250
|
}
|
|
251
|
-
),
|
|
251
|
+
), Ee && /* @__PURE__ */ t.createElement(Ze, null)),
|
|
252
252
|
[
|
|
253
|
-
|
|
253
|
+
J,
|
|
254
254
|
_,
|
|
255
255
|
y,
|
|
256
256
|
C,
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
f,
|
|
258
|
+
ae,
|
|
259
259
|
w,
|
|
260
|
-
|
|
260
|
+
a,
|
|
261
261
|
u,
|
|
262
262
|
l,
|
|
263
263
|
d,
|
|
@@ -266,32 +266,32 @@ const st = {
|
|
|
266
266
|
), Oe = t.useCallback(() => {
|
|
267
267
|
var i;
|
|
268
268
|
const e = {
|
|
269
|
-
animation: !!((i =
|
|
270
|
-
title:
|
|
271
|
-
expand:
|
|
272
|
-
onClose:
|
|
269
|
+
animation: !!((i = v == null ? void 0 : v.animate) == null || i),
|
|
270
|
+
title: Q,
|
|
271
|
+
expand: p,
|
|
272
|
+
onClose: G,
|
|
273
273
|
windowWidth: R,
|
|
274
274
|
footer: {
|
|
275
|
-
cancelText: b.toLanguageString(
|
|
276
|
-
onCancel:
|
|
277
|
-
applyText: b.toLanguageString(
|
|
278
|
-
onApply:
|
|
275
|
+
cancelText: b.toLanguageString(me, D[me]),
|
|
276
|
+
onCancel: G,
|
|
277
|
+
applyText: b.toLanguageString(ve, D[ve]),
|
|
278
|
+
onApply: ne
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
return /* @__PURE__ */ t.createElement(it, { ...e }, /* @__PURE__ */ t.createElement(ct, null,
|
|
281
|
+
return /* @__PURE__ */ t.createElement(it, { ...e }, /* @__PURE__ */ t.createElement(ct, null, M(!0)));
|
|
282
282
|
}, [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
v == null ? void 0 : v.animate,
|
|
284
|
+
Q,
|
|
285
|
+
p,
|
|
286
|
+
G,
|
|
287
287
|
R,
|
|
288
288
|
b,
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
ne,
|
|
290
|
+
M
|
|
291
291
|
]), Fe = t.useCallback((e) => {
|
|
292
292
|
for (const i of e)
|
|
293
|
-
|
|
294
|
-
}, []),
|
|
293
|
+
Ie(i.target.clientWidth);
|
|
294
|
+
}, []), re = je(s, o.dir), Ve = be !== !1;
|
|
295
295
|
return /* @__PURE__ */ t.createElement(
|
|
296
296
|
"span",
|
|
297
297
|
{
|
|
@@ -301,43 +301,43 @@ const st = {
|
|
|
301
301
|
"aria-labelledby": o.ariaLabelledBy,
|
|
302
302
|
"aria-describedby": o.ariaDescribedBy,
|
|
303
303
|
"aria-haspopup": "dialog",
|
|
304
|
-
"aria-expanded":
|
|
305
|
-
"aria-controls": `k-colorpicker-popup-${(
|
|
304
|
+
"aria-expanded": p,
|
|
305
|
+
"aria-controls": `k-colorpicker-popup-${(oe = o.id) != null ? oe : 0}`,
|
|
306
306
|
"aria-disabled": N ? "true" : void 0,
|
|
307
|
-
className:
|
|
308
|
-
[`k-picker-${
|
|
307
|
+
className: Z("k-colorpicker", "k-picker", "k-icon-picker", {
|
|
308
|
+
[`k-picker-${pe.sizeMap[u] || u}`]: u,
|
|
309
309
|
[`k-picker-${_}`]: _,
|
|
310
|
-
[`k-rounded-${
|
|
310
|
+
[`k-rounded-${pe.roundedMap[x] || x}`]: x,
|
|
311
311
|
"k-invalid": !Ve,
|
|
312
312
|
"k-disabled": N,
|
|
313
|
-
"k-focus":
|
|
314
|
-
className:
|
|
313
|
+
"k-focus": _e,
|
|
314
|
+
className: ye
|
|
315
315
|
}),
|
|
316
316
|
ref: s,
|
|
317
|
-
tabIndex: qe(
|
|
317
|
+
tabIndex: qe(we, N),
|
|
318
318
|
title: o.title,
|
|
319
319
|
onKeyDown: ze,
|
|
320
320
|
onFocus: Le,
|
|
321
321
|
onBlur: Ne,
|
|
322
|
-
dir:
|
|
322
|
+
dir: re
|
|
323
323
|
},
|
|
324
324
|
/* @__PURE__ */ t.createElement(
|
|
325
325
|
Ye,
|
|
326
326
|
{
|
|
327
|
-
dir:
|
|
328
|
-
open:
|
|
327
|
+
dir: re,
|
|
328
|
+
open: p,
|
|
329
329
|
onOpen: Be,
|
|
330
330
|
popupAnchor: s.current || void 0,
|
|
331
|
-
popupSettings: { id: `k-colorpicker-popup-${(
|
|
331
|
+
popupSettings: { id: `k-colorpicker-popup-${(le = o.id) != null ? le : 0}`, ...v },
|
|
332
332
|
input: /* @__PURE__ */ t.createElement("span", { onClick: De, className: "k-input-inner" }, /* @__PURE__ */ t.createElement(
|
|
333
333
|
"span",
|
|
334
334
|
{
|
|
335
|
-
className:
|
|
335
|
+
className: Z("k-value-icon", "k-color-preview", {
|
|
336
336
|
"k-no-color": !l,
|
|
337
337
|
"k-icon-color-preview": O || F || P
|
|
338
338
|
})
|
|
339
339
|
},
|
|
340
|
-
P && /* @__PURE__ */ t.createElement("span", { className:
|
|
340
|
+
P && /* @__PURE__ */ t.createElement("span", { className: Z("k-color-preview-icon", P) }),
|
|
341
341
|
!P && (O || F) && /* @__PURE__ */ t.createElement(Je, { name: O, icon: F }),
|
|
342
342
|
/* @__PURE__ */ t.createElement("span", { className: "k-color-preview-mask", style: { backgroundColor: l } })
|
|
343
343
|
)),
|
|
@@ -346,42 +346,43 @@ const st = {
|
|
|
346
346
|
{
|
|
347
347
|
tabIndex: -1,
|
|
348
348
|
type: "button",
|
|
349
|
-
onClick: () =>
|
|
349
|
+
onClick: () => a(!p),
|
|
350
350
|
className: "k-input-button",
|
|
351
351
|
rounded: null,
|
|
352
352
|
icon: "caret-alt-down",
|
|
353
353
|
svgIcon: ot,
|
|
354
354
|
"aria-label": b.toLanguageString(
|
|
355
|
-
|
|
356
|
-
D[
|
|
355
|
+
ge,
|
|
356
|
+
D[ge]
|
|
357
357
|
)
|
|
358
358
|
}
|
|
359
359
|
),
|
|
360
|
-
content:
|
|
361
|
-
_mobileMode:
|
|
360
|
+
content: M(!1),
|
|
361
|
+
_mobileMode: $,
|
|
362
362
|
_actionSheet: Oe()
|
|
363
363
|
}
|
|
364
364
|
)
|
|
365
365
|
);
|
|
366
366
|
});
|
|
367
|
-
|
|
368
|
-
value:
|
|
369
|
-
defaultValue:
|
|
370
|
-
disabled:
|
|
371
|
-
view:
|
|
372
|
-
views:
|
|
373
|
-
dir:
|
|
374
|
-
id:
|
|
375
|
-
icon:
|
|
367
|
+
ke.propTypes = {
|
|
368
|
+
value: r.string,
|
|
369
|
+
defaultValue: r.string,
|
|
370
|
+
disabled: r.bool,
|
|
371
|
+
view: r.oneOf(["gradient", "palette", "combo"]),
|
|
372
|
+
views: r.arrayOf(r.oneOf(["gradient", "palette"])),
|
|
373
|
+
dir: r.string,
|
|
374
|
+
id: r.string,
|
|
375
|
+
icon: r.string,
|
|
376
376
|
svgIcon: Qe,
|
|
377
|
-
ariaLabelledBy:
|
|
378
|
-
ariaDescribedBy:
|
|
379
|
-
size:
|
|
380
|
-
rounded:
|
|
381
|
-
fillMode:
|
|
382
|
-
className:
|
|
383
|
-
adaptive:
|
|
384
|
-
adaptiveTitle:
|
|
377
|
+
ariaLabelledBy: r.string,
|
|
378
|
+
ariaDescribedBy: r.string,
|
|
379
|
+
size: r.oneOf([null, "small", "medium", "large"]),
|
|
380
|
+
rounded: r.oneOf([null, "small", "medium", "large", "full"]),
|
|
381
|
+
fillMode: r.oneOf([null, "solid", "flat", "outline"]),
|
|
382
|
+
className: r.string,
|
|
383
|
+
adaptive: r.bool,
|
|
384
|
+
adaptiveTitle: r.string,
|
|
385
|
+
adaptiveSubtitle: r.string
|
|
385
386
|
};
|
|
386
387
|
const k = {
|
|
387
388
|
size: "medium",
|
|
@@ -392,8 +393,8 @@ const k = {
|
|
|
392
393
|
gradientSettings: st,
|
|
393
394
|
paletteSettings: ut
|
|
394
395
|
};
|
|
395
|
-
|
|
396
|
+
ke.displayName = "KendoColorPicker";
|
|
396
397
|
export {
|
|
397
|
-
|
|
398
|
+
ke as ColorPicker,
|
|
398
399
|
dt as ColorPickerPropsContext
|
|
399
400
|
};
|
|
@@ -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 J=require("react"),o=require("prop-types"),n=require("@progress/kendo-react-common"),s=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),Q=require("./ColorPalette.js"),U=require("./ColorGradient.js"),X=require("../package-metadata.js"),Y=require("@progress/kendo-react-intl"),l=require("../messages/index.js");function Z(e){const h=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const b in e)if(b!=="default"){const v=Object.getOwnPropertyDescriptor(e,b);Object.defineProperty(h,b,v.get?v:{enumerable:!0,get:()=>e[b]})}}return h.default=e,Object.freeze(h)}const t=Z(J),M=t.forwardRef((e,h)=>{const b=!n.validatePackage(X.packageMetadata,{component:"FlatColorPicker"}),v=t.useRef(null),B=t.useRef(null),A=t.useRef(null),{defaultValue:E,showButtons:w=!0,showPreview:x=!0,showClearButton:F=!0,view:P=e.views?void 0:"ColorGradient",views:d=P?void 0:["gradient","palette"],activeView:N="gradient",size:i="medium"}=e,[C,z]=t.useState((P||"ColorGradient")==="ColorGradient"),[g,V]=t.useState((d!=null?d:[])[0]==="gradient"&&N==="gradient"),[c,y]=t.useState(e.value||E||void 0),[k,G]=t.useState(e.value||E||void 0),_=e.value!==void 0?e.value:void 0;t.useEffect(()=>{y(e.value)},[e.value]);const m=Y.useLocalization(),L=t.useCallback(()=>{v.current&&v.current.focus()},[v]);t.useImperativeHandle(v,()=>({element:B.current,focus:L,props:e,value:_}),[_,L,e]),t.useImperativeHandle(h,()=>v.current);const R=t.useCallback(a=>{(a==="ColorGradient"&&!C||a==="ColorPalette"&&C)&&z(!C)},[C]),S=t.useCallback(a=>{a==="gradient"&&!g||a==="palette"&&g||a==="palette"&&N==="gradient"?V(!g):a==="gradient"&&N==="palette"&&V(!0)},[N,g]),T=t.useCallback(a=>{var u;const r=E||void 0;if(y(r),G(r),(u=e._gradientSettings)!=null&&u._adaptive&&e.setAdaptiveModeValue&&e.setAdaptiveModeValue(r),e.onPreviewChange){const I={value:r,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,I)}},[E,e.onPreviewChange]),q=t.useCallback(a=>{var r;if(y(a.value),e.onPreviewChange){const u={value:a.value,nativeEvent:a.nativeEvent,syntheticEvent:a.syntheticEvent};e.onPreviewChange.call(void 0,u)}(r=e._gradientSettings)!=null&&r._adaptive&&e.setAdaptiveModeValue&&e.setAdaptiveModeValue(a.value)},[e.onPreviewChange]),j=t.useCallback(a=>{if(c!==void 0&&G(c),e.onChange){const r={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,r)}},[c,e.onChange]),D=t.useCallback(()=>{y(k),e.setOpen&&e.setOpen(!1)},[k]),K=t.useCallback(a=>{if(y(k),e.onPreviewChange){const r={value:k,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,r)}},[k,e.onPreviewChange]),H=t.useCallback(a=>{var u,I;if((!a.relatedTarget||!((u=B.current)!=null&&u.contains(a.relatedTarget)))&&!((I=e._gradientSettings)!=null&&I._adaptive)&&(!w&&c!==void 0&&G(c),!w&&e.onChange)){const $={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,$)}},[c,w,e.onChange]),O=t.useMemo(()=>new n.Navigation({root:B,selectors:[".k-coloreditor"],tabIndex:0,keyboardEvents:{keydown:{Tab:(a,r,u)=>{n.getActiveElement(document)===a?n.disableNavigatableContainer(a):n.keepFocusInContainer(u,a)},Enter:(a,r,u)=>{n.getActiveElement(document)===a&&(n.focusFirstFocusableChild(a),n.enableNavigatableContainer(a))},Escape:(a,r,u)=>{n.getActiveElement(document)!==a&&(a.focus(),n.disableNavigatableContainer(a))}}}}),[]),W=t.useCallback(O.triggerKeyboardEvent.bind(O),[]);return t.createElement("div",{id:e.id,role:"textbox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-disabled":e.disabled?"true":void 0,style:{position:"relative",...e.style},ref:B,tabIndex:n.getTabIndex(e.tabIndex,e.disabled),className:n.classNames("k-flatcolorpicker k-coloreditor",{[`k-coloreditor-${n.kendoThemeMaps.sizeMap[i]||i}`]:i,"k-disabled":e.disabled},e.className),onBlur:H,onKeyDown:W},e.header||t.createElement("div",{className:"k-coloreditor-header k-hstack"},t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},d&&d[0]==="gradient"&&d[1]==="palette"&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.dropletSliderIcon,selected:g,onClick:()=>S("gradient")}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.paletteIcon,selected:!g,onClick:()=>S("palette")})),d&&d[0]==="palette"&&d[1]==="gradient"&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.paletteIcon,selected:!g,onClick:()=>S("palette")}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.dropletSliderIcon,selected:g,onClick:()=>S("gradient")})),P&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,selected:C,onClick:()=>R("ColorGradient"),icon:"droplet-slider",svgIcon:f.dropletSliderIcon}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,selected:!C,onClick:()=>R("ColorPalette"),icon:"palette",svgIcon:f.paletteIcon}))),t.createElement("div",{className:"k-spacer"}),t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},F&&t.createElement(s.Button,{type:"button",fillMode:"flat",size:i,onClick:T,"aria-label":m.toLanguageString(l.flatColorPickerClearBtn,l.messages[l.flatColorPickerClearBtn]),icon:"droplet-slash",svgIcon:f.dropletSlashIcon}),x&&t.createElement("div",{className:"k-coloreditor-preview k-vstack"},t.createElement("span",{className:n.classNames("k-coloreditor-preview-color","k-color-preview",{"k-no-color":_===void 0})},t.createElement("span",{className:"k-color-preview-mask",style:{background:c||void 0}})),t.createElement("span",{className:n.classNames("k-coloreditor-current-color","k-color-preview",{"k-no-color":k===void 0}),onClick:K},t.createElement("span",{className:"k-color-preview-mask",style:{background:k||void 0}})))),b&&t.createElement(n.WatermarkOverlay,null)),t.createElement("div",{className:"k-coloreditor-views k-vstack"},(P&&C||d&&g)&&t.createElement(U.ColorGradient,{ref:A,role:"none",ariaLabel:void 0,value:c,onChange:q,opacity:e.opacity,format:e.format,size:i,_adaptive:e._gradientSettings?e._gradientSettings._adaptive:void 0,...e._gradientSettings}),(P&&!C||d&&!g)&&t.createElement(Q.ColorPalette,{ariaDisabled:!0,ariaLabelledBy:"required_label",value:c,onChange:q,size:i,...e._paletteSettings})),w&&t.createElement("div",{className:"k-coloreditor-footer k-actions k-actions-
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("react"),o=require("prop-types"),n=require("@progress/kendo-react-common"),s=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),Q=require("./ColorPalette.js"),U=require("./ColorGradient.js"),X=require("../package-metadata.js"),Y=require("@progress/kendo-react-intl"),l=require("../messages/index.js");function Z(e){const h=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const b in e)if(b!=="default"){const v=Object.getOwnPropertyDescriptor(e,b);Object.defineProperty(h,b,v.get?v:{enumerable:!0,get:()=>e[b]})}}return h.default=e,Object.freeze(h)}const t=Z(J),M=t.forwardRef((e,h)=>{const b=!n.validatePackage(X.packageMetadata,{component:"FlatColorPicker"}),v=t.useRef(null),B=t.useRef(null),A=t.useRef(null),{defaultValue:E,showButtons:w=!0,showPreview:x=!0,showClearButton:F=!0,view:P=e.views?void 0:"ColorGradient",views:d=P?void 0:["gradient","palette"],activeView:N="gradient",size:i="medium"}=e,[C,z]=t.useState((P||"ColorGradient")==="ColorGradient"),[g,V]=t.useState((d!=null?d:[])[0]==="gradient"&&N==="gradient"),[c,y]=t.useState(e.value||E||void 0),[k,G]=t.useState(e.value||E||void 0),_=e.value!==void 0?e.value:void 0;t.useEffect(()=>{y(e.value)},[e.value]);const m=Y.useLocalization(),L=t.useCallback(()=>{v.current&&v.current.focus()},[v]);t.useImperativeHandle(v,()=>({element:B.current,focus:L,props:e,value:_}),[_,L,e]),t.useImperativeHandle(h,()=>v.current);const R=t.useCallback(a=>{(a==="ColorGradient"&&!C||a==="ColorPalette"&&C)&&z(!C)},[C]),S=t.useCallback(a=>{a==="gradient"&&!g||a==="palette"&&g||a==="palette"&&N==="gradient"?V(!g):a==="gradient"&&N==="palette"&&V(!0)},[N,g]),T=t.useCallback(a=>{var u;const r=E||void 0;if(y(r),G(r),(u=e._gradientSettings)!=null&&u._adaptive&&e.setAdaptiveModeValue&&e.setAdaptiveModeValue(r),e.onPreviewChange){const I={value:r,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,I)}},[E,e.onPreviewChange]),q=t.useCallback(a=>{var r;if(y(a.value),e.onPreviewChange){const u={value:a.value,nativeEvent:a.nativeEvent,syntheticEvent:a.syntheticEvent};e.onPreviewChange.call(void 0,u)}(r=e._gradientSettings)!=null&&r._adaptive&&e.setAdaptiveModeValue&&e.setAdaptiveModeValue(a.value)},[e.onPreviewChange]),j=t.useCallback(a=>{if(c!==void 0&&G(c),e.onChange){const r={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,r)}},[c,e.onChange]),D=t.useCallback(()=>{y(k),e.setOpen&&e.setOpen(!1)},[k]),K=t.useCallback(a=>{if(y(k),e.onPreviewChange){const r={value:k,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,r)}},[k,e.onPreviewChange]),H=t.useCallback(a=>{var u,I;if((!a.relatedTarget||!((u=B.current)!=null&&u.contains(a.relatedTarget)))&&!((I=e._gradientSettings)!=null&&I._adaptive)&&(!w&&c!==void 0&&G(c),!w&&e.onChange)){const $={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,$)}},[c,w,e.onChange]),O=t.useMemo(()=>new n.Navigation({root:B,selectors:[".k-coloreditor"],tabIndex:0,keyboardEvents:{keydown:{Tab:(a,r,u)=>{n.getActiveElement(document)===a?n.disableNavigatableContainer(a):n.keepFocusInContainer(u,a)},Enter:(a,r,u)=>{n.getActiveElement(document)===a&&(n.focusFirstFocusableChild(a),n.enableNavigatableContainer(a))},Escape:(a,r,u)=>{n.getActiveElement(document)!==a&&(a.focus(),n.disableNavigatableContainer(a))}}}}),[]),W=t.useCallback(O.triggerKeyboardEvent.bind(O),[]);return t.createElement("div",{id:e.id,role:"textbox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-disabled":e.disabled?"true":void 0,style:{position:"relative",...e.style},ref:B,tabIndex:n.getTabIndex(e.tabIndex,e.disabled),className:n.classNames("k-flatcolorpicker k-coloreditor",{[`k-coloreditor-${n.kendoThemeMaps.sizeMap[i]||i}`]:i,"k-disabled":e.disabled},e.className),onBlur:H,onKeyDown:W},e.header||t.createElement("div",{className:"k-coloreditor-header k-hstack"},t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},d&&d[0]==="gradient"&&d[1]==="palette"&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.dropletSliderIcon,selected:g,onClick:()=>S("gradient")}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.paletteIcon,selected:!g,onClick:()=>S("palette")})),d&&d[0]==="palette"&&d[1]==="gradient"&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.paletteIcon,selected:!g,onClick:()=>S("palette")}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,svgIcon:f.dropletSliderIcon,selected:g,onClick:()=>S("gradient")})),P&&t.createElement(s.ButtonGroup,{className:"k-button-group-flat"},t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorGradientBtn,l.messages[l.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",size:i,selected:C,onClick:()=>R("ColorGradient"),icon:"droplet-slider",svgIcon:f.dropletSliderIcon}),t.createElement(s.Button,{type:"button","aria-label":m.toLanguageString(l.flatColorPickerColorPaletteBtn,l.messages[l.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",size:i,selected:!C,onClick:()=>R("ColorPalette"),icon:"palette",svgIcon:f.paletteIcon}))),t.createElement("div",{className:"k-spacer"}),t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},F&&t.createElement(s.Button,{type:"button",fillMode:"flat",size:i,onClick:T,"aria-label":m.toLanguageString(l.flatColorPickerClearBtn,l.messages[l.flatColorPickerClearBtn]),icon:"droplet-slash",svgIcon:f.dropletSlashIcon}),x&&t.createElement("div",{className:"k-coloreditor-preview k-vstack"},t.createElement("span",{className:n.classNames("k-coloreditor-preview-color","k-color-preview",{"k-no-color":_===void 0})},t.createElement("span",{className:"k-color-preview-mask",style:{background:c||void 0}})),t.createElement("span",{className:n.classNames("k-coloreditor-current-color","k-color-preview",{"k-no-color":k===void 0}),onClick:K},t.createElement("span",{className:"k-color-preview-mask",style:{background:k||void 0}})))),b&&t.createElement(n.WatermarkOverlay,null)),t.createElement("div",{className:"k-coloreditor-views k-vstack"},(P&&C||d&&g)&&t.createElement(U.ColorGradient,{ref:A,role:"none",ariaLabel:void 0,value:c,onChange:q,opacity:e.opacity,format:e.format,size:i,_adaptive:e._gradientSettings?e._gradientSettings._adaptive:void 0,...e._gradientSettings}),(P&&!C||d&&!g)&&t.createElement(Q.ColorPalette,{ariaDisabled:!0,ariaLabelledBy:"required_label",value:c,onChange:q,size:i,...e._paletteSettings})),w&&t.createElement("div",{className:"k-coloreditor-footer k-actions k-actions-start k-actions-horizontal"},t.createElement(s.Button,{type:"button",themeColor:"primary",className:"k-coloreditor-apply",size:i,onClick:j},l.messages[l.flatColorPickerApplyBtn]),t.createElement(s.Button,{type:"button",className:"k-coloreditor-cancel",size:i,onClick:D},l.messages[l.flatColorPickerCancelBtn])))}),p={id:o.string,style:o.any,className:o.string,value:o.string,defaultValue:o.string,onPreviewChange:o.func,onChange:o.func,opacity:o.bool,format:o.any,tabIndex:o.number,ariaLabel:o.string,ariaLabelledBy:o.string,disabled:o.bool,view:o.any,header:o.any,showClearButton:o.bool,showPreview:o.bool,showButtons:o.bool,views:o.array,size:o.oneOf([null,"small","medium","large"])};M.displayName="KendoFlatColorPicker";M.propTypes=p;exports.FlatColorPicker=M;
|