1 | import { HighContrastSelector } from './CommonStyles';
|
2 | import { IsFocusVisibleClassName } from '@uifabric/utilities';
|
3 | import { ZIndexes } from './zIndexes';
|
4 | export function getFocusStyle(theme, insetOrOptions, position, highContrastStyle, borderColor, outlineColor, isFocusedOnly) {
|
5 | if (typeof insetOrOptions === 'number' || !insetOrOptions) {
|
6 | return _getFocusStyleInternal(theme, {
|
7 | inset: insetOrOptions,
|
8 | position: position,
|
9 | highContrastStyle: highContrastStyle,
|
10 | borderColor: borderColor,
|
11 | outlineColor: outlineColor,
|
12 | isFocusedOnly: isFocusedOnly,
|
13 | });
|
14 | }
|
15 | else {
|
16 | return _getFocusStyleInternal(theme, insetOrOptions);
|
17 | }
|
18 | }
|
19 | function _getFocusStyleInternal(theme, options) {
|
20 | var _a, _b;
|
21 | if (options === void 0) { options = {}; }
|
22 | var _c = options.inset, inset = _c === void 0 ? 0 : _c, _d = options.width, width = _d === void 0 ? 1 : _d, _e = options.position, position = _e === void 0 ? 'relative' : _e, highContrastStyle = options.highContrastStyle, _f = options.borderColor, borderColor = _f === void 0 ? theme.palette.white : _f, _g = options.outlineColor, outlineColor = _g === void 0 ? theme.palette.neutralSecondary : _g, _h = options.isFocusedOnly, isFocusedOnly = _h === void 0 ? true : _h;
|
23 | return {
|
24 |
|
25 | outline: 'transparent',
|
26 |
|
27 | position: position,
|
28 | selectors: (_a = {
|
29 |
|
30 |
|
31 | '::-moz-focus-inner': {
|
32 | border: '0',
|
33 | }
|
34 | },
|
35 |
|
36 |
|
37 | _a["." + IsFocusVisibleClassName + " &" + (isFocusedOnly ? ':focus' : '') + ":after"] = {
|
38 | content: '""',
|
39 | position: 'absolute',
|
40 | left: inset + 1,
|
41 | top: inset + 1,
|
42 | bottom: inset + 1,
|
43 | right: inset + 1,
|
44 | border: width + "px solid " + borderColor,
|
45 | outline: width + "px solid " + outlineColor,
|
46 | zIndex: ZIndexes.FocusStyle,
|
47 | selectors: (_b = {},
|
48 | _b[HighContrastSelector] = highContrastStyle,
|
49 | _b),
|
50 | },
|
51 | _a),
|
52 | };
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 | export function focusClear() {
|
58 | return {
|
59 | selectors: {
|
60 | '&::-moz-focus-inner': {
|
61 |
|
62 | border: 0,
|
63 | },
|
64 | '&': {
|
65 |
|
66 | outline: 'transparent',
|
67 | },
|
68 | },
|
69 | };
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export function getFocusOutlineStyle(theme, inset, width, color) {
|
81 | var _a;
|
82 | if (inset === void 0) { inset = 0; }
|
83 | if (width === void 0) { width = 1; }
|
84 | return {
|
85 | selectors: (_a = {},
|
86 | _a[":global(" + IsFocusVisibleClassName + ") &:focus"] = {
|
87 | outline: width + " solid " + (color || theme.palette.neutralSecondary),
|
88 | outlineOffset: -inset + "px",
|
89 | },
|
90 | _a),
|
91 | };
|
92 | }
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | export var getInputFocusStyle = function (borderColor, borderRadius, borderType, borderPosition) {
|
104 | var _a, _b, _c;
|
105 | if (borderType === void 0) { borderType = 'border'; }
|
106 | if (borderPosition === void 0) { borderPosition = -1; }
|
107 | var isBorderBottom = borderType === 'borderBottom';
|
108 | return {
|
109 | borderColor: borderColor,
|
110 | selectors: {
|
111 | ':after': (_a = {
|
112 | pointerEvents: 'none',
|
113 | content: "''",
|
114 | position: 'absolute',
|
115 | left: isBorderBottom ? 0 : borderPosition,
|
116 | top: borderPosition,
|
117 | bottom: borderPosition,
|
118 | right: isBorderBottom ? 0 : borderPosition
|
119 | },
|
120 | _a[borderType] = "2px solid " + borderColor,
|
121 | _a.borderRadius = borderRadius,
|
122 | _a.width = borderType === 'borderBottom' ? '100%' : undefined,
|
123 | _a.selectors = (_b = {},
|
124 | _b[HighContrastSelector] = (_c = {},
|
125 | _c[borderType === 'border' ? 'borderColor' : 'borderBottomColor'] = 'Highlight',
|
126 | _c),
|
127 | _b),
|
128 | _a),
|
129 | },
|
130 | };
|
131 | };
|
132 |
|
\ | No newline at end of file |