@@ -11,10 +11,20 @@ OF ANY KIND, either express or implied. See the License for the specific languag
11
11
governing permissions and limitations under the License.
12
12
*/
13
13
14
- import { converterFor } from '../../../tasks/process-spectrum-utils.js' ;
14
+ import {
15
+ builder ,
16
+ converterFor ,
17
+ } from '../../../tasks/process-spectrum-utils.js' ;
15
18
16
19
const converter = converterFor ( 'spectrum-ClearButton' ) ;
17
20
21
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
22
+ const notDisabled = ( type = 'pseudoClass' ) => ( {
23
+ type : 'pseudo-class' ,
24
+ kind : 'not' ,
25
+ selectors : builder [ type ] ?. ( 'disabled' ) ,
26
+ } ) ;
27
+
18
28
/**
19
29
* @type { import('../../../tasks/spectrum-css-converter').SpectrumCSSConverter }
20
30
*/
@@ -24,13 +34,15 @@ const config = {
24
34
inPackage : '@spectrum-css/clearbutton' ,
25
35
outPackage : 'clear-button' ,
26
36
fileName : 'clear-button' ,
37
+ excludeByComponents : [
38
+ // is-disabled is a duplicate of the :disabled pseudo-class
39
+ builder . class ( 'is-disabled' ) ,
40
+ ] ,
27
41
components : [
28
42
converter . classToHost ( ) ,
43
+ converter . classToAttribute ( 'spectrum-ClearButton--quiet' ) ,
29
44
{
30
- find : {
31
- type : 'pseudo-class' ,
32
- kind : 'active' ,
33
- } ,
45
+ find : builder . pseudoClass ( 'active' ) ,
34
46
replace : {
35
47
type : 'pseudo-class' ,
36
48
kind : 'is' ,
@@ -52,14 +64,12 @@ const config = {
52
64
hoist : true ,
53
65
} ,
54
66
converter . pseudoToAttribute ( 'disabled' , 'disabled' ) ,
55
- converter . classToAttribute ( 'is-disabled' , 'disabled' ) ,
56
67
...converter . enumerateAttributes (
57
68
[
58
- [ 'spectrum-ClearButton--cta' ] ,
59
- [ 'spectrum-ClearButton--primary' ] ,
60
- [ 'spectrum-ClearButton--secondary' ] ,
61
- [ 'spectrum-ClearButton--overBackground' ] ,
62
- [ 'spectrum-ClearButton--warning' , 'negative' ] ,
69
+ [
70
+ 'spectrum-ClearButton--overBackground' ,
71
+ 'overBackground' ,
72
+ ] ,
63
73
] ,
64
74
'variant'
65
75
) ,
@@ -75,12 +85,41 @@ const config = {
75
85
) ,
76
86
converter . classToClass ( 'spectrum-Icon' , 'icon' ) ,
77
87
converter . classToClass ( 'spectrum-ClearButton-fill' ) ,
78
- ] ,
79
- excludeByComponents : [
88
+ converter . classToClass ( 'spectrum-ClearButton-icon' ) ,
89
+ ...converter . enumerateAttributes (
90
+ [ [ 'spectrum-ClearButton--staticWhite' , 'white' ] ] ,
91
+ 'static-color'
92
+ ) ,
93
+ {
94
+ find : builder . pseudoClass ( 'hover' ) ,
95
+ replace : builder . pseudoClass ( 'hover' ) ,
96
+ hoist : true ,
97
+ } ,
80
98
{
81
- type : 'pseudo-element' ,
82
- kind : 'custom' ,
83
- name : '-moz-focus-inner' ,
99
+ find : notDisabled ( ) ,
100
+ replace : notDisabled ( 'attribute' ) ,
101
+ hoist : true ,
102
+ } ,
103
+ {
104
+ find : [ notDisabled ( ) , builder . pseudoClass ( 'focus-visible' ) ] ,
105
+ replace : [
106
+ builder . pseudoClass ( 'focus-visible' ) ,
107
+ notDisabled ( 'attribute' ) ,
108
+ ] ,
109
+ hoist : true ,
110
+ } ,
111
+ {
112
+ find : [ notDisabled ( ) , builder . pseudoClass ( 'focus-within' ) ] ,
113
+ replace : [
114
+ builder . attribute ( 'focus-within' ) ,
115
+ notDisabled ( 'attribute' ) ,
116
+ ] ,
117
+ hoist : true ,
118
+ } ,
119
+ {
120
+ find : notDisabled ( ) ,
121
+ replace : notDisabled ( 'attribute' ) ,
122
+ hoist : true ,
84
123
} ,
85
124
] ,
86
125
} ,
0 commit comments