@@ -9,7 +9,22 @@ function resolveColor(color, opacityVariableName) {
9
9
return color . replace ( '<alpha-value>' , `var(${ opacityVariableName } , 1)` )
10
10
}
11
11
12
- const forms = plugin . withOptions ( function ( options = { strategy : undefined } ) {
12
+ /**
13
+ * @template T
14
+ * @param {boolean } bool
15
+ * @param {T } value
16
+ */
17
+ function maybe ( bool , value ) {
18
+ return bool ? value : undefined
19
+ }
20
+
21
+ function getEmptyRule ( ) {
22
+ return { base : [ ] , class : [ ] , styles : { } }
23
+ }
24
+
25
+ const forms = plugin . withOptions ( function (
26
+ options = { strategy : undefined , disableOutlines : undefined }
27
+ ) {
13
28
return function ( { addBase, addComponents, theme } ) {
14
29
function resolveChevronColor ( color , fallback ) {
15
30
let resolved = theme ( color )
@@ -22,6 +37,7 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
22
37
}
23
38
24
39
const strategy = options . strategy === undefined ? [ 'base' , 'class' ] : [ options . strategy ]
40
+ const disableOutlines = options . disableOutlines === undefined ? false : options . disableOutlines
25
41
26
42
const rules = [
27
43
{
@@ -60,24 +76,25 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
60
76
'font-size' : baseFontSize ,
61
77
'line-height' : baseLineHeight ,
62
78
'--tw-shadow' : '0 0 #0000' ,
63
- '&:focus' : {
64
- outline : '2px solid transparent' ,
65
- 'outline-offset' : '2px' ,
66
- '--tw-ring-inset' : 'var(--tw-empty,/*!*/ /*!*/)' ,
67
- '--tw-ring-offset-width' : '0px' ,
68
- '--tw-ring-offset-color' : '#fff' ,
69
- '--tw-ring-color' : resolveColor (
70
- theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
71
- '--tw-ring-opacity'
72
- ) ,
73
- '--tw-ring-offset-shadow' : `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)` ,
74
- '--tw-ring-shadow' : `var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)` ,
75
- 'box-shadow' : `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)` ,
76
- 'border-color' : resolveColor (
77
- theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
78
- '--tw-border-opacity'
79
- ) ,
80
- } ,
79
+ '&:focus' :
80
+ maybe ( disableOutlines , {
81
+ outline : '2px solid transparent' ,
82
+ 'outline-offset' : '2px' ,
83
+ '--tw-ring-inset' : 'var(--tw-empty,/*!*/ /*!*/)' ,
84
+ '--tw-ring-offset-width' : '0px' ,
85
+ '--tw-ring-offset-color' : '#fff' ,
86
+ '--tw-ring-color' : resolveColor (
87
+ theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
88
+ '--tw-ring-opacity'
89
+ ) ,
90
+ '--tw-ring-offset-shadow' : `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)` ,
91
+ '--tw-ring-shadow' : `var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)` ,
92
+ 'box-shadow' : `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)` ,
93
+ 'border-color' : resolveColor (
94
+ theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
95
+ '--tw-border-opacity'
96
+ ) ,
97
+ } ) || { } ,
81
98
} ,
82
99
} ,
83
100
{
@@ -225,7 +242,7 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
225
242
'border-radius' : '100%' ,
226
243
} ,
227
244
} ,
228
- {
245
+ maybe ( ! disableOutlines , {
229
246
base : [ `[type='checkbox']:focus` , `[type='radio']:focus` ] ,
230
247
class : [ '.form-checkbox:focus' , '.form-radio:focus' ] ,
231
248
styles : {
@@ -242,7 +259,7 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
242
259
'--tw-ring-shadow' : `var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)` ,
243
260
'box-shadow' : `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)` ,
244
261
} ,
245
- } ,
262
+ } ) || getEmptyRule ( ) ,
246
263
{
247
264
base : [ `[type='checkbox']:checked` , `[type='radio']:checked` ] ,
248
265
class : [ '.form-checkbox:checked' , '.form-radio:checked' ] ,
@@ -337,13 +354,13 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
337
354
'line-height' : 'inherit' ,
338
355
} ,
339
356
} ,
340
- {
357
+ maybe ( ! disableOutlines , {
341
358
base : [ `[type='file']:focus` ] ,
342
359
class : null ,
343
360
styles : {
344
361
outline : [ `1px solid ButtonText` , `1px auto -webkit-focus-ring-color` ] ,
345
362
} ,
346
- } ,
363
+ } ) || getEmptyRule ( ) ,
347
364
]
348
365
349
366
const getStrategyRules = ( strategy ) =>
0 commit comments