@tylertech/forge 3.0.0-next.20 → 3.0.0-next.21
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 +141 -309
- package/dist/esm/accordion/index.js +1 -1
- package/dist/esm/autocomplete/index.js +1 -1
- package/dist/esm/button-area/index.js +1 -1
- package/dist/esm/chunks/{chunk.OFXSMOV6.js → chunk.5UGN5FYV.js} +2 -2
- package/dist/esm/chunks/{chunk.2N5KNNQX.js → chunk.5UZ2DEW3.js} +2 -2
- package/dist/esm/chunks/chunk.656X22EF.js +7 -0
- package/dist/esm/chunks/chunk.656X22EF.js.map +7 -0
- package/dist/esm/chunks/chunk.6JVMCBCR.js +7 -0
- package/dist/esm/chunks/{chunk.OT4AIOMN.js.map → chunk.6JVMCBCR.js.map} +3 -3
- package/dist/esm/chunks/{chunk.O56VP4OZ.js → chunk.A6BIUNPW.js} +2 -2
- package/dist/esm/chunks/{chunk.KEFJZO5K.js → chunk.BMQAVBWZ.js} +2 -2
- package/dist/esm/chunks/{chunk.KEFJZO5K.js.map → chunk.BMQAVBWZ.js.map} +1 -1
- package/dist/esm/chunks/{chunk.5S7XNYRQ.js → chunk.GL2H6QOP.js} +2 -2
- package/dist/esm/chunks/chunk.HMJODLAS.js +7 -0
- package/dist/esm/chunks/chunk.HMJODLAS.js.map +7 -0
- package/dist/esm/chunks/{chunk.ZAREP2QH.js → chunk.HYTFCFP6.js} +2 -2
- package/dist/esm/chunks/{chunk.TPNZYEC7.js → chunk.NIUX6DVF.js} +2 -2
- package/dist/esm/chunks/{chunk.VOTT5COZ.js → chunk.OSBNFFCI.js} +2 -2
- package/dist/esm/chunks/chunk.RJC42RNR.js +7 -0
- package/dist/esm/chunks/chunk.RJC42RNR.js.map +7 -0
- package/dist/esm/chunks/chunk.V7ILFIOR.js +7 -0
- package/dist/esm/chunks/chunk.V7ILFIOR.js.map +7 -0
- package/dist/esm/date-picker/index.js +1 -1
- package/dist/esm/date-range-picker/index.js +1 -1
- package/dist/esm/expansion-panel/index.js +1 -1
- package/dist/esm/field-next/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/split-view/index.js +1 -1
- package/dist/esm/split-view/split-view/index.js +1 -1
- package/dist/esm/split-view/split-view-panel/index.js +1 -1
- package/dist/esm/stepper/index.js +1 -1
- package/dist/esm/stepper/step/index.js +1 -1
- package/dist/esm/stepper/stepper/index.js +1 -1
- package/dist/esm/table/index.js +1 -1
- package/dist/esm/text-field/index.js +1 -1
- package/dist/esm/time-picker/index.js +1 -1
- package/dist/forge.css +1 -1
- package/esm/button-area/button-area-foundation.js +2 -3
- package/esm/expansion-panel/expansion-panel-adapter.d.ts +13 -20
- package/esm/expansion-panel/expansion-panel-adapter.js +22 -159
- package/esm/expansion-panel/expansion-panel-constants.d.ts +16 -22
- package/esm/expansion-panel/expansion-panel-constants.js +16 -30
- package/esm/expansion-panel/expansion-panel-foundation.d.ts +14 -37
- package/esm/expansion-panel/expansion-panel-foundation.js +50 -117
- package/esm/expansion-panel/expansion-panel.d.ts +29 -32
- package/esm/expansion-panel/expansion-panel.js +32 -32
- package/esm/field-next/field.js +1 -1
- package/esm/split-view/split-view-panel/split-view-panel.js +1 -1
- package/esm/stepper/step/step-adapter.js +2 -2
- package/esm/table/table-utils.js +5 -4
- package/package.json +1 -1
- package/styles/core/styles/tokens/expansion-panel/_tokens.scss +17 -0
- package/styles/expansion-panel/_core.scss +65 -0
- package/styles/expansion-panel/_token-utils.scss +30 -0
- package/styles/expansion-panel/expansion-panel.scss +83 -3
- package/styles/expansion-panel/index.scss +6 -0
- package/styles/field-next/_core.layout.scss +2 -6
- package/styles/field-next/_core.scss +2 -1
- package/styles/field-next/field.scss +0 -4
- package/styles/forge.scss +0 -1
- package/dist/esm/chunks/chunk.IZ63EJ32.js +0 -7
- package/dist/esm/chunks/chunk.IZ63EJ32.js.map +0 -7
- package/dist/esm/chunks/chunk.LGEZI5SZ.js +0 -7
- package/dist/esm/chunks/chunk.LGEZI5SZ.js.map +0 -7
- package/dist/esm/chunks/chunk.OT4AIOMN.js +0 -7
- package/dist/esm/chunks/chunk.SIGRWU4V.js +0 -7
- package/dist/esm/chunks/chunk.SIGRWU4V.js.map +0 -7
- package/dist/esm/chunks/chunk.USO2XVOI.js +0 -7
- package/dist/esm/chunks/chunk.USO2XVOI.js.map +0 -7
- package/dist/expansion-panel/forge-expansion-panel.css +0 -6
- package/styles/expansion-panel/_mixins.scss +0 -88
- package/styles/expansion-panel/forge-expansion-panel.scss +0 -16
- /package/dist/esm/chunks/{chunk.OFXSMOV6.js.map → chunk.5UGN5FYV.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.2N5KNNQX.js.map → chunk.5UZ2DEW3.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.O56VP4OZ.js.map → chunk.A6BIUNPW.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.5S7XNYRQ.js.map → chunk.GL2H6QOP.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.ZAREP2QH.js.map → chunk.HYTFCFP6.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.TPNZYEC7.js.map → chunk.NIUX6DVF.js.map} +0 -0
- /package/dist/esm/chunks/{chunk.VOTT5COZ.js.map → chunk.OSBNFFCI.js.map} +0 -0
|
@@ -5,36 +5,30 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const EXPANSION_PANEL_CONSTANTS: {
|
|
7
7
|
elementName: "forge-expansion-panel";
|
|
8
|
+
observedAttributes: {
|
|
9
|
+
OPEN: string;
|
|
10
|
+
ORIENTATION: string;
|
|
11
|
+
ANIMATION_TYPE: string;
|
|
12
|
+
};
|
|
13
|
+
attributes: {
|
|
14
|
+
OPENING: string;
|
|
15
|
+
OPEN: string;
|
|
16
|
+
ORIENTATION: string;
|
|
17
|
+
ANIMATION_TYPE: string;
|
|
18
|
+
};
|
|
8
19
|
classes: {
|
|
9
|
-
|
|
10
|
-
HEADER: string;
|
|
11
|
-
CONTENT: string;
|
|
20
|
+
HIDDEN: string;
|
|
12
21
|
};
|
|
13
22
|
selectors: {
|
|
14
|
-
CONTAINER: string;
|
|
15
23
|
HEADER: string;
|
|
16
24
|
CONTENT: string;
|
|
17
|
-
|
|
25
|
+
IGNORE: string;
|
|
18
26
|
OPEN_ICON: string;
|
|
19
27
|
};
|
|
20
28
|
events: {
|
|
21
29
|
TOGGLE: string;
|
|
22
|
-
|
|
23
|
-
attributes: {
|
|
24
|
-
OPEN: string;
|
|
25
|
-
ORIENTATION: string;
|
|
26
|
-
USE_ANIMATIONS: string;
|
|
27
|
-
IGNORE: string;
|
|
28
|
-
IGNORE_ALT: string;
|
|
29
|
-
};
|
|
30
|
-
numbers: {
|
|
31
|
-
COLLAPSE_ANIMATION_DURATION: number;
|
|
32
|
-
CLICK_DEBOUNCE_THRESHOLD: number;
|
|
33
|
-
};
|
|
34
|
-
strings: {
|
|
35
|
-
ORIENTATION_VERTICAL: string;
|
|
36
|
-
ORIENTATION_HORIZONTAL: string;
|
|
37
|
-
EXPANSION_VERTICAL_TRANSITION: string;
|
|
38
|
-
EXPANSION_HORIZONTAL_TRANSITION: string;
|
|
30
|
+
ANIMATION_COMPLETE: string;
|
|
39
31
|
};
|
|
40
32
|
};
|
|
33
|
+
export type ExpansionPanelOrientation = 'horizontal' | 'vertical';
|
|
34
|
+
export type ExpansionPanelAnimationType = 'default' | 'none';
|
|
@@ -6,44 +6,30 @@
|
|
|
6
6
|
import { COMPONENT_NAME_PREFIX } from '../constants';
|
|
7
7
|
import { OPEN_ICON_CONSTANTS } from '../open-icon';
|
|
8
8
|
const elementName = `${COMPONENT_NAME_PREFIX}expansion-panel`;
|
|
9
|
+
const observedAttributes = {
|
|
10
|
+
OPEN: 'open',
|
|
11
|
+
ORIENTATION: 'orientation',
|
|
12
|
+
ANIMATION_TYPE: 'animation-type'
|
|
13
|
+
};
|
|
14
|
+
const attributes = Object.assign(Object.assign({}, observedAttributes), { OPENING: 'opening' });
|
|
9
15
|
const classes = {
|
|
10
|
-
|
|
11
|
-
HEADER: 'forge-expansion-panel__header',
|
|
12
|
-
CONTENT: 'forge-expansion-panel__content'
|
|
16
|
+
HIDDEN: 'hidden'
|
|
13
17
|
};
|
|
14
18
|
const selectors = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
OPEN_ICON: `[slot=header] ${OPEN_ICON_CONSTANTS.elementName}`
|
|
19
|
+
HEADER: '.header',
|
|
20
|
+
CONTENT: '.content',
|
|
21
|
+
IGNORE: ':is([data-forge-ignore],[forge-ignore])',
|
|
22
|
+
OPEN_ICON: `:is([slot=header] ${OPEN_ICON_CONSTANTS.elementName}, ${OPEN_ICON_CONSTANTS.elementName}[slot^=header])`
|
|
20
23
|
};
|
|
21
24
|
const events = {
|
|
22
|
-
TOGGLE: `${elementName}-toggle
|
|
23
|
-
}
|
|
24
|
-
const attributes = {
|
|
25
|
-
OPEN: 'open',
|
|
26
|
-
ORIENTATION: 'orientation',
|
|
27
|
-
USE_ANIMATIONS: 'use-animations',
|
|
28
|
-
IGNORE: 'data-forge-ignore',
|
|
29
|
-
IGNORE_ALT: 'forge-ignore'
|
|
30
|
-
};
|
|
31
|
-
const numbers = {
|
|
32
|
-
COLLAPSE_ANIMATION_DURATION: 400,
|
|
33
|
-
CLICK_DEBOUNCE_THRESHOLD: 200
|
|
34
|
-
};
|
|
35
|
-
const strings = {
|
|
36
|
-
ORIENTATION_VERTICAL: 'vertical',
|
|
37
|
-
ORIENTATION_HORIZONTAL: 'horizontal',
|
|
38
|
-
EXPANSION_VERTICAL_TRANSITION: `height ${numbers.COLLAPSE_ANIMATION_DURATION}ms cubic-bezier(0.4, 0, 0.2, 1), opacity ${numbers.COLLAPSE_ANIMATION_DURATION}ms ease-in-out`,
|
|
39
|
-
EXPANSION_HORIZONTAL_TRANSITION: `width ${numbers.COLLAPSE_ANIMATION_DURATION}ms cubic-bezier(0.4, 0, 0.2, 1), opacity ${numbers.COLLAPSE_ANIMATION_DURATION}ms ease-in-out`
|
|
25
|
+
TOGGLE: `${elementName}-toggle`,
|
|
26
|
+
ANIMATION_COMPLETE: `${elementName}-animation-complete`
|
|
40
27
|
};
|
|
41
28
|
export const EXPANSION_PANEL_CONSTANTS = {
|
|
42
29
|
elementName,
|
|
30
|
+
observedAttributes,
|
|
31
|
+
attributes,
|
|
43
32
|
classes,
|
|
44
33
|
selectors,
|
|
45
|
-
events
|
|
46
|
-
attributes,
|
|
47
|
-
numbers,
|
|
48
|
-
strings
|
|
34
|
+
events
|
|
49
35
|
};
|
|
@@ -5,55 +5,32 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ICustomElementFoundation } from '@tylertech/forge-core';
|
|
7
7
|
import { IExpansionPanelAdapter } from './expansion-panel-adapter';
|
|
8
|
+
import { ExpansionPanelAnimationType, ExpansionPanelOrientation } from './expansion-panel-constants';
|
|
8
9
|
export interface IExpansionPanelFoundation extends ICustomElementFoundation {
|
|
9
10
|
open: boolean;
|
|
10
|
-
orientation:
|
|
11
|
-
|
|
12
|
-
openCallback: () => void | Promise<void>;
|
|
13
|
-
closeCallback: () => void | Promise<void>;
|
|
14
|
-
setOpenImmediate(open: boolean): void;
|
|
11
|
+
orientation: ExpansionPanelOrientation;
|
|
12
|
+
animationType: ExpansionPanelAnimationType;
|
|
15
13
|
}
|
|
16
14
|
export declare class ExpansionPanelFoundation implements IExpansionPanelFoundation {
|
|
17
15
|
private _adapter;
|
|
18
16
|
private _open;
|
|
19
|
-
private _useAnimations;
|
|
20
|
-
private _openCallback;
|
|
21
|
-
private _closeCallback;
|
|
22
17
|
private _orientation;
|
|
18
|
+
private _animationType;
|
|
23
19
|
private _clickListener;
|
|
24
20
|
private _keydownListener;
|
|
25
|
-
private
|
|
26
|
-
private _isInitialized;
|
|
21
|
+
private _animationCompleteListener;
|
|
27
22
|
constructor(_adapter: IExpansionPanelAdapter);
|
|
28
23
|
initialize(): void;
|
|
29
|
-
connect(): void;
|
|
30
|
-
disconnect(): void;
|
|
31
|
-
setOpenImmediate(open: boolean): void;
|
|
32
|
-
private _applyOpen;
|
|
33
|
-
/** Controls the open state of the panel. */
|
|
34
|
-
get open(): boolean;
|
|
35
|
-
set open(value: boolean);
|
|
36
|
-
get openCallback(): () => void | Promise<void>;
|
|
37
|
-
set openCallback(callback: () => void | Promise<void>);
|
|
38
|
-
get closeCallback(): () => void | Promise<void>;
|
|
39
|
-
set closeCallback(callback: () => void | Promise<void>);
|
|
40
|
-
get orientation(): string;
|
|
41
|
-
set orientation(value: string);
|
|
42
|
-
get useAnimations(): boolean;
|
|
43
|
-
set useAnimations(value: boolean);
|
|
44
|
-
/**
|
|
45
|
-
* Handles click events on the header element.
|
|
46
|
-
* @param {MouseEvent} evt The click event.
|
|
47
|
-
*/
|
|
48
24
|
private _onClick;
|
|
49
|
-
/**
|
|
50
|
-
* Handles keydown events on the header.
|
|
51
|
-
* @param {KeyboardEvent} evt The keydown event
|
|
52
|
-
*/
|
|
53
25
|
private _onKeydown;
|
|
54
|
-
private
|
|
26
|
+
private _onAnimationComplete;
|
|
27
|
+
private _togglePanel;
|
|
28
|
+
private _dispatchToggleEvent;
|
|
55
29
|
private _toggle;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
get open(): boolean;
|
|
31
|
+
set open(value: boolean);
|
|
32
|
+
get orientation(): ExpansionPanelOrientation;
|
|
33
|
+
set orientation(value: ExpansionPanelOrientation);
|
|
34
|
+
get animationType(): ExpansionPanelAnimationType;
|
|
35
|
+
set animationType(value: ExpansionPanelAnimationType);
|
|
59
36
|
}
|
|
@@ -3,152 +3,85 @@
|
|
|
3
3
|
* Copyright 2023 Tyler Technologies, Inc.
|
|
4
4
|
* License: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { debounce, getEventPath } from '@tylertech/forge-core';
|
|
7
6
|
import { EXPANSION_PANEL_CONSTANTS } from './expansion-panel-constants';
|
|
8
7
|
export class ExpansionPanelFoundation {
|
|
9
8
|
constructor(_adapter) {
|
|
10
9
|
this._adapter = _adapter;
|
|
11
10
|
this._open = false;
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this._headerSlotChangeListener = (evt) => this._onHeaderSlotChanged(evt);
|
|
11
|
+
this._orientation = 'vertical';
|
|
12
|
+
this._animationType = 'default';
|
|
13
|
+
this._clickListener = this._onClick.bind(this);
|
|
14
|
+
this._keydownListener = this._onKeydown.bind(this);
|
|
15
|
+
this._animationCompleteListener = this._onAnimationComplete.bind(this);
|
|
18
16
|
}
|
|
19
17
|
initialize() {
|
|
20
|
-
this.
|
|
21
|
-
this._adapter.
|
|
22
|
-
this.
|
|
18
|
+
this._adapter.addHeaderListener('click', this._clickListener);
|
|
19
|
+
this._adapter.addHeaderListener('keydown', this._keydownListener);
|
|
20
|
+
this._adapter.setAnimationCompleteListener(this._animationCompleteListener);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
disconnect() {
|
|
30
|
-
this._adapter.deregisterHeaderSlotListener(this._headerSlotChangeListener);
|
|
31
|
-
this._adapter.deregisterClickListener(this._clickListener);
|
|
32
|
-
this._adapter.deregisterKeydownListener(this._keydownListener);
|
|
33
|
-
}
|
|
34
|
-
setOpenImmediate(open) {
|
|
35
|
-
if (open) {
|
|
36
|
-
this._openPanel(false);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this._closePanel(false);
|
|
22
|
+
_onClick(evt) {
|
|
23
|
+
const fromIgnoredEl = evt.composedPath().find((el) => el.nodeType === Node.ELEMENT_NODE && el.matches(EXPANSION_PANEL_CONSTANTS.selectors.IGNORE));
|
|
24
|
+
if (fromIgnoredEl) {
|
|
25
|
+
return;
|
|
40
26
|
}
|
|
27
|
+
evt.stopPropagation();
|
|
28
|
+
this._toggle();
|
|
29
|
+
this._dispatchToggleEvent();
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
_onKeydown(evt) {
|
|
32
|
+
if (evt.key === ' ' || evt.key === 'Enter') {
|
|
33
|
+
evt.stopPropagation();
|
|
34
|
+
evt.preventDefault();
|
|
35
|
+
this._toggle();
|
|
36
|
+
this._dispatchToggleEvent();
|
|
46
37
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this._open = value;
|
|
52
|
-
this._openPanel(this._useAnimations);
|
|
53
|
-
})
|
|
54
|
-
.catch(() => { });
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this._open = value;
|
|
58
|
-
this._openPanel(this._useAnimations);
|
|
59
|
-
}
|
|
38
|
+
}
|
|
39
|
+
_onAnimationComplete() {
|
|
40
|
+
if (!this._open) {
|
|
41
|
+
this._adapter.setContentVisibility(false);
|
|
60
42
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.catch(() => { });
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this._open = value;
|
|
72
|
-
this._closePanel(this._useAnimations);
|
|
73
|
-
}
|
|
43
|
+
this._adapter.dispatchHostEvent(new CustomEvent(EXPANSION_PANEL_CONSTANTS.events.ANIMATION_COMPLETE, { detail: this._open }));
|
|
44
|
+
}
|
|
45
|
+
_togglePanel() {
|
|
46
|
+
this._adapter.toggleHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.OPEN, this._open);
|
|
47
|
+
this._adapter.tryToggleOpenIcon(this._open);
|
|
48
|
+
if (this._open) {
|
|
49
|
+
this._adapter.setContentVisibility(true);
|
|
74
50
|
}
|
|
75
51
|
}
|
|
76
|
-
|
|
52
|
+
_dispatchToggleEvent() {
|
|
53
|
+
const evt = new CustomEvent(EXPANSION_PANEL_CONSTANTS.events.TOGGLE, { detail: this._open, bubbles: true, composed: true });
|
|
54
|
+
this._adapter.dispatchHostEvent(evt);
|
|
55
|
+
}
|
|
56
|
+
_toggle() {
|
|
57
|
+
this.open = !this.open;
|
|
58
|
+
}
|
|
77
59
|
get open() {
|
|
78
60
|
return this._open;
|
|
79
61
|
}
|
|
80
62
|
set open(value) {
|
|
81
63
|
value = Boolean(value);
|
|
82
64
|
if (this._open !== value) {
|
|
83
|
-
this.
|
|
65
|
+
this._open = value;
|
|
66
|
+
this._togglePanel();
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
|
-
get openCallback() {
|
|
87
|
-
return this._openCallback;
|
|
88
|
-
}
|
|
89
|
-
set openCallback(callback) {
|
|
90
|
-
this._openCallback = callback;
|
|
91
|
-
}
|
|
92
|
-
get closeCallback() {
|
|
93
|
-
return this._closeCallback;
|
|
94
|
-
}
|
|
95
|
-
set closeCallback(callback) {
|
|
96
|
-
this._closeCallback = callback;
|
|
97
|
-
}
|
|
98
69
|
get orientation() {
|
|
99
70
|
return this._orientation;
|
|
100
71
|
}
|
|
101
72
|
set orientation(value) {
|
|
102
|
-
this._orientation
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return this._useAnimations;
|
|
106
|
-
}
|
|
107
|
-
set useAnimations(value) {
|
|
108
|
-
if (this._useAnimations !== !!value) {
|
|
109
|
-
this._useAnimations = !!value;
|
|
110
|
-
this._adapter.setHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.USE_ANIMATIONS, `${this._useAnimations}`);
|
|
73
|
+
if (this._orientation !== value) {
|
|
74
|
+
this._orientation = value;
|
|
75
|
+
this._adapter.setHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.ORIENTATION, this._orientation);
|
|
111
76
|
}
|
|
112
77
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @param {MouseEvent} evt The click event.
|
|
116
|
-
*/
|
|
117
|
-
_onClick(evt) {
|
|
118
|
-
if (getEventPath(evt).find(p => p.nodeType === 1 && (p.hasAttribute(EXPANSION_PANEL_CONSTANTS.attributes.IGNORE) || p.hasAttribute(EXPANSION_PANEL_CONSTANTS.attributes.IGNORE_ALT)))) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
evt.stopPropagation();
|
|
122
|
-
this._toggle();
|
|
123
|
-
this._emitEvent();
|
|
78
|
+
get animationType() {
|
|
79
|
+
return this._animationType;
|
|
124
80
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
_onKeydown(evt) {
|
|
130
|
-
if (evt.key === ' ' || evt.key === 'Enter') {
|
|
131
|
-
evt.stopPropagation();
|
|
132
|
-
evt.preventDefault();
|
|
133
|
-
this._toggle();
|
|
134
|
-
this._emitEvent();
|
|
81
|
+
set animationType(value) {
|
|
82
|
+
if (this._animationType !== value) {
|
|
83
|
+
this._animationType = value;
|
|
84
|
+
this._adapter.setHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.ANIMATION_TYPE, this._animationType);
|
|
135
85
|
}
|
|
136
86
|
}
|
|
137
|
-
_emitEvent() {
|
|
138
|
-
this._adapter.emitHostEvent(EXPANSION_PANEL_CONSTANTS.events.TOGGLE, this._open);
|
|
139
|
-
}
|
|
140
|
-
_toggle() {
|
|
141
|
-
this.open = !this.open;
|
|
142
|
-
}
|
|
143
|
-
_openPanel(animate) {
|
|
144
|
-
this._adapter.setHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.OPEN, '');
|
|
145
|
-
this._adapter.setOpenState(true, this._orientation, animate);
|
|
146
|
-
}
|
|
147
|
-
_closePanel(animate) {
|
|
148
|
-
this._adapter.removeHostAttribute(EXPANSION_PANEL_CONSTANTS.attributes.OPEN);
|
|
149
|
-
this._adapter.setOpenState(false, this._orientation, animate);
|
|
150
|
-
}
|
|
151
|
-
_onHeaderSlotChanged(evt) {
|
|
152
|
-
this._adapter.setHeaderVisibility(!!evt.target.assignedNodes().length);
|
|
153
|
-
}
|
|
154
87
|
}
|
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
* License: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { BaseComponent, IBaseComponent } from '../core/base/base-component';
|
|
7
|
+
import { ExpansionPanelAnimationType, ExpansionPanelOrientation } from './expansion-panel-constants';
|
|
7
8
|
export interface IExpansionPanelComponent extends IBaseComponent {
|
|
8
9
|
open: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
closeCallback: () => void | Promise<void>;
|
|
12
|
-
orientation: string;
|
|
10
|
+
orientation: ExpansionPanelOrientation;
|
|
11
|
+
animationType: ExpansionPanelAnimationType;
|
|
13
12
|
toggle(): void;
|
|
14
|
-
setOpenImmediate(open: boolean): void;
|
|
15
13
|
}
|
|
16
14
|
declare global {
|
|
17
15
|
interface HTMLElementTagNameMap {
|
|
@@ -19,44 +17,43 @@ declare global {
|
|
|
19
17
|
}
|
|
20
18
|
interface HTMLElementEventMap {
|
|
21
19
|
'forge-expansion-panel-toggle': CustomEvent<boolean>;
|
|
20
|
+
'forge-expansion-panel-animation-complete': CustomEvent<boolean>;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
|
-
* A web component that encapsulates the functionality of expanding/collapsing content when clicked.
|
|
26
|
-
*
|
|
27
24
|
* @tag forge-expansion-panel
|
|
25
|
+
*
|
|
26
|
+
* @summary Expansion panels provide progressive disclosure of content.
|
|
27
|
+
*
|
|
28
|
+
* @property {boolean} open - Whether the panel is open or closed.
|
|
29
|
+
* @property {ExpansionPanelOrientation} orientation - The orientation of the panel.
|
|
30
|
+
* @property {ExpansionPanelAnimationType} animationType - The type of animation to use when opening/closing the panel.
|
|
31
|
+
*
|
|
32
|
+
* @attribute {boolean} open - Whether the panel is open or closed.
|
|
33
|
+
* @attribute {ExpansionPanelOrientation} orientation - The orientation of the panel.
|
|
34
|
+
* @attribute {ExpansionPanelAnimationType} animation-type - The type of animation to use when opening/closing the panel.
|
|
35
|
+
*
|
|
36
|
+
* @fires forge-expansion-panel-toggle - Event fired when the panel is toggled open or closed.
|
|
37
|
+
* @fires forge-expansion-panel-animation-complete - Event fired when the panel has finished animating when toggling.
|
|
38
|
+
*
|
|
39
|
+
* @cssproperty --forge-expansion-animation-duration - The duration of the open/close animation.
|
|
40
|
+
* @cssproperty --forge-expansion-animation-easing - The easing function of the open/close animation.
|
|
41
|
+
*
|
|
42
|
+
* @csspart root - The root element of the panel.
|
|
43
|
+
* @csspart header - The header of the panel.
|
|
44
|
+
* @csspart content - The content of the panel.
|
|
45
|
+
*
|
|
46
|
+
* @slot - The content of the panel.
|
|
47
|
+
* @slot header - The header of the panel.
|
|
28
48
|
*/
|
|
29
49
|
export declare class ExpansionPanelComponent extends BaseComponent implements IExpansionPanelComponent {
|
|
30
50
|
static get observedAttributes(): string[];
|
|
31
51
|
private _foundation;
|
|
32
52
|
constructor();
|
|
33
|
-
initializedCallback(): void;
|
|
34
53
|
connectedCallback(): void;
|
|
35
54
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
36
|
-
disconnectedCallback(): void;
|
|
37
|
-
/** Controls the open state of the panel. */
|
|
38
55
|
open: boolean;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* The function must return a promise which can be resolved to
|
|
42
|
-
* open the panel or rejected which cancels the panel open.
|
|
43
|
-
*/
|
|
44
|
-
openCallback: () => void | Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Sets the function to call when the panel wants to close.
|
|
47
|
-
* The function must return a promise which can be resolved to
|
|
48
|
-
* close the panel or rejected which cancels the panel close.
|
|
49
|
-
*/
|
|
50
|
-
closeCallback: () => void | Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Sets the orientation of the panel expansion.
|
|
53
|
-
* Valid values are 'vertical' (default) or 'horizontal'.
|
|
54
|
-
*/
|
|
55
|
-
orientation: string;
|
|
56
|
-
/** Gets/sets if animations are used in the expand/collapse transition. */
|
|
57
|
-
useAnimations: boolean;
|
|
58
|
-
/** Toggles the collapsed state. */
|
|
56
|
+
orientation: ExpansionPanelOrientation;
|
|
57
|
+
animationType: ExpansionPanelAnimationType;
|
|
59
58
|
toggle(): void;
|
|
60
|
-
/** Forces the expansion panel to expand/collapse without transition animations. */
|
|
61
|
-
setOpenImmediate(open: boolean): void;
|
|
62
59
|
}
|
|
@@ -9,72 +9,72 @@ import { BaseComponent } from '../core/base/base-component';
|
|
|
9
9
|
import { ExpansionPanelAdapter } from './expansion-panel-adapter';
|
|
10
10
|
import { EXPANSION_PANEL_CONSTANTS } from './expansion-panel-constants';
|
|
11
11
|
import { ExpansionPanelFoundation } from './expansion-panel-foundation';
|
|
12
|
-
const template = '<template><div class=\"forge-expansion-panel\" part=\"root\"><div class=\"
|
|
13
|
-
const styles = '
|
|
12
|
+
const template = '<template><div class=\"forge-expansion-panel\" part=\"root\"><div class=\"header\" part=\"header\"><slot name=\"header\"></slot></div><div class=\"content hidden\" part=\"content\"><div class=\"inner\"><slot></slot></div></div></div></template>';
|
|
13
|
+
const styles = ':host{display:block}:host([hidden]){display:none}.forge-expansion-panel{--_expansion-panel-animation-duration:var(--forge-expansion-panel-animation-duration, var(--forge-animation-duration-medium4, 400ms));--_expansion-panel-animation-easing:var(--forge-expansion-panel-animation-easing, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)))}.header{outline:0;-webkit-tap-highlight-color:transparent;cursor:pointer}.content{display:grid;grid-template-rows:0fr;-webkit-transition-property:opacity,grid-template-rows;transition-property:opacity,grid-template-rows;transition-property:opacity,grid-template-rows,-ms-grid-rows;-webkit-transition-duration:var(--_expansion-panel-animation-duration);transition-duration:var(--_expansion-panel-animation-duration);-webkit-transition-timing-function:var(--_expansion-panel-animation-easing);transition-timing-function:var(--_expansion-panel-animation-easing);min-height:0;overflow:hidden;opacity:0}.content .inner{display:grid;grid-template-rows:1fr;overflow:hidden}.hidden{visibility:hidden}@media (prefers-reduced-motion:reduce){.content{-webkit-transition:none;transition:none}}:host([open]) .content{opacity:1}:host([open]:is(:not([orientation]),[orientation=vertical])) .content{grid-template-rows:1fr}:host([open][orientation=horizontal]) .content{grid-template-columns:1fr}:host([orientation=horizontal]) .forge-expansion-panel{display:grid;grid-template-columns:auto 1fr}:host([orientation=horizontal]) .content{-webkit-transition-property:opacity,grid-template-columns;transition-property:opacity,grid-template-columns;transition-property:opacity,grid-template-columns,-ms-grid-columns;grid-template-rows:none;grid-template-columns:0fr}:host([animation-type=none]) .content{-webkit-transition:none;transition:none}';
|
|
14
14
|
/**
|
|
15
|
-
* A web component that encapsulates the functionality of expanding/collapsing content when clicked.
|
|
16
|
-
*
|
|
17
15
|
* @tag forge-expansion-panel
|
|
16
|
+
*
|
|
17
|
+
* @summary Expansion panels provide progressive disclosure of content.
|
|
18
|
+
*
|
|
19
|
+
* @property {boolean} open - Whether the panel is open or closed.
|
|
20
|
+
* @property {ExpansionPanelOrientation} orientation - The orientation of the panel.
|
|
21
|
+
* @property {ExpansionPanelAnimationType} animationType - The type of animation to use when opening/closing the panel.
|
|
22
|
+
*
|
|
23
|
+
* @attribute {boolean} open - Whether the panel is open or closed.
|
|
24
|
+
* @attribute {ExpansionPanelOrientation} orientation - The orientation of the panel.
|
|
25
|
+
* @attribute {ExpansionPanelAnimationType} animation-type - The type of animation to use when opening/closing the panel.
|
|
26
|
+
*
|
|
27
|
+
* @fires forge-expansion-panel-toggle - Event fired when the panel is toggled open or closed.
|
|
28
|
+
* @fires forge-expansion-panel-animation-complete - Event fired when the panel has finished animating when toggling.
|
|
29
|
+
*
|
|
30
|
+
* @cssproperty --forge-expansion-animation-duration - The duration of the open/close animation.
|
|
31
|
+
* @cssproperty --forge-expansion-animation-easing - The easing function of the open/close animation.
|
|
32
|
+
*
|
|
33
|
+
* @csspart root - The root element of the panel.
|
|
34
|
+
* @csspart header - The header of the panel.
|
|
35
|
+
* @csspart content - The content of the panel.
|
|
36
|
+
*
|
|
37
|
+
* @slot - The content of the panel.
|
|
38
|
+
* @slot header - The header of the panel.
|
|
18
39
|
*/
|
|
19
40
|
let ExpansionPanelComponent = class ExpansionPanelComponent extends BaseComponent {
|
|
20
41
|
static get observedAttributes() {
|
|
21
|
-
return
|
|
22
|
-
EXPANSION_PANEL_CONSTANTS.attributes.OPEN,
|
|
23
|
-
EXPANSION_PANEL_CONSTANTS.attributes.ORIENTATION,
|
|
24
|
-
EXPANSION_PANEL_CONSTANTS.attributes.USE_ANIMATIONS
|
|
25
|
-
];
|
|
42
|
+
return Object.values(EXPANSION_PANEL_CONSTANTS.observedAttributes);
|
|
26
43
|
}
|
|
27
44
|
constructor() {
|
|
28
45
|
super();
|
|
29
46
|
attachShadowTemplate(this, template, styles);
|
|
30
47
|
this._foundation = new ExpansionPanelFoundation(new ExpansionPanelAdapter(this));
|
|
31
48
|
}
|
|
32
|
-
initializedCallback() {
|
|
33
|
-
this._foundation.initialize();
|
|
34
|
-
}
|
|
35
49
|
connectedCallback() {
|
|
36
|
-
this._foundation.
|
|
50
|
+
this._foundation.initialize();
|
|
37
51
|
}
|
|
38
52
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
39
53
|
switch (name) {
|
|
40
|
-
case EXPANSION_PANEL_CONSTANTS.
|
|
54
|
+
case EXPANSION_PANEL_CONSTANTS.observedAttributes.OPEN:
|
|
41
55
|
this.open = coerceBoolean(newValue);
|
|
42
56
|
break;
|
|
43
|
-
case EXPANSION_PANEL_CONSTANTS.
|
|
57
|
+
case EXPANSION_PANEL_CONSTANTS.observedAttributes.ORIENTATION:
|
|
44
58
|
this.orientation = newValue;
|
|
45
59
|
break;
|
|
46
|
-
case EXPANSION_PANEL_CONSTANTS.
|
|
47
|
-
this.
|
|
60
|
+
case EXPANSION_PANEL_CONSTANTS.observedAttributes.ANIMATION_TYPE:
|
|
61
|
+
this.animationType = newValue;
|
|
48
62
|
break;
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
|
-
disconnectedCallback() {
|
|
52
|
-
this._foundation.disconnect();
|
|
53
|
-
}
|
|
54
|
-
/** Toggles the collapsed state. */
|
|
55
65
|
toggle() {
|
|
56
66
|
this.open = !this.open;
|
|
57
67
|
}
|
|
58
|
-
/** Forces the expansion panel to expand/collapse without transition animations. */
|
|
59
|
-
setOpenImmediate(open) {
|
|
60
|
-
this._foundation.setOpenImmediate(open);
|
|
61
|
-
}
|
|
62
68
|
};
|
|
63
69
|
__decorate([
|
|
64
70
|
FoundationProperty()
|
|
65
71
|
], ExpansionPanelComponent.prototype, "open", void 0);
|
|
66
|
-
__decorate([
|
|
67
|
-
FoundationProperty()
|
|
68
|
-
], ExpansionPanelComponent.prototype, "openCallback", void 0);
|
|
69
|
-
__decorate([
|
|
70
|
-
FoundationProperty()
|
|
71
|
-
], ExpansionPanelComponent.prototype, "closeCallback", void 0);
|
|
72
72
|
__decorate([
|
|
73
73
|
FoundationProperty()
|
|
74
74
|
], ExpansionPanelComponent.prototype, "orientation", void 0);
|
|
75
75
|
__decorate([
|
|
76
76
|
FoundationProperty()
|
|
77
|
-
], ExpansionPanelComponent.prototype, "
|
|
77
|
+
], ExpansionPanelComponent.prototype, "animationType", void 0);
|
|
78
78
|
ExpansionPanelComponent = __decorate([
|
|
79
79
|
CustomElement({
|
|
80
80
|
name: EXPANSION_PANEL_CONSTANTS.elementName
|