@react-aria/color 3.0.0-beta.3 → 3.0.0-beta.31
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/dist/ar-AE.main.js +9 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +11 -0
- package/dist/ar-AE.module.js +11 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +9 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +11 -0
- package/dist/bg-BG.module.js +11 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +9 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +11 -0
- package/dist/cs-CZ.module.js +11 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +9 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +11 -0
- package/dist/da-DK.module.js +11 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +9 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +11 -0
- package/dist/de-DE.module.js +11 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +9 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +11 -0
- package/dist/el-GR.module.js +11 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +9 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +11 -0
- package/dist/en-US.module.js +11 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +9 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +11 -0
- package/dist/es-ES.module.js +11 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +9 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +11 -0
- package/dist/et-EE.module.js +11 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +9 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +11 -0
- package/dist/fi-FI.module.js +11 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +9 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +11 -0
- package/dist/fr-FR.module.js +11 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +9 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +11 -0
- package/dist/he-IL.module.js +11 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +9 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +11 -0
- package/dist/hr-HR.module.js +11 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +9 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +11 -0
- package/dist/hu-HU.module.js +11 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +1139 -0
- package/dist/it-IT.main.js +9 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +11 -0
- package/dist/it-IT.module.js +11 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +9 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +11 -0
- package/dist/ja-JP.module.js +11 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +9 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +11 -0
- package/dist/ko-KR.module.js +11 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +9 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +11 -0
- package/dist/lt-LT.module.js +11 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +9 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +11 -0
- package/dist/lv-LV.module.js +11 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +1122 -492
- package/dist/main.js.map +1 -1
- package/dist/module.js +1121 -457
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +9 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +11 -0
- package/dist/nb-NO.module.js +11 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +9 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +11 -0
- package/dist/nl-NL.module.js +11 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +9 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +11 -0
- package/dist/pl-PL.module.js +11 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +9 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +11 -0
- package/dist/pt-BR.module.js +11 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +9 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +11 -0
- package/dist/pt-PT.module.js +11 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +9 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +11 -0
- package/dist/ro-RO.module.js +11 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +9 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +11 -0
- package/dist/ru-RU.module.js +11 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +9 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +11 -0
- package/dist/sk-SK.module.js +11 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +9 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +11 -0
- package/dist/sl-SI.module.js +11 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +9 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +11 -0
- package/dist/sr-SP.module.js +11 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +9 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +11 -0
- package/dist/sv-SE.module.js +11 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +9 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +11 -0
- package/dist/tr-TR.module.js +11 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +45 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +9 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +11 -0
- package/dist/uk-UA.module.js +11 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/zh-CN.main.js +9 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +11 -0
- package/dist/zh-CN.module.js +11 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +9 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +11 -0
- package/dist/zh-TW.module.js +11 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +21 -15
- package/src/index.ts +9 -4
- package/src/useColorArea.ts +460 -0
- package/src/useColorAreaGradient.ts +254 -0
- package/src/useColorField.ts +34 -18
- package/src/useColorSlider.ts +18 -21
- package/src/useColorWheel.ts +103 -69
package/dist/main.js
CHANGED
|
@@ -1,517 +1,1147 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
1
|
+
var $f141a15c3076a67b$exports = require("./ar-AE.main.js");
|
|
2
|
+
var $435ac2a9fdd2ae5e$exports = require("./bg-BG.main.js");
|
|
3
|
+
var $6b29758b432284f5$exports = require("./cs-CZ.main.js");
|
|
4
|
+
var $357597bcf4afd6fb$exports = require("./da-DK.main.js");
|
|
5
|
+
var $ddc6333960e2b591$exports = require("./de-DE.main.js");
|
|
6
|
+
var $417ee93d3ca474c0$exports = require("./el-GR.main.js");
|
|
7
|
+
var $519561bc6dcff98b$exports = require("./en-US.main.js");
|
|
8
|
+
var $7a34c3fcc03402b8$exports = require("./es-ES.main.js");
|
|
9
|
+
var $860f86d6eae22cba$exports = require("./et-EE.main.js");
|
|
10
|
+
var $8525d3c77b8a51b0$exports = require("./fi-FI.main.js");
|
|
11
|
+
var $8240fe6825e900ec$exports = require("./fr-FR.main.js");
|
|
12
|
+
var $377849238307c673$exports = require("./he-IL.main.js");
|
|
13
|
+
var $5a6f44e0ec14b083$exports = require("./hr-HR.main.js");
|
|
14
|
+
var $82327d6e71e3e273$exports = require("./hu-HU.main.js");
|
|
15
|
+
var $b1e297275c248ab8$exports = require("./it-IT.main.js");
|
|
16
|
+
var $b39c9f2638b4d2b9$exports = require("./ja-JP.main.js");
|
|
17
|
+
var $2d2fbf4195848a62$exports = require("./ko-KR.main.js");
|
|
18
|
+
var $ea88350d0828fa2c$exports = require("./lt-LT.main.js");
|
|
19
|
+
var $0e0acd541630120a$exports = require("./lv-LV.main.js");
|
|
20
|
+
var $952a458224052046$exports = require("./nb-NO.main.js");
|
|
21
|
+
var $2d8e195bc5683483$exports = require("./nl-NL.main.js");
|
|
22
|
+
var $750d83f83c5f38d4$exports = require("./pl-PL.main.js");
|
|
23
|
+
var $656b2846f611067c$exports = require("./pt-BR.main.js");
|
|
24
|
+
var $58ce120874d069dd$exports = require("./pt-PT.main.js");
|
|
25
|
+
var $fd6c85b4eba18825$exports = require("./ro-RO.main.js");
|
|
26
|
+
var $8849a15ecc435984$exports = require("./ru-RU.main.js");
|
|
27
|
+
var $5192372f064be783$exports = require("./sk-SK.main.js");
|
|
28
|
+
var $094525f9176df65d$exports = require("./sl-SI.main.js");
|
|
29
|
+
var $9795aa59b4ad40ed$exports = require("./sr-SP.main.js");
|
|
30
|
+
var $9ebaa0b485f13e4d$exports = require("./sv-SE.main.js");
|
|
31
|
+
var $ad58e2e4e0f2e750$exports = require("./tr-TR.main.js");
|
|
32
|
+
var $dafc19306f8b2dfc$exports = require("./uk-UA.main.js");
|
|
33
|
+
var $d31a8b80af5acc16$exports = require("./zh-CN.main.js");
|
|
34
|
+
var $7377d28aec5fa200$exports = require("./zh-TW.main.js");
|
|
35
|
+
var $kZqDi$reactariautils = require("@react-aria/utils");
|
|
36
|
+
var $kZqDi$react = require("react");
|
|
37
|
+
var $kZqDi$reactariainteractions = require("@react-aria/interactions");
|
|
38
|
+
var $kZqDi$reactariai18n = require("@react-aria/i18n");
|
|
39
|
+
var $kZqDi$reactariavisuallyhidden = require("@react-aria/visually-hidden");
|
|
40
|
+
var $kZqDi$reactariaslider = require("@react-aria/slider");
|
|
41
|
+
var $kZqDi$reactstatelyform = require("@react-stately/form");
|
|
42
|
+
var $kZqDi$reactariatextfield = require("@react-aria/textfield");
|
|
43
|
+
var $kZqDi$reactariaspinbutton = require("@react-aria/spinbutton");
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function $parcel$export(e, n, v, s) {
|
|
47
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
48
|
+
}
|
|
40
49
|
|
|
41
50
|
function $parcel$interopDefault(a) {
|
|
42
51
|
return a && a.__esModule ? a.default : a;
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
outputProps
|
|
72
|
-
} = useSlider(_babelRuntimeHelpersExtends({}, props, {
|
|
73
|
-
'aria-label': ariaLabel
|
|
74
|
-
}), state, trackRef);
|
|
75
|
-
let {
|
|
76
|
-
inputProps,
|
|
77
|
-
thumbProps
|
|
78
|
-
} = useSliderThumb({
|
|
79
|
-
index: 0,
|
|
80
|
-
orientation,
|
|
81
|
-
isDisabled: props.isDisabled,
|
|
82
|
-
trackRef,
|
|
83
|
-
inputRef
|
|
84
|
-
}, state);
|
|
85
|
-
|
|
86
|
-
let generateBackground = () => {
|
|
87
|
-
let value = state.getDisplayColor();
|
|
88
|
-
let to;
|
|
89
|
-
|
|
90
|
-
if (orientation === 'vertical') {
|
|
91
|
-
to = 'top';
|
|
92
|
-
} else if (direction === 'ltr') {
|
|
93
|
-
to = 'right';
|
|
94
|
-
} else {
|
|
95
|
-
to = 'left';
|
|
96
|
-
}
|
|
54
|
+
$parcel$export(module.exports, "useColorArea", () => $47925bd68062ac17$export$2f92a7a615a014f6);
|
|
55
|
+
$parcel$export(module.exports, "useColorSlider", () => $afbb9647440a7f5b$export$106b7a4e66508f66);
|
|
56
|
+
$parcel$export(module.exports, "useColorWheel", () => $1d29bf243d4a9a53$export$9064ff4e44b3729a);
|
|
57
|
+
$parcel$export(module.exports, "useColorField", () => $58c850037bc7a7ce$export$77e32ca575a28fdf);
|
|
58
|
+
/*
|
|
59
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
60
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
61
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
62
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
63
|
+
*
|
|
64
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
65
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
66
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
67
|
+
* governing permissions and limitations under the License.
|
|
68
|
+
*/ /*
|
|
69
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
70
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
71
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
72
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
73
|
+
*
|
|
74
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
75
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
76
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
77
|
+
* governing permissions and limitations under the License.
|
|
78
|
+
*/
|
|
79
|
+
var $4a33e168940636d5$exports = {};
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
$4a33e168940636d5$exports = {
|
|
115
|
+
"ar-AE": $f141a15c3076a67b$exports,
|
|
116
|
+
"bg-BG": $435ac2a9fdd2ae5e$exports,
|
|
117
|
+
"cs-CZ": $6b29758b432284f5$exports,
|
|
118
|
+
"da-DK": $357597bcf4afd6fb$exports,
|
|
119
|
+
"de-DE": $ddc6333960e2b591$exports,
|
|
120
|
+
"el-GR": $417ee93d3ca474c0$exports,
|
|
121
|
+
"en-US": $519561bc6dcff98b$exports,
|
|
122
|
+
"es-ES": $7a34c3fcc03402b8$exports,
|
|
123
|
+
"et-EE": $860f86d6eae22cba$exports,
|
|
124
|
+
"fi-FI": $8525d3c77b8a51b0$exports,
|
|
125
|
+
"fr-FR": $8240fe6825e900ec$exports,
|
|
126
|
+
"he-IL": $377849238307c673$exports,
|
|
127
|
+
"hr-HR": $5a6f44e0ec14b083$exports,
|
|
128
|
+
"hu-HU": $82327d6e71e3e273$exports,
|
|
129
|
+
"it-IT": $b1e297275c248ab8$exports,
|
|
130
|
+
"ja-JP": $b39c9f2638b4d2b9$exports,
|
|
131
|
+
"ko-KR": $2d2fbf4195848a62$exports,
|
|
132
|
+
"lt-LT": $ea88350d0828fa2c$exports,
|
|
133
|
+
"lv-LV": $0e0acd541630120a$exports,
|
|
134
|
+
"nb-NO": $952a458224052046$exports,
|
|
135
|
+
"nl-NL": $2d8e195bc5683483$exports,
|
|
136
|
+
"pl-PL": $750d83f83c5f38d4$exports,
|
|
137
|
+
"pt-BR": $656b2846f611067c$exports,
|
|
138
|
+
"pt-PT": $58ce120874d069dd$exports,
|
|
139
|
+
"ro-RO": $fd6c85b4eba18825$exports,
|
|
140
|
+
"ru-RU": $8849a15ecc435984$exports,
|
|
141
|
+
"sk-SK": $5192372f064be783$exports,
|
|
142
|
+
"sl-SI": $094525f9176df65d$exports,
|
|
143
|
+
"sr-SP": $9795aa59b4ad40ed$exports,
|
|
144
|
+
"sv-SE": $9ebaa0b485f13e4d$exports,
|
|
145
|
+
"tr-TR": $ad58e2e4e0f2e750$exports,
|
|
146
|
+
"uk-UA": $dafc19306f8b2dfc$exports,
|
|
147
|
+
"zh-CN": $d31a8b80af5acc16$exports,
|
|
148
|
+
"zh-TW": $7377d28aec5fa200$exports
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
155
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
156
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
157
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
158
|
+
*
|
|
159
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
160
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
161
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
162
|
+
* governing permissions and limitations under the License.
|
|
163
|
+
*/
|
|
164
|
+
const $99936ad0bf67c8c4$var$generateRGB_R = (orientation, dir, zValue)=>{
|
|
165
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
166
|
+
let result = {
|
|
167
|
+
colorAreaStyles: {
|
|
168
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
169
|
+
},
|
|
170
|
+
gradientStyles: {
|
|
171
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
172
|
+
"WebkitMaskImage": maskImage,
|
|
173
|
+
maskImage: maskImage
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return result;
|
|
177
|
+
};
|
|
178
|
+
const $99936ad0bf67c8c4$var$generateRGB_G = (orientation, dir, zValue)=>{
|
|
179
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
180
|
+
let result = {
|
|
181
|
+
colorAreaStyles: {
|
|
182
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
183
|
+
},
|
|
184
|
+
gradientStyles: {
|
|
185
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
186
|
+
"WebkitMaskImage": maskImage,
|
|
187
|
+
maskImage: maskImage
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
return result;
|
|
191
|
+
};
|
|
192
|
+
const $99936ad0bf67c8c4$var$generateRGB_B = (orientation, dir, zValue)=>{
|
|
193
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
194
|
+
let result = {
|
|
195
|
+
colorAreaStyles: {
|
|
196
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
197
|
+
},
|
|
198
|
+
gradientStyles: {
|
|
199
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
200
|
+
"WebkitMaskImage": maskImage,
|
|
201
|
+
maskImage: maskImage
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return result;
|
|
205
|
+
};
|
|
206
|
+
const $99936ad0bf67c8c4$var$generateHSL_H = (orientation, dir, zValue)=>{
|
|
207
|
+
let result = {
|
|
208
|
+
colorAreaStyles: {},
|
|
209
|
+
gradientStyles: {
|
|
210
|
+
background: [
|
|
211
|
+
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
212
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
213
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
214
|
+
].join(",")
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
return result;
|
|
218
|
+
};
|
|
219
|
+
const $99936ad0bf67c8c4$var$generateHSL_S = (orientation, dir, alphaValue)=>{
|
|
220
|
+
let result = {
|
|
221
|
+
colorAreaStyles: {},
|
|
222
|
+
gradientStyles: {
|
|
223
|
+
background: [
|
|
224
|
+
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
225
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
226
|
+
"hsl(0, 0%, 50%)"
|
|
227
|
+
].join(",")
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
return result;
|
|
231
|
+
};
|
|
232
|
+
const $99936ad0bf67c8c4$var$generateHSL_L = (orientation, dir, zValue)=>{
|
|
233
|
+
let result = {
|
|
234
|
+
colorAreaStyles: {},
|
|
235
|
+
gradientStyles: {
|
|
236
|
+
backgroundImage: [
|
|
237
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
238
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
239
|
+
].join(",")
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
return result;
|
|
243
|
+
};
|
|
244
|
+
const $99936ad0bf67c8c4$var$generateHSB_H = (orientation, dir, zValue)=>{
|
|
245
|
+
let result = {
|
|
246
|
+
colorAreaStyles: {},
|
|
247
|
+
gradientStyles: {
|
|
248
|
+
background: [
|
|
249
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
250
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
251
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
252
|
+
].join(",")
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return result;
|
|
256
|
+
};
|
|
257
|
+
const $99936ad0bf67c8c4$var$generateHSB_S = (orientation, dir, alphaValue)=>{
|
|
258
|
+
let result = {
|
|
259
|
+
colorAreaStyles: {},
|
|
260
|
+
gradientStyles: {
|
|
261
|
+
background: [
|
|
262
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
263
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
264
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
265
|
+
].join(",")
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
return result;
|
|
269
|
+
};
|
|
270
|
+
const $99936ad0bf67c8c4$var$generateHSB_B = (orientation, dir, alphaValue)=>{
|
|
271
|
+
let result = {
|
|
272
|
+
colorAreaStyles: {},
|
|
273
|
+
gradientStyles: {
|
|
274
|
+
background: [
|
|
275
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
276
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
277
|
+
"#000"
|
|
278
|
+
].join(",")
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
283
|
+
function $99936ad0bf67c8c4$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
|
|
284
|
+
let returnVal = (0, $kZqDi$react.useMemo)(()=>{
|
|
285
|
+
let orientation = [
|
|
286
|
+
"top",
|
|
287
|
+
direction === "rtl" ? "left" : "right"
|
|
288
|
+
];
|
|
289
|
+
let dir = false;
|
|
290
|
+
let background = {
|
|
291
|
+
colorAreaStyles: {},
|
|
292
|
+
gradientStyles: {}
|
|
293
|
+
};
|
|
294
|
+
let zValue = state.value.getChannelValue(zChannel);
|
|
295
|
+
let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
|
|
296
|
+
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
297
|
+
let isHSL = state.value.getColorSpace() === "hsl";
|
|
298
|
+
if (!isDisabled) switch(zChannel){
|
|
299
|
+
case "red":
|
|
300
|
+
dir = xChannel === "green";
|
|
301
|
+
background = $99936ad0bf67c8c4$var$generateRGB_R(orientation, dir, zValue);
|
|
302
|
+
break;
|
|
303
|
+
case "green":
|
|
304
|
+
dir = xChannel === "red";
|
|
305
|
+
background = $99936ad0bf67c8c4$var$generateRGB_G(orientation, dir, zValue);
|
|
306
|
+
break;
|
|
307
|
+
case "blue":
|
|
308
|
+
dir = xChannel === "red";
|
|
309
|
+
background = $99936ad0bf67c8c4$var$generateRGB_B(orientation, dir, zValue);
|
|
310
|
+
break;
|
|
311
|
+
case "hue":
|
|
312
|
+
dir = xChannel !== "saturation";
|
|
313
|
+
if (isHSL) background = $99936ad0bf67c8c4$var$generateHSL_H(orientation, dir, zValue);
|
|
314
|
+
else background = $99936ad0bf67c8c4$var$generateHSB_H(orientation, dir, zValue);
|
|
315
|
+
break;
|
|
316
|
+
case "saturation":
|
|
317
|
+
dir = xChannel === "hue";
|
|
318
|
+
if (isHSL) background = $99936ad0bf67c8c4$var$generateHSL_S(orientation, dir, alphaValue);
|
|
319
|
+
else background = $99936ad0bf67c8c4$var$generateHSB_S(orientation, dir, alphaValue);
|
|
320
|
+
break;
|
|
321
|
+
case "brightness":
|
|
322
|
+
dir = xChannel === "hue";
|
|
323
|
+
background = $99936ad0bf67c8c4$var$generateHSB_B(orientation, dir, alphaValue);
|
|
324
|
+
break;
|
|
325
|
+
case "lightness":
|
|
326
|
+
dir = xChannel === "hue";
|
|
327
|
+
background = $99936ad0bf67c8c4$var$generateHSL_L(orientation, dir, zValue);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
let { x: x, y: y } = state.getThumbPosition();
|
|
331
|
+
if (direction === "rtl") x = 1 - x;
|
|
332
|
+
let forcedColorAdjustNoneStyle = {
|
|
333
|
+
forcedColorAdjust: "none"
|
|
334
|
+
};
|
|
335
|
+
return {
|
|
336
|
+
colorAreaStyleProps: {
|
|
337
|
+
style: {
|
|
338
|
+
position: "relative",
|
|
339
|
+
touchAction: "none",
|
|
340
|
+
...forcedColorAdjustNoneStyle,
|
|
341
|
+
...background.colorAreaStyles
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
gradientStyleProps: {
|
|
345
|
+
style: {
|
|
346
|
+
touchAction: "none",
|
|
347
|
+
...forcedColorAdjustNoneStyle,
|
|
348
|
+
...background.gradientStyles
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
thumbStyleProps: {
|
|
352
|
+
style: {
|
|
353
|
+
position: "absolute",
|
|
354
|
+
left: `${x * 100}%`,
|
|
355
|
+
top: `${y * 100}%`,
|
|
356
|
+
transform: "translate(0%, 0%)",
|
|
357
|
+
touchAction: "none",
|
|
358
|
+
...forcedColorAdjustNoneStyle
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}, [
|
|
363
|
+
direction,
|
|
364
|
+
state,
|
|
365
|
+
zChannel,
|
|
366
|
+
xChannel,
|
|
367
|
+
isDisabled
|
|
368
|
+
]);
|
|
369
|
+
return returnVal;
|
|
157
370
|
}
|
|
158
371
|
|
|
159
|
-
exports.useColorSlider = useColorSlider;
|
|
160
|
-
const $c5e318998f160f365e09b073e8447c3d$var$PAGE_MIN_STEP_SIZE = 6;
|
|
161
|
-
/**
|
|
162
|
-
* Provides the behavior and accessibility implementation for a color wheel component.
|
|
163
|
-
* Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
function useColorWheel(props, state, inputRef) {
|
|
167
|
-
let {
|
|
168
|
-
isDisabled,
|
|
169
|
-
step = 1,
|
|
170
|
-
innerRadius,
|
|
171
|
-
outerRadius,
|
|
172
|
-
'aria-label': ariaLabel
|
|
173
|
-
} = props;
|
|
174
|
-
let {
|
|
175
|
-
addGlobalListener,
|
|
176
|
-
removeGlobalListener
|
|
177
|
-
} = useGlobalListeners();
|
|
178
|
-
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
179
|
-
let focusInput = useCallback(() => {
|
|
180
|
-
if (inputRef.current) {
|
|
181
|
-
focusWithoutScrolling(inputRef.current);
|
|
182
|
-
}
|
|
183
|
-
}, [inputRef]);
|
|
184
|
-
let stateRef = useRef(null);
|
|
185
|
-
stateRef.current = state;
|
|
186
|
-
let currentPosition = useRef(null);
|
|
187
|
-
let moveHandler = {
|
|
188
|
-
onMoveStart() {
|
|
189
|
-
currentPosition.current = null;
|
|
190
|
-
state.setDragging(true);
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
onMove(_ref) {
|
|
194
|
-
let {
|
|
195
|
-
deltaX,
|
|
196
|
-
deltaY,
|
|
197
|
-
pointerType
|
|
198
|
-
} = _ref;
|
|
199
|
-
|
|
200
|
-
if (currentPosition.current == null) {
|
|
201
|
-
currentPosition.current = stateRef.current.getThumbPosition(thumbRadius);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
currentPosition.current.x += deltaX;
|
|
205
|
-
currentPosition.current.y += deltaY;
|
|
206
|
-
|
|
207
|
-
if (pointerType === 'keyboard') {
|
|
208
|
-
if (deltaX > 0 || deltaY < 0) {
|
|
209
|
-
state.increment();
|
|
210
|
-
} else if (deltaX < 0 || deltaY > 0) {
|
|
211
|
-
state.decrement();
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
stateRef.current.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
onMoveEnd() {
|
|
219
|
-
isOnTrack.current = undefined;
|
|
220
|
-
state.setDragging(false);
|
|
221
|
-
focusInput();
|
|
222
|
-
}
|
|
223
372
|
|
|
224
|
-
};
|
|
225
|
-
let {
|
|
226
|
-
moveProps: movePropsThumb
|
|
227
|
-
} = useMove(moveHandler);
|
|
228
|
-
let currentPointer = useRef(undefined);
|
|
229
|
-
let isOnTrack = useRef(false);
|
|
230
|
-
let {
|
|
231
|
-
moveProps: movePropsContainer
|
|
232
|
-
} = useMove({
|
|
233
|
-
onMoveStart() {
|
|
234
|
-
if (isOnTrack.current) {
|
|
235
|
-
moveHandler.onMoveStart();
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
onMove(e) {
|
|
240
|
-
if (isOnTrack.current) {
|
|
241
|
-
moveHandler.onMove(e);
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
onMoveEnd() {
|
|
246
|
-
if (isOnTrack.current) {
|
|
247
|
-
moveHandler.onMoveEnd();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
373
|
|
|
251
|
-
});
|
|
252
374
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
375
|
+
|
|
376
|
+
function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
|
|
377
|
+
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, "aria-label": ariaLabel, xName: xName, yName: yName } = props;
|
|
378
|
+
let stringFormatter = (0, $kZqDi$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($4a33e168940636d5$exports))), "@react-aria/color");
|
|
379
|
+
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $kZqDi$reactariautils.useGlobalListeners)();
|
|
380
|
+
let { direction: direction, locale: locale } = (0, $kZqDi$reactariai18n.useLocale)();
|
|
381
|
+
let [focusedInput, setFocusedInput] = (0, $kZqDi$react.useState)(null);
|
|
382
|
+
let focusInput = (0, $kZqDi$react.useCallback)((inputRef = inputXRef)=>{
|
|
383
|
+
if (inputRef.current) (0, $kZqDi$reactariautils.focusWithoutScrolling)(inputRef.current);
|
|
384
|
+
}, [
|
|
385
|
+
inputXRef
|
|
386
|
+
]);
|
|
387
|
+
(0, $kZqDi$reactariautils.useFormReset)(inputXRef, [
|
|
388
|
+
state.xValue,
|
|
389
|
+
state.yValue
|
|
390
|
+
], ([x, y])=>{
|
|
391
|
+
let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
|
|
392
|
+
state.setValue(newColor);
|
|
393
|
+
});
|
|
394
|
+
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $kZqDi$react.useState)(false);
|
|
395
|
+
let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
|
|
396
|
+
let xChannelStep = state.xChannelStep;
|
|
397
|
+
let yChannelStep = state.yChannelStep;
|
|
398
|
+
let currentPosition = (0, $kZqDi$react.useRef)(null);
|
|
399
|
+
let { keyboardProps: keyboardProps } = (0, $kZqDi$reactariainteractions.useKeyboard)({
|
|
400
|
+
onKeyDown (e) {
|
|
401
|
+
// these are the cases that useMove doesn't handle
|
|
402
|
+
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
403
|
+
e.continuePropagation();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
407
|
+
e.preventDefault();
|
|
408
|
+
// remember to set this and unset it so that onChangeEnd is fired
|
|
409
|
+
state.setDragging(true);
|
|
410
|
+
setValueChangedViaKeyboard(true);
|
|
411
|
+
let dir;
|
|
412
|
+
switch(e.key){
|
|
413
|
+
case "PageUp":
|
|
414
|
+
state.incrementY(state.yChannelPageStep);
|
|
415
|
+
dir = "y";
|
|
416
|
+
break;
|
|
417
|
+
case "PageDown":
|
|
418
|
+
state.decrementY(state.yChannelPageStep);
|
|
419
|
+
dir = "y";
|
|
420
|
+
break;
|
|
421
|
+
case "Home":
|
|
422
|
+
direction === "rtl" ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
|
|
423
|
+
dir = "x";
|
|
424
|
+
break;
|
|
425
|
+
case "End":
|
|
426
|
+
direction === "rtl" ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
|
|
427
|
+
dir = "x";
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
state.setDragging(false);
|
|
431
|
+
if (dir) {
|
|
432
|
+
let input = dir === "x" ? inputXRef : inputYRef;
|
|
433
|
+
focusInput(input);
|
|
434
|
+
setFocusedInput(dir);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
let moveHandler = {
|
|
439
|
+
onMoveStart () {
|
|
440
|
+
currentPosition.current = null;
|
|
441
|
+
state.setDragging(true);
|
|
442
|
+
},
|
|
443
|
+
onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
|
|
444
|
+
var _containerRef_current;
|
|
445
|
+
let { incrementX: incrementX, decrementX: decrementX, incrementY: incrementY, decrementY: decrementY, xChannelPageStep: xChannelPageStep, xChannelStep: xChannelStep, yChannelPageStep: yChannelPageStep, yChannelStep: yChannelStep, getThumbPosition: getThumbPosition, setColorFromPoint: setColorFromPoint } = state;
|
|
446
|
+
if (currentPosition.current == null) currentPosition.current = getThumbPosition();
|
|
447
|
+
let { width: width, height: height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
|
|
448
|
+
width: 0,
|
|
449
|
+
height: 0
|
|
450
|
+
};
|
|
451
|
+
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
452
|
+
if (pointerType === "keyboard") {
|
|
453
|
+
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
454
|
+
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
455
|
+
if (deltaX > 0 && direction === "ltr" || deltaX < 0 && direction === "rtl") incrementX(deltaXValue);
|
|
456
|
+
else if (deltaX < 0 && direction === "ltr" || deltaX > 0 && direction === "rtl") decrementX(deltaXValue);
|
|
457
|
+
else if (deltaY > 0) decrementY(deltaYValue);
|
|
458
|
+
else if (deltaY < 0) incrementY(deltaYValue);
|
|
459
|
+
setValueChangedViaKeyboard(valueChanged);
|
|
460
|
+
// set the focused input based on which axis has the greater delta
|
|
461
|
+
focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? "y" : "x";
|
|
462
|
+
setFocusedInput(focusedInput);
|
|
463
|
+
} else {
|
|
464
|
+
currentPosition.current.x += (direction === "rtl" ? -1 : 1) * deltaX / width;
|
|
465
|
+
currentPosition.current.y += deltaY / height;
|
|
466
|
+
setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
onMoveEnd () {
|
|
470
|
+
isOnColorArea.current = false;
|
|
471
|
+
state.setDragging(false);
|
|
472
|
+
let input = focusedInput === "x" ? inputXRef : inputYRef;
|
|
473
|
+
focusInput(input);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
let { moveProps: movePropsThumb } = (0, $kZqDi$reactariainteractions.useMove)(moveHandler);
|
|
477
|
+
let { focusWithinProps: focusWithinProps } = (0, $kZqDi$reactariainteractions.useFocusWithin)({
|
|
478
|
+
onFocusWithinChange: (focusWithin)=>{
|
|
479
|
+
if (!focusWithin) setValueChangedViaKeyboard(false);
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
let currentPointer = (0, $kZqDi$react.useRef)(undefined);
|
|
483
|
+
let isOnColorArea = (0, $kZqDi$react.useRef)(false);
|
|
484
|
+
let { moveProps: movePropsContainer } = (0, $kZqDi$reactariainteractions.useMove)({
|
|
485
|
+
onMoveStart () {
|
|
486
|
+
if (isOnColorArea.current) moveHandler.onMoveStart();
|
|
487
|
+
},
|
|
488
|
+
onMove (e) {
|
|
489
|
+
if (isOnColorArea.current) moveHandler.onMove(e);
|
|
490
|
+
},
|
|
491
|
+
onMoveEnd () {
|
|
492
|
+
if (isOnColorArea.current) moveHandler.onMoveEnd();
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
let onThumbDown = (id)=>{
|
|
496
|
+
if (!state.isDragging) {
|
|
497
|
+
currentPointer.current = id;
|
|
498
|
+
setValueChangedViaKeyboard(false);
|
|
499
|
+
focusInput();
|
|
500
|
+
state.setDragging(true);
|
|
501
|
+
if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
|
|
502
|
+
else {
|
|
503
|
+
addGlobalListener(window, "mouseup", onThumbUp, false);
|
|
504
|
+
addGlobalListener(window, "touchend", onThumbUp, false);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
let onThumbUp = (e)=>{
|
|
509
|
+
var _e_changedTouches;
|
|
510
|
+
var _e_pointerId;
|
|
511
|
+
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
512
|
+
if (id === currentPointer.current) {
|
|
513
|
+
setValueChangedViaKeyboard(false);
|
|
514
|
+
focusInput();
|
|
515
|
+
state.setDragging(false);
|
|
516
|
+
currentPointer.current = undefined;
|
|
517
|
+
isOnColorArea.current = false;
|
|
518
|
+
if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
|
|
519
|
+
else {
|
|
520
|
+
removeGlobalListener(window, "mouseup", onThumbUp, false);
|
|
521
|
+
removeGlobalListener(window, "touchend", onThumbUp, false);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
|
|
526
|
+
let rect = colorArea.getBoundingClientRect();
|
|
527
|
+
let { width: width, height: height } = rect;
|
|
528
|
+
let x = (clientX - rect.x) / width;
|
|
529
|
+
let y = (clientY - rect.y) / height;
|
|
530
|
+
if (direction === "rtl") x = 1 - x;
|
|
531
|
+
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
532
|
+
isOnColorArea.current = true;
|
|
533
|
+
setValueChangedViaKeyboard(false);
|
|
534
|
+
currentPointer.current = id;
|
|
535
|
+
state.setColorFromPoint(x, y);
|
|
536
|
+
focusInput();
|
|
537
|
+
state.setDragging(true);
|
|
538
|
+
if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onColorAreaUp, false);
|
|
539
|
+
else {
|
|
540
|
+
addGlobalListener(window, "mouseup", onColorAreaUp, false);
|
|
541
|
+
addGlobalListener(window, "touchend", onColorAreaUp, false);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
let onColorAreaUp = (e)=>{
|
|
546
|
+
var _e_changedTouches;
|
|
547
|
+
var _e_pointerId;
|
|
548
|
+
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
549
|
+
if (isOnColorArea.current && id === currentPointer.current) {
|
|
550
|
+
isOnColorArea.current = false;
|
|
551
|
+
setValueChangedViaKeyboard(false);
|
|
552
|
+
currentPointer.current = undefined;
|
|
553
|
+
state.setDragging(false);
|
|
554
|
+
focusInput();
|
|
555
|
+
if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onColorAreaUp, false);
|
|
556
|
+
else {
|
|
557
|
+
removeGlobalListener(window, "mouseup", onColorAreaUp, false);
|
|
558
|
+
removeGlobalListener(window, "touchend", onColorAreaUp, false);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
let colorAreaInteractions = isDisabled ? {} : (0, $kZqDi$reactariautils.mergeProps)({
|
|
563
|
+
...typeof PointerEvent !== "undefined" ? {
|
|
564
|
+
onPointerDown: (e)=>{
|
|
565
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
566
|
+
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
567
|
+
}
|
|
568
|
+
} : {
|
|
569
|
+
onMouseDown: (e)=>{
|
|
570
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
571
|
+
onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
572
|
+
},
|
|
573
|
+
onTouchStart: (e)=>{
|
|
574
|
+
onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}, movePropsContainer);
|
|
578
|
+
let thumbInteractions = isDisabled ? {} : (0, $kZqDi$reactariautils.mergeProps)({
|
|
579
|
+
...typeof PointerEvent !== "undefined" ? {
|
|
580
|
+
onPointerDown: (e)=>{
|
|
581
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
582
|
+
onThumbDown(e.pointerId);
|
|
583
|
+
}
|
|
584
|
+
} : {
|
|
585
|
+
onMouseDown: (e)=>{
|
|
586
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
587
|
+
onThumbDown(undefined);
|
|
588
|
+
},
|
|
589
|
+
onTouchStart: (e)=>{
|
|
590
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
594
|
+
let { focusProps: xInputFocusProps } = (0, $kZqDi$reactariainteractions.useFocus)({
|
|
595
|
+
onFocus: ()=>{
|
|
596
|
+
setFocusedInput("x");
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
let { focusProps: yInputFocusProps } = (0, $kZqDi$reactariainteractions.useFocus)({
|
|
600
|
+
onFocus: ()=>{
|
|
601
|
+
setFocusedInput("y");
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
let isMobile = (0, $kZqDi$reactariautils.isIOS)() || (0, $kZqDi$reactariautils.isAndroid)();
|
|
605
|
+
function getAriaValueTextForChannel(channel) {
|
|
606
|
+
return valueChangedViaKeyboard ? stringFormatter.format("colorNameAndValue", {
|
|
607
|
+
name: state.value.getChannelName(channel, locale),
|
|
608
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
609
|
+
}) : [
|
|
610
|
+
stringFormatter.format("colorNameAndValue", {
|
|
611
|
+
name: state.value.getChannelName(channel, locale),
|
|
612
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
613
|
+
}),
|
|
614
|
+
stringFormatter.format("colorNameAndValue", {
|
|
615
|
+
name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
|
|
616
|
+
value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
|
|
617
|
+
})
|
|
618
|
+
].join(", ");
|
|
261
619
|
}
|
|
262
|
-
|
|
620
|
+
let colorPickerLabel = stringFormatter.format("colorPicker");
|
|
621
|
+
let xInputLabellingProps = (0, $kZqDi$reactariautils.useLabels)({
|
|
622
|
+
...props,
|
|
623
|
+
"aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
|
|
624
|
+
label: ariaLabel,
|
|
625
|
+
channelLabel: colorPickerLabel
|
|
626
|
+
}) : colorPickerLabel
|
|
627
|
+
});
|
|
628
|
+
let yInputLabellingProps = (0, $kZqDi$reactariautils.useLabels)({
|
|
629
|
+
...props,
|
|
630
|
+
"aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
|
|
631
|
+
label: ariaLabel,
|
|
632
|
+
channelLabel: colorPickerLabel
|
|
633
|
+
}) : colorPickerLabel
|
|
634
|
+
});
|
|
635
|
+
let colorAreaLabellingProps = (0, $kZqDi$reactariautils.useLabels)({
|
|
636
|
+
...props,
|
|
637
|
+
"aria-label": ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
|
|
638
|
+
}, isMobile ? colorPickerLabel : undefined);
|
|
639
|
+
let ariaRoleDescription = stringFormatter.format("twoDimensionalSlider");
|
|
640
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $kZqDi$reactariavisuallyhidden.useVisuallyHidden)({
|
|
641
|
+
style: {
|
|
642
|
+
opacity: "0.0001",
|
|
643
|
+
width: "100%",
|
|
644
|
+
height: "100%",
|
|
645
|
+
pointerEvents: "none"
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
let { colorAreaStyleProps: colorAreaStyleProps, gradientStyleProps: gradientStyleProps, thumbStyleProps: thumbStyleProps } = (0, $99936ad0bf67c8c4$export$dd62420467d245ca)({
|
|
649
|
+
direction: direction,
|
|
650
|
+
state: state,
|
|
651
|
+
xChannel: xChannel,
|
|
652
|
+
zChannel: zChannel,
|
|
653
|
+
isDisabled: props.isDisabled
|
|
654
|
+
});
|
|
655
|
+
return {
|
|
656
|
+
colorAreaProps: {
|
|
657
|
+
...colorAreaLabellingProps,
|
|
658
|
+
...colorAreaInteractions,
|
|
659
|
+
...colorAreaStyleProps,
|
|
660
|
+
role: "group"
|
|
661
|
+
},
|
|
662
|
+
gradientProps: {
|
|
663
|
+
...gradientStyleProps,
|
|
664
|
+
role: "presentation"
|
|
665
|
+
},
|
|
666
|
+
thumbProps: {
|
|
667
|
+
...thumbInteractions,
|
|
668
|
+
...thumbStyleProps,
|
|
669
|
+
role: "presentation"
|
|
670
|
+
},
|
|
671
|
+
xInputProps: {
|
|
672
|
+
...xInputLabellingProps,
|
|
673
|
+
...visuallyHiddenProps,
|
|
674
|
+
...xInputFocusProps,
|
|
675
|
+
type: "range",
|
|
676
|
+
min: state.value.getChannelRange(xChannel).minValue,
|
|
677
|
+
max: state.value.getChannelRange(xChannel).maxValue,
|
|
678
|
+
step: xChannelStep,
|
|
679
|
+
"aria-roledescription": ariaRoleDescription,
|
|
680
|
+
"aria-valuetext": getAriaValueTextForChannel(xChannel),
|
|
681
|
+
disabled: isDisabled,
|
|
682
|
+
value: state.value.getChannelValue(xChannel),
|
|
683
|
+
name: xName,
|
|
684
|
+
tabIndex: isMobile || !focusedInput || focusedInput === "x" ? undefined : -1,
|
|
685
|
+
/*
|
|
686
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
687
|
+
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
688
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
689
|
+
*/ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
|
|
690
|
+
onChange: (e)=>{
|
|
691
|
+
state.setXValue(parseFloat(e.target.value));
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
yInputProps: {
|
|
695
|
+
...yInputLabellingProps,
|
|
696
|
+
...visuallyHiddenProps,
|
|
697
|
+
...yInputFocusProps,
|
|
698
|
+
type: "range",
|
|
699
|
+
min: state.value.getChannelRange(yChannel).minValue,
|
|
700
|
+
max: state.value.getChannelRange(yChannel).maxValue,
|
|
701
|
+
step: yChannelStep,
|
|
702
|
+
"aria-roledescription": ariaRoleDescription,
|
|
703
|
+
"aria-valuetext": getAriaValueTextForChannel(yChannel),
|
|
704
|
+
"aria-orientation": "vertical",
|
|
705
|
+
disabled: isDisabled,
|
|
706
|
+
value: state.value.getChannelValue(yChannel),
|
|
707
|
+
name: yName,
|
|
708
|
+
tabIndex: isMobile || focusedInput === "y" ? undefined : -1,
|
|
709
|
+
/*
|
|
710
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
711
|
+
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
712
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
713
|
+
*/ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
|
|
714
|
+
onChange: (e)=>{
|
|
715
|
+
state.setYValue(parseFloat(e.target.value));
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
263
720
|
|
|
264
|
-
let onThumbUp = e => {
|
|
265
|
-
var _e$pointerId, _e$changedTouches;
|
|
266
721
|
|
|
267
|
-
|
|
722
|
+
/*
|
|
723
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
724
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
725
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
726
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
727
|
+
*
|
|
728
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
729
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
730
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
731
|
+
* governing permissions and limitations under the License.
|
|
732
|
+
*/
|
|
268
733
|
|
|
269
|
-
if (id === currentPointer.current) {
|
|
270
|
-
focusInput();
|
|
271
|
-
state.setDragging(false);
|
|
272
|
-
currentPointer.current = undefined;
|
|
273
|
-
isOnTrack.current = false;
|
|
274
|
-
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
275
|
-
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
276
|
-
removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
let onTrackDown = (track, id, pageX, pageY) => {
|
|
281
|
-
let rect = track.getBoundingClientRect();
|
|
282
|
-
let x = pageX - rect.x - rect.width / 2;
|
|
283
|
-
let y = pageY - rect.y - rect.height / 2;
|
|
284
|
-
let radius = Math.sqrt(x * x + y * y);
|
|
285
|
-
|
|
286
|
-
if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
|
|
287
|
-
isOnTrack.current = true;
|
|
288
|
-
currentPointer.current = id;
|
|
289
|
-
stateRef.current.setHueFromPoint(x, y, radius);
|
|
290
|
-
focusInput();
|
|
291
|
-
state.setDragging(true);
|
|
292
|
-
addGlobalListener(window, 'mouseup', onTrackUp, false);
|
|
293
|
-
addGlobalListener(window, 'touchend', onTrackUp, false);
|
|
294
|
-
addGlobalListener(window, 'pointerup', onTrackUp, false);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
734
|
|
|
298
|
-
|
|
299
|
-
|
|
735
|
+
function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
736
|
+
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
|
|
737
|
+
let { locale: locale, direction: direction } = (0, $kZqDi$reactariai18n.useLocale)();
|
|
738
|
+
// Provide a default aria-label if there is no other label provided.
|
|
739
|
+
if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
|
|
740
|
+
// @ts-ignore - ignore unused incompatible props
|
|
741
|
+
let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $kZqDi$reactariaslider.useSlider)({
|
|
742
|
+
...props,
|
|
743
|
+
"aria-label": ariaLabel
|
|
744
|
+
}, state, trackRef);
|
|
745
|
+
let { inputProps: inputProps, thumbProps: thumbProps } = (0, $kZqDi$reactariaslider.useSliderThumb)({
|
|
746
|
+
index: 0,
|
|
747
|
+
orientation: orientation,
|
|
748
|
+
isDisabled: props.isDisabled,
|
|
749
|
+
name: name,
|
|
750
|
+
trackRef: trackRef,
|
|
751
|
+
inputRef: inputRef
|
|
752
|
+
}, state);
|
|
753
|
+
let generateBackground = ()=>{
|
|
754
|
+
let value = state.getDisplayColor();
|
|
755
|
+
let to;
|
|
756
|
+
if (orientation === "vertical") to = "top";
|
|
757
|
+
else if (direction === "ltr") to = "right";
|
|
758
|
+
else to = "left";
|
|
759
|
+
switch(channel){
|
|
760
|
+
case "hue":
|
|
761
|
+
return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
|
|
762
|
+
case "lightness":
|
|
763
|
+
{
|
|
764
|
+
// We have to add an extra color stop in the middle so that the hue shows up at all.
|
|
765
|
+
// Otherwise it will always just be black to white.
|
|
766
|
+
let min = state.getThumbMinValue(0);
|
|
767
|
+
let max = state.getThumbMaxValue(0);
|
|
768
|
+
let start = value.withChannelValue(channel, min).toString("css");
|
|
769
|
+
let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
|
|
770
|
+
let end = value.withChannelValue(channel, max).toString("css");
|
|
771
|
+
return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
|
|
772
|
+
}
|
|
773
|
+
case "saturation":
|
|
774
|
+
case "brightness":
|
|
775
|
+
case "red":
|
|
776
|
+
case "green":
|
|
777
|
+
case "blue":
|
|
778
|
+
case "alpha":
|
|
779
|
+
{
|
|
780
|
+
let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
|
|
781
|
+
let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
|
|
782
|
+
return `linear-gradient(to ${to}, ${start}, ${end})`;
|
|
783
|
+
}
|
|
784
|
+
default:
|
|
785
|
+
throw new Error("Unknown color channel: " + channel);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
let forcedColorAdjustNoneStyle = {
|
|
789
|
+
forcedColorAdjust: "none"
|
|
790
|
+
};
|
|
791
|
+
return {
|
|
792
|
+
trackProps: {
|
|
793
|
+
...(0, $kZqDi$reactariautils.mergeProps)(groupProps, trackProps),
|
|
794
|
+
style: {
|
|
795
|
+
...trackProps.style,
|
|
796
|
+
...forcedColorAdjustNoneStyle,
|
|
797
|
+
background: generateBackground()
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
inputProps: inputProps,
|
|
801
|
+
thumbProps: {
|
|
802
|
+
...thumbProps,
|
|
803
|
+
style: {
|
|
804
|
+
...thumbProps.style,
|
|
805
|
+
...forcedColorAdjustNoneStyle
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
labelProps: labelProps,
|
|
809
|
+
outputProps: outputProps
|
|
810
|
+
};
|
|
811
|
+
}
|
|
300
812
|
|
|
301
|
-
let id = (_e$pointerId2 = e.pointerId) != null ? _e$pointerId2 : (_e$changedTouches2 = e.changedTouches) == null ? void 0 : _e$changedTouches2[0].identifier;
|
|
302
813
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
let {
|
|
315
|
-
keyboardProps
|
|
316
|
-
} = useKeyboard({
|
|
317
|
-
onKeyDown(e) {
|
|
318
|
-
switch (e.key) {
|
|
319
|
-
case 'PageUp':
|
|
320
|
-
e.preventDefault();
|
|
321
|
-
state.increment($c5e318998f160f365e09b073e8447c3d$var$PAGE_MIN_STEP_SIZE);
|
|
322
|
-
break;
|
|
323
|
-
|
|
324
|
-
case 'PageDown':
|
|
325
|
-
e.preventDefault();
|
|
326
|
-
state.decrement($c5e318998f160f365e09b073e8447c3d$var$PAGE_MIN_STEP_SIZE);
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
814
|
+
/*
|
|
815
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
816
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
817
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
818
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
819
|
+
*
|
|
820
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
821
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
822
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
823
|
+
* governing permissions and limitations under the License.
|
|
824
|
+
*/
|
|
330
825
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
function $1d29bf243d4a9a53$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
829
|
+
let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
|
|
830
|
+
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $kZqDi$reactariautils.useGlobalListeners)();
|
|
831
|
+
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
832
|
+
let focusInput = (0, $kZqDi$react.useCallback)(()=>{
|
|
833
|
+
if (inputRef.current) (0, $kZqDi$reactariautils.focusWithoutScrolling)(inputRef.current);
|
|
834
|
+
}, [
|
|
835
|
+
inputRef
|
|
836
|
+
]);
|
|
837
|
+
(0, $kZqDi$reactariautils.useFormReset)(inputRef, state.hue, state.setHue);
|
|
838
|
+
let currentPosition = (0, $kZqDi$react.useRef)(null);
|
|
839
|
+
let { keyboardProps: keyboardProps } = (0, $kZqDi$reactariainteractions.useKeyboard)({
|
|
840
|
+
onKeyDown (e) {
|
|
841
|
+
// these are the cases that useMove doesn't handle
|
|
842
|
+
if (!/^(PageUp|PageDown)$/.test(e.key)) {
|
|
843
|
+
e.continuePropagation();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
847
|
+
e.preventDefault();
|
|
848
|
+
// remember to set this and unset it so that onChangeEnd is fired
|
|
849
|
+
state.setDragging(true);
|
|
850
|
+
switch(e.key){
|
|
851
|
+
case "PageUp":
|
|
852
|
+
e.preventDefault();
|
|
853
|
+
state.increment(state.pageStep);
|
|
854
|
+
break;
|
|
855
|
+
case "PageDown":
|
|
856
|
+
e.preventDefault();
|
|
857
|
+
state.decrement(state.pageStep);
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
state.setDragging(false);
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
let moveHandler = {
|
|
864
|
+
onMoveStart () {
|
|
865
|
+
currentPosition.current = null;
|
|
866
|
+
state.setDragging(true);
|
|
867
|
+
},
|
|
868
|
+
onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
|
|
869
|
+
if (currentPosition.current == null) currentPosition.current = state.getThumbPosition(thumbRadius);
|
|
870
|
+
currentPosition.current.x += deltaX;
|
|
871
|
+
currentPosition.current.y += deltaY;
|
|
872
|
+
if (pointerType === "keyboard") {
|
|
873
|
+
if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? state.pageStep : state.step);
|
|
874
|
+
else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? state.pageStep : state.step);
|
|
875
|
+
} else state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
|
|
876
|
+
},
|
|
877
|
+
onMoveEnd () {
|
|
878
|
+
isOnTrack.current = false;
|
|
879
|
+
state.setDragging(false);
|
|
880
|
+
focusInput();
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
let { moveProps: movePropsThumb } = (0, $kZqDi$reactariainteractions.useMove)(moveHandler);
|
|
884
|
+
let currentPointer = (0, $kZqDi$react.useRef)(undefined);
|
|
885
|
+
let isOnTrack = (0, $kZqDi$react.useRef)(false);
|
|
886
|
+
let { moveProps: movePropsContainer } = (0, $kZqDi$reactariainteractions.useMove)({
|
|
887
|
+
onMoveStart () {
|
|
888
|
+
if (isOnTrack.current) moveHandler.onMoveStart();
|
|
889
|
+
},
|
|
890
|
+
onMove (e) {
|
|
891
|
+
if (isOnTrack.current) moveHandler.onMove(e);
|
|
892
|
+
},
|
|
893
|
+
onMoveEnd () {
|
|
894
|
+
if (isOnTrack.current) moveHandler.onMoveEnd();
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
let onThumbDown = (id)=>{
|
|
898
|
+
if (!state.isDragging) {
|
|
899
|
+
currentPointer.current = id;
|
|
900
|
+
focusInput();
|
|
901
|
+
state.setDragging(true);
|
|
902
|
+
if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
|
|
903
|
+
else {
|
|
904
|
+
addGlobalListener(window, "mouseup", onThumbUp, false);
|
|
905
|
+
addGlobalListener(window, "touchend", onThumbUp, false);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
let onThumbUp = (e)=>{
|
|
910
|
+
var _e_changedTouches;
|
|
911
|
+
var _e_pointerId;
|
|
912
|
+
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
913
|
+
if (id === currentPointer.current) {
|
|
914
|
+
focusInput();
|
|
915
|
+
state.setDragging(false);
|
|
916
|
+
currentPointer.current = undefined;
|
|
917
|
+
isOnTrack.current = false;
|
|
918
|
+
if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
|
|
919
|
+
else {
|
|
920
|
+
removeGlobalListener(window, "mouseup", onThumbUp, false);
|
|
921
|
+
removeGlobalListener(window, "touchend", onThumbUp, false);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
let onTrackDown = (track, id, pageX, pageY)=>{
|
|
926
|
+
let rect = track.getBoundingClientRect();
|
|
927
|
+
let x = pageX - rect.x - rect.width / 2;
|
|
928
|
+
let y = pageY - rect.y - rect.height / 2;
|
|
929
|
+
let radius = Math.sqrt(x * x + y * y);
|
|
930
|
+
if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
|
|
931
|
+
isOnTrack.current = true;
|
|
932
|
+
currentPointer.current = id;
|
|
933
|
+
state.setHueFromPoint(x, y, radius);
|
|
934
|
+
focusInput();
|
|
935
|
+
state.setDragging(true);
|
|
936
|
+
if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onTrackUp, false);
|
|
937
|
+
else {
|
|
938
|
+
addGlobalListener(window, "mouseup", onTrackUp, false);
|
|
939
|
+
addGlobalListener(window, "touchend", onTrackUp, false);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
let onTrackUp = (e)=>{
|
|
944
|
+
var _e_changedTouches;
|
|
945
|
+
var _e_pointerId;
|
|
946
|
+
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
947
|
+
if (isOnTrack.current && id === currentPointer.current) {
|
|
948
|
+
isOnTrack.current = false;
|
|
949
|
+
currentPointer.current = undefined;
|
|
950
|
+
state.setDragging(false);
|
|
951
|
+
focusInput();
|
|
952
|
+
if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onTrackUp, false);
|
|
953
|
+
else {
|
|
954
|
+
removeGlobalListener(window, "mouseup", onTrackUp, false);
|
|
955
|
+
removeGlobalListener(window, "touchend", onTrackUp, false);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
let trackInteractions = isDisabled ? {} : (0, $kZqDi$reactariautils.mergeProps)({
|
|
960
|
+
...typeof PointerEvent !== "undefined" ? {
|
|
961
|
+
onPointerDown: (e)=>{
|
|
962
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
963
|
+
onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
964
|
+
}
|
|
965
|
+
} : {
|
|
966
|
+
onMouseDown: (e)=>{
|
|
967
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
968
|
+
onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
969
|
+
},
|
|
970
|
+
onTouchStart: (e)=>{
|
|
971
|
+
onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}, movePropsContainer);
|
|
975
|
+
let thumbInteractions = isDisabled ? {} : (0, $kZqDi$reactariautils.mergeProps)({
|
|
976
|
+
onMouseDown: (e)=>{
|
|
977
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
978
|
+
onThumbDown(undefined);
|
|
979
|
+
},
|
|
980
|
+
onPointerDown: (e)=>{
|
|
981
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
982
|
+
onThumbDown(e.pointerId);
|
|
983
|
+
},
|
|
984
|
+
onTouchStart: (e)=>{
|
|
985
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
986
|
+
}
|
|
987
|
+
}, keyboardProps, movePropsThumb);
|
|
988
|
+
let { x: x, y: y } = state.getThumbPosition(thumbRadius);
|
|
989
|
+
// Provide a default aria-label if none is given
|
|
990
|
+
let { locale: locale } = (0, $kZqDi$reactariai18n.useLocale)();
|
|
991
|
+
if (ariaLabel == null && props["aria-labelledby"] == null) ariaLabel = state.value.getChannelName("hue", locale);
|
|
992
|
+
let inputLabellingProps = (0, $kZqDi$reactariautils.useLabels)({
|
|
993
|
+
...props,
|
|
994
|
+
"aria-label": ariaLabel
|
|
995
|
+
});
|
|
996
|
+
let { minValue: minValue, maxValue: maxValue, step: step } = state.value.getChannelRange("hue");
|
|
997
|
+
let forcedColorAdjustNoneStyle = {
|
|
998
|
+
forcedColorAdjust: "none"
|
|
999
|
+
};
|
|
1000
|
+
return {
|
|
1001
|
+
trackProps: {
|
|
1002
|
+
...trackInteractions,
|
|
1003
|
+
style: {
|
|
1004
|
+
position: "relative",
|
|
1005
|
+
touchAction: "none",
|
|
1006
|
+
width: outerRadius * 2,
|
|
1007
|
+
height: outerRadius * 2,
|
|
1008
|
+
background: `
|
|
1009
|
+
conic-gradient(
|
|
1010
|
+
from 90deg,
|
|
1011
|
+
hsl(0, 100%, 50%),
|
|
1012
|
+
hsl(30, 100%, 50%),
|
|
1013
|
+
hsl(60, 100%, 50%),
|
|
1014
|
+
hsl(90, 100%, 50%),
|
|
1015
|
+
hsl(120, 100%, 50%),
|
|
1016
|
+
hsl(150, 100%, 50%),
|
|
1017
|
+
hsl(180, 100%, 50%),
|
|
1018
|
+
hsl(210, 100%, 50%),
|
|
1019
|
+
hsl(240, 100%, 50%),
|
|
1020
|
+
hsl(270, 100%, 50%),
|
|
1021
|
+
hsl(300, 100%, 50%),
|
|
1022
|
+
hsl(330, 100%, 50%),
|
|
1023
|
+
hsl(360, 100%, 50%)
|
|
1024
|
+
)
|
|
1025
|
+
`,
|
|
1026
|
+
clipPath: `path(evenodd, "${$1d29bf243d4a9a53$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$1d29bf243d4a9a53$var$circlePath(outerRadius, outerRadius, innerRadius)}")`,
|
|
1027
|
+
...forcedColorAdjustNoneStyle
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
thumbProps: {
|
|
1031
|
+
...thumbInteractions,
|
|
1032
|
+
style: {
|
|
1033
|
+
position: "absolute",
|
|
1034
|
+
left: "50%",
|
|
1035
|
+
top: "50%",
|
|
1036
|
+
transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
|
|
1037
|
+
touchAction: "none",
|
|
1038
|
+
...forcedColorAdjustNoneStyle
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
inputProps: (0, $kZqDi$reactariautils.mergeProps)(inputLabellingProps, {
|
|
1042
|
+
type: "range",
|
|
1043
|
+
min: String(minValue),
|
|
1044
|
+
max: String(maxValue),
|
|
1045
|
+
step: String(step),
|
|
1046
|
+
"aria-valuetext": state.value.formatChannelValue("hue", locale),
|
|
1047
|
+
disabled: isDisabled,
|
|
1048
|
+
value: `${state.value.getChannelValue("hue")}`,
|
|
1049
|
+
name: name,
|
|
1050
|
+
onChange: (e)=>{
|
|
1051
|
+
state.setHue(parseFloat(e.target.value));
|
|
1052
|
+
}
|
|
1053
|
+
})
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
// Creates an SVG path string for a circle.
|
|
1057
|
+
function $1d29bf243d4a9a53$var$circlePath(cx, cy, r) {
|
|
1058
|
+
return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;
|
|
426
1059
|
}
|
|
427
1060
|
|
|
428
|
-
/**
|
|
429
|
-
* Provides the behavior and accessibility implementation for a color field component.
|
|
430
|
-
* Color fields allow users to enter and adjust a hex color value.
|
|
431
|
-
*/
|
|
432
|
-
function useColorField(props, state, ref) {
|
|
433
|
-
let {
|
|
434
|
-
isDisabled,
|
|
435
|
-
isReadOnly,
|
|
436
|
-
isRequired
|
|
437
|
-
} = props;
|
|
438
|
-
let {
|
|
439
|
-
colorValue,
|
|
440
|
-
inputValue,
|
|
441
|
-
commit,
|
|
442
|
-
increment,
|
|
443
|
-
decrement,
|
|
444
|
-
incrementToMax,
|
|
445
|
-
decrementToMin
|
|
446
|
-
} = state;
|
|
447
|
-
let inputId = useId();
|
|
448
|
-
let {
|
|
449
|
-
spinButtonProps
|
|
450
|
-
} = useSpinButton({
|
|
451
|
-
isDisabled,
|
|
452
|
-
isReadOnly,
|
|
453
|
-
isRequired,
|
|
454
|
-
maxValue: 0xFFFFFF,
|
|
455
|
-
minValue: 0,
|
|
456
|
-
onIncrement: increment,
|
|
457
|
-
onIncrementToMax: incrementToMax,
|
|
458
|
-
onDecrement: decrement,
|
|
459
|
-
onDecrementToMin: decrementToMin,
|
|
460
|
-
value: colorValue ? colorValue.toHexInt() : undefined,
|
|
461
|
-
textValue: colorValue ? colorValue.toString('hex') : undefined
|
|
462
|
-
});
|
|
463
|
-
let [focusWithin, setFocusWithin] = useState(false);
|
|
464
|
-
let {
|
|
465
|
-
focusWithinProps
|
|
466
|
-
} = useFocusWithin({
|
|
467
|
-
isDisabled,
|
|
468
|
-
onFocusWithinChange: setFocusWithin
|
|
469
|
-
});
|
|
470
|
-
let onWheel = useCallback(e => {
|
|
471
|
-
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
1061
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
})
|
|
513
|
-
|
|
1062
|
+
/*
|
|
1063
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1064
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1065
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1066
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1067
|
+
*
|
|
1068
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1069
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1070
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1071
|
+
* governing permissions and limitations under the License.
|
|
1072
|
+
*/
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
function $58c850037bc7a7ce$export$77e32ca575a28fdf(props, state, ref) {
|
|
1079
|
+
let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
|
|
1080
|
+
let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
|
|
1081
|
+
let inputId = (0, $kZqDi$reactariautils.useId)();
|
|
1082
|
+
let { spinButtonProps: spinButtonProps } = (0, $kZqDi$reactariaspinbutton.useSpinButton)({
|
|
1083
|
+
isDisabled: isDisabled,
|
|
1084
|
+
isReadOnly: isReadOnly,
|
|
1085
|
+
isRequired: isRequired,
|
|
1086
|
+
maxValue: 0xFFFFFF,
|
|
1087
|
+
minValue: 0,
|
|
1088
|
+
onIncrement: increment,
|
|
1089
|
+
onIncrementToMax: incrementToMax,
|
|
1090
|
+
onDecrement: decrement,
|
|
1091
|
+
onDecrementToMin: decrementToMin,
|
|
1092
|
+
value: colorValue ? colorValue.toHexInt() : undefined,
|
|
1093
|
+
textValue: colorValue ? colorValue.toString("hex") : undefined
|
|
1094
|
+
});
|
|
1095
|
+
let [focusWithin, setFocusWithin] = (0, $kZqDi$react.useState)(false);
|
|
1096
|
+
let { focusWithinProps: focusWithinProps } = (0, $kZqDi$reactariainteractions.useFocusWithin)({
|
|
1097
|
+
isDisabled: isDisabled,
|
|
1098
|
+
onFocusWithinChange: setFocusWithin
|
|
1099
|
+
});
|
|
1100
|
+
let onWheel = (0, $kZqDi$react.useCallback)((e)=>{
|
|
1101
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
1102
|
+
if (e.deltaY > 0) increment();
|
|
1103
|
+
else if (e.deltaY < 0) decrement();
|
|
1104
|
+
}, [
|
|
1105
|
+
decrement,
|
|
1106
|
+
increment
|
|
1107
|
+
]);
|
|
1108
|
+
// If the input isn't supposed to receive input, disable scrolling.
|
|
1109
|
+
let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
|
|
1110
|
+
(0, $kZqDi$reactariainteractions.useScrollWheel)({
|
|
1111
|
+
onScroll: onWheel,
|
|
1112
|
+
isDisabled: scrollingDisabled
|
|
1113
|
+
}, ref);
|
|
1114
|
+
let onChange = (value)=>{
|
|
1115
|
+
if (state.validate(value)) state.setInputValue(value);
|
|
1116
|
+
};
|
|
1117
|
+
let { inputProps: inputProps, ...otherProps } = (0, $kZqDi$reactariatextfield.useFormattedTextField)((0, $kZqDi$reactariautils.mergeProps)(props, {
|
|
1118
|
+
id: inputId,
|
|
1119
|
+
value: inputValue,
|
|
1120
|
+
defaultValue: undefined,
|
|
1121
|
+
validate: undefined,
|
|
1122
|
+
[(0, $kZqDi$reactstatelyform.privateValidationStateProp)]: state,
|
|
1123
|
+
type: "text",
|
|
1124
|
+
autoComplete: "off",
|
|
1125
|
+
onChange: onChange
|
|
1126
|
+
}), state, ref);
|
|
1127
|
+
inputProps = (0, $kZqDi$reactariautils.mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
1128
|
+
role: "textbox",
|
|
1129
|
+
"aria-valuemax": null,
|
|
1130
|
+
"aria-valuemin": null,
|
|
1131
|
+
"aria-valuenow": null,
|
|
1132
|
+
"aria-valuetext": null,
|
|
1133
|
+
autoCorrect: "off",
|
|
1134
|
+
spellCheck: "false",
|
|
1135
|
+
onBlur: commit
|
|
1136
|
+
});
|
|
1137
|
+
if (validationBehavior === "native") inputProps["aria-required"] = undefined;
|
|
1138
|
+
return {
|
|
1139
|
+
inputProps: inputProps,
|
|
1140
|
+
...otherProps
|
|
1141
|
+
};
|
|
514
1142
|
}
|
|
515
1143
|
|
|
516
|
-
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
517
1147
|
//# sourceMappingURL=main.js.map
|