@govtechsg/sgds-web-component 0.0.7 → 0.0.10
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/.github/workflows/publish-latest.yml +22 -0
- package/.github/workflows/publish-pr.yml +28 -0
- package/.husky/commit-msg +4 -0
- package/.husky/prepare-commit-msg +8 -0
- package/.storybook/main.js +16 -0
- package/.storybook/preview-head.html +11 -0
- package/.storybook/preview.js +9 -0
- package/.vscode/settings.json +7 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +20 -0
- package/amplify.yml +22 -0
- package/commitlint.config.js +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/button-element.scss.html +112 -0
- package/coverage/lcov-report/button-element.ts.html +145 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +32 -0
- package/index.html +430 -0
- package/{Button → lib/Button}/index.d.ts +0 -0
- package/{Button → lib/Button}/index.js +304 -39
- package/lib/Button/index.js.map +1 -0
- package/{Button → lib/Button}/package.json +0 -0
- package/lib/Button/sgds-button.d.ts +48 -0
- package/lib/Card/index.d.ts +1 -0
- package/lib/Card/index.js +6150 -0
- package/lib/Card/index.js.map +1 -0
- package/lib/Card/package.json +7 -0
- package/lib/Card/sgds-action-card.d.ts +20 -0
- package/lib/Checkbox/index.d.ts +1 -0
- package/lib/Checkbox/index.js +6366 -0
- package/lib/Checkbox/index.js.map +1 -0
- package/lib/Checkbox/package.json +7 -0
- package/lib/Checkbox/sgds-checkbox.d.ts +36 -0
- package/lib/Dropdown/index.d.ts +3 -0
- package/{Mainnav → lib/Dropdown}/index.js +2786 -9258
- package/lib/Dropdown/index.js.map +1 -0
- package/lib/Dropdown/package.json +7 -0
- package/lib/Dropdown/sgds-dropdown-item.d.ts +7 -0
- package/lib/Dropdown/sgds-dropdown.d.ts +7 -0
- package/{Footer → lib/Footer}/index.d.ts +0 -0
- package/{Footer → lib/Footer}/index.js +111 -95
- package/lib/Footer/index.js.map +1 -0
- package/{Footer → lib/Footer}/package.json +0 -0
- package/{Footer → lib/Footer}/sgds-footer.d.ts +2 -2
- package/lib/Input/index.d.ts +1 -0
- package/lib/Input/index.js +6656 -0
- package/lib/Input/index.js.map +1 -0
- package/lib/Input/package.json +7 -0
- package/lib/Input/sgds-input.d.ts +42 -0
- package/{Mainnav → lib/Mainnav}/index.d.ts +1 -0
- package/{index.js → lib/Mainnav/index.js} +3876 -23415
- package/lib/Mainnav/index.js.map +1 -0
- package/{Mainnav → lib/Mainnav}/package.json +0 -0
- package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +5 -0
- package/lib/Mainnav/sgds-mainnav-item.d.ts +4 -0
- package/{Mainnav → lib/Mainnav}/sgds-mainnav.d.ts +3 -2
- package/{Masthead → lib/Masthead}/index.d.ts +0 -0
- package/{Masthead → lib/Masthead}/index.js +140 -114
- package/lib/Masthead/index.js.map +1 -0
- package/{Masthead → lib/Masthead}/package.json +0 -0
- package/{Masthead → lib/Masthead}/sgds-masthead.d.ts +1 -1
- package/lib/Modal/index.d.ts +1 -0
- package/lib/Modal/index.js +6432 -0
- package/lib/Modal/index.js.map +1 -0
- package/lib/Modal/package.json +7 -0
- package/lib/Modal/sgds-modal.d.ts +28 -0
- package/lib/QuantityToggle/index.d.ts +1 -0
- package/lib/QuantityToggle/index.js +7049 -0
- package/lib/QuantityToggle/index.js.map +1 -0
- package/lib/QuantityToggle/package.json +7 -0
- package/lib/QuantityToggle/sgds-quantitytoggle.d.ts +30 -0
- package/lib/Radio/index.d.ts +2 -0
- package/lib/Radio/index.js +12607 -0
- package/lib/Radio/index.js.map +1 -0
- package/lib/Radio/package.json +7 -0
- package/lib/Radio/sgds-radio.d.ts +31 -0
- package/lib/Radio/sgds-radiogroup.d.ts +41 -0
- package/{Sidenav → lib/Sidenav}/index.d.ts +0 -0
- package/{Sidenav → lib/Sidenav}/index.js +2266 -2171
- package/lib/Sidenav/index.js.map +1 -0
- package/{Sidenav → lib/Sidenav}/package.json +0 -0
- package/{Sidenav → lib/Sidenav}/sgds-sidenav-item.d.ts +2 -1
- package/lib/Sidenav/sgds-sidenav-link.d.ts +4 -0
- package/{Sidenav → lib/Sidenav}/sgds-sidenav.d.ts +1 -1
- package/lib/Tab/index.d.ts +3 -0
- package/lib/Tab/index.js +13557 -0
- package/lib/Tab/index.js.map +1 -0
- package/lib/Tab/package.json +7 -0
- package/lib/Tab/sgds-tab.d.ts +26 -0
- package/lib/Tab/sgds-tabgroup.d.ts +47 -0
- package/lib/Tab/sgds-tabpanel.d.ts +25 -0
- package/lib/Textarea/index.d.ts +1 -0
- package/lib/Textarea/index.js +6696 -0
- package/lib/Textarea/index.js.map +1 -0
- package/lib/Textarea/package.json +7 -0
- package/lib/Textarea/sgds-textarea.d.ts +53 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +134580 -0
- package/lib/index.js.map +1 -0
- package/lib/umd/index.js +134587 -0
- package/lib/umd/index.js.map +1 -0
- package/lib/utils/animate.d.ts +10 -0
- package/lib/utils/animation-registry.d.ts +18 -0
- package/{utils → lib/utils}/breakpoints.d.ts +0 -0
- package/lib/utils/card-element.d.ts +11 -0
- package/lib/utils/defaultvalue.d.ts +2 -0
- package/lib/utils/dropdown-element.d.ts +37 -0
- package/lib/utils/event.d.ts +2 -0
- package/lib/utils/form.d.ts +38 -0
- package/{utils → lib/utils}/generateId.d.ts +0 -0
- package/lib/utils/link-element.d.ts +7 -0
- package/lib/utils/mergeDeep.d.ts +2 -0
- package/lib/utils/modal.d.ts +12 -0
- package/lib/utils/object.d.ts +2 -0
- package/lib/utils/offset.d.ts +4 -0
- package/lib/utils/scroll.d.ts +13 -0
- package/{utils → lib/utils}/sgds-element.d.ts +0 -0
- package/lib/utils/slot.d.ts +22 -0
- package/lib/utils/tabbable.d.ts +8 -0
- package/lib/utils/watch.d.ts +14 -0
- package/mocks/dropdown.d.ts +4 -0
- package/mocks/dropdown.ts +27 -0
- package/mocks/link.d.ts +3 -0
- package/mocks/link.ts +6 -0
- package/package.json +65 -10
- package/rollup.config.js +73 -0
- package/rollup.test.config.js +42 -0
- package/scripts/buildUtils.js +30 -0
- package/scripts/frankBuild.js +49 -0
- package/src/Button/index.ts +1 -0
- package/src/Button/sgds-button.scss +28 -0
- package/src/Button/sgds-button.ts +153 -0
- package/src/Card/index.ts +1 -0
- package/src/Card/sgds-action-card.scss +27 -0
- package/src/Card/sgds-action-card.ts +115 -0
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/sgds-checkbox.scss +4 -0
- package/src/Checkbox/sgds-checkbox.ts +149 -0
- package/src/Dropdown/index.ts +3 -0
- package/src/Dropdown/sgds-dropdown-item.ts +39 -0
- package/src/Dropdown/sgds-dropdown.scss +5 -0
- package/src/Dropdown/sgds-dropdown.ts +54 -0
- package/src/Footer/index.ts +3 -0
- package/src/Footer/sgds-footer.scss +5 -0
- package/src/Footer/sgds-footer.ts +121 -0
- package/src/Input/index.ts +1 -0
- package/src/Input/sgds-input.scss +20 -0
- package/src/Input/sgds-input.ts +178 -0
- package/src/Mainnav/index.ts +4 -0
- package/src/Mainnav/sgds-mainnav-dropdown.scss +13 -0
- package/src/Mainnav/sgds-mainnav-dropdown.ts +45 -0
- package/src/Mainnav/sgds-mainnav-item.scss +24 -0
- package/src/Mainnav/sgds-mainnav-item.ts +8 -0
- package/src/Mainnav/sgds-mainnav.scss +39 -0
- package/src/Mainnav/sgds-mainnav.ts +183 -0
- package/src/Masthead/index.ts +1 -0
- package/src/Masthead/sgds-masthead.scss +217 -0
- package/src/Masthead/sgds-masthead.ts +189 -0
- package/src/Modal/index.ts +1 -0
- package/src/Modal/sgds-modal.scss +128 -0
- package/src/Modal/sgds-modal.ts +309 -0
- package/src/QuantityToggle/index.ts +1 -0
- package/src/QuantityToggle/sgds-quantitytoggle.scss +10 -0
- package/src/QuantityToggle/sgds-quantitytoggle.ts +130 -0
- package/src/Radio/index.ts +2 -0
- package/src/Radio/sgds-radio.scss +5 -0
- package/src/Radio/sgds-radio.ts +120 -0
- package/src/Radio/sgds-radiogroup.scss +22 -0
- package/src/Radio/sgds-radiogroup.ts +221 -0
- package/src/Sidenav/index.ts +4 -0
- package/src/Sidenav/sgds-sidenav-item.scss +73 -0
- package/src/Sidenav/sgds-sidenav-item.ts +145 -0
- package/src/Sidenav/sgds-sidenav-link.scss +25 -0
- package/src/Sidenav/sgds-sidenav-link.ts +8 -0
- package/src/Sidenav/sgds-sidenav.scss +6 -0
- package/src/Sidenav/sgds-sidenav.ts +33 -0
- package/src/Tab/index.ts +3 -0
- package/src/Tab/sgds-tab.scss +84 -0
- package/src/Tab/sgds-tab.ts +87 -0
- package/src/Tab/sgds-tabgroup.scss +198 -0
- package/src/Tab/sgds-tabgroup.ts +295 -0
- package/src/Tab/sgds-tabpanel.scss +12 -0
- package/src/Tab/sgds-tabpanel.ts +55 -0
- package/src/Textarea/index.ts +1 -0
- package/src/Textarea/sgds-textarea.scss +23 -0
- package/src/Textarea/sgds-textarea.ts +201 -0
- package/src/index.ts +16 -0
- package/src/utils/animate.ts +69 -0
- package/src/utils/animation-registry.ts +71 -0
- package/src/utils/base.scss +14 -0
- package/src/utils/breakpoints.ts +5 -0
- package/src/utils/card-element.ts +42 -0
- package/src/utils/components.style.scss +531 -0
- package/src/utils/defaultvalue.ts +51 -0
- package/src/utils/dropdown-element.ts +244 -0
- package/src/utils/event.ts +13 -0
- package/src/utils/form.ts +183 -0
- package/src/utils/generateId.ts +4 -0
- package/src/utils/link-element.ts +34 -0
- package/src/utils/mergeDeep.ts +22 -0
- package/src/utils/modal.ts +64 -0
- package/src/utils/object.ts +2 -0
- package/src/utils/offset.ts +6 -0
- package/src/utils/scroll.ts +57 -0
- package/src/utils/sgds-element.ts +18 -0
- package/src/utils/slot.ts +102 -0
- package/src/utils/tabbable.ts +81 -0
- package/src/utils/watch.ts +62 -0
- package/stories/ActionCard.stories.mdx +199 -0
- package/stories/Button.stories.mdx +194 -0
- package/stories/Checkbox.stories.mdx +196 -0
- package/stories/Dropdown.stories.mdx +152 -0
- package/stories/Footer.stories.mdx +261 -0
- package/stories/Input.stories.mdx +236 -0
- package/stories/MainNav.stories.mdx +169 -0
- package/stories/Masthead.stories.mdx +112 -0
- package/stories/Modal.stories.mdx +103 -0
- package/stories/QuantityToggle.stories.mdx +97 -0
- package/stories/Radio.stories.mdx +262 -0
- package/stories/Sample.stories.js +29 -0
- package/stories/Sample.stories.mdx +33 -0
- package/stories/SideNav.stories.mdx +245 -0
- package/stories/common.js +185 -0
- package/stories/textarea.stories.mdx +253 -0
- package/test/button.element.test.ts +185 -0
- package/test/checkbox.test.ts +240 -0
- package/test/dropdown.test.ts +637 -0
- package/test/footer.test.ts +181 -0
- package/test/generateId.test.ts +18 -0
- package/test/input.element.test.ts +316 -0
- package/test/link-element.test.ts +38 -0
- package/test/mainnav.test.ts +313 -0
- package/test/masthead.test.ts +116 -0
- package/test/modal.test.ts +149 -0
- package/test/quantitytoggle.test.ts +76 -0
- package/test/radio.test.ts +310 -0
- package/test/selectable-card.test.ts +159 -0
- package/test/sidenav.test.ts +390 -0
- package/test/tab.test.ts +76 -0
- package/test/textarea.test.ts +126 -0
- package/tsconfig.json +26 -0
- package/tsconfig.test.json +24 -0
- package/typings/scss.d.ts +5 -0
- package/web-dev-server.config.mjs +7 -0
- package/web-test-runner.config.mjs +47 -0
- package/Button/index.js.map +0 -1
- package/Button/sgds-button.d.ts +0 -23
- package/Footer/index.js.map +0 -1
- package/Mainnav/index.js.map +0 -1
- package/Mainnav/sgds-mainnav-item.d.ts +0 -7
- package/Masthead/index.js.map +0 -1
- package/Sidenav/index.js.map +0 -1
- package/Sidenav/sgds-sidenav-link.d.ts +0 -7
- package/index.d.ts +0 -5
- package/index.js.map +0 -1
- package/umd/index.js +0 -52092
- package/umd/index.js.map +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { property, state } from "lit/decorators.js";
|
|
2
|
+
import { Dropdown } from "bootstrap";
|
|
3
|
+
import * as Popper from "@popperjs/core";
|
|
4
|
+
import type { StrictModifiers } from "@popperjs/core";
|
|
5
|
+
import { createRef, Ref } from "lit/directives/ref.js";
|
|
6
|
+
import mergeDeep from "./mergeDeep";
|
|
7
|
+
import genId from "./generateId";
|
|
8
|
+
import { SgdsDropdownItem } from "../Dropdown/sgds-dropdown-item";
|
|
9
|
+
import SgdsElement from "./sgds-element";
|
|
10
|
+
|
|
11
|
+
const ARROW_DOWN = "ArrowDown";
|
|
12
|
+
const ARROW_UP = "ArrowUp";
|
|
13
|
+
const ESC = "Escape";
|
|
14
|
+
const ENTER = "Enter";
|
|
15
|
+
const TAB = "Tab";
|
|
16
|
+
|
|
17
|
+
export type DropdownButtonVariant =
|
|
18
|
+
| "primary"
|
|
19
|
+
| "secondary"
|
|
20
|
+
| "success"
|
|
21
|
+
| "danger"
|
|
22
|
+
| "warning"
|
|
23
|
+
| "info"
|
|
24
|
+
| "light"
|
|
25
|
+
| "dark";
|
|
26
|
+
export type DropDirection = "left" | "right" | "up" | "down";
|
|
27
|
+
|
|
28
|
+
export class DropdownElement extends SgdsElement {
|
|
29
|
+
myDropdown: Ref<HTMLElement> = createRef();
|
|
30
|
+
bsDropdown: Dropdown = null;
|
|
31
|
+
|
|
32
|
+
@property({ type: Boolean, reflect: true })
|
|
33
|
+
noFlip = false;
|
|
34
|
+
@property({ type: Boolean, reflect: true })
|
|
35
|
+
menuAlignRight = false;
|
|
36
|
+
@property({ type: String, reflect: true })
|
|
37
|
+
drop: DropDirection = "down";
|
|
38
|
+
@property({ type: Object })
|
|
39
|
+
popperOpts = {};
|
|
40
|
+
@property({ type: String })
|
|
41
|
+
togglerId = genId("dropdown", "button");
|
|
42
|
+
|
|
43
|
+
@property({ type: String })
|
|
44
|
+
togglerText = "";
|
|
45
|
+
@property({ type: String })
|
|
46
|
+
variant: DropdownButtonVariant = "secondary";
|
|
47
|
+
|
|
48
|
+
@property({ type: Boolean })
|
|
49
|
+
menuIsOpen = false;
|
|
50
|
+
|
|
51
|
+
@property({ type: String })
|
|
52
|
+
close: "outside" | "default" | "inside" = "default";
|
|
53
|
+
|
|
54
|
+
@property({ type: Boolean, reflect: true })
|
|
55
|
+
disabled = false;
|
|
56
|
+
|
|
57
|
+
@state()
|
|
58
|
+
nextDropdownItemNo: number = 0;
|
|
59
|
+
@state()
|
|
60
|
+
prevDropdownItemNo: number = -1;
|
|
61
|
+
@state()
|
|
62
|
+
dropdownConfig: Partial<Popper.Options>;
|
|
63
|
+
@state()
|
|
64
|
+
modifierOpt: StrictModifiers[] = [];
|
|
65
|
+
|
|
66
|
+
firstUpdated() {
|
|
67
|
+
this.bsDropdown = new Dropdown(this.myDropdown.value, {
|
|
68
|
+
// autoClose not working as bootstrap is using attribute data-bs-toggle="dropdown" to configure autoclose. But it doesnt look into this attribute in the shadow dom
|
|
69
|
+
reference: "toggle", // working
|
|
70
|
+
popperConfig: (defaultConfig?: Partial<Popper.Options>) => {
|
|
71
|
+
//working
|
|
72
|
+
this.dropdownConfig = {
|
|
73
|
+
placement: "bottom-start",
|
|
74
|
+
modifiers: !this.noFlip
|
|
75
|
+
? this.modifierOpt
|
|
76
|
+
: [
|
|
77
|
+
...this.modifierOpt,
|
|
78
|
+
{
|
|
79
|
+
name: "flip",
|
|
80
|
+
options: { fallbackPlacements: [] },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
switch (this.drop) {
|
|
86
|
+
case "up":
|
|
87
|
+
this.dropdownConfig.placement = this.menuAlignRight
|
|
88
|
+
? "top-end"
|
|
89
|
+
: "top-start";
|
|
90
|
+
break;
|
|
91
|
+
case "right":
|
|
92
|
+
this.dropdownConfig.placement = "right-start";
|
|
93
|
+
break;
|
|
94
|
+
case "left":
|
|
95
|
+
this.dropdownConfig.placement = "left-start";
|
|
96
|
+
break;
|
|
97
|
+
case "down":
|
|
98
|
+
this.dropdownConfig.placement = this.menuAlignRight
|
|
99
|
+
? "bottom-end"
|
|
100
|
+
: "bottom-start";
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
this.dropdownConfig.placement = undefined;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return mergeDeep(
|
|
107
|
+
defaultConfig,
|
|
108
|
+
mergeDeep(this.dropdownConfig, this.popperOpts)
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
this.myDropdown.value.addEventListener("show.bs.dropdown", () => {
|
|
113
|
+
this.menuIsOpen = true;
|
|
114
|
+
this.emit("sgds-show");
|
|
115
|
+
});
|
|
116
|
+
this.myDropdown.value.addEventListener("shown.bs.dropdown", () => {
|
|
117
|
+
this.menuIsOpen = true;
|
|
118
|
+
this.emit("sgds-shown");
|
|
119
|
+
});
|
|
120
|
+
this.myDropdown.value.addEventListener("hide.bs.dropdown", () => {
|
|
121
|
+
this.menuIsOpen = false;
|
|
122
|
+
this._resetMenu();
|
|
123
|
+
this.emit("sgds-hide");
|
|
124
|
+
});
|
|
125
|
+
this.myDropdown.value.addEventListener("hidden.bs.dropdown", () => {
|
|
126
|
+
this.menuIsOpen = false;
|
|
127
|
+
this.emit("sgds-hidden");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this.addEventListener("keydown", this._handleKeyboardEvent);
|
|
131
|
+
if (this.close !== "inside") {
|
|
132
|
+
this.addEventListener("blur", (e) => {
|
|
133
|
+
return e.relatedTarget == null
|
|
134
|
+
? this.bsDropdown.hide()
|
|
135
|
+
: e.stopPropagation();
|
|
136
|
+
});
|
|
137
|
+
addEventListener("click", (e) => this._handleClickOutOfElement(e, this));
|
|
138
|
+
}
|
|
139
|
+
if (this.menuIsOpen) this.bsDropdown.show();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public showMenu() {
|
|
143
|
+
this.bsDropdown.show();
|
|
144
|
+
}
|
|
145
|
+
public hideMenu() {
|
|
146
|
+
this.bsDropdown.hide();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_onClickButton() {
|
|
150
|
+
this.bsDropdown.toggle();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_resetMenu() {
|
|
154
|
+
this.nextDropdownItemNo = 0;
|
|
155
|
+
this.prevDropdownItemNo = -1;
|
|
156
|
+
// reset the tabindex
|
|
157
|
+
const items = this._getMenuItems();
|
|
158
|
+
items.forEach((i) => {
|
|
159
|
+
i.removeAttribute("tabindex");
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_getMenuItems(): SgdsDropdownItem[] {
|
|
164
|
+
return this.shadowRoot
|
|
165
|
+
.querySelector("slot")
|
|
166
|
+
.assignedElements({ flatten: true }) as SgdsDropdownItem[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_getActiveMenuItems(): SgdsDropdownItem[] {
|
|
170
|
+
return this._getMenuItems().filter((item) => !item.disabled);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_setMenuItem(currentItemIdx: number, isArrowDown: boolean = true) {
|
|
174
|
+
const items = this._getActiveMenuItems();
|
|
175
|
+
if (items.length === 0) return;
|
|
176
|
+
let item = items[currentItemIdx];
|
|
177
|
+
this.nextDropdownItemNo = currentItemIdx + 1;
|
|
178
|
+
this.prevDropdownItemNo =
|
|
179
|
+
currentItemIdx - 1 < 0 ? items.length - 1 : currentItemIdx - 1;
|
|
180
|
+
let activeItem: SgdsDropdownItem;
|
|
181
|
+
if (item.disabled) {
|
|
182
|
+
return this._setMenuItem(
|
|
183
|
+
isArrowDown ? this.nextDropdownItemNo : this.prevDropdownItemNo
|
|
184
|
+
);
|
|
185
|
+
} else activeItem = item;
|
|
186
|
+
|
|
187
|
+
// focus or blur items depending on active or not
|
|
188
|
+
items.forEach((i) => {
|
|
189
|
+
i.setAttribute("tabindex", i === activeItem ? "0" : "-1");
|
|
190
|
+
i === activeItem ? i.focus() : i.blur();
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
_handleSelectSlot(e: KeyboardEvent | MouseEvent) {
|
|
195
|
+
const items = this._getActiveMenuItems();
|
|
196
|
+
const currentItemNo = items.indexOf(e.target as SgdsDropdownItem);
|
|
197
|
+
this.nextDropdownItemNo = currentItemNo + 1;
|
|
198
|
+
this.prevDropdownItemNo =
|
|
199
|
+
currentItemNo <= 0 ? items.length - 1 : currentItemNo - 1;
|
|
200
|
+
|
|
201
|
+
// assign selected dropdown-item value to sgds-dropdown value
|
|
202
|
+
const selectedItem = e.target as SgdsDropdownItem;
|
|
203
|
+
if (!selectedItem.disabled) {
|
|
204
|
+
this.emit("sgds-select");
|
|
205
|
+
this.close !== "outside" && this.bsDropdown.hide();
|
|
206
|
+
} else return;
|
|
207
|
+
}
|
|
208
|
+
_handleKeyboardEvent(e: KeyboardEvent) {
|
|
209
|
+
const menuItems = this._getActiveMenuItems();
|
|
210
|
+
switch (e.key) {
|
|
211
|
+
case ARROW_DOWN:
|
|
212
|
+
if (!this.menuIsOpen) return this.bsDropdown.show();
|
|
213
|
+
if (this.nextDropdownItemNo === menuItems.length) {
|
|
214
|
+
return this._setMenuItem(0);
|
|
215
|
+
} else {
|
|
216
|
+
return this._setMenuItem(
|
|
217
|
+
this.nextDropdownItemNo > 0 ? this.nextDropdownItemNo : 0
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
case ARROW_UP:
|
|
221
|
+
if (!this.menuIsOpen) return this.bsDropdown.show();
|
|
222
|
+
if (this.prevDropdownItemNo < 0) {
|
|
223
|
+
return this._setMenuItem(menuItems.length - 1, false);
|
|
224
|
+
} else {
|
|
225
|
+
return this._setMenuItem(this.prevDropdownItemNo, false);
|
|
226
|
+
}
|
|
227
|
+
case ESC:
|
|
228
|
+
return this.bsDropdown.hide();
|
|
229
|
+
case ENTER:
|
|
230
|
+
if (menuItems.includes(e.target as SgdsDropdownItem)) {
|
|
231
|
+
return this._handleSelectSlot(e);
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
_handleClickOutOfElement(e: MouseEvent, self: DropdownElement) {
|
|
240
|
+
if (!e.composedPath().includes(self)) {
|
|
241
|
+
this.bsDropdown.hide();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Waits for a specific event to be emitted from an element. Ignores events that bubble up from child elements. */
|
|
2
|
+
export function waitForEvent(el: HTMLElement, eventName: string) {
|
|
3
|
+
return new Promise<void>(resolve => {
|
|
4
|
+
function done(event: Event) {
|
|
5
|
+
if (event.target === el) {
|
|
6
|
+
el.removeEventListener(eventName, done);
|
|
7
|
+
resolve();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
el.addEventListener(eventName, done);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type SgdsButton from '../Button/sgds-button';
|
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
3
|
+
|
|
4
|
+
const reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();
|
|
5
|
+
|
|
6
|
+
export interface FormSubmitControllerOptions {
|
|
7
|
+
/** A function that returns the form containing the form control. */
|
|
8
|
+
form: (input: unknown) => HTMLFormElement | null;
|
|
9
|
+
/** A function that returns the form control's name, which will be submitted with the form data. */
|
|
10
|
+
name: (input: unknown) => string;
|
|
11
|
+
/** A function that returns the form control's current value. */
|
|
12
|
+
value: (input: unknown) => unknown | unknown[];
|
|
13
|
+
/** A function that returns the form control's default value. */
|
|
14
|
+
defaultValue: (input: unknown) => unknown | unknown[];
|
|
15
|
+
/** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */
|
|
16
|
+
disabled: (input: unknown) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A function that maps to the form control's reportValidity() function. When the control is invalid, this will
|
|
19
|
+
* prevent submission and trigger the browser's constraint violation warning.
|
|
20
|
+
*/
|
|
21
|
+
reportValidity: (input: unknown) => boolean;
|
|
22
|
+
|
|
23
|
+
/** A function that sets the form control's value */
|
|
24
|
+
setValue: (input: unknown, value: unknown) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class FormSubmitController implements ReactiveController {
|
|
28
|
+
host?: ReactiveControllerHost & Element;
|
|
29
|
+
form?: HTMLFormElement | null;
|
|
30
|
+
options: FormSubmitControllerOptions;
|
|
31
|
+
|
|
32
|
+
constructor(host: ReactiveControllerHost & Element, options?: Partial<FormSubmitControllerOptions>) {
|
|
33
|
+
(this.host = host).addController(this);
|
|
34
|
+
this.options = {
|
|
35
|
+
form: (input: HTMLInputElement) => input.closest('form'),
|
|
36
|
+
name: (input: HTMLInputElement) => input.name,
|
|
37
|
+
value: (input: HTMLInputElement) => input.value,
|
|
38
|
+
defaultValue: (input: HTMLInputElement) => input.defaultValue,
|
|
39
|
+
disabled: (input: HTMLInputElement) => input.disabled,
|
|
40
|
+
reportValidity: (input: HTMLInputElement) => {
|
|
41
|
+
return typeof input.reportValidity === 'function' ? input.reportValidity() : true;
|
|
42
|
+
},
|
|
43
|
+
setValue: (input: HTMLInputElement, value: string) => {
|
|
44
|
+
input.value = value;
|
|
45
|
+
},
|
|
46
|
+
...options
|
|
47
|
+
};
|
|
48
|
+
this.handleFormData = this.handleFormData.bind(this);
|
|
49
|
+
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
50
|
+
this.handleFormReset = this.handleFormReset.bind(this);
|
|
51
|
+
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
hostConnected() {
|
|
55
|
+
this.form = this.options.form(this.host);
|
|
56
|
+
|
|
57
|
+
if (this.form) {
|
|
58
|
+
this.form.addEventListener('formdata', this.handleFormData);
|
|
59
|
+
this.form.addEventListener('submit', this.handleFormSubmit);
|
|
60
|
+
this.form.addEventListener('reset', this.handleFormReset);
|
|
61
|
+
|
|
62
|
+
// Overload the form's reportValidity() method so it looks at Shoelace form controls
|
|
63
|
+
if (!reportValidityOverloads.has(this.form)) {
|
|
64
|
+
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
65
|
+
this.form.reportValidity = () => this.reportFormValidity();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
hostDisconnected() {
|
|
71
|
+
if (this.form) {
|
|
72
|
+
this.form.removeEventListener('formdata', this.handleFormData);
|
|
73
|
+
this.form.removeEventListener('submit', this.handleFormSubmit);
|
|
74
|
+
this.form.removeEventListener('reset', this.handleFormReset);
|
|
75
|
+
|
|
76
|
+
// Remove the overload and restore the original method
|
|
77
|
+
if (reportValidityOverloads.has(this.form)) {
|
|
78
|
+
this.form.reportValidity = reportValidityOverloads.get(this.form)!;
|
|
79
|
+
reportValidityOverloads.delete(this.form);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.form = undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
handleFormData(event: FormDataEvent) {
|
|
87
|
+
const disabled = this.options.disabled(this.host);
|
|
88
|
+
const name = this.options.name(this.host);
|
|
89
|
+
const value = this.options.value(this.host);
|
|
90
|
+
|
|
91
|
+
if (!disabled && typeof name === 'string' && typeof value !== 'undefined') {
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
(value as unknown[]).forEach(val => {
|
|
94
|
+
event.formData.append(name, (val as string | number | boolean).toString());
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
event.formData.append(name, (value as string | number | boolean).toString());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
handleFormSubmit(event: Event) {
|
|
103
|
+
const disabled = this.options.disabled(this.host);
|
|
104
|
+
const reportValidity = this.options.reportValidity;
|
|
105
|
+
|
|
106
|
+
if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
event.stopImmediatePropagation();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
handleFormReset() {
|
|
113
|
+
this.options.setValue(this.host, this.options.defaultValue(this.host));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
reportFormValidity() {
|
|
117
|
+
//
|
|
118
|
+
// Shoelace form controls work hard to act like regular form controls. They support the Constraint Validation API
|
|
119
|
+
// and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
|
|
120
|
+
// has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
|
|
121
|
+
// ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
|
|
122
|
+
//
|
|
123
|
+
// We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
|
|
124
|
+
// validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
|
|
125
|
+
// be necessary once we can use ElementInternals.
|
|
126
|
+
//
|
|
127
|
+
// Note that we're also honoring the form's novalidate attribute.
|
|
128
|
+
//
|
|
129
|
+
if (this.form && !this.form.noValidate) {
|
|
130
|
+
// This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
|
|
131
|
+
// elements that support the constraint validation API.
|
|
132
|
+
const elements = this.form.querySelectorAll<HTMLInputElement>('*');
|
|
133
|
+
|
|
134
|
+
for (const element of elements) {
|
|
135
|
+
if (typeof element.reportValidity === 'function') {
|
|
136
|
+
if (!element.reportValidity()) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
doAction(type: 'submit' | 'reset', invoker?: HTMLInputElement | SgdsButton) {
|
|
147
|
+
if (this.form) {
|
|
148
|
+
const button = document.createElement('button');
|
|
149
|
+
button.type = type;
|
|
150
|
+
button.style.position = 'absolute';
|
|
151
|
+
button.style.width = '0';
|
|
152
|
+
button.style.height = '0';
|
|
153
|
+
button.style.clipPath = 'inset(50%)';
|
|
154
|
+
button.style.overflow = 'hidden';
|
|
155
|
+
button.style.whiteSpace = 'nowrap';
|
|
156
|
+
|
|
157
|
+
// Pass form attributes through to the temporary button
|
|
158
|
+
if (invoker) {
|
|
159
|
+
['formaction', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {
|
|
160
|
+
if (invoker.hasAttribute(attr)) {
|
|
161
|
+
button.setAttribute(attr, invoker.getAttribute(attr)!);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.form.append(button);
|
|
167
|
+
button.click();
|
|
168
|
+
button.remove();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Resets the form, restoring all the control to their default value */
|
|
173
|
+
reset(invoker?: HTMLInputElement | SgdsButton) {
|
|
174
|
+
this.doAction('reset', invoker);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Submits the form, triggering validation and form data injection. */
|
|
178
|
+
submit(invoker?: HTMLInputElement | SgdsButton) {
|
|
179
|
+
// Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
|
|
180
|
+
// native submit button into the form, "click" it, then remove it to simulate a standard form submission.
|
|
181
|
+
this.doAction('submit', invoker);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import SgdsElement from "../utils/sgds-element";
|
|
3
|
+
import { property } from "lit/decorators.js";
|
|
4
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
5
|
+
|
|
6
|
+
export default class LinkElement extends SgdsElement {
|
|
7
|
+
|
|
8
|
+
@property({ type: Boolean })
|
|
9
|
+
active = false;
|
|
10
|
+
|
|
11
|
+
@property({ type: String })
|
|
12
|
+
href = "";
|
|
13
|
+
|
|
14
|
+
@property({ type: Boolean, reflect: true })
|
|
15
|
+
disabled = false;
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
return html`
|
|
19
|
+
<li>
|
|
20
|
+
<a
|
|
21
|
+
href="${this.href}"
|
|
22
|
+
class="nav-link ${classMap({
|
|
23
|
+
disabled: this.disabled,
|
|
24
|
+
active: this.active,
|
|
25
|
+
})} "
|
|
26
|
+
?disabled=${this.disabled}
|
|
27
|
+
aria-disabled=${this.disabled ? "true" : "false"}
|
|
28
|
+
><slot></slot
|
|
29
|
+
></a>
|
|
30
|
+
</li>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {assign, keys} from './object'
|
|
2
|
+
function _isObject(item: any) {
|
|
3
|
+
return item && typeof item === 'object' && item.constructor === Object
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const mergeDeep = (target:any, source:any) => {
|
|
7
|
+
if (_isObject(target) && _isObject(source)) {
|
|
8
|
+
keys(source).forEach(key => {
|
|
9
|
+
if (_isObject(source[key])) {
|
|
10
|
+
if (!target[key] || !_isObject(target[key])) {
|
|
11
|
+
target[key] = source[key]
|
|
12
|
+
}
|
|
13
|
+
mergeDeep(target[key], source[key])
|
|
14
|
+
} else {
|
|
15
|
+
assign(target, { [key]: source[key] })
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
return target
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default mergeDeep
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getTabbableBoundary } from './tabbable';
|
|
2
|
+
|
|
3
|
+
let activeModals: HTMLElement[] = [];
|
|
4
|
+
|
|
5
|
+
export default class Modal {
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
tabDirection: 'forward' | 'backward' = 'forward';
|
|
8
|
+
|
|
9
|
+
constructor(element: HTMLElement) {
|
|
10
|
+
this.element = element;
|
|
11
|
+
this.handleFocusIn = this.handleFocusIn.bind(this);
|
|
12
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
13
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
activate() {
|
|
17
|
+
activeModals.push(this.element);
|
|
18
|
+
document.addEventListener('focusin', this.handleFocusIn);
|
|
19
|
+
document.addEventListener('keydown', this.handleKeyDown);
|
|
20
|
+
document.addEventListener('keyup', this.handleKeyUp);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
deactivate() {
|
|
24
|
+
activeModals = activeModals.filter(modal => modal !== this.element);
|
|
25
|
+
document.removeEventListener('focusin', this.handleFocusIn);
|
|
26
|
+
document.removeEventListener('keydown', this.handleKeyDown);
|
|
27
|
+
document.removeEventListener('keyup', this.handleKeyUp);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
isActive() {
|
|
31
|
+
// The "active" modal is always the most recent one shown
|
|
32
|
+
return activeModals[activeModals.length - 1] === this.element;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
checkFocus() {
|
|
36
|
+
if (this.isActive()) {
|
|
37
|
+
if (!this.element.matches(':focus-within')) {
|
|
38
|
+
const { start, end } = getTabbableBoundary(this.element);
|
|
39
|
+
const target = this.tabDirection === 'forward' ? start : end;
|
|
40
|
+
|
|
41
|
+
if (typeof target?.focus === 'function') {
|
|
42
|
+
target.focus({ preventScroll: true });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
handleFocusIn() {
|
|
49
|
+
this.checkFocus();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
handleKeyDown(event: KeyboardEvent) {
|
|
53
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
54
|
+
this.tabDirection = 'backward';
|
|
55
|
+
|
|
56
|
+
// Ensure focus remains trapped after the key is pressed
|
|
57
|
+
requestAnimationFrame(() => this.checkFocus());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
handleKeyUp() {
|
|
62
|
+
this.tabDirection = 'forward';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function getOffset(element: HTMLElement, parent: HTMLElement) {
|
|
2
|
+
return {
|
|
3
|
+
top: Math.round(element.getBoundingClientRect().top - parent.getBoundingClientRect().top),
|
|
4
|
+
left: Math.round(element.getBoundingClientRect().left - parent.getBoundingClientRect().left)
|
|
5
|
+
};
|
|
6
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getOffset } from './offset';
|
|
2
|
+
|
|
3
|
+
const locks = new Set();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Prevents body scrolling. Keeps track of which elements requested a lock so multiple levels of locking are possible
|
|
7
|
+
* without premature unlocking.
|
|
8
|
+
*/
|
|
9
|
+
export function lockBodyScrolling(lockingEl: HTMLElement) {
|
|
10
|
+
locks.add(lockingEl);
|
|
11
|
+
document.body.classList.add('sl-scroll-lock');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Unlocks body scrolling. Scrolling will only be unlocked once all elements that requested a lock call this method.
|
|
16
|
+
*/
|
|
17
|
+
export function unlockBodyScrolling(lockingEl: HTMLElement) {
|
|
18
|
+
locks.delete(lockingEl);
|
|
19
|
+
|
|
20
|
+
if (locks.size === 0) {
|
|
21
|
+
document.body.classList.remove('sl-scroll-lock');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Scrolls an element into view of its container. If the element is already in view, nothing will happen.
|
|
27
|
+
*/
|
|
28
|
+
export function scrollIntoView(
|
|
29
|
+
element: HTMLElement,
|
|
30
|
+
container: HTMLElement,
|
|
31
|
+
direction: 'horizontal' | 'vertical' | 'both' = 'vertical',
|
|
32
|
+
behavior: 'smooth' | 'auto' = 'smooth'
|
|
33
|
+
) {
|
|
34
|
+
const offset = getOffset(element, container);
|
|
35
|
+
const offsetTop = offset.top + container.scrollTop;
|
|
36
|
+
const offsetLeft = offset.left + container.scrollLeft;
|
|
37
|
+
const minX = container.scrollLeft;
|
|
38
|
+
const maxX = container.scrollLeft + container.offsetWidth;
|
|
39
|
+
const minY = container.scrollTop;
|
|
40
|
+
const maxY = container.scrollTop + container.offsetHeight;
|
|
41
|
+
|
|
42
|
+
if (direction === 'horizontal' || direction === 'both') {
|
|
43
|
+
if (offsetLeft < minX) {
|
|
44
|
+
container.scrollTo({ left: offsetLeft, behavior });
|
|
45
|
+
} else if (offsetLeft + element.clientWidth > maxX) {
|
|
46
|
+
container.scrollTo({ left: offsetLeft - container.offsetWidth + element.clientWidth, behavior });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (direction === 'vertical' || direction === 'both') {
|
|
51
|
+
if (offsetTop < minY) {
|
|
52
|
+
container.scrollTo({ top: offsetTop, behavior });
|
|
53
|
+
} else if (offsetTop + element.clientHeight > maxY) {
|
|
54
|
+
container.scrollTo({ top: offsetTop - container.offsetHeight + element.clientHeight, behavior });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default class SgdsElement extends LitElement {
|
|
4
|
+
/** Emits a custom event with more convenient defaults. */
|
|
5
|
+
emit(name: string, options?: CustomEventInit) {
|
|
6
|
+
const event = new CustomEvent(name, {
|
|
7
|
+
bubbles: true,
|
|
8
|
+
cancelable: false,
|
|
9
|
+
composed: true,
|
|
10
|
+
detail: {},
|
|
11
|
+
...options
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
this.dispatchEvent(event);
|
|
15
|
+
|
|
16
|
+
return event;
|
|
17
|
+
}
|
|
18
|
+
}
|