@tylertech/forge 3.5.1 → 3.6.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.
- package/custom-elements.json +287 -198
- package/dist/checkbox/forge-checkbox.css +1 -0
- package/dist/lib.js +27 -19
- package/dist/lib.js.map +4 -4
- package/dist/radio/forge-radio.css +2 -0
- package/dist/switch/forge-switch.css +2 -0
- package/dist/vscode.css-custom-data.json +15 -0
- package/dist/vscode.html-custom-data.json +32 -47
- package/esm/app-bar/profile-button/app-bar-profile-button.js +5 -2
- package/esm/avatar/avatar-constants.d.ts +0 -7
- package/esm/avatar/avatar-constants.js +1 -10
- package/esm/avatar/avatar.d.ts +24 -21
- package/esm/avatar/avatar.js +68 -45
- package/esm/avatar/index.d.ts +1 -3
- package/esm/avatar/index.js +4 -6
- package/esm/button/base/base-button-adapter.js +1 -1
- package/esm/button-area/button-area.js +1 -1
- package/esm/checkbox/checkbox.d.ts +1 -0
- package/esm/checkbox/checkbox.js +2 -1
- package/esm/dialog/dialog-adapter.d.ts +7 -0
- package/esm/dialog/dialog-adapter.js +43 -19
- package/esm/dialog/dialog-constants.d.ts +6 -0
- package/esm/dialog/dialog-constants.js +6 -2
- package/esm/dialog/dialog-core.d.ts +8 -0
- package/esm/dialog/dialog-core.js +21 -1
- package/esm/dialog/dialog.d.ts +15 -0
- package/esm/dialog/dialog.js +14 -1
- package/esm/icon-button/icon-button-constants.d.ts +4 -0
- package/esm/icon-button/icon-button-constants.js +2 -0
- package/esm/icon-button/icon-button-core.d.ts +4 -4
- package/esm/icon-button/icon-button-core.js +16 -14
- package/esm/icon-button/icon-button.d.ts +32 -29
- package/esm/icon-button/icon-button.js +6 -31
- package/esm/profile-card/profile-card.js +5 -2
- package/esm/radio/radio/radio.d.ts +1 -0
- package/esm/radio/radio/radio.js +2 -1
- package/esm/split-view/split-view/split-view-adapter.js +1 -0
- package/esm/split-view/split-view-panel/split-view-panel.js +1 -1
- package/esm/switch/switch-adapter.d.ts +4 -4
- package/esm/switch/switch-adapter.js +5 -5
- package/esm/switch/switch-component-delegate.d.ts +7 -0
- package/esm/switch/switch-component-delegate.js +15 -0
- package/esm/switch/switch-constants.d.ts +10 -0
- package/esm/switch/switch-constants.js +5 -0
- package/esm/switch/switch-core.d.ts +9 -9
- package/esm/switch/switch-core.js +26 -25
- package/esm/switch/switch.d.ts +23 -7
- package/esm/switch/switch.js +26 -17
- package/esm/table/table-utils.js +6 -6
- package/esm/tabs/tab-bar/tab-bar-adapter.d.ts +0 -5
- package/esm/tabs/tab-bar/tab-bar-adapter.js +3 -11
- package/esm/tabs/tab-bar/tab-bar-constants.d.ts +0 -3
- package/esm/tabs/tab-bar/tab-bar-constants.js +0 -4
- package/esm/tabs/tab-bar/tab-bar-core.js +7 -7
- package/esm/tabs/tab-bar/tab-bar.d.ts +6 -3
- package/esm/tabs/tab-bar/tab-bar.js +6 -3
- package/package.json +1 -1
- package/sass/button-area/_core.scss +3 -0
- package/sass/checkbox/_core.scss +2 -2
- package/sass/core/styles/tokens/checkbox/_tokens.scss +1 -0
- package/sass/core/styles/tokens/radio/_tokens.scss +1 -0
- package/sass/core/styles/tokens/switch/_tokens.scss +1 -0
- package/sass/dialog/dialog.scss +5 -0
- package/sass/icon-button/icon-button.scss +10 -10
- package/sass/radio/radio/_core.scss +2 -2
- package/sass/switch/_core.scss +2 -2
- package/sass/switch/switch.scss +2 -2
- package/esm/avatar/avatar-adapter.d.ts +0 -36
- package/esm/avatar/avatar-adapter.js +0 -55
- package/esm/avatar/avatar-core.d.ts +0 -38
- package/esm/avatar/avatar-core.js +0 -101
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import { SWITCH_CONSTANTS } from './switch-constants';
|
|
7
7
|
export class SwitchCore {
|
|
8
8
|
get _submittedValue() {
|
|
9
|
-
return this.
|
|
9
|
+
return this._checked ? this._value : null;
|
|
10
10
|
}
|
|
11
11
|
constructor(_adapter) {
|
|
12
12
|
this._adapter = _adapter;
|
|
13
13
|
// State
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
this._checked = false;
|
|
15
|
+
this._defaultChecked = false;
|
|
16
16
|
this._value = 'on';
|
|
17
17
|
this._dense = false;
|
|
18
18
|
this._disabled = false;
|
|
@@ -46,9 +46,9 @@ export class SwitchCore {
|
|
|
46
46
|
if (this._readonly) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const oldValue = this.
|
|
50
|
-
const newValue = !this.
|
|
51
|
-
this.
|
|
49
|
+
const oldValue = this._checked;
|
|
50
|
+
const newValue = !this._checked;
|
|
51
|
+
this._checked = newValue;
|
|
52
52
|
const event = new Event('change', { cancelable: true, bubbles: true });
|
|
53
53
|
const forgeEvent = new CustomEvent(SWITCH_CONSTANTS.events.CHANGE, {
|
|
54
54
|
detail: newValue,
|
|
@@ -57,35 +57,36 @@ export class SwitchCore {
|
|
|
57
57
|
});
|
|
58
58
|
this._adapter.dispatchHostEvent(event);
|
|
59
59
|
this._adapter.dispatchHostEvent(forgeEvent);
|
|
60
|
-
this.
|
|
60
|
+
this._checked = oldValue;
|
|
61
61
|
if (event.defaultPrevented || forgeEvent.defaultPrevented) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
this.
|
|
64
|
+
this.checked = newValue;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.
|
|
68
|
-
// Also set
|
|
69
|
-
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.
|
|
66
|
+
_setCheckedAttribute() {
|
|
67
|
+
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.CHECKED, this._checked);
|
|
68
|
+
// Also set the following for backwards compatibility
|
|
69
|
+
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.ON, this._checked);
|
|
70
|
+
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.SELECTED, this._checked);
|
|
70
71
|
}
|
|
71
|
-
get
|
|
72
|
-
return this.
|
|
72
|
+
get checked() {
|
|
73
|
+
return this._checked;
|
|
73
74
|
}
|
|
74
|
-
set
|
|
75
|
-
if (this.
|
|
76
|
-
this.
|
|
77
|
-
this._adapter.
|
|
75
|
+
set checked(value) {
|
|
76
|
+
if (this._checked !== value) {
|
|
77
|
+
this._checked = value;
|
|
78
|
+
this._adapter.setChecked(this._checked);
|
|
78
79
|
this._adapter.syncValue(this._submittedValue);
|
|
79
|
-
this.
|
|
80
|
+
this._setCheckedAttribute();
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
get
|
|
83
|
-
return this.
|
|
83
|
+
get defaultChecked() {
|
|
84
|
+
return this._defaultChecked;
|
|
84
85
|
}
|
|
85
|
-
set
|
|
86
|
-
if (this.
|
|
87
|
-
this.
|
|
88
|
-
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.
|
|
86
|
+
set defaultChecked(value) {
|
|
87
|
+
if (this._defaultChecked !== value) {
|
|
88
|
+
this._defaultChecked = value;
|
|
89
|
+
this._adapter.toggleHostAttribute(SWITCH_CONSTANTS.attributes.DEFAULT_CHECKED, this._defaultChecked);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
get value() {
|
package/esm/switch/switch.d.ts
CHANGED
|
@@ -13,11 +13,13 @@ import { IWithLabelAwareness } from '../core/mixins/label/with-label-aware';
|
|
|
13
13
|
import { SwitchIconVisibility, SwitchLabelPosition } from './switch-constants';
|
|
14
14
|
export interface ISwitchComponent extends IWithFormAssociation, IWithFocusable, IWithLabelAwareness, IWithElementInternals, IWithDefaultAria {
|
|
15
15
|
value: string;
|
|
16
|
+
checked: boolean;
|
|
17
|
+
/** @deprecated use `checked` instead */
|
|
16
18
|
on: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated use `on` instead
|
|
19
|
-
*/
|
|
19
|
+
/** @deprecated use `on` instead */
|
|
20
20
|
selected: boolean;
|
|
21
|
+
defaultChecked: boolean;
|
|
22
|
+
/** @deprecated use `defaultChecked` instead */
|
|
21
23
|
defaultOn: boolean;
|
|
22
24
|
required: boolean;
|
|
23
25
|
dense: boolean;
|
|
@@ -103,6 +105,7 @@ declare const SwitchComponent_base: import("../constants").AbstractConstructor<i
|
|
|
103
105
|
* @cssproperty --forge-switch-icon-active-off-scale - The scale transformation applied to the handle icons when the switch is active (pressed) in its off state.
|
|
104
106
|
* @cssproperty --forge-switch-gap - The space between the switch and label.
|
|
105
107
|
* @cssproperty --forge-switch-justify - How the switch and label are distributed along their main axis.
|
|
108
|
+
* @cssproperty --forge-switch-align - How the switch and label are distributed along their cross axis.
|
|
106
109
|
* @cssproperty --forge-switch-direction - Whether the switch and label are arranged along the inline or block axis.
|
|
107
110
|
* @cssproperty --forge-switch-state-layer-size - The inline and block size of the handle's state layer.
|
|
108
111
|
* @cssproperty --forge-switch-state-layer-width - The inline size of the handle's state layer.
|
|
@@ -149,20 +152,33 @@ export declare class SwitchComponent extends SwitchComponent_base implements ISw
|
|
|
149
152
|
/** @ignore */
|
|
150
153
|
setFormValue(value: FormValue | null, state?: FormValue | null | undefined): void;
|
|
151
154
|
/**
|
|
152
|
-
* Gets/sets whether the switch is
|
|
155
|
+
* Gets/sets whether the switch is checked or not.
|
|
156
|
+
* @default false
|
|
157
|
+
* @attribute
|
|
158
|
+
*/
|
|
159
|
+
checked: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Alias for `checked` _(deprecated)_. Gets/sets whether the switch is checked or not.
|
|
162
|
+
* @deprecated use `checked` instead.
|
|
153
163
|
* @default false
|
|
154
164
|
* @attribute
|
|
155
165
|
*/
|
|
156
166
|
on: boolean;
|
|
157
167
|
/**
|
|
158
|
-
* Alias for `
|
|
159
|
-
* @deprecated use `
|
|
168
|
+
* Alias for `checked` _(deprecated)_.
|
|
169
|
+
* @deprecated use `checked` instead
|
|
160
170
|
* @default false
|
|
161
171
|
* @attribute
|
|
162
172
|
*/
|
|
163
173
|
selected: boolean;
|
|
164
174
|
/**
|
|
165
|
-
* Gets/sets whether the switch is
|
|
175
|
+
* Gets/sets whether the switch is checked by default.
|
|
176
|
+
* @default false
|
|
177
|
+
* @attribute default-checked
|
|
178
|
+
*/
|
|
179
|
+
defaultChecked: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Alias for `defaultChecked` _(deprecated)_. Gets/sets whether the switch is checked by default.
|
|
166
182
|
* @default false
|
|
167
183
|
* @attribute default-on
|
|
168
184
|
*/
|
package/esm/switch/switch.js
CHANGED
|
@@ -18,7 +18,7 @@ import { SwitchAdapter } from './switch-adapter';
|
|
|
18
18
|
import { SWITCH_CONSTANTS } from './switch-constants';
|
|
19
19
|
import { SwitchCore } from './switch-core';
|
|
20
20
|
const template = '<template><div class=\"forge-switch\" part=\"switch\"><div id=\"container\" class=\"container\"><div class=\"track\" part=\"track\"></div><div class=\"handle\" part=\"handle\"><div id=\"icon-off\" class=\"icon icon__off\" part=\"icon-off\"><slot name=\"icon-off\"><svg aria-hidden=\"true\" viewBox=\"0 0 24 24\"><path d=\"M20 13H4v-2h16v2z\"/></svg></slot></div><div id=\"icon-on\" class=\"icon icon__on\" part=\"icon-on\"><slot name=\"icon-on\"><svg aria-hidden=\"true\" viewBox=\"0 0 24 24\"><path d=\"M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z\"/></svg></slot></div><forge-state-layer target=\":host\" exportparts=\"surface:state-layer\"></forge-state-layer></div><forge-focus-indicator target=\":host\" part=\"focus-indicator\"></forge-focus-indicator></div><label id=\"label\" class=\"label\" part=\"label\"><slot></slot></label></div></template>';
|
|
21
|
-
const styles = ':host{display:inline-block;outline:0;-webkit-tap-highlight-color:transparent}:host([hidden]){display:none}.forge-switch{--_switch-handle-size:var(--forge-switch-handle-size, 20px);--_switch-handle-scale:var(--forge-switch-handle-scale, 1);--_switch-handle-elevation:var(--forge-switch-handle-elevation, 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12));--_switch-track-border-width:var(--forge-switch-track-border-width, 0);--_switch-track-border-color:var(--forge-switch-track-border-color, transparent);--_switch-icon-color:var(--forge-switch-icon-color, var(--forge-theme-on-tertiary, #ffffff));--_switch-icon-size:var(--forge-switch-icon-size, 16px);--_switch-icon-scale:var(--forge-switch-icon-scale, 1);--_switch-state-layer-size:var(--forge-switch-state-layer-size, 40px);--_switch-state-layer-dense-size:var(--forge-switch-state-layer-dense-size, 28px);--_switch-handle-on-color:var(--forge-switch-handle-on-color, var(--forge-theme-tertiary, #3d5afe));--_switch-handle-off-color:var(--forge-switch-handle-off-color, var(--forge-theme-surface-container-high, #9e9e9e));--_switch-handle-width:var(--forge-switch-handle-width, var(--_switch-handle-size));--_switch-handle-height:var(--forge-switch-handle-height, var(--_switch-handle-size));--_switch-handle-on-scale:var(--forge-switch-handle-on-scale, var(--_switch-handle-scale));--_switch-handle-off-scale:var(--forge-switch-handle-off-scale, var(--_switch-handle-scale));--_switch-handle-shape:var(--forge-switch-handle-shape, calc(var(--forge-shape-round, 50%) * var(--forge-shape-factor, 1)));--_switch-handle-on-elevation:var(--forge-switch-handle-on-elevation, var(--_switch-handle-elevation));--_switch-handle-off-elevation:var(--forge-switch-handle-off-elevation, var(--_switch-handle-elevation));--_switch-track-on-color:var(--forge-switch-track-on-color, var(--forge-theme-tertiary-container, #d0d7ff));--_switch-track-off-color:var(--forge-switch-track-off-color, var(--forge-theme-surface-container, #e0e0e0));--_switch-track-width:var(--forge-switch-track-width, 36px);--_switch-track-height:var(--forge-switch-track-height, 14px);--_switch-track-shape:var(--forge-switch-track-shape, calc(var(--forge-shape-full, 9999px) * var(--forge-shape-factor, 1)));--_switch-track-on-border-width:var(--forge-switch-track-on-border-width, var(--_switch-track-border-width));--_switch-track-off-border-width:var(--forge-switch-track-off-border-width, var(--_switch-track-border-width));--_switch-track-on-border-color:var(--forge-switch-track-on-border-color, var(--_switch-track-border-color));--_switch-track-off-border-color:var(--forge-switch-track-off-border-color, var(--_switch-track-border-color));--_switch-icon-on-color:var(--forge-switch-icon-on-color, var(--_switch-icon-color));--_switch-icon-off-color:var(--forge-switch-icon-off-color, var(--_switch-icon-color));--_switch-icon-on-size:var(--forge-switch-icon-on-size, var(--_switch-icon-size));--_switch-icon-off-size:var(--forge-switch-icon-off-size, var(--_switch-icon-size));--_switch-icon-on-scale:var(--forge-switch-icon-on-scale, var(--_switch-icon-scale));--_switch-icon-off-scale:var(--forge-switch-icon-off-scale, var(--_switch-icon-scale));--_switch-gap:var(--forge-switch-gap, 0);--_switch-justify:var(--forge-switch-justify, start);--_switch-direction:var(--forge-switch-direction, initial);--_switch-state-layer-width:var(--forge-switch-state-layer-width, var(--_switch-state-layer-size));--_switch-state-layer-height:var(--forge-switch-state-layer-height, var(--_switch-state-layer-size));--_switch-state-layer-on-color:var(--forge-switch-state-layer-on-color, var(--_switch-handle-on-color));--_switch-state-layer-off-color:var(--forge-switch-state-layer-off-color, var(--_switch-color));--_switch-state-layer-dense-width:var(--forge-switch-state-layer-dense-width, var(--_switch-state-layer-dense-size));--_switch-state-layer-dense-height:var(--forge-switch-state-layer-dense-height, var(--_switch-state-layer-dense-size));--_switch-disabled-opacity:var(--forge-switch-disabled-opacity, 0.38);--_switch-handle-active-on-color:var(--forge-switch-handle-active-on-color, var(--_switch-handle-on-color));--_switch-handle-active-off-color:var(--forge-switch-handle-active-off-color, var(--_switch-handle-off-color));--_switch-handle-active-scale:var(--forge-switch-handle-active-scale, 1.2);--_switch-handle-active-on-scale:var(--forge-switch-handle-active-on-scale, var(--_switch-handle-active-scale));--_switch-handle-active-off-scale:var(--forge-switch-handle-active-off-scale, var(--_switch-handle-active-scale));--_switch-handle-active-elevation:var(--forge-switch-handle-active-elevation, var(--_switch-handle-elevation));--_switch-handle-active-on-elevation:var(--forge-switch-handle-active-on-elevation, var(--_switch-handle-active-elevation));--_switch-handle-active-off-elevation:var(--forge-switch-handle-active-off-elevation, var(--_switch-handle-active-elevation));--_switch-track-active-on-color:var(--forge-switch-track-active-on-color, var(--_switch-track-on-color));--_switch-track-active-off-color:var(--forge-switch-track-active-off-color, var(--_switch-track-off-color));--_switch-track-active-on-border-width:var(--forge-switch-track-active-on-border-width, var(--_switch-track-on-border-width));--_switch-track-active-off-border-width:var(--forge-switch-track-active-off-border-width, var(--_switch-track-off-border-width));--_switch-track-active-on-border-color:var(--forge-switch-track-active-on-border-color, var(--_switch-track-on-border-color));--_switch-track-active-off-border-color:var(--forge-switch-track-active-off-border-color, var(--_switch-track-off-border-color));--_switch-icon-active-on-color:var(--forge-switch-icon-active-on-color, var(--_switch-icon-on-color));--_switch-icon-active-off-color:var(--forge-switch-icon-active-off-color, var(--_switch-icon-off-color));--_switch-icon-active-on-scale:var(--forge-switch-icon-active-on-scale, var(--_switch-icon-on-scale));--_switch-icon-active-off-scale:var(--forge-switch-icon-active-off-scale, var(--_switch-icon-off-scale));--_switch-animation-duration:var(--forge-switch-animation-duration, var(--forge-animation-duration-short2, 100ms));--_switch-animation-timing:var(--forge-switch-animation-timing, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)));--_switch-active-animation-timing:var(--forge-switch-active-animation-timing, var(--forge-animation-easing-linear, cubic-bezier(0, 0, 1, 1)))}.forge-switch{display:flex;position:relative;flex-direction:var(--_switch-direction);flex-shrink:0;align-items:center;justify-content:var(--_switch-justify);gap:var(--_switch-gap);--_switch-current-state-layer-width:var(--_switch-state-layer-width);--_switch-current-state-layer-height:var(--_switch-state-layer-height)}.forge-switch .container{position:relative;align-items:center;display:flex;block-size:max(var(--_switch-handle-height),var(--_switch-track-height),var(--_switch-current-state-layer-height));cursor:pointer}.forge-switch .input{position:absolute;z-index:1;appearance:none;outline:0;margin:0;inline-size:100%;block-size:100%;cursor:unset}.forge-switch .track{transition-property:background-color,border-color,border-width;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);box-sizing:border-box;margin-inline:calc(max(var(--_switch-handle-width),var(--_switch-current-state-layer-width))/ 2 - calc(var(--_switch-track-height)/ 2));border-width:var(--_switch-track-off-border-width);border-color:var(--_switch-track-off-border-color);border-style:solid;border-radius:var(--_switch-track-shape);inline-size:var(--_switch-track-width);block-size:var(--_switch-track-height);background-color:var(--_switch-track-off-color)}.forge-switch .handle{position:absolute;justify-content:center;align-items:center;display:flex;transition-property:translate;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);border-radius:var(--_switch-handle-shape);inline-size:var(--_switch-current-state-layer-width);block-size:var(--_switch-current-state-layer-height)}.forge-switch .handle::before{content:\"\";position:relative;display:block;scale:var(--_switch-handle-off-scale);transition:background-color var(--_switch-animation-duration) var(--_switch-animation-timing),box-shadow var(--_switch-animation-duration) var(--_switch-animation-timing),scale var(--_switch-animation-duration) var(--_switch-active-animation-timing);box-shadow:var(--_switch-handle-off-elevation);border-radius:var(--_switch-handle-shape);inline-size:var(--_switch-handle-width);block-size:var(--_switch-handle-height);background-color:var(--_switch-handle-off-color)}.forge-switch .icon{position:absolute;align-items:center;justify-content:center;display:flex;transition-property:opacity,scale;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);inline-size:var(--_switch-icon-off-size);block-size:var(--_switch-icon-off-size);color:var(--_switch-icon-off-color);fill:var(--_switch-icon-off-color);font-size:var(--_switch-icon-off-size);--forge-icon-font-size:var(--_switch-icon-off-size)}.forge-switch .icon__on{--forge-icon-font-size:var(--_switch-icon-on-size);inline-size:var(--_switch-icon-on-size);block-size:var(--_switch-icon-on-size);color:var(--_switch-icon-on-color);fill:var(--_switch-icon-on-color);font-size:var(--_switch-icon-on-size);opacity:0;scale:0.4}.forge-switch .icon__off{opacity:1;scale:var(--_switch-icon-off-scale)}.forge-switch .label{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-label2-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));font-size:var(--forge-typography-label2-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-font-size-scale, .8125)));font-weight:var(--forge-typography-label2-font-weight,400);line-height:var(--forge-typography-label2-line-height, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-line-height-scale, 1.25)));letter-spacing:var(--forge-typography-label2-letter-spacing, .0096153846em);text-transform:var(--forge-typography-label2-text-transform,inherit);text-decoration:var(--forge-typography-label2-text-decoration,inherit)}.forge-switch .label:empty{display:none}.forge-switch .hidden{display:none}.forge-switch ::slotted([slot=input]){position:absolute;z-index:1;appearance:none;outline:0;margin:0;inline-size:100%;block-size:100%;cursor:unset}:host([on]) .track{border-width:var(--_switch-track-on-border-width);border-color:var(--_switch-track-on-border-color);background-color:var(--_switch-track-on-color)}:host([on]) .handle{translate:calc(var(--_switch-track-width) - calc(var(--_switch-track-height)/ 2) * 2)}:host([on]) .handle::before{scale:var(--_switch-handle-on-scale);box-shadow:var(--_switch-handle-on-elevation);background-color:var(--_switch-handle-on-color)}:host([on]) .handle .icon__on{opacity:1;scale:var(--_switch-icon-on-scale)}:host([on]) .handle .icon__off{opacity:0;scale:0.4}:host([on]) forge-state-layer{--forge-state-layer-color:var(--_switch-state-layer-on-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .track{border-width:var(--_switch-track-active-off-border-width);border-color:var(--_switch-track-active-off-border-color);background-color:var(--_switch-track-active-off-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .handle::before{scale:var(--_switch-handle-active-off-scale);box-shadow:var(--_switch-handle-active-off-elevation);background-color:var(--_switch-handle-active-off-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .handle .icon{scale:var(--_switch-icon-active-off-scale);color:var(--_switch-icon-active-off-color);fill:var(--_switch-icon-active-off-color)}:host(:not([disabled]):not([readonly])[on]) .forge-switch .container:active .track{border-width:var(--_switch-track-active-on-border-width);border-color:var(--_switch-track-active-on-border-color);background-color:var(--_switch-track-active-on-color)}:host(:not([disabled]):not([readonly])[on]) .forge-switch .container:active .handle::before{scale:var(--_switch-handle-active-on-scale);box-shadow:var(--_switch-handle-active-on-elevation);background-color:var(--_switch-handle-active-on-color)}:host(:not([disabled]):not([readonly])[on]) .forge-switch .container:active .handle .icon{scale:var(--_switch-icon-active-on-scale);color:var(--_switch-icon-active-on-color);fill:var(--_switch-icon-active-on-color)}:host([dense]) .forge-switch{--_switch-current-state-layer-width:var(--_switch-state-layer-dense-width);--_switch-current-state-layer-height:var(--_switch-state-layer-dense-height)}:host([disabled]) .forge-switch .container{opacity:var(--_switch-disabled-opacity);cursor:not-allowed}:host([disabled]) .forge-switch .handle::before{box-shadow:none}:host([readonly]) .forge-switch .container{cursor:not-allowed}@media (prefers-reduced-motion){.switch{--_switch-animation-duration:var(--forge-switch-animation-duration, 0s)}}forge-state-layer{--forge-state-layer-color:var(--_switch-state-layer-off-color)}forge-focus-indicator{--forge-focus-indicator-shape:var(--_switch-track-shape);--forge-focus-indicator-outward-offset:0px}';
|
|
21
|
+
const styles = ':host{display:inline-block;outline:0;-webkit-tap-highlight-color:transparent}:host([hidden]){display:none}.forge-switch{--_switch-handle-size:var(--forge-switch-handle-size, 20px);--_switch-handle-scale:var(--forge-switch-handle-scale, 1);--_switch-handle-elevation:var(--forge-switch-handle-elevation, 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12));--_switch-track-border-width:var(--forge-switch-track-border-width, 0);--_switch-track-border-color:var(--forge-switch-track-border-color, transparent);--_switch-icon-color:var(--forge-switch-icon-color, var(--forge-theme-on-tertiary, #ffffff));--_switch-icon-size:var(--forge-switch-icon-size, 16px);--_switch-icon-scale:var(--forge-switch-icon-scale, 1);--_switch-state-layer-size:var(--forge-switch-state-layer-size, 40px);--_switch-state-layer-dense-size:var(--forge-switch-state-layer-dense-size, 28px);--_switch-handle-on-color:var(--forge-switch-handle-on-color, var(--forge-theme-tertiary, #3d5afe));--_switch-handle-off-color:var(--forge-switch-handle-off-color, var(--forge-theme-surface-container-high, #9e9e9e));--_switch-handle-width:var(--forge-switch-handle-width, var(--_switch-handle-size));--_switch-handle-height:var(--forge-switch-handle-height, var(--_switch-handle-size));--_switch-handle-on-scale:var(--forge-switch-handle-on-scale, var(--_switch-handle-scale));--_switch-handle-off-scale:var(--forge-switch-handle-off-scale, var(--_switch-handle-scale));--_switch-handle-shape:var(--forge-switch-handle-shape, calc(var(--forge-shape-round, 50%) * var(--forge-shape-factor, 1)));--_switch-handle-on-elevation:var(--forge-switch-handle-on-elevation, var(--_switch-handle-elevation));--_switch-handle-off-elevation:var(--forge-switch-handle-off-elevation, var(--_switch-handle-elevation));--_switch-track-on-color:var(--forge-switch-track-on-color, var(--forge-theme-tertiary-container, #d0d7ff));--_switch-track-off-color:var(--forge-switch-track-off-color, var(--forge-theme-surface-container, #e0e0e0));--_switch-track-width:var(--forge-switch-track-width, 36px);--_switch-track-height:var(--forge-switch-track-height, 14px);--_switch-track-shape:var(--forge-switch-track-shape, calc(var(--forge-shape-full, 9999px) * var(--forge-shape-factor, 1)));--_switch-track-on-border-width:var(--forge-switch-track-on-border-width, var(--_switch-track-border-width));--_switch-track-off-border-width:var(--forge-switch-track-off-border-width, var(--_switch-track-border-width));--_switch-track-on-border-color:var(--forge-switch-track-on-border-color, var(--_switch-track-border-color));--_switch-track-off-border-color:var(--forge-switch-track-off-border-color, var(--_switch-track-border-color));--_switch-icon-on-color:var(--forge-switch-icon-on-color, var(--_switch-icon-color));--_switch-icon-off-color:var(--forge-switch-icon-off-color, var(--_switch-icon-color));--_switch-icon-on-size:var(--forge-switch-icon-on-size, var(--_switch-icon-size));--_switch-icon-off-size:var(--forge-switch-icon-off-size, var(--_switch-icon-size));--_switch-icon-on-scale:var(--forge-switch-icon-on-scale, var(--_switch-icon-scale));--_switch-icon-off-scale:var(--forge-switch-icon-off-scale, var(--_switch-icon-scale));--_switch-gap:var(--forge-switch-gap, 0);--_switch-justify:var(--forge-switch-justify, start);--_switch-align:var(--forge-switch-align, center);--_switch-direction:var(--forge-switch-direction, initial);--_switch-state-layer-width:var(--forge-switch-state-layer-width, var(--_switch-state-layer-size));--_switch-state-layer-height:var(--forge-switch-state-layer-height, var(--_switch-state-layer-size));--_switch-state-layer-on-color:var(--forge-switch-state-layer-on-color, var(--_switch-handle-on-color));--_switch-state-layer-off-color:var(--forge-switch-state-layer-off-color, var(--_switch-color));--_switch-state-layer-dense-width:var(--forge-switch-state-layer-dense-width, var(--_switch-state-layer-dense-size));--_switch-state-layer-dense-height:var(--forge-switch-state-layer-dense-height, var(--_switch-state-layer-dense-size));--_switch-disabled-opacity:var(--forge-switch-disabled-opacity, 0.38);--_switch-handle-active-on-color:var(--forge-switch-handle-active-on-color, var(--_switch-handle-on-color));--_switch-handle-active-off-color:var(--forge-switch-handle-active-off-color, var(--_switch-handle-off-color));--_switch-handle-active-scale:var(--forge-switch-handle-active-scale, 1.2);--_switch-handle-active-on-scale:var(--forge-switch-handle-active-on-scale, var(--_switch-handle-active-scale));--_switch-handle-active-off-scale:var(--forge-switch-handle-active-off-scale, var(--_switch-handle-active-scale));--_switch-handle-active-elevation:var(--forge-switch-handle-active-elevation, var(--_switch-handle-elevation));--_switch-handle-active-on-elevation:var(--forge-switch-handle-active-on-elevation, var(--_switch-handle-active-elevation));--_switch-handle-active-off-elevation:var(--forge-switch-handle-active-off-elevation, var(--_switch-handle-active-elevation));--_switch-track-active-on-color:var(--forge-switch-track-active-on-color, var(--_switch-track-on-color));--_switch-track-active-off-color:var(--forge-switch-track-active-off-color, var(--_switch-track-off-color));--_switch-track-active-on-border-width:var(--forge-switch-track-active-on-border-width, var(--_switch-track-on-border-width));--_switch-track-active-off-border-width:var(--forge-switch-track-active-off-border-width, var(--_switch-track-off-border-width));--_switch-track-active-on-border-color:var(--forge-switch-track-active-on-border-color, var(--_switch-track-on-border-color));--_switch-track-active-off-border-color:var(--forge-switch-track-active-off-border-color, var(--_switch-track-off-border-color));--_switch-icon-active-on-color:var(--forge-switch-icon-active-on-color, var(--_switch-icon-on-color));--_switch-icon-active-off-color:var(--forge-switch-icon-active-off-color, var(--_switch-icon-off-color));--_switch-icon-active-on-scale:var(--forge-switch-icon-active-on-scale, var(--_switch-icon-on-scale));--_switch-icon-active-off-scale:var(--forge-switch-icon-active-off-scale, var(--_switch-icon-off-scale));--_switch-animation-duration:var(--forge-switch-animation-duration, var(--forge-animation-duration-short2, 100ms));--_switch-animation-timing:var(--forge-switch-animation-timing, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)));--_switch-active-animation-timing:var(--forge-switch-active-animation-timing, var(--forge-animation-easing-linear, cubic-bezier(0, 0, 1, 1)))}.forge-switch{display:flex;position:relative;flex-direction:var(--_switch-direction);align-items:var(--_switch-align);justify-content:var(--_switch-justify);gap:var(--_switch-gap);--_switch-current-state-layer-width:var(--_switch-state-layer-width);--_switch-current-state-layer-height:var(--_switch-state-layer-height)}.forge-switch .container{position:relative;align-items:center;display:flex;flex-shrink:0;block-size:max(var(--_switch-handle-height),var(--_switch-track-height),var(--_switch-current-state-layer-height));cursor:pointer}.forge-switch .input{position:absolute;z-index:1;appearance:none;outline:0;margin:0;inline-size:100%;block-size:100%;cursor:unset}.forge-switch .track{transition-property:background-color,border-color,border-width;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);box-sizing:border-box;margin-inline:calc(max(var(--_switch-handle-width),var(--_switch-current-state-layer-width))/ 2 - calc(var(--_switch-track-height)/ 2));border-width:var(--_switch-track-off-border-width);border-color:var(--_switch-track-off-border-color);border-style:solid;border-radius:var(--_switch-track-shape);inline-size:var(--_switch-track-width);block-size:var(--_switch-track-height);background-color:var(--_switch-track-off-color)}.forge-switch .handle{position:absolute;justify-content:center;align-items:center;display:flex;transition-property:translate;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);border-radius:var(--_switch-handle-shape);inline-size:var(--_switch-current-state-layer-width);block-size:var(--_switch-current-state-layer-height)}.forge-switch .handle::before{content:\"\";position:relative;display:block;scale:var(--_switch-handle-off-scale);transition:background-color var(--_switch-animation-duration) var(--_switch-animation-timing),box-shadow var(--_switch-animation-duration) var(--_switch-animation-timing),scale var(--_switch-animation-duration) var(--_switch-active-animation-timing);box-shadow:var(--_switch-handle-off-elevation);border-radius:var(--_switch-handle-shape);inline-size:var(--_switch-handle-width);block-size:var(--_switch-handle-height);background-color:var(--_switch-handle-off-color)}.forge-switch .icon{position:absolute;align-items:center;justify-content:center;display:flex;transition-property:opacity,scale;transition-duration:var(--_switch-animation-duration);transition-timing-function:var(--_switch-animation-timing);inline-size:var(--_switch-icon-off-size);block-size:var(--_switch-icon-off-size);color:var(--_switch-icon-off-color);fill:var(--_switch-icon-off-color);font-size:var(--_switch-icon-off-size);--forge-icon-font-size:var(--_switch-icon-off-size)}.forge-switch .icon__on{--forge-icon-font-size:var(--_switch-icon-on-size);inline-size:var(--_switch-icon-on-size);block-size:var(--_switch-icon-on-size);color:var(--_switch-icon-on-color);fill:var(--_switch-icon-on-color);font-size:var(--_switch-icon-on-size);opacity:0;scale:0.4}.forge-switch .icon__off{opacity:1;scale:var(--_switch-icon-off-scale)}.forge-switch .label{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-label2-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));font-size:var(--forge-typography-label2-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-font-size-scale, .8125)));font-weight:var(--forge-typography-label2-font-weight,400);line-height:var(--forge-typography-label2-line-height, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-label-line-height-scale, 1.25)));letter-spacing:var(--forge-typography-label2-letter-spacing, .0096153846em);text-transform:var(--forge-typography-label2-text-transform,inherit);text-decoration:var(--forge-typography-label2-text-decoration,inherit)}.forge-switch .label:empty{display:none}.forge-switch .hidden{display:none}.forge-switch ::slotted([slot=input]){position:absolute;z-index:1;appearance:none;outline:0;margin:0;inline-size:100%;block-size:100%;cursor:unset}:host([checked]) .track{border-width:var(--_switch-track-on-border-width);border-color:var(--_switch-track-on-border-color);background-color:var(--_switch-track-on-color)}:host([checked]) .handle{translate:calc(var(--_switch-track-width) - calc(var(--_switch-track-height)/ 2) * 2)}:host([checked]) .handle::before{scale:var(--_switch-handle-on-scale);box-shadow:var(--_switch-handle-on-elevation);background-color:var(--_switch-handle-on-color)}:host([checked]) .handle .icon__on{opacity:1;scale:var(--_switch-icon-on-scale)}:host([checked]) .handle .icon__off{opacity:0;scale:0.4}:host([checked]) forge-state-layer{--forge-state-layer-color:var(--_switch-state-layer-on-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .track{border-width:var(--_switch-track-active-off-border-width);border-color:var(--_switch-track-active-off-border-color);background-color:var(--_switch-track-active-off-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .handle::before{scale:var(--_switch-handle-active-off-scale);box-shadow:var(--_switch-handle-active-off-elevation);background-color:var(--_switch-handle-active-off-color)}:host(:not([disabled]):not([readonly])) .forge-switch .container:active .handle .icon{scale:var(--_switch-icon-active-off-scale);color:var(--_switch-icon-active-off-color);fill:var(--_switch-icon-active-off-color)}:host(:not([disabled]):not([readonly])[checked]) .forge-switch .container:active .track{border-width:var(--_switch-track-active-on-border-width);border-color:var(--_switch-track-active-on-border-color);background-color:var(--_switch-track-active-on-color)}:host(:not([disabled]):not([readonly])[checked]) .forge-switch .container:active .handle::before{scale:var(--_switch-handle-active-on-scale);box-shadow:var(--_switch-handle-active-on-elevation);background-color:var(--_switch-handle-active-on-color)}:host(:not([disabled]):not([readonly])[checked]) .forge-switch .container:active .handle .icon{scale:var(--_switch-icon-active-on-scale);color:var(--_switch-icon-active-on-color);fill:var(--_switch-icon-active-on-color)}:host([dense]) .forge-switch{--_switch-current-state-layer-width:var(--_switch-state-layer-dense-width);--_switch-current-state-layer-height:var(--_switch-state-layer-dense-height)}:host([disabled]) .forge-switch .container{opacity:var(--_switch-disabled-opacity);cursor:not-allowed}:host([disabled]) .forge-switch .handle::before{box-shadow:none}:host([readonly]) .forge-switch .container{cursor:not-allowed}@media (prefers-reduced-motion){.switch{--_switch-animation-duration:var(--forge-switch-animation-duration, 0s)}}forge-state-layer{--forge-state-layer-color:var(--_switch-state-layer-off-color)}forge-focus-indicator{--forge-focus-indicator-shape:var(--_switch-track-shape);--forge-focus-indicator-outward-offset:0px}';
|
|
22
22
|
/**
|
|
23
23
|
* @tag forge-switch
|
|
24
24
|
*
|
|
@@ -86,6 +86,7 @@ const styles = ':host{display:inline-block;outline:0;-webkit-tap-highlight-color
|
|
|
86
86
|
* @cssproperty --forge-switch-icon-active-off-scale - The scale transformation applied to the handle icons when the switch is active (pressed) in its off state.
|
|
87
87
|
* @cssproperty --forge-switch-gap - The space between the switch and label.
|
|
88
88
|
* @cssproperty --forge-switch-justify - How the switch and label are distributed along their main axis.
|
|
89
|
+
* @cssproperty --forge-switch-align - How the switch and label are distributed along their cross axis.
|
|
89
90
|
* @cssproperty --forge-switch-direction - Whether the switch and label are arranged along the inline or block axis.
|
|
90
91
|
* @cssproperty --forge-switch-state-layer-size - The inline and block size of the handle's state layer.
|
|
91
92
|
* @cssproperty --forge-switch-state-layer-width - The inline size of the handle's state layer.
|
|
@@ -130,7 +131,7 @@ let SwitchComponent = class SwitchComponent extends WithFormAssociation(WithLabe
|
|
|
130
131
|
super.connectedCallback();
|
|
131
132
|
this[setDefaultAria]({
|
|
132
133
|
role: 'switch',
|
|
133
|
-
ariaChecked: this.
|
|
134
|
+
ariaChecked: this.checked ? 'true' : 'false',
|
|
134
135
|
ariaDisabled: this.disabled ? 'true' : 'false',
|
|
135
136
|
ariaRequired: this.required ? 'true' : 'false'
|
|
136
137
|
});
|
|
@@ -138,12 +139,14 @@ let SwitchComponent = class SwitchComponent extends WithFormAssociation(WithLabe
|
|
|
138
139
|
}
|
|
139
140
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
140
141
|
switch (name) {
|
|
142
|
+
case SWITCH_CONSTANTS.observedAttributes.CHECKED:
|
|
141
143
|
case SWITCH_CONSTANTS.observedAttributes.ON:
|
|
142
144
|
case SWITCH_CONSTANTS.observedAttributes.SELECTED:
|
|
143
|
-
this.
|
|
145
|
+
this.checked = coerceBoolean(newValue);
|
|
144
146
|
break;
|
|
147
|
+
case SWITCH_CONSTANTS.observedAttributes.DEFAULT_CHECKED:
|
|
145
148
|
case SWITCH_CONSTANTS.observedAttributes.DEFAULT_ON:
|
|
146
|
-
this.
|
|
149
|
+
this.defaultChecked = coerceBoolean(newValue);
|
|
147
150
|
break;
|
|
148
151
|
case SWITCH_CONSTANTS.observedAttributes.VALUE:
|
|
149
152
|
this.value = newValue;
|
|
@@ -170,22 +173,22 @@ let SwitchComponent = class SwitchComponent extends WithFormAssociation(WithLabe
|
|
|
170
173
|
super.attributeChangedCallback(name, oldValue, newValue);
|
|
171
174
|
}
|
|
172
175
|
[getFormValue]() {
|
|
173
|
-
return this.
|
|
176
|
+
return this.checked ? this.value : null;
|
|
174
177
|
}
|
|
175
178
|
[getFormState]() {
|
|
176
|
-
return this.
|
|
179
|
+
return this.checked ? SWITCH_CONSTANTS.state.ON : SWITCH_CONSTANTS.state.OFF;
|
|
177
180
|
}
|
|
178
181
|
[setValidity]() {
|
|
179
|
-
this[internals].setValidity({ valueMissing: this.required && !this.
|
|
180
|
-
checked: this.
|
|
182
|
+
this[internals].setValidity({ valueMissing: this.required && !this.checked }, this[getValidationMessage]({
|
|
183
|
+
checked: this.checked,
|
|
181
184
|
required: this.required
|
|
182
185
|
}));
|
|
183
186
|
}
|
|
184
187
|
formResetCallback() {
|
|
185
|
-
this.
|
|
188
|
+
this.checked = this.defaultChecked;
|
|
186
189
|
}
|
|
187
190
|
formStateRestoreCallback(state) {
|
|
188
|
-
this.
|
|
191
|
+
this.checked = state === SWITCH_CONSTANTS.state.ON;
|
|
189
192
|
}
|
|
190
193
|
labelClickedCallback() {
|
|
191
194
|
this.click();
|
|
@@ -200,17 +203,17 @@ let SwitchComponent = class SwitchComponent extends WithFormAssociation(WithLabe
|
|
|
200
203
|
this[internals].setFormValue(value, state);
|
|
201
204
|
if (state) {
|
|
202
205
|
const stateValue = isString(state) ? state : state[this.name];
|
|
203
|
-
this.
|
|
206
|
+
this.checked = stateValue === SWITCH_CONSTANTS.state.ON;
|
|
204
207
|
return;
|
|
205
208
|
}
|
|
206
209
|
if (isString(value)) {
|
|
207
|
-
this.
|
|
210
|
+
this.checked = !!value;
|
|
208
211
|
}
|
|
209
212
|
else if (value?.[this.name]) {
|
|
210
|
-
this.
|
|
213
|
+
this.checked = !!value[this.name];
|
|
211
214
|
}
|
|
212
215
|
else {
|
|
213
|
-
this.
|
|
216
|
+
this.checked = false;
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
/**
|
|
@@ -219,21 +222,27 @@ let SwitchComponent = class SwitchComponent extends WithFormAssociation(WithLabe
|
|
|
219
222
|
*/
|
|
220
223
|
toggle(force) {
|
|
221
224
|
if (isDefined(force)) {
|
|
222
|
-
this._core.
|
|
225
|
+
this._core.checked = force;
|
|
223
226
|
}
|
|
224
227
|
else {
|
|
225
|
-
this._core.
|
|
228
|
+
this._core.checked = !this._core.checked;
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
};
|
|
229
232
|
__decorate([
|
|
230
233
|
coreProperty()
|
|
234
|
+
], SwitchComponent.prototype, "checked", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
coreProperty({ name: 'checked' })
|
|
231
237
|
], SwitchComponent.prototype, "on", void 0);
|
|
232
238
|
__decorate([
|
|
233
|
-
coreProperty({ name: '
|
|
239
|
+
coreProperty({ name: 'checked' })
|
|
234
240
|
], SwitchComponent.prototype, "selected", void 0);
|
|
235
241
|
__decorate([
|
|
236
242
|
coreProperty()
|
|
243
|
+
], SwitchComponent.prototype, "defaultChecked", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
coreProperty({ name: 'defaultChecked' })
|
|
237
246
|
], SwitchComponent.prototype, "defaultOn", void 0);
|
|
238
247
|
__decorate([
|
|
239
248
|
coreProperty()
|
package/esm/table/table-utils.js
CHANGED
|
@@ -177,12 +177,6 @@ export class TableUtils {
|
|
|
177
177
|
Object.assign(th.style, columnConfig.headerCellStyle);
|
|
178
178
|
Object.assign(cellContainer.style, columnConfig.headerCellStyle);
|
|
179
179
|
}
|
|
180
|
-
const span = document.createElement('span');
|
|
181
|
-
span.classList.add(TABLE_CONSTANTS.classes.TABLE_HEAD_CELL_TEXT);
|
|
182
|
-
span.textContent = columnConfig.header && typeof columnConfig.header === 'string' ? columnConfig.header.trim() : '';
|
|
183
|
-
if (span.textContent.trim().length === 0) {
|
|
184
|
-
th.setAttribute('aria-hidden', 'true');
|
|
185
|
-
}
|
|
186
180
|
// Add the sort icon if this column is sortable
|
|
187
181
|
if (columnConfig.sortable) {
|
|
188
182
|
th.classList.add(TABLE_CONSTANTS.classes.TABLE_HEAD_CELL_SORTABLE);
|
|
@@ -231,6 +225,12 @@ export class TableUtils {
|
|
|
231
225
|
});
|
|
232
226
|
}
|
|
233
227
|
else {
|
|
228
|
+
const span = document.createElement('span');
|
|
229
|
+
span.classList.add(TABLE_CONSTANTS.classes.TABLE_HEAD_CELL_TEXT);
|
|
230
|
+
span.textContent = columnConfig.header && typeof columnConfig.header === 'string' ? columnConfig.header.trim() : '';
|
|
231
|
+
if (span.textContent.trim().length === 0) {
|
|
232
|
+
th.setAttribute('aria-hidden', 'true');
|
|
233
|
+
}
|
|
234
234
|
TableUtils._prepend(span, cellContainer);
|
|
235
235
|
}
|
|
236
236
|
th.appendChild(cellContainer);
|
|
@@ -7,8 +7,6 @@ import { BaseAdapter, IBaseAdapter } from '../../core/base/base-adapter';
|
|
|
7
7
|
import { ITabComponent } from '../tab/tab';
|
|
8
8
|
import { ITabBarComponent } from './tab-bar';
|
|
9
9
|
export interface ITabBarAdapter extends IBaseAdapter {
|
|
10
|
-
initialize(): void;
|
|
11
|
-
destroy(): void;
|
|
12
10
|
initializeContainerSizeObserver(listener: () => void): void;
|
|
13
11
|
destroyContainerSizeObserver(): void;
|
|
14
12
|
initializeScrollObserver(listener: EventListener): void;
|
|
@@ -41,10 +39,7 @@ export declare class TabBarAdapter extends BaseAdapter<ITabBarComponent> impleme
|
|
|
41
39
|
private _resizeObserver;
|
|
42
40
|
private _backwardScrollButton;
|
|
43
41
|
private _forwardScrollButton;
|
|
44
|
-
private _forwardObserver?;
|
|
45
42
|
constructor(component: ITabBarComponent);
|
|
46
|
-
initialize(): void;
|
|
47
|
-
destroy(): void;
|
|
48
43
|
initializeContainerSizeObserver(listener: () => void): void;
|
|
49
44
|
initializeScrollObserver(listener: EventListener): void;
|
|
50
45
|
destroyContainerSizeObserver(): void;
|
|
@@ -8,7 +8,6 @@ import { tylIconKeyboardArrowLeft, tylIconKeyboardArrowRight, tylIconKeyboardArr
|
|
|
8
8
|
import { BaseAdapter } from '../../core/base/base-adapter';
|
|
9
9
|
import { TAB_CONSTANTS } from '../tab/tab-constants';
|
|
10
10
|
import { TAB_BAR_CONSTANTS } from './tab-bar-constants';
|
|
11
|
-
import { forwardAttributes } from '../../core/utils/reflect-utils';
|
|
12
11
|
export class TabBarAdapter extends BaseAdapter {
|
|
13
12
|
constructor(component) {
|
|
14
13
|
super(component);
|
|
@@ -16,15 +15,6 @@ export class TabBarAdapter extends BaseAdapter {
|
|
|
16
15
|
this._rootElement = getShadowElement(this._component, TAB_BAR_CONSTANTS.selectors.ROOT);
|
|
17
16
|
this._scrollContainer = getShadowElement(this._component, TAB_BAR_CONSTANTS.selectors.SCROLL_CONTAINER);
|
|
18
17
|
}
|
|
19
|
-
initialize() {
|
|
20
|
-
this._forwardObserver = forwardAttributes(this._component, Object.keys(TAB_BAR_CONSTANTS.forwardedAttributes), (name, value) => {
|
|
21
|
-
toggleAttribute(this._scrollContainer, !!value, TAB_BAR_CONSTANTS.forwardedAttributes[name], value ?? undefined);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
destroy() {
|
|
25
|
-
this._forwardObserver?.disconnect();
|
|
26
|
-
this._forwardObserver = undefined;
|
|
27
|
-
}
|
|
28
18
|
initializeContainerSizeObserver(listener) {
|
|
29
19
|
this._resizeObserver = new ResizeObserver(() => listener());
|
|
30
20
|
this._resizeObserver.observe(this._component);
|
|
@@ -40,7 +30,7 @@ export class TabBarAdapter extends BaseAdapter {
|
|
|
40
30
|
this._scrollContainer.removeEventListener('scroll', listener, { passive: true });
|
|
41
31
|
}
|
|
42
32
|
setVertical(value) {
|
|
43
|
-
toggleAttribute(this.
|
|
33
|
+
toggleAttribute(this._component, !!value, 'aria-orientation', 'vertical');
|
|
44
34
|
}
|
|
45
35
|
setScrollBackwardButtonListener(listener) {
|
|
46
36
|
this._backwardScrollButton?.addEventListener('click', listener);
|
|
@@ -109,6 +99,7 @@ export class TabBarAdapter extends BaseAdapter {
|
|
|
109
99
|
this._forwardScrollButton?.focus();
|
|
110
100
|
}
|
|
111
101
|
this._backwardScrollButton.disabled = disabled;
|
|
102
|
+
this._backwardScrollButton.tabIndex = -1;
|
|
112
103
|
}
|
|
113
104
|
if (this._forwardScrollButton) {
|
|
114
105
|
const disabled = !forwardEnabled;
|
|
@@ -116,6 +107,7 @@ export class TabBarAdapter extends BaseAdapter {
|
|
|
116
107
|
this._backwardScrollButton?.focus();
|
|
117
108
|
}
|
|
118
109
|
this._forwardScrollButton.disabled = disabled;
|
|
110
|
+
this._forwardScrollButton.tabIndex = -1;
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
113
|
scroll(which) {
|
|
@@ -19,9 +19,6 @@ const observedAttributes = {
|
|
|
19
19
|
const attributes = {
|
|
20
20
|
...observedAttributes
|
|
21
21
|
};
|
|
22
|
-
const forwardedAttributes = {
|
|
23
|
-
'data-aria-label': 'aria-label'
|
|
24
|
-
};
|
|
25
22
|
const selectors = {
|
|
26
23
|
ROOT: '.forge-tab-bar',
|
|
27
24
|
SCROLL_CONTAINER: '.scroll-container',
|
|
@@ -40,7 +37,6 @@ export const TAB_BAR_CONSTANTS = {
|
|
|
40
37
|
elementName,
|
|
41
38
|
observedAttributes,
|
|
42
39
|
attributes,
|
|
43
|
-
forwardedAttributes,
|
|
44
40
|
events,
|
|
45
41
|
selectors,
|
|
46
42
|
classes,
|
|
@@ -29,7 +29,6 @@ export class TabBarCore {
|
|
|
29
29
|
this._scrollForwardButtonListener = () => this._onScrollForward();
|
|
30
30
|
}
|
|
31
31
|
initialize() {
|
|
32
|
-
this._adapter.initialize();
|
|
33
32
|
this._adapter.addSlotListener(this._tabsChangedListener);
|
|
34
33
|
this._adapter.addHostListener(TAB_CONSTANTS.events.SELECT, this._tabSelectedListener);
|
|
35
34
|
this._adapter.addHostListener('keydown', this._keydownListener);
|
|
@@ -43,7 +42,6 @@ export class TabBarCore {
|
|
|
43
42
|
this._isInitialized = true;
|
|
44
43
|
}
|
|
45
44
|
destroy() {
|
|
46
|
-
this._adapter.destroy();
|
|
47
45
|
this._adapter.destroyContainerSizeObserver();
|
|
48
46
|
this._adapter.destroyScrollObserver(this._scrollListener);
|
|
49
47
|
this._isInitialized = false;
|
|
@@ -54,7 +52,7 @@ export class TabBarCore {
|
|
|
54
52
|
this._tryScrollActiveTabIntoView();
|
|
55
53
|
}
|
|
56
54
|
_onTabSelected(evt) {
|
|
57
|
-
this._selectTab(evt.target);
|
|
55
|
+
this._selectTab({ tab: evt.target, focusTab: true });
|
|
58
56
|
}
|
|
59
57
|
async _onKeydown(evt) {
|
|
60
58
|
const orientation = this._vertical ? 'vertical' : 'horizontal';
|
|
@@ -91,14 +89,14 @@ export class TabBarCore {
|
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
93
91
|
if (this._autoActivate) {
|
|
94
|
-
this._selectTab(this._tabs[index]);
|
|
92
|
+
this._selectTab({ tab: this._tabs[index], focusTab: true });
|
|
95
93
|
}
|
|
96
94
|
else {
|
|
97
95
|
this._tabs[index].focus({ preventScroll: true, focusVisible: true });
|
|
98
96
|
await this._adapter.tryScrollTabIntoView(this._tabs[index]);
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
|
-
async _selectTab(tab, emitEvent = true) {
|
|
99
|
+
async _selectTab({ tab, emitEvent = true, focusTab = false }) {
|
|
102
100
|
if (!tab || tab.disabled) {
|
|
103
101
|
return;
|
|
104
102
|
}
|
|
@@ -121,7 +119,9 @@ export class TabBarCore {
|
|
|
121
119
|
}
|
|
122
120
|
// Selecting a tab causes an animation of the indicator to start relative to the currently selected tab
|
|
123
121
|
tab.selected = true;
|
|
124
|
-
|
|
122
|
+
if (focusTab) {
|
|
123
|
+
tab.focus({ preventScroll: true });
|
|
124
|
+
}
|
|
125
125
|
await this._adapter.tryScrollTabIntoView(tab);
|
|
126
126
|
// Always deselect the currently selected tab after selecting a new tab to allow
|
|
127
127
|
// for the tab indicator animation to run properly (the newly selected tab attempts
|
|
@@ -223,7 +223,7 @@ export class TabBarCore {
|
|
|
223
223
|
this._activeTab = value ?? undefined;
|
|
224
224
|
if (typeof this._activeTab === 'number') {
|
|
225
225
|
const newSelectedTab = this._tabs[this._activeTab];
|
|
226
|
-
this._selectTab(newSelectedTab, false);
|
|
226
|
+
this._selectTab({ tab: newSelectedTab, emitEvent: false, focusTab: false });
|
|
227
227
|
this._adapter.setHostAttribute(TAB_BAR_CONSTANTS.attributes.ACTIVE_TAB, String(this._activeTab));
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { BaseComponent, IBaseComponent } from '../../core/base/base-component';
|
|
7
7
|
import { ITabBarChangeEventData } from './tab-bar-constants';
|
|
8
|
-
|
|
8
|
+
import { IWithElementInternals } from '../../core/mixins/internals/with-element-internals';
|
|
9
|
+
import { IWithDefaultAria } from '../../core/mixins/internals/with-default-aria';
|
|
10
|
+
export interface ITabBarComponent extends IBaseComponent, IWithDefaultAria, IWithElementInternals {
|
|
9
11
|
disabled: boolean;
|
|
10
12
|
activeTab: number | null | undefined;
|
|
11
13
|
vertical: boolean;
|
|
@@ -25,6 +27,7 @@ declare global {
|
|
|
25
27
|
'forge-tab-bar-change': CustomEvent<ITabBarChangeEventData>;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
30
|
+
declare const TabBarComponent_base: import("../../constants").AbstractConstructor<import("../../core/mixins/internals/with-default-aria").WithDefaultAriaContract> & import("../../constants").AbstractConstructor<import("../../core/mixins/internals/with-element-internals").WithElementInternalsContract> & typeof BaseComponent;
|
|
28
31
|
/**
|
|
29
32
|
* @tag forge-tab-bar
|
|
30
33
|
*
|
|
@@ -57,7 +60,6 @@ declare global {
|
|
|
57
60
|
* @attribute {boolean} [secondary=false] - Deprecated. Controls whether the tabs are styled as secondary tab navigation.
|
|
58
61
|
* @attribute {boolean} [auto-activate=false] - Controls whether the tabs are automatically activated when receiving focus.
|
|
59
62
|
* @attribute {boolean} [scroll-buttons=false] - Controls whether scroll buttons are displayed when the tabs overflow their container.
|
|
60
|
-
* @attribute {string} [data-aria-label] - The ARIA label to forward to the internal tablist element.
|
|
61
63
|
*
|
|
62
64
|
* @event {CustomEvent<ITabBarChangeEventData>} forge-tab-bar-change - Dispatches when the active tab changes.
|
|
63
65
|
*
|
|
@@ -69,7 +71,7 @@ declare global {
|
|
|
69
71
|
* @csspart container - The container element.
|
|
70
72
|
* @csspart scroll-container - The scroll container element.
|
|
71
73
|
*/
|
|
72
|
-
export declare class TabBarComponent extends
|
|
74
|
+
export declare class TabBarComponent extends TabBarComponent_base implements ITabBarComponent {
|
|
73
75
|
static get observedAttributes(): string[];
|
|
74
76
|
private _core;
|
|
75
77
|
constructor();
|
|
@@ -87,3 +89,4 @@ export declare class TabBarComponent extends BaseComponent implements ITabBarCom
|
|
|
87
89
|
autoActivate: boolean;
|
|
88
90
|
scrollButtons: boolean;
|
|
89
91
|
}
|
|
92
|
+
export {};
|
|
@@ -13,7 +13,10 @@ import { TabBarAdapter } from './tab-bar-adapter';
|
|
|
13
13
|
import { TAB_BAR_CONSTANTS } from './tab-bar-constants';
|
|
14
14
|
import { TabBarCore } from './tab-bar-core';
|
|
15
15
|
import { tylIconKeyboardArrowLeft, tylIconKeyboardArrowRight, tylIconKeyboardArrowUp, tylIconKeyboardArrowDown } from '@tylertech/tyler-icons/standard';
|
|
16
|
-
|
|
16
|
+
import { WithElementInternals } from '../../core/mixins/internals/with-element-internals';
|
|
17
|
+
import { WithDefaultAria } from '../../core/mixins/internals/with-default-aria';
|
|
18
|
+
import { setDefaultAria } from '../../constants';
|
|
19
|
+
const template = '<template><div class=\"forge-tab-bar\" part=\"container\"><div class=\"scroll-container\" part=\"scroll-container\"><slot></slot></div></div></template>';
|
|
17
20
|
const styles = ':host{position:relative;display:block}:host([hidden]){display:none}.forge-tab-bar{--_tab-bar-justify:var(--forge-tab-bar-justify, space-between);--_tab-bar-stretch:var(--forge-tab-bar-stretch, 1);--_tab-bar-divider-color:var(--forge-tab-bar-divider-color, var(--forge-theme-outline, #e0e0e0));--_tab-bar-divider-thickness:var(--forge-tab-bar-divider-thickness, 1px)}.forge-tab-bar{position:relative;display:grid;grid-template-columns:auto 1fr auto;max-width:100%;max-height:100%;align-items:center;border-bottom:var(--_tab-bar-divider-thickness) solid var(--_tab-bar-divider-color)}.scroll-container{position:relative;display:flex;justify-content:var(--_tab-bar-justify);align-items:flex-end;box-sizing:border-box;overflow:auto;scroll-behavior:smooth;scrollbar-width:none;grid-column:2}.scroll-container::-webkit-scrollbar{display:none}::slotted(*){flex:var(--_tab-bar-stretch);align-self:stretch}::slotted([selected]){z-index:1}forge-icon-button{--forge-icon-button-shape-squared:0px}:host([vertical]) .forge-tab-bar{grid-template-columns:none;grid-template-rows:auto 1fr auto;align-items:initial;border-bottom:none;border-right:var(--_tab-bar-divider-thickness) solid var(--_tab-bar-divider-color);height:100%}:host([vertical]) .scroll-container{display:inline-flex;flex-direction:column;align-items:stretch;gap:0;grid-column:auto;grid-row:2}:host([vertical]) .scroll-button{justify-self:center}:host([inverted]:not([vertical])) .forge-tab-bar{border-bottom:none;border-top:variale(divider-thickness) solid var(--_tab-bar-divider-color)}:host([inverted][vertical]) .forge-tab-bar{border-bottom:none;border-top:var(--_tab-bar-divider-thickness) solid var(--_tab-bar-divider-color)}:host([clustered]) .forge-tab-bar{--_tab-bar-justify:var(--forge-tab-bar-justify, flex-start);--_tab-bar-stretch:var(--forge-tab-bar-stretch, 0)}:host([clustered=start]) .forge-tab-bar{--_tab-bar-justify:var(--forge-tab-bar-justify, flex-start)}:host([clustered=center]) .forge-tab-bar{--_tab-bar-justify:var(--forge-tab-bar-justify, center)}:host([clustered=end]) .forge-tab-bar{--_tab-bar-justify:var(--forge-tab-bar-justify, flex-end)}';
|
|
18
21
|
/**
|
|
19
22
|
* @tag forge-tab-bar
|
|
@@ -47,7 +50,6 @@ const styles = ':host{position:relative;display:block}:host([hidden]){display:no
|
|
|
47
50
|
* @attribute {boolean} [secondary=false] - Deprecated. Controls whether the tabs are styled as secondary tab navigation.
|
|
48
51
|
* @attribute {boolean} [auto-activate=false] - Controls whether the tabs are automatically activated when receiving focus.
|
|
49
52
|
* @attribute {boolean} [scroll-buttons=false] - Controls whether scroll buttons are displayed when the tabs overflow their container.
|
|
50
|
-
* @attribute {string} [data-aria-label] - The ARIA label to forward to the internal tablist element.
|
|
51
53
|
*
|
|
52
54
|
* @event {CustomEvent<ITabBarChangeEventData>} forge-tab-bar-change - Dispatches when the active tab changes.
|
|
53
55
|
*
|
|
@@ -59,7 +61,7 @@ const styles = ':host{position:relative;display:block}:host([hidden]){display:no
|
|
|
59
61
|
* @csspart container - The container element.
|
|
60
62
|
* @csspart scroll-container - The scroll container element.
|
|
61
63
|
*/
|
|
62
|
-
let TabBarComponent = class TabBarComponent extends BaseComponent {
|
|
64
|
+
let TabBarComponent = class TabBarComponent extends WithDefaultAria(WithElementInternals(BaseComponent)) {
|
|
63
65
|
static get observedAttributes() {
|
|
64
66
|
return Object.values(TAB_BAR_CONSTANTS.observedAttributes);
|
|
65
67
|
}
|
|
@@ -70,6 +72,7 @@ let TabBarComponent = class TabBarComponent extends BaseComponent {
|
|
|
70
72
|
this._core = new TabBarCore(new TabBarAdapter(this));
|
|
71
73
|
}
|
|
72
74
|
connectedCallback() {
|
|
75
|
+
this[setDefaultAria]({ role: 'tablist' }, { setAttribute: true });
|
|
73
76
|
this._core.initialize();
|
|
74
77
|
}
|
|
75
78
|
disconnectedCallback() {
|
package/package.json
CHANGED
package/sass/checkbox/_core.scss
CHANGED
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
@mixin checkbox {
|
|
18
18
|
position: relative;
|
|
19
19
|
flex-direction: #{token(direction)};
|
|
20
|
-
|
|
21
|
-
align-items: center;
|
|
20
|
+
align-items: #{token(align)};
|
|
22
21
|
justify-content: #{token(justify)};
|
|
23
22
|
gap: #{token(gap)};
|
|
24
23
|
|
|
@@ -39,6 +38,7 @@
|
|
|
39
38
|
justify-content: center;
|
|
40
39
|
|
|
41
40
|
display: flex;
|
|
41
|
+
flex-shrink: 0;
|
|
42
42
|
|
|
43
43
|
border-radius: #{token(state-layer-shape)};
|
|
44
44
|
inline-size: #{token(state-layer-width)};
|