@brightspace-ui/core 3.261.0 → 3.262.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.
@@ -1,6 +1,10 @@
1
- import { css } from 'lit';
1
+ import { css, unsafeCSS } from 'lit';
2
+ import { _isValidCssSelector } from '../../helpers/internal/css.js';
3
+ import { getFlag } from '../../helpers/flags.js';
2
4
  import { registerSemanticVariableForSvgImageUrl } from '../colors/colors.js';
3
5
 
6
+ export const useGeneratedStyles = getFlag('GAUD-8849-Use-input-radio-generated-styles', true);
7
+
4
8
  registerSemanticVariableForSvgImageUrl(
5
9
  '--d2l-input-radio-check-image',
6
10
  `<svg width="10" height="10" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
@@ -8,7 +12,169 @@ registerSemanticVariableForSvgImageUrl(
8
12
  </svg>`
9
13
  );
10
14
 
11
- export const radioStyles = css`
15
+ function _getRadioStyleSelectors(inputSelectors) {
16
+ const parseAndJoin = selectors => unsafeCSS(selectors.map(s => s.trim()).join(',\n'));
17
+ return {
18
+ simple: parseAndJoin(inputSelectors),
19
+ checked: parseAndJoin(inputSelectors.map(s => `
20
+ ${s}[aria-checked="true"],
21
+ ${s}:checked
22
+ `)),
23
+ checkedAfter: parseAndJoin(inputSelectors.map(s => `
24
+ ${s}[aria-checked="true"]::after,
25
+ ${s}:checked::after
26
+ `)),
27
+ hoverFocus: parseAndJoin(inputSelectors.map(s => `
28
+ ${s}.d2l-hovering,
29
+ ${s}:not(.d2l-input-radio-disabled-tooltip):not(:disabled):not(.d2l-disabled):hover,
30
+ ${s}:not(.d2l-input-radio-disabled-tooltip):not(:disabled):not(.d2l-disabled):focus,
31
+ ${s}.d2l-input-radio-disabled-tooltip:hover,
32
+ ${s}.d2l-input-radio-disabled-tooltip:focus
33
+ `)),
34
+ invalid: parseAndJoin(inputSelectors.map(s => `
35
+ ${s}[aria-invalid="true"]
36
+ `)),
37
+ disabled: parseAndJoin(inputSelectors.map(s => `
38
+ ${s}:disabled,
39
+ ${s}.d2l-disabled
40
+ `)),
41
+ disabledTooltip: parseAndJoin(inputSelectors.map(s => `
42
+ ${s}.d2l-input-radio-disabled-tooltip.d2l-hovering,
43
+ ${s}.d2l-input-radio-disabled-tooltip:hover,
44
+ ${s}.d2l-input-radio-disabled-tooltip:focus
45
+ `))
46
+ };
47
+ }
48
+
49
+ /**
50
+ * A private helper method that should not be used by general consumers
51
+ */
52
+ export function _generateRadioStyles(selector, containerSelector) {
53
+ if (!_isValidCssSelector(selector) || !_isValidCssSelector(containerSelector)) return '';
54
+ const inputSelectors = [selector];
55
+ if (containerSelector) {
56
+ inputSelectors.push(`${containerSelector} > input[type="radio"]`);
57
+ containerSelector = unsafeCSS(containerSelector);
58
+ }
59
+ const selectors = _getRadioStyleSelectors(inputSelectors);
60
+
61
+ return css`
62
+ ${selectors.simple} {
63
+ -webkit-appearance: none;
64
+ -moz-appearance: none;
65
+ appearance: none;
66
+ background-color: var(--d2l-theme-background-color-interactive-faint-default);
67
+ background-position: center center;
68
+ background-repeat: no-repeat;
69
+ background-size: 0.5rem 0.5rem;
70
+ border: 1px solid var(--d2l-theme-border-color-emphasized);
71
+ border-radius: 50%;
72
+ box-sizing: border-box;
73
+ display: inline-block;
74
+ height: 1.2rem;
75
+ margin: 0;
76
+ outline: none;
77
+ padding: 0;
78
+ vertical-align: middle;
79
+ width: 1.2rem;
80
+ }
81
+ ${selectors.checked} {
82
+ background-image: var(--d2l-input-radio-check-image);
83
+ }
84
+ ${selectors.hoverFocus} {
85
+ border: 2px solid var(--d2l-input-radio-border-color-hover-focus, var(--d2l-theme-border-color-focus));
86
+ }
87
+ ${selectors.invalid} {
88
+ --d2l-input-radio-border-color-hover-focus: var(--d2l-theme-status-color-error);
89
+ border-color: var(--d2l-theme-status-color-error);
90
+ }
91
+ ${selectors.disabled} {
92
+ opacity: var(--d2l-theme-opacity-disabled-control);
93
+ }
94
+
95
+ ${selectors.disabledTooltip} {
96
+ background-blend-mode: lighten;
97
+ background-color: var(--d2l-theme-background-color-interactive-faint-disabled);
98
+ opacity: 1;
99
+ }
100
+
101
+ @media (prefers-contrast: more) {
102
+ ${selectors.simple} {
103
+ background-color: Canvas;
104
+ border-color: ButtonText;
105
+ forced-color-adjust: none;
106
+ }
107
+ ${selectors.checked} {
108
+ background-image: none;
109
+ position: relative;
110
+ }
111
+ ${selectors.checkedAfter} {
112
+ background-color: FieldText;
113
+ content: "";
114
+ display: block;
115
+ height: 1.2rem;
116
+ left: 50%;
117
+ mask-image: var(--d2l-input-radio-check-image);
118
+ mask-position: center center;
119
+ mask-repeat: no-repeat;
120
+ mask-size: 0.5rem 0.5rem;
121
+ position: absolute;
122
+ top: 50%;
123
+ transform: translate(-50%, -50%);
124
+ width: 1.2rem;
125
+ }
126
+
127
+ ${selectors.invalid} {
128
+ --d2l-input-radio-border-color-hover-focus: var(--d2l-theme-status-color-error);
129
+ border-color: var(--d2l-theme-status-color-error);
130
+ }
131
+
132
+ ${selectors.disabledTooltip} {
133
+ background-blend-mode: initial;
134
+ background-color: Canvas;
135
+ }
136
+ }
137
+
138
+ ${containerSelector ? css`
139
+ ${containerSelector} {
140
+ align-items: center;
141
+ color: var(--d2l-theme-text-color-static-standard);
142
+ display: flex;
143
+ font-size: 0.8rem;
144
+ font-weight: 400;
145
+ line-height: 1.2rem;
146
+ margin-bottom: 0.9rem;
147
+ overflow-wrap: anywhere;
148
+ padding-inline-end: 0;
149
+ padding-inline-start: 1.7rem;
150
+ vertical-align: middle;
151
+ }
152
+ ${containerSelector}:last-of-type {
153
+ margin-bottom: 0;
154
+ }
155
+
156
+ ${containerSelector}.d2l-input-radio-label-disabled {
157
+ color: var(--d2l-theme-text-color-static-disabled);
158
+ }
159
+ ${containerSelector}.d2l-input-radio-label-disabled > * {
160
+ color: var(--d2l-theme-text-color-static-standard);
161
+ opacity: var(--d2l-theme-opacity-disabled-control);
162
+ }
163
+
164
+ ${containerSelector} > .d2l-input-radio,
165
+ ${containerSelector} > input[type="radio"] {
166
+ flex: 0 0 auto;
167
+ margin-inline-end: 0.5rem;
168
+ margin-inline-start: -1.7rem;
169
+ }
170
+ ` : css``}
171
+ `;
172
+
173
+ }
174
+
175
+ export const radioStyles = useGeneratedStyles ? css`
176
+ ${_generateRadioStyles('.d2l-input-radio', '.d2l-input-radio-label')}
177
+ ` : css`
12
178
  .d2l-input-radio,
