@redvars/peacock 3.5.0 → 3.5.1
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/dist/BaseButton-DuASuVth.js +219 -0
- package/dist/BaseButton-DuASuVth.js.map +1 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +12 -27
- package/dist/banner.js.map +1 -1
- package/dist/{button-DMN1dPAg.js → button-DouvOfEU.js} +77 -251
- package/dist/button-DouvOfEU.js.map +1 -0
- package/dist/{button-group-CX9CUUXk.js → button-group-CEdMwvJJ.js} +71 -42
- package/dist/button-group-CEdMwvJJ.js.map +1 -0
- package/dist/button-group.js +5 -5
- package/dist/button.js +3 -3
- package/dist/card.js +18 -73
- package/dist/card.js.map +1 -1
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +2 -2
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +2 -2
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/code-highlighter.js +2 -1
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +3105 -1494
- package/dist/custom-elements.json +9244 -7829
- package/dist/fab.js +421 -9
- package/dist/fab.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/{select-4pl4XBj7.js → navigation-rail-Lxetd5-Z.js} +2214 -1090
- package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
- package/dist/notification.js +3 -2
- package/dist/notification.js.map +1 -1
- package/dist/peacock-loader.js +22 -10
- package/dist/peacock-loader.js.map +1 -1
- package/dist/search.js +4 -0
- package/dist/search.js.map +1 -1
- package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
- package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
- package/dist/src/__mixins/MixinConstructor.d.ts +1 -0
- package/dist/src/banner/banner.d.ts +0 -4
- package/dist/src/button/BaseButton.d.ts +4 -47
- package/dist/src/button/button/button.d.ts +32 -3
- package/dist/src/button/button-group/button-group.d.ts +2 -2
- package/dist/src/button/icon-button/icon-button.d.ts +33 -8
- package/dist/src/card/card.d.ts +4 -15
- package/dist/src/fab/fab.d.ts +4 -35
- package/dist/src/focus-ring/focus-ring.d.ts +11 -5
- package/dist/src/index.d.ts +3 -1
- package/dist/src/link/link.d.ts +1 -1
- package/dist/src/navigation-rail/index.d.ts +2 -0
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
- package/dist/src/navigation-rail/navigation-rail.d.ts +71 -0
- package/dist/src/sidebar-menu/index.d.ts +3 -0
- package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
- package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
- package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
- package/dist/src/toolbar/toolbar.d.ts +10 -10
- package/dist/src/tooltip/tooltip.d.ts +3 -0
- package/dist/src/url-field/index.d.ts +1 -0
- package/dist/src/url-field/url-field.d.ts +48 -0
- package/dist/test/sidebar-menu.test.d.ts +1 -0
- package/dist/toolbar.js +10 -10
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +73 -65
- package/scss/mixin.scss +16 -0
- package/src/__mixins/BaseButtonMixin.ts +83 -0
- package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
- package/src/__mixins/MixinConstructor.ts +1 -0
- package/src/{__base_element → __mixins}/README.md +2 -2
- package/src/banner/banner.scss +18 -22
- package/src/banner/banner.ts +1 -7
- package/src/button/BaseButton.ts +11 -100
- package/src/button/button/button-sizes.scss +4 -2
- package/src/button/button/button.ts +76 -23
- package/src/button/button-group/button-group.ts +2 -2
- package/src/button/icon-button/icon-button.ts +75 -33
- package/src/card/card.ts +11 -71
- package/src/chart-bar/chart-bar.ts +9 -14
- package/src/chart-bar/chart-stacked-bar.ts +12 -18
- package/src/chart-doughnut/chart-doughnut.ts +23 -27
- package/src/chart-pie/chart-pie.ts +19 -23
- package/src/checkbox/checkbox.scss +17 -34
- package/src/checkbox/checkbox.ts +3 -1
- package/src/code-highlighter/code-highlighter.scss +1 -0
- package/src/code-highlighter/code-highlighter.ts +1 -1
- package/src/date-picker/date-picker.ts +1 -1
- package/src/elevation/elevation.scss +5 -5
- package/src/fab/fab.ts +29 -100
- package/src/focus-ring/focus-ring.ts +47 -40
- package/src/index.ts +3 -1
- package/src/input/input.ts +3 -1
- package/src/link/link.ts +2 -2
- package/src/menu/menu-item/menu-item.ts +3 -1
- package/src/navigation-rail/index.ts +2 -0
- package/src/navigation-rail/navigation-rail-item.scss +216 -0
- package/src/navigation-rail/navigation-rail-item.ts +223 -0
- package/src/navigation-rail/navigation-rail.scss +72 -0
- package/src/navigation-rail/navigation-rail.ts +149 -0
- package/src/notification/notification.ts +3 -2
- package/src/number-field/number-field.ts +6 -4
- package/src/pagination/pagination.ts +6 -4
- package/src/peacock-loader.ts +22 -5
- package/src/search/search.ts +4 -0
- package/src/sidebar-menu/demo/index.html +68 -0
- package/src/sidebar-menu/index.ts +3 -0
- package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
- package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
- package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
- package/src/sidebar-menu/sidebar-menu.ts +182 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
- package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
- package/src/skeleton/skeleton.scss +18 -24
- package/src/snackbar/snackbar.ts +1 -1
- package/src/tabs/tab.ts +4 -3
- package/src/text/text.css-component.scss +7 -1
- package/src/time-picker/time-picker.ts +1 -1
- package/src/toolbar/toolbar.ts +10 -10
- package/src/tooltip/tooltip.ts +24 -0
- package/src/url-field/index.ts +1 -0
- package/src/url-field/url-field.scss +50 -0
- package/src/url-field/url-field.ts +239 -0
- package/dist/button-DMN1dPAg.js.map +0 -1
- package/dist/button-group-CX9CUUXk.js.map +0 -1
- package/dist/fab-C5Nzxk0E.js +0 -497
- package/dist/fab-C5Nzxk0E.js.map +0 -1
- package/dist/select-4pl4XBj7.js.map +0 -1
- package/dist/spread-B5cgadZl.js +0 -32
- package/dist/spread-B5cgadZl.js.map +0 -1
- package/dist/src/__base_element/BaseHyperlink.d.ts +0 -20
- package/dist/src/tree-view/index.d.ts +0 -2
- package/dist/src/tree-view/tree-node.d.ts +0 -69
- package/dist/src/tree-view/tree-view.d.ts +0 -40
- package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
- package/dist/test/tree-view.test.d.ts +0 -1
- package/dist/throttle-C7ZAPqtu.js +0 -24
- package/dist/throttle-C7ZAPqtu.js.map +0 -1
- package/src/__base_element/BaseHyperlink.ts +0 -42
- package/src/tree-view/demo/index.html +0 -57
- package/src/tree-view/index.ts +0 -2
- package/src/tree-view/tree-node.scss +0 -101
- package/src/tree-view/tree-node.ts +0 -268
- package/src/tree-view/tree-view.ts +0 -182
- package/src/tree-view/wc-tree-view.ts +0 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { property, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
5
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
6
|
import styles from './button.scss';
|
|
6
7
|
import colorStyles from './button-colors.scss';
|
|
@@ -56,8 +57,6 @@ import { BaseButton } from '../BaseButton.js';
|
|
|
56
57
|
export class Button extends BaseButton {
|
|
57
58
|
static override styles = [styles, colorStyles, sizeStyles];
|
|
58
59
|
|
|
59
|
-
#tabindex?: number = 0;
|
|
60
|
-
|
|
61
60
|
/**
|
|
62
61
|
* Icon alignment.
|
|
63
62
|
* Possible values are `"start"`, `"end"`. Defaults to `"end"`.
|
|
@@ -65,6 +64,53 @@ export class Button extends BaseButton {
|
|
|
65
64
|
@property({ attribute: 'icon-align' })
|
|
66
65
|
iconAlign: 'start' | 'end' = 'end';
|
|
67
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Button size.
|
|
69
|
+
* Possible values are `"xs"`, `"sm"`, `"md"`, `"lg"`, `"xl"`. Defaults to `"sm"`.
|
|
70
|
+
*/
|
|
71
|
+
@property({ reflect: true }) size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Type is preset of color and variant. Type will be only applied.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
@property({ type: String }) type?: 'primary' | 'secondary' | 'tertiary';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The visual style of the button.
|
|
81
|
+
*
|
|
82
|
+
* Possible variant values:
|
|
83
|
+
* `"filled"` is a filled button.
|
|
84
|
+
* `"outlined"` is an outlined button.
|
|
85
|
+
* `"text"` is a transparent button.
|
|
86
|
+
* `"tonal"` is a light color button.
|
|
87
|
+
* `"elevated"` is elevated button
|
|
88
|
+
*/
|
|
89
|
+
@property() variant:
|
|
90
|
+
| 'elevated'
|
|
91
|
+
| 'filled'
|
|
92
|
+
| 'tonal'
|
|
93
|
+
| 'outlined'
|
|
94
|
+
| 'text'
|
|
95
|
+
| 'neo' = 'filled';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Defines the primary color of the button. This can be set to predefined color names to apply specific color themes.
|
|
99
|
+
*/
|
|
100
|
+
@property({ reflect: true }) color:
|
|
101
|
+
| 'primary'
|
|
102
|
+
| 'success'
|
|
103
|
+
| 'danger'
|
|
104
|
+
| 'warning'
|
|
105
|
+
| 'surface'
|
|
106
|
+
| 'on-surface' = 'primary';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Additional ARIA attributes to pass to the inner button/anchor element.
|
|
110
|
+
*/
|
|
111
|
+
@property({ reflect: true })
|
|
112
|
+
configAria?: { [key: string]: any };
|
|
113
|
+
|
|
68
114
|
@state()
|
|
69
115
|
private slotHasContent = false;
|
|
70
116
|
|
|
@@ -76,18 +122,6 @@ export class Button extends BaseButton {
|
|
|
76
122
|
this.buttonElement?.blur();
|
|
77
123
|
}
|
|
78
124
|
|
|
79
|
-
override connectedCallback() {
|
|
80
|
-
super.connectedCallback();
|
|
81
|
-
this.addEventListener('click', this.__dispatchClickWithThrottle);
|
|
82
|
-
window.addEventListener('mouseup', this.__handlePress);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
override disconnectedCallback() {
|
|
86
|
-
window.removeEventListener('mouseup', this.__handlePress);
|
|
87
|
-
this.removeEventListener('click', this.__dispatchClickWithThrottle);
|
|
88
|
-
super.disconnectedCallback();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
125
|
override firstUpdated() {
|
|
92
126
|
this.__dispatchClickWithThrottle = throttle(
|
|
93
127
|
this.__dispatchClick,
|
|
@@ -104,6 +138,22 @@ export class Button extends BaseButton {
|
|
|
104
138
|
this.__convertTypeToVariantAndColor();
|
|
105
139
|
}
|
|
106
140
|
|
|
141
|
+
__convertTypeToVariantAndColor() {
|
|
142
|
+
if (this.type === 'primary') {
|
|
143
|
+
this.color = 'primary';
|
|
144
|
+
this.variant = 'filled';
|
|
145
|
+
} else if (this.type === 'secondary') {
|
|
146
|
+
this.color = 'surface';
|
|
147
|
+
this.variant = 'filled';
|
|
148
|
+
} else if (this.type === 'tertiary') {
|
|
149
|
+
this.color = 'primary';
|
|
150
|
+
this.variant = 'text';
|
|
151
|
+
} else if (this.type === 'danger') {
|
|
152
|
+
this.color = 'danger';
|
|
153
|
+
this.variant = 'filled';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
107
157
|
override render() {
|
|
108
158
|
const isLink = this.__isLink();
|
|
109
159
|
|
|
@@ -124,14 +174,15 @@ export class Button extends BaseButton {
|
|
|
124
174
|
return html`<button
|
|
125
175
|
class=${classMap(cssClasses)}
|
|
126
176
|
id="button"
|
|
127
|
-
tabindex=${this.#tabindex}
|
|
128
177
|
type=${this.htmlType}
|
|
129
178
|
@click=${this.__dispatchClickWithThrottle}
|
|
130
179
|
@mousedown=${this.__handlePress}
|
|
131
180
|
@keydown=${this.__handlePress}
|
|
132
181
|
@keyup=${this.__handlePress}
|
|
133
|
-
|
|
134
|
-
aria-
|
|
182
|
+
|
|
183
|
+
aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
|
|
184
|
+
?aria-disabled=${this.softDisabled}
|
|
185
|
+
|
|
135
186
|
?disabled=${this.disabled}
|
|
136
187
|
${spread(this.configAria)}
|
|
137
188
|
>
|
|
@@ -142,16 +193,18 @@ export class Button extends BaseButton {
|
|
|
142
193
|
return html`<a
|
|
143
194
|
class=${classMap(cssClasses)}
|
|
144
195
|
id="button"
|
|
145
|
-
tabindex=${this.#tabindex}
|
|
146
196
|
href=${this.href}
|
|
147
197
|
target=${this.target}
|
|
148
|
-
|
|
198
|
+
tabindex=${this.disabled ? '-1' : '0'}
|
|
199
|
+
@click=${this.__dispatchClick}
|
|
149
200
|
@mousedown=${this.__handlePress}
|
|
150
201
|
@keydown=${this.__handlePress}
|
|
151
202
|
@keyup=${this.__handlePress}
|
|
152
203
|
role="button"
|
|
153
|
-
|
|
154
|
-
aria-
|
|
204
|
+
|
|
205
|
+
aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
|
|
206
|
+
?aria-disabled=${this.softDisabled}
|
|
207
|
+
|
|
155
208
|
${spread(this.configAria)}
|
|
156
209
|
>
|
|
157
210
|
${this.renderButtonContent()}
|
|
@@ -161,7 +214,7 @@ export class Button extends BaseButton {
|
|
|
161
214
|
|
|
162
215
|
renderButtonContent() {
|
|
163
216
|
return html`
|
|
164
|
-
<wc-focus-ring class="focus-ring"
|
|
217
|
+
<wc-focus-ring class="focus-ring" for='button'></wc-focus-ring>
|
|
165
218
|
<wc-elevation class="elevation"></wc-elevation>
|
|
166
219
|
<div class="neo-background"></div>
|
|
167
220
|
<div class="background"></div>
|
|
@@ -177,7 +230,7 @@ export class Button extends BaseButton {
|
|
|
177
230
|
<slot name="icon"></slot>
|
|
178
231
|
</div>
|
|
179
232
|
|
|
180
|
-
${this.__renderDisabledReason()}
|
|
233
|
+
${this.__renderDisabledReason(this.softDisabled)}
|
|
181
234
|
`;
|
|
182
235
|
}
|
|
183
236
|
}
|
|
@@ -17,8 +17,8 @@ import { BaseButton } from '../BaseButton.js';
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```html
|
|
19
19
|
* <wc-button-group variant="connected">
|
|
20
|
-
* <wc-icon-button name="home"
|
|
21
|
-
* <wc-icon-button name="alarm"
|
|
20
|
+
* <wc-icon-button toggle selected><wc-icon name="home"></wc-icon></wc-icon-button>
|
|
21
|
+
* <wc-icon-button toggle><wc-icon name="alarm"></wc-icon></wc-icon-button>
|
|
22
22
|
* </wc-button-group>
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
5
|
import styles from '../button/button.scss';
|
|
5
6
|
import colorStyles from '../button/button-colors.scss';
|
|
6
7
|
import sizeStyles from './icon-button-sizes.scss';
|
|
7
8
|
import { spread } from '@/__directive/spread.js';
|
|
8
9
|
import { throttle } from '@/__utils/throttle.js';
|
|
9
10
|
import { BaseButton } from '../BaseButton.js';
|
|
10
|
-
import { IconProvider } from '../../icon/icon.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @label Icon Button
|
|
@@ -48,20 +48,59 @@ import { IconProvider } from '../../icon/icon.js';
|
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
50
|
* ```html
|
|
51
|
-
* <wc-icon-button name="home"></wc-icon-button>
|
|
51
|
+
* <wc-icon-button><wc-icon name="home"></wc-icon></wc-icon-button>
|
|
52
52
|
* ```
|
|
53
53
|
* @tags display
|
|
54
54
|
*/
|
|
55
55
|
export class IconButton extends BaseButton {
|
|
56
56
|
static override styles = [styles, colorStyles, sizeStyles];
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Button size.
|
|
60
|
+
* Possible values are `"xs"`, `"sm"`, `"md"`, `"lg"`, `"xl"`. Defaults to `"sm"`.
|
|
61
|
+
*/
|
|
62
|
+
@property({ reflect: true }) size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Type is preset of color and variant. Type will be only applied.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
@property({ type: String }) type?: 'primary' | 'secondary' | 'tertiary';
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The visual style of the button.
|
|
72
|
+
*
|
|
73
|
+
* Possible variant values:
|
|
74
|
+
* `"filled"` is a filled button.
|
|
75
|
+
* `"outlined"` is an outlined button.
|
|
76
|
+
* `"text"` is a transparent button.
|
|
77
|
+
* `"tonal"` is a light color button.
|
|
78
|
+
* `"elevated"` is elevated button
|
|
79
|
+
*/
|
|
80
|
+
@property() variant:
|
|
81
|
+
| 'elevated'
|
|
82
|
+
| 'filled'
|
|
83
|
+
| 'tonal'
|
|
84
|
+
| 'outlined'
|
|
85
|
+
| 'text'
|
|
86
|
+
| 'neo' = 'filled';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Defines the primary color of the button. This can be set to predefined color names to apply specific color themes.
|
|
90
|
+
*/
|
|
91
|
+
@property({ reflect: true }) color:
|
|
92
|
+
| 'primary'
|
|
93
|
+
| 'success'
|
|
94
|
+
| 'danger'
|
|
95
|
+
| 'warning'
|
|
96
|
+
| 'surface'
|
|
97
|
+
| 'on-surface' = 'primary';
|
|
63
98
|
|
|
64
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Additional ARIA attributes to pass to the inner button/anchor element.
|
|
101
|
+
*/
|
|
102
|
+
@property({ reflect: true })
|
|
103
|
+
configAria?: { [key: string]: any };
|
|
65
104
|
|
|
66
105
|
override focus() {
|
|
67
106
|
this.buttonElement?.focus();
|
|
@@ -70,18 +109,6 @@ export class IconButton extends BaseButton {
|
|
|
70
109
|
override blur() {
|
|
71
110
|
this.buttonElement?.blur();
|
|
72
111
|
}
|
|
73
|
-
|
|
74
|
-
override connectedCallback() {
|
|
75
|
-
super.connectedCallback();
|
|
76
|
-
this.addEventListener('click', this.__dispatchClickWithThrottle);
|
|
77
|
-
window.addEventListener('mouseup', this.__handlePress);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
override disconnectedCallback() {
|
|
81
|
-
window.removeEventListener('mouseup', this.__handlePress);
|
|
82
|
-
this.removeEventListener('click', this.__dispatchClickWithThrottle);
|
|
83
|
-
super.disconnectedCallback();
|
|
84
|
-
}
|
|
85
112
|
|
|
86
113
|
override firstUpdated() {
|
|
87
114
|
this.__dispatchClickWithThrottle = throttle(
|
|
@@ -91,6 +118,22 @@ export class IconButton extends BaseButton {
|
|
|
91
118
|
this.__convertTypeToVariantAndColor();
|
|
92
119
|
}
|
|
93
120
|
|
|
121
|
+
__convertTypeToVariantAndColor() {
|
|
122
|
+
if (this.type === 'primary') {
|
|
123
|
+
this.color = 'primary';
|
|
124
|
+
this.variant = 'filled';
|
|
125
|
+
} else if (this.type === 'secondary') {
|
|
126
|
+
this.color = 'surface';
|
|
127
|
+
this.variant = 'filled';
|
|
128
|
+
} else if (this.type === 'tertiary') {
|
|
129
|
+
this.color = 'primary';
|
|
130
|
+
this.variant = 'text';
|
|
131
|
+
} else if (this.type === 'danger') {
|
|
132
|
+
this.color = 'danger';
|
|
133
|
+
this.variant = 'filled';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
94
137
|
override render() {
|
|
95
138
|
const isLink = this.__isLink();
|
|
96
139
|
|
|
@@ -109,14 +152,15 @@ export class IconButton extends BaseButton {
|
|
|
109
152
|
return html`<button
|
|
110
153
|
class=${classMap(cssClasses)}
|
|
111
154
|
id="button"
|
|
112
|
-
tabindex=${this.#tabindex}
|
|
113
155
|
type=${this.htmlType}
|
|
114
156
|
@click=${this.__dispatchClickWithThrottle}
|
|
115
157
|
@mousedown=${this.__handlePress}
|
|
116
158
|
@keydown=${this.__handlePress}
|
|
117
159
|
@keyup=${this.__handlePress}
|
|
118
|
-
|
|
119
|
-
aria-
|
|
160
|
+
|
|
161
|
+
aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
|
|
162
|
+
?aria-disabled=${this.softDisabled}
|
|
163
|
+
|
|
120
164
|
?disabled=${this.disabled}
|
|
121
165
|
${spread(this.configAria)}
|
|
122
166
|
>
|
|
@@ -127,16 +171,18 @@ export class IconButton extends BaseButton {
|
|
|
127
171
|
return html`<a
|
|
128
172
|
class=${classMap(cssClasses)}
|
|
129
173
|
id="button"
|
|
130
|
-
tabindex=${this.#tabindex}
|
|
131
174
|
href=${this.href}
|
|
132
175
|
target=${this.target}
|
|
133
|
-
|
|
176
|
+
tabindex=${this.disabled ? '-1' : '0'}
|
|
177
|
+
@click=${this.__dispatchClick}
|
|
134
178
|
@mousedown=${this.__handlePress}
|
|
135
179
|
@keydown=${this.__handlePress}
|
|
136
180
|
@keyup=${this.__handlePress}
|
|
137
181
|
role="button"
|
|
138
|
-
|
|
139
|
-
aria-
|
|
182
|
+
|
|
183
|
+
aria-describedby=${ifDefined(this.softDisabled ? BaseButton.DISABLED_REASON_ID : undefined)}
|
|
184
|
+
?aria-disabled=${this.softDisabled}
|
|
185
|
+
|
|
140
186
|
${spread(this.configAria)}
|
|
141
187
|
>
|
|
142
188
|
${this.renderButtonContent()}
|
|
@@ -146,7 +192,7 @@ export class IconButton extends BaseButton {
|
|
|
146
192
|
|
|
147
193
|
renderButtonContent() {
|
|
148
194
|
return html`
|
|
149
|
-
<wc-focus-ring class="focus-ring"
|
|
195
|
+
<wc-focus-ring class="focus-ring" for='button'></wc-focus-ring>
|
|
150
196
|
<wc-elevation class="elevation"></wc-elevation>
|
|
151
197
|
<div class="neo-background"></div>
|
|
152
198
|
<div class="background"></div>
|
|
@@ -155,14 +201,10 @@ export class IconButton extends BaseButton {
|
|
|
155
201
|
<wc-skeleton class="skeleton"></wc-skeleton>
|
|
156
202
|
|
|
157
203
|
<div class="button-content">
|
|
158
|
-
<
|
|
159
|
-
name=${this.name}
|
|
160
|
-
src=${this.src}
|
|
161
|
-
provider=${this.provider}
|
|
162
|
-
></wc-icon>
|
|
204
|
+
<slot></slot>
|
|
163
205
|
</div>
|
|
164
206
|
|
|
165
|
-
${this.__renderDisabledReason()}
|
|
207
|
+
${this.__renderDisabledReason(this.softDisabled)}
|
|
166
208
|
`;
|
|
167
209
|
}
|
|
168
210
|
}
|
package/src/card/card.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, html, nothing
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { dispatchActivationClick, isActivationClick } from '../__utils/dispatch-event-utils.js';
|
|
@@ -7,6 +7,7 @@ import { throttle } from '@/__utils/throttle.js';
|
|
|
7
7
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
8
8
|
import styles from './card.scss';
|
|
9
9
|
import colorStyles from './card-colors.scss';
|
|
10
|
+
import BaseHyperlinkMixin from '@/__mixins/BaseHyperlinkMixin.js';
|
|
10
11
|
|
|
11
12
|
type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
12
13
|
|
|
@@ -28,7 +29,7 @@ type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
|
28
29
|
* ```
|
|
29
30
|
*/
|
|
30
31
|
@IndividualComponent
|
|
31
|
-
export class Card extends LitElement {
|
|
32
|
+
export class Card extends BaseHyperlinkMixin(LitElement) {
|
|
32
33
|
static styles = [styles, colorStyles];
|
|
33
34
|
|
|
34
35
|
#id = crypto.randomUUID();
|
|
@@ -48,17 +49,6 @@ export class Card extends LitElement {
|
|
|
48
49
|
@property({ attribute: 'disabled-reason' })
|
|
49
50
|
disabledReason: string = '';
|
|
50
51
|
|
|
51
|
-
/**
|
|
52
|
-
* Hyperlink to navigate to on click.
|
|
53
|
-
*/
|
|
54
|
-
@property({ reflect: true }) href?: string;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Sets or retrieves the window or frame at which to target content.
|
|
58
|
-
*/
|
|
59
|
-
@property() target: string = '_self';
|
|
60
|
-
|
|
61
|
-
|
|
62
52
|
/**
|
|
63
53
|
* Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
|
|
64
54
|
*/
|
|
@@ -76,12 +66,8 @@ export class Card extends LitElement {
|
|
|
76
66
|
|
|
77
67
|
@query('.card') readonly cardElement!: HTMLElement | null;
|
|
78
68
|
|
|
79
|
-
@query('slot') readonly contentSlot!: HTMLSlotElement | null;
|
|
80
|
-
|
|
81
69
|
#tabindex?: number = 0;
|
|
82
70
|
|
|
83
|
-
#slottedTabIndexMap = new WeakMap<HTMLElement, string | null>();
|
|
84
|
-
|
|
85
71
|
override firstUpdated() {
|
|
86
72
|
this.__dispatchClickWithThrottle = throttle(
|
|
87
73
|
this.__dispatchClick,
|
|
@@ -91,52 +77,9 @@ export class Card extends LitElement {
|
|
|
91
77
|
this.renderRoot.querySelector('slot'),
|
|
92
78
|
hasContent => {
|
|
93
79
|
this.slotHasContent = hasContent;
|
|
94
|
-
this.__syncSlottedChildrenTabIndex();
|
|
95
80
|
this.requestUpdate();
|
|
96
81
|
},
|
|
97
82
|
);
|
|
98
|
-
this.__syncSlottedChildrenTabIndex();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
override updated(changedProperties: PropertyValues<this>) {
|
|
102
|
-
if (changedProperties.has('actionable') || changedProperties.has('href')) {
|
|
103
|
-
this.__syncSlottedChildrenTabIndex();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
__syncSlottedChildrenTabIndex() {
|
|
108
|
-
if (!this.contentSlot) return;
|
|
109
|
-
|
|
110
|
-
const shouldDisableTabbing = this.actionable || this.__isLink();
|
|
111
|
-
const assignedChildren = this.contentSlot.assignedElements({ flatten: true });
|
|
112
|
-
|
|
113
|
-
assignedChildren.forEach(node => {
|
|
114
|
-
if (!(node instanceof HTMLElement)) return;
|
|
115
|
-
|
|
116
|
-
if (shouldDisableTabbing) {
|
|
117
|
-
if (!this.#slottedTabIndexMap.has(node)) {
|
|
118
|
-
this.#slottedTabIndexMap.set(node, node.getAttribute('tabindex'));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (node.getAttribute('tabindex') !== '-1') {
|
|
122
|
-
node.setAttribute('tabindex', '-1');
|
|
123
|
-
}
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const originalTabIndex = this.#slottedTabIndexMap.get(node);
|
|
128
|
-
if (originalTabIndex === null) {
|
|
129
|
-
if (node.hasAttribute('tabindex')) {
|
|
130
|
-
node.removeAttribute('tabindex');
|
|
131
|
-
}
|
|
132
|
-
} else if (originalTabIndex !== undefined) {
|
|
133
|
-
if (node.getAttribute('tabindex') !== originalTabIndex) {
|
|
134
|
-
node.setAttribute('tabindex', originalTabIndex);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.#slottedTabIndexMap.delete(node);
|
|
139
|
-
});
|
|
140
83
|
}
|
|
141
84
|
|
|
142
85
|
__dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
|
|
@@ -162,10 +105,6 @@ export class Card extends LitElement {
|
|
|
162
105
|
dispatchActivationClick(this.cardElement);
|
|
163
106
|
};
|
|
164
107
|
|
|
165
|
-
__isLink() {
|
|
166
|
-
return !!this.href;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
108
|
__getDisabledReasonID() {
|
|
170
109
|
return this.disabled && this.disabledReason
|
|
171
110
|
? `disabled-reason-${this.#id}`
|
|
@@ -207,6 +146,7 @@ export class Card extends LitElement {
|
|
|
207
146
|
render() {
|
|
208
147
|
|
|
209
148
|
const isLink = this.__isLink();
|
|
149
|
+
const disableSlotTabbing = this.actionable || isLink;
|
|
210
150
|
|
|
211
151
|
const cssClasses = {
|
|
212
152
|
card: true,
|
|
@@ -223,7 +163,7 @@ export class Card extends LitElement {
|
|
|
223
163
|
class=${classMap(cssClasses)}
|
|
224
164
|
id="card"
|
|
225
165
|
>
|
|
226
|
-
${this.renderCardContent()}
|
|
166
|
+
${this.renderCardContent(disableSlotTabbing)}
|
|
227
167
|
</div>`;
|
|
228
168
|
}
|
|
229
169
|
|
|
@@ -240,7 +180,7 @@ export class Card extends LitElement {
|
|
|
240
180
|
aria-disabled=${`${this.disabled}`}
|
|
241
181
|
?disabled=${this.disabled}
|
|
242
182
|
>
|
|
243
|
-
${this.renderCardContent()}
|
|
183
|
+
${this.renderCardContent(disableSlotTabbing)}
|
|
244
184
|
</button>`;
|
|
245
185
|
}
|
|
246
186
|
return html`<a
|
|
@@ -257,13 +197,13 @@ export class Card extends LitElement {
|
|
|
257
197
|
?aria-describedby=${this.__getDisabledReasonID()}
|
|
258
198
|
aria-disabled=${`${this.disabled}`}
|
|
259
199
|
>
|
|
260
|
-
${this.renderCardContent()}
|
|
200
|
+
${this.renderCardContent(disableSlotTabbing)}
|
|
261
201
|
</a>`;
|
|
262
202
|
}
|
|
263
203
|
|
|
264
|
-
renderCardContent() {
|
|
204
|
+
renderCardContent(disableSlotTabbing: boolean) {
|
|
265
205
|
return html`
|
|
266
|
-
|
|
206
|
+
<wc-focus-ring class="focus-ring" for='card'></wc-focus-ring>
|
|
267
207
|
<wc-elevation class="elevation"></wc-elevation>
|
|
268
208
|
<div class="background"></div>
|
|
269
209
|
<div class="outline"></div>
|
|
@@ -271,8 +211,8 @@ export class Card extends LitElement {
|
|
|
271
211
|
|
|
272
212
|
<div class="card-content">
|
|
273
213
|
|
|
274
|
-
<div class="slot-container">
|
|
275
|
-
<slot
|
|
214
|
+
<div class="slot-container" ?inert=${disableSlotTabbing}>
|
|
215
|
+
<slot></slot>
|
|
276
216
|
</div>
|
|
277
217
|
|
|
278
218
|
</div>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { html, LitElement, PropertyValues } from 'lit';
|
|
2
2
|
import { property, query } from 'lit/decorators.js';
|
|
3
3
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
+
import { select, max, scaleBand, scaleLinear, scaleOrdinal, axisLeft, axisBottom, ScaleOrdinal } from 'd3';
|
|
4
5
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
-
import * as d3 from 'd3';
|
|
6
6
|
import styles from './chart-bar.scss';
|
|
7
7
|
|
|
8
8
|
export type ChartBarItem = {
|
|
@@ -94,8 +94,7 @@ export class ChartBar extends LitElement {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
private _getPaletteScale() {
|
|
97
|
-
return
|
|
98
|
-
.scaleOrdinal<string, string>()
|
|
97
|
+
return scaleOrdinal<string, string>()
|
|
99
98
|
.domain(this.data.map(d => d.name))
|
|
100
99
|
.range(chartColors);
|
|
101
100
|
}
|
|
@@ -103,7 +102,7 @@ export class ChartBar extends LitElement {
|
|
|
103
102
|
private _resolveColor(
|
|
104
103
|
name: string,
|
|
105
104
|
override: string | undefined,
|
|
106
|
-
scale:
|
|
105
|
+
scale: ScaleOrdinal<string, string>,
|
|
107
106
|
) {
|
|
108
107
|
return override || scale(name);
|
|
109
108
|
}
|
|
@@ -116,7 +115,7 @@ export class ChartBar extends LitElement {
|
|
|
116
115
|
const margin = Math.max(this.margin, 12);
|
|
117
116
|
const data = this.data ?? [];
|
|
118
117
|
|
|
119
|
-
const svg =
|
|
118
|
+
const svg = select(this.svgElement);
|
|
120
119
|
svg.attr('width', width).attr('height', height);
|
|
121
120
|
|
|
122
121
|
const innerWidth = Math.max(width - margin * 2, 0);
|
|
@@ -134,15 +133,13 @@ export class ChartBar extends LitElement {
|
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
const xScale =
|
|
138
|
-
.scaleBand<string>()
|
|
136
|
+
const xScale = scaleBand<string>()
|
|
139
137
|
.domain(data.map(d => d.name))
|
|
140
138
|
.range([0, innerWidth])
|
|
141
139
|
.padding(0.28);
|
|
142
140
|
|
|
143
|
-
const maxValue =
|
|
144
|
-
const yScale =
|
|
145
|
-
.scaleLinear()
|
|
141
|
+
const maxValue = max(data, d => d.value) ?? 0;
|
|
142
|
+
const yScale = scaleLinear()
|
|
146
143
|
.domain([0, maxValue || 1])
|
|
147
144
|
.nice()
|
|
148
145
|
.range([innerHeight, 0]);
|
|
@@ -150,8 +147,7 @@ export class ChartBar extends LitElement {
|
|
|
150
147
|
const yGrid = container.select<SVGGElement>('.y-grid');
|
|
151
148
|
yGrid
|
|
152
149
|
.call(
|
|
153
|
-
|
|
154
|
-
.axisLeft(yScale)
|
|
150
|
+
axisLeft(yScale)
|
|
155
151
|
.ticks(5)
|
|
156
152
|
.tickSize(-innerWidth)
|
|
157
153
|
.tickFormat(() => ''),
|
|
@@ -165,8 +161,7 @@ export class ChartBar extends LitElement {
|
|
|
165
161
|
xAxis
|
|
166
162
|
.attr('transform', `translate(0,${innerHeight})`)
|
|
167
163
|
.call(
|
|
168
|
-
|
|
169
|
-
.axisBottom(xScale)
|
|
164
|
+
axisBottom(xScale)
|
|
170
165
|
.tickSizeOuter(0)
|
|
171
166
|
.tickFormat(name => {
|
|
172
167
|
const entry = data.find(d => d.name === name);
|