@spectrum-web-components/color-field 0.41.2
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/LICENSE +201 -0
- package/README.md +142 -0
- package/custom-elements.json +145 -0
- package/package.json +68 -0
- package/sp-color-field.d.ts +6 -0
- package/sp-color-field.dev.js +4 -0
- package/sp-color-field.dev.js.map +7 -0
- package/sp-color-field.js +2 -0
- package/sp-color-field.js.map +7 -0
- package/src/ColorField.d.ts +20 -0
- package/src/ColorField.dev.js +82 -0
- package/src/ColorField.dev.js.map +7 -0
- package/src/ColorField.js +9 -0
- package/src/ColorField.js.map +7 -0
- package/src/index.d.ts +1 -0
- package/src/index.dev.js +3 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/stories/args.js +57 -0
- package/stories/args.js.map +7 -0
- package/stories/color-field-sizes.stories.js +13 -0
- package/stories/color-field-sizes.stories.js.map +7 -0
- package/stories/color-field.stories.js +41 -0
- package/stories/color-field.stories.js.map +7 -0
- package/stories/template.js +26 -0
- package/stories/template.js.map +7 -0
- package/test/benchmark/basic-test.js +8 -0
- package/test/benchmark/basic-test.js.map +7 -0
- package/test/color-field-sizes.test-vrt.js +5 -0
- package/test/color-field-sizes.test-vrt.js.map +7 -0
- package/test/color-field.test-vrt.js +5 -0
- package/test/color-field.test-vrt.js.map +7 -0
- package/test/color-field.test.js +71 -0
- package/test/color-field.test.js.map +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
`<sp-color-field>` elements are textfields that allow users to input custom color values.
|
|
4
|
+
Color formats supported are `HEX, RGB, HSL, HSV, and shorthand HEX`
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/@spectrum-web-components/color-field)
|
|
9
|
+
[](https://bundlephobia.com/result?p=@spectrum-web-components/color-field)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
yarn add @spectrum-web-components/color-field
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the side effectful registration of `<sp-color-field>` via:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
import '@spectrum-web-components/color-field/sp-color-field.js';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
When looking to leverage the `ColorField` base class as a type and/or for extension purposes, do so via:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
import { ColorField } from '@spectrum-web-components/color-field';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Sizes
|
|
28
|
+
|
|
29
|
+
<sp-tabs selected="m" auto label="Size Attribute Options">
|
|
30
|
+
<sp-tab value="s">Small</sp-tab>
|
|
31
|
+
<sp-tab-panel value="s">
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<sp-color-field size="s" value="#ffff00"></sp-color-field>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</sp-tab-panel>
|
|
38
|
+
<sp-tab value="m">Medium</sp-tab>
|
|
39
|
+
<sp-tab-panel value="m">
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<sp-color-field size="m" value="#ffff00"></sp-color-field>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</sp-tab-panel>
|
|
46
|
+
<sp-tab value="l">Large</sp-tab>
|
|
47
|
+
|
|
48
|
+
<sp-tab-panel value="l">
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<sp-color-field size="l" value="#ffff00"></sp-color-field>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
</sp-tab-panel>
|
|
55
|
+
<sp-tab value="xl">Xtra Large</sp-tab>
|
|
56
|
+
|
|
57
|
+
<sp-tab-panel value="xl">
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<sp-color-field size="xl" value="#ffff00"></sp-color-field>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
</sp-tab-panel>
|
|
64
|
+
</sp-tabs>
|
|
65
|
+
|
|
66
|
+
## View Color
|
|
67
|
+
|
|
68
|
+
When `view-color` is true, the color handle will be rendered. This is useful for development and debugging purposes.
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<sp-color-field view-color value="#f00"></sp-color-field>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Read Only
|
|
75
|
+
|
|
76
|
+
A readonly color field
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<sp-color-field readonly value="#ffff00"></sp-color-field>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quiet
|
|
83
|
+
|
|
84
|
+
A Quiet color field
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<sp-color-field quiet value="#e6e600"></sp-color-field>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Invalid Input
|
|
91
|
+
|
|
92
|
+
If the input value is not a valid color, `<sp-color-field>` will not accept it.
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<sp-color-field value="not a color"></sp-color-field>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Valid Input
|
|
99
|
+
|
|
100
|
+
If the input value is a valid color, the `<sp-color-field>` will accept it and the color handle will be updated to reflect the new color.
|
|
101
|
+
|
|
102
|
+
`<sp-color-field>` component accepts color values in various formats: `HEX, RGB, HSL, HSV, and shorthand HEX`
|
|
103
|
+
|
|
104
|
+
- **HEX**: A hexadecimal color is specified with: `#RRGGBB`. `RR` (red), `GG` (green) and `BB` (blue) are hexadecimal integers between `00` and `FF` specifying the intensity of the color.
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<sp-color-field value="#ff0000"></sp-color-field>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- **Shorthand HEX**: Shorthand hexadecimal color values are also supported. `#RGB` is a shorthand for `#RRGGBB`. In the shorthand form, `R` (red), `G` (green), and `B` (blue) are hexadecimal characters between `0` and `F`. Each character is repeated to create the full 6-digit color code. For example, `#123` would expand to `#112233`.
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<sp-color-field view-color value="#f00"></sp-color-field>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- **RGB**: An RGB color value is specified with: rgb(red, green, blue). Each parameter defines the intensity of the color with a value between 0 and 255.
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<sp-color-field view-color value="rgb(0,2555,0)"></sp-color-field>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- **RGBA**: An RGBA color value is specified with: `rgba(red, green, blue, alpha)`. The `alpha` parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<sp-color-field view-color value="rgba(0,255,0,0.3)"></sp-color-field>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- **HSL**: An HSL color value is specified with: hsl(hue, saturation, lightness). Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation and lightness are percentages.
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<sp-color-field view-color value="hsl(234, 70%, 50%)"></sp-color-field>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- **HSV**: An HSV color value is specified with: hsv(hue, saturation, value). Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation and value are percentages.
|
|
135
|
+
|
|
136
|
+
```html
|
|
137
|
+
<sp-color-field view-color value="hsv(0, 70%, 50%)"></sp-color-field>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Events
|
|
141
|
+
|
|
142
|
+
The sp-color-field component fires a change event when the color value is changed. You can listen for this event to react to changes in the color value.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "sp-color-field.js",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "custom-element-definition",
|
|
12
|
+
"name": "sp-color-field",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "ColorField",
|
|
15
|
+
"module": "/src/ColorField.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"kind": "javascript-module",
|
|
22
|
+
"path": "src/ColorField.js",
|
|
23
|
+
"declarations": [
|
|
24
|
+
{
|
|
25
|
+
"kind": "class",
|
|
26
|
+
"description": "",
|
|
27
|
+
"name": "ColorField",
|
|
28
|
+
"members": [
|
|
29
|
+
{
|
|
30
|
+
"kind": "field",
|
|
31
|
+
"name": "viewColor",
|
|
32
|
+
"type": {
|
|
33
|
+
"text": "boolean"
|
|
34
|
+
},
|
|
35
|
+
"privacy": "public",
|
|
36
|
+
"default": "false",
|
|
37
|
+
"attribute": "view-color"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"kind": "field",
|
|
41
|
+
"name": "value",
|
|
42
|
+
"privacy": "public",
|
|
43
|
+
"type": {
|
|
44
|
+
"text": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "field",
|
|
49
|
+
"name": "_value",
|
|
50
|
+
"type": {
|
|
51
|
+
"text": "string"
|
|
52
|
+
},
|
|
53
|
+
"privacy": "protected",
|
|
54
|
+
"default": "''"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"kind": "field",
|
|
58
|
+
"name": "cachedColor",
|
|
59
|
+
"type": {
|
|
60
|
+
"text": "string | null"
|
|
61
|
+
},
|
|
62
|
+
"privacy": "private",
|
|
63
|
+
"default": "null"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"kind": "method",
|
|
67
|
+
"name": "getColorValue",
|
|
68
|
+
"privacy": "private",
|
|
69
|
+
"return": {
|
|
70
|
+
"type": {
|
|
71
|
+
"text": "string"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"kind": "method",
|
|
77
|
+
"name": "renderColorHandle",
|
|
78
|
+
"privacy": "private",
|
|
79
|
+
"return": {
|
|
80
|
+
"type": {
|
|
81
|
+
"text": "TemplateResult"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"kind": "field",
|
|
87
|
+
"name": "cachedTinyColor",
|
|
88
|
+
"type": {
|
|
89
|
+
"text": "TinyColor | null"
|
|
90
|
+
},
|
|
91
|
+
"privacy": "private",
|
|
92
|
+
"default": "null"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"kind": "method",
|
|
96
|
+
"name": "checkValidity",
|
|
97
|
+
"privacy": "public",
|
|
98
|
+
"return": {
|
|
99
|
+
"type": {
|
|
100
|
+
"text": "boolean"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"events": [
|
|
106
|
+
{
|
|
107
|
+
"description": "The value of the color-field has changed.",
|
|
108
|
+
"name": "input"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"description": "An alteration to the value of the color-field has been committed by the user.",
|
|
112
|
+
"name": "change"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"attributes": [
|
|
116
|
+
{
|
|
117
|
+
"name": "view-color",
|
|
118
|
+
"type": {
|
|
119
|
+
"text": "boolean"
|
|
120
|
+
},
|
|
121
|
+
"default": "false",
|
|
122
|
+
"fieldName": "viewColor"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"superclass": {
|
|
126
|
+
"name": "TextfieldBase",
|
|
127
|
+
"package": "@spectrum-web-components/textfield"
|
|
128
|
+
},
|
|
129
|
+
"tagName": "sp-color-field",
|
|
130
|
+
"customElement": true
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"exports": [
|
|
134
|
+
{
|
|
135
|
+
"kind": "js",
|
|
136
|
+
"name": "ColorField",
|
|
137
|
+
"declaration": {
|
|
138
|
+
"name": "ColorField",
|
|
139
|
+
"module": "src/ColorField.js"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spectrum-web-components/color-field",
|
|
3
|
+
"version": "0.41.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Web component implementation of a Spectrum design ColorField",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/adobe/spectrum-web-components.git",
|
|
12
|
+
"directory": "packages/color-field"
|
|
13
|
+
},
|
|
14
|
+
"author": "",
|
|
15
|
+
"homepage": "https://adobe.github.io/spectrum-web-components/components/color-field",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/adobe/spectrum-web-components/issues"
|
|
18
|
+
},
|
|
19
|
+
"main": "src/index.js",
|
|
20
|
+
"module": "src/index.js",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
"./src/ColorField.js": {
|
|
29
|
+
"development": "./src/ColorField.dev.js",
|
|
30
|
+
"default": "./src/ColorField.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/index.js": {
|
|
33
|
+
"development": "./src/index.dev.js",
|
|
34
|
+
"default": "./src/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./sp-color-field.js": {
|
|
37
|
+
"development": "./sp-color-field.dev.js",
|
|
38
|
+
"default": "./sp-color-field.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"**/*.d.ts",
|
|
46
|
+
"**/*.js",
|
|
47
|
+
"**/*.js.map",
|
|
48
|
+
"custom-elements.json",
|
|
49
|
+
"!stories/",
|
|
50
|
+
"!test/"
|
|
51
|
+
],
|
|
52
|
+
"keywords": [
|
|
53
|
+
"spectrum css",
|
|
54
|
+
"web components",
|
|
55
|
+
"lit-element",
|
|
56
|
+
"lit-html"
|
|
57
|
+
],
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@spectrum-web-components/base": "^0.41.2"
|
|
60
|
+
},
|
|
61
|
+
"types": "./src/index.d.ts",
|
|
62
|
+
"customElements": "custom-elements.json",
|
|
63
|
+
"sideEffects": [
|
|
64
|
+
"./sp-*.js",
|
|
65
|
+
"./**/*.dev.js"
|
|
66
|
+
],
|
|
67
|
+
"gitHead": "78c3f16b08c9133c9e5ca88d0c9fef5ea7d2ab87"
|
|
68
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-color-field.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { ColorField } from './src/ColorField.dev.js'\n\ncustomElements.define('sp-color-field', ColorField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-field': ColorField;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,kBAAkB;AAE3B,eAAe,OAAO,kBAAkB,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-color-field.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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 { ColorField } from './src/ColorField.js';\n\ncustomElements.define('sp-color-field', ColorField);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-field': ColorField;\n }\n}\n"],
|
|
5
|
+
"mappings": "aAYA,OAAS,cAAAA,MAAkB,sBAE3B,eAAe,OAAO,iBAAkBA,CAAU",
|
|
6
|
+
"names": ["ColorField"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CSSResultArray, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import { TextfieldBase } from '@spectrum-web-components/textfield';
|
|
3
|
+
/**
|
|
4
|
+
* @element sp-color-field
|
|
5
|
+
* @fires input - The value of the color-field has changed.
|
|
6
|
+
* @fires change - An alteration to the value of the color-field has been committed by the user.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ColorField extends TextfieldBase {
|
|
9
|
+
static get styles(): CSSResultArray;
|
|
10
|
+
viewColor: boolean;
|
|
11
|
+
set value(value: string);
|
|
12
|
+
get value(): string;
|
|
13
|
+
protected _value: string;
|
|
14
|
+
private cachedColor;
|
|
15
|
+
private getColorValue;
|
|
16
|
+
private renderColorHandle;
|
|
17
|
+
protected render(): TemplateResult;
|
|
18
|
+
private cachedTinyColor;
|
|
19
|
+
checkValidity(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result)
|
|
10
|
+
__defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
import {
|
|
14
|
+
html
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import { TinyColor } from "@ctrl/tinycolor";
|
|
18
|
+
import { TextfieldBase } from "@spectrum-web-components/textfield";
|
|
19
|
+
export class ColorField extends TextfieldBase {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.viewColor = false;
|
|
23
|
+
this._value = "";
|
|
24
|
+
this.cachedColor = null;
|
|
25
|
+
this.cachedTinyColor = null;
|
|
26
|
+
}
|
|
27
|
+
static get styles() {
|
|
28
|
+
return [...super.styles];
|
|
29
|
+
}
|
|
30
|
+
set value(value) {
|
|
31
|
+
if (value === this.value) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const oldValue = this._value;
|
|
35
|
+
this._value = value;
|
|
36
|
+
this.requestUpdate("value", oldValue);
|
|
37
|
+
}
|
|
38
|
+
get value() {
|
|
39
|
+
return this._value;
|
|
40
|
+
}
|
|
41
|
+
getColorValue() {
|
|
42
|
+
if (!this.value) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
if (!this.cachedColor || this.cachedColor !== this.value) {
|
|
46
|
+
const tinyColor = new TinyColor(this.value);
|
|
47
|
+
this.cachedColor = tinyColor.isValid ? tinyColor.toRgbString() : "";
|
|
48
|
+
}
|
|
49
|
+
return this.cachedColor;
|
|
50
|
+
}
|
|
51
|
+
renderColorHandle() {
|
|
52
|
+
return this.viewColor ? html`
|
|
53
|
+
<sp-color-handle
|
|
54
|
+
size="m"
|
|
55
|
+
color="${this.getColorValue()}"
|
|
56
|
+
></sp-color-handle>
|
|
57
|
+
` : html``;
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
if (this.viewColor) {
|
|
61
|
+
import("@spectrum-web-components/color-handle/sp-color-handle.js");
|
|
62
|
+
}
|
|
63
|
+
return html`
|
|
64
|
+
${super.render()} ${this.renderColorHandle()}
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
checkValidity() {
|
|
68
|
+
let validity = super.checkValidity();
|
|
69
|
+
if (this.value) {
|
|
70
|
+
if (!this.cachedTinyColor || this.cachedTinyColor.originalInput !== this.value) {
|
|
71
|
+
this.cachedTinyColor = new TinyColor(this.value);
|
|
72
|
+
}
|
|
73
|
+
this.valid = validity = this.cachedTinyColor.isValid;
|
|
74
|
+
this.invalid = !validity;
|
|
75
|
+
}
|
|
76
|
+
return validity;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
__decorateClass([
|
|
80
|
+
property({ type: Boolean, attribute: "view-color" })
|
|
81
|
+
], ColorField.prototype, "viewColor", 2);
|
|
82
|
+
//# sourceMappingURL=ColorField.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["ColorField.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport {\n CSSResultArray,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { TinyColor } from '@ctrl/tinycolor';\nimport { TextfieldBase } from '@spectrum-web-components/textfield';\n\n/**\n * @element sp-color-field\n * @fires input - The value of the color-field has changed.\n * @fires change - An alteration to the value of the color-field has been committed by the user.\n */\nexport class ColorField extends TextfieldBase {\n public static override get styles(): CSSResultArray {\n return [...super.styles];\n }\n\n @property({ type: Boolean, attribute: 'view-color' })\n public viewColor = false;\n\n public override set value(value: string) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public override get value(): string {\n return this._value;\n }\n\n protected override _value = '';\n\n private cachedColor: string | null = null;\n\n private getColorValue(): string {\n if (!this.value) {\n return '';\n }\n\n if (!this.cachedColor || this.cachedColor !== this.value) {\n const tinyColor = new TinyColor(this.value);\n this.cachedColor = tinyColor.isValid ? tinyColor.toRgbString() : '';\n }\n\n return this.cachedColor;\n }\n\n private renderColorHandle(): TemplateResult {\n return this.viewColor\n ? html`\n <sp-color-handle\n size=\"m\"\n color=\"${this.getColorValue()}\"\n ></sp-color-handle>\n `\n : html``;\n }\n\n protected override render(): TemplateResult {\n if (this.viewColor) {\n import('@spectrum-web-components/color-handle/sp-color-handle.js');\n }\n return html`\n ${super.render()} ${this.renderColorHandle()}\n `;\n }\n\n private cachedTinyColor: TinyColor | null = null;\n\n public override checkValidity(): boolean {\n let validity = super.checkValidity();\n if (this.value) {\n if (\n !this.cachedTinyColor ||\n this.cachedTinyColor.originalInput !== this.value\n ) {\n this.cachedTinyColor = new TinyColor(this.value);\n }\n this.valid = validity = this.cachedTinyColor.isValid;\n this.invalid = !validity;\n }\n return validity;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAWA;AAAA,EAEI;AAAA,OAEG;AAEP,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAOvB,aAAM,mBAAmB,cAAc;AAAA,EAAvC;AAAA;AAMH,SAAO,YAAY;AAenB,SAAmB,SAAS;AAE5B,SAAQ,cAA6B;AAmCrC,SAAQ,kBAAoC;AAAA;AAAA,EAzD5C,WAA2B,SAAyB;AAChD,WAAO,CAAC,GAAG,MAAM,MAAM;AAAA,EAC3B;AAAA,EAKA,IAAoB,MAAM,OAAe;AACrC,QAAI,UAAU,KAAK,OAAO;AACtB;AAAA,IACJ;AACA,UAAM,WAAW,KAAK;AACtB,SAAK,SAAS;AACd,SAAK,cAAc,SAAS,QAAQ;AAAA,EACxC;AAAA,EAEA,IAAoB,QAAgB;AAChC,WAAO,KAAK;AAAA,EAChB;AAAA,EAMQ,gBAAwB;AAC5B,QAAI,CAAC,KAAK,OAAO;AACb,aAAO;AAAA,IACX;AAEA,QAAI,CAAC,KAAK,eAAe,KAAK,gBAAgB,KAAK,OAAO;AACtD,YAAM,YAAY,IAAI,UAAU,KAAK,KAAK;AAC1C,WAAK,cAAc,UAAU,UAAU,UAAU,YAAY,IAAI;AAAA,IACrE;AAEA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEQ,oBAAoC;AACxC,WAAO,KAAK,YACN;AAAA;AAAA;AAAA,+BAGiB,KAAK,cAAc,CAAC;AAAA;AAAA,kBAGrC;AAAA,EACV;AAAA,EAEmB,SAAyB;AACxC,QAAI,KAAK,WAAW;AAChB,aAAO,0DAA0D;AAAA,IACrE;AACA,WAAO;AAAA,cACD,MAAM,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAAA;AAAA,EAEpD;AAAA,EAIgB,gBAAyB;AACrC,QAAI,WAAW,MAAM,cAAc;AACnC,QAAI,KAAK,OAAO;AACZ,UACI,CAAC,KAAK,mBACN,KAAK,gBAAgB,kBAAkB,KAAK,OAC9C;AACE,aAAK,kBAAkB,IAAI,UAAU,KAAK,KAAK;AAAA,MACnD;AACA,WAAK,QAAQ,WAAW,KAAK,gBAAgB;AAC7C,WAAK,UAAU,CAAC;AAAA,IACpB;AACA,WAAO;AAAA,EACX;AACJ;AApEW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,WAAW,aAAa,CAAC;AAAA,GAL3C,WAMF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=(l,i,e,t)=>{for(var r=t>1?void 0:t?c(i,e):i,o=l.length-1,s;o>=0;o--)(s=l[o])&&(r=(t?s(i,e,r):s(r))||r);return t&&r&&h(i,e,r),r};import{html as a}from"@spectrum-web-components/base";import{property as d}from"@spectrum-web-components/base/src/decorators.js";import{TinyColor as n}from"@ctrl/tinycolor";import{TextfieldBase as p}from"@spectrum-web-components/textfield";export class ColorField extends p{constructor(){super(...arguments);this.viewColor=!1;this._value="";this.cachedColor=null;this.cachedTinyColor=null}static get styles(){return[...super.styles]}set value(e){if(e===this.value)return;const t=this._value;this._value=e,this.requestUpdate("value",t)}get value(){return this._value}getColorValue(){if(!this.value)return"";if(!this.cachedColor||this.cachedColor!==this.value){const e=new n(this.value);this.cachedColor=e.isValid?e.toRgbString():""}return this.cachedColor}renderColorHandle(){return this.viewColor?a`
|
|
2
|
+
<sp-color-handle
|
|
3
|
+
size="m"
|
|
4
|
+
color="${this.getColorValue()}"
|
|
5
|
+
></sp-color-handle>
|
|
6
|
+
`:a``}render(){return this.viewColor&&import("@spectrum-web-components/color-handle/sp-color-handle.js"),a`
|
|
7
|
+
${super.render()} ${this.renderColorHandle()}
|
|
8
|
+
`}checkValidity(){let e=super.checkValidity();return this.value&&((!this.cachedTinyColor||this.cachedTinyColor.originalInput!==this.value)&&(this.cachedTinyColor=new n(this.value)),this.valid=e=this.cachedTinyColor.isValid,this.invalid=!e),e}}u([d({type:Boolean,attribute:"view-color"})],ColorField.prototype,"viewColor",2);
|
|
9
|
+
//# sourceMappingURL=ColorField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["ColorField.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport {\n CSSResultArray,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { TinyColor } from '@ctrl/tinycolor';\nimport { TextfieldBase } from '@spectrum-web-components/textfield';\n\n/**\n * @element sp-color-field\n * @fires input - The value of the color-field has changed.\n * @fires change - An alteration to the value of the color-field has been committed by the user.\n */\nexport class ColorField extends TextfieldBase {\n public static override get styles(): CSSResultArray {\n return [...super.styles];\n }\n\n @property({ type: Boolean, attribute: 'view-color' })\n public viewColor = false;\n\n public override set value(value: string) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public override get value(): string {\n return this._value;\n }\n\n protected override _value = '';\n\n private cachedColor: string | null = null;\n\n private getColorValue(): string {\n if (!this.value) {\n return '';\n }\n\n if (!this.cachedColor || this.cachedColor !== this.value) {\n const tinyColor = new TinyColor(this.value);\n this.cachedColor = tinyColor.isValid ? tinyColor.toRgbString() : '';\n }\n\n return this.cachedColor;\n }\n\n private renderColorHandle(): TemplateResult {\n return this.viewColor\n ? html`\n <sp-color-handle\n size=\"m\"\n color=\"${this.getColorValue()}\"\n ></sp-color-handle>\n `\n : html``;\n }\n\n protected override render(): TemplateResult {\n if (this.viewColor) {\n import('@spectrum-web-components/color-handle/sp-color-handle.js');\n }\n return html`\n ${super.render()} ${this.renderColorHandle()}\n `;\n }\n\n private cachedTinyColor: TinyColor | null = null;\n\n public override checkValidity(): boolean {\n let validity = super.checkValidity();\n if (this.value) {\n if (\n !this.cachedTinyColor ||\n this.cachedTinyColor.originalInput !== this.value\n ) {\n this.cachedTinyColor = new TinyColor(this.value);\n }\n this.valid = validity = this.cachedTinyColor.isValid;\n this.invalid = !validity;\n }\n return validity;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAWA,OAEI,QAAAA,MAEG,gCAEP,OAAS,YAAAC,MAAgB,kDACzB,OAAS,aAAAC,MAAiB,kBAC1B,OAAS,iBAAAC,MAAqB,qCAOvB,aAAM,mBAAmBA,CAAc,CAAvC,kCAMH,KAAO,UAAY,GAenB,KAAmB,OAAS,GAE5B,KAAQ,YAA6B,KAmCrC,KAAQ,gBAAoC,KAzD5C,WAA2B,QAAyB,CAChD,MAAO,CAAC,GAAG,MAAM,MAAM,CAC3B,CAKA,IAAoB,MAAMC,EAAe,CACrC,GAAIA,IAAU,KAAK,MACf,OAEJ,MAAMC,EAAW,KAAK,OACtB,KAAK,OAASD,EACd,KAAK,cAAc,QAASC,CAAQ,CACxC,CAEA,IAAoB,OAAgB,CAChC,OAAO,KAAK,MAChB,CAMQ,eAAwB,CAC5B,GAAI,CAAC,KAAK,MACN,MAAO,GAGX,GAAI,CAAC,KAAK,aAAe,KAAK,cAAgB,KAAK,MAAO,CACtD,MAAMC,EAAY,IAAIJ,EAAU,KAAK,KAAK,EAC1C,KAAK,YAAcI,EAAU,QAAUA,EAAU,YAAY,EAAI,EACrE,CAEA,OAAO,KAAK,WAChB,CAEQ,mBAAoC,CACxC,OAAO,KAAK,UACNN;AAAA;AAAA;AAAA,+BAGiB,KAAK,cAAc,CAAC;AAAA;AAAA,gBAGrCA,GACV,CAEmB,QAAyB,CACxC,OAAI,KAAK,WACL,OAAO,0DAA0D,EAE9DA;AAAA,cACD,MAAM,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAAA,SAEpD,CAIgB,eAAyB,CACrC,IAAIO,EAAW,MAAM,cAAc,EACnC,OAAI,KAAK,SAED,CAAC,KAAK,iBACN,KAAK,gBAAgB,gBAAkB,KAAK,SAE5C,KAAK,gBAAkB,IAAIL,EAAU,KAAK,KAAK,GAEnD,KAAK,MAAQK,EAAW,KAAK,gBAAgB,QAC7C,KAAK,QAAU,CAACA,GAEbA,CACX,CACJ,CApEWC,EAAA,CADNP,EAAS,CAAE,KAAM,QAAS,UAAW,YAAa,CAAC,GAL3C,WAMF",
|
|
6
|
+
"names": ["html", "property", "TinyColor", "TextfieldBase", "value", "oldValue", "tinyColor", "validity", "__decorateClass"]
|
|
7
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ColorField.js';
|
package/src/index.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nexport * from './ColorField.dev.js'\n"],
|
|
5
|
+
"mappings": ";AAWA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nexport * from './ColorField.js';\n"],
|
|
5
|
+
"mappings": "aAWA,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/stories/args.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export const argTypes = {
|
|
3
|
+
quiet: {
|
|
4
|
+
name: "quiet",
|
|
5
|
+
type: { name: "boolean", required: false },
|
|
6
|
+
description: "Whether the color-field type is quiet",
|
|
7
|
+
table: {
|
|
8
|
+
type: { summary: "boolean" },
|
|
9
|
+
defaultValue: { summary: false }
|
|
10
|
+
},
|
|
11
|
+
control: {
|
|
12
|
+
type: "boolean"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
name: "disabled",
|
|
17
|
+
type: { name: "boolean", required: false },
|
|
18
|
+
description: "Whether the color-field is disabled or not",
|
|
19
|
+
table: {
|
|
20
|
+
type: { summary: "boolean" },
|
|
21
|
+
defaultValue: { summary: false }
|
|
22
|
+
},
|
|
23
|
+
control: {
|
|
24
|
+
type: "boolean"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
viewColor: {
|
|
28
|
+
name: "viewColor",
|
|
29
|
+
type: { name: "boolean", required: false },
|
|
30
|
+
description: "Whether the color-field has color handle or not",
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: "boolean" },
|
|
33
|
+
defaultValue: { summary: false }
|
|
34
|
+
},
|
|
35
|
+
control: {
|
|
36
|
+
type: "boolean"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
size: {
|
|
40
|
+
name: "size",
|
|
41
|
+
type: { name: "string", required: false },
|
|
42
|
+
description: "The size at which to display color-field items.",
|
|
43
|
+
table: {
|
|
44
|
+
defaultValue: { summary: "m" }
|
|
45
|
+
},
|
|
46
|
+
control: {
|
|
47
|
+
labels: {
|
|
48
|
+
s: "Small",
|
|
49
|
+
m: "Medium",
|
|
50
|
+
l: "Large",
|
|
51
|
+
xl: "Extra large"
|
|
52
|
+
},
|
|
53
|
+
type: "select"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["args.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 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\nexport const argTypes = {\n quiet: {\n name: 'quiet',\n type: { name: 'boolean', required: false },\n description: 'Whether the color-field type is quiet',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n disabled: {\n name: 'disabled',\n type: { name: 'boolean', required: false },\n description: 'Whether the color-field is disabled or not',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n viewColor: {\n name: 'viewColor',\n type: { name: 'boolean', required: false },\n description: 'Whether the color-field has color handle or not',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n size: {\n name: 'size',\n type: { name: 'string', required: false },\n description: 'The size at which to display color-field items.',\n table: {\n defaultValue: { summary: 'm' },\n },\n control: {\n labels: {\n s: 'Small',\n m: 'Medium',\n l: 'Large',\n xl: 'Extra large',\n },\n type: 'select',\n },\n },\n};\n"],
|
|
5
|
+
"mappings": ";AAYO,aAAM,WAAW;AAAA,EACpB,OAAO;AAAA,IACH,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACN,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,WAAW;AAAA,IACP,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,WAAW,UAAU,MAAM;AAAA,IACzC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,UAAU;AAAA,MAC3B,cAAc,EAAE,SAAS,MAAM;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,cAAc,EAAE,SAAS,IAAI;AAAA,IACjC;AAAA,IACA,SAAS;AAAA,MACL,QAAQ;AAAA,QACJ,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACH,IAAI;AAAA,MACR;AAAA,MACA,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/field-label/sp-field-label.js";
|
|
3
|
+
import "@spectrum-web-components/help-text/sp-help-text.js";
|
|
4
|
+
import { ColorFieldMarkup } from "./template.js";
|
|
5
|
+
export default {
|
|
6
|
+
component: "sp-color-field",
|
|
7
|
+
title: "Color Field/Sizes"
|
|
8
|
+
};
|
|
9
|
+
export const s = () => ColorFieldMarkup({ size: "s" });
|
|
10
|
+
export const m = () => ColorFieldMarkup({ size: "m" });
|
|
11
|
+
export const l = () => ColorFieldMarkup({ size: "l" });
|
|
12
|
+
export const xl = () => ColorFieldMarkup({ size: "xl" });
|
|
13
|
+
//# sourceMappingURL=color-field-sizes.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-field-sizes.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport { TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\nimport { ColorFieldMarkup } from './template.js';\n\nexport default {\n component: 'sp-color-field',\n title: 'Color Field/Sizes',\n};\n\nexport const s = (): TemplateResult => ColorFieldMarkup({ size: 's' });\nexport const m = (): TemplateResult => ColorFieldMarkup({ size: 'm' });\nexport const l = (): TemplateResult => ColorFieldMarkup({ size: 'l' });\nexport const xl = (): TemplateResult => ColorFieldMarkup({ size: 'xl' });\n"],
|
|
5
|
+
"mappings": ";AAaA,OAAO;AACP,OAAO;AACP,SAAS,wBAAwB;AAEjC,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AACX;AAEO,aAAM,IAAI,MAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAC9D,aAAM,IAAI,MAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAC9D,aAAM,IAAI,MAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAC9D,aAAM,KAAK,MAAsB,iBAAiB,EAAE,MAAM,KAAK,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/color-field/sp-color-field.js";
|
|
3
|
+
import { ColorFieldMarkup } from "./template.js";
|
|
4
|
+
import { argTypes } from "./args.js";
|
|
5
|
+
export default {
|
|
6
|
+
component: "sp-color-field",
|
|
7
|
+
title: "Color Field",
|
|
8
|
+
args: {
|
|
9
|
+
label: "",
|
|
10
|
+
size: "m"
|
|
11
|
+
},
|
|
12
|
+
argTypes
|
|
13
|
+
};
|
|
14
|
+
export const Default = (args) => ColorFieldMarkup(args);
|
|
15
|
+
export const Quiet = (args) => ColorFieldMarkup(args);
|
|
16
|
+
Quiet.args = {
|
|
17
|
+
quiet: true
|
|
18
|
+
};
|
|
19
|
+
export const ReadOnly = (args) => ColorFieldMarkup(args);
|
|
20
|
+
ReadOnly.args = {
|
|
21
|
+
readonly: true,
|
|
22
|
+
value: "rgb(255,255,255)"
|
|
23
|
+
};
|
|
24
|
+
export const Disabled = (args) => ColorFieldMarkup(args);
|
|
25
|
+
Disabled.args = {
|
|
26
|
+
disabled: true
|
|
27
|
+
};
|
|
28
|
+
export const viewColor = (args) => ColorFieldMarkup(args);
|
|
29
|
+
viewColor.args = {
|
|
30
|
+
viewColor: true,
|
|
31
|
+
value: "rgb(255,255,0)"
|
|
32
|
+
};
|
|
33
|
+
export const WrongInput = (args) => ColorFieldMarkup(args);
|
|
34
|
+
WrongInput.args = {
|
|
35
|
+
value: "apple"
|
|
36
|
+
};
|
|
37
|
+
export const RightInput = (args) => ColorFieldMarkup(args);
|
|
38
|
+
RightInput.args = {
|
|
39
|
+
value: "#a8323a"
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=color-field.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-field.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport { TemplateResult } from '@spectrum-web-components/base';\nimport '@spectrum-web-components/color-field/sp-color-field.js';\nimport { ColorFieldMarkup } from './template.js';\nimport { argTypes } from './args.js';\n\nexport default {\n component: 'sp-color-field',\n title: 'Color Field',\n args: {\n label: '',\n size: 'm',\n },\n argTypes,\n};\n\ntype Properties = {\n quiet?: boolean;\n readonly?: boolean;\n disabled?: boolean;\n viewColor?: boolean;\n value?: string;\n label?: string;\n size?: 's' | 'm' | 'l' | 'xl';\n};\n\nexport const Default = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\n\nexport const Quiet = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\nQuiet.args = {\n quiet: true,\n};\n\nexport const ReadOnly = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\nReadOnly.args = {\n readonly: true,\n value: 'rgb(255,255,255)',\n};\n\nexport const Disabled = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\nDisabled.args = {\n disabled: true,\n};\nexport const viewColor = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\nviewColor.args = {\n viewColor: true,\n value: 'rgb(255,255,0)',\n};\n\nexport const WrongInput = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\n\nWrongInput.args = {\n value: 'apple',\n};\nexport const RightInput = (args?: Properties): TemplateResult =>\n ColorFieldMarkup(args);\nRightInput.args = {\n value: '#a8323a',\n};\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AAEzB,eAAe;AAAA,EACX,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,IACF,OAAO;AAAA,IACP,MAAM;AAAA,EACV;AAAA,EACA;AACJ;AAYO,aAAM,UAAU,CAAC,SACpB,iBAAiB,IAAI;AAElB,aAAM,QAAQ,CAAC,SAClB,iBAAiB,IAAI;AACzB,MAAM,OAAO;AAAA,EACT,OAAO;AACX;AAEO,aAAM,WAAW,CAAC,SACrB,iBAAiB,IAAI;AACzB,SAAS,OAAO;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AACX;AAEO,aAAM,WAAW,CAAC,SACrB,iBAAiB,IAAI;AACzB,SAAS,OAAO;AAAA,EACZ,UAAU;AACd;AACO,aAAM,YAAY,CAAC,SACtB,iBAAiB,IAAI;AACzB,UAAU,OAAO;AAAA,EACb,WAAW;AAAA,EACX,OAAO;AACX;AAEO,aAAM,aAAa,CAAC,SACvB,iBAAiB,IAAI;AAEzB,WAAW,OAAO;AAAA,EACd,OAAO;AACX;AACO,aAAM,aAAa,CAAC,SACvB,iBAAiB,IAAI;AACzB,WAAW,OAAO;AAAA,EACd,OAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import "@spectrum-web-components/color-field/sp-color-field.js";
|
|
4
|
+
export const ColorFieldMarkup = ({
|
|
5
|
+
label = "Color Field",
|
|
6
|
+
quiet = false,
|
|
7
|
+
size = "m",
|
|
8
|
+
readonly = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
viewColor = false,
|
|
11
|
+
value = ""
|
|
12
|
+
} = {}) => {
|
|
13
|
+
return html`
|
|
14
|
+
<sp-color-field
|
|
15
|
+
label=${label}
|
|
16
|
+
size=${size}
|
|
17
|
+
value=${value}
|
|
18
|
+
?view-color=${viewColor}
|
|
19
|
+
?quiet=${quiet}
|
|
20
|
+
?readonly=${readonly}
|
|
21
|
+
?disabled=${disabled}
|
|
22
|
+
></sp-color-field>
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
export const Template = ColorFieldMarkup;
|
|
26
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["template.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2024 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 { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/color-field/sp-color-field.js';\n\nexport interface Properties {\n quiet?: boolean;\n readonly?: boolean;\n disabled?: boolean;\n viewColor?: boolean;\n value?: string;\n label?: string;\n size?: 's' | 'm' | 'l' | 'xl';\n}\n\nexport const ColorFieldMarkup = ({\n label = 'Color Field',\n quiet = false,\n size = 'm',\n readonly = false,\n disabled = false,\n viewColor = false,\n value = '',\n} = {}): TemplateResult => {\n return html`\n <sp-color-field\n label=${label}\n size=${size}\n value=${value}\n ?view-color=${viewColor}\n ?quiet=${quiet}\n ?readonly=${readonly}\n ?disabled=${disabled}\n ></sp-color-field>\n `;\n};\n\nexport const Template = ColorFieldMarkup;\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAA4B;AAErC,OAAO;AAYA,aAAM,mBAAmB,CAAC;AAAA,EAC7B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AACZ,IAAI,CAAC,MAAsB;AACvB,SAAO;AAAA;AAAA,oBAES,KAAK;AAAA,mBACN,IAAI;AAAA,oBACH,KAAK;AAAA,0BACC,SAAS;AAAA,qBACd,KAAK;AAAA,wBACF,QAAQ;AAAA,wBACR,QAAQ;AAAA;AAAA;AAGhC;AAEO,aAAM,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/color-field/sp-color-field.js";
|
|
3
|
+
import { html } from "@spectrum-web-components/base";
|
|
4
|
+
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
5
|
+
measureFixtureCreation(html`
|
|
6
|
+
<sp-color-field value="#f0f" view-color></sp-color-field>
|
|
7
|
+
`);
|
|
8
|
+
//# sourceMappingURL=basic-test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["basic-test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport '@spectrum-web-components/color-field/sp-color-field.js';\nimport { html } from '@spectrum-web-components/base';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-color-field value=\"#f0f\" view-color></sp-color-field>\n`);\n"],
|
|
5
|
+
"mappings": ";AAWA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-field-sizes.test-vrt.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 * as stories from '../stories/color-field-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ColorFieldSizesStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,0BAA0B,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-field.test-vrt.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 * as stories from '../stories/color-field.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\nimport type { TestsType } from '../../../test/visual/test.js';\n\nregressVisuals('ColorFieldStories', stories as unknown as TestsType);\n"],
|
|
5
|
+
"mappings": ";AAYA,YAAY,aAAa;AACzB,SAAS,sBAAsB;AAG/B,eAAe,qBAAqB,OAA+B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
3
|
+
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
4
|
+
import { Template } from "../stories/template.js";
|
|
5
|
+
describe("ColorField", () => {
|
|
6
|
+
testForLitDevWarnings(async () => await fixture(Template({})));
|
|
7
|
+
it("loads default color-field accessibly", async () => {
|
|
8
|
+
const el = await fixture(
|
|
9
|
+
Template({ label: "Enter color value" })
|
|
10
|
+
);
|
|
11
|
+
await elementUpdated(el);
|
|
12
|
+
await expect(el).to.be.accessible();
|
|
13
|
+
});
|
|
14
|
+
it("validates rgba color values", async () => {
|
|
15
|
+
const el = await fixture(Template({}));
|
|
16
|
+
el.value = "rgba(255, 0, 0, 1)";
|
|
17
|
+
expect(el.checkValidity()).to.be.true;
|
|
18
|
+
el.value = "rgba(255, 0, 0, 0.5)";
|
|
19
|
+
expect(el.checkValidity()).to.be.true;
|
|
20
|
+
el.value = "rgba(255, 0, 0)";
|
|
21
|
+
expect(el.checkValidity()).to.be.false;
|
|
22
|
+
});
|
|
23
|
+
it("validates hex color values", async () => {
|
|
24
|
+
const el = await fixture(Template({}));
|
|
25
|
+
el.value = "#ff0000";
|
|
26
|
+
expect(el.checkValidity()).to.be.true;
|
|
27
|
+
el.value = "#f00";
|
|
28
|
+
expect(el.checkValidity()).to.be.true;
|
|
29
|
+
el.value = "##F00000000000";
|
|
30
|
+
expect(el.checkValidity()).to.be.false;
|
|
31
|
+
});
|
|
32
|
+
it("validates hsl color values", async () => {
|
|
33
|
+
const el = await fixture(Template({}));
|
|
34
|
+
el.value = "hsl(120, 100%, 50%)";
|
|
35
|
+
expect(el.checkValidity()).to.be.true;
|
|
36
|
+
el.value = "hsl(120, 50%, 50%)";
|
|
37
|
+
expect(el.checkValidity()).to.be.true;
|
|
38
|
+
el.value = "hsl(120, 50%)";
|
|
39
|
+
expect(el.checkValidity()).to.be.false;
|
|
40
|
+
});
|
|
41
|
+
it("validates hsv color values", async () => {
|
|
42
|
+
const el = await fixture(Template({}));
|
|
43
|
+
el.value = "hsv(120, 100%, 50%)";
|
|
44
|
+
expect(el.checkValidity()).to.be.true;
|
|
45
|
+
el.value = "hsv(120, 50%, 50%)";
|
|
46
|
+
expect(el.checkValidity()).to.be.true;
|
|
47
|
+
el.value = "hsv(120, 50%)";
|
|
48
|
+
expect(el.checkValidity()).to.be.false;
|
|
49
|
+
});
|
|
50
|
+
it("handles invalid color values", async () => {
|
|
51
|
+
const el = await fixture(Template({}));
|
|
52
|
+
el.value = "not a color";
|
|
53
|
+
await elementUpdated(el);
|
|
54
|
+
expect(el.checkValidity()).to.be.false;
|
|
55
|
+
});
|
|
56
|
+
it("renders color handle when viewColor is true", async () => {
|
|
57
|
+
const el = await fixture(Template({}));
|
|
58
|
+
el.viewColor = true;
|
|
59
|
+
await elementUpdated(el);
|
|
60
|
+
const colorHandle = el.shadowRoot.querySelector("sp-color-handle");
|
|
61
|
+
expect(colorHandle).to.not.be.null;
|
|
62
|
+
});
|
|
63
|
+
it("does not render color handle when viewColor is false", async () => {
|
|
64
|
+
const el = await fixture(Template({}));
|
|
65
|
+
el.viewColor = false;
|
|
66
|
+
await elementUpdated(el);
|
|
67
|
+
const colorHandle = el.shadowRoot.querySelector("sp-color-handle");
|
|
68
|
+
expect(colorHandle).to.be.null;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=color-field.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-field.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2023 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*/\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { ColorField } from '@spectrum-web-components/color-field';\n\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { Template } from '../stories/template.js';\n\ndescribe('ColorField', () => {\n testForLitDevWarnings(async () => await fixture<ColorField>(Template({})));\n it('loads default color-field accessibly', async () => {\n const el = await fixture<ColorField>(\n Template({ label: 'Enter color value' })\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('validates rgba color values', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.value = 'rgba(255, 0, 0, 1)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'rgba(255, 0, 0, 0.5)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'rgba(255, 0, 0)';\n\n expect(el.checkValidity()).to.be.false;\n });\n\n it('validates hex color values', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.value = '#ff0000';\n expect(el.checkValidity()).to.be.true;\n\n el.value = '#f00';\n expect(el.checkValidity()).to.be.true;\n\n el.value = '##F00000000000';\n expect(el.checkValidity()).to.be.false;\n });\n\n it('validates hsl color values', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.value = 'hsl(120, 100%, 50%)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'hsl(120, 50%, 50%)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'hsl(120, 50%)';\n expect(el.checkValidity()).to.be.false;\n });\n\n it('validates hsv color values', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.value = 'hsv(120, 100%, 50%)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'hsv(120, 50%, 50%)';\n expect(el.checkValidity()).to.be.true;\n\n el.value = 'hsv(120, 50%)';\n expect(el.checkValidity()).to.be.false;\n });\n\n it('handles invalid color values', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.value = 'not a color';\n await elementUpdated(el);\n\n expect(el.checkValidity()).to.be.false;\n });\n\n it('renders color handle when viewColor is true', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.viewColor = true;\n await elementUpdated(el);\n\n const colorHandle = el.shadowRoot.querySelector('sp-color-handle');\n expect(colorHandle).to.not.be.null;\n });\n\n it('does not render color handle when viewColor is false', async () => {\n const el = await fixture<ColorField>(Template({}));\n\n el.viewColor = false;\n await elementUpdated(el);\n\n const colorHandle = el.shadowRoot.querySelector('sp-color-handle');\n expect(colorHandle).to.be.null;\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,gBAAgB,QAAQ,eAAe;AAGhD,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAEzB,SAAS,cAAc,MAAM;AACzB,wBAAsB,YAAY,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC,CAAC;AACzE,KAAG,wCAAwC,YAAY;AACnD,UAAM,KAAK,MAAM;AAAA,MACb,SAAS,EAAE,OAAO,oBAAoB,CAAC;AAAA,IAC3C;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC1C,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AAEX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AAED,KAAG,8BAA8B,YAAY;AACzC,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AAED,KAAG,8BAA8B,YAAY;AACzC,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AAED,KAAG,8BAA8B,YAAY;AACzC,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAEjC,OAAG,QAAQ;AACX,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC3C,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,QAAQ;AACX,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,cAAc,CAAC,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AAED,KAAG,+CAA+C,YAAY;AAC1D,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,YAAY;AACf,UAAM,eAAe,EAAE;AAEvB,UAAM,cAAc,GAAG,WAAW,cAAc,iBAAiB;AACjE,WAAO,WAAW,EAAE,GAAG,IAAI,GAAG;AAAA,EAClC,CAAC;AAED,KAAG,wDAAwD,YAAY;AACnE,UAAM,KAAK,MAAM,QAAoB,SAAS,CAAC,CAAC,CAAC;AAEjD,OAAG,YAAY;AACf,UAAM,eAAe,EAAE;AAEvB,UAAM,cAAc,GAAG,WAAW,cAAc,iBAAiB;AACjE,WAAO,WAAW,EAAE,GAAG,GAAG;AAAA,EAC9B,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|