@progress/kendo-react-inputs 7.2.4-develop.3 → 7.3.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/checkbox/Checkbox.js +8 -0
- package/checkbox/Checkbox.mjs +214 -0
- package/colors/ColorContrastLabels.js +8 -0
- package/colors/ColorContrastLabels.mjs +24 -0
- package/colors/ColorContrastSvg.js +8 -0
- package/colors/ColorContrastSvg.mjs +52 -0
- package/colors/ColorGradient.js +8 -0
- package/colors/ColorGradient.mjs +293 -0
- package/colors/ColorInput.js +8 -0
- package/colors/ColorInput.mjs +122 -0
- package/colors/ColorPalette.js +8 -0
- package/colors/ColorPalette.mjs +191 -0
- package/colors/ColorPicker.js +8 -0
- package/colors/ColorPicker.mjs +253 -0
- package/colors/FlatColorPicker.js +8 -0
- package/colors/FlatColorPicker.mjs +216 -0
- package/colors/HexInput.js +8 -0
- package/colors/HexInput.mjs +39 -0
- package/colors/Picker.js +8 -0
- package/colors/Picker.mjs +42 -0
- package/colors/models/palette-presets.js +8 -0
- package/colors/models/palette-presets.mjs +61 -0
- package/colors/utils/color-cache.js +8 -0
- package/colors/utils/color-cache.mjs +51 -0
- package/colors/utils/color-palette.service.js +8 -0
- package/colors/utils/color-palette.service.mjs +50 -0
- package/colors/utils/color-parser.js +8 -0
- package/colors/utils/color-parser.mjs +61 -0
- package/colors/utils/misc.js +8 -0
- package/colors/utils/misc.mjs +13 -0
- package/colors/utils/svg-calc.js +8 -0
- package/colors/utils/svg-calc.mjs +36 -0
- package/dist/cdn/js/kendo-react-inputs.js +8 -21
- package/index.d.mts +4275 -5
- package/index.d.ts +4275 -75
- package/index.js +8 -21
- package/index.mjs +97 -5042
- package/input/Input.js +8 -0
- package/input/Input.mjs +185 -0
- package/input/InputClearValue.js +8 -0
- package/input/InputClearValue.mjs +24 -0
- package/input/InputPrefix.js +8 -0
- package/input/InputPrefix.mjs +24 -0
- package/input/InputSeparator.js +8 -0
- package/input/InputSeparator.mjs +24 -0
- package/input/InputSuffix.js +8 -0
- package/input/InputSuffix.mjs +24 -0
- package/input/InputValidationIcon.js +8 -0
- package/input/InputValidationIcon.mjs +15 -0
- package/maskedtextbox/MaskedTextBox.js +8 -0
- package/maskedtextbox/MaskedTextBox.mjs +322 -0
- package/maskedtextbox/masking.service.js +8 -0
- package/maskedtextbox/masking.service.mjs +121 -0
- package/maskedtextbox/parsing/combinators.js +8 -0
- package/maskedtextbox/parsing/combinators.mjs +20 -0
- package/maskedtextbox/parsing/parsers.js +8 -0
- package/maskedtextbox/parsing/parsers.mjs +80 -0
- package/maskedtextbox/parsing/result.js +8 -0
- package/maskedtextbox/parsing/result.mjs +35 -0
- package/maskedtextbox/parsing/stream.js +8 -0
- package/maskedtextbox/parsing/stream.mjs +41 -0
- package/maskedtextbox/utils.js +8 -0
- package/maskedtextbox/utils.mjs +43 -0
- package/messages/index.js +8 -0
- package/messages/index.mjs +77 -0
- package/numerictextbox/NumericTextBox.js +8 -0
- package/numerictextbox/NumericTextBox.mjs +415 -0
- package/numerictextbox/utils/index.js +8 -0
- package/numerictextbox/utils/index.mjs +218 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +8 -8
- package/radiobutton/RadioButton.js +8 -0
- package/radiobutton/RadioButton.mjs +138 -0
- package/radiobutton/RadioGroup.js +8 -0
- package/radiobutton/RadioGroup.mjs +135 -0
- package/range-slider/RangeSlider.js +20 -0
- package/range-slider/RangeSlider.mjs +337 -0
- package/range-slider/range-raducer.js +8 -0
- package/range-slider/range-raducer.mjs +90 -0
- package/rating/Rating.js +12 -0
- package/rating/Rating.mjs +323 -0
- package/rating/RatingItem.js +8 -0
- package/rating/RatingItem.mjs +144 -0
- package/rating/rating-reducer.js +8 -0
- package/rating/rating-reducer.mjs +34 -0
- package/rating/utils/index.js +8 -0
- package/rating/utils/index.mjs +28 -0
- package/signature/Signature.js +8 -0
- package/signature/Signature.mjs +335 -0
- package/signature/utils/index.js +8 -0
- package/signature/utils/index.mjs +17 -0
- package/slider/Slider.js +8 -0
- package/slider/Slider.mjs +223 -0
- package/slider/SliderLabel.js +8 -0
- package/slider/SliderLabel.mjs +39 -0
- package/switch/Switch.js +8 -0
- package/switch/Switch.mjs +228 -0
- package/textarea/TextArea.js +8 -0
- package/textarea/TextArea.mjs +196 -0
- package/textbox/Textbox.js +8 -0
- package/textbox/Textbox.mjs +125 -0
- package/checkbox/Checkbox.d.ts +0 -36
- package/checkbox/interfaces/CheckboxBlurEvent.d.ts +0 -11
- package/checkbox/interfaces/CheckboxChangeEvent.d.ts +0 -15
- package/checkbox/interfaces/CheckboxFocusEvent.d.ts +0 -11
- package/checkbox/interfaces/CheckboxProps.d.ts +0 -126
- package/colors/ColorContrastLabels.d.ts +0 -19
- package/colors/ColorContrastSvg.d.ts +0 -22
- package/colors/ColorGradient.d.ts +0 -191
- package/colors/ColorInput.d.ts +0 -34
- package/colors/ColorPalette.d.ts +0 -127
- package/colors/ColorPicker.d.ts +0 -34
- package/colors/FlatColorPicker.d.ts +0 -139
- package/colors/HexInput.d.ts +0 -33
- package/colors/Picker.d.ts +0 -10
- package/colors/interfaces/ColorGradientChangeEvent.d.ts +0 -15
- package/colors/interfaces/ColorGradientProps.d.ts +0 -101
- package/colors/interfaces/ColorPaletteChangeEvent.d.ts +0 -19
- package/colors/interfaces/ColorPaletteProps.d.ts +0 -87
- package/colors/interfaces/ColorPickerActiveColorClick.d.ts +0 -21
- package/colors/interfaces/ColorPickerBlurEvent.d.ts +0 -17
- package/colors/interfaces/ColorPickerChangeEvent.d.ts +0 -21
- package/colors/interfaces/ColorPickerFocusEvent.d.ts +0 -17
- package/colors/interfaces/ColorPickerGradientSettings.d.ts +0 -22
- package/colors/interfaces/ColorPickerPaletteSettings.d.ts +0 -36
- package/colors/interfaces/ColorPickerPopupSettings.d.ts +0 -18
- package/colors/interfaces/ColorPickerProps.d.ts +0 -165
- package/colors/interfaces/ColorPickerView.d.ts +0 -14
- package/colors/interfaces/PickerPopupSettings.d.ts +0 -22
- package/colors/interfaces/PickerProps.d.ts +0 -46
- package/colors/models/hsva.d.ts +0 -13
- package/colors/models/output-format.d.ts +0 -8
- package/colors/models/palette-presets.d.ts +0 -57
- package/colors/models/rgb.d.ts +0 -12
- package/colors/models/rgba.d.ts +0 -13
- package/colors/models/table-cell.d.ts +0 -11
- package/colors/models/tile-size.d.ts +0 -15
- package/colors/utils/color-cache.d.ts +0 -34
- package/colors/utils/color-palette.service.d.ts +0 -16
- package/colors/utils/color-parser.d.ts +0 -69
- package/colors/utils/misc.d.ts +0 -19
- package/colors/utils/svg-calc.d.ts +0 -66
- package/input/Input.d.ts +0 -171
- package/input/InputClearValue.d.ts +0 -19
- package/input/InputPrefix.d.ts +0 -29
- package/input/InputSeparator.d.ts +0 -29
- package/input/InputSuffix.d.ts +0 -29
- package/input/InputValidationIcon.d.ts +0 -18
- package/input/interfaces/InputChangeEvent.d.ts +0 -15
- package/interfaces/Direction.d.ts +0 -5
- package/interfaces/ToggleBaseProps.d.ts +0 -12
- package/maskedtextbox/MaskedTextBox.d.ts +0 -238
- package/maskedtextbox/MaskedTextBoxProps.d.ts +0 -200
- package/maskedtextbox/masking.service.d.ts +0 -45
- package/maskedtextbox/parsing/combinators.d.ts +0 -13
- package/maskedtextbox/parsing/parsers.d.ts +0 -51
- package/maskedtextbox/parsing/result.d.ts +0 -27
- package/maskedtextbox/parsing/stream.d.ts +0 -26
- package/maskedtextbox/utils.d.ts +0 -20
- package/messages/index.d.ts +0 -169
- package/numerictextbox/NumericTextBox.d.ts +0 -18
- package/numerictextbox/interfaces/NumericTextBoxBlurEvent.d.ts +0 -11
- package/numerictextbox/interfaces/NumericTextBoxChangeEvent.d.ts +0 -15
- package/numerictextbox/interfaces/NumericTextBoxFocusEvent.d.ts +0 -11
- package/numerictextbox/interfaces/NumericTextBoxHandle.d.ts +0 -43
- package/numerictextbox/interfaces/NumericTextBoxProps.d.ts +0 -188
- package/numerictextbox/interfaces/NumericTextBoxState.d.ts +0 -19
- package/numerictextbox/utils/index.d.ts +0 -123
- package/package-metadata.d.ts +0 -9
- package/radiobutton/RadioButton.d.ts +0 -27
- package/radiobutton/RadioGroup.d.ts +0 -27
- package/radiobutton/interfaces/RadioButtonBlurEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioButtonChangeEvent.d.ts +0 -15
- package/radiobutton/interfaces/RadioButtonFocusEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioButtonProps.d.ts +0 -101
- package/radiobutton/interfaces/RadioGroupChangeEvent.d.ts +0 -15
- package/radiobutton/interfaces/RadioGroupFocusEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioGroupProps.d.ts +0 -90
- package/range-slider/RangeSlider.d.ts +0 -142
- package/range-slider/range-raducer.d.ts +0 -40
- package/rating/Rating.d.ts +0 -170
- package/rating/RatingItem.d.ts +0 -108
- package/rating/models/index.d.ts +0 -88
- package/rating/rating-reducer.d.ts +0 -36
- package/rating/utils/index.d.ts +0 -28
- package/signature/Signature.d.ts +0 -18
- package/signature/interfaces/SignatureBlurEvent.d.ts +0 -11
- package/signature/interfaces/SignatureChangeEvent.d.ts +0 -15
- package/signature/interfaces/SignatureCloseEvent.d.ts +0 -11
- package/signature/interfaces/SignatureFocusEvent.d.ts +0 -11
- package/signature/interfaces/SignatureHandle.d.ts +0 -46
- package/signature/interfaces/SignatureOpenEvent.d.ts +0 -11
- package/signature/interfaces/SignatureProps.d.ts +0 -198
- package/signature/interfaces/index.d.ts +0 -11
- package/signature/utils/index.d.ts +0 -8
- package/slider/Slider.d.ts +0 -197
- package/slider/SliderLabel.d.ts +0 -38
- package/switch/Switch.d.ts +0 -294
- package/textarea/TextArea.d.ts +0 -40
- package/textarea/interfaces/TextAreaBlurEvent.d.ts +0 -11
- package/textarea/interfaces/TextAreaChangeEvent.d.ts +0 -15
- package/textarea/interfaces/TextAreaFocusEvent.d.ts +0 -11
- package/textarea/interfaces/TextAreaProps.d.ts +0 -140
- package/textbox/Textbox.d.ts +0 -80
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as t from "react";
|
|
10
|
+
import { NumericTextBox as g } from "../numerictextbox/NumericTextBox.mjs";
|
|
11
|
+
import b from "./HexInput.mjs";
|
|
12
|
+
import { Button as u } from "@progress/kendo-react-buttons";
|
|
13
|
+
import { Label as o } from "@progress/kendo-react-labels";
|
|
14
|
+
import { caretAltExpandIcon as f } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { provideLocalizationService as x, registerForIntl as k, registerForLocalization as v } from "@progress/kendo-react-intl";
|
|
16
|
+
import { colorGradientR as n, messages as r, colorGradientHex as C, colorGradientG as E, colorGradientB as M, colorGradientA as R, colorGradientToggleInputsButton as l } from "../messages/index.mjs";
|
|
17
|
+
const i = ["rgba", "rgb", "hex"];
|
|
18
|
+
class p extends t.Component {
|
|
19
|
+
constructor(e) {
|
|
20
|
+
super(e), this.onRgbaRChange = (a) => {
|
|
21
|
+
this.dispatchRgbaChange({ r: a.value }, a);
|
|
22
|
+
}, this.onRgbaGChange = (a) => {
|
|
23
|
+
this.dispatchRgbaChange({ g: a.value }, a);
|
|
24
|
+
}, this.onRgbaBChange = (a) => {
|
|
25
|
+
this.dispatchRgbaChange({ b: a.value }, a);
|
|
26
|
+
}, this.onRgbaAChange = (a) => {
|
|
27
|
+
this.dispatchRgbaChange({ a: a.value }, a);
|
|
28
|
+
}, this.state = { inputMode: e.defaultInputMode || i[1] };
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
const e = x(this), a = e.toLanguageString(n, r[C]), s = e.toLanguageString(n, r[n]), c = e.toLanguageString(n, r[E]), h = e.toLanguageString(n, r[M]), d = e.toLanguageString(n, r[R]), m = e.toLanguageString(l, r[l]);
|
|
32
|
+
return /* @__PURE__ */ t.createElement("div", { className: "k-colorgradient-inputs k-hstack" }, /* @__PURE__ */ t.createElement("div", { className: "k-vstack" }, /* @__PURE__ */ t.createElement(
|
|
33
|
+
u,
|
|
34
|
+
{
|
|
35
|
+
"aria-label": m,
|
|
36
|
+
fillMode: "flat",
|
|
37
|
+
icon: "caret-alt-expand",
|
|
38
|
+
svgIcon: f,
|
|
39
|
+
className: "k-colorgradient-toggle-mode k-icon-button",
|
|
40
|
+
onClick: this.onToggleModeChange.bind(this)
|
|
41
|
+
}
|
|
42
|
+
)), this.state.inputMode === "hex" && /* @__PURE__ */ t.createElement("div", { className: "k-vstack k-flex-1" }, /* @__PURE__ */ t.createElement("span", { className: "k-hex-value k-textbox k-input" }, /* @__PURE__ */ t.createElement(
|
|
43
|
+
b,
|
|
44
|
+
{
|
|
45
|
+
hex: this.props.hex,
|
|
46
|
+
onHexChange: this.props.onHexChange,
|
|
47
|
+
disabled: this.props.disabled
|
|
48
|
+
}
|
|
49
|
+
)), /* @__PURE__ */ t.createElement(o, { className: "k-colorgradient-input-label" }, a)), (this.state.inputMode === "rgb" || this.state.inputMode === "rgba") && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", { className: "k-vstack" }, /* @__PURE__ */ t.createElement(
|
|
50
|
+
g,
|
|
51
|
+
{
|
|
52
|
+
inputType: "number",
|
|
53
|
+
value: this.props.rgba.r,
|
|
54
|
+
ariaLabel: String(this.props.rgba.r),
|
|
55
|
+
min: 0,
|
|
56
|
+
max: 255,
|
|
57
|
+
spinners: !1,
|
|
58
|
+
format: "n",
|
|
59
|
+
onChange: this.onRgbaRChange,
|
|
60
|
+
disabled: this.props.disabled
|
|
61
|
+
}
|
|
62
|
+
), /* @__PURE__ */ t.createElement(o, { className: "k-colorgradient-input-label" }, s)), /* @__PURE__ */ t.createElement("div", { className: "k-vstack" }, /* @__PURE__ */ t.createElement(
|
|
63
|
+
g,
|
|
64
|
+
{
|
|
65
|
+
inputType: "number",
|
|
66
|
+
value: this.props.rgba.g,
|
|
67
|
+
ariaLabel: String(this.props.rgba.g),
|
|
68
|
+
min: 0,
|
|
69
|
+
max: 255,
|
|
70
|
+
spinners: !1,
|
|
71
|
+
format: "n",
|
|
72
|
+
onChange: this.onRgbaGChange,
|
|
73
|
+
disabled: this.props.disabled
|
|
74
|
+
}
|
|
75
|
+
), /* @__PURE__ */ t.createElement(o, { className: "k-colorgradient-input-label" }, c)), /* @__PURE__ */ t.createElement("div", { className: "k-vstack" }, /* @__PURE__ */ t.createElement(
|
|
76
|
+
g,
|
|
77
|
+
{
|
|
78
|
+
inputType: "number",
|
|
79
|
+
value: this.props.rgba.b,
|
|
80
|
+
ariaLabel: String(this.props.rgba.b),
|
|
81
|
+
min: 0,
|
|
82
|
+
max: 255,
|
|
83
|
+
spinners: !1,
|
|
84
|
+
format: "n",
|
|
85
|
+
onChange: this.onRgbaBChange,
|
|
86
|
+
disabled: this.props.disabled
|
|
87
|
+
}
|
|
88
|
+
), /* @__PURE__ */ t.createElement(o, { className: "k-colorgradient-input-label" }, h))), this.state.inputMode === "rgba" && /* @__PURE__ */ t.createElement("div", { className: "k-vstack" }, this.props.opacity && /* @__PURE__ */ t.createElement(
|
|
89
|
+
g,
|
|
90
|
+
{
|
|
91
|
+
inputType: "number",
|
|
92
|
+
value: this.props.rgba.a,
|
|
93
|
+
ariaLabel: String(this.props.rgba.a),
|
|
94
|
+
min: 0,
|
|
95
|
+
max: 1,
|
|
96
|
+
step: 0.01,
|
|
97
|
+
spinners: !1,
|
|
98
|
+
format: "n2",
|
|
99
|
+
onChange: this.onRgbaAChange,
|
|
100
|
+
disabled: this.props.disabled
|
|
101
|
+
}
|
|
102
|
+
), this.props.opacity && /* @__PURE__ */ t.createElement(o, { className: "k-colorgradient-input-label" }, d)));
|
|
103
|
+
}
|
|
104
|
+
dispatchRgbaChange(e, a) {
|
|
105
|
+
let s = { ...this.props.rgba };
|
|
106
|
+
e.r !== void 0 && (s.r = e.r), e.g !== void 0 && (s.g = e.g), e.b !== void 0 && (s.b = e.b), e.a !== void 0 && (s.a = e.a), this.props.onRgbaChange(s, a);
|
|
107
|
+
}
|
|
108
|
+
onToggleModeChange() {
|
|
109
|
+
const e = i.length - 1 === i.indexOf(this.state.inputMode) ? 0 : i.indexOf(this.state.inputMode) + 1;
|
|
110
|
+
if (this.props.opacity)
|
|
111
|
+
this.setState({ inputMode: i[e] });
|
|
112
|
+
else {
|
|
113
|
+
const a = i[e] === "rgba" ? e + 1 : e;
|
|
114
|
+
this.setState({ inputMode: i[a] });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
k(p);
|
|
119
|
+
v(p);
|
|
120
|
+
export {
|
|
121
|
+
p as default
|
|
122
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),s=require("prop-types"),N=require("./utils/color-palette.service.js"),r=require("@progress/kendo-react-common"),R=require("../package-metadata.js"),D=require("./models/palette-presets.js"),I=require("./utils/misc.js"),L=require("./utils/color-parser.js");function O(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const a=O(T),b=24,C=10,m="office",c=class c extends a.Component{constructor(t){super(t),this.wrapper=null,this.paletteService=null,this.focus=()=>{this.wrapper&&this.wrapper.focus()},this.onKeyDown=e=>{switch(e.keyCode){case r.Keys.down:this.handleCellNavigation(0,1);break;case r.Keys.up:this.handleCellNavigation(0,-1);break;case r.Keys.right:this.handleCellNavigation(1,0);break;case r.Keys.left:this.handleCellNavigation(-1,0);break;case r.Keys.enter:this.handleEnter(e);break;default:return}e.preventDefault()},this.onColorClick=(e,o)=>{this.isUncontrolled?this.setState({selectedColor:e,focusedColor:e}):this.setState({focusedColor:e}),this.dispatchChangeEvent(e,o)},this.onFocus=e=>{this.paletteService&&(this.setState({focusedColor:this.state.selectedColor||this.paletteService.colorRows[0][0]}),this.props.onFocus&&this.props.onFocus.call(void 0,e))},this.onBlur=()=>{this.setState({focusedColor:void 0})},r.validatePackage(R.packageMetadata),this.state={selectedColor:this.props.value!==void 0?this.props.value:this.props.defaultValue,isFirstRender:!0}}get guid(){return this.props.id}render(){const t=this.getPaletteInfo(),e=this.paletteService=new N.ColorPaletteService;e.setColorMatrix(t.colors,t.columns);const o=e.getCellCoordsFor(this.state.selectedColor),i=e.getCellCoordsFor(this.state.focusedColor),l=r.classNames("k-colorpalette",{"k-disabled":this.props.disabled},this.props.className);return t.colors.length?a.createElement("div",{id:this.props.id,role:"grid",className:l,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,"aria-disabled":this.props.ariaDisabled||(this.props.disabled?"true":void 0),"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,tabIndex:r.getTabIndex(this.props.tabIndex,this.props.disabled),ref:h=>this.wrapper=h},a.createElement("table",{className:"k-colorpalette-table",role:"presentation"},a.createElement("tbody",{role:"rowgroup"},this.renderRows(e.colorRows,o,i)))):""}static getDerivedStateFromProps(t,e){if(!e.isFirstRender&&t.value!==void 0){if(t.value===""&&e.selectedColor!==void 0)return{selectedColor:void 0};if(t.value!==""&&t.value!==e.selectedColor)return{selectedColor:t.value}}else if(e.isFirstRender)return{isFirstRender:!1};return null}handleCellNavigation(t,e){if(this.paletteService)if(this.focusedColorCooridanates){const o=this.paletteService.getNextCell(this.focusedColorCooridanates,t,e);this.setState({focusedColor:this.paletteService.getColorAt(o)})}else this.setState({focusedColor:this.paletteService.colorRows[0][0]})}handleEnter(t){this.isUncontrolled&&this.setState({selectedColor:this.state.focusedColor}),this.dispatchChangeEvent(this.state.focusedColor,t)}dispatchChangeEvent(t,e){r.dispatchEvent(this.props.onChange,e,this,{value:t,rgbaValue:L.parseColor(t,"rgba")})}get focusedColorCooridanates(){return this.state.focusedColor&&this.paletteService?this.paletteService.getCellCoordsFor(this.state.focusedColor):void 0}get isUncontrolled(){return this.props.value===void 0}getPaletteInfo(){if(typeof this.props.palette=="string"){const t=D.PALETTEPRESETS[this.props.palette];return I.isPresent(t)?{colors:t.colors,columns:this.props.columns||t.columns||C}:{colors:[],columns:0}}else return{colors:this.props.palette||[],columns:this.props.columns||C}}renderRows(t,e,o){return t.map((i,l)=>a.createElement("tr",{role:"row",key:l},this.renderColumns(i,l,e,o)))}renderColumns(t,e,o,i){const l=o!==void 0&&o.row===e,h=o&&o.col,E=i!==void 0&&i.row===e,w=i&&i.col,f=typeof this.props.tileSize!="number"?this.props.tileSize:{width:this.props.tileSize,height:this.props.tileSize},g=f.width+"px",P=f.height+"px";return t.map((u,d)=>{const v=l&&h===d,k=r.classNames("k-colorpalette-tile",{"k-selected":v,"k-focus":E&&w===d});return a.createElement("td",{role:"gridcell",className:k,"aria-label":u,"aria-selected":v?!0:this.props.disabled?void 0:!1,style:{backgroundColor:u,width:g,height:P,minWidth:g},onClick:F=>this.onColorClick(u,F),id:this.createCellId({row:e,col:d}),key:d})})}createCellId(t){return`${this.guid}_${t.row}_${t.col}`}};c.displayName="ColorPalette",c.propTypes={palette:s.oneOfType([s.arrayOf(s.string.isRequired),s.string]),columns:s.number,tileSize:s.any,defaultValue:s.string,value:s.string,disabled:s.bool,tabIndex:s.number,onChange:s.func,onFocus:s.func,id:s.string,ariaLabelledBy:s.string,ariaDescribedBy:s.string,className:s.string},c.defaultProps={palette:m,tileSize:b};let p=c;const S=r.createPropsContext(),y=r.withIdHOC(r.withPropsContext(S,p));y.displayName="KendoReactColorPalette";exports.ColorPalette=y;exports.ColorPalettePropsContext=S;exports.ColorPaletteWithoutContext=p;exports.DEFAULT_COLUMNS_COUNT=C;exports.DEFAULT_PRESET=m;exports.DEFAULT_TILE_SIZE=b;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as l from "react";
|
|
10
|
+
import s from "prop-types";
|
|
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";
|
|
13
|
+
import { packageMetadata as I } from "../package-metadata.mjs";
|
|
14
|
+
import { PALETTEPRESETS as D } from "./models/palette-presets.mjs";
|
|
15
|
+
import { isPresent as L } from "./utils/misc.mjs";
|
|
16
|
+
import { parseColor as U } from "./utils/color-parser.mjs";
|
|
17
|
+
const x = 24, g = 10, z = "office", n = class n extends l.Component {
|
|
18
|
+
constructor(t) {
|
|
19
|
+
super(t), this.wrapper = null, this.paletteService = null, this.focus = () => {
|
|
20
|
+
this.wrapper && this.wrapper.focus();
|
|
21
|
+
}, this.onKeyDown = (e) => {
|
|
22
|
+
switch (e.keyCode) {
|
|
23
|
+
case a.down:
|
|
24
|
+
this.handleCellNavigation(0, 1);
|
|
25
|
+
break;
|
|
26
|
+
case a.up:
|
|
27
|
+
this.handleCellNavigation(0, -1);
|
|
28
|
+
break;
|
|
29
|
+
case a.right:
|
|
30
|
+
this.handleCellNavigation(1, 0);
|
|
31
|
+
break;
|
|
32
|
+
case a.left:
|
|
33
|
+
this.handleCellNavigation(-1, 0);
|
|
34
|
+
break;
|
|
35
|
+
case a.enter:
|
|
36
|
+
this.handleEnter(e);
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
}, this.onColorClick = (e, o) => {
|
|
43
|
+
this.isUncontrolled ? this.setState({ selectedColor: e, focusedColor: e }) : this.setState({ focusedColor: e }), this.dispatchChangeEvent(e, o);
|
|
44
|
+
}, this.onFocus = (e) => {
|
|
45
|
+
this.paletteService && (this.setState({ focusedColor: this.state.selectedColor || this.paletteService.colorRows[0][0] }), this.props.onFocus && this.props.onFocus.call(
|
|
46
|
+
void 0,
|
|
47
|
+
e
|
|
48
|
+
));
|
|
49
|
+
}, this.onBlur = () => {
|
|
50
|
+
this.setState({ focusedColor: void 0 });
|
|
51
|
+
}, k(I), this.state = {
|
|
52
|
+
selectedColor: this.props.value !== void 0 ? this.props.value : this.props.defaultValue,
|
|
53
|
+
isFirstRender: !0
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
get guid() {
|
|
57
|
+
return this.props.id;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
render() {
|
|
63
|
+
const t = this.getPaletteInfo(), e = this.paletteService = new E();
|
|
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(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
id: this.props.id,
|
|
70
|
+
role: "grid",
|
|
71
|
+
className: i,
|
|
72
|
+
onFocus: this.onFocus,
|
|
73
|
+
onBlur: this.onBlur,
|
|
74
|
+
onKeyDown: this.onKeyDown,
|
|
75
|
+
"aria-disabled": this.props.ariaDisabled || (this.props.disabled ? "true" : void 0),
|
|
76
|
+
"aria-labelledby": this.props.ariaLabelledBy,
|
|
77
|
+
"aria-describedby": this.props.ariaDescribedBy,
|
|
78
|
+
tabIndex: F(this.props.tabIndex, this.props.disabled),
|
|
79
|
+
ref: (d) => this.wrapper = d
|
|
80
|
+
},
|
|
81
|
+
/* @__PURE__ */ l.createElement("table", { className: "k-colorpalette-table", role: "presentation" }, /* @__PURE__ */ l.createElement("tbody", { role: "rowgroup" }, this.renderRows(e.colorRows, o, r)))
|
|
82
|
+
) : "";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @hidden
|
|
86
|
+
*/
|
|
87
|
+
static getDerivedStateFromProps(t, e) {
|
|
88
|
+
if (!e.isFirstRender && t.value !== void 0) {
|
|
89
|
+
if (t.value === "" && e.selectedColor !== void 0)
|
|
90
|
+
return { selectedColor: void 0 };
|
|
91
|
+
if (t.value !== "" && t.value !== e.selectedColor)
|
|
92
|
+
return { selectedColor: t.value };
|
|
93
|
+
} else if (e.isFirstRender)
|
|
94
|
+
return { isFirstRender: !1 };
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
handleCellNavigation(t, e) {
|
|
98
|
+
if (this.paletteService)
|
|
99
|
+
if (this.focusedColorCooridanates) {
|
|
100
|
+
const o = this.paletteService.getNextCell(
|
|
101
|
+
this.focusedColorCooridanates,
|
|
102
|
+
t,
|
|
103
|
+
e
|
|
104
|
+
);
|
|
105
|
+
this.setState({ focusedColor: this.paletteService.getColorAt(o) });
|
|
106
|
+
} else
|
|
107
|
+
this.setState({ focusedColor: this.paletteService.colorRows[0][0] });
|
|
108
|
+
}
|
|
109
|
+
handleEnter(t) {
|
|
110
|
+
this.isUncontrolled && this.setState({ selectedColor: this.state.focusedColor }), this.dispatchChangeEvent(this.state.focusedColor, t);
|
|
111
|
+
}
|
|
112
|
+
dispatchChangeEvent(t, e) {
|
|
113
|
+
N(this.props.onChange, e, this, { value: t, rgbaValue: U(t, "rgba") });
|
|
114
|
+
}
|
|
115
|
+
get focusedColorCooridanates() {
|
|
116
|
+
return this.state.focusedColor && this.paletteService ? this.paletteService.getCellCoordsFor(this.state.focusedColor) : void 0;
|
|
117
|
+
}
|
|
118
|
+
get isUncontrolled() {
|
|
119
|
+
return this.props.value === void 0;
|
|
120
|
+
}
|
|
121
|
+
getPaletteInfo() {
|
|
122
|
+
if (typeof this.props.palette == "string") {
|
|
123
|
+
const t = D[this.props.palette];
|
|
124
|
+
return L(t) ? {
|
|
125
|
+
colors: t.colors,
|
|
126
|
+
columns: this.props.columns || t.columns || g
|
|
127
|
+
} : { colors: [], columns: 0 };
|
|
128
|
+
} else
|
|
129
|
+
return { colors: this.props.palette || [], columns: this.props.columns || g };
|
|
130
|
+
}
|
|
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)));
|
|
133
|
+
}
|
|
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(
|
|
138
|
+
"k-colorpalette-tile",
|
|
139
|
+
{
|
|
140
|
+
"k-selected": C,
|
|
141
|
+
"k-focus": v && b === c
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
return /* @__PURE__ */ l.createElement(
|
|
145
|
+
"td",
|
|
146
|
+
{
|
|
147
|
+
role: "gridcell",
|
|
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),
|
|
153
|
+
id: this.createCellId({ row: e, col: c }),
|
|
154
|
+
key: c
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
createCellId(t) {
|
|
160
|
+
return `${this.guid}_${t.row}_${t.col}`;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
n.displayName = "ColorPalette", n.propTypes = {
|
|
164
|
+
palette: s.oneOfType([s.arrayOf(s.string.isRequired), s.string]),
|
|
165
|
+
columns: s.number,
|
|
166
|
+
tileSize: s.any,
|
|
167
|
+
defaultValue: s.string,
|
|
168
|
+
value: s.string,
|
|
169
|
+
disabled: s.bool,
|
|
170
|
+
tabIndex: s.number,
|
|
171
|
+
onChange: s.func,
|
|
172
|
+
onFocus: s.func,
|
|
173
|
+
id: s.string,
|
|
174
|
+
ariaLabelledBy: s.string,
|
|
175
|
+
ariaDescribedBy: s.string,
|
|
176
|
+
className: s.string
|
|
177
|
+
}, n.defaultProps = {
|
|
178
|
+
palette: z,
|
|
179
|
+
tileSize: x
|
|
180
|
+
};
|
|
181
|
+
let h = n;
|
|
182
|
+
const B = P(), A = R(T(B, h));
|
|
183
|
+
A.displayName = "KendoReactColorPalette";
|
|
184
|
+
export {
|
|
185
|
+
A as ColorPalette,
|
|
186
|
+
B as ColorPalettePropsContext,
|
|
187
|
+
h as ColorPaletteWithoutContext,
|
|
188
|
+
g as DEFAULT_COLUMNS_COUNT,
|
|
189
|
+
z as DEFAULT_PRESET,
|
|
190
|
+
x as DEFAULT_TILE_SIZE
|
|
191
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
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"),M=require("./ColorPalette.js"),pe=require("@progress/kendo-react-buttons"),fe=require("@progress/kendo-svg-icons"),A=require("../messages/index.js"),me=require("@progress/kendo-react-intl");function ke(l){const m=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const o in l)if(o!=="default"){const k=Object.getOwnPropertyDescriptor(l,o);Object.defineProperty(m,o,k.get?k:{enumerable:!0,get:()=>l[o]})}}return m.default=l,Object.freeze(m)}const e=ke(ce),be={opacity:!0},ge={palette:M.DEFAULT_PRESET,tileSize:M.DEFAULT_TILE_SIZE},B=l=>l!==void 0,z=n.createPropsContext(),C=e.forwardRef((l,m)=>{n.validatePackage(ie.packageMetadata);const o=n.usePropsContext(z,l),k=me.useLocalization(),{size:E=v.size,rounded:y=v.rounded,fillMode:q=v.fillMode,popupSettings:F,gradientSettings:H,paletteSettings:V,valid:j,disabled:P,tabIndex:G,view:b,icon:T,svgIcon:S,iconClassName:g,onChange:w,onFocus:I,onBlur:R,onActiveColorClick:D,className:U}=o,r=e.useRef(null),N=e.useRef(null),O=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),h=B(o.value),i=B(o.open),c=h?o.value:Z,p=i?o.open:Q,K=e.useCallback(()=>{r.current&&r.current.focus()},[]);e.useImperativeHandle(m,()=>({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||(N.current?N.current.focus():O.current&&O.current.focus())},[i]),te=e.useCallback(()=>{u(!p,!0)},[p]),ne=e.useCallback(t=>{D&&D.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:c})},[D,c]),oe=e.useCallback(t=>{d.current?(clearTimeout(d.current),d.current=void 0):x(!0),I&&I.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[I]),ae=e.useCallback(()=>{u(!1,!0),x(!1),d.current=void 0},[]),re=e.useCallback(t=>{clearTimeout(d.current),d.current=window.setTimeout(ae),R&&R.call(void 0,{nativeEvent:t.nativeEvent,syntheticEvent:t})},[R]),L=e.useCallback((t,f)=>{const s=f?t.rgbaValue:t.value;h||J(s),f&&u(!1),w&&w.call(void 0,{value:s,nativeEvent:t.nativeEvent,syntheticEvent:t.syntheticEvent})},[h,w]),le=e.useCallback(t=>L(t,!0),[B,L]),_=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":P?"true":void 0,className:n.classNames("k-colorpicker","k-picker","k-icon-picker",{[`k-picker-${n.kendoThemeMaps.sizeMap[E]||E}`]:E,[`k-picker-${q}`]:q,[`k-rounded-${n.kendoThemeMaps.roundedMap[y]||y}`]:y,"k-invalid":!se,"k-disabled":P,"k-focus":W,className:U}),ref:r,tabIndex:n.getTabIndex(G,P),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:{...F},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":T||S||g})},g&&e.createElement("span",{className:n.classNames("k-color-preview-icon",g)}),!g&&(T||S)&&e.createElement(n.IconWrap,{name:T,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":k.toLanguageString(A.colorPickerDropdownButtonAriaLabel,A.messages[A.colorPickerDropdownButtonAriaLabel])}),content:e.createElement(e.Fragment,null,(b==="combo"||b==="gradient")&&e.createElement(de.ColorGradient,{...H,tabIndex:0,ref:N,value:c,onChange:L}),(b==="combo"||b==="palette")&&e.createElement(M.ColorPalette,{...V,ref:O,value:c,onChange:le}))}))});C.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 v={size:"medium",rounded:"medium",fillMode:"solid",view:"palette",gradientSettings:be,paletteSettings:ge};C.defaultProps=v;C.displayName="KendoColorPicker";exports.ColorPicker=C;exports.ColorPickerPropsContext=z;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
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 O, 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 be } from "./Picker.mjs";
|
|
14
|
+
import { ColorGradient as ve } 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 z, messages as Se } from "../messages/index.mjs";
|
|
19
|
+
import { useLocalization as Pe } from "@progress/kendo-react-intl";
|
|
20
|
+
const we = {
|
|
21
|
+
opacity: !0
|
|
22
|
+
}, Ie = {
|
|
23
|
+
palette: Ee,
|
|
24
|
+
tileSize: Ce
|
|
25
|
+
}, L = (b) => b !== void 0, De = se(), A = e.forwardRef((b, M) => {
|
|
26
|
+
ce(ke);
|
|
27
|
+
const o = ue(De, b), V = Pe(), {
|
|
28
|
+
size: v = k.size,
|
|
29
|
+
rounded: g = k.rounded,
|
|
30
|
+
fillMode: x = k.fillMode,
|
|
31
|
+
popupSettings: _,
|
|
32
|
+
gradientSettings: K,
|
|
33
|
+
paletteSettings: G,
|
|
34
|
+
valid: U,
|
|
35
|
+
disabled: E,
|
|
36
|
+
tabIndex: $,
|
|
37
|
+
view: f,
|
|
38
|
+
icon: C,
|
|
39
|
+
svgIcon: y,
|
|
40
|
+
iconClassName: m,
|
|
41
|
+
onChange: T,
|
|
42
|
+
onFocus: S,
|
|
43
|
+
onBlur: P,
|
|
44
|
+
onActiveColorClick: w,
|
|
45
|
+
className: W
|
|
46
|
+
} = o, a = e.useRef(null), I = e.useRef(null), D = e.useRef(null), c = e.useRef(), Z = e.useRef(null), [j, B] = 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, F = e.useCallback(
|
|
47
|
+
() => {
|
|
48
|
+
a.current && a.current.focus();
|
|
49
|
+
},
|
|
50
|
+
[]
|
|
51
|
+
);
|
|
52
|
+
e.useImperativeHandle(M, () => ({
|
|
53
|
+
// we agreed that each element will have focus method exposed
|
|
54
|
+
element: a.current,
|
|
55
|
+
actionElement: Z.current,
|
|
56
|
+
value: l,
|
|
57
|
+
focus: F
|
|
58
|
+
}), [l, F]);
|
|
59
|
+
const s = e.useCallback(
|
|
60
|
+
(t, d) => {
|
|
61
|
+
i || (!t && !d && a && a.current && a.current.focus(), X(t));
|
|
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;
|
|
74
|
+
}
|
|
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(
|
|
79
|
+
() => {
|
|
80
|
+
i || (I.current ? I.current.focus() : D.current && D.current.focus());
|
|
81
|
+
},
|
|
82
|
+
[i]
|
|
83
|
+
), te = e.useCallback(
|
|
84
|
+
() => {
|
|
85
|
+
s(!u, !0);
|
|
86
|
+
},
|
|
87
|
+
[u]
|
|
88
|
+
), ne = e.useCallback(
|
|
89
|
+
(t) => {
|
|
90
|
+
w && w.call(void 0, {
|
|
91
|
+
syntheticEvent: t,
|
|
92
|
+
nativeEvent: t.nativeEvent,
|
|
93
|
+
value: l
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
[w, l]
|
|
97
|
+
), oe = e.useCallback(
|
|
98
|
+
(t) => {
|
|
99
|
+
c.current ? (clearTimeout(c.current), c.current = void 0) : B(!0), S && S.call(void 0, {
|
|
100
|
+
nativeEvent: t.nativeEvent,
|
|
101
|
+
syntheticEvent: t
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
[S]
|
|
105
|
+
), ae = e.useCallback(
|
|
106
|
+
() => {
|
|
107
|
+
s(!1, !0), B(!1), c.current = void 0;
|
|
108
|
+
},
|
|
109
|
+
[]
|
|
110
|
+
), re = e.useCallback(
|
|
111
|
+
(t) => {
|
|
112
|
+
clearTimeout(c.current), c.current = window.setTimeout(ae), P && P.call(void 0, {
|
|
113
|
+
nativeEvent: t.nativeEvent,
|
|
114
|
+
syntheticEvent: t
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
[P]
|
|
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,
|
|
123
|
+
nativeEvent: t.nativeEvent,
|
|
124
|
+
syntheticEvent: t.syntheticEvent
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
[N, T]
|
|
128
|
+
), le = e.useCallback(
|
|
129
|
+
(t) => R(t, !0),
|
|
130
|
+
[L, R]
|
|
131
|
+
), H = de(a, o.dir), ie = U !== !1;
|
|
132
|
+
return /* @__PURE__ */ e.createElement(
|
|
133
|
+
"span",
|
|
134
|
+
{
|
|
135
|
+
id: o.id,
|
|
136
|
+
role: "combobox",
|
|
137
|
+
"aria-label": o.ariaLabel,
|
|
138
|
+
"aria-labelledby": o.ariaLabelledBy,
|
|
139
|
+
"aria-describedby": o.ariaDescribedBy,
|
|
140
|
+
"aria-haspopup": "dialog",
|
|
141
|
+
"aria-expanded": u,
|
|
142
|
+
"aria-disabled": E ? "true" : void 0,
|
|
143
|
+
className: h(
|
|
144
|
+
"k-colorpicker",
|
|
145
|
+
"k-picker",
|
|
146
|
+
"k-icon-picker",
|
|
147
|
+
{
|
|
148
|
+
[`k-picker-${O.sizeMap[v] || v}`]: v,
|
|
149
|
+
[`k-picker-${x}`]: x,
|
|
150
|
+
[`k-rounded-${O.roundedMap[g] || g}`]: g,
|
|
151
|
+
"k-invalid": !ie,
|
|
152
|
+
"k-disabled": E,
|
|
153
|
+
"k-focus": j,
|
|
154
|
+
className: W
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
ref: a,
|
|
158
|
+
tabIndex: pe($, E),
|
|
159
|
+
title: o.title,
|
|
160
|
+
onKeyDown: Y,
|
|
161
|
+
onFocus: oe,
|
|
162
|
+
onBlur: re,
|
|
163
|
+
dir: H
|
|
164
|
+
},
|
|
165
|
+
/* @__PURE__ */ e.createElement(
|
|
166
|
+
be,
|
|
167
|
+
{
|
|
168
|
+
dir: H,
|
|
169
|
+
open: u,
|
|
170
|
+
onOpen: ee,
|
|
171
|
+
popupAnchor: a.current || void 0,
|
|
172
|
+
popupSettings: { ..._ },
|
|
173
|
+
input: /* @__PURE__ */ e.createElement("span", { onClick: ne, className: "k-input-inner" }, /* @__PURE__ */ e.createElement(
|
|
174
|
+
"span",
|
|
175
|
+
{
|
|
176
|
+
className: h(
|
|
177
|
+
"k-value-icon",
|
|
178
|
+
"k-color-preview",
|
|
179
|
+
{
|
|
180
|
+
"k-no-color": !l,
|
|
181
|
+
"k-icon-color-preview": C || y || m
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
},
|
|
185
|
+
m && /* @__PURE__ */ e.createElement("span", { className: h("k-color-preview-icon", m) }),
|
|
186
|
+
!m && (C || y) && /* @__PURE__ */ e.createElement(fe, { name: C, icon: y }),
|
|
187
|
+
/* @__PURE__ */ e.createElement("span", { className: "k-color-preview-mask", style: { backgroundColor: l } })
|
|
188
|
+
)),
|
|
189
|
+
button: /* @__PURE__ */ e.createElement(
|
|
190
|
+
ye,
|
|
191
|
+
{
|
|
192
|
+
tabIndex: -1,
|
|
193
|
+
type: "button",
|
|
194
|
+
onClick: te,
|
|
195
|
+
className: "k-input-button",
|
|
196
|
+
rounded: null,
|
|
197
|
+
icon: "caret-alt-down",
|
|
198
|
+
svgIcon: Te,
|
|
199
|
+
"aria-label": V.toLanguageString(z, Se[z])
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
content: /* @__PURE__ */ e.createElement(e.Fragment, null, (f === "combo" || f === "gradient") && /* @__PURE__ */ e.createElement(
|
|
203
|
+
ve,
|
|
204
|
+
{
|
|
205
|
+
...K,
|
|
206
|
+
tabIndex: 0,
|
|
207
|
+
ref: I,
|
|
208
|
+
value: l,
|
|
209
|
+
onChange: R
|
|
210
|
+
}
|
|
211
|
+
), (f === "combo" || f === "palette") && /* @__PURE__ */ e.createElement(
|
|
212
|
+
ge,
|
|
213
|
+
{
|
|
214
|
+
...G,
|
|
215
|
+
ref: D,
|
|
216
|
+
value: l,
|
|
217
|
+
onChange: le
|
|
218
|
+
}
|
|
219
|
+
))
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
A.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
|
|
239
|
+
};
|
|
240
|
+
const k = {
|
|
241
|
+
size: "medium",
|
|
242
|
+
rounded: "medium",
|
|
243
|
+
fillMode: "solid",
|
|
244
|
+
view: "palette",
|
|
245
|
+
gradientSettings: we,
|
|
246
|
+
paletteSettings: Ie
|
|
247
|
+
};
|
|
248
|
+
A.defaultProps = k;
|
|
249
|
+
A.displayName = "KendoColorPicker";
|
|
250
|
+
export {
|
|
251
|
+
A as ColorPicker,
|
|
252
|
+
De as ColorPickerPropsContext
|
|
253
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react"),l=require("prop-types"),m=require("@progress/kendo-react-common"),d=require("@progress/kendo-react-buttons"),h=require("@progress/kendo-svg-icons"),_=require("./ColorPalette.js"),z=require("./ColorGradient.js"),D=require("../package-metadata.js"),H=require("@progress/kendo-react-intl"),n=require("../messages/index.js");function A(e){const v=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(v,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return v.default=e,Object.freeze(v)}const t=A(j),S="rgba(255, 255, 255, 1)",y=t.forwardRef((e,v)=>{m.validatePackage(D.packageMetadata);const o=t.useRef(null),r=t.useRef(null),G=t.useRef(null),{defaultValue:s=S,showButtons:k=!0,showPreview:R=!0,showClearButton:q=!0}=e,[u,L]=t.useState((e.view||"ColorGradient")==="ColorGradient"),[c,g]=t.useState(e.value||s),[C,b]=t.useState(e.value||s),E=e.value!==void 0?e.value:C;t.useEffect(()=>{g(e.value||s)},[e.value,s]);const f=H.useLocalization(),P=t.useCallback(()=>{o.current&&o.current.focus()},[o]);t.useImperativeHandle(o,()=>({element:r.current,focus:P,props:e,value:E}),[E,P,e]),t.useImperativeHandle(v,()=>o.current);const w=t.useCallback(a=>{(a==="ColorGradient"&&!u||a==="ColorPalette"&&u)&&L(!u)},[u]),x=t.useCallback(a=>{if(g(s),e.onPreviewChange){const i={value:s,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,i)}},[s,e.onPreviewChange]),B=t.useCallback(a=>{if(g(a.value),e.onPreviewChange){const i={value:a.value,nativeEvent:a.nativeEvent,syntheticEvent:a.syntheticEvent};e.onPreviewChange.call(void 0,i)}},[e.onPreviewChange]),F=t.useCallback(a=>{if(b(c),e.onChange){const i={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,i)}},[c,e.onChange]),M=t.useCallback(()=>{b(S)},[]),T=t.useCallback(a=>{if(g(C),e.onPreviewChange){const i={value:C,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onPreviewChange.call(void 0,i)}},[C,e.onPreviewChange]),N=t.useCallback(a=>{r.current&&!(a.nativeEvent.target instanceof HTMLInputElement)&&r.current.focus()},[r]),V=t.useCallback(a=>{var I;if((!a.relatedTarget||!((I=r.current)!=null&&I.contains(a.relatedTarget)))&&(k||b(c),!k&&e.onChange)){const O={value:c,nativeEvent:a.nativeEvent,syntheticEvent:a};e.onChange.call(void 0,O)}},[c,k,e.onChange]);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:e.style,ref:r,tabIndex:m.getTabIndex(e.tabIndex,e.disabled),className:m.classNames("k-flatcolorpicker k-coloreditor",{"k-disabled":e.disabled},e.className),onBlur:V},t.createElement(t.Fragment,null,e.header||t.createElement("div",{className:"k-coloreditor-header k-hstack"},t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},t.createElement(d.ButtonGroup,{className:"k-button-group-flat"},t.createElement(d.Button,{type:"button","aria-label":f.toLanguageString(n.flatColorPickerColorGradientBtn,n.messages[n.flatColorPickerColorGradientBtn]),togglable:!0,fillMode:"flat",selected:u,onClick:()=>w("ColorGradient"),icon:"droplet-slider",svgIcon:h.dropletSliderIcon}),t.createElement(d.Button,{type:"button","aria-label":f.toLanguageString(n.flatColorPickerColorPaletteBtn,n.messages[n.flatColorPickerColorPaletteBtn]),togglable:!0,fillMode:"flat",selected:!u,onClick:()=>w("ColorPalette"),icon:"palette",svgIcon:h.paletteIcon}))),t.createElement("div",{className:"k-spacer"}),t.createElement("div",{className:"k-coloreditor-header-actions k-hstack"},q&&t.createElement(d.Button,{type:"button",fillMode:"flat",onClick:x,"aria-label":f.toLanguageString(n.flatColorPickerClearBtn,n.messages[n.flatColorPickerClearBtn]),icon:"droplet-slash",svgIcon:h.dropletSlashIcon}),R&&t.createElement("div",{className:"k-coloreditor-preview k-vstack"},t.createElement("span",{className:"k-coloreditor-preview-color k-color-preview",style:{background:c}}),t.createElement("span",{className:"k-coloreditor-current-color k-color-preview",style:{background:C},onClick:T})))),t.createElement("div",{className:"k-coloreditor-views k-vstack"},u?t.createElement(z.ColorGradient,{ref:G,role:"none",tabIndex:-1,ariaLabel:void 0,value:c,onChange:B,onFocus:N,opacity:e.opacity,format:e.format}):t.createElement(_.ColorPalette,{ariaDisabled:!0,ariaLabelledBy:"required_label",value:c,onChange:B,onFocus:N})),k&&t.createElement("div",{className:"k-coloreditor-footer k-actions k-actions-end"},t.createElement(d.Button,{type:"button",className:"k-coloreditor-cancel",onClick:M},n.messages[n.flatColorPickerCancelBtn]),t.createElement(d.Button,{type:"button",className:"k-coloreditor-apply k-primary",onClick:F},n.messages[n.flatColorPickerApplyBtn]))))}),K={id:l.string,style:l.any,className:l.string,value:l.string,defaultValue:l.string,onPreviewChange:l.func,onChange:l.func,opacity:l.bool,format:l.any,tabIndex:l.number,ariaLabel:l.string,ariaLabelledBy:l.string,disabled:l.bool,view:l.any,header:l.any,showClearButton:l.bool,showPreview:l.bool,showButtons:l.bool};y.displayName="KendoFlatColorPicker";y.propTypes=K;exports.FlatColorPicker=y;
|