@govtechsg/sgds-web-component 1.0.0-rc.4 → 1.0.0-rc.5
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/base/dropdown-element.cjs.js +3 -0
- package/base/dropdown-element.cjs.js.map +1 -1
- package/base/dropdown-element.d.ts +2 -0
- package/base/dropdown-element.js +3 -0
- package/base/dropdown-element.js.map +1 -1
- package/components/ComboBox/index.umd.js +11 -5
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.cjs.js +5 -1
- package/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.js +5 -1
- package/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/components/Datepicker/index.umd.js +9 -3
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs.js +5 -1
- package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.js +5 -1
- package/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/components/Dropdown/index.umd.js +8 -4
- package/components/Dropdown/index.umd.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.cjs.js +2 -0
- package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.js +2 -0
- package/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/components/Mainnav/index.umd.js +2 -0
- package/components/Mainnav/index.umd.js.map +1 -1
- package/components/index.umd.js +14 -2
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +14 -2
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ var decorators_js = require('lit/decorators.js');
|
|
|
8
8
|
var ref_js = require('lit/directives/ref.js');
|
|
9
9
|
var mergeDeep = require('../utils/mergeDeep.cjs.js');
|
|
10
10
|
var sgdsElement = require('./sgds-element.cjs.js');
|
|
11
|
+
var generateId = require('../utils/generateId.cjs.js');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -30,6 +31,8 @@ class DropdownElement extends sgdsElement["default"] {
|
|
|
30
31
|
this.myDropdown = ref_js.createRef();
|
|
31
32
|
/** @internal */
|
|
32
33
|
this.bsDropdown = null;
|
|
34
|
+
/** @internal Unique id generated for the dropdown menu */
|
|
35
|
+
this.dropdownMenuId = generateId["default"]("dropdown-menu", "ul");
|
|
33
36
|
/** @internal Controls auto-flipping of menu */
|
|
34
37
|
this.noFlip = false;
|
|
35
38
|
/** @internal When true, aligns right edge of menu with right edge of button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-element.cjs.js","sources":["../../src/base/dropdown-element.ts"],"sourcesContent":["import type { StrictModifiers } from \"@popperjs/core\";\nimport * as Popper from \"@popperjs/core\";\nimport Dropdown from \"bootstrap/js/src/dropdown\";\nimport type { Dropdown as BsDropdown } from \"bootstrap\";\nimport { property, state } from \"lit/decorators.js\";\nimport { Ref, createRef } from \"lit/directives/ref.js\";\nimport mergeDeep from \"../utils/mergeDeep\";\nimport SgdsElement from \"./sgds-element\";\n\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_UP = \"ArrowUp\";\nconst ESC = \"Escape\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * @event sgds-show - Emitted event when show instance is called\n * @event sgds-after-show - Emitted event when dropdown has been made visible to the user and CSS transitions have completed\n * @event sgds-hide - Emitted event when hide instance is called\n * @event sgds-after-hide - Emitted event when dropdown has hidden to the user and CSS transitions have completed\n * @event sgds-select - Emitted event when a slot item is selected\n */\n\nexport class DropdownElement extends SgdsElement {\n static styles = SgdsElement.styles;\n\n /** @internal */\n protected myDropdown: Ref<HTMLElement> = createRef();\n /** @internal */\n protected bsDropdown: BsDropdown = null;\n\n /** @internal Controls auto-flipping of menu */\n @property({ type: Boolean, state: true })\n protected noFlip = false;\n\n /** @internal When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: true })\n protected menuAlignRight = false;\n\n /** @internal The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: true })\n protected drop: DropDirection = \"down\";\n\n /** Additional configuration to pass to Popper.js. See https://popper.js.org/ for config opts */\n @property({ type: Object })\n popperOpts = {};\n\n /** @internal */\n @state()\n dropdownConfig: Partial<Popper.Options>;\n /** @internal */\n @state()\n modifierOpt: StrictModifiers[] = [];\n\n /** When true, dropdown menu shows on first load */\n @property({ type: Boolean, reflect: true })\n menuIsOpen = false;\n\n /** Controls the close behaviour of dropdown menu. By default menu auto-closes when SgdsDropdownItem or area outside dropdown is clicked */\n @property({ type: String })\n close: \"outside\" | \"default\" | \"inside\" = \"default\";\n\n /** Disables the dropdown toggle */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.close !== \"inside\") {\n document.addEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n document.removeEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n\n firstUpdated() {\n this.bsDropdown = new Dropdown(this.myDropdown.value, {\n // 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\n reference: \"toggle\", // working\n popperConfig: (defaultConfig?: Partial<Popper.Options>) => {\n //working\n this.dropdownConfig = {\n placement: \"bottom-start\",\n modifiers: !this.noFlip\n ? this.modifierOpt\n : [\n ...this.modifierOpt,\n {\n name: \"flip\",\n options: { fallbackPlacements: [] }\n }\n ]\n };\n\n switch (this.drop) {\n case \"up\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"top-end\" : \"top-start\";\n break;\n case \"right\":\n this.dropdownConfig.placement = \"right-start\";\n break;\n case \"left\":\n this.dropdownConfig.placement = \"left-start\";\n break;\n case \"down\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"bottom-end\" : \"bottom-start\";\n break;\n default:\n this.dropdownConfig.placement = undefined;\n break;\n }\n return mergeDeep(defaultConfig, mergeDeep(this.dropdownConfig, this.popperOpts));\n }\n });\n\n this.myDropdown.value.addEventListener(\"show.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-show\");\n });\n\n this.myDropdown.value.addEventListener(\"shown.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-after-show\");\n });\n\n this.myDropdown.value.addEventListener(\"hide.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-hide\");\n });\n\n this.myDropdown.value.addEventListener(\"hidden.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-after-hide\");\n });\n\n this.addEventListener(\"keydown\", this._handleKeyboardMenuEvent);\n }\n\n /** When invoked, opens the dropdown menu */\n showMenu() {\n this.bsDropdown.show();\n }\n\n /** When invoked, hides the dropdown menu */\n hideMenu() {\n this.bsDropdown.hide();\n }\n\n toggleMenu() {\n this.bsDropdown.toggle();\n }\n\n private _handleKeyboardMenuEvent(e: KeyboardEvent) {\n switch (e.key) {\n case ARROW_DOWN:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ARROW_UP:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ESC:\n return this.hideMenu();\n default:\n break;\n }\n }\n\n private _handleClickOutOfElement(e: MouseEvent, self: DropdownElement) {\n if (!e.composedPath().includes(self)) {\n this.hideMenu();\n }\n }\n}\n"],"names":["SgdsElement","createRef","Dropdown","mergeDeep","__decorate","property","state"],"mappings":";;;;;;;;;;;;;;;AASA,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIrB;;;;;;AAMG;AAEG,MAAO,eAAgB,SAAQA,sBA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A,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxCF,gBAAA,CAAA;AADC,IAAAE,mBAAK,EAAE;AAC4B,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIpCF,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACxB,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAInBD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACyB,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIpDD,gBAAA,CAAA;IADCC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"dropdown-element.cjs.js","sources":["../../src/base/dropdown-element.ts"],"sourcesContent":["import type { StrictModifiers } from \"@popperjs/core\";\nimport * as Popper from \"@popperjs/core\";\nimport Dropdown from \"bootstrap/js/src/dropdown\";\nimport type { Dropdown as BsDropdown } from \"bootstrap\";\nimport { property, state } from \"lit/decorators.js\";\nimport { Ref, createRef } from \"lit/directives/ref.js\";\nimport mergeDeep from \"../utils/mergeDeep\";\nimport SgdsElement from \"./sgds-element\";\nimport generateId from \"../utils/generateId\";\n\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_UP = \"ArrowUp\";\nconst ESC = \"Escape\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * @event sgds-show - Emitted event when show instance is called\n * @event sgds-after-show - Emitted event when dropdown has been made visible to the user and CSS transitions have completed\n * @event sgds-hide - Emitted event when hide instance is called\n * @event sgds-after-hide - Emitted event when dropdown has hidden to the user and CSS transitions have completed\n * @event sgds-select - Emitted event when a slot item is selected\n */\n\nexport class DropdownElement extends SgdsElement {\n static styles = SgdsElement.styles;\n\n /** @internal */\n protected myDropdown: Ref<HTMLElement> = createRef();\n /** @internal */\n protected bsDropdown: BsDropdown = null;\n\n /** @internal Unique id generated for the dropdown menu */\n protected dropdownMenuId: string = generateId(\"dropdown-menu\", \"ul\");\n\n /** @internal Controls auto-flipping of menu */\n @property({ type: Boolean, state: true })\n protected noFlip = false;\n\n /** @internal When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: true })\n protected menuAlignRight = false;\n\n /** @internal The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: true })\n protected drop: DropDirection = \"down\";\n\n /** Additional configuration to pass to Popper.js. See https://popper.js.org/ for config opts */\n @property({ type: Object })\n popperOpts = {};\n\n /** @internal */\n @state()\n dropdownConfig: Partial<Popper.Options>;\n /** @internal */\n @state()\n modifierOpt: StrictModifiers[] = [];\n\n /** When true, dropdown menu shows on first load */\n @property({ type: Boolean, reflect: true })\n menuIsOpen = false;\n\n /** Controls the close behaviour of dropdown menu. By default menu auto-closes when SgdsDropdownItem or area outside dropdown is clicked */\n @property({ type: String })\n close: \"outside\" | \"default\" | \"inside\" = \"default\";\n\n /** Disables the dropdown toggle */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.close !== \"inside\") {\n document.addEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n document.removeEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n\n firstUpdated() {\n this.bsDropdown = new Dropdown(this.myDropdown.value, {\n // 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\n reference: \"toggle\", // working\n popperConfig: (defaultConfig?: Partial<Popper.Options>) => {\n //working\n this.dropdownConfig = {\n placement: \"bottom-start\",\n modifiers: !this.noFlip\n ? this.modifierOpt\n : [\n ...this.modifierOpt,\n {\n name: \"flip\",\n options: { fallbackPlacements: [] }\n }\n ]\n };\n\n switch (this.drop) {\n case \"up\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"top-end\" : \"top-start\";\n break;\n case \"right\":\n this.dropdownConfig.placement = \"right-start\";\n break;\n case \"left\":\n this.dropdownConfig.placement = \"left-start\";\n break;\n case \"down\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"bottom-end\" : \"bottom-start\";\n break;\n default:\n this.dropdownConfig.placement = undefined;\n break;\n }\n return mergeDeep(defaultConfig, mergeDeep(this.dropdownConfig, this.popperOpts));\n }\n });\n\n this.myDropdown.value.addEventListener(\"show.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-show\");\n });\n\n this.myDropdown.value.addEventListener(\"shown.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-after-show\");\n });\n\n this.myDropdown.value.addEventListener(\"hide.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-hide\");\n });\n\n this.myDropdown.value.addEventListener(\"hidden.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-after-hide\");\n });\n\n this.addEventListener(\"keydown\", this._handleKeyboardMenuEvent);\n }\n\n /** When invoked, opens the dropdown menu */\n showMenu() {\n this.bsDropdown.show();\n }\n\n /** When invoked, hides the dropdown menu */\n hideMenu() {\n this.bsDropdown.hide();\n }\n\n toggleMenu() {\n this.bsDropdown.toggle();\n }\n\n private _handleKeyboardMenuEvent(e: KeyboardEvent) {\n switch (e.key) {\n case ARROW_DOWN:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ARROW_UP:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ESC:\n return this.hideMenu();\n default:\n break;\n }\n }\n\n private _handleClickOutOfElement(e: MouseEvent, self: DropdownElement) {\n if (!e.composedPath().includes(self)) {\n this.hideMenu();\n }\n }\n}\n"],"names":["SgdsElement","createRef","generateId","Dropdown","mergeDeep","__decorate","property","state"],"mappings":";;;;;;;;;;;;;;;;AAUA,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIrB;;;;;;AAMG;AAEG,MAAO,eAAgB,SAAQA,sBAAW,CAAA;AAAhD,IAAA,WAAA,GAAA;;;QAIY,IAAU,CAAA,UAAA,GAAqBC,gBAAS,EAAE,CAAC;;QAE3C,IAAU,CAAA,UAAA,GAAe,IAAI,CAAC;;AAG9B,QAAA,IAAA,CAAA,cAAc,GAAWC,qBAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;;QAI3D,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAIvB,IAAI,CAAA,IAAA,GAAkB,MAAM,CAAC;;QAIvC,IAAU,CAAA,UAAA,GAAG,EAAE,CAAC;;QAOhB,IAAW,CAAA,WAAA,GAAsB,EAAE,CAAC;;QAIpC,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAInB,IAAK,CAAA,KAAA,GAAqC,SAAS,CAAC;;QAIpD,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;KAmHlB;IAjHC,iBAAiB,GAAA;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;AAE1B,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;AAC3B,YAAA,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAiB,KAAK,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACvG,SAAA;KACF;IAED,oBAAoB,GAAA;QAClB,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/** @internal */
|
|
19
19
|
protected bsDropdown: BsDropdown;
|
|
20
|
+
/** @internal Unique id generated for the dropdown menu */
|
|
21
|
+
protected dropdownMenuId: string;
|
|
20
22
|
/** @internal Controls auto-flipping of menu */
|
|
21
23
|
protected noFlip: boolean;
|
|
22
24
|
/** @internal When true, aligns right edge of menu with right edge of button */
|
package/base/dropdown-element.js
CHANGED
|
@@ -4,6 +4,7 @@ import { property, state } from 'lit/decorators.js';
|
|
|
4
4
|
import { createRef } from 'lit/directives/ref.js';
|
|
5
5
|
import mergeDeep from '../utils/mergeDeep.js';
|
|
6
6
|
import SgdsElement from './sgds-element.js';
|
|
7
|
+
import genId from '../utils/generateId.js';
|
|
7
8
|
|
|
8
9
|
const ARROW_DOWN = "ArrowDown";
|
|
9
10
|
const ARROW_UP = "ArrowUp";
|
|
@@ -22,6 +23,8 @@ class DropdownElement extends SgdsElement {
|
|
|
22
23
|
this.myDropdown = createRef();
|
|
23
24
|
/** @internal */
|
|
24
25
|
this.bsDropdown = null;
|
|
26
|
+
/** @internal Unique id generated for the dropdown menu */
|
|
27
|
+
this.dropdownMenuId = genId("dropdown-menu", "ul");
|
|
25
28
|
/** @internal Controls auto-flipping of menu */
|
|
26
29
|
this.noFlip = false;
|
|
27
30
|
/** @internal When true, aligns right edge of menu with right edge of button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-element.js","sources":["../../src/base/dropdown-element.ts"],"sourcesContent":["import type { StrictModifiers } from \"@popperjs/core\";\nimport * as Popper from \"@popperjs/core\";\nimport Dropdown from \"bootstrap/js/src/dropdown\";\nimport type { Dropdown as BsDropdown } from \"bootstrap\";\nimport { property, state } from \"lit/decorators.js\";\nimport { Ref, createRef } from \"lit/directives/ref.js\";\nimport mergeDeep from \"../utils/mergeDeep\";\nimport SgdsElement from \"./sgds-element\";\n\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_UP = \"ArrowUp\";\nconst ESC = \"Escape\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * @event sgds-show - Emitted event when show instance is called\n * @event sgds-after-show - Emitted event when dropdown has been made visible to the user and CSS transitions have completed\n * @event sgds-hide - Emitted event when hide instance is called\n * @event sgds-after-hide - Emitted event when dropdown has hidden to the user and CSS transitions have completed\n * @event sgds-select - Emitted event when a slot item is selected\n */\n\nexport class DropdownElement extends SgdsElement {\n static styles = SgdsElement.styles;\n\n /** @internal */\n protected myDropdown: Ref<HTMLElement> = createRef();\n /** @internal */\n protected bsDropdown: BsDropdown = null;\n\n /** @internal Controls auto-flipping of menu */\n @property({ type: Boolean, state: true })\n protected noFlip = false;\n\n /** @internal When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: true })\n protected menuAlignRight = false;\n\n /** @internal The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: true })\n protected drop: DropDirection = \"down\";\n\n /** Additional configuration to pass to Popper.js. See https://popper.js.org/ for config opts */\n @property({ type: Object })\n popperOpts = {};\n\n /** @internal */\n @state()\n dropdownConfig: Partial<Popper.Options>;\n /** @internal */\n @state()\n modifierOpt: StrictModifiers[] = [];\n\n /** When true, dropdown menu shows on first load */\n @property({ type: Boolean, reflect: true })\n menuIsOpen = false;\n\n /** Controls the close behaviour of dropdown menu. By default menu auto-closes when SgdsDropdownItem or area outside dropdown is clicked */\n @property({ type: String })\n close: \"outside\" | \"default\" | \"inside\" = \"default\";\n\n /** Disables the dropdown toggle */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.close !== \"inside\") {\n document.addEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n document.removeEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n\n firstUpdated() {\n this.bsDropdown = new Dropdown(this.myDropdown.value, {\n // 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\n reference: \"toggle\", // working\n popperConfig: (defaultConfig?: Partial<Popper.Options>) => {\n //working\n this.dropdownConfig = {\n placement: \"bottom-start\",\n modifiers: !this.noFlip\n ? this.modifierOpt\n : [\n ...this.modifierOpt,\n {\n name: \"flip\",\n options: { fallbackPlacements: [] }\n }\n ]\n };\n\n switch (this.drop) {\n case \"up\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"top-end\" : \"top-start\";\n break;\n case \"right\":\n this.dropdownConfig.placement = \"right-start\";\n break;\n case \"left\":\n this.dropdownConfig.placement = \"left-start\";\n break;\n case \"down\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"bottom-end\" : \"bottom-start\";\n break;\n default:\n this.dropdownConfig.placement = undefined;\n break;\n }\n return mergeDeep(defaultConfig, mergeDeep(this.dropdownConfig, this.popperOpts));\n }\n });\n\n this.myDropdown.value.addEventListener(\"show.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-show\");\n });\n\n this.myDropdown.value.addEventListener(\"shown.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-after-show\");\n });\n\n this.myDropdown.value.addEventListener(\"hide.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-hide\");\n });\n\n this.myDropdown.value.addEventListener(\"hidden.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-after-hide\");\n });\n\n this.addEventListener(\"keydown\", this._handleKeyboardMenuEvent);\n }\n\n /** When invoked, opens the dropdown menu */\n showMenu() {\n this.bsDropdown.show();\n }\n\n /** When invoked, hides the dropdown menu */\n hideMenu() {\n this.bsDropdown.hide();\n }\n\n toggleMenu() {\n this.bsDropdown.toggle();\n }\n\n private _handleKeyboardMenuEvent(e: KeyboardEvent) {\n switch (e.key) {\n case ARROW_DOWN:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ARROW_UP:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ESC:\n return this.hideMenu();\n default:\n break;\n }\n }\n\n private _handleClickOutOfElement(e: MouseEvent, self: DropdownElement) {\n if (!e.composedPath().includes(self)) {\n this.hideMenu();\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIrB;;;;;;AAMG;AAEG,MAAO,eAAgB,SAAQ,WAAW,CAAA;AAAhD,IAAA,WAAA,GAAA;;;QAIY,IAAU,CAAA,UAAA,GAAqB,SAAS,EAAE,CAAC;;QAE3C,IAAU,CAAA,UAAA,GAAe,IAAI,CAAC;;QAI9B,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAIvB,IAAI,CAAA,IAAA,GAAkB,MAAM,CAAC;;QAIvC,IAAU,CAAA,UAAA,GAAG,EAAE,CAAC;;QAOhB,IAAW,CAAA,WAAA,GAAsB,EAAE,CAAC;;QAIpC,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAInB,IAAK,CAAA,KAAA,GAAqC,SAAS,CAAC;;QAIpD,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;KAmHlB;IAjHC,iBAAiB,GAAA;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;AAE1B,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;AAC3B,YAAA,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAiB,KAAK,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACvG,SAAA;KACF;IAED,oBAAoB,GAAA;QAClB,KAAK,CAAC,oBAAoB,EAAE,CAAC;AAE7B,QAAA,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,KAAiB,KA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EAAA,eAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIvC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACX,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIhB,UAAA,CAAA;AADC,IAAA,KAAK,EAAE;AACgC,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxC,UAAA,CAAA;AADC,IAAA,KAAK,EAAE;AAC4B,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIpC,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACxB,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAInB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACyB,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIpD,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAA,EAAA,eAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"dropdown-element.js","sources":["../../src/base/dropdown-element.ts"],"sourcesContent":["import type { StrictModifiers } from \"@popperjs/core\";\nimport * as Popper from \"@popperjs/core\";\nimport Dropdown from \"bootstrap/js/src/dropdown\";\nimport type { Dropdown as BsDropdown } from \"bootstrap\";\nimport { property, state } from \"lit/decorators.js\";\nimport { Ref, createRef } from \"lit/directives/ref.js\";\nimport mergeDeep from \"../utils/mergeDeep\";\nimport SgdsElement from \"./sgds-element\";\nimport generateId from \"../utils/generateId\";\n\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_UP = \"ArrowUp\";\nconst ESC = \"Escape\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * @event sgds-show - Emitted event when show instance is called\n * @event sgds-after-show - Emitted event when dropdown has been made visible to the user and CSS transitions have completed\n * @event sgds-hide - Emitted event when hide instance is called\n * @event sgds-after-hide - Emitted event when dropdown has hidden to the user and CSS transitions have completed\n * @event sgds-select - Emitted event when a slot item is selected\n */\n\nexport class DropdownElement extends SgdsElement {\n static styles = SgdsElement.styles;\n\n /** @internal */\n protected myDropdown: Ref<HTMLElement> = createRef();\n /** @internal */\n protected bsDropdown: BsDropdown = null;\n\n /** @internal Unique id generated for the dropdown menu */\n protected dropdownMenuId: string = generateId(\"dropdown-menu\", \"ul\");\n\n /** @internal Controls auto-flipping of menu */\n @property({ type: Boolean, state: true })\n protected noFlip = false;\n\n /** @internal When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: true })\n protected menuAlignRight = false;\n\n /** @internal The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: true })\n protected drop: DropDirection = \"down\";\n\n /** Additional configuration to pass to Popper.js. See https://popper.js.org/ for config opts */\n @property({ type: Object })\n popperOpts = {};\n\n /** @internal */\n @state()\n dropdownConfig: Partial<Popper.Options>;\n /** @internal */\n @state()\n modifierOpt: StrictModifiers[] = [];\n\n /** When true, dropdown menu shows on first load */\n @property({ type: Boolean, reflect: true })\n menuIsOpen = false;\n\n /** Controls the close behaviour of dropdown menu. By default menu auto-closes when SgdsDropdownItem or area outside dropdown is clicked */\n @property({ type: String })\n close: \"outside\" | \"default\" | \"inside\" = \"default\";\n\n /** Disables the dropdown toggle */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.close !== \"inside\") {\n document.addEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n document.removeEventListener(\"click\", (event: MouseEvent) => this._handleClickOutOfElement(event, this));\n }\n\n firstUpdated() {\n this.bsDropdown = new Dropdown(this.myDropdown.value, {\n // 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\n reference: \"toggle\", // working\n popperConfig: (defaultConfig?: Partial<Popper.Options>) => {\n //working\n this.dropdownConfig = {\n placement: \"bottom-start\",\n modifiers: !this.noFlip\n ? this.modifierOpt\n : [\n ...this.modifierOpt,\n {\n name: \"flip\",\n options: { fallbackPlacements: [] }\n }\n ]\n };\n\n switch (this.drop) {\n case \"up\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"top-end\" : \"top-start\";\n break;\n case \"right\":\n this.dropdownConfig.placement = \"right-start\";\n break;\n case \"left\":\n this.dropdownConfig.placement = \"left-start\";\n break;\n case \"down\":\n this.dropdownConfig.placement = this.menuAlignRight ? \"bottom-end\" : \"bottom-start\";\n break;\n default:\n this.dropdownConfig.placement = undefined;\n break;\n }\n return mergeDeep(defaultConfig, mergeDeep(this.dropdownConfig, this.popperOpts));\n }\n });\n\n this.myDropdown.value.addEventListener(\"show.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-show\");\n });\n\n this.myDropdown.value.addEventListener(\"shown.bs.dropdown\", () => {\n this.menuIsOpen = true;\n this.emit(\"sgds-after-show\");\n });\n\n this.myDropdown.value.addEventListener(\"hide.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-hide\");\n });\n\n this.myDropdown.value.addEventListener(\"hidden.bs.dropdown\", () => {\n this.menuIsOpen = false;\n this.emit(\"sgds-after-hide\");\n });\n\n this.addEventListener(\"keydown\", this._handleKeyboardMenuEvent);\n }\n\n /** When invoked, opens the dropdown menu */\n showMenu() {\n this.bsDropdown.show();\n }\n\n /** When invoked, hides the dropdown menu */\n hideMenu() {\n this.bsDropdown.hide();\n }\n\n toggleMenu() {\n this.bsDropdown.toggle();\n }\n\n private _handleKeyboardMenuEvent(e: KeyboardEvent) {\n switch (e.key) {\n case ARROW_DOWN:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ARROW_UP:\n e.preventDefault();\n if (!this.menuIsOpen) return this.showMenu();\n break;\n case ESC:\n return this.hideMenu();\n default:\n break;\n }\n }\n\n private _handleClickOutOfElement(e: MouseEvent, self: DropdownElement) {\n if (!e.composedPath().includes(self)) {\n this.hideMenu();\n }\n }\n}\n"],"names":["generateId"],"mappings":";;;;;;;;AAUA,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIrB;;;;;;AAMG;AAEG,MAAO,eAAgB,SAAQ,WAAW,CAAA;AAAhD,IAAA,WAAA,GAAA;;;QAIY,IAAU,CAAA,UAAA,GAAqB,SAAS,EAAE,CAAC;;QAE3C,IAAU,CAAA,UAAA,GAAe,IAAI,CAAC;;AAG9B,QAAA,IAAA,CAAA,cAAc,GAAWA,KAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;;QAI3D,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAIvB,IAAI,CAAA,IAAA,GAAkB,MAAM,CAAC;;QAIvC,IAAU,CAAA,UAAA,GAAG,EAAE,CAAC;;QAOhB,IAAW,CAAA,WAAA,GAAsB,EAAE,CAAC;;QAIpC,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAInB,IAAK,CAAA,KAAA,GAAqC,SAAS,CAAC;;QAIpD,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;KAmHlB;IAjHC,iBAAiB,GAAA;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;AAE1B,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AAA,EAAA,eAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -3610,6 +3610,10 @@
|
|
|
3610
3610
|
}
|
|
3611
3611
|
SgdsElement.styles = css_248z$1;
|
|
3612
3612
|
|
|
3613
|
+
function genId (componentName = "", elementName = "") {
|
|
3614
|
+
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3613
3617
|
const ARROW_DOWN$1 = "ArrowDown";
|
|
3614
3618
|
const ARROW_UP$1 = "ArrowUp";
|
|
3615
3619
|
const ESC = "Escape";
|
|
@@ -3627,6 +3631,8 @@
|
|
|
3627
3631
|
this.myDropdown = e$2();
|
|
3628
3632
|
/** @internal */
|
|
3629
3633
|
this.bsDropdown = null;
|
|
3634
|
+
/** @internal Unique id generated for the dropdown menu */
|
|
3635
|
+
this.dropdownMenuId = genId("dropdown-menu", "ul");
|
|
3630
3636
|
/** @internal Controls auto-flipping of menu */
|
|
3631
3637
|
this.noFlip = false;
|
|
3632
3638
|
/** @internal When true, aligns right edge of menu with right edge of button */
|
|
@@ -3956,10 +3962,6 @@
|
|
|
3956
3962
|
}
|
|
3957
3963
|
}
|
|
3958
3964
|
|
|
3959
|
-
function genId (componentName = "", elementName = "") {
|
|
3960
|
-
return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
|
|
3961
|
-
}
|
|
3962
|
-
|
|
3963
3965
|
// @watch decorator
|
|
3964
3966
|
//
|
|
3965
3967
|
// Runs when an observed property changes, e.g. @property or @state, but before the component updates.
|
|
@@ -4433,12 +4435,16 @@
|
|
|
4433
4435
|
?readonly=${this.readonly}
|
|
4434
4436
|
.value=${this.value}
|
|
4435
4437
|
@sgds-input=${this._handleInputChange}
|
|
4438
|
+
role="combobox"
|
|
4439
|
+
aria-expanded=${this.menuIsOpen}
|
|
4440
|
+
aria-autocomplete="list"
|
|
4441
|
+
aria-controls=${this.dropdownMenuId}
|
|
4436
4442
|
>
|
|
4437
4443
|
</sgds-input>
|
|
4438
4444
|
<div class="form-control-icon">
|
|
4439
4445
|
<slot name="icon"></slot>
|
|
4440
4446
|
</div>
|
|
4441
|
-
<ul class="dropdown-menu" part="menu">
|
|
4447
|
+
<ul id=${this.dropdownMenuId} class="dropdown-menu" part="menu" tabindex="-1">
|
|
4442
4448
|
${this.filteredMenuList.map(item => x `<button class="dropdown-item" @click=${this._handleSelectChange}>${item}</button>`)}
|
|
4443
4449
|
</ul>
|
|
4444
4450
|
</div>
|