@progress/kendo-vue-inputs 6.1.0-develop.4 → 6.1.0-develop.6
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/ColorGradient.js +2 -2
- package/colors/ColorGradient.mjs +104 -89
- package/colors/ColorInput.js +1 -1
- package/colors/ColorInput.mjs +68 -61
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +68 -59
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +113 -57
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +82 -60
- package/colors/HexInput.js +1 -1
- package/colors/HexInput.mjs +13 -11
- package/colors/common/ColorsAdaptiveMode.js +8 -0
- package/colors/common/ColorsAdaptiveMode.mjs +91 -0
- package/colors/utils/color-cache.js +1 -1
- package/colors/utils/color-cache.mjs +2 -7
- package/dist/cdn/js/kendo-vue-inputs.js +1 -1
- package/index.d.mts +116 -7
- package/index.d.ts +116 -7
- package/messages/main.js +2 -2
- package/messages/main.mjs +26 -24
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +9 -9
package/colors/ColorInput.mjs
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { defineComponent as R, createVNode as
|
|
9
|
-
import { HexInput as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { Label as
|
|
12
|
-
import { provideLocalizationService as
|
|
13
|
-
import { colorGradientHex as
|
|
14
|
-
import { guid as
|
|
15
|
-
import { caretAltExpandIcon as
|
|
8
|
+
import { defineComponent as R, createVNode as t, isVNode as S } from "vue";
|
|
9
|
+
import { HexInput as z } from "./HexInput.mjs";
|
|
10
|
+
import { Button as G } from "@progress/kendo-vue-buttons";
|
|
11
|
+
import { Label as o } from "@progress/kendo-vue-labels";
|
|
12
|
+
import { provideLocalizationService as B } from "@progress/kendo-vue-intl";
|
|
13
|
+
import { colorGradientHex as c, messages as a, colorGradientInputColorButton as b, colorGradientR as u, colorGradientG as f, colorGradientB as m, colorGradientA as x, colorGradientRLabel as $, colorGradientGLabel as k, colorGradientBLabel as C, colorGradientALabel as I } from "../messages/main.mjs";
|
|
14
|
+
import { guid as T, Keys as j } from "@progress/kendo-vue-common";
|
|
15
|
+
import { caretAltExpandIcon as A } from "@progress/kendo-svg-icons";
|
|
16
16
|
import { NumericTextBox as l } from "../numerictextbox/NumericTextBox.mjs";
|
|
17
17
|
function r(e) {
|
|
18
18
|
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !S(e);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const s = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
21
21
|
name: "KendoColorInput",
|
|
22
22
|
emits: {
|
|
23
23
|
hexchange: null,
|
|
@@ -33,7 +33,8 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
33
33
|
},
|
|
34
34
|
hex: String,
|
|
35
35
|
opacity: Boolean,
|
|
36
|
-
disabled: Boolean
|
|
36
|
+
disabled: Boolean,
|
|
37
|
+
size: String
|
|
37
38
|
},
|
|
38
39
|
inject: {
|
|
39
40
|
kendoLocalizationService: {
|
|
@@ -41,11 +42,11 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
created() {
|
|
44
|
-
this.hexInputId =
|
|
45
|
+
this.hexInputId = T();
|
|
45
46
|
},
|
|
46
47
|
data() {
|
|
47
48
|
return {
|
|
48
|
-
inputMode:
|
|
49
|
+
inputMode: s[1]
|
|
49
50
|
};
|
|
50
51
|
},
|
|
51
52
|
mounted() {
|
|
@@ -55,40 +56,42 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
55
56
|
this.lastFocusable = this.$refs.hexinput || this.$refs.numerica || this.$refs.numericb;
|
|
56
57
|
},
|
|
57
58
|
render() {
|
|
58
|
-
const e =
|
|
59
|
-
return
|
|
59
|
+
const e = B(this), i = e.toLanguageString(c, a[c]), n = e.toLanguageString(b, a[b]), g = e.toLanguageString(u, a[u]), d = e.toLanguageString(f, a[f]), p = e.toLanguageString(m, a[m]), h = e.toLanguageString(x, a[x]), L = e.toLanguageString($, a[$]), v = e.toLanguageString(k, a[k]), M = e.toLanguageString(C, a[C]), y = e.toLanguageString(I, a[I]);
|
|
60
|
+
return t("div", {
|
|
60
61
|
class: "k-colorgradient-inputs k-hstack"
|
|
61
|
-
}, [
|
|
62
|
+
}, [t("div", {
|
|
62
63
|
class: "k-vstack"
|
|
63
|
-
}, [
|
|
64
|
-
ariaLabel:
|
|
64
|
+
}, [t(G, {
|
|
65
|
+
ariaLabel: n,
|
|
65
66
|
tabIndex: this.tabIndex,
|
|
66
67
|
type: "button",
|
|
67
68
|
fillMode: "flat",
|
|
68
69
|
icon: "caret-alt-expand",
|
|
69
|
-
svgIcon:
|
|
70
|
+
svgIcon: A,
|
|
70
71
|
class: "k-colorgradient-toggle-mode k-icon-button",
|
|
71
72
|
onClick: this.onToggleModeChange,
|
|
72
|
-
onKeydown: this.onKeyDown
|
|
73
|
-
|
|
73
|
+
onKeydown: this.onKeyDown,
|
|
74
|
+
size: this.$props.size
|
|
75
|
+
}, null)]), this.inputMode === "hex" && t("div", {
|
|
74
76
|
class: "k-vstack k-flex-1"
|
|
75
|
-
}, [
|
|
77
|
+
}, [t("span", {
|
|
76
78
|
class: "k-hex-value"
|
|
77
|
-
}, [
|
|
79
|
+
}, [t(z, {
|
|
78
80
|
id: this.hexInputId,
|
|
79
81
|
tabIndex: this.tabIndex,
|
|
80
82
|
hex: this.$props.hex,
|
|
81
83
|
onHexchange: this.onHexChange,
|
|
82
84
|
disabled: this.$props.disabled,
|
|
83
|
-
ref: "hexinput"
|
|
84
|
-
|
|
85
|
+
ref: "hexinput",
|
|
86
|
+
size: this.$props.size
|
|
87
|
+
}, null)]), t(o, {
|
|
85
88
|
class: "k-colorgradient-input-label",
|
|
86
89
|
editorId: this.hexInputId
|
|
87
|
-
}, r(
|
|
88
|
-
default: () => [
|
|
89
|
-
})]), (this.inputMode === "rgb" || this.inputMode === "rgba") && [
|
|
90
|
+
}, r(i) ? i : {
|
|
91
|
+
default: () => [i]
|
|
92
|
+
})]), (this.inputMode === "rgb" || this.inputMode === "rgba") && [t("div", {
|
|
90
93
|
class: "k-vstack"
|
|
91
|
-
}, [
|
|
94
|
+
}, [t(l, {
|
|
92
95
|
inputType: "number",
|
|
93
96
|
tabIndex: this.tabIndex,
|
|
94
97
|
value: this.$props.rgba.r,
|
|
@@ -96,16 +99,17 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
96
99
|
max: 255,
|
|
97
100
|
spinners: !1,
|
|
98
101
|
format: "n",
|
|
99
|
-
ariaLabel:
|
|
102
|
+
ariaLabel: L,
|
|
100
103
|
onChange: this.onRgbaRChange,
|
|
101
|
-
disabled: this.$props.disabled
|
|
102
|
-
|
|
104
|
+
disabled: this.$props.disabled,
|
|
105
|
+
size: this.$props.size
|
|
106
|
+
}, null), t(o, {
|
|
103
107
|
class: "k-colorgradient-input-label"
|
|
104
|
-
}, r(
|
|
105
|
-
default: () => [
|
|
106
|
-
})]),
|
|
108
|
+
}, r(g) ? g : {
|
|
109
|
+
default: () => [g]
|
|
110
|
+
})]), t("div", {
|
|
107
111
|
class: "k-vstack"
|
|
108
|
-
}, [
|
|
112
|
+
}, [t(l, {
|
|
109
113
|
inputType: "number",
|
|
110
114
|
tabIndex: this.tabIndex,
|
|
111
115
|
value: this.$props.rgba.g,
|
|
@@ -113,16 +117,17 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
113
117
|
max: 255,
|
|
114
118
|
spinners: !1,
|
|
115
119
|
format: "n",
|
|
116
|
-
ariaLabel:
|
|
120
|
+
ariaLabel: v,
|
|
117
121
|
onChange: this.onRgbaGChange,
|
|
118
|
-
disabled: this.$props.disabled
|
|
119
|
-
|
|
122
|
+
disabled: this.$props.disabled,
|
|
123
|
+
size: this.$props.size
|
|
124
|
+
}, null), t(o, {
|
|
120
125
|
class: "k-colorgradient-input-label"
|
|
121
|
-
}, r(
|
|
122
|
-
default: () => [
|
|
123
|
-
})]),
|
|
126
|
+
}, r(d) ? d : {
|
|
127
|
+
default: () => [d]
|
|
128
|
+
})]), t("div", {
|
|
124
129
|
class: "k-vstack"
|
|
125
|
-
}, [
|
|
130
|
+
}, [t(l, {
|
|
126
131
|
inputType: "number",
|
|
127
132
|
tabIndex: this.tabIndex,
|
|
128
133
|
value: this.$props.rgba.b,
|
|
@@ -130,17 +135,18 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
130
135
|
max: 255,
|
|
131
136
|
spinners: !1,
|
|
132
137
|
format: "n",
|
|
133
|
-
ariaLabel:
|
|
138
|
+
ariaLabel: M,
|
|
134
139
|
onChange: this.onRgbaBChange,
|
|
135
140
|
disabled: this.$props.disabled,
|
|
136
|
-
ref: "numericb"
|
|
137
|
-
|
|
141
|
+
ref: "numericb",
|
|
142
|
+
size: this.$props.size
|
|
143
|
+
}, null), t(o, {
|
|
138
144
|
class: "k-colorgradient-input-label"
|
|
139
|
-
}, r(
|
|
140
|
-
default: () => [
|
|
141
|
-
})])], this.inputMode === "rgba" &&
|
|
145
|
+
}, r(p) ? p : {
|
|
146
|
+
default: () => [p]
|
|
147
|
+
})])], this.inputMode === "rgba" && t("div", {
|
|
142
148
|
class: "k-vstack"
|
|
143
|
-
}, [this.$props.opacity &&
|
|
149
|
+
}, [this.$props.opacity && t(l, {
|
|
144
150
|
inputType: "number",
|
|
145
151
|
tabIndex: this.tabIndex,
|
|
146
152
|
value: this.$props.rgba.a,
|
|
@@ -152,11 +158,12 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
152
158
|
ariaLabel: y,
|
|
153
159
|
onChange: this.onRgbaAChange,
|
|
154
160
|
disabled: this.$props.disabled,
|
|
155
|
-
ref: "numerica"
|
|
156
|
-
|
|
161
|
+
ref: "numerica",
|
|
162
|
+
size: this.$props.size
|
|
163
|
+
}, null), this.$props.opacity && t(o, {
|
|
157
164
|
class: "k-colorgradient-input-label"
|
|
158
|
-
}, r(
|
|
159
|
-
default: () => [
|
|
165
|
+
}, r(h) ? h : {
|
|
166
|
+
default: () => [h]
|
|
160
167
|
})])]);
|
|
161
168
|
},
|
|
162
169
|
methods: {
|
|
@@ -183,23 +190,23 @@ const o = ["rgba", "rgb", "hex"], q = /* @__PURE__ */ R({
|
|
|
183
190
|
a: e.value
|
|
184
191
|
}, e);
|
|
185
192
|
},
|
|
186
|
-
dispatchRgbaChange(e,
|
|
187
|
-
let
|
|
193
|
+
dispatchRgbaChange(e, i) {
|
|
194
|
+
let n = {
|
|
188
195
|
...this.$props.rgba
|
|
189
196
|
};
|
|
190
|
-
e.r !== void 0 && (
|
|
197
|
+
e.r !== void 0 && (n.r = e.r), e.g !== void 0 && (n.g = e.g), e.b !== void 0 && (n.b = e.b), e.a !== void 0 && (n.a = e.a), this.$emit("rgbachange", n, i);
|
|
191
198
|
},
|
|
192
199
|
onToggleModeChange() {
|
|
193
|
-
const e =
|
|
200
|
+
const e = s.length - 1 === s.indexOf(this.inputMode) ? 0 : s.indexOf(this.inputMode) + 1;
|
|
194
201
|
if (this.$props.opacity)
|
|
195
|
-
this.inputMode =
|
|
202
|
+
this.inputMode = s[e];
|
|
196
203
|
else {
|
|
197
|
-
const
|
|
198
|
-
this.inputMode =
|
|
204
|
+
const i = s[e] === "rgba" ? e + 1 : e;
|
|
205
|
+
this.inputMode = s[i];
|
|
199
206
|
}
|
|
200
207
|
},
|
|
201
208
|
onKeyDown(e) {
|
|
202
|
-
e.keyCode ===
|
|
209
|
+
e.keyCode === j.enter && e.stopPropagation();
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
});
|
package/colors/ColorPalette.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),U=require("./utils/color-palette.service.js"),t=require("@progress/kendo-vue-common"),D=require("../package-metadata.js"),F=require("./models/palette-presets.js"),I=require("./utils/misc.js"),K=require("./utils/color-parser.js"),C=10,$="office",L=a.defineComponent({name:"KendoColorPalette",model:{event:"changemodel"},emits:{keydown:null,focus:null,blur:null,changemodel:null,"update:modelValue":null,"update:modelRgbaValue":null,change:null},props:{palette:{type:[String,Array],default:$},columns:Number,tileSize:{type:[Number,Object]},modelValue:String,modelRgbaValue:String,defaultValue:String,value:String,disabled:Boolean,tabIndex:Number,id:String,class:String,ariaLabelledBy:String,ariaDescribedBy:String,size:{type:[String,null],default:"medium"}},created(){t.validatePackage(D.packageMetadata),this.guid=t.guid()},mounted(){this.wrapper=t.getRef(this,"wrapper")},updated(){this.wrapper=t.getRef(this,"wrapper")},computed:{focusedColorCooridanates(){return this.focusedColor?this.paletteService.getCellCoordsFor(this.focusedColor):void 0},isUncontrolled(){return this.$props.value===void 0},selectedColor(){return this.$props.value!==void 0?this.$props.value:this.modelValue!==void 0?this.modelValue:this.modelRgbaValue!==void 0?this.modelRgbaValue:this.currentValue!==void 0?this.currentValue:this.$props.defaultValue}},data(){return{focusedColor:this.$props.value,currentValue:void 0}},render(){const{size:e,disabled:s,class:o,tileSize:l}=this.$props,p=this.getPaletteInfo(),d=this.paletteService=new U.ColorPaletteService;d.setColorMatrix(p.colors,p.columns);const w=d.getCellCoordsFor(this.selectedColor),f=d.getCellCoordsFor(this.focusedColor),k=t.classNames("k-colorpalette",{[`k-colorpalette-${t.kendoThemeMaps.sizeMap[e]||e}`]:e,"k-disabled":s},o),S=function(g,n,r,i){const c=r!==void 0&&r.row===n,N=r&&r.col,v=i!==void 0&&i.row===n,E=i&&i.col,u=typeof l!="number"?l:{width:l,height:l},b=u?u.width+"px":void 0,P=u?u.height+"px":void 0;return g.map(function(m,h){const y=c&&N===h,R=t.classNames("k-colorpalette-tile",{"k-selected":y,"k-focus":v&&E===h});return a.createVNode("td",{class:R,"aria-label":m,"aria-selected":y?!0:this.$props.disabled?void 0:!1,style:{backgroundColor:m,width:b,height:P,minWidth:b},onClick:T=>this.onColorClick(m,T),id:this.createCellId({row:n,col:h}),key:h,role:"gridcell"},null)},this)},V=function(g,n,r){return g.map(function(i,c){return a.createVNode("tr",{role:"row",key:c},[S.call(this,i,c,n,r)])},this)};return p.colors.length?a.createVNode("div",{id:this.$props.id,class:k,onFocusin:this.onFocus,onFocusout:this.onBlur,onKeydown:this.onKeyDown,"aria-disabled":this.$props.disabled?"true":void 0,"aria-activedescendant":f&&this.createCellId(f),"aria-labelledby":this.$props.ariaLabelledBy,"aria-describedby":this.$props.ariaDescribedBy,role:"grid",tabindex:t.getTabIndex(this.$props.tabIndex,this.$props.disabled),ref:t.setRef(this,"wrapper")},[a.createVNode("table",{class:"k-colorpalette-table k-palette",role:"presentation"},[a.createVNode("tbody",null,[V.call(this,d.colorRows,w,f)])])]):""},methods:{focus(){this.wrapper&&this.wrapper.focus()},onKeyDown(e){switch(e.keyCode){case t.Keys.down:this.handleCellNavigation(e,0,1);break;case t.Keys.up:this.handleCellNavigation(e,0,-1);break;case t.Keys.right:this.handleCellNavigation(e,1,0);break;case t.Keys.left:this.handleCellNavigation(e,-1,0);break;case t.Keys.enter:this.handleEnter(e);break;default:this.$emit("keydown",e);return}this.$emit("keydown",e)},onColorClick(e,s){this.isUncontrolled?(this.currentValue=e,this.focusedColor=e):this.focusedColor=e,this.dispatchChangeEvent(e,s)},onFocus(e){this.focusedColor=this.selectedColor||this.paletteService.colorRows[0][0],this.$emit("focus",{event:e,target:this})},onBlur(e){this.focusedColor=void 0,this.$emit("blur",{event:e,target:this})},handleCellNavigation(e,s,o){if(e.preventDefault(),this.focusedColorCooridanates){const l=this.paletteService.getNextCell(this.focusedColorCooridanates,s,o);this.focusedColor=this.paletteService.getColorAt(l)}else this.focusedColor=this.paletteService.colorRows[0][0]},handleEnter(e){this.isUncontrolled&&(this.currentValue=this.focusedColor),this.dispatchChangeEvent(this.focusedColor,e)},dispatchChangeEvent(e,s){const o=K.parseColor(e,"rgba");this.$emit("changemodel",e),this.$emit("update:modelValue",e),this.$emit("update:modelRgbaValue",o),this.$emit("change",{event:s,component:this,value:e,rgbaValue:o})},getPaletteInfo(){if(typeof this.$props.palette=="string"){const e=F.PALETTEPRESETS[this.$props.palette];return I.isPresent(e)?{colors:e.colors,columns:this.$props.columns||e.columns||C}:{colors:[],columns:0}}else return{colors:this.$props.palette||[],columns:this.$props.columns||C}},createCellId(e){return`${this.guid}_${e.row}_${e.col}`}}});exports.ColorPalette=L;exports.DEFAULT_COLUMNS_COUNT=C;exports.DEFAULT_PRESET=$;
|
package/colors/ColorPalette.mjs
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { defineComponent as
|
|
9
|
-
import { ColorPaletteService as
|
|
10
|
-
import { validatePackage as
|
|
11
|
-
import { packageMetadata as
|
|
12
|
-
import { PALETTEPRESETS as
|
|
13
|
-
import { isPresent as
|
|
14
|
-
import { parseColor as
|
|
15
|
-
const
|
|
8
|
+
import { defineComponent as x, createVNode as a } from "vue";
|
|
9
|
+
import { ColorPaletteService as B } from "./utils/color-palette.service.mjs";
|
|
10
|
+
import { validatePackage as D, guid as F, getRef as $, classNames as w, kendoThemeMaps as U, getTabIndex as z, setRef as L, Keys as n } from "@progress/kendo-vue-common";
|
|
11
|
+
import { packageMetadata as A } from "../package-metadata.mjs";
|
|
12
|
+
import { PALETTEPRESETS as K } from "./models/palette-presets.mjs";
|
|
13
|
+
import { isPresent as M } from "./utils/misc.mjs";
|
|
14
|
+
import { parseColor as _ } from "./utils/color-parser.mjs";
|
|
15
|
+
const k = 10, O = "office", X = /* @__PURE__ */ x({
|
|
16
16
|
name: "KendoColorPalette",
|
|
17
17
|
model: {
|
|
18
18
|
event: "changemodel"
|
|
@@ -29,12 +29,11 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
29
29
|
props: {
|
|
30
30
|
palette: {
|
|
31
31
|
type: [String, Array],
|
|
32
|
-
default:
|
|
32
|
+
default: O
|
|
33
33
|
},
|
|
34
34
|
columns: Number,
|
|
35
35
|
tileSize: {
|
|
36
|
-
type: [Number, Object]
|
|
37
|
-
default: _
|
|
36
|
+
type: [Number, Object]
|
|
38
37
|
},
|
|
39
38
|
modelValue: String,
|
|
40
39
|
modelRgbaValue: String,
|
|
@@ -43,17 +42,22 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
43
42
|
disabled: Boolean,
|
|
44
43
|
tabIndex: Number,
|
|
45
44
|
id: String,
|
|
45
|
+
class: String,
|
|
46
46
|
ariaLabelledBy: String,
|
|
47
|
-
ariaDescribedBy: String
|
|
47
|
+
ariaDescribedBy: String,
|
|
48
|
+
size: {
|
|
49
|
+
type: [String, null],
|
|
50
|
+
default: "medium"
|
|
51
|
+
}
|
|
48
52
|
},
|
|
49
53
|
created() {
|
|
50
|
-
|
|
54
|
+
D(A), this.guid = F();
|
|
51
55
|
},
|
|
52
56
|
mounted() {
|
|
53
|
-
this.wrapper =
|
|
57
|
+
this.wrapper = $(this, "wrapper");
|
|
54
58
|
},
|
|
55
59
|
updated() {
|
|
56
|
-
this.wrapper =
|
|
60
|
+
this.wrapper = $(this, "wrapper");
|
|
57
61
|
},
|
|
58
62
|
computed: {
|
|
59
63
|
focusedColorCooridanates() {
|
|
@@ -73,64 +77,70 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
73
77
|
};
|
|
74
78
|
},
|
|
75
79
|
render() {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const {
|
|
81
|
+
size: e,
|
|
82
|
+
disabled: t,
|
|
83
|
+
class: o,
|
|
84
|
+
tileSize: s
|
|
85
|
+
} = this.$props, p = this.getPaletteInfo(), d = this.paletteService = new B();
|
|
86
|
+
d.setColorMatrix(p.colors, p.columns);
|
|
87
|
+
const y = d.getCellCoordsFor(this.selectedColor), f = d.getCellCoordsFor(this.focusedColor), S = w("k-colorpalette", {
|
|
88
|
+
[`k-colorpalette-${U.sizeMap[e] || e}`]: e,
|
|
89
|
+
"k-disabled": t
|
|
90
|
+
}, o), V = function(m, r, i, l) {
|
|
91
|
+
const u = i !== void 0 && i.row === r, N = i && i.col, E = l !== void 0 && l.row === r, R = l && l.col, c = typeof s != "number" ? s : {
|
|
92
|
+
width: s,
|
|
93
|
+
height: s
|
|
94
|
+
}, C = c ? c.width + "px" : void 0, P = c ? c.height + "px" : void 0;
|
|
95
|
+
return m.map(function(g, h) {
|
|
96
|
+
const b = u && N === h, I = w("k-colorpalette-tile", {
|
|
97
|
+
"k-selected": b,
|
|
98
|
+
"k-focus": E && R === h
|
|
89
99
|
});
|
|
90
100
|
return a("td", {
|
|
91
|
-
class:
|
|
92
|
-
"aria-label":
|
|
93
|
-
"aria-selected":
|
|
101
|
+
class: I,
|
|
102
|
+
"aria-label": g,
|
|
103
|
+
"aria-selected": b ? !0 : this.$props.disabled ? void 0 : !1,
|
|
94
104
|
style: {
|
|
95
|
-
backgroundColor:
|
|
96
|
-
width:
|
|
97
|
-
height:
|
|
98
|
-
minWidth:
|
|
105
|
+
backgroundColor: g,
|
|
106
|
+
width: C,
|
|
107
|
+
height: P,
|
|
108
|
+
minWidth: C
|
|
99
109
|
},
|
|
100
|
-
onClick: (
|
|
110
|
+
onClick: (T) => this.onColorClick(g, T),
|
|
101
111
|
id: this.createCellId({
|
|
102
112
|
row: r,
|
|
103
|
-
col:
|
|
113
|
+
col: h
|
|
104
114
|
}),
|
|
105
|
-
key:
|
|
115
|
+
key: h,
|
|
106
116
|
role: "gridcell"
|
|
107
117
|
}, null);
|
|
108
118
|
}, this);
|
|
109
|
-
},
|
|
110
|
-
return
|
|
119
|
+
}, v = function(m, r, i) {
|
|
120
|
+
return m.map(function(l, u) {
|
|
111
121
|
return a("tr", {
|
|
112
122
|
role: "row",
|
|
113
|
-
key:
|
|
114
|
-
}, [
|
|
123
|
+
key: u
|
|
124
|
+
}, [V.call(this, l, u, r, i)]);
|
|
115
125
|
}, this);
|
|
116
126
|
};
|
|
117
|
-
return
|
|
127
|
+
return p.colors.length ? a("div", {
|
|
118
128
|
id: this.$props.id,
|
|
119
|
-
class:
|
|
129
|
+
class: S,
|
|
120
130
|
onFocusin: this.onFocus,
|
|
121
131
|
onFocusout: this.onBlur,
|
|
122
132
|
onKeydown: this.onKeyDown,
|
|
123
133
|
"aria-disabled": this.$props.disabled ? "true" : void 0,
|
|
124
|
-
"aria-activedescendant":
|
|
134
|
+
"aria-activedescendant": f && this.createCellId(f),
|
|
125
135
|
"aria-labelledby": this.$props.ariaLabelledBy,
|
|
126
136
|
"aria-describedby": this.$props.ariaDescribedBy,
|
|
127
137
|
role: "grid",
|
|
128
|
-
tabindex:
|
|
129
|
-
ref:
|
|
138
|
+
tabindex: z(this.$props.tabIndex, this.$props.disabled),
|
|
139
|
+
ref: L(this, "wrapper")
|
|
130
140
|
}, [a("table", {
|
|
131
141
|
class: "k-colorpalette-table k-palette",
|
|
132
142
|
role: "presentation"
|
|
133
|
-
}, [a("tbody", null, [
|
|
143
|
+
}, [a("tbody", null, [v.call(this, d.colorRows, y, f)])])]) : "";
|
|
134
144
|
},
|
|
135
145
|
methods: {
|
|
136
146
|
focus() {
|
|
@@ -176,8 +186,8 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
176
186
|
},
|
|
177
187
|
handleCellNavigation(e, t, o) {
|
|
178
188
|
if (e.preventDefault(), this.focusedColorCooridanates) {
|
|
179
|
-
const
|
|
180
|
-
this.focusedColor = this.paletteService.getColorAt(
|
|
189
|
+
const s = this.paletteService.getNextCell(this.focusedColorCooridanates, t, o);
|
|
190
|
+
this.focusedColor = this.paletteService.getColorAt(s);
|
|
181
191
|
} else
|
|
182
192
|
this.focusedColor = this.paletteService.colorRows[0][0];
|
|
183
193
|
},
|
|
@@ -185,7 +195,7 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
185
195
|
this.isUncontrolled && (this.currentValue = this.focusedColor), this.dispatchChangeEvent(this.focusedColor, e);
|
|
186
196
|
},
|
|
187
197
|
dispatchChangeEvent(e, t) {
|
|
188
|
-
const o =
|
|
198
|
+
const o = _(e, "rgba");
|
|
189
199
|
this.$emit("changemodel", e), this.$emit("update:modelValue", e), this.$emit("update:modelRgbaValue", o), this.$emit("change", {
|
|
190
200
|
event: t,
|
|
191
201
|
component: this,
|
|
@@ -195,10 +205,10 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
195
205
|
},
|
|
196
206
|
getPaletteInfo() {
|
|
197
207
|
if (typeof this.$props.palette == "string") {
|
|
198
|
-
const e =
|
|
199
|
-
return
|
|
208
|
+
const e = K[this.$props.palette];
|
|
209
|
+
return M(e) ? {
|
|
200
210
|
colors: e.colors,
|
|
201
|
-
columns: this.$props.columns || e.columns ||
|
|
211
|
+
columns: this.$props.columns || e.columns || k
|
|
202
212
|
} : {
|
|
203
213
|
colors: [],
|
|
204
214
|
columns: 0
|
|
@@ -206,7 +216,7 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
206
216
|
} else
|
|
207
217
|
return {
|
|
208
218
|
colors: this.$props.palette || [],
|
|
209
|
-
columns: this.$props.columns ||
|
|
219
|
+
columns: this.$props.columns || k
|
|
210
220
|
};
|
|
211
221
|
},
|
|
212
222
|
createCellId(e) {
|
|
@@ -215,8 +225,7 @@ const _ = 24, b = 10, z = "office", q = /* @__PURE__ */ R({
|
|
|
215
225
|
}
|
|
216
226
|
});
|
|
217
227
|
export {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
_ as DEFAULT_TILE_SIZE
|
|
228
|
+
X as ColorPalette,
|
|
229
|
+
k as DEFAULT_COLUMNS_COUNT,
|
|
230
|
+
O as DEFAULT_PRESET
|
|
222
231
|
};
|
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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),w=require("@progress/kendo-vue-buttons"),t=require("@progress/kendo-vue-common"),S=require("../package-metadata.js"),V=require("./Picker.js"),B=require("./FlatColorPicker.js"),P=require("./utils/color-cache.js"),O=require("@progress/kendo-vue-intl"),n=require("../messages/main.js"),$=require("@progress/kendo-svg-icons"),T=require("./ColorPalette.js"),A=require("./common/ColorsAdaptiveMode.js");function R(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!a.isVNode(e)}const N=a.defineComponent({name:"KendoColorPicker",model:{event:"changemodel"},emits:{open:null,close:null,changemodel:null,"update:modelValue":null,"update:modelRgbaValue":null,activecolorclick:null,focus:null,blur:null,change:null,viewchange:null},props:{modelValue:String,modelRgbaValue:String,value:{type:String,default:void 0},defaultValue:String,disabled:Boolean,dir:String,id:String,ariaLabelledBy:String,ariaDescribedBy:String,showClearButton:{type:Boolean,default:!0},showPreview:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!0},paletteSettings:{type:Object,default:function(){return{palette:T.DEFAULT_PRESET}}},valid:{type:Boolean,default:!0},tabIndex:{type:Number,default:0},title:String,icon:String,svgIcon:Object,iconClassName:String,popupSettings:{type:Object,default:function(){return{}}},gradientSettings:{type:Object,default:function(){return P.DEFAULT_GRADIENT_SETTINGS}},flatColorPickerSettings:{type:Object,default:function(){return{}}},open:{type:Boolean,default:void 0},size:{type:String,default:"medium",validator:function(e){return[null,"small","medium","large"].includes(e)}},rounded:{type:String,default:"medium",validator:function(e){return[null,"small","medium","large","full"].includes(e)}},fillMode:{type:String,default:"solid",validator:function(e){return[null,"solid","flat","outline"].includes(e)}},view:{type:String,default:"combo",validator:function(e){return["gradient","palette","combo"].includes(e)}},selectedView:{type:Number,default:void 0},adaptive:{type:Boolean,default:!1},adaptiveTitle:{type:String}},inject:{kendoLocalizationService:{default:null},adaptiveModeBreakpoints:{default:{small:t.ADAPTIVE_SMALL_BREAKPOINT,medium:t.ADAPTIVE_MEDIUM_BREAKPOINT}}},data(){return{focused:!1,currentValue:this.$props.defaultValue,currentOpen:!1,flatcolorpickerRef:null,windowWidth:0,observer:null}},computed:{isValueControlled(){return this.$props.value!==void 0},isOpenControlled(){return this.$props.open!==void 0},computedValue(){return this.isValueControlled?this.$props.value:this.$props.modelValue!==void 0?this.$props.modelValue:this.$props.modelRgbaValue!==void 0?this.$props.modelRgbaValue:this.currentValue!==void 0?this.currentValue:this.defaultValue},computedOpen(){return this.isOpenControlled?this.$props.open:this.currentOpen},wrapperClassName(){const{size:e,fillMode:o,rounded:i}=this.$props;return{"k-picker":!0,"k-colorpicker":!0,"k-icon-picker":!0,[`k-picker-${t.kendoThemeMaps.sizeMap[e]||e}`]:e,[`k-picker-${o}`]:o,[`k-rounded-${t.kendoThemeMaps.roundedMap[i]||i}`]:i,"k-invalid":!this.valid,"k-disabled":this.disabled,"k-focus":this.focused}},animationStyles(){return this.windowWidth<=this.adaptiveModeBreakpoints.small?{top:0,width:"100%",height:"100%"}:void 0},classNameAdaptive(){return this.windowWidth<=this.adaptiveModeBreakpoints.small?"k-adaptive-actionsheet k-actionsheet-fullscreen":"k-adaptive-actionsheet k-actionsheet-bottom"},adaptiveState(){return!!(this.$props.adaptive&&this.windowWidth&&this.windowWidth<=this.adaptiveModeBreakpoints.medium)}},created(){t.validatePackage(S.packageMetadata),this._popupId="popup"+t.guid(),this.focusableElementGuid=t.guid()},mounted(){this.observer=t.canUseDOM&&window.ResizeObserver&&new ResizeObserver(this.calculateMedia),document!=null&&document.body&&this.observer&&this.observer.observe(document.body),this.flatcolorpickerRef=t.getRef(this,"flatcolorpicker"),this.button=t.getRef(this,"button")},unmounted(){var e;(e=this.document)!=null&&e.body&&this.observer&&this.observer.disconnect()},render(){let e;const{disabled:o,tabIndex:i,dir:r,view:d,selectedView:c,showClearButton:p,showPreview:h,showButtons:f,popupSettings:m,size:g,adaptiveTitle:k}=this.$props,s=O.provideLocalizationService(this),b=s.toLanguageString(n.colorPickerDropdownButtonAriaLabel,n.messages[n.colorPickerDropdownButtonAriaLabel]),v=k||s.toLanguageString(n.colorPickerAdaptiveTitle,n.messages[n.colorPickerAdaptiveTitle]),C=s.toLanguageString(n.flatColorPickerApplyBtn,n.messages[n.flatColorPickerApplyBtn]),y=s.toLanguageString(n.flatColorPickerCancelBtn,n.messages[n.flatColorPickerCancelBtn]),u=function(){return a.h(B.FlatColorPicker,{onKeydown:this.onKeyDownHandler,ref:t.setRef(this,"flatcolorpicker"),view:d,selectedView:c,showClearButton:p,showPreview:h,showButtons:this.adaptiveState?!1:f,size:this.adaptiveState?"large":g,value:this.computedValue||void 0,onChange:this.onFlatChangeHandler,onFocusout:this.onBlurHandler,onViewchange:this.onViewChange,paletteSettings:this.paletteSettings,gradientSettings:this.gradientSettings,adaptive:this.adaptiveState,...this.flatColorPickerSettings})};return a.createVNode("span",{class:this.wrapperClassName,role:"combobox",dir:r,id:this.$props.id,"aria-labelledby":this.$props.ariaLabelledBy,"aria-describedby":this.$props.ariaDescribedBy,"aria-disabled":this.$props.disabled,"aria-haspopup":"dialog","aria-expanded":this.computedOpen,ref:this.focusableElementGuid,tabindex:t.getTabIndex(i,o),title:this.$props.title,onKeydown:this.onButtonKeyDown,onFocusin:this.onFocusHandler,onFocusout:this.onButtonBlur},[a.createVNode("span",{onClick:this.onActiveColorClickHandler,class:"k-input-inner"},[a.createVNode("span",{class:t.classNames("k-value-icon","k-color-preview",{"k-no-color":!this.computedValue,"k-icon-color-preview":this.icon||this.iconClassName})},[(this.iconClassName||this.icon||this.svgIcon)&&a.createVNode(t.Icon,{class:t.classNames("k-color-preview-icon",this.iconClassName),name:t.getIconName(this.icon),icon:this.svgIcon},null),a.createVNode("span",{class:"k-color-preview-mask",style:{backgroundColor:this.computedValue}},null)])]),a.createVNode(w.Button,{type:"button",tabIndex:-1,ref:l=>{this.buttonRef=l},onClick:this.onClickHandler,rounded:null,class:"k-input-button",icon:"caret-alt-down",svgIcon:$.caretAltDownIcon,"aria-label":b},null),!this.adaptiveState&&a.createVNode(V.Picker,{dir:r,id:this._popupId,open:this.computedOpen,onOpen:this.onOpenHandler,popupAnchor:this.focusableElementGuid,popupSettings:{...m}},R(e=u.call(this))?e:{default:()=>[e]}),this.adaptiveState&&a.createVNode(A.ColorsAdaptiveMode,{expand:this.computedOpen,animationStyles:this.animationStyles,classNameAdaptive:this.classNameAdaptive,title:v,applyText:C,cancelText:y,componentToRender:u.call(this),onActionSheetClose:()=>this.setOpen(!this.computedOpen),onCancelBtnClick:()=>this.flatcolorpickerRef.handleCancelBtnClick(),onApplyBtnClick:l=>this.flatcolorpickerRef.triggerChange(l)},null)])},methods:{calculateMedia(e){for(let o of e)this.windowWidth=o.target.clientWidth},focusElement(){this.$el&&this.$el.focus()},setOpen(e,o){!e&&!o&&this.$el&&this.$el.focus(),this.currentOpen=e,this.$emit(e?"open":"close")},onButtonKeyDown(e){const{altKey:o,keyCode:i}=e;if(i===t.Keys.esc){e.preventDefault(),e.stopPropagation(),this.setOpen(!1);return}if(i===t.Keys.enter){e.preventDefault(),e.stopPropagation(),this.setOpen(!this.computedOpen);return}o&&i===t.Keys.down&&(e.preventDefault(),e.stopPropagation(),this.setOpen(!0))},onKeyDownHandler(e){const{altKey:o,keyCode:i}=e;if(i===t.Keys.esc){e.preventDefault(),e.stopPropagation(),this.setOpen(!1);return}if(i===t.Keys.enter){e.preventDefault(),e.stopPropagation(),this.focusElement();return}o&&i===t.Keys.up&&(e.preventDefault(),e.stopPropagation(),this.setOpen(!1),this.focusElement())},onOpenHandler(){const e=t.getRef(this,"flatcolorpicker");e&&e.focus()},onClickHandler(){this.setOpen(!this.computedOpen,!0)},onActiveColorClickHandler(e){this.$emit("activecolorclick",{event:e,value:this.computedValue})},isViewFocused(){return!!(document.activeElement&&document.activeElement.closest(`#${this._popupId}`))},onButtonBlur(e){this.focused=this.isViewFocused(),this.$emit("blur",{event:e})},onFocusHandler(e){this.blurTimeoutRef?(clearTimeout(this.blurTimeoutRef),this.blurTimeoutRef=void 0,e.target===this.$el&&this.setOpen(!1)):this.focused=!0,this.$emit("focus",{event:e})},onBlurTimeout(){const e=this.isViewFocused();e||this.setOpen(!1,!0),this.focused=e,this.blurTimeoutRef=void 0},onBlurHandler(){clearTimeout(this.blurTimeoutRef),this.palette=t.getRef(this,"palette"),this.gradient=t.getRef(this,"gradient"),this.blurTimeoutRef=setTimeout(this.onBlurTimeout,200)},onViewChange(e){this.$emit("viewchange",e)},onChangeHandler(e,o){const i=e.value;this.isValueControlled||(this.currentValue=i),o&&this.setOpen(!1),this.$emit("changemodel",i),this.$emit("update:modelRgbaValue",e.rgbaValue),this.$emit("update:modelValue",i),this.$emit("change",{value:i,rgbaValue:e.rgbaValue,event:e})},onFlatChangeHandler(e){this.onChangeHandler(e,!0)}}});exports.ColorPicker=N;
|