13
179
  .d2l-input-radio-label > input[type="radio"] {
14
180
  -webkit-appearance: none;
@@ -1,13 +1,13 @@
1
1
  import '../expand-collapse/expand-collapse-content.js';
2
2
  import '../tooltip/tooltip.js';
3
3
  import { css, html, LitElement, nothing } from 'lit';
4
+ import { radioStyles, useGeneratedStyles } from './input-radio-styles.js';
4
5
  import { classMap } from 'lit/directives/class-map.js';
5
6
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
6
7
  import { getUniqueId } from '../../helpers/uniqueId.js';
7
8
  import { ifDefined } from 'lit/directives/if-defined.js';
8
9
  import { InputInlineHelpMixin } from './input-inline-help.js';
9
10
  import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
10
- import { radioStyles } from './input-radio-styles.js';
11
11
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
12
12
  import { styleMap } from 'lit/directives/style-map.js';
13
13
 
@@ -133,10 +133,11 @@ class InputRadio extends InputInlineHelpMixin(SkeletonMixin(FocusMixin(PropertyR
133
133
  const labelClasses = {
134
134
  'd2l-input-radio-label': true,
135
135
  'd2l-input-radio-label-disabled': this.disabled && !this.skeleton,
136
- 'd2l-input-radio-label-disabled-tooltip': this.disabled && this.disabledTooltip
136
+ 'd2l-input-radio-label-disabled-tooltip': !useGeneratedStyles && this.disabled && this.disabledTooltip
137
137
  };
138
138
  const radioClasses = {
139
139
  'd2l-input-radio': true,
140
+ 'd2l-input-radio-disabled-tooltip': useGeneratedStyles && this.disabled && this.disabledTooltip,
140
141
  'd2l-disabled': this.focusDisabled && !this.skeleton,
141
142
  'd2l-hovering': this._isHovered && !this.focusDisabled,
142
143
  'd2l-skeletize': true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.261.0",
3
+ "version": "3.262.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",