@spectrum-web-components/color-wheel 1.7.0 → 1.8.0
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/README.md +291 -23
- package/custom-elements.json +16 -1
- package/package.json +5 -5
- package/sp-color-wheel.d.ts +11 -0
- package/sp-color-wheel.dev.js.map +1 -1
- package/sp-color-wheel.js.map +1 -1
- package/src/ColorWheel.d.ts +14 -1
- package/src/ColorWheel.dev.js +14 -8
- package/src/ColorWheel.dev.js.map +2 -2
- package/src/ColorWheel.js +3 -3
- package/src/ColorWheel.js.map +2 -2
- package/src/color-wheel-overrides.css.dev.js.map +1 -1
- package/src/color-wheel-overrides.css.js.map +1 -1
- package/src/color-wheel.css.dev.js.map +1 -1
- package/src/color-wheel.css.js.map +1 -1
- package/src/index.d.ts +11 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-color-wheel.css.dev.js.map +1 -1
- package/src/spectrum-color-wheel.css.js.map +1 -1
- package/src/types.d.ts +11 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Overview
|
|
2
2
|
|
|
3
|
-
An `<sp-color-wheel>`
|
|
3
|
+
An `<sp-color-wheel>` allows users to visually select the hue of a color on a circular track. It's commonly used together with other color components to create comprehensive color selection interfaces.
|
|
4
4
|
|
|
5
5
|
### Usage
|
|
6
6
|
|
|
@@ -8,57 +8,325 @@ An `<sp-color-wheel>` lets users visually change an individual channel of a colo
|
|
|
8
8
|
[](https://bundlephobia.com/result?p=@spectrum-web-components/color-wheel)
|
|
9
9
|
[](https://stackblitz.com/edit/vitejs-vite-cqyqwmbq)
|
|
10
10
|
|
|
11
|
-
```
|
|
11
|
+
```bash
|
|
12
12
|
yarn add @spectrum-web-components/color-wheel
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Import the side effectful registration of `<sp-color-wheel>` via:
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```javascript
|
|
18
18
|
import '@spectrum-web-components/color-wheel/sp-color-wheel.js';
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
When looking to leverage the `ColorWheel` base class as a type and/or for extension purposes, do so via:
|
|
22
22
|
|
|
23
|
-
```
|
|
23
|
+
```javascript
|
|
24
24
|
import { ColorWheel } from '@spectrum-web-components/color-wheel';
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### Anatomy
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The color wheel consists of several key parts:
|
|
30
|
+
|
|
31
|
+
- A circular track displaying the full spectrum of hues
|
|
32
|
+
- A draggable handle that indicates the current hue selection
|
|
33
|
+
- Accessible labels for screen readers
|
|
34
|
+
- Optional custom gradient slot for advanced styling
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<sp-color-wheel></sp-color-wheel>
|
|
38
|
+
```
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
### Custom Gradient
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
- HSV, HSVA
|
|
35
|
-
- HSL, HSLA
|
|
36
|
-
- RGB, RGBA
|
|
37
|
-
- Strings (eg "red", "blue")
|
|
42
|
+
**⚠️ Deprecated Feature**
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
The custom gradient functionality has been deprecated and is no longer supported. While the `gradient` slot may still be present in the component's code, it is broken and will not work as intended.
|
|
45
|
+
|
|
46
|
+
If you previously relied on custom gradients for the color wheel, you should:
|
|
47
|
+
|
|
48
|
+
- Use the default color wheel appearance
|
|
49
|
+
- Consider alternative approaches for custom styling
|
|
50
|
+
- Remove any existing custom gradient implementations
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
**Note**: Even if you find the `gradient` slot in the component's source code, this feature is non-functional and should not be used in new implementations.
|
|
53
|
+
|
|
54
|
+
### Options
|
|
55
|
+
|
|
56
|
+
#### Properties
|
|
57
|
+
|
|
58
|
+
The color wheel supports several properties for configuration:
|
|
59
|
+
|
|
60
|
+
##### Value (Hue)
|
|
61
|
+
|
|
62
|
+
The `value` property controls the hue angle of the color wheel (0-360 degrees). This represents the position of the handle on the circular track and determines the hue component of the displayed color.
|
|
43
63
|
|
|
44
64
|
```html
|
|
45
|
-
<sp-color-wheel></sp-color-wheel>
|
|
65
|
+
<sp-color-wheel value="180"></sp-color-wheel>
|
|
46
66
|
```
|
|
47
67
|
|
|
48
|
-
|
|
68
|
+
##### Color Values
|
|
49
69
|
|
|
50
|
-
|
|
70
|
+
The color wheel supports a wide variety of color formats for setting and getting color values:
|
|
51
71
|
|
|
52
72
|
```html
|
|
53
|
-
<
|
|
73
|
+
<div style="display: flex; gap: 16px;">
|
|
74
|
+
<sp-color-wheel color="#7277b5"></sp-color-wheel>
|
|
75
|
+
<sp-color-wheel color="hsl(96, 84.00%, 49.00%)"></sp-color-wheel>
|
|
76
|
+
<sp-color-wheel color="red"></sp-color-wheel>
|
|
77
|
+
</div>
|
|
54
78
|
```
|
|
55
79
|
|
|
56
|
-
|
|
80
|
+
<sp-table>
|
|
81
|
+
<sp-table-head>
|
|
82
|
+
<sp-table-head-cell>Format</sp-table-head-cell>
|
|
83
|
+
<sp-table-head-cell>Example Values</sp-table-head-cell>
|
|
84
|
+
<sp-table-head-cell>Description</sp-table-head-cell>
|
|
85
|
+
</sp-table-head>
|
|
86
|
+
<sp-table-body>
|
|
87
|
+
<sp-table-row>
|
|
88
|
+
<sp-table-cell>Hex3</sp-table-cell>
|
|
89
|
+
<sp-table-cell><code>#f00</code>, <code>#0a5</code></sp-table-cell>
|
|
90
|
+
<sp-table-cell>3-digit hexadecimal</sp-table-cell>
|
|
91
|
+
</sp-table-row>
|
|
92
|
+
<sp-table-row>
|
|
93
|
+
<sp-table-cell>Hex4</sp-table-cell>
|
|
94
|
+
<sp-table-cell><code>#f00f</code>, <code>#0a58</code></sp-table-cell>
|
|
95
|
+
<sp-table-cell>3-digit hexadecimal + alpha</sp-table-cell>
|
|
96
|
+
</sp-table-row>
|
|
97
|
+
<sp-table-row>
|
|
98
|
+
<sp-table-cell>Hex6</sp-table-cell>
|
|
99
|
+
<sp-table-cell><code>#ff0000</code>, <code>#00aa55</code></sp-table-cell>
|
|
100
|
+
<sp-table-cell>6-digit hexadecimal</sp-table-cell>
|
|
101
|
+
</sp-table-row>
|
|
102
|
+
<sp-table-row>
|
|
103
|
+
<sp-table-cell>Hex8</sp-table-cell>
|
|
104
|
+
<sp-table-cell><code>#ff0000ff</code>, <code>#00aa5580</code></sp-table-cell>
|
|
105
|
+
<sp-table-cell>6-digit hexadecimal + alpha</sp-table-cell>
|
|
106
|
+
</sp-table-row>
|
|
107
|
+
<sp-table-row>
|
|
108
|
+
<sp-table-cell>RGB</sp-table-cell>
|
|
109
|
+
<sp-table-cell><code>rgb(255, 0, 0)</code>, <code>rgb(0, 170, 85)</code></sp-table-cell>
|
|
110
|
+
<sp-table-cell>Red, Green, Blue values (0-255)</sp-table-cell>
|
|
111
|
+
</sp-table-row>
|
|
112
|
+
<sp-table-row>
|
|
113
|
+
<sp-table-cell>RGBA</sp-table-cell>
|
|
114
|
+
<sp-table-cell><code>rgba(255, 0, 0, 1)</code>, <code>rgba(0, 170, 85, 0.5)</code></sp-table-cell>
|
|
115
|
+
<sp-table-cell>RGB + Alpha channel (0-1)</sp-table-cell>
|
|
116
|
+
</sp-table-row>
|
|
117
|
+
<sp-table-row>
|
|
118
|
+
<sp-table-cell>HSL</sp-table-cell>
|
|
119
|
+
<sp-table-cell><code>hsl(0, 100%, 50%)</code>, <code>hsl(150, 100%, 33%)</code></sp-table-cell>
|
|
120
|
+
<sp-table-cell>Hue (0-360°), Saturation, Lightness</sp-table-cell>
|
|
121
|
+
</sp-table-row>
|
|
122
|
+
<sp-table-row>
|
|
123
|
+
<sp-table-cell>HSLA</sp-table-cell>
|
|
124
|
+
<sp-table-cell><code>hsla(0, 100%, 50%, 1)</code>, <code>hsla(150, 100%, 33%, 0.5)</code></sp-table-cell>
|
|
125
|
+
<sp-table-cell>HSL + Alpha channel (0-1)</sp-table-cell>
|
|
126
|
+
</sp-table-row>
|
|
127
|
+
<sp-table-row>
|
|
128
|
+
<sp-table-cell>HSV</sp-table-cell>
|
|
129
|
+
<sp-table-cell><code>hsv(0, 100%, 100%)</code>, <code>hsv(150, 100%, 67%)</code></sp-table-cell>
|
|
130
|
+
<sp-table-cell>Hue (0-360°), Saturation, Value</sp-table-cell>
|
|
131
|
+
</sp-table-row>
|
|
132
|
+
<sp-table-row>
|
|
133
|
+
<sp-table-cell>HSVA</sp-table-cell>
|
|
134
|
+
<sp-table-cell><code>hsva(0, 100%, 100%, 1)</code>, <code>hsva(150, 100%, 67%, 0.5)</code></sp-table-cell>
|
|
135
|
+
<sp-table-cell>HSV + Alpha channel (0-1)</sp-table-cell>
|
|
136
|
+
</sp-table-row>
|
|
137
|
+
<sp-table-row>
|
|
138
|
+
<sp-table-cell>Named Colors</sp-table-cell>
|
|
139
|
+
<sp-table-cell><code>red</code>, <code>rebeccapurple</code>, <code>darkseagreen</code></sp-table-cell>
|
|
140
|
+
<sp-table-cell>CSS color keywords (<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">full list</a>)</sp-table-cell>
|
|
141
|
+
</sp-table-row>
|
|
142
|
+
</sp-table-body>
|
|
143
|
+
</sp-table>
|
|
144
|
+
</br>
|
|
145
|
+
|
|
146
|
+
##### Step Size
|
|
147
|
+
|
|
148
|
+
The `step` attribute controls the increment of hue adjustment when using keyboard navigation. It defines how many degrees the hue changes with each arrow key press:
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<div style="display: flex; gap: 16px;">
|
|
152
|
+
<sp-color-wheel step="1" label="Fine Control (1° per key)"></sp-color-wheel>
|
|
153
|
+
<sp-color-wheel
|
|
154
|
+
step="10"
|
|
155
|
+
label="Medium Control (10° per key)"
|
|
156
|
+
></sp-color-wheel>
|
|
157
|
+
<sp-color-wheel
|
|
158
|
+
step="45"
|
|
159
|
+
label="Coarse Control (45° per key)"
|
|
160
|
+
></sp-color-wheel>
|
|
161
|
+
</div>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The step size affects keyboard navigation:
|
|
165
|
+
|
|
166
|
+
- Regular arrow keys move by the step value
|
|
167
|
+
- <kbd>Shift</kbd> + arrow keys move by 10× the step value
|
|
168
|
+
- Choose your step size based on your use case:
|
|
169
|
+
- **step="1"**: Precise color selection, best for professional design tools
|
|
170
|
+
- **step="10"**: Balanced control, good for general use
|
|
171
|
+
- **step="45"**: Quick selection between major hues, ideal for simple color pickers
|
|
172
|
+
|
|
173
|
+
##### Label
|
|
174
|
+
|
|
175
|
+
Provide a custom aria-label for accessibility:
|
|
176
|
+
|
|
177
|
+
```html
|
|
178
|
+
<sp-color-wheel label="Select color hue"></sp-color-wheel>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
##### Direction
|
|
182
|
+
|
|
183
|
+
The color wheel supports both left-to-right and right-to-left layouts:
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<sp-color-wheel dir="rtl"></sp-color-wheel>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
##### Tab Index
|
|
190
|
+
|
|
191
|
+
The `tabIndex` property controls the tab order of the color wheel within the page. This follows the standard HTML `tabindex` attribute behavior:
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<div style="display: flex; gap: 16px;">
|
|
195
|
+
<div style="text-align: center;">
|
|
196
|
+
<div style="font-weight: bold; margin-bottom: 8px;">
|
|
197
|
+
Default Tab Order
|
|
198
|
+
</div>
|
|
199
|
+
<sp-color-wheel></sp-color-wheel>
|
|
200
|
+
</div>
|
|
201
|
+
<div style="text-align: center;">
|
|
202
|
+
<div style="font-weight: bold; margin-bottom: 8px;">
|
|
203
|
+
Skip in Tab Order
|
|
204
|
+
</div>
|
|
205
|
+
<sp-color-wheel tabindex="-1"></sp-color-wheel>
|
|
206
|
+
</div>
|
|
207
|
+
<div style="text-align: center;">
|
|
208
|
+
<div style="font-weight: bold; margin-bottom: 8px;">
|
|
209
|
+
Custom Tab Order
|
|
210
|
+
</div>
|
|
211
|
+
<sp-color-wheel tabindex="5"></sp-color-wheel>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Note**: See the general documentation about the [HTML tabindex property](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) for detailed information about tab order behavior.
|
|
217
|
+
|
|
218
|
+
#### Custom Sizing
|
|
219
|
+
|
|
220
|
+
An `<sp-color-wheel>`'s size can be customized appropriately for its context. By default, the size is 192 px.
|
|
57
221
|
|
|
58
|
-
|
|
222
|
+
##### Using Inline Styles
|
|
59
223
|
|
|
60
|
-
|
|
224
|
+
You can set custom dimensions using inline styles. For a perfect circle, ensure width and height are the same:
|
|
61
225
|
|
|
62
226
|
```html
|
|
63
227
|
<sp-color-wheel style="width: 300px; height: 300px;"></sp-color-wheel>
|
|
64
228
|
```
|
|
229
|
+
|
|
230
|
+
##### Using Mod Tokens
|
|
231
|
+
|
|
232
|
+
The component exposes CSS custom properties for consistent theming. Both `--mod-colorwheel-width` and `--mod-colorwheel-height` should be set to the same value to maintain a perfect circle:
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<sp-color-wheel
|
|
236
|
+
style="--mod-colorwheel-width: 250px; --mod-colorwheel-height: 250px;"
|
|
237
|
+
></sp-color-wheel>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Note**: The CSS internally reuses the width value for both dimensions, but both mod tokens are exposed for flexibility in custom implementations.
|
|
241
|
+
|
|
242
|
+
### States
|
|
243
|
+
|
|
244
|
+
#### Disabled
|
|
245
|
+
|
|
246
|
+
A color wheel in a disabled state shows that an input exists, but is not available in that circumstance. This can be used to maintain layout continuity and communicate that the wheel may become available later.
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<sp-color-wheel disabled></sp-color-wheel>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Focused
|
|
253
|
+
|
|
254
|
+
The color wheel manages its focused state automatically, providing visual feedback during keyboard navigation:
|
|
255
|
+
|
|
256
|
+
```html
|
|
257
|
+
<sp-color-wheel focused></sp-color-wheel>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Behaviors
|
|
261
|
+
|
|
262
|
+
#### Color Formatting
|
|
263
|
+
|
|
264
|
+
When using the color elements, use `el.color` to access the `color` property, which should manage itself in the color format supplied. If you supply a color in `rgb()` format, `el.color` should return the color in `rgb()` format, as well.
|
|
265
|
+
|
|
266
|
+
**Please note for the following formats: HSV, HSVA, HSL, HSLA**
|
|
267
|
+
When using the HSL or HSV formats, and a color's value (in HSV) is set to 0, or its luminosity (in HSL) is set to 0 or 1, the hue and saturation values may not be preserved by the element's `color` property. This is detailed in the [colorjs documentation](https://colorjs.io/docs/). Separately, the element's `value` property is directly managed by the hue as represented in the interface.
|
|
268
|
+
|
|
269
|
+
#### Pointer Interactions
|
|
270
|
+
|
|
271
|
+
The color wheel supports both mouse and touch interactions:
|
|
272
|
+
|
|
273
|
+
- **Click**: Jump to a specific hue on the wheel
|
|
274
|
+
- **Drag**: Continuously adjust hue while dragging around the wheel
|
|
275
|
+
- **Touch**: Full touch support for mobile devices
|
|
276
|
+
|
|
277
|
+
#### Focus Management
|
|
278
|
+
|
|
279
|
+
The color wheel automatically manages focus for keyboard accessibility, ensuring proper focus indication and keyboard operability.
|
|
280
|
+
|
|
281
|
+
### Accessibility
|
|
282
|
+
|
|
283
|
+
The `<sp-color-wheel>` is rendered with appropriate ARIA attributes to ensure accessibility for screen readers and keyboard navigation.
|
|
284
|
+
|
|
285
|
+
#### Keyboard Navigation
|
|
286
|
+
|
|
287
|
+
The color wheel supports comprehensive keyboard interaction:
|
|
288
|
+
|
|
289
|
+
<sp-table>
|
|
290
|
+
<sp-table-head>
|
|
291
|
+
<sp-table-head-cell>Key</sp-table-head-cell>
|
|
292
|
+
<sp-table-head-cell>Action</sp-table-head-cell>
|
|
293
|
+
</sp-table-head>
|
|
294
|
+
<sp-table-body>
|
|
295
|
+
<sp-table-row>
|
|
296
|
+
<sp-table-cell><kbd>Arrow Left</kbd>/<kbd>Arrow Right</kbd></sp-table-cell>
|
|
297
|
+
<sp-table-cell>Decrease/Increase hue by step value (respects RTL)</sp-table-cell>
|
|
298
|
+
</sp-table-row>
|
|
299
|
+
<sp-table-row>
|
|
300
|
+
<sp-table-cell><kbd>Arrow Up</kbd>/<kbd>Arrow Down</kbd></sp-table-cell>
|
|
301
|
+
<sp-table-cell>Increase/Decrease hue by step value</sp-table-cell>
|
|
302
|
+
</sp-table-row>
|
|
303
|
+
<sp-table-row>
|
|
304
|
+
<sp-table-cell><kbd>Shift</kbd> + Arrow Keys</sp-table-cell>
|
|
305
|
+
<sp-table-cell>Adjust hue by larger increments (10× step)</sp-table-cell>
|
|
306
|
+
</sp-table-row>
|
|
307
|
+
</sp-table-body>
|
|
308
|
+
</sp-table>
|
|
309
|
+
|
|
310
|
+
#### ARIA Attributes
|
|
311
|
+
|
|
312
|
+
The component provides comprehensive ARIA support:
|
|
313
|
+
|
|
314
|
+
- **Role**: Uses native `input[type="range"]` with implicit "slider" role
|
|
315
|
+
- **Label**: Customizable via the `label` property (defaults to "hue")
|
|
316
|
+
- **Value Text**: Announces the current hue value in degrees with proper internationalization
|
|
317
|
+
- **Orientation**: Implicitly circular, supporting both LTR and RTL layouts
|
|
318
|
+
|
|
319
|
+
#### Screen Reader Support
|
|
320
|
+
|
|
321
|
+
The component provides meaningful announcements for assistive technologies:
|
|
322
|
+
|
|
323
|
+
- Current hue value announced in degrees (e.g., "180 degrees")
|
|
324
|
+
- Internationalized number formatting based on user's locale
|
|
325
|
+
- Clear indication of the control's purpose through proper labeling
|
|
326
|
+
|
|
327
|
+
#### Mobile Accessibility
|
|
328
|
+
|
|
329
|
+
The color wheel is fully accessible on mobile devices with:
|
|
330
|
+
|
|
331
|
+
- Touch-friendly interaction areas
|
|
332
|
+
- Proper focus management for mobile screen readers
|
package/custom-elements.json
CHANGED
|
@@ -124,12 +124,27 @@
|
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
"kind": "field",
|
|
127
|
-
"name": "
|
|
127
|
+
"name": "_baseStep",
|
|
128
128
|
"type": {
|
|
129
129
|
"text": "number"
|
|
130
130
|
},
|
|
131
|
+
"privacy": "private",
|
|
132
|
+
"default": "1"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"kind": "field",
|
|
136
|
+
"name": "altered",
|
|
131
137
|
"privacy": "private"
|
|
132
138
|
},
|
|
139
|
+
{
|
|
140
|
+
"kind": "field",
|
|
141
|
+
"name": "effectiveStep",
|
|
142
|
+
"type": {
|
|
143
|
+
"text": "number"
|
|
144
|
+
},
|
|
145
|
+
"privacy": "private",
|
|
146
|
+
"readonly": true
|
|
147
|
+
},
|
|
133
148
|
{
|
|
134
149
|
"kind": "field",
|
|
135
150
|
"name": "_altered",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/color-wheel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"css"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@spectrum-web-components/base": "1.
|
|
72
|
-
"@spectrum-web-components/color-handle": "1.
|
|
73
|
-
"@spectrum-web-components/reactive-controllers": "1.
|
|
74
|
-
"@spectrum-web-components/shared": "1.
|
|
71
|
+
"@spectrum-web-components/base": "1.8.0",
|
|
72
|
+
"@spectrum-web-components/color-handle": "1.8.0",
|
|
73
|
+
"@spectrum-web-components/reactive-controllers": "1.8.0",
|
|
74
|
+
"@spectrum-web-components/shared": "1.8.0"
|
|
75
75
|
},
|
|
76
76
|
"types": "./src/index.d.ts",
|
|
77
77
|
"customElements": "custom-elements.json",
|
package/sp-color-wheel.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
1
12
|
import { ColorWheel } from './src/ColorWheel.js';
|
|
2
13
|
declare global {
|
|
3
14
|
interface HTMLElementTagNameMap {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-color-wheel.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { ColorWheel } from './src/ColorWheel.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-color-wheel', ColorWheel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-wheel': ColorWheel;\n }\n}\n"],
|
|
5
5
|
"mappings": ";AAYA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAE9B,cAAc,kBAAkB,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-color-wheel.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-color-wheel.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { ColorWheel } from './src/ColorWheel.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-color-wheel', ColorWheel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-wheel': ColorWheel;\n }\n}\n"],
|
|
5
5
|
"mappings": "aAYA,OAAS,cAAAA,MAAkB,sBAC3B,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,iBAAkBD,CAAU",
|
|
6
6
|
"names": ["ColorWheel", "defineElement"]
|
|
7
7
|
}
|
package/src/ColorWheel.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
1
12
|
import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
|
|
2
13
|
import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
|
|
3
14
|
import '@spectrum-web-components/color-handle/sp-color-handle.js';
|
|
@@ -22,8 +33,9 @@ export declare class ColorWheel extends Focusable {
|
|
|
22
33
|
set value(hue: number);
|
|
23
34
|
get color(): ColorTypes;
|
|
24
35
|
set color(color: ColorTypes);
|
|
25
|
-
private
|
|
36
|
+
private _baseStep;
|
|
26
37
|
private set altered(value);
|
|
38
|
+
private get effectiveStep();
|
|
27
39
|
private _altered;
|
|
28
40
|
input: HTMLInputElement;
|
|
29
41
|
get focusElement(): HTMLInputElement;
|
|
@@ -54,6 +66,7 @@ export declare class ColorWheel extends Focusable {
|
|
|
54
66
|
};
|
|
55
67
|
protected render(): TemplateResult;
|
|
56
68
|
protected firstUpdated(changed: PropertyValues): void;
|
|
69
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
57
70
|
private observer?;
|
|
58
71
|
connectedCallback(): void;
|
|
59
72
|
disconnectedCallback(): void;
|
package/src/ColorWheel.dev.js
CHANGED
|
@@ -34,6 +34,7 @@ export class ColorWheel extends Focusable {
|
|
|
34
34
|
this.step = 1;
|
|
35
35
|
this.languageResolver = new LanguageResolutionController(this);
|
|
36
36
|
this.colorController = new ColorController(this, { manageAs: "hsv" });
|
|
37
|
+
this._baseStep = 1;
|
|
37
38
|
this._altered = 0;
|
|
38
39
|
this._pointerDown = false;
|
|
39
40
|
}
|
|
@@ -52,12 +53,12 @@ export class ColorWheel extends Focusable {
|
|
|
52
53
|
set color(color) {
|
|
53
54
|
this.colorController.color = color;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
return this._altered;
|
|
57
|
-
}
|
|
56
|
+
// Preserves user's value
|
|
58
57
|
set altered(altered) {
|
|
59
58
|
this._altered = altered;
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
get effectiveStep() {
|
|
61
|
+
return this._altered > 0 ? this._baseStep * 10 : this._baseStep;
|
|
61
62
|
}
|
|
62
63
|
get focusElement() {
|
|
63
64
|
return this.input;
|
|
@@ -71,16 +72,16 @@ export class ColorWheel extends Focusable {
|
|
|
71
72
|
let delta = 0;
|
|
72
73
|
switch (key) {
|
|
73
74
|
case "ArrowUp":
|
|
74
|
-
delta = this.
|
|
75
|
+
delta = this.effectiveStep;
|
|
75
76
|
break;
|
|
76
77
|
case "ArrowDown":
|
|
77
|
-
delta = -this.
|
|
78
|
+
delta = -this.effectiveStep;
|
|
78
79
|
break;
|
|
79
80
|
case "ArrowLeft":
|
|
80
|
-
delta = this.
|
|
81
|
+
delta = this.effectiveStep * (this.isLTR ? -1 : 1);
|
|
81
82
|
break;
|
|
82
83
|
case "ArrowRight":
|
|
83
|
-
delta = this.
|
|
84
|
+
delta = this.effectiveStep * (this.isLTR ? 1 : -1);
|
|
84
85
|
break;
|
|
85
86
|
default:
|
|
86
87
|
return;
|
|
@@ -309,6 +310,11 @@ export class ColorWheel extends Focusable {
|
|
|
309
310
|
this.addEventListener("focus", this.handleFocus);
|
|
310
311
|
this.addEventListener("blur", this.handleBlur);
|
|
311
312
|
}
|
|
313
|
+
willUpdate(changed) {
|
|
314
|
+
if (changed.has("step")) {
|
|
315
|
+
this._baseStep = this.step;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
312
318
|
connectedCallback() {
|
|
313
319
|
var _a;
|
|
314
320
|
super.connectedCallback();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ColorWheel.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { SWCResizeObserverEntry, WithSWCResizeObserver } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport type { ColorHandle } from '@spectrum-web-components/color-handle';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport {\n ColorController,\n ColorTypes,\n} from '@spectrum-web-components/reactive-controllers/src/ColorController.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\n\nimport styles from './color-wheel.css.js';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Wheel has changed.\n * @fires change - An alteration to the value of the Color Wheel has been committed by the user.\n */\nexport class ColorWheel extends Focusable {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public override dir!: 'ltr' | 'rtl';\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n private languageResolver = new LanguageResolutionController(this);\n\n private colorController = new ColorController(this, { manageAs: 'hsv' });\n\n @property({ type: Number })\n public get value(): number {\n return this.colorController.hue;\n }\n\n public set value(hue: number) {\n this.colorController.hue = hue;\n }\n\n @property({ type: String })\n public get color(): ColorTypes {\n return this.colorController.colorValue;\n }\n\n public set color(color: ColorTypes) {\n this.colorController.color = color;\n }\n\n private get altered(): number {\n return this._altered;\n }\n\n private set altered(altered: number) {\n this._altered = altered;\n this.step = Math.max(1, this.altered * 10);\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public override get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.step;\n break;\n case 'ArrowDown':\n delta = -this.step;\n break;\n case 'ArrowLeft':\n delta = this.step * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.step * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this.colorController.savePreviousColor();\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public override focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n this.focused = this.hasVisibleFocusInTree();\n this.input.focus();\n }\n\n private handleFocus(): void {\n this.focused = true;\n }\n\n private handleBlur(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this.colorController.savePreviousColor();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + (this.isLTR ? value : 180 - value))) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n const { button, pointerId, pointerType } = event;\n this.handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button,\n pointerId,\n pointerType,\n })\n );\n this.handlePointermove(event);\n }\n\n calculateStyleData(): {\n clipPath: string;\n clipPathBorders: string;\n diameter: number;\n handleLocationStyles: string;\n } {\n // Extract values from element.\n const { width: diameter = 160 } = this.boundingClientRect || {};\n const styles = getComputedStyle(this);\n const borderWidth = parseFloat(\n styles.getPropertyValue('--_border-width')\n );\n const trackWidth = parseFloat(\n styles.getPropertyValue('--_track-width')\n );\n\n // Calculate wheel data.\n const radius = diameter / 2;\n const diameterAfterBoarder = diameter - borderWidth * 2;\n const radiusAfterBoarder = radius - borderWidth;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const innerRadiusAfterBorder = innerRadius + borderWidth;\n const innerDiameterAfterBorder = innerDiameter + borderWidth * 2;\n const clipPathBorders = `\"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\"`;\n const clipPath = `\"M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${radiusAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 ${diameterAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 -${diameterAfterBoarder} 0 M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${innerRadiusAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 ${innerDiameterAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 -${innerDiameterAfterBorder} 0\"`;\n\n // Calculate handle position on the wheel.\n const translateX =\n (this.isLTR ? 1 : -1) *\n (radius - trackWidth / 2) *\n Math.cos((this.value * Math.PI) / 180);\n const translateY =\n (radius - trackWidth / 2) * Math.sin((this.value * Math.PI) / 180);\n const handleLocationStyles = `transform: translate(${translateX}px, ${translateY}px);`;\n\n return {\n clipPath,\n clipPathBorders,\n diameter,\n handleLocationStyles,\n };\n }\n\n protected override render(): TemplateResult {\n const { clipPath, clipPathBorders, diameter, handleLocationStyles } =\n this.calculateStyleData();\n\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n style=\"\n --spectrum-colorwheel-colorarea-container-size: ${diameter}px;\n --spectrum-colorwheel-height: ${diameter}px;\n --spectrum-colorwheel-width: ${diameter}px;\n --spectrum-colorwheel-path-borders: ${clipPathBorders};\n --spectrum-colorwheel-path: ${clipPath};\n \"\n >\n <div class=\"inner\">\n <div class=\"colorarea-container\"></div>\n </div>\n <div class=\"border\">\n <div class=\"wheel\"></div>\n </div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [\n ['pointerup', 'pointercancel', 'pointerleave'],\n this.handlePointerup,\n ],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n aria-valuetext=${`${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n maximumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'unit',\n unit: 'degree',\n unitDisplay: 'narrow',\n }\n ).format(this.value)}`}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focus', this.handleFocus);\n this.addEventListener('blur', this.handleBlur);\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n (window as unknown as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new (\n window as unknown as WithSWCResizeObserver\n ).ResizeObserver((entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n });\n }\n this.observer?.observe(this);\n }\n\n public override disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,OAGG;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,yBAAyB;AAElC,SAAS,iBAAiB;AAE1B,OAAO;AACP;AAAA,EACI;AAAA,OAEG;AACP,SAAS,oCAAoC;AAE7C,OAAO,YAAY;AAQZ,aAAM,mBAAmB,UAAU;AAAA,EAAnC;AAAA;AASH,SAAgB,WAAW;AAG3B,SAAO,UAAU;AAMjB,SAAO,QAAQ;AAGf,SAAO,OAAO;AAEd,SAAQ,mBAAmB,IAAI,6BAA6B,IAAI;AAEhE,SAAQ,kBAAkB,IAAI,gBAAgB,MAAM,EAAE,UAAU,MAAM,CAAC;
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { SWCResizeObserverEntry, WithSWCResizeObserver } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport type { ColorHandle } from '@spectrum-web-components/color-handle';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport {\n ColorController,\n ColorTypes,\n} from '@spectrum-web-components/reactive-controllers/src/ColorController.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\n\nimport styles from './color-wheel.css.js';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Wheel has changed.\n * @fires change - An alteration to the value of the Color Wheel has been committed by the user.\n */\nexport class ColorWheel extends Focusable {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public override dir!: 'ltr' | 'rtl';\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n private languageResolver = new LanguageResolutionController(this);\n\n private colorController = new ColorController(this, { manageAs: 'hsv' });\n\n @property({ type: Number })\n public get value(): number {\n return this.colorController.hue;\n }\n\n public set value(hue: number) {\n this.colorController.hue = hue;\n }\n\n @property({ type: String })\n public get color(): ColorTypes {\n return this.colorController.colorValue;\n }\n\n public set color(color: ColorTypes) {\n this.colorController.color = color;\n }\n\n private _baseStep: number = 1; // Preserves user's value\n\n private set altered(altered: number) {\n this._altered = altered;\n // Don't modify anything here!\n }\n\n private get effectiveStep(): number {\n // Calculate on-the-fly without modifying stored values\n return this._altered > 0 ? this._baseStep * 10 : this._baseStep;\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public override get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.effectiveStep;\n break;\n case 'ArrowDown':\n delta = -this.effectiveStep;\n break;\n case 'ArrowLeft':\n delta = this.effectiveStep * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.effectiveStep * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this.colorController.savePreviousColor();\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public override focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n this.focused = this.hasVisibleFocusInTree();\n this.input.focus();\n }\n\n private handleFocus(): void {\n this.focused = true;\n }\n\n private handleBlur(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this.colorController.savePreviousColor();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + (this.isLTR ? value : 180 - value))) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n const { button, pointerId, pointerType } = event;\n this.handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button,\n pointerId,\n pointerType,\n })\n );\n this.handlePointermove(event);\n }\n\n calculateStyleData(): {\n clipPath: string;\n clipPathBorders: string;\n diameter: number;\n handleLocationStyles: string;\n } {\n // Extract values from element.\n const { width: diameter = 160 } = this.boundingClientRect || {};\n const styles = getComputedStyle(this);\n const borderWidth = parseFloat(\n styles.getPropertyValue('--_border-width')\n );\n const trackWidth = parseFloat(\n styles.getPropertyValue('--_track-width')\n );\n\n // Calculate wheel data.\n const radius = diameter / 2;\n const diameterAfterBoarder = diameter - borderWidth * 2;\n const radiusAfterBoarder = radius - borderWidth;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const innerRadiusAfterBorder = innerRadius + borderWidth;\n const innerDiameterAfterBorder = innerDiameter + borderWidth * 2;\n const clipPathBorders = `\"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\"`;\n const clipPath = `\"M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${radiusAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 ${diameterAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 -${diameterAfterBoarder} 0 M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${innerRadiusAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 ${innerDiameterAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 -${innerDiameterAfterBorder} 0\"`;\n\n // Calculate handle position on the wheel.\n const translateX =\n (this.isLTR ? 1 : -1) *\n (radius - trackWidth / 2) *\n Math.cos((this.value * Math.PI) / 180);\n const translateY =\n (radius - trackWidth / 2) * Math.sin((this.value * Math.PI) / 180);\n const handleLocationStyles = `transform: translate(${translateX}px, ${translateY}px);`;\n\n return {\n clipPath,\n clipPathBorders,\n diameter,\n handleLocationStyles,\n };\n }\n\n protected override render(): TemplateResult {\n const { clipPath, clipPathBorders, diameter, handleLocationStyles } =\n this.calculateStyleData();\n\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n style=\"\n --spectrum-colorwheel-colorarea-container-size: ${diameter}px;\n --spectrum-colorwheel-height: ${diameter}px;\n --spectrum-colorwheel-width: ${diameter}px;\n --spectrum-colorwheel-path-borders: ${clipPathBorders};\n --spectrum-colorwheel-path: ${clipPath};\n \"\n >\n <div class=\"inner\">\n <div class=\"colorarea-container\"></div>\n </div>\n <div class=\"border\">\n <div class=\"wheel\"></div>\n </div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [\n ['pointerup', 'pointercancel', 'pointerleave'],\n this.handlePointerup,\n ],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n aria-valuetext=${`${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n maximumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'unit',\n unit: 'degree',\n unitDisplay: 'narrow',\n }\n ).format(this.value)}`}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focus', this.handleFocus);\n this.addEventListener('blur', this.handleBlur);\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('step')) {\n this._baseStep = this.step;\n }\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n (window as unknown as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new (\n window as unknown as WithSWCResizeObserver\n ).ResizeObserver((entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n });\n }\n this.observer?.observe(this);\n }\n\n public override disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,OAGG;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,yBAAyB;AA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AE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GARjC,WASO;AAGT;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAXjC,WAYF;AAGC;AAAA,EADP,MAAM,SAAS;AAAA,GAdP,WAeD;AAGD;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAjBjB,WAkBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GApBjB,WAqBF;AAOI;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA3BjB,WA4BE;AASA;AAAA,EADV,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GApCjB,WAqCE;AAuBJ;AAAA,EADN,MAAM,OAAO;AAAA,GA3DL,WA4DF;",
|
|
6
6
|
"names": ["key", "styles"]
|
|
7
7
|
}
|
package/src/ColorWheel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var n=(v,
|
|
1
|
+
"use strict";var y=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var n=(v,u,e,i)=>{for(var t=i>1?void 0:i?C(u,e):u,s=v.length-1,r;s>=0;s--)(r=v[s])&&(t=(i?r(u,e,t):r(t))||t);return i&&t&&y(u,e,t),t};import{html as P}from"@spectrum-web-components/base";import{ifDefined as R}from"@spectrum-web-components/base/src/directives.js";import{property as c,query as b}from"@spectrum-web-components/base/src/decorators.js";import{streamingListener as E}from"@spectrum-web-components/base/src/streaming-listener.js";import{Focusable as S}from"@spectrum-web-components/shared/src/focusable.js";import"@spectrum-web-components/color-handle/sp-color-handle.js";import{ColorController as D}from"@spectrum-web-components/reactive-controllers/src/ColorController.js";import{LanguageResolutionController as L}from"@spectrum-web-components/reactive-controllers/src/LanguageResolution.js";import T from"./color-wheel.css.js";export class ColorWheel extends S{constructor(){super(...arguments);this.disabled=!1;this.focused=!1;this.label="hue";this.step=1;this.languageResolver=new L(this);this.colorController=new D(this,{manageAs:"hsv"});this._baseStep=1;this._altered=0;this._pointerDown=!1}static get styles(){return[T]}get value(){return this.colorController.hue}set value(e){this.colorController.hue=e}get color(){return this.colorController.colorValue}set color(e){this.colorController.color=e}set altered(e){this._altered=e}get effectiveStep(){return this._altered>0?this._baseStep*10:this._baseStep}get focusElement(){return this.input}handleKeydown(e){const{key:i}=e;this.focused=!0,this.altered=[e.shiftKey,e.ctrlKey,e.altKey].filter(r=>!!r).length;let t=0;switch(i){case"ArrowUp":t=this.effectiveStep;break;case"ArrowDown":t=-this.effectiveStep;break;case"ArrowLeft":t=this.effectiveStep*(this.isLTR?-1:1);break;case"ArrowRight":t=this.effectiveStep*(this.isLTR?1:-1);break;default:return}e.preventDefault(),this.value=(360+this.value+t)%360,this.colorController.savePreviousColor(),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||this.colorController.restorePreviousColor()}handleInput(e){const{valueAsNumber:i}=e.target;this.value=i}handleChange(e){this.handleInput(e),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(e={}){super.focus(e),this.forwardFocus()}forwardFocus(){this.focused=this.hasVisibleFocusInTree(),this.input.focus()}handleFocus(){this.focused=!0}handleBlur(){this._pointerDown||(this.altered=0,this.focused=!1)}handlePointerdown(e){if(e.button!==0){e.preventDefault();return}this._pointerDown=!0,this.colorController.savePreviousColor(),this.boundingClientRect=this.getBoundingClientRect(),e.target.setPointerCapture(e.pointerId),e.pointerType==="mouse"&&(this.focused=!0)}handlePointermove(e){this.value=this.calculateHandlePosition(e),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))}handlePointerup(e){this._pointerDown=!1,e.target.releasePointerCapture(e.pointerId),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||this.colorController.restorePreviousColor(),this.focus(),e.pointerType==="mouse"&&(this.focused=!1)}calculateHandlePosition(e){if(!this.boundingClientRect)return this.value;const i=this.boundingClientRect,{width:t,height:s,left:r,top:h}=i,o=r+t/2,a=h+s/2,d=e.clientX-o,l=e.clientY-a,p=Math.atan2(l,d)*180/Math.PI;return(360+(360+(this.isLTR?p:180-p)))%360}handleGradientPointerdown(e){if(e.button!==0||e.target.classList.contains("innerCircle"))return;e.stopPropagation(),e.preventDefault();const{button:i,pointerId:t,pointerType:s}=e;this.handle.dispatchEvent(new PointerEvent("pointerdown",{button:i,pointerId:t,pointerType:s})),this.handlePointermove(e)}calculateStyleData(){const{width:e=160}=this.boundingClientRect||{},i=getComputedStyle(this),t=parseFloat(i.getPropertyValue("--_border-width")),s=parseFloat(i.getPropertyValue("--_track-width")),r=e/2,h=e-t*2,o=r-t,a=r-s,d=a*2,l=a+t,p=d+t*2,m=`"M ${r} ${r} m -${r} 0 a ${r} ${r} 0 1 0 ${e} 0 a ${r} ${r} 0 1 0 -${e} 0 M ${r} ${r} m -${a} 0 a ${a} ${a} 0 1 0 ${d} 0 a ${a} ${a} 0 1 0 -${d} 0"`,f=`"M ${o} ${o} m -${o} 0 a ${o} ${o} 0 1 0 ${h} 0 a ${o} ${o} 0 1 0 -${h} 0 M ${o} ${o} m -${l} 0 a ${l} ${l} 0 1 0 ${p} 0 a ${l} ${l} 0 1 0 -${p} 0"`,g=(this.isLTR?1:-1)*(r-s/2)*Math.cos(this.value*Math.PI/180),$=(r-s/2)*Math.sin(this.value*Math.PI/180),w=`transform: translate(${g}px, ${$}px);`;return{clipPath:f,clipPathBorders:m,diameter:e,handleLocationStyles:w}}render(){const{clipPath:e,clipPathBorders:i,diameter:t,handleLocationStyles:s}=this.calculateStyleData();return P`
|
|
2
2
|
<slot
|
|
3
3
|
name="gradient"
|
|
4
4
|
@pointerdown=${this.handleGradientPointerdown}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
class="handle"
|
|
26
26
|
color="hsl(${this.value}, 100%, 50%)"
|
|
27
27
|
?disabled=${this.disabled}
|
|
28
|
-
style=${
|
|
28
|
+
style=${s}
|
|
29
29
|
${E({start:["pointerdown",this.handlePointerdown],streamInside:["pointermove",this.handlePointermove],end:[["pointerup","pointercancel","pointerleave"],this.handlePointerup]})}
|
|
30
30
|
></sp-color-handle>
|
|
31
31
|
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
@change=${this.handleChange}
|
|
43
43
|
@keydown=${this.handleKeydown}
|
|
44
44
|
/>
|
|
45
|
-
`}firstUpdated(e){super.firstUpdated(e),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focus",this.handleFocus),this.addEventListener("blur",this.handleBlur)}connectedCallback(){var e;super.connectedCallback(),!this.observer&&window.ResizeObserver&&(this.observer=new window.ResizeObserver(i=>{for(const t of i)this.boundingClientRect=t.contentRect;this.requestUpdate()})),(e=this.observer)==null||e.observe(this)}disconnectedCallback(){var e;(e=this.observer)==null||e.unobserve(this),super.disconnectedCallback()}}n([
|
|
45
|
+
`}firstUpdated(e){super.firstUpdated(e),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focus",this.handleFocus),this.addEventListener("blur",this.handleBlur)}willUpdate(e){e.has("step")&&(this._baseStep=this.step)}connectedCallback(){var e;super.connectedCallback(),!this.observer&&window.ResizeObserver&&(this.observer=new window.ResizeObserver(i=>{for(const t of i)this.boundingClientRect=t.contentRect;this.requestUpdate()})),(e=this.observer)==null||e.observe(this)}disconnectedCallback(){var e;(e=this.observer)==null||e.unobserve(this),super.disconnectedCallback()}}n([c({type:String,reflect:!0})],ColorWheel.prototype,"dir",2),n([c({type:Boolean,reflect:!0})],ColorWheel.prototype,"disabled",2),n([c({type:Boolean,reflect:!0})],ColorWheel.prototype,"focused",2),n([b(".handle")],ColorWheel.prototype,"handle",2),n([c({type:String})],ColorWheel.prototype,"label",2),n([c({type:Number})],ColorWheel.prototype,"step",2),n([c({type:Number})],ColorWheel.prototype,"value",1),n([c({type:String})],ColorWheel.prototype,"color",1),n([b("input")],ColorWheel.prototype,"input",2);
|
|
46
46
|
//# sourceMappingURL=ColorWheel.js.map
|
package/src/ColorWheel.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ColorWheel.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { SWCResizeObserverEntry, WithSWCResizeObserver } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport type { ColorHandle } from '@spectrum-web-components/color-handle';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport {\n ColorController,\n ColorTypes,\n} from '@spectrum-web-components/reactive-controllers/src/ColorController.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\n\nimport styles from './color-wheel.css.js';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Wheel has changed.\n * @fires change - An alteration to the value of the Color Wheel has been committed by the user.\n */\nexport class ColorWheel extends Focusable {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public override dir!: 'ltr' | 'rtl';\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n private languageResolver = new LanguageResolutionController(this);\n\n private colorController = new ColorController(this, { manageAs: 'hsv' });\n\n @property({ type: Number })\n public get value(): number {\n return this.colorController.hue;\n }\n\n public set value(hue: number) {\n this.colorController.hue = hue;\n }\n\n @property({ type: String })\n public get color(): ColorTypes {\n return this.colorController.colorValue;\n }\n\n public set color(color: ColorTypes) {\n this.colorController.color = color;\n }\n\n private get altered(): number {\n return this._altered;\n }\n\n private set altered(altered: number) {\n this._altered = altered;\n this.step = Math.max(1, this.altered * 10);\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public override get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.step;\n break;\n case 'ArrowDown':\n delta = -this.step;\n break;\n case 'ArrowLeft':\n delta = this.step * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.step * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this.colorController.savePreviousColor();\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public override focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n this.focused = this.hasVisibleFocusInTree();\n this.input.focus();\n }\n\n private handleFocus(): void {\n this.focused = true;\n }\n\n private handleBlur(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this.colorController.savePreviousColor();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + (this.isLTR ? value : 180 - value))) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n const { button, pointerId, pointerType } = event;\n this.handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button,\n pointerId,\n pointerType,\n })\n );\n this.handlePointermove(event);\n }\n\n calculateStyleData(): {\n clipPath: string;\n clipPathBorders: string;\n diameter: number;\n handleLocationStyles: string;\n } {\n // Extract values from element.\n const { width: diameter = 160 } = this.boundingClientRect || {};\n const styles = getComputedStyle(this);\n const borderWidth = parseFloat(\n styles.getPropertyValue('--_border-width')\n );\n const trackWidth = parseFloat(\n styles.getPropertyValue('--_track-width')\n );\n\n // Calculate wheel data.\n const radius = diameter / 2;\n const diameterAfterBoarder = diameter - borderWidth * 2;\n const radiusAfterBoarder = radius - borderWidth;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const innerRadiusAfterBorder = innerRadius + borderWidth;\n const innerDiameterAfterBorder = innerDiameter + borderWidth * 2;\n const clipPathBorders = `\"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\"`;\n const clipPath = `\"M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${radiusAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 ${diameterAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 -${diameterAfterBoarder} 0 M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${innerRadiusAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 ${innerDiameterAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 -${innerDiameterAfterBorder} 0\"`;\n\n // Calculate handle position on the wheel.\n const translateX =\n (this.isLTR ? 1 : -1) *\n (radius - trackWidth / 2) *\n Math.cos((this.value * Math.PI) / 180);\n const translateY =\n (radius - trackWidth / 2) * Math.sin((this.value * Math.PI) / 180);\n const handleLocationStyles = `transform: translate(${translateX}px, ${translateY}px);`;\n\n return {\n clipPath,\n clipPathBorders,\n diameter,\n handleLocationStyles,\n };\n }\n\n protected override render(): TemplateResult {\n const { clipPath, clipPathBorders, diameter, handleLocationStyles } =\n this.calculateStyleData();\n\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n style=\"\n --spectrum-colorwheel-colorarea-container-size: ${diameter}px;\n --spectrum-colorwheel-height: ${diameter}px;\n --spectrum-colorwheel-width: ${diameter}px;\n --spectrum-colorwheel-path-borders: ${clipPathBorders};\n --spectrum-colorwheel-path: ${clipPath};\n \"\n >\n <div class=\"inner\">\n <div class=\"colorarea-container\"></div>\n </div>\n <div class=\"border\">\n <div class=\"wheel\"></div>\n </div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [\n ['pointerup', 'pointercancel', 'pointerleave'],\n this.handlePointerup,\n ],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n aria-valuetext=${`${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n maximumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'unit',\n unit: 'degree',\n unitDisplay: 'narrow',\n }\n ).format(this.value)}`}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focus', this.handleFocus);\n this.addEventListener('blur', this.handleBlur);\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n (window as unknown as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new (\n window as unknown as WithSWCResizeObserver\n ).ResizeObserver((entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n });\n }\n this.observer?.observe(this);\n }\n\n public override disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,MAGG,gCACP,OAAS,aAAAC,MAAiB,kDAC1B,OACI,YAAAC,EACA,SAAAC,MACG,kDACP,OAAS,qBAAAC,MAAyB,0DAElC,OAAS,aAAAC,MAAiB,mDAE1B,MAAO,2DACP,OACI,mBAAAC,MAEG,uEACP,OAAS,gCAAAC,MAAoC,0EAE7C,OAAOC,MAAY,uBAQZ,aAAM,mBAAmBH,CAAU,CAAnC,kCASH,KAAgB,SAAW,GAG3B,KAAO,QAAU,GAMjB,KAAO,MAAQ,MAGf,KAAO,KAAO,EAEd,KAAQ,iBAAmB,IAAIE,EAA6B,IAAI,EAEhE,KAAQ,gBAAkB,IAAID,EAAgB,KAAM,CAAE,SAAU,KAAM,CAAC,
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { SWCResizeObserverEntry, WithSWCResizeObserver } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport type { ColorHandle } from '@spectrum-web-components/color-handle';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport {\n ColorController,\n ColorTypes,\n} from '@spectrum-web-components/reactive-controllers/src/ColorController.js';\nimport { LanguageResolutionController } from '@spectrum-web-components/reactive-controllers/src/LanguageResolution.js';\n\nimport styles from './color-wheel.css.js';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Wheel has changed.\n * @fires change - An alteration to the value of the Color Wheel has been committed by the user.\n */\nexport class ColorWheel extends Focusable {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String, reflect: true })\n public override dir!: 'ltr' | 'rtl';\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n private languageResolver = new LanguageResolutionController(this);\n\n private colorController = new ColorController(this, { manageAs: 'hsv' });\n\n @property({ type: Number })\n public get value(): number {\n return this.colorController.hue;\n }\n\n public set value(hue: number) {\n this.colorController.hue = hue;\n }\n\n @property({ type: String })\n public get color(): ColorTypes {\n return this.colorController.colorValue;\n }\n\n public set color(color: ColorTypes) {\n this.colorController.color = color;\n }\n\n private _baseStep: number = 1; // Preserves user's value\n\n private set altered(altered: number) {\n this._altered = altered;\n // Don't modify anything here!\n }\n\n private get effectiveStep(): number {\n // Calculate on-the-fly without modifying stored values\n return this._altered > 0 ? this._baseStep * 10 : this._baseStep;\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public override get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.effectiveStep;\n break;\n case 'ArrowDown':\n delta = -this.effectiveStep;\n break;\n case 'ArrowLeft':\n delta = this.effectiveStep * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.effectiveStep * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this.colorController.savePreviousColor();\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public override focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n this.focused = this.hasVisibleFocusInTree();\n this.input.focus();\n }\n\n private handleFocus(): void {\n this.focused = true;\n }\n\n private handleBlur(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this.colorController.savePreviousColor();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this.colorController.restorePreviousColor();\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + (this.isLTR ? value : 180 - value))) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n const { button, pointerId, pointerType } = event;\n this.handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button,\n pointerId,\n pointerType,\n })\n );\n this.handlePointermove(event);\n }\n\n calculateStyleData(): {\n clipPath: string;\n clipPathBorders: string;\n diameter: number;\n handleLocationStyles: string;\n } {\n // Extract values from element.\n const { width: diameter = 160 } = this.boundingClientRect || {};\n const styles = getComputedStyle(this);\n const borderWidth = parseFloat(\n styles.getPropertyValue('--_border-width')\n );\n const trackWidth = parseFloat(\n styles.getPropertyValue('--_track-width')\n );\n\n // Calculate wheel data.\n const radius = diameter / 2;\n const diameterAfterBoarder = diameter - borderWidth * 2;\n const radiusAfterBoarder = radius - borderWidth;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const innerRadiusAfterBorder = innerRadius + borderWidth;\n const innerDiameterAfterBorder = innerDiameter + borderWidth * 2;\n const clipPathBorders = `\"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\"`;\n const clipPath = `\"M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${radiusAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 ${diameterAfterBoarder} 0 a ${radiusAfterBoarder} ${radiusAfterBoarder} 0 1 0 -${diameterAfterBoarder} 0 M ${radiusAfterBoarder} ${radiusAfterBoarder} m -${innerRadiusAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 ${innerDiameterAfterBorder} 0 a ${innerRadiusAfterBorder} ${innerRadiusAfterBorder} 0 1 0 -${innerDiameterAfterBorder} 0\"`;\n\n // Calculate handle position on the wheel.\n const translateX =\n (this.isLTR ? 1 : -1) *\n (radius - trackWidth / 2) *\n Math.cos((this.value * Math.PI) / 180);\n const translateY =\n (radius - trackWidth / 2) * Math.sin((this.value * Math.PI) / 180);\n const handleLocationStyles = `transform: translate(${translateX}px, ${translateY}px);`;\n\n return {\n clipPath,\n clipPathBorders,\n diameter,\n handleLocationStyles,\n };\n }\n\n protected override render(): TemplateResult {\n const { clipPath, clipPathBorders, diameter, handleLocationStyles } =\n this.calculateStyleData();\n\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n style=\"\n --spectrum-colorwheel-colorarea-container-size: ${diameter}px;\n --spectrum-colorwheel-height: ${diameter}px;\n --spectrum-colorwheel-width: ${diameter}px;\n --spectrum-colorwheel-path-borders: ${clipPathBorders};\n --spectrum-colorwheel-path: ${clipPath};\n \"\n >\n <div class=\"inner\">\n <div class=\"colorarea-container\"></div>\n </div>\n <div class=\"border\">\n <div class=\"wheel\"></div>\n </div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [\n ['pointerup', 'pointercancel', 'pointerleave'],\n this.handlePointerup,\n ],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n aria-valuetext=${`${new Intl.NumberFormat(\n this.languageResolver.language,\n {\n maximumFractionDigits: 0,\n minimumIntegerDigits: 1,\n style: 'unit',\n unit: 'degree',\n unitDisplay: 'narrow',\n }\n ).format(this.value)}`}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focus', this.handleFocus);\n this.addEventListener('blur', this.handleBlur);\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('step')) {\n this._baseStep = this.step;\n }\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n (window as unknown as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new (\n window as unknown as WithSWCResizeObserver\n ).ResizeObserver((entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n });\n }\n this.observer?.observe(this);\n }\n\n public override disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,MAGG,gCACP,OAAS,aAAAC,MAAiB,kDAC1B,OACI,YAAAC,EACA,SAAAC,MACG,kDACP,OAAS,qBAAAC,MAAyB,0DAElC,OAAS,aAAAC,MAAiB,mDAE1B,MAAO,2DACP,OACI,mBAAAC,MAEG,uEACP,OAAS,gCAAAC,MAAoC,0EAE7C,OAAOC,MAAY,uBAQZ,aAAM,mBAAmBH,CAAU,CAAnC,kCASH,KAAgB,SAAW,GAG3B,KAAO,QAAU,GAMjB,KAAO,MAAQ,MAGf,KAAO,KAAO,EAEd,KAAQ,iBAAmB,IAAIE,EAA6B,IAAI,EAEhE,KAAQ,gBAAkB,IAAID,EAAgB,KAAM,CAAE,SAAU,KAAM,CAAC,EAoBvE,KAAQ,UAAoB,EAY5B,KAAQ,SAAW,EA4FnB,KAAQ,aAAe,GApJvB,WAA2B,QAAyB,CAChD,MAAO,CAACE,CAAM,CAClB,CAyBA,IAAW,OAAgB,CACvB,OAAO,KAAK,gBAAgB,GAChC,CAEA,IAAW,MAAMC,EAAa,CAC1B,KAAK,gBAAgB,IAAMA,CAC/B,CAGA,IAAW,OAAoB,CAC3B,OAAO,KAAK,gBAAgB,UAChC,CAEA,IAAW,MAAMC,EAAmB,CAChC,KAAK,gBAAgB,MAAQA,CACjC,CAIA,IAAY,QAAQC,EAAiB,CACjC,KAAK,SAAWA,CAEpB,CAEA,IAAY,eAAwB,CAEhC,OAAO,KAAK,SAAW,EAAI,KAAK,UAAY,GAAK,KAAK,SAC1D,CAOA,IAAoB,cAAiC,CACjD,OAAO,KAAK,KAChB,CAEQ,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
6
6
|
"names": ["html", "ifDefined", "property", "query", "streamingListener", "Focusable", "ColorController", "LanguageResolutionController", "styles", "hue", "color", "altered", "event", "key", "delta", "valueAsNumber", "focusOptions", "rect", "width", "height", "left", "top", "centerX", "centerY", "pointX", "pointY", "value", "button", "pointerId", "pointerType", "diameter", "borderWidth", "trackWidth", "radius", "diameterAfterBoarder", "radiusAfterBoarder", "innerRadius", "innerDiameter", "innerRadiusAfterBorder", "innerDiameterAfterBorder", "clipPathBorders", "clipPath", "translateX", "translateY", "handleLocationStyles", "changed", "_a", "entries", "entry", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-wheel-overrides.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{--spectrum-colorwheel-border-color:var(--system-color-wheel-border-color)}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-wheel-overrides.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{--spectrum-colorwheel-border-color:var(--system-color-wheel-border-color)}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
6
|
"names": ["css", "styles"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-wheel.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-colorwheel-border-color-disabled:GrayText;--highcontrast-colorwheel-fill-color-disabled:Canvas;forced-color-adjust:none}}:host{--spectrum-colorwheel-width:var(--mod-colorwheel-width,var(--spectrum-color-wheel-width));--spectrum-colorwheel-height:var(--mod-colorwheel-height,var(--spectrum-color-wheel-width));--spectrum-colorwheel-fill-color-disabled:var(--mod-colorwheel-fill-color-disabled,var(--spectrum-disabled-background-color));--spectrum-colorwheel-border-width:var(--mod-colorwheel-border-width,var(--spectrum-border-width-100));--spectrum-colorwheel-track-width:var(--mod-colorwheel-track-width,var(--spectrum-color-control-track-width));--_track-width:var(--spectrum-colorwheel-track-width);--_border-width:var(--spectrum-colorwheel-border-width);min-inline-size:var(--mod-colorwheel-min-width,var(--spectrum-color-wheel-minimum-width));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);-webkit-user-select:none;user-select:none;cursor:default;display:block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none}:host([dragged]){z-index:1}.inner{inline-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));block-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));margin:auto;display:flex;position:absolute;inset-block:0;inset-inline:0}.colorarea-container{block-size:auto;inline-size:100%;margin:var(--mod-colorwheel-colorarea-margin,var(--spectrum-color-wheel-color-area-margin));justify-content:center;align-items:center;display:flex}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}.handle{transform:translate(calc(var(--spectrum-colorwheel-width)/2 - var(--spectrum-colorwheel-track-width)/2));inset-block-start:50%;inset-inline:50%}.border{background-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);clip-path:path(evenodd,var(--mod-colorwheel-path-borders,var(--spectrum-colorwheel-path-borders)));position:relative}:host([disabled]) .border{background-color:var(--highcontrast-colorwheel-border-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}.wheel{inset-block:var(--spectrum-colorwheel-border-width);inset-inline:var(--spectrum-colorwheel-border-width);clip-path:path(evenodd,var(--mod-colorwheel-path,var(--spectrum-colorwheel-path)));background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);position:absolute}:host([disabled]) .wheel{pointer-events:none;background:var(--highcontrast-colorwheel-fill-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}:host{--spectrum-colorwheel-border-color:var(--system-color-wheel-border-color)}:host{touch-action:none}:host(:focus){outline:none}::slotted([slot=gradient]){border-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));border-style:solid;border-width:var(--_border-width);box-sizing:border-box;block-size:var(--mod-colorwheel-height,var(--spectrum-colorwheel-height));inline-size:var(--mod-colorwheel-width,var(--spectrum-colorwheel-width));z-index:0;border-radius:100%;position:relative}:host([dir=rtl]) .wheel,:host([dir=rtl]) ::slotted([slot=gradient]){transform:scaleX(-1)}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-wheel.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-colorwheel-border-color-disabled:GrayText;--highcontrast-colorwheel-fill-color-disabled:Canvas;forced-color-adjust:none}}:host{--spectrum-colorwheel-width:var(--mod-colorwheel-width,var(--spectrum-color-wheel-width));--spectrum-colorwheel-height:var(--mod-colorwheel-height,var(--spectrum-color-wheel-width));--spectrum-colorwheel-fill-color-disabled:var(--mod-colorwheel-fill-color-disabled,var(--spectrum-disabled-background-color));--spectrum-colorwheel-border-width:var(--mod-colorwheel-border-width,var(--spectrum-border-width-100));--spectrum-colorwheel-track-width:var(--mod-colorwheel-track-width,var(--spectrum-color-control-track-width));--_track-width:var(--spectrum-colorwheel-track-width);--_border-width:var(--spectrum-colorwheel-border-width);min-inline-size:var(--mod-colorwheel-min-width,var(--spectrum-color-wheel-minimum-width));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);-webkit-user-select:none;user-select:none;cursor:default;display:block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none}:host([dragged]){z-index:1}.inner{inline-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));block-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));margin:auto;display:flex;position:absolute;inset-block:0;inset-inline:0}.colorarea-container{block-size:auto;inline-size:100%;margin:var(--mod-colorwheel-colorarea-margin,var(--spectrum-color-wheel-color-area-margin));justify-content:center;align-items:center;display:flex}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}.handle{transform:translate(calc(var(--spectrum-colorwheel-width)/2 - var(--spectrum-colorwheel-track-width)/2));inset-block-start:50%;inset-inline:50%}.border{background-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);clip-path:path(evenodd,var(--mod-colorwheel-path-borders,var(--spectrum-colorwheel-path-borders)));position:relative}:host([disabled]) .border{background-color:var(--highcontrast-colorwheel-border-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}.wheel{inset-block:var(--spectrum-colorwheel-border-width);inset-inline:var(--spectrum-colorwheel-border-width);clip-path:path(evenodd,var(--mod-colorwheel-path,var(--spectrum-colorwheel-path)));background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);position:absolute}:host([disabled]) .wheel{pointer-events:none;background:var(--highcontrast-colorwheel-fill-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}:host{--spectrum-colorwheel-border-color:var(--system-color-wheel-border-color)}:host{touch-action:none}:host(:focus){outline:none}::slotted([slot=gradient]){border-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));border-style:solid;border-width:var(--_border-width);box-sizing:border-box;block-size:var(--mod-colorwheel-height,var(--spectrum-colorwheel-height));inline-size:var(--mod-colorwheel-width,var(--spectrum-colorwheel-width));z-index:0;border-radius:100%;position:relative}:host([dir=rtl]) .wheel,:host([dir=rtl]) ::slotted([slot=gradient]){transform:scaleX(-1)}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
6
|
"names": ["css", "styles"]
|
|
7
7
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
1
12
|
export * from './ColorWheel.js';
|
package/src/index.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './ColorWheel.dev.js'\n"],
|
|
5
5
|
"mappings": ";AAYA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './ColorWheel.js';\n"],
|
|
5
5
|
"mappings": "aAYA,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-color-wheel.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-colorwheel-border-color-disabled:GrayText;--highcontrast-colorwheel-fill-color-disabled:Canvas;forced-color-adjust:none}}:host{--spectrum-colorwheel-width:var(--mod-colorwheel-width,var(--spectrum-color-wheel-width));--spectrum-colorwheel-height:var(--mod-colorwheel-height,var(--spectrum-color-wheel-width));--spectrum-colorwheel-fill-color-disabled:var(--mod-colorwheel-fill-color-disabled,var(--spectrum-disabled-background-color));--spectrum-colorwheel-border-width:var(--mod-colorwheel-border-width,var(--spectrum-border-width-100));--spectrum-colorwheel-track-width:var(--mod-colorwheel-track-width,var(--spectrum-color-control-track-width));--_track-width:var(--spectrum-colorwheel-track-width);--_border-width:var(--spectrum-colorwheel-border-width);min-inline-size:var(--mod-colorwheel-min-width,var(--spectrum-color-wheel-minimum-width));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);-webkit-user-select:none;user-select:none;cursor:default;display:block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none}:host([dragged]){z-index:1}.inner{inline-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));block-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));margin:auto;display:flex;position:absolute;inset-block:0;inset-inline:0}.colorarea-container{block-size:auto;inline-size:100%;margin:var(--mod-colorwheel-colorarea-margin,var(--spectrum-color-wheel-color-area-margin));justify-content:center;align-items:center;display:flex}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}.handle{transform:translate(calc(var(--spectrum-colorwheel-width)/2 - var(--spectrum-colorwheel-track-width)/2));inset-block-start:50%;inset-inline:50%}.border{background-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);clip-path:path(evenodd,var(--mod-colorwheel-path-borders,var(--spectrum-colorwheel-path-borders)));position:relative}:host([disabled]) .border{background-color:var(--highcontrast-colorwheel-border-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}.wheel{inset-block:var(--spectrum-colorwheel-border-width);inset-inline:var(--spectrum-colorwheel-border-width);clip-path:path(evenodd,var(--mod-colorwheel-path,var(--spectrum-colorwheel-path)));background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);position:absolute}:host([disabled]) .wheel{pointer-events:none;background:var(--highcontrast-colorwheel-fill-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-color-wheel.css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-colorwheel-border-color-disabled:GrayText;--highcontrast-colorwheel-fill-color-disabled:Canvas;forced-color-adjust:none}}:host{--spectrum-colorwheel-width:var(--mod-colorwheel-width,var(--spectrum-color-wheel-width));--spectrum-colorwheel-height:var(--mod-colorwheel-height,var(--spectrum-color-wheel-width));--spectrum-colorwheel-fill-color-disabled:var(--mod-colorwheel-fill-color-disabled,var(--spectrum-disabled-background-color));--spectrum-colorwheel-border-width:var(--mod-colorwheel-border-width,var(--spectrum-border-width-100));--spectrum-colorwheel-track-width:var(--mod-colorwheel-track-width,var(--spectrum-color-control-track-width));--_track-width:var(--spectrum-colorwheel-track-width);--_border-width:var(--spectrum-colorwheel-border-width);min-inline-size:var(--mod-colorwheel-min-width,var(--spectrum-color-wheel-minimum-width));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);-webkit-user-select:none;user-select:none;cursor:default;display:block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none}:host([dragged]){z-index:1}.inner{inline-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));block-size:var(--mod-colorwheel-colorarea-container-size,var(--spectrum-colorwheel-colorarea-container-size));margin:auto;display:flex;position:absolute;inset-block:0;inset-inline:0}.colorarea-container{block-size:auto;inline-size:100%;margin:var(--mod-colorwheel-colorarea-margin,var(--spectrum-color-wheel-color-area-margin));justify-content:center;align-items:center;display:flex}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}.handle{transform:translate(calc(var(--spectrum-colorwheel-width)/2 - var(--spectrum-colorwheel-track-width)/2));inset-block-start:50%;inset-inline:50%}.border{background-color:var(--mod-colorwheel-border-color,var(--spectrum-colorwheel-border-color));inline-size:var(--spectrum-colorwheel-width);block-size:var(--spectrum-colorwheel-height);clip-path:path(evenodd,var(--mod-colorwheel-path-borders,var(--spectrum-colorwheel-path-borders)));position:relative}:host([disabled]) .border{background-color:var(--highcontrast-colorwheel-border-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}.wheel{inset-block:var(--spectrum-colorwheel-border-width);inset-inline:var(--spectrum-colorwheel-border-width);clip-path:path(evenodd,var(--mod-colorwheel-path,var(--spectrum-colorwheel-path)));background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);position:absolute}:host([disabled]) .wheel{pointer-events:none;background:var(--highcontrast-colorwheel-fill-color-disabled,var(--spectrum-colorwheel-fill-color-disabled))}\n`;\nexport default styles;"],
|
|
5
5
|
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
6
|
"names": ["css", "styles"]
|
|
7
7
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
1
12
|
export interface SWCResizeObserverEntry {
|
|
2
13
|
contentRect: DOMRectReadOnly;
|
|
3
14
|
}
